diff options
| author | George Karpenkov <ekarpenkov@apple.com> | 2018-11-30 02:17:57 +0000 |
|---|---|---|
| committer | George Karpenkov <ekarpenkov@apple.com> | 2018-11-30 02:17:57 +0000 |
| commit | e2f09542a5decacbdebea73e4186dd267f123b52 (patch) | |
| tree | dd936eb8cfa30ef31735a2281cfa7100bcc24247 /clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp | |
| parent | f893ea1592a4df9cba8e63d7fee1600eeda51a2a (diff) | |
| download | bcm5719-llvm-e2f09542a5decacbdebea73e4186dd267f123b52.tar.gz bcm5719-llvm-e2f09542a5decacbdebea73e4186dd267f123b52.zip | |
[analyzer] Print a fully qualified name for functions in RetainCountChecker diagnostics
Attempt to get a fully qualified name from AST if an SVal corresponding
to the object is not available.
Differential Revision: https://reviews.llvm.org/D55034
llvm-svn: 347944
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp index 8758091a9b9..ce824ba0777 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp @@ -173,10 +173,19 @@ CFRefReportVisitor::VisitNode(const ExplodedNode *N, os << "Object loaded from instance variable"; } else { if (const CallExpr *CE = dyn_cast<CallExpr>(S)) { - // Get the name of the callee (if it is available). + // Get the name of the callee (if it is available) + // from the tracked SVal. SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee(), LCtx); - if (const FunctionDecl *FD = X.getAsFunctionDecl()) { - os << "Call to function '" << *FD << '\''; + const FunctionDecl *FD = X.getAsFunctionDecl(); + + // If failed, try to get it from AST. + if (!FD) + FD = dyn_cast<FunctionDecl>(CE->getCalleeDecl()); + + if (const auto *MD = dyn_cast<CXXMethodDecl>(CE->getCalleeDecl())) { + os << "Call to method '" << MD->getQualifiedNameAsString() << '\''; + } else if (FD) { + os << "Call to function '" << FD->getQualifiedNameAsString() << '\''; } else { os << "function call"; } |

