diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-05-22 19:56:11 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-05-22 19:56:11 +0000 |
commit | c2f2b74ec2885c7a6f2a96a4626bac42269fbcf6 (patch) | |
tree | 65a23facd270401a144e869427dc968cce99612d /include/clang/Basic/PartialDiagnostic.h | |
parent | 3c19b124a8004cc5a1371a720692df6b6469fa32 (diff) |
Remove limits on the number of fix-it hints and ranges in the DiagnosticsEngine.
Summary:
The limits on the number of fix-it hints and ranges attached to a
diagnostic are arbitrary and don't apply universally to all users of the
DiagnosticsEngine. The way the limits are enforced may lead to diagnostics
generating invalid sets of fixes. I suggest removing the limits, which will also
simplify the implementation.
Reviewers: rsmith
Reviewed By: rsmith
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D3879
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209468 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h index f5418c02d7..bb55b626b7 100644 --- a/include/clang/Basic/PartialDiagnostic.h +++ b/include/clang/Basic/PartialDiagnostic.h @@ -36,7 +36,7 @@ public: }; struct Storage { - Storage() : NumDiagArgs(0), NumDiagRanges(0) { } + Storage() : NumDiagArgs(0) { } enum { /// \brief The maximum number of arguments we can hold. We @@ -50,9 +50,6 @@ public: /// \brief The number of entries in Arguments. unsigned char NumDiagArgs; - /// \brief This is the number of ranges in the DiagRanges array. - unsigned char NumDiagRanges; - /// \brief Specifies for each argument whether it is in DiagArgumentsStr /// or in DiagArguments. unsigned char DiagArgumentsKind[MaxArguments]; @@ -69,9 +66,7 @@ public: std::string DiagArgumentsStr[MaxArguments]; /// \brief The list of ranges added to this diagnostic. - /// - /// It currently only support 10 ranges, could easily be extended if needed. - CharSourceRange DiagRanges[10]; + SmallVector<CharSourceRange, 8> DiagRanges; /// \brief If valid, provides a hint with some code to insert, remove, or /// modify at a particular position. @@ -97,7 +92,6 @@ public: Storage *Result = FreeList[--NumFreeListEntries]; Result->NumDiagArgs = 0; - Result->NumDiagRanges = 0; Result->FixItHints.clear(); return Result; } @@ -166,10 +160,7 @@ private: if (!DiagStorage) DiagStorage = getStorage(); - assert(DiagStorage->NumDiagRanges < - llvm::array_lengthof(DiagStorage->DiagRanges) && - "Too many arguments to diagnostic!"); - DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R; + DiagStorage->DiagRanges.push_back(R); } void AddFixItHint(const FixItHint &Hint) const { @@ -308,12 +299,12 @@ public: } // Add all ranges. - for (unsigned i = 0, e = DiagStorage->NumDiagRanges; i != e; ++i) - DB.AddSourceRange(DiagStorage->DiagRanges[i]); + for (const CharSourceRange &Range : DiagStorage->DiagRanges) + DB.AddSourceRange(Range); // Add all fix-its. - for (unsigned i = 0, e = DiagStorage->FixItHints.size(); i != e; ++i) - DB.AddFixItHint(DiagStorage->FixItHints[i]); + for (const FixItHint &Fix : DiagStorage->FixItHints) + DB.AddFixItHint(Fix); } void EmitToString(DiagnosticsEngine &Diags, |