From cad151491e7df26b57eb6dc5daef19dfa8320fae Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Wed, 10 Aug 2016 16:25:16 +0000 Subject: [analyzer] Fix a crash in CloneDetector when calling functions by pointers. CallExpr may have a null direct callee when the callee function is not known in compile-time. Do not try to take callee name in this case. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23320 llvm-svn: 278238 --- clang/lib/Analysis/CloneDetection.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/Analysis/CloneDetection.cpp') diff --git a/clang/lib/Analysis/CloneDetection.cpp b/clang/lib/Analysis/CloneDetection.cpp index 038f9eb87cd..27815f30aea 100644 --- a/clang/lib/Analysis/CloneDetection.cpp +++ b/clang/lib/Analysis/CloneDetection.cpp @@ -249,8 +249,11 @@ public: }) //--- Calls --------------------------------------------------------------// - DEF_ADD_DATA(CallExpr, - { addData(S->getDirectCallee()->getQualifiedNameAsString()); }) + DEF_ADD_DATA(CallExpr, { + // Function pointers don't have a callee and we just skip hashing it. + if (S->getDirectCallee()) + addData(S->getDirectCallee()->getQualifiedNameAsString()); + }) //--- Exceptions ---------------------------------------------------------// DEF_ADD_DATA(CXXCatchStmt, { addData(S->getCaughtType()); }) -- cgit v1.2.3