From 12e0c13819f09162aa8ff1036351be4f97839cae Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Sat, 16 Feb 2013 01:33:16 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175335 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h | 2 ++ test/Analysis/dead-stores.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h index dd6de6e548..2bf3eda070 100644 --- a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h +++ b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h @@ -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) diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index 86d84f0fbf..e1a034b1d0 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -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}} +} -- 2.50.0