[clang] 5301826 - [clang][ExtractAPI] Don't print locations for anonymous tags
Zixu Wang via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 5 13:11:35 PDT 2022
Author: Zixu Wang
Date: 2022-10-05T13:11:21-07:00
New Revision: 5301826fa86aa520b65c86abbe3b3a7194849e27
URL: https://github.com/llvm/llvm-project/commit/5301826fa86aa520b65c86abbe3b3a7194849e27
DIFF: https://github.com/llvm/llvm-project/commit/5301826fa86aa520b65c86abbe3b3a7194849e27.diff
LOG: [clang][ExtractAPI] Don't print locations for anonymous tags
ExtractAPI doesn't care about locations of anonymous TagDecls. Set the
printing policy to exclude that from anonymous decl names.
Differential Revision: https://reviews.llvm.org/D135295
Added:
Modified:
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index 969ee772fa063..4a97ee9922ddd 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -850,6 +850,11 @@ ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.getPreprocessor().addPPCallbacks(std::make_unique<MacroCallback>(
CI.getSourceManager(), *LCF, *API, CI.getPreprocessor()));
+ // Do not include location in anonymous decls.
+ PrintingPolicy Policy = CI.getASTContext().getPrintingPolicy();
+ Policy.AnonymousTagLocations = false;
+ CI.getASTContext().setPrintingPolicy(Policy);
+
return std::make_unique<ExtractAPIConsumer>(CI.getASTContext(),
std::move(LCF), *API);
}
More information about the cfe-commits
mailing list