[PATCH] D20510: [PATCH] Fix for bug 27802 misc-macro-parentheses breaks variadic macros
Mads Ravn via cfe-commits
cfe-commits at lists.llvm.org
Sat May 21 08:24:37 PDT 2016
madsravn created this revision.
madsravn added reviewers: alexfh, flx.
madsravn added a subscriber: cfe-commits.
This is fix for bug 27802: https://llvm.org/bugs/show_bug.cgi?id=27802
I have added a check to clang-tidy which refrains from putting parantheses around macros which are variadic.
http://reviews.llvm.org/D20510
Files:
clang-tidy/misc/MacroParenthesesCheck.cpp
test/clang-tidy/misc-macro-parentheses.cpp
Index: test/clang-tidy/misc-macro-parentheses.cpp
===================================================================
--- test/clang-tidy/misc-macro-parentheses.cpp
+++ test/clang-tidy/misc-macro-parentheses.cpp
@@ -37,6 +37,8 @@
#define GOOD26(x) (a->*x)
#define GOOD27(x) (a.*x)
#define GOOD28(x) namespace x {int b;}
+#define GOOD29(...) std::cout << __VA_ARGS__;
+#define GOOD30(args...) std::cout << args;
// These are allowed for now..
#define MAYBE1 *12.34
Index: clang-tidy/misc/MacroParenthesesCheck.cpp
===================================================================
--- clang-tidy/misc/MacroParenthesesCheck.cpp
+++ clang-tidy/misc/MacroParenthesesCheck.cpp
@@ -188,6 +188,10 @@
if (Prev.is(tok::kw_namespace))
continue;
+ // Variadic templates
+ if (MI->isVariadic())
+ continue;
+
Check->diag(Tok.getLocation(), "macro argument should be enclosed in "
"parentheses")
<< FixItHint::CreateInsertion(Tok.getLocation(), "(")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20510.58042.patch
Type: text/x-patch
Size: 1063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160521/0f8467d2/attachment.bin>
More information about the cfe-commits
mailing list