summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-10-04 11:14:43 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-10-04 11:14:43 +0200
commit56c9446f74747214f733757f134cbc9e055ca5e2 (patch)
treedcff407d2b0b81eb5d6385aaa8164a6a0bc03e43 /compilerplugins
parent83a34d29100862b15d9d86cb852a0fd86f5b7f77 (diff)
Suppress loplugin:blockblock in functions involving preprocessing conditionals
...as needed to avoid an unhelpful warning about Player::createPlayerWindow in avmedia/source/gstreamer/gstplayer.cxx when included from avmedia/source/gstreamer/gst_0_10.cxx (so that ENABLE_GTKSINK is not defined). Change-Id: I6de9cc59cf8e611c4c9d939dd837499b1d2c8787
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/blockblock.cxx35
-rw-r--r--compilerplugins/clang/test/blockblock.cxx11
2 files changed, 46 insertions, 0 deletions
diff --git a/compilerplugins/clang/blockblock.cxx b/compilerplugins/clang/blockblock.cxx
index 43e9b94deedb..3d5d69c2ab57 100644
--- a/compilerplugins/clang/blockblock.cxx
+++ b/compilerplugins/clang/blockblock.cxx
@@ -35,6 +35,41 @@ public:
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
+ bool TraverseCXXMethodDecl(CXXMethodDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseCXXMethodDecl(decl);
+ }
+
+ bool TraverseCXXConstructorDecl(CXXConstructorDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseCXXConstructorDecl(decl);
+ }
+
+ bool TraverseCXXDestructorDecl(CXXDestructorDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseCXXDestructorDecl(decl);
+ }
+
+ bool TraverseCXXConversionDecl(CXXConversionDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseCXXConversionDecl(decl);
+ }
+
+ bool TraverseObjCMethodDecl(ObjCMethodDecl * decl) {
+ if (containsPreprocessingConditionalInclusion(decl->getSourceRange())) {
+ return true;
+ }
+ return RecursiveASTVisitor::TraverseObjCMethodDecl(decl);
+ }
+
bool VisitCompoundStmt(CompoundStmt const * );
};
diff --git a/compilerplugins/clang/test/blockblock.cxx b/compilerplugins/clang/test/blockblock.cxx
index d81f9fe527ae..89733103eb58 100644
--- a/compilerplugins/clang/test/blockblock.cxx
+++ b/compilerplugins/clang/test/blockblock.cxx
@@ -7,6 +7,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+int f(bool b1, bool b2) {
+ if (b1 || b2) {
+#if 1
+ if (b1)
+#endif
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
int main() { // expected-error {{block directly inside block [loplugin:blockblock]}}
{ // expected-note {{inner block here [loplugin:blockblock]}}