[clang-tools-extra] r269786 - [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Tue May 17 10:26:02 PDT 2016
Author: vedantk
Date: Tue May 17 12:26:02 2016
New Revision: 269786
URL: http://llvm.org/viewvc/llvm-project?rev=269786&view=rev
Log:
[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!
Modified:
clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp?rev=269786&r1=269785&r2=269786&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroParenthesesCheck.cpp Tue May 17 12:26:02 2016
@@ -184,6 +184,10 @@ void MacroParenthesesPPCallbacks::argume
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(), "(")
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp?rev=269786&r1=269785&r2=269786&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses.cpp Tue May 17 12:26:02 2016
@@ -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
More information about the cfe-commits
mailing list