aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-01-10 15:05:09 +0000
committerAlexander Kornienko <alexfh@google.com>2013-01-10 15:05:09 +0000
commit3048aeae0654b34dcae561494c1b28872c88a5c8 (patch)
treec1e7d87e4041429ea47308b19cfca5244f7ec83f /lib/Format/UnwrappedLineParser.cpp
parent2851c16443dcdb9d8bb509d321fb827a560b47bc (diff)
Basic support for diagnostics.
Summary: Uses DiagnosticsEngine to output diagnostics. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D278 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--lib/Format/UnwrappedLineParser.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index e9c6211313..a6c5c165ff 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include "UnwrappedLineParser.h"
+#include "clang/Basic/Diagnostic.h"
#include "llvm/Support/raw_ostream.h"
// Uncomment to get debug output from the UnwrappedLineParser.
@@ -110,12 +111,12 @@ private:
bool PreBlockRootTokenInitialized;
};
-UnwrappedLineParser::UnwrappedLineParser(const FormatStyle &Style,
- FormatTokenSource &Tokens,
- UnwrappedLineConsumer &Callback)
+UnwrappedLineParser::UnwrappedLineParser(
+ clang::DiagnosticsEngine &Diag, const FormatStyle &Style,
+ FormatTokenSource &Tokens, UnwrappedLineConsumer &Callback)
: Line(new UnwrappedLine), RootTokenInitialized(false),
- LastInCurrentLine(NULL), MustBreakBeforeNextToken(false), Style(Style),
- Tokens(&Tokens), Callback(Callback) {
+ LastInCurrentLine(NULL), MustBreakBeforeNextToken(false), Diag(Diag),
+ Style(Style), Tokens(&Tokens), Callback(Callback) {
}
bool UnwrappedLineParser::parse() {
@@ -149,7 +150,9 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
if (HasOpeningBrace) {
return false;
} else {
- // Stray '}' is an error.
+ Diag.Report(FormatTok.Tok.getLocation(),
+ Diag.getCustomDiagID(clang::DiagnosticsEngine::Error,
+ "Stray '}' found"));
Error = true;
nextToken();
addUnwrappedLine();