diff options
author | David Blaikie <dblaikie@gmail.com> | 2011-09-25 23:23:43 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2011-09-25 23:23:43 +0000 |
commit | d6471f7c1921c7802804ce3ff6fe9768310f72b9 (patch) | |
tree | f8559e8ca7afb0328fab36e22a34e55ce566008d /lib/Basic | |
parent | 026cb7604c8ef0bc7032e4c067500907d03b67a3 (diff) |
Rename Diagnostic to DiagnosticsEngine as per issue 5397
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic')
-rw-r--r-- | lib/Basic/Diagnostic.cpp | 85 | ||||
-rw-r--r-- | lib/Basic/DiagnosticIDs.cpp | 28 | ||||
-rw-r--r-- | lib/Basic/SourceManager.cpp | 8 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 2 |
4 files changed, 63 insertions, 60 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 0e4159db8d..87a3d1c9b5 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -20,10 +20,10 @@ using namespace clang; -static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT, +static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, const char *Modifier, unsigned ML, const char *Argument, unsigned ArgLen, - const Diagnostic::ArgumentValue *PrevArgs, + const DiagnosticsEngine::ArgumentValue *PrevArgs, unsigned NumPrevArgs, SmallVectorImpl<char> &Output, void *Cookie, @@ -33,7 +33,8 @@ static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT, } -Diagnostic::Diagnostic(const llvm::IntrusiveRefCntPtr<DiagnosticIDs> &diags, +DiagnosticsEngine::DiagnosticsEngine( + const llvm::IntrusiveRefCntPtr<DiagnosticIDs> &diags, DiagnosticClient *client, bool ShouldOwnClient) : Diags(diags), Client(client), OwnsDiagClient(ShouldOwnClient), SourceMgr(0) { @@ -56,12 +57,13 @@ Diagnostic::Diagnostic(const llvm::IntrusiveRefCntPtr<DiagnosticIDs> &diags, Reset(); } -Diagnostic::~Diagnostic() { +DiagnosticsEngine::~DiagnosticsEngine() { if (OwnsDiagClient) delete Client; } -void Diagnostic::setClient(DiagnosticClient *client, bool ShouldOwnClient) { +void DiagnosticsEngine::setClient(DiagnosticClient *client, + bool ShouldOwnClient) { if (OwnsDiagClient && Client) delete Client; @@ -69,11 +71,11 @@ void Diagnostic::setClient(DiagnosticClient *client, bool ShouldOwnClient) { OwnsDiagClient = ShouldOwnClient; } -void Diagnostic::pushMappings(SourceLocation Loc) { +void DiagnosticsEngine::pushMappings(SourceLocation Loc) { DiagStateOnPushStack.push_back(GetCurDiagState()); } -bool Diagnostic::popMappings(SourceLocation Loc) { +bool DiagnosticsEngine::popMappings(SourceLocation Loc) { if (DiagStateOnPushStack.empty()) return false; @@ -85,7 +87,7 @@ bool Diagnostic::popMappings(SourceLocation Loc) { return true; } -void Diagnostic::Reset() { +void DiagnosticsEngine::Reset() { ErrorOccurred = false; FatalErrorOccurred = false; UnrecoverableErrorOccurred = false; @@ -98,8 +100,8 @@ void Diagnostic::Reset() { CurDiagID = ~0U; // Set LastDiagLevel to an "unset" state. If we set it to 'Ignored', notes - // using a Diagnostic associated to a translation unit that follow - // diagnostics from a Diagnostic associated to anoter t.u. will not be + // using a DiagnosticsEngine associated to a translation unit that follow + // diagnostics from a DiagnosticsEngine associated to anoter t.u. will not be // displayed. LastDiagLevel = (DiagnosticIDs::Level)-1; DelayedDiagID = 0; @@ -115,7 +117,7 @@ void Diagnostic::Reset() { PushDiagStatePoint(&DiagStates.back(), SourceLocation()); } -void Diagnostic::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1, +void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1, StringRef Arg2) { if (DelayedDiagID) return; @@ -125,15 +127,15 @@ void Diagnostic::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1, DelayedDiagArg2 = Arg2.str(); } -void Diagnostic::ReportDelayed() { +void DiagnosticsEngine::ReportDelayed() { Report(DelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2; DelayedDiagID = 0; DelayedDiagArg1.clear(); DelayedDiagArg2.clear(); } -Diagnostic::DiagStatePointsTy::iterator -Diagnostic::GetDiagStatePointForLoc(SourceLocation L) const { +DiagnosticsEngine::DiagStatePointsTy::iterator +DiagnosticsEngine::GetDiagStatePointForLoc(SourceLocation L) const { assert(!DiagStatePoints.empty()); assert(DiagStatePoints.front().Loc.isInvalid() && "Should have created a DiagStatePoint for command-line"); @@ -158,7 +160,7 @@ Diagnostic::GetDiagStatePointForLoc(SourceLocation L) const { /// /// \param The source location that this change of diagnostic state should /// take affect. It can be null if we are setting the latest state. -void Diagnostic::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map, +void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map, SourceLocation L) { assert(Diag < diag::DIAG_UPPER_LIMIT && "Can only map builtin diagnostics"); @@ -218,7 +220,7 @@ void Diagnostic::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map, FullSourceLoc(Loc, *SourceMgr))); } -void Diagnostic::Report(const StoredDiagnostic &storedDiag) { +void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) { assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!"); CurDiagLoc = storedDiag.getLocation(); @@ -235,7 +237,8 @@ void Diagnostic::Report(const StoredDiagnostic &storedDiag) { DiagRanges[i++] = *RI; NumFixItHints = storedDiag.fixit_size(); - assert(NumFixItHints < Diagnostic::MaxFixItHints && "Too many fix-it hints!"); + assert(NumFixItHints < DiagnosticsEngine::MaxFixItHints && + "Too many fix-it hints!"); i = 0; for (StoredDiagnostic::fixit_iterator FI = storedDiag.fixit_begin(), @@ -247,7 +250,7 @@ void Diagnostic::Report(const StoredDiagnostic &storedDiag) { DiagnosticInfo Info(this, storedDiag.getMessage()); Client->HandleDiagnostic(DiagLevel, Info); if (Client->IncludeInDiagnosticCounts()) { - if (DiagLevel == Diagnostic::Warning) + if (DiagLevel == DiagnosticsEngine::Warning) ++NumWarnings; } @@ -266,7 +269,7 @@ bool DiagnosticBuilder::Emit() { if (DiagObj == 0) return false; // When emitting diagnostics, we set the final argument count into - // the Diagnostic object. + // the DiagnosticsEngine object. FlushCounts(); // Process the diagnostic, sending the accumulated information to the @@ -290,14 +293,14 @@ bool DiagnosticBuilder::Emit() { DiagnosticClient::~DiagnosticClient() {} -void DiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel, +void DiagnosticClient::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const DiagnosticInfo &Info) { if (!IncludeInDiagnosticCounts()) return; - if (DiagLevel == Diagnostic::Warning) + if (DiagLevel == DiagnosticsEngine::Warning) ++NumWarnings; - else if (DiagLevel >= Diagnostic::Error) + else if (DiagLevel >= DiagnosticsEngine::Error) ++NumErrors; } @@ -547,13 +550,13 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, /// ConvertArgToString and pass them into subsequent calls to /// ConvertArgToString, allowing the implementation to avoid redundancies in /// obvious cases. - SmallVector<Diagnostic::ArgumentValue, 8> FormattedArgs; + SmallVector<DiagnosticsEngine::ArgumentValue, 8> FormattedArgs; /// QualTypeVals - Pass a vector of arrays so that QualType names can be /// compared to see if more information is needed to be printed. SmallVector<intptr_t, 2> QualTypeVals; for (unsigned i = 0, e = getNumArgs(); i < e; ++i) - if (getArgKind(i) == Diagnostic::ak_qualtype) + if (getArgKind(i) == DiagnosticsEngine::ak_qualtype) QualTypeVals.push_back(getRawArg(i)); while (DiagStr != DiagEnd) { @@ -603,17 +606,17 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic"); unsigned ArgNo = *DiagStr++ - '0'; - Diagnostic::ArgumentKind Kind = getArgKind(ArgNo); + DiagnosticsEngine::ArgumentKind Kind = getArgKind(ArgNo); switch (Kind) { // ---- STRINGS ---- - case Diagnostic::ak_std_string: { + case DiagnosticsEngine::ak_std_string: { const std::string &S = getArgStdStr(ArgNo); assert(ModifierLen == 0 && "No modifiers for strings yet"); OutStr.append(S.begin(), S.end()); break; } - case Diagnostic::ak_c_string: { + case DiagnosticsEngine::ak_c_string: { const char *S = getArgCStr(ArgNo); assert(ModifierLen == 0 && "No modifiers for strings yet"); @@ -625,7 +628,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, break; } // ---- INTEGERS ---- - case Diagnostic::ak_sint: { + case DiagnosticsEngine::ak_sint: { int Val = getArgSInt(ArgNo); if (ModifierIs(Modifier, ModifierLen, "select")) { @@ -644,7 +647,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, } break; } - case Diagnostic::ak_uint: { + case DiagnosticsEngine::ak_uint: { unsigned Val = getArgUInt(ArgNo); if (ModifierIs(Modifier, ModifierLen, "select")) { @@ -663,7 +666,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, break; } // ---- NAMES and TYPES ---- - case Diagnostic::ak_identifierinfo: { + case DiagnosticsEngine::ak_identifierinfo: { const IdentifierInfo *II = getArgIdentifier(ArgNo); assert(ModifierLen == 0 && "No modifiers for strings yet"); @@ -677,11 +680,11 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, llvm::raw_svector_ostream(OutStr) << '\'' << II->getName() << '\''; break; } - case Diagnostic::ak_qualtype: - case Diagnostic::ak_declarationname: - case Diagnostic::ak_nameddecl: - case Diagnostic::ak_nestednamespec: - case Diagnostic::ak_declcontext: + case DiagnosticsEngine::ak_qualtype: + case DiagnosticsEngine::ak_declarationname: + case DiagnosticsEngine::ak_nameddecl: + case DiagnosticsEngine::ak_nestednamespec: + case DiagnosticsEngine::ak_declcontext: getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo), Modifier, ModifierLen, Argument, ArgumentLen, @@ -693,10 +696,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, // Remember this argument info for subsequent formatting operations. Turn // std::strings into a null terminated string to make it be the same case as // all the other ones. - if (Kind != Diagnostic::ak_std_string) + if (Kind != DiagnosticsEngine::ak_std_string) FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo))); else - FormattedArgs.push_back(std::make_pair(Diagnostic::ak_c_string, + FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_c_string, (intptr_t)getArgStdStr(ArgNo).c_str())); } @@ -704,11 +707,11 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, StoredDiagnostic::StoredDiagnostic() { } -StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level, unsigned ID, +StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, StringRef Message) : ID(ID), Level(Level), Loc(), Message(Message) { } -StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level, +StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, const DiagnosticInfo &Info) : ID(Info.getID()), Level(Level) { @@ -729,7 +732,7 @@ StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level, FixIts.push_back(Info.getFixItHint(I)); } -StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level, unsigned ID, +StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, StringRef Message, FullSourceLoc Loc, ArrayRef<CharSourceRange> Ranges, ArrayRef<FixItHint> Fixits) @@ -744,7 +747,7 @@ StoredDiagnostic::~StoredDiagnostic() { } /// IncludeInDiagnosticCounts - This method (whose default implementation /// returns true) indicates whether the diagnostics handled by this /// DiagnosticClient should be included in the number of diagnostics -/// reported by Diagnostic. +/// reported by DiagnosticsEngine. bool DiagnosticClient::IncludeInDiagnosticCounts() const { return true; } PartialDiagnostic::StorageAllocator::StorageAllocator() { diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp index dab4663617..eda2f8e19f 100644 --- a/lib/Basic/DiagnosticIDs.cpp +++ b/lib/Basic/DiagnosticIDs.cpp @@ -446,12 +446,12 @@ StringRef DiagnosticIDs::getDescription(unsigned DiagID) const { return CustomDiagInfo->getDescription(DiagID); } -/// getDiagnosticLevel - Based on the way the client configured the Diagnostic -/// object, classify the specified diagnostic ID into a Level, consumable by -/// the DiagnosticClient. +/// getDiagnosticLevel - Based on the way the client configured the +/// DiagnosticsEngine object, classify the specified diagnostic ID into a Level, +/// by consumable the DiagnosticClient. DiagnosticIDs::Level DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, - const Diagnostic &Diag, + const DiagnosticsEngine &Diag, diag::Mapping *mapping) const { // Handle custom diagnostics, which cannot be mapped. if (DiagID >= diag::DIAG_UPPER_LIMIT) @@ -471,15 +471,15 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, DiagnosticIDs::Level DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, - const Diagnostic &Diag, + const DiagnosticsEngine &Diag, diag::Mapping *mapping) const { // Specific non-error diagnostics may be mapped to various levels from ignored // to error. Errors can only be mapped to fatal. DiagnosticIDs::Level Result = DiagnosticIDs::Fatal; - Diagnostic::DiagStatePointsTy::iterator + DiagnosticsEngine::DiagStatePointsTy::iterator Pos = Diag.GetDiagStatePointForLoc(Loc); - Diagnostic::DiagState *State = Pos->State; + DiagnosticsEngine::DiagState *State = Pos->State; // Get the mapping information, if unset, compute it lazily. unsigned MappingInfo = Diag.getDiagnosticMappingInfo((diag::kind)DiagID, @@ -508,7 +508,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, // Otherwise, ignore this diagnostic unless this is an extension diagnostic // and we're mapping them onto warnings or errors. else if (!isBuiltinExtensionDiag(DiagID) || // Not an extension - Diag.ExtBehavior == Diagnostic::Ext_Ignore || // Ext ignored + Diag.ExtBehavior == DiagnosticsEngine::Ext_Ignore || // Ext ignored (MappingInfo & 8) != 0) { // User explicitly mapped it. return DiagnosticIDs::Ignored; } @@ -516,7 +516,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, Result = DiagnosticIDs::Warning; } - if (Diag.ExtBehavior == Diagnostic::Ext_Error) + if (Diag.ExtBehavior == DiagnosticsEngine::Ext_Error) Result = DiagnosticIDs::Error; if (Result == DiagnosticIDs::Error && Diag.ErrorsAsFatal) Result = DiagnosticIDs::Fatal; @@ -541,7 +541,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, // If this is an extension diagnostic and we're in -pedantic-error mode, and // if the user didn't explicitly map it, upgrade to an error. - if (Diag.ExtBehavior == Diagnostic::Ext_Error && + if (Diag.ExtBehavior == DiagnosticsEngine::Ext_Error && (MappingInfo & 8) == 0 && isBuiltinExtensionDiag(DiagID)) Result = DiagnosticIDs::Error; @@ -628,7 +628,7 @@ static bool WarningOptionCompare(const WarningOption &LHS, } static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping, - SourceLocation Loc, Diagnostic &Diag) { + SourceLocation Loc, DiagnosticsEngine &Diag) { // Option exists, poke all the members of its diagnostic set. if (const short *Member = Group->Members) { for (; *Member != -1; ++Member) @@ -648,7 +648,7 @@ static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping, bool DiagnosticIDs::setDiagnosticGroupMapping(StringRef Group, diag::Mapping Map, SourceLocation Loc, - Diagnostic &Diag) const { + DiagnosticsEngine &Diag) const { assert((Loc.isValid() || Diag.DiagStatePoints.empty() || Diag.DiagStatePoints.back().Loc.isInvalid()) && @@ -673,7 +673,7 @@ bool DiagnosticIDs::setDiagnosticGroupMapping(StringRef Group, /// ProcessDiag - This is the method used to report a diagnostic that is /// finally fully formed. -bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const { +bool DiagnosticIDs::ProcessDiag(DiagnosticsEngine &Diag) const { DiagnosticInfo Info(&Diag); if (Diag.SuppressAllDiagnostics) @@ -770,7 +770,7 @@ bool DiagnosticIDs::ProcessDiag(Diagnostic &Diag) const { } // Finally, report it. - Diag.Client->HandleDiagnostic((Diagnostic::Level)DiagLevel, Info); + Diag.Client->HandleDiagnostic((DiagnosticsEngine::Level)DiagLevel, Info); if (Diag.Client->IncludeInDiagnosticCounts()) { if (DiagLevel == DiagnosticIDs::Warning) ++Diag.NumWarnings; diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index f15c5dc334..410d4dfbeb 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -80,7 +80,7 @@ void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B, Buffer.setInt(DoNotFree? DoNotFreeFlag : 0); } -const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag, +const llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc, bool *Invalid) const { @@ -364,7 +364,7 @@ LineTableInfo &SourceManager::getLineTable() { // Private 'Create' methods. //===----------------------------------------------------------------------===// -SourceManager::SourceManager(Diagnostic &Diag, FileManager &FileMgr) +SourceManager::SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr) : Diag(Diag), FileMgr(FileMgr), OverridenFilesKeepOriginalName(true), ExternalSLocEntries(0), LineTable(0), NumLinearScans(0), NumBinaryProbes(0), FakeBufferForRecovery(0) { @@ -971,10 +971,10 @@ unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, } static LLVM_ATTRIBUTE_NOINLINE void -ComputeLineNumbers(Diagnostic &Diag, ContentCache *FI, +ComputeLineNumbers(DiagnosticsEngine &Diag, ContentCache *FI, llvm::BumpPtrAllocator &Alloc, const SourceManager &SM, bool &Invalid); -static void ComputeLineNumbers(Diagnostic &Diag, ContentCache *FI, +static void ComputeLineNumbers(DiagnosticsEngine &Diag, ContentCache *FI, llvm::BumpPtrAllocator &Alloc, const SourceManager &SM, bool &Invalid) { // Note that calling 'getBuffer()' may lazily page in the file. diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 8d30c2cd2c..5ee44080ac 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3293,7 +3293,7 @@ static TargetInfo *AllocateTarget(const std::string &T) { /// CreateTargetInfo - Return the target info object for the specified target /// triple. -TargetInfo *TargetInfo::CreateTargetInfo(Diagnostic &Diags, +TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, TargetOptions &Opts) { llvm::Triple Triple(Opts.Triple); |