[PATCH] Teach static analyzer about AttributedStmts
Pavel Labath
labath at google.com
Tue Jun 25 01:54:13 PDT 2013
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]];
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1030.2.patch
Type: text/x-patch
Size: 1261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130625/9b7edb94/attachment.bin>
More information about the cfe-commits
mailing list