]> granicus.if.org Git - clang/commitdiff
Teach static analyzer about AttributedStmts
authorPavel Labath <labath@google.com>
Tue, 2 Jul 2013 09:38:48 +0000 (09:38 +0000)
committerPavel Labath <labath@google.com>
Tue, 2 Jul 2013 09:38:48 +0000 (09:38 +0000)
Summary:
Static analyzer used to abort when encountering AttributedStmts, because it
asserted that the statements should not appear in the CFG. This is however not
the case, since at least the clang::fallthrough annotation makes it through.

This commit simply makes the analyzer ignore the statement attributes.

CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1030

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185417 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Analysis/cxx11-crashes.cpp

index db32003e7bffb6404f3022174a7a3a8468cb6559..59c66b83c73074d85d625eadc300e6285bd94e16 100644 (file)
@@ -652,7 +652,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     case Stmt::IfStmtClass:
     case Stmt::IndirectGotoStmtClass:
     case Stmt::LabelStmtClass:
-    case Stmt::AttributedStmtClass:
     case Stmt::NoStmtClass:
     case Stmt::NullStmtClass:
     case Stmt::SwitchStmtClass:
@@ -709,6 +708,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     // Cases we intentionally don't evaluate, since they don't need
     // to be explicitly evaluated.
     case Stmt::AddrLabelExprClass:
+    case Stmt::AttributedStmtClass:
     case Stmt::IntegerLiteralClass:
     case Stmt::CharacterLiteralClass:
     case Stmt::ImplicitValueInitExprClass:
index a2b70db2f8706074a387befc41338cf79e913c13..3c33de33558f92ee2924904a1b4a5e84e8933a04 100644 (file)
@@ -85,4 +85,12 @@ class SocketWireProtocolStream : public JSONWireProtocolInputStream {
 void test() {
   SocketWireProtocolStream stream{};
   JSONWireProtocolReader reader{stream};
-}
\ No newline at end of file
+}
+
+// This crashed because the analyzer did not understand AttributedStmts.
+void fallthrough() {
+  switch (1) {
+    case 1:
+      [[clang::fallthrough]];
+  }
+}