summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/PartialDiagnostic.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-02-07 22:29:24 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-02-07 22:29:24 +0000
commitd7a3e2c5f61cd4893f95b69a424fe4def3aa0f69 (patch)
tree97e42c8f768c6c5dd0bb147397b71feacb927c21 /include/clang/Basic/PartialDiagnostic.h
parent77e4bcacd5c80d8bffe19a4489b5f059b618d4bc (diff)
Revert my patches which removed Diagnostic.h includes by moving some operator overloads out of line.
This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r--include/clang/Basic/PartialDiagnostic.h150
1 files changed, 77 insertions, 73 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index 7bc9f54655..f6092e6858 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -23,87 +23,91 @@
namespace clang {
-struct PartialDiagnosticStorage {
- PartialDiagnosticStorage() : NumDiagArgs(0), NumDiagRanges(0) { }
-
+class PartialDiagnostic {
+public:
enum {
- /// MaxArguments - The maximum number of arguments we can hold. We
- /// currently only support up to 10 arguments (%0-%9).
- /// A single diagnostic with more than that almost certainly has to
- /// be simplified anyway.
+ // The MaxArguments and MaxFixItHints member enum values from
+ // 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
};
- /// NumDiagArgs - This contains the number of entries in Arguments.
- unsigned char NumDiagArgs;
-
- /// NumDiagRanges - This is the number of ranges in the DiagRanges array.
- unsigned char NumDiagRanges;
-
- /// 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.
- unsigned char DiagArgumentsKind[MaxArguments];
-
- /// DiagArgumentsVal - The values for the various substitution positions.
- /// This is used when the argument is not an std::string. The specific value
- /// is mangled into an intptr_t and the interpretation depends on exactly
- /// what sort of argument kind it is.
- intptr_t DiagArgumentsVal[MaxArguments];
-
- /// \brief The values for the various substitution positions that have
- /// string arguments.
- std::string DiagArgumentsStr[MaxArguments];
-
- /// DiagRanges - The list of ranges added to this diagnostic. It currently
- /// only support 10 ranges, could easily be extended if needed.
- CharSourceRange DiagRanges[10];
-
- /// FixItHints - If valid, provides a hint with some code
- /// to insert, remove, or modify at a particular position.
- SmallVector<FixItHint, 6> FixItHints;
-};
-
-/// \brief An allocator for Storage objects, which uses a small cache to
-/// objects, used to reduce malloc()/free() traffic for partial diagnostics.
-class PartialDiagnosticStorageAllocator {
- static const unsigned NumCached = 16;
- typedef PartialDiagnosticStorage Storage;
- Storage Cached[NumCached];
- Storage *FreeList[NumCached];
- unsigned NumFreeListEntries;
-
-public:
- PartialDiagnosticStorageAllocator();
- ~PartialDiagnosticStorageAllocator();
-
- /// \brief Allocate new storage.
- Storage *Allocate() {
- if (NumFreeListEntries == 0)
- return new Storage;
-
- Storage *Result = FreeList[--NumFreeListEntries];
- Result->NumDiagArgs = 0;
- Result->NumDiagRanges = 0;
- Result->FixItHints.clear();
- return Result;
- }
+ struct Storage {
+ Storage() : NumDiagArgs(0), NumDiagRanges(0) { }
+
+ enum {
+ /// MaxArguments - The maximum number of arguments we can hold. We
+ /// currently only support up to 10 arguments (%0-%9).
+ /// A single diagnostic with more than that almost certainly has to
+ /// be simplified anyway.
+ MaxArguments = PartialDiagnostic::MaxArguments
+ };
+
+ /// NumDiagArgs - This contains the number of entries in Arguments.
+ unsigned char NumDiagArgs;
+
+ /// NumDiagRanges - This is the number of ranges in the DiagRanges array.
+ unsigned char NumDiagRanges;
+
+ /// 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.
+ unsigned char DiagArgumentsKind[MaxArguments];
+
+ /// DiagArgumentsVal - The values for the various substitution positions.
+ /// This is used when the argument is not an std::string. The specific value
+ /// is mangled into an intptr_t and the interpretation depends on exactly
+ /// what sort of argument kind it is.
+ intptr_t DiagArgumentsVal[MaxArguments];
+
+ /// \brief The values for the various substitution positions that have
+ /// string arguments.
+ std::string DiagArgumentsStr[MaxArguments];
+
+ /// DiagRanges - The list of ranges added to this diagnostic. It currently
+ /// only support 10 ranges, could easily be extended if needed.
+ CharSourceRange DiagRanges[10];
+
+ /// FixItHints - If valid, provides a hint with some code
+ /// to insert, remove, or modify at a particular position.
+ SmallVector<FixItHint, 6> FixItHints;
+ };
- /// \brief Free the given storage object.
- void Deallocate(Storage *S) {
- if (S >= Cached && S <= Cached + NumCached) {
- FreeList[NumFreeListEntries++] = S;
- return;
+ /// \brief An allocator for Storage objects, which uses a small cache to
+ /// objects, used to reduce malloc()/free() traffic for partial diagnostics.
+ class StorageAllocator {
+ static const unsigned NumCached = 16;
+ Storage Cached[NumCached];
+ Storage *FreeList[NumCached];
+ unsigned NumFreeListEntries;
+
+ public:
+ StorageAllocator();
+ ~StorageAllocator();
+
+ /// \brief Allocate new storage.
+ Storage *Allocate() {
+ if (NumFreeListEntries == 0)
+ return new Storage;
+
+ Storage *Result = FreeList[--NumFreeListEntries];
+ Result->NumDiagArgs = 0;
+ Result->NumDiagRanges = 0;
+ Result->FixItHints.clear();
+ return Result;
}
- delete S;
- }
-};
+ /// \brief Free the given storage object.
+ void Deallocate(Storage *S) {
+ if (S >= Cached && S <= Cached + NumCached) {
+ FreeList[NumFreeListEntries++] = S;
+ return;
+ }
-class PartialDiagnostic {
-public:
- typedef PartialDiagnosticStorage Storage;
- typedef PartialDiagnosticStorageAllocator StorageAllocator;
+ delete S;
+ }
+ };
private:
// NOTE: Sema assumes that PartialDiagnostic is location-invariant