Suppress elided variadic macro argument extension diagnostic for macros using
authorEli Friedman <eli.friedman@gmail.com>
Wed, 14 Nov 2012 02:18:46 +0000 (02:18 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 14 Nov 2012 02:18:46 +0000 (02:18 +0000)
commit14d3c79b451f09b580328f36f768df859d9c846a
tree18572c897008e616acecee69ca10f6ef55e9b7d5
parent095deba5336bfaf275f4837a5f229e58f9a927c0
Suppress elided variadic macro argument extension diagnostic for macros using
the related comma pasting extension.

In certain cases, we used to get two diagnostics for what is essentially one
extension.  This change suppresses the first diagnostic in certain cases
where we know we're going to print the second diagnostic.  The
diagnostic is redundant, and it can't be suppressed in the definition
of the macro because it points at the use of the macro, so we want to
avoid printing it if possible.

The implementation works by detecting constructs which look like comma
pasting at the time of the definition of the macro; this information
is then used when the macro is used.  (We can't actually detect
whether we're using the comma pasting extension until the macro is
actually used, but we can detecting constructs which will be comma
pasting if the varargs argument is elided.)

<rdar://problem/12292192>

llvm-svn: 167907
clang/include/clang/Lex/MacroInfo.h
clang/lib/Lex/MacroInfo.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/Preprocessor/macro_fn.c