[llvm-branch-commits] [cfe-branch] r196007 - Merging r195777:

Bill Wendling isanbard at gmail.com
Sat Nov 30 19:45:50 PST 2013


Author: void
Date: Sat Nov 30 21:45:49 2013
New Revision: 196007

URL: http://llvm.org/viewvc/llvm-project?rev=196007&view=rev
Log:
Merging r195777:
------------------------------------------------------------------------
r195777 | delesley | 2013-11-26 11:45:21 -0800 (Tue, 26 Nov 2013) | 1 line

Thread safety analysis: fix ICE due to missing null check on dyn_cast.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/Analysis/ThreadSafety.cpp
    cfe/branches/release_34/test/SemaCXX/warn-thread-safety-analysis.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 30 21:45:49 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760,195768,195789,195804,195827,195877,195887-195888,195897,195906,195983
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760,195768,195777,195789,195804,195827,195877,195887-195888,195897,195906,195983
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Analysis/ThreadSafety.cpp?rev=196007&r1=196006&r2=196007&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/branches/release_34/lib/Analysis/ThreadSafety.cpp Sat Nov 30 21:45:49 2013
@@ -266,6 +266,11 @@ private:
     return NodeVec.size()-1;
   }
 
+  inline bool isCalleeArrow(const Expr *E) {
+    const MemberExpr *ME = dyn_cast<MemberExpr>(E->IgnoreParenCasts());
+    return ME ? ME->isArrow() : false;
+  }
+
   /// Build an SExpr from the given C++ expression.
   /// Recursive function that terminates on DeclRefExpr.
   /// Note: this function merely creates a SExpr; it does not check to
@@ -327,8 +332,7 @@ private:
       if (LockReturnedAttr* At = MD->getAttr<LockReturnedAttr>()) {
         CallingContext LRCallCtx(CMCE->getMethodDecl());
         LRCallCtx.SelfArg = CMCE->getImplicitObjectArgument();
-        LRCallCtx.SelfArrow =
-          dyn_cast<MemberExpr>(CMCE->getCallee())->isArrow();
+        LRCallCtx.SelfArrow = isCalleeArrow(CMCE->getCallee());
         LRCallCtx.NumArgs = CMCE->getNumArgs();
         LRCallCtx.FunArgs = CMCE->getArgs();
         LRCallCtx.PrevCtx = CallCtx;
@@ -338,7 +342,7 @@ private:
       // ignore any method named get().
       if (CMCE->getMethodDecl()->getNameAsString() == "get" &&
           CMCE->getNumArgs() == 0) {
-        if (NDeref && dyn_cast<MemberExpr>(CMCE->getCallee())->isArrow())
+        if (NDeref && isCalleeArrow(CMCE->getCallee()))
           ++(*NDeref);
         return buildSExpr(CMCE->getImplicitObjectArgument(), CallCtx, NDeref);
       }
@@ -496,11 +500,10 @@ private:
     } else if (const CXXMemberCallExpr *CE =
                dyn_cast<CXXMemberCallExpr>(DeclExp)) {
       CallCtx.SelfArg   = CE->getImplicitObjectArgument();
-      CallCtx.SelfArrow = dyn_cast<MemberExpr>(CE->getCallee())->isArrow();
+      CallCtx.SelfArrow = isCalleeArrow(CE->getCallee());
       CallCtx.NumArgs   = CE->getNumArgs();
       CallCtx.FunArgs   = CE->getArgs();
-    } else if (const CallExpr *CE =
-               dyn_cast<CallExpr>(DeclExp)) {
+    } else if (const CallExpr *CE = dyn_cast<CallExpr>(DeclExp)) {
       CallCtx.NumArgs = CE->getNumArgs();
       CallCtx.FunArgs = CE->getArgs();
     } else if (const CXXConstructExpr *CE =

Modified: cfe/branches/release_34/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=196007&r1=196006&r2=196007&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/release_34/test/SemaCXX/warn-thread-safety-analysis.cpp Sat Nov 30 21:45:49 2013
@@ -4300,3 +4300,17 @@ class SmartPtr_PtGuardedBy_Test {
 
 }  // end namespace PtGuardedByTest
 
+
+namespace NonMemberCalleeICETest {
+
+class A {
+  void Run() {
+  (RunHelper)();  // expected-warning {{calling function 'RunHelper' requires exclusive lock on 'M'}}
+ }
+
+ void RunHelper() __attribute__((exclusive_locks_required(M)));
+ Mutex M;
+};
+
+}  // end namespace NonMemberCalleeICETest
+





More information about the llvm-branch-commits mailing list