summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-11-30 02:17:57 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-11-30 02:17:57 +0000
commit06d1de83f0578f4eca6cab53cce1945aec66161e (patch)
treeded9ac681c94688bc8758f4f20f3d16fca708538 /lib
parentc3e5d5d8305e164969db8458b4f920db0c23e995 (diff)
downloadclang-06d1de83f0578f4eca6cab53cce1945aec66161e.tar.gz
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 8758091a9b..ce824ba077 100644
--- a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/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";
}