[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 02:29:47 PDT 2024
================
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition(
// Add an enclosing time trace scope for a bunch of small scopes with
// "EvaluateAsConstExpr".
llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() {
- return Tok.getLocation().printToString(
- Actions.getASTContext().getSourceManager());
+ llvm::TimeTraceMetadata M;
+ const SourceManager &SM = Actions.getASTContext().getSourceManager();
+ auto Loc = SM.getExpansionLoc(Tok.getLocation());
+ M.File = SM.getFilename(Loc);
----------------
ilya-biryukov wrote:
This is guarded by `isTimeTraceVerbose` in other places, but not here.
The only reason I can see for that is historical accidents, although perhaps the parsing events are less frequent too.
That being said, I don't think we should necessarily change it in this patch, but could we add a FIXME here saying that other places only log locations in verbose mode and an explanation why this one does not?
https://github.com/llvm/llvm-project/pull/106277
More information about the cfe-commits
mailing list