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); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits