aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-21 06:59:12 +0000
committerChris Lattner <sabre@nondot.org>2008-11-21 06:59:12 +0000
commitb7fc3b87d065041a10eaa0603d738df21ff7af3a (patch)
tree1bdee477a6826e40738f2dbddfd330141ebe761e
parent2cb836eb16afea6a7e07109bdec37e85c44d7bd7 (diff)
move the diagnostic location and ID out of DiagnosticInfo and store it in
the Diagnostic class. Since we can already only have one diagnostic in flight at a time, this shrinks DiagnosticInfo. This reduces DiagnosticInfo to being basically a rather crazy smart pointer to a DiagnosticInfo :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59798 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/Diagnostic.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index 94c77406ae..e6fe2a4a7b 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -182,7 +182,14 @@ private:
// tradeoff to keep these objects small. Assertions verify that only one
// diagnostic is in flight at a time.
friend class DiagnosticInfo;
+
+ /// CurDiagLoc - This is the location of the current diagnostic that is in
+ /// flight.
+ FullSourceLoc CurDiagLoc;
+ /// CurDiagID - This is the ID of the current diagnostic that is in flight.
+ unsigned CurDiagID;
+
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
@@ -233,8 +240,6 @@ private:
/// for more info.
class DiagnosticInfo {
mutable Diagnostic *DiagObj;
- FullSourceLoc Loc;
- unsigned DiagID;
void operator=(const DiagnosticInfo&); // DO NOT IMPLEMENT
public:
enum ArgumentKind {
@@ -246,20 +251,20 @@ public:
};
- DiagnosticInfo(Diagnostic *diagObj, FullSourceLoc loc, unsigned diagID) :
- DiagObj(diagObj), Loc(loc), DiagID(diagID) {
+ DiagnosticInfo(Diagnostic *diagObj, FullSourceLoc Loc, unsigned DiagID) :
+ DiagObj(diagObj) {
if (DiagObj == 0) return;
assert(DiagObj->NumDiagArgs == -1 &&
"Multiple diagnostics in flight at once!");
DiagObj->NumDiagArgs = DiagObj->NumDiagRanges = 0;
+ DiagObj->CurDiagLoc = Loc;
+ DiagObj->CurDiagID = DiagID;
}
/// Copy constructor. When copied, this "takes" the diagnostic info from the
/// input and neuters it.
DiagnosticInfo(const DiagnosticInfo &D) {
DiagObj = D.DiagObj;
- Loc = D.Loc;
- DiagID = D.DiagID;
D.DiagObj = 0;
}
@@ -275,8 +280,8 @@ public:
}
const Diagnostic *getDiags() const { return DiagObj; }
- unsigned getID() const { return DiagID; }
- const FullSourceLoc &getLocation() const { return Loc; }
+ unsigned getID() const { return DiagObj->CurDiagID; }
+ const FullSourceLoc &getLocation() const { return DiagObj->CurDiagLoc; }
/// Operator bool: conversion of DiagnosticInfo to bool always returns true.
/// This allows is to be used in boolean error contexts like: