HomePhabricator

[analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to…

Authored by Szelethus on Sep 11 2020, 4:51 AM.

Description

[analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to VA_ARGS

In short, macro expansions handled the case where a variadic parameter mapped to
multiple arguments, but not the other way around. An internal ticket was
submitted that demonstrated that we fail an assertion. Macro expansion so far
worked by lexing the source code token-by-token and using the Preprocessor to
turn these tokens into identifiers or just get their proper spelling, but what
this counter intuitively doesn't do, is actually expand these macros, so we have
to do the heavy lifting -- in this case, figure out what VA_ARGS expands
into. Since this case can only occur in a nested macro, the information we
gathered from the containing macro does contain this information. If a parameter
resolves to VA_ARGS, we need to temporarily stop getting our tokens from the
lexer, and get the tokens from what VA_ARGS maps to.

Differential Revision: https://reviews.llvm.org/D86135