[cfe-commits] r117970 - in /cfe/trunk: lib/Checker/CStringChecker.cpp lib/Checker/PthreadLockChecker.cpp test/Analysis/operator-calls.cpp

Douglas Gregor dgregor at apple.com
Mon Nov 1 16:16:05 PDT 2010


Author: dgregor
Date: Mon Nov  1 18:16:05 2010
New Revision: 117970

URL: http://llvm.org/viewvc/llvm-project?rev=117970&view=rev
Log:
Teach the CStringChecker and PthreadLockChecker about non-identifier
declaration names, from Jim Goodnow II!

Added:
    cfe/trunk/test/Analysis/operator-calls.cpp   (with props)
Modified:
    cfe/trunk/lib/Checker/CStringChecker.cpp
    cfe/trunk/lib/Checker/PthreadLockChecker.cpp

Modified: cfe/trunk/lib/Checker/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CStringChecker.cpp?rev=117970&r1=117969&r2=117970&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CStringChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CStringChecker.cpp Mon Nov  1 18:16:05 2010
@@ -905,7 +905,10 @@
     return false;
 
   // Get the name of the callee. If it's a builtin, strip off the prefix.
-  llvm::StringRef Name = FD->getName();
+  IdentifierInfo *II = FD->getIdentifier();
+  if (!II)   // if no identifier, not a simple C function
+    return false;
+  llvm::StringRef Name = II->getName();
   if (Name.startswith("__builtin_"))
     Name = Name.substr(10);
 

Modified: cfe/trunk/lib/Checker/PthreadLockChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/PthreadLockChecker.cpp?rev=117970&r1=117969&r2=117970&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/PthreadLockChecker.cpp (original)
+++ cfe/trunk/lib/Checker/PthreadLockChecker.cpp Mon Nov  1 18:16:05 2010
@@ -65,7 +65,10 @@
   if (!R)
     return;
   
-  llvm::StringRef FName = R->getDecl()->getName();
+  IdentifierInfo *II = R->getDecl()->getIdentifier();
+  if (!II)   // if no identifier, not a simple C function
+    return;
+  llvm::StringRef FName = II->getName();
   
   if (FName == "pthread_mutex_lock") {
     if (CE->getNumArgs() != 1)

Added: cfe/trunk/test/Analysis/operator-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/operator-calls.cpp?rev=117970&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/operator-calls.cpp (added)
+++ cfe/trunk/test/Analysis/operator-calls.cpp Mon Nov  1 18:16:05 2010
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem  -analyzer-experimental-checks -verify %s
+struct X0 { };
+bool operator==(const X0&, const X0&);
+
+// PR7287
+struct test { int a[2]; };
+
+void t2() {
+  test p = {{1,2}};
+  test q;
+  q = p;
+}
+
+bool PR7287(X0 a, X0 b) {
+  return a == b;
+}

Propchange: cfe/trunk/test/Analysis/operator-calls.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/Analysis/operator-calls.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/Analysis/operator-calls.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list