On May 21, 2012, at 1:36 PM, Benjamin Kramer wrote: > > On 21.05.2012, at 22:04, Anna Zaks wrote: > >> Benjamin, >> >> The issue is that the size of the string is 1, correct? Can we just check >> the size and return if it's less than 2 and proceed with the existing checks >> afterwards? This function is called a lot. > > LLVM knows how to generate great optimized code for startswith, it becomes a > check that the length is >=2 and two unaligned loads + compares. It's far > more readable and I doubt that it's slower than the old buggy code. > >> Do you have a test case? > > Yes, and a reduced version was committed along with this fix. > Sorry, I've missed that. > - Ben > >> >> Thanks, >> Anna. >> On May 21, 2012, at 12:40 PM, Benjamin Kramer wrote: >> >>> Author: d0k >>> Date: Mon May 21 14:40:38 2012 >>> New Revision: 157204 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=157204&view=rev >>> Log: >>> Analyzer: Fix PR12905, a crash when encountering a call to a function named >>> "C". >>> >>> While there clean up indentation. >>> >>> Added: >>> cfe/trunk/test/Analysis/PR12905.c >>> Modified: >>> cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp >>> >>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp?rev=157204&r1=157203&r2=157204&view=diff >>> ============================================================================== >>> --- cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp (original) >>> +++ cfe/trunk/lib/StaticAnalyzer/Core/ObjCMessage.cpp Mon May 21 14:40:38 >>> 2012 >>> @@ -161,16 +161,15 @@ >>> } >>> >>> 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; >>> } >>> >>> >>> >>> Added: cfe/trunk/test/Analysis/PR12905.c >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR12905.c?rev=157204&view=auto >>> ============================================================================== >>> --- cfe/trunk/test/Analysis/PR12905.c (added) >>> +++ cfe/trunk/test/Analysis/PR12905.c Mon May 21 14:40:38 2012 >>> @@ -0,0 +1,8 @@ >>> +// RUN: %clang_cc1 -analyze -analyzer-checker=core %s >>> +// PR12905 >>> + >>> +void C(void); >>> + >>> +void t(void) { >>> + C(); >>> +} >>> >>> >>> _______________________________________________ >>> cfe-commits mailing list >>> [email protected] >>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
