[clang] 1015592 - [clang][extract-api][NFC] Use dedicated API to check for macro equality
Daniel Grumberg via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 7 11:11:01 PDT 2022
Author: Daniel Grumberg
Date: 2022-04-07T19:08:17+01:00
New Revision: 101559225189e63b7f6236fb944501b1e6b74a87
URL: https://github.com/llvm/llvm-project/commit/101559225189e63b7f6236fb944501b1e6b74a87
DIFF: https://github.com/llvm/llvm-project/commit/101559225189e63b7f6236fb944501b1e6b74a87.diff
LOG: [clang][extract-api][NFC] Use dedicated API to check for macro equality
Differential Revision: https://reviews.llvm.org/D123295
Added:
Modified:
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index 949413d7d2b1d..0757881862984 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -649,8 +649,9 @@ class ExtractAPIConsumer : public ASTConsumer {
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 @@ class MacroCallback : public PPCallbacks {
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 @@ class MacroCallback : public PPCallbacks {
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);
More information about the cfe-commits
mailing list