summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/Diagnostic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Basic/Diagnostic.h')
-rw-r--r--include/clang/Basic/Diagnostic.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index c5d6d7c..d2516f8 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -23,16 +23,19 @@
namespace llvm {
template <typename T> class SmallVectorImpl;
+ class raw_ostream;
}
namespace clang {
class DeclContext;
class DiagnosticBuilder;
class DiagnosticClient;
+ class FileManager;
class IdentifierInfo;
class LangOptions;
class PartialDiagnostic;
class Preprocessor;
+ class SourceManager;
class SourceRange;
// Import the diagnostic enums themselves.
@@ -400,6 +403,13 @@ public:
/// \brief Clear out the current diagnostic.
void Clear() { CurDiagID = ~0U; }
+ /// Deserialize - Deserialize the first diagnostic within the memory
+ /// [Memory, MemoryEnd), producing a new diagnostic builder describing the
+ /// deserialized diagnostic. If the memory does not contain a
+ /// diagnostic, returns a diagnostic builder with no diagnostic ID.
+ DiagnosticBuilder Deserialize(FileManager &FM, SourceManager &SM,
+ const char *&Memory, const char *MemoryEnd);
+
private:
/// getDiagnosticMappingInfo - Return the mapping info currently set for the
/// specified builtin diagnostic. This returns the high bit encoding, or zero
@@ -472,7 +482,7 @@ private:
/// DiagRanges - The list of ranges added to this diagnostic. It currently
/// only support 10 ranges, could easily be extended if needed.
- const SourceRange *DiagRanges[10];
+ SourceRange DiagRanges[10];
enum { MaxCodeModificationHints = 3 };
@@ -568,6 +578,9 @@ public:
/// been emitted.
~DiagnosticBuilder() { Emit(); }
+ /// isActive - Determine whether this diagnostic is still active.
+ bool isActive() const { return DiagObj != 0; }
+
/// Operator bool: conversion of DiagnosticBuilder to bool always returns
/// true. This allows is to be used in boolean error contexts like:
/// return Diag(...);
@@ -596,7 +609,7 @@ public:
sizeof(DiagObj->DiagRanges)/sizeof(DiagObj->DiagRanges[0]) &&
"Too many arguments to diagnostic!");
if (DiagObj)
- DiagObj->DiagRanges[NumRanges++] = &R;
+ DiagObj->DiagRanges[NumRanges++] = R;
}
void AddCodeModificationHint(const CodeModificationHint &Hint) const {
@@ -759,9 +772,9 @@ public:
return DiagObj->NumDiagRanges;
}
- const SourceRange &getRange(unsigned Idx) const {
+ SourceRange getRange(unsigned Idx) const {
assert(Idx < DiagObj->NumDiagRanges && "Invalid diagnostic range index!");
- return *DiagObj->DiagRanges[Idx];
+ return DiagObj->DiagRanges[Idx];
}
unsigned getNumCodeModificationHints() const {
@@ -786,6 +799,12 @@ public:
/// output buffer using the arguments stored in this diagnostic.
void FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
llvm::SmallVectorImpl<char> &OutStr) const;
+
+ /// Serialize - Serialize the given diagnostic (with its diagnostic
+ /// level) to the given stream. Serialization is a lossy operation,
+ /// since the specific diagnostic ID and any macro-instantiation
+ /// information is lost.
+ void Serialize(Diagnostic::Level DiagLevel, llvm::raw_ostream &OS) const;
};
/// DiagnosticClient - This is an abstract interface implemented by clients of
OpenPOWER on IntegriCloud