[PATCH] Added an inserter for ArrayRef<SourceRange>.
Alexander Kornienko
alexfh at google.com
Thu Mar 6 04:50:41 PST 2014
Hi jordan_rose,
Added an inserter for ArrayRef<SourceRange>, as it is already needed in at least
two places (static analyzer and clang-tidy).
http://llvm-reviews.chandlerc.com/D2984
Files:
include/clang/Basic/Diagnostic.h
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Index: include/clang/Basic/Diagnostic.h
===================================================================
--- include/clang/Basic/Diagnostic.h
+++ include/clang/Basic/Diagnostic.h
@@ -1015,7 +1015,8 @@
return DB;
}
-inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,bool I) {
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ bool I) {
DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
return DB;
}
@@ -1052,28 +1053,35 @@
DiagnosticsEngine::ak_declcontext);
return DB;
}
-
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const SourceRange &R) {
DB.AddSourceRange(CharSourceRange::getTokenRange(R));
return DB;
}
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+ ArrayRef<SourceRange> Ranges) {
+ for (const SourceRange &R: Ranges)
+ DB.AddSourceRange(CharSourceRange::getTokenRange(R));
+ return DB;
+}
+
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const CharSourceRange &R) {
DB.AddSourceRange(R);
return DB;
}
-
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const FixItHint &Hint) {
if (!Hint.isNull())
DB.AddFixItHint(Hint);
return DB;
}
inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
- unsigned DiagID){
+ unsigned DiagID) {
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
CurDiagLoc = Loc;
CurDiagID = DiagID;
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===================================================================
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -103,14 +103,6 @@
IncludePath = true;
}
- const DiagnosticBuilder &addRanges(const DiagnosticBuilder &DB,
- ArrayRef<SourceRange> Ranges) {
- for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end();
- I != E; ++I)
- DB << *I;
- return DB;
- }
-
void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags,
FilesMade *filesMade) {
unsigned WarnID = Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
@@ -120,8 +112,8 @@
E = Diags.end(); I != E; ++I) {
const PathDiagnostic *PD = *I;
SourceLocation WarnLoc = PD->getLocation().asLocation();
- addRanges(Diag.Report(WarnLoc, WarnID) << PD->getShortDescription(),
- PD->path.back()->getRanges());
+ Diag.Report(WarnLoc, WarnID) << PD->getShortDescription()
+ << PD->path.back()->getRanges();
if (!IncludePath)
continue;
@@ -131,8 +123,8 @@
PE = FlatPath.end();
PI != PE; ++PI) {
SourceLocation NoteLoc = (*PI)->getLocation().asLocation();
- addRanges(Diag.Report(NoteLoc, NoteID) << (*PI)->getString(),
- (*PI)->getRanges());
+ Diag.Report(NoteLoc, NoteID) << (*PI)->getString()
+ << (*PI)->getRanges();
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2984.1.patch
Type: text/x-patch
Size: 3481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140306/dcc62a45/attachment.bin>
More information about the cfe-commits
mailing list