From 14a392a9da45c2caa7d41d159b7e81560dff4bcc Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Tue, 20 Nov 2018 18:00:13 +0800 Subject: [PATCH] Let header-abi-dumper get lookahead token from preprocessor header-abi-dumper looks ahead one token to determine whether an identifier is a template. This commit makes the dumper get token from preprocessor so as to handle template instantiation in macro. Test: ./test.py Bug: 117582158 Change-Id: I0e3f3708ec98eba5353fee619f4cfbdc50570a59 --- .../header-abi-dumper/src/fake_decl_source.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vndk/tools/header-checker/header-abi-dumper/src/fake_decl_source.cpp b/vndk/tools/header-checker/header-abi-dumper/src/fake_decl_source.cpp index a8abbea4c..417433cdf 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/fake_decl_source.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/fake_decl_source.cpp @@ -14,7 +14,7 @@ #include "fake_decl_source.h" -#include +#include #include FakeDeclSource::FakeDeclSource(const clang::CompilerInstance &ci) : ci_(ci) {} @@ -90,10 +90,8 @@ FakeDeclSource::CreateDecl(clang::Sema::LookupNameKind kind, CreateCXXRecordDecl(name, decl_context); // If `<` follows the type name, the type must be a template. // Otherwise, the compiler takes it as a syntax error. - clang::Optional next_token = clang::Lexer::findNextToken( - name_info.getLoc(), ci_.getASTContext().getSourceManager(), - ci_.getLangOpts()); - if (next_token.hasValue() && next_token->is(clang::tok::less)) { + const clang::Token &next_token = ci_.getPreprocessor().LookAhead(0); + if (next_token.is(clang::tok::less)) { decl = CreateClassTemplateDecl(cxx_record_decl, decl_context); } else { decl = cxx_record_decl;