[clang] [analyzer] Set and display CSA analysis entry points as notes on debugging (PR #84823)

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 4 14:30:02 PDT 2024


================
@@ -788,7 +791,7 @@ class PathDiagnostic : public llvm::FoldingSetNode {
   PathDiagnostic(StringRef CheckerName, const Decl *DeclWithIssue,
                  StringRef bugtype, StringRef verboseDesc, StringRef shortDesc,
                  StringRef category, PathDiagnosticLocation LocationToUnique,
-                 const Decl *DeclToUnique,
+                 const Decl *DeclToUnique, const Decl *AnalysisEntryPoint,
----------------
haoNoQ wrote:

I mean, this is a debug feature. Debug features are great but it's probably ok to have them slightly incorrect or incomplete if it means that they're no longer associated with increased complexity, with paying for something we don't use.

Out of those AST checkers, how many are emitting diagnostics outside of the entry function / decl-with-issue function? If you append
```
[debug] This bubble's decl name is 'foo()'
```
to _every_ message bubble, would that entirely cover all your needs?

I can easily see how there could be a checker that always warns outside of the entry function. If that's the case then it's probably incredibly useful for debugging to quickly know which entry function inspired the warning. But at the same time I'm not sure I can think of a good example when the same information wouldn't be useful for the *user* as well; maybe the users could benefit from a user-facing note too? (Somewhat similarly to how Clang explains template instantiation stack when diagnosing problems in individual template instantiations. (Something we cannot mimic in static analysis tools because the instantiation stack is already lost.))

https://github.com/llvm/llvm-project/pull/84823


More information about the cfe-commits mailing list