diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-09-30 10:40:32 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-09-30 13:28:43 +0200 |
commit | 62274b24f91952cf98d387333684d9e874a6b75e (patch) | |
tree | fde04890d6bf088082374e10dd2aca638770e3e5 /compilerplugins | |
parent | 82ae825198ada84049c630ab49f280c8c6f2ad6e (diff) |
Suppress loplugin:flatten in functions involving preprocessing conditionals
...as needed by clang-cl on Windows to avoid unhelpful warnings about
OleEmbeddedObject::changeState (embeddedobj/source/msole/oleembed.cxx)
containging an "if" in an "#ifdef _WIN32" block followed by "else throw".
Change-Id: I95bed29b9003db08499156ae7f885aeeea5a0158
Reviewed-on: https://gerrit.libreoffice.org/42963
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/flatten.cxx | 7 | ||||
-rw-r--r-- | compilerplugins/clang/test/flatten.cxx | 10 |
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) { |