summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-05-17 17:26:02 +0000
committerVedant Kumar <vsk@apple.com>2016-05-17 17:26:02 +0000
commit5119923cdd7c2340ce669e57bf67cb7ac79724ac (patch)
tree4afa65b132d77d56f2ae0e553997144258b10d53
parent1c0f0b242da706ee4b31b5107273476358895049 (diff)
downloadbcm5719-llvm-5119923cdd7c2340ce669e57bf67cb7ac79724ac.tar.gz
bcm5719-llvm-5119923cdd7c2340ce669e57bf67cb7ac79724ac.zip
[clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)
If a use of a macro argument is preceded by the `namespace` keyword, do not warn that the use should be wrapped in parentheses. Patch by Mads Ravn! llvm-svn: 269786
-rw-r--r--clang-tools-extra/clang-tidy/misc/MacroParenthesesCheck.cpp4
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-macro-parentheses.cpp1
2 files changed, 5 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/MacroParenthesesCheck.cpp b/clang-tools-extra/clang-tidy/misc/MacroParenthesesCheck.cpp
index 4b3e1ca688e..590bc4d8138 100644
--- a/clang-tools-extra/clang-tidy/misc/MacroParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MacroParenthesesCheck.cpp
@@ -184,6 +184,10 @@ void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
Next.isOneOf(tok::comma, tok::greater))
continue;
+ // Namespaces.
+ if (Prev.is(tok::kw_namespace))
+ continue;
+
Check->diag(Tok.getLocation(), "macro argument should be enclosed in "
"parentheses")
<< FixItHint::CreateInsertion(Tok.getLocation(), "(")
diff --git a/clang-tools-extra/test/clang-tidy/misc-macro-parentheses.cpp b/clang-tools-extra/test/clang-tidy/misc-macro-parentheses.cpp
index 8f23a0991da..de83a827bfd 100644
--- a/clang-tools-extra/test/clang-tidy/misc-macro-parentheses.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-macro-parentheses.cpp
@@ -36,6 +36,7 @@
#define GOOD25(t) std::set<t,t,t> s
#define GOOD26(x) (a->*x)
#define GOOD27(x) (a.*x)
+#define GOOD28(x) namespace x {int b;}
// These are allowed for now..
#define MAYBE1 *12.34
OpenPOWER on IntegriCloud