r203117 - Added an inserter for ArrayRef<SourceRange>.
David Blaikie
dblaikie at gmail.com
Thu Mar 6 09:14:56 PST 2014
On Thu, Mar 6, 2014 at 5:23 AM, Alexander Kornienko <alexfh at google.com> wrote:
> Author: alexfh
> Date: Thu Mar 6 07:23:30 2014
> New Revision: 203117
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203117&view=rev
> Log:
> Added an inserter for ArrayRef<SourceRange>.
>
> Summary:
> Added an inserter for ArrayRef<SourceRange>, as it is already needed in at least
> two places (static analyzer and clang-tidy).
You may be able to remove the single-argument (SourceRange) version of
this, since ArrayRef<T> is implicitly constructible from T (to create
a single-element ArrayRef<T>). Though the extra user defined
conversion might cause some hiccups.
- David
>
> Reviewers: jordan_rose
>
> CC: cfe-commits, gribozavr
>
> Differential Revision: http://llvm-reviews.chandlerc.com/D2984
>
> Modified:
> cfe/trunk/include/clang/Basic/Diagnostic.h
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=203117&r1=203116&r2=203117&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
> +++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Mar 6 07:23:30 2014
> @@ -1015,7 +1015,8 @@ inline const DiagnosticBuilder &operator
> 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,7 +1053,7 @@ operator<<(const DiagnosticBuilder &DB,
> DiagnosticsEngine::ak_declcontext);
> return DB;
> }
> -
> +
> inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
> const SourceRange &R) {
> DB.AddSourceRange(CharSourceRange::getTokenRange(R));
> @@ -1060,11 +1061,18 @@ inline const DiagnosticBuilder &operator
> }
>
> 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())
> @@ -1073,7 +1081,7 @@ inline const DiagnosticBuilder &operator
> }
>
> inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
> - unsigned DiagID){
> + unsigned DiagID) {
> assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
> CurDiagLoc = Loc;
> CurDiagID = DiagID;
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=203117&r1=203116&r2=203117&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Thu Mar 6 07:23:30 2014
> @@ -103,14 +103,6 @@ public:
> 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 @@ public:
> 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 @@ public:
> 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();
> }
> }
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list