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(), "(")
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(), "(")
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits