Skip to content
Snippets Groups Projects
Commit 10155922 authored by Daniel Grumberg's avatar Daniel Grumberg
Browse files

[clang][extract-api][NFC] Use dedicated API to check for macro equality

Differential Revision: https://reviews.llvm.org/D123295
parent fac9f45e
No related branches found
No related tags found
No related merge requests found
......@@ -649,8 +649,9 @@ private:
class MacroCallback : public PPCallbacks {
public:
MacroCallback(const SourceManager &SM, LocationFileChecker &LCF, APISet &API)
: SM(SM), LCF(LCF), API(API) {}
MacroCallback(const SourceManager &SM, LocationFileChecker &LCF, APISet &API,
Preprocessor &PP)
: SM(SM), LCF(LCF), API(API), PP(PP) {}
void MacroDefined(const Token &MacroNameToken,
const MacroDirective *MD) override {
......@@ -677,9 +678,9 @@ public:
if (!Undef)
return;
llvm::erase_if(PendingMacros, [&MD](const PendingMacro &PM) {
return MD.getMacroInfo()->getDefinitionLoc() ==
PM.MD->getMacroInfo()->getDefinitionLoc();
llvm::erase_if(PendingMacros, [&MD, this](const PendingMacro &PM) {
return MD.getMacroInfo()->isIdenticalTo(*PM.MD->getMacroInfo(), PP,
/*Syntactically*/ false);
});
}
......@@ -719,6 +720,7 @@ private:
const SourceManager &SM;
LocationFileChecker &LCF;
APISet &API;
Preprocessor &PP;
llvm::SmallVector<PendingMacro> PendingMacros;
};
......@@ -741,9 +743,8 @@ ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
auto LCF = std::make_unique<LocationFileChecker>(CI.getSourceManager(),
KnownInputFiles);
// Register preprocessor callbacks that will add macro definitions to API.
CI.getPreprocessor().addPPCallbacks(
std::make_unique<MacroCallback>(CI.getSourceManager(), *LCF, *API));
CI.getPreprocessor().addPPCallbacks(std::make_unique<MacroCallback>(
CI.getSourceManager(), *LCF, *API, CI.getPreprocessor()));
return std::make_unique<ExtractAPIConsumer>(CI.getASTContext(),
std::move(LCF), *API);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment