diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-02-03 05:58:22 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-02-03 05:58:22 +0000 |
commit | cbf46a0b2bb2b47d6e13437e0d52cc583c5ce539 (patch) | |
tree | 5340c9ce936d820fd757cef447feeaca57b78c00 /include/clang/Basic/PartialDiagnostic.h | |
parent | 8deabc133c121f6c5561d0b2171a41cb2c29b2ce (diff) |
Change the fixed array of FixitHints to a SmallVector to lift off
the limit on the number of fixits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h index 6049123148..f6092e6858 100644 --- a/include/clang/Basic/PartialDiagnostic.h +++ b/include/clang/Basic/PartialDiagnostic.h @@ -30,12 +30,11 @@ public: // DiagnosticsEngine are private but DiagnosticsEngine declares // PartialDiagnostic a friend. These enum values are redeclared // here so that the nested Storage class below can access them. - MaxArguments = DiagnosticsEngine::MaxArguments, - MaxFixItHints = DiagnosticsEngine::MaxFixItHints + MaxArguments = DiagnosticsEngine::MaxArguments }; struct Storage { - Storage() : NumDiagArgs(0), NumDiagRanges(0), NumFixItHints(0) { } + Storage() : NumDiagArgs(0), NumDiagRanges(0) { } enum { /// MaxArguments - The maximum number of arguments we can hold. We @@ -51,10 +50,6 @@ public: /// NumDiagRanges - This is the number of ranges in the DiagRanges array. unsigned char NumDiagRanges; - /// \brief The number of code modifications hints in the - /// FixItHints array. - unsigned char NumFixItHints; - /// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum /// values, with one for each argument. This specifies whether the argument /// is in DiagArgumentsStr or in DiagArguments. @@ -74,11 +69,9 @@ public: /// only support 10 ranges, could easily be extended if needed. CharSourceRange DiagRanges[10]; - enum { MaxFixItHints = PartialDiagnostic::MaxFixItHints }; - /// FixItHints - If valid, provides a hint with some code /// to insert, remove, or modify at a particular position. - FixItHint FixItHints[MaxFixItHints]; + SmallVector<FixItHint, 6> FixItHints; }; /// \brief An allocator for Storage objects, which uses a small cache to @@ -101,7 +94,7 @@ public: Storage *Result = FreeList[--NumFreeListEntries]; Result->NumDiagArgs = 0; Result->NumDiagRanges = 0; - Result->NumFixItHints = 0; + Result->FixItHints.clear(); return Result; } @@ -172,12 +165,7 @@ private: if (!DiagStorage) DiagStorage = getStorage(); - assert(DiagStorage->NumFixItHints < Storage::MaxFixItHints && - "Too many code modification hints!"); - if (DiagStorage->NumFixItHints >= Storage::MaxFixItHints) - return; // Don't crash in release builds - DiagStorage->FixItHints[DiagStorage->NumFixItHints++] - = Hint; + DiagStorage->FixItHints.push_back(Hint); } public: @@ -281,7 +269,7 @@ public: DB.AddSourceRange(DiagStorage->DiagRanges[i]); // Add all fix-its. - for (unsigned i = 0, e = DiagStorage->NumFixItHints; i != e; ++i) + for (unsigned i = 0, e = DiagStorage->FixItHints.size(); i != e; ++i) DB.AddFixItHint(DiagStorage->FixItHints[i]); } |