summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-05-05 07:54:59 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-05-05 07:54:59 +0000
commite9af37d2e1737dac5ddf9d4ca25c43845522a886 (patch)
treebefe5ebf0d344fd47b2eb1fc3479fa15c85c3d86 /clang/lib
parenta48b1375df09ff74ad26ad26751955127d179940 (diff)
downloadbcm5719-llvm-e9af37d2e1737dac5ddf9d4ca25c43845522a886.tar.gz
bcm5719-llvm-e9af37d2e1737dac5ddf9d4ca25c43845522a886.zip
Introduce a Diagnostic::Report function that accepts and emits a StoredDiagnostic.
llvm-svn: 130919
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Diagnostic.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index e8cd21885d2..c79fe7b83d3 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -212,6 +212,42 @@ void Diagnostic::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
FullSourceLoc(Loc, *SourceMgr)));
}
+void Diagnostic::Report(const StoredDiagnostic &storedDiag) {
+ assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
+
+ CurDiagLoc = storedDiag.getLocation();
+ CurDiagID = storedDiag.getID();
+ NumDiagArgs = 0;
+
+ NumDiagRanges = storedDiag.range_size();
+ assert(NumDiagRanges < sizeof(DiagRanges)/sizeof(DiagRanges[0]) &&
+ "Too many arguments to diagnostic!");
+ unsigned i = 0;
+ for (StoredDiagnostic::range_iterator
+ RI = storedDiag.range_begin(),
+ RE = storedDiag.range_end(); RI != RE; ++RI)
+ DiagRanges[i++] = *RI;
+
+ NumFixItHints = storedDiag.fixit_size();
+ assert(NumFixItHints < Diagnostic::MaxFixItHints && "Too many fix-it hints!");
+ i = 0;
+ for (StoredDiagnostic::fixit_iterator
+ FI = storedDiag.fixit_begin(),
+ FE = storedDiag.fixit_end(); FI != FE; ++FI)
+ FixItHints[i++] = *FI;
+
+ assert(Client && "DiagnosticClient not set!");
+ Level DiagLevel = storedDiag.getLevel();
+ DiagnosticInfo Info(this, storedDiag.getMessage());
+ Client->HandleDiagnostic(DiagLevel, Info);
+ if (Client->IncludeInDiagnosticCounts()) {
+ if (DiagLevel == Diagnostic::Warning)
+ ++NumWarnings;
+ }
+
+ CurDiagID = ~0U;
+}
+
void DiagnosticBuilder::FlushCounts() {
DiagObj->NumDiagArgs = NumArgs;
DiagObj->NumDiagRanges = NumRanges;
@@ -486,6 +522,11 @@ static void HandlePluralModifier(const DiagnosticInfo &DInfo, unsigned ValNo,
/// array.
void DiagnosticInfo::
FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
+ if (!StoredDiagMessage.empty()) {
+ OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
+ return;
+ }
+
const char *DiagStr = getDiags()->getDiagnosticIDs()->getDescription(getID());
const char *DiagEnd = DiagStr+strlen(DiagStr);
OpenPOWER on IntegriCloud