Kaydet (Commit) 3d1b53a0 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
1084e8be "More targeted check for preprocessing
conditionals in loplugin:blockblock").

Change-Id: I0300e0a547e969520a90cd126ea8f788cc17560f
Reviewed-on: https://gerrit.libreoffice.org/42975Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 5be8c9cc
...@@ -30,13 +30,6 @@ public: ...@@ -30,13 +30,6 @@ public:
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
} }
bool TraverseFunctionDecl(FunctionDecl * decl) {
if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
return true;
}
return RecursiveASTVisitor::TraverseFunctionDecl(decl);
}
bool TraverseCXXCatchStmt(CXXCatchStmt * ); bool TraverseCXXCatchStmt(CXXCatchStmt * );
bool VisitIfStmt(IfStmt const * ); bool VisitIfStmt(IfStmt const * );
private: private:
...@@ -115,6 +108,10 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt) ...@@ -115,6 +108,10 @@ bool Flatten::VisitIfStmt(IfStmt const * ifStmt)
if (parentIfStmt && parentIfStmt->getElse() == ifStmt) if (parentIfStmt && parentIfStmt->getElse() == ifStmt)
return true; return true;
if (containsPreprocessingConditionalInclusion(ifStmt->getSourceRange())) {
return true;
}
auto throwExpr = containsSingleThrowExpr(ifStmt->getElse()); auto throwExpr = containsSingleThrowExpr(ifStmt->getElse());
if (throwExpr) if (throwExpr)
{ {
......
...@@ -56,13 +56,16 @@ void top4() { ...@@ -56,13 +56,16 @@ void top4() {
} }
void top5() { void top5() {
// no warning expected
#if 1 #if 1
if (foo() == 2) { if (foo() == 2) {
if (foo() == 3) { // expected-note {{if condition here [loplugin:flatten]}}
bar(); 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 } else
#endif #endif
throw std::exception(); throw std::exception(); // no warning expected
} }
int main() { int main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment