aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/MacroInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-09 20:33:32 +0000
committerChris Lattner <sabre@nondot.org>2009-03-09 20:33:32 +0000
commit688a248e03f31312161db97e5e11a950b5b1369c (patch)
treee05e9bb59ec02d3c916fb16a3c712fce15f37731 /lib/Lex/MacroInfo.cpp
parentc3c489e64219b132c23110d6ba8d0d4e121bc5f8 (diff)
fix PR3764 - A redefinition of a pre-processor macro fails
Redefinition checking should ignore the leading whitespace and start of line flags on the first token of an expansion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/MacroInfo.cpp')
-rw-r--r--lib/Lex/MacroInfo.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Lex/MacroInfo.cpp b/lib/Lex/MacroInfo.cpp
index de19ff502a..df89450f5a 100644
--- a/lib/Lex/MacroInfo.cpp
+++ b/lib/Lex/MacroInfo.cpp
@@ -49,9 +49,14 @@ bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const {
for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) {
const Token &A = ReplacementTokens[i];
const Token &B = Other.ReplacementTokens[i];
- if (A.getKind() != B.getKind() ||
- A.isAtStartOfLine() != B.isAtStartOfLine() ||
- A.hasLeadingSpace() != B.hasLeadingSpace())
+ if (A.getKind() != B.getKind())
+ return false;
+
+ // If this isn't the first first token, check that the whitespace and
+ // start-of-line characteristics match.
+ if (i != 0 &&
+ (A.isAtStartOfLine() != B.isAtStartOfLine() ||
+ A.hasLeadingSpace() != B.hasLeadingSpace()))
return false;
// If this is an identifier, it is easy.