Teach static analyzer about AttributedStmts
Revised, as requested.
I originally done the other way, because I thought Attributes can be also
applied to other, non-null statements. If that is not the case right now,
then I
agree that it's better to ignore them altogether.
Hi jordan_rose,
http://llvm-reviews.chandlerc.com/D1030
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1030?vs=2542&id=2553#toc
Files:
lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Analysis/cxx11-crashes.cpp
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -652,7 +652,6 @@
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 @@
// 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: test/Analysis/cxx11-crashes.cpp
===================================================================
--- test/Analysis/cxx11-crashes.cpp
+++ test/Analysis/cxx11-crashes.cpp
@@ -85,4 +85,12 @@
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]];
+ }
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -652,7 +652,6 @@
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 @@
// 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: test/Analysis/cxx11-crashes.cpp
===================================================================
--- test/Analysis/cxx11-crashes.cpp
+++ test/Analysis/cxx11-crashes.cpp
@@ -85,4 +85,12 @@
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]];
+ }
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits