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
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "fake_decl_source.h"
|
#include "fake_decl_source.h"
|
||||||
|
|
||||||
#include <clang/Lex/Lexer.h>
|
#include <clang/Lex/Preprocessor.h>
|
||||||
#include <clang/Sema/Lookup.h>
|
#include <clang/Sema/Lookup.h>
|
||||||
|
|
||||||
FakeDeclSource::FakeDeclSource(const clang::CompilerInstance &ci) : ci_(ci) {}
|
FakeDeclSource::FakeDeclSource(const clang::CompilerInstance &ci) : ci_(ci) {}
|
||||||
@@ -90,10 +90,8 @@ FakeDeclSource::CreateDecl(clang::Sema::LookupNameKind kind,
|
|||||||
CreateCXXRecordDecl(name, decl_context);
|
CreateCXXRecordDecl(name, decl_context);
|
||||||
// If `<` follows the type name, the type must be a template.
|
// If `<` follows the type name, the type must be a template.
|
||||||
// Otherwise, the compiler takes it as a syntax error.
|
// Otherwise, the compiler takes it as a syntax error.
|
||||||
clang::Optional<clang::Token> next_token = clang::Lexer::findNextToken(
|
const clang::Token &next_token = ci_.getPreprocessor().LookAhead(0);
|
||||||
name_info.getLoc(), ci_.getASTContext().getSourceManager(),
|
if (next_token.is(clang::tok::less)) {
|
||||||
ci_.getLangOpts());
|
|
||||||
if (next_token.hasValue() && next_token->is(clang::tok::less)) {
|
|
||||||
decl = CreateClassTemplateDecl(cxx_record_decl, decl_context);
|
decl = CreateClassTemplateDecl(cxx_record_decl, decl_context);
|
||||||
} else {
|
} else {
|
||||||
decl = cxx_record_decl;
|
decl = cxx_record_decl;
|
||||||
|
|||||||
Reference in New Issue
Block a user