From 9bbf481f0203bd97038b4c9d8001476e0ac03c90 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 21 May 2012 19:40:38 +0000 Subject: [PATCH] Analyzer: Fix PR12905, a crash when encountering a call to a function named "C". While there clean up indentation. llvm-svn: 157204 --- clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp | 19 +++++++++---------- clang/test/Analysis/PR12905.c | 8 ++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 clang/test/Analysis/PR12905.c diff --git a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp index 2003c8d..a00eece 100644 --- a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp +++ b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp @@ -161,16 +161,15 @@ bool CallOrObjCMessage::hasNonZeroCallbackArg() const { } bool CallOrObjCMessage::isCFCGAllowingEscape(StringRef FName) { - if (FName[0] == 'C' && (FName[1] == 'F' || FName[1] == 'G')) - if (StrInStrNoCase(FName, "InsertValue") != StringRef::npos|| - StrInStrNoCase(FName, "AddValue") != StringRef::npos || - StrInStrNoCase(FName, "SetValue") != StringRef::npos || - StrInStrNoCase(FName, "WithData") != StringRef::npos || - StrInStrNoCase(FName, "AppendValue") != StringRef::npos|| - StrInStrNoCase(FName, "SetAttribute") != StringRef::npos) { - return true; - } - return false; + if (!FName.startswith("CF") && !FName.startswith("CG")) + return false; + + return StrInStrNoCase(FName, "InsertValue") != StringRef::npos || + StrInStrNoCase(FName, "AddValue") != StringRef::npos || + StrInStrNoCase(FName, "SetValue") != StringRef::npos || + StrInStrNoCase(FName, "WithData") != StringRef::npos || + StrInStrNoCase(FName, "AppendValue") != StringRef::npos || + StrInStrNoCase(FName, "SetAttribute") != StringRef::npos; } diff --git a/clang/test/Analysis/PR12905.c b/clang/test/Analysis/PR12905.c new file mode 100644 index 0000000..8f678d1 --- /dev/null +++ b/clang/test/Analysis/PR12905.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core %s +// PR12905 + +void C(void); + +void t(void) { + C(); +} -- 2.7.4