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
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index e9c6211..a6c5c16 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 @@
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 @@
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();