summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-09-30 22:39:33 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-10-05 09:38:31 +0200
commit3d1b53a0998659e6a75def21d2b539c692168149 (patch)
treed2b828c95357c90e76efb11258b4c4d8f679cfda /compilerplugins
parent5be8c9cc1b92101e6f9fe5685df86e77d3eee3cc (diff)
Also suppress loplugin:flatten in C++ class member functions...
...invovling preprocessing conditionals, to actually make the unhelpful warning on Windows about OleEmbeddedObject::changeState go away. And while at it, make the check for preprocessing conditionals more targeted (similar to 1084e8be44661aaeacb8801707701013eb3fcdbc "More targeted check for preprocessing conditionals in loplugin:blockblock"). Change-Id: I0300e0a547e969520a90cd126ea8f788cc17560f Reviewed-on: https://gerrit.libreoffice.org/42975 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/flatten.cxx11
-rw-r--r--compilerplugins/clang/test/flatten.cxx9
2 files changed, 10 insertions, 10 deletions
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx
index 1dd265990cb7..7fa408ea1731 100644
--- a/compilerplugins/clang/flatten.cxx
+++ b/compilerplugins/clang/flatten.cxx
@@ -30,13 +30,6 @@ 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:
@@ -115,6 +108,10 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt)
if (parentIfStmt && parentIfStmt->getElse() == ifStmt)
return true;
+ if (containsPreprocessingConditionalInclusion(ifStmt->getSourceRange())) {
+ return true;
+ }
+
auto throwExpr = containsSingleThrowExpr(ifStmt->getElse());
if (throwExpr)
{
diff --git a/compilerplugins/clang/test/flatten.cxx b/compilerplugins/clang/test/flatten.cxx
index 91321276c45e..a901d273b9a1 100644
--- a/compilerplugins/clang/test/flatten.cxx
+++ b/compilerplugins/clang/test/flatten.cxx
@@ -56,13 +56,16 @@ void top4() {
}
void top5() {
- // no warning expected
#if 1
if (foo() == 2) {
- bar();
+ if (foo() == 3) { // expected-note {{if condition here [loplugin:flatten]}}
+ bar();
+ } else {
+ throw std::exception(); // expected-error {{unconditional throw in else branch, rather invert the condition, throw early, and flatten the normal case [loplugin:flatten]}}
+ }
} else
#endif
- throw std::exception();
+ throw std::exception(); // no warning expected
}
int main() {