summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp7
-rw-r--r--clang/lib/Format/UnwrappedLineParser.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index c1bafa9a3b1..2f3a6034bcf 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -27,10 +27,11 @@ public:
ScopedMacroState(UnwrappedLine &Line, FormatTokenSource *&TokenSource,
FormatToken &ResetToken)
: Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
- PreviousTokenSource(TokenSource) {
+ PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource) {
TokenSource = this;
// FIXME: Back up all other state (errors, line indent, etc) and reset after
// parsing the macro.
+ Line.Level = 0;
Line.InPPDirective = true;
}
@@ -38,7 +39,7 @@ public:
TokenSource = PreviousTokenSource;
ResetToken = Token;
Line.InPPDirective = false;
- Line.Level = 0; // FIXME: Test + this is obviously incorrect
+ Line.Level = PreviousLineLevel;
}
virtual FormatToken getNextToken() {
@@ -65,7 +66,7 @@ private:
UnwrappedLine &Line;
FormatTokenSource *&TokenSource;
FormatToken &ResetToken;
-
+ unsigned PreviousLineLevel;
FormatTokenSource *PreviousTokenSource;
FormatToken Token;
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h
index 69ac7683254..a8e5b739bc8 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -124,6 +124,9 @@ private:
void nextToken();
void readToken();
+ // FIXME: We are constantly running into bugs where Line.Level is incorrectly
+ // subtracted from beyond 0. Introduce a method to subtract from Line.Level
+ // and use that everywhere in the Parser.
UnwrappedLine Line;
FormatToken FormatTok;
OpenPOWER on IntegriCloud