Analyzer: Fix PR12905, a crash when encountering a call to a function named "C".

While there clean up indentation.

llvm-svn: 157204
This commit is contained in:
Benjamin Kramer 2012-05-21 19:40:38 +00:00
parent fc732755ad
commit 9bbf481f02
2 changed files with 17 additions and 10 deletions

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core %s
// PR12905
void C(void);
void t(void) {
C();
}