[clang] [analyzer] Add time-trace scopes for high-level analyzer steps (PR #125508)
Arseniy Zaostrovnykh via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 4 06:04:32 PST 2025
================
@@ -358,9 +359,41 @@ class AnalysisConsumer : public AnalysisASTConsumer,
/// Print \p S to stderr if \c Opts.AnalyzerDisplayProgress is set.
void reportAnalyzerProgress(StringRef S);
-}; // namespace
-} // end anonymous namespace
+};
+std::string timeTraceScopeDeclName(StringRef FunName, const Decl *D) {
+ if (llvm::timeTraceProfilerEnabled()) {
+ if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
+ return (FunName + " " + ND->getQualifiedNameAsString()).str();
+ }
+ return (FunName + " <anonymous> ").str();
+ }
+ return "";
+}
+
+llvm::TimeTraceMetadata timeTraceScopeDeclMetadata(const Decl *D) {
+ // If time-trace profiler is not enabled, this function is never called.
+ assert(llvm::timeTraceProfilerEnabled());
+ if (const auto &Loc = D->getBeginLoc(); Loc.isValid()) {
+ const auto &SM = D->getASTContext().getSourceManager();
+ std::string DeclName = AnalysisDeclContext::getFunctionName(D);
+ return llvm::TimeTraceMetadata{
+ DeclName, SM.getFilename(Loc).str(),
----------------
necto wrote:
Moved, thanks
a63907b742f6 [NFC] Move some strings
https://github.com/llvm/llvm-project/pull/125508
More information about the cfe-commits
mailing list