diff --git a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp index 2003c8d29c8a..a00eece506cd 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 000000000000..8f678d114472 --- /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(); +}