r175335 - libAnalysis: Add a case for TypeAliasDecl in CFGRecStmtDeclVisitor.

Jordan Rose jordan_rose at apple.com
Fri Feb 15 17:33:17 PST 2013


Author: jrose
Date: Fri Feb 15 19:33:16 2013
New Revision: 175335

URL: http://llvm.org/viewvc/llvm-project?rev=175335&view=rev
Log:
libAnalysis: Add a case for TypeAliasDecl in CFGRecStmtDeclVisitor.

Neither of the current clients of CFGRecStmtDeclVisitor are doing
anything with typedefs, so I assume type aliases (C++11 "using")
can be safely ignored. This was causing assertion failures in
the analyzer.

<rdar://problem/13228440>

Modified:
    cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
    cfe/trunk/test/Analysis/dead-stores.cpp

Modified: cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h?rev=175335&r1=175334&r2=175335&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h (original)
+++ cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h Fri Feb 15 19:33:16 2013
@@ -63,6 +63,7 @@ public:
         DISPATCH_CASE(ImplicitParam)
         DISPATCH_CASE(EnumConstant)
         DISPATCH_CASE(Typedef)
+        DISPATCH_CASE(TypeAlias)
         DISPATCH_CASE(Record)    // FIXME: Refine.  VisitStructDecl?
         DISPATCH_CASE(CXXRecord)
         DISPATCH_CASE(Enum)
@@ -82,6 +83,7 @@ public:
   DEFAULT_DISPATCH(ImplicitParam)
   DEFAULT_DISPATCH(EnumConstant)
   DEFAULT_DISPATCH(Typedef)
+  DEFAULT_DISPATCH(TypeAlias)
   DEFAULT_DISPATCH(Record)
   DEFAULT_DISPATCH(Enum)
   DEFAULT_DISPATCH(Field)

Modified: cfe/trunk/test/Analysis/dead-stores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.cpp?rev=175335&r1=175334&r2=175335&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dead-stores.cpp (original)
+++ cfe/trunk/test/Analysis/dead-stores.cpp Fri Feb 15 19:33:16 2013
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
 
 //===----------------------------------------------------------------------===//
 // Basic dead store checking (but in C++ mode).
@@ -149,3 +149,10 @@ void test_6b() {
   }
   catch (void *) {}
 }
+
+
+void testCXX11Using() {
+  using Int = int;
+  Int value;
+  value = 1; // expected-warning {{never read}}
+}





More information about the cfe-commits mailing list