summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/flatten.cxx7
-rw-r--r--compilerplugins/clang/test/flatten.cxx10
2 files changed, 17 insertions, 0 deletions
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx
index dd7afa44d068..1dd265990cb7 100644
--- a/compilerplugins/clang/flatten.cxx
+++ b/compilerplugins/clang/flatten.cxx
@@ -30,6 +30,13 @@ public:
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
+ bool TraverseFunctionDecl(FunctionDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseFunctionDecl(decl);
+ }
+
bool TraverseCXXCatchStmt(CXXCatchStmt * );
bool VisitIfStmt(IfStmt const * );
private:
diff --git a/compilerplugins/clang/test/flatten.cxx b/compilerplugins/clang/test/flatten.cxx
index 8d745b16ad45..91321276c45e 100644
--- a/compilerplugins/clang/test/flatten.cxx
+++ b/compilerplugins/clang/test/flatten.cxx
@@ -55,6 +55,16 @@ void top4() {
(void)x;
}
+void top5() {
+ // no warning expected
+#if 1
+ if (foo() == 2) {
+ bar();
+ } else
+#endif
+ throw std::exception();
+}
+
int main() {
// no warning expected
if (bar() == 3) {