summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2017-02-15 15:35:56 +0000
committerGabor Horvath <xazax.hun@gmail.com>2017-02-15 15:35:56 +0000
commit562f3ccf3ed65e1a7e0a8d2a46b86fc0b8c159ae (patch)
treeaff71f885bb5be016c918e0894bd653f360ec78f /clang/lib
parent288f075f8eb8df6c846aab8ef52d964de99c03a2 (diff)
downloadbcm5719-llvm-562f3ccf3ed65e1a7e0a8d2a46b86fc0b8c159ae.tar.gz
bcm5719-llvm-562f3ccf3ed65e1a7e0a8d2a46b86fc0b8c159ae.zip
[analyzer] Proper caching in CallDescription objects.
During the review of D29567 it turned out the caching in CallDescription is not implemented properly. In case an identifier does not exist in a translation unit, repeated identifier lookups will be done which might have bad impact on the performance. This patch guarantees that the lookup is only executed once. Moreover this patch fixes a corner case when the identifier of CallDescription does not exist in the translation unit and the called function does not have an identifier (e.g.: overloaded operator in C++). Differential Revision: https://reviews.llvm.org/D29884 llvm-svn: 295186
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index af610395a87..ef824b8a3b1 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -212,9 +212,12 @@ ProgramPoint CallEvent::getProgramPoint(bool IsPreVisit,
bool CallEvent::isCalled(const CallDescription &CD) const {
assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
- if (!CD.II)
+ if (!CD.IsLookupDone) {
+ CD.IsLookupDone = true;
CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName);
- if (getCalleeIdentifier() != CD.II)
+ }
+ const IdentifierInfo *II = getCalleeIdentifier();
+ if (!II || II != CD.II)
return false;
return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
CD.RequiredArgs == getNumArgs());
OpenPOWER on IntegriCloud