Vedant Kumar 95a2a7f2a1 [Lexer] Don't merge macro args from different macro files
The lexer sets the end location of macro arguments incorrectly *if*,
while merging consecutive args to fit into a single SLocEntry, it finds
args which come from different macro files.

Fix the issue by using separate SLocEntries in this situation.

This fixes a code coverage crasher (rdar://problem/26181005). Because
the lexer reported end locations for certain macro args incorrectly, we
would generate bogus coverage mappings with negative line offsets.

Reviewed-by: akyrtzi

Differential Revision: http://reviews.llvm.org/D20401

llvm-svn: 270160
2016-05-19 23:44:02 +00:00

14 lines
529 B
C

// Assorted macros to help test #include behavior across file boundaries.
#define helper1 0
void helper2(const char *, ...);
#define M1(a, ...) helper2(a, ##__VA_ARGS__);
// Note: M2 stresses vararg macro functions with macro arguments. The spelling
// locations of the args used to be set to the expansion site, leading to
// crashes (region LineEnd < LineStart). The regression test requires M2's line
// number to be greater than the line number containing the expansion.
#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__);