diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2011-09-29 01:42:25 +0000 | 
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2011-09-29 01:42:25 +0000 | 
| commit | e8c12a2979e384405ccdf5fe6e670a1586448ce6 (patch) | |
| tree | 14417aa3aac89752e59fe0f3bbe999c70713895e /clang/lib/Basic | |
| parent | e9a700cba16f7abb15dd7032f95abd2469014af8 (diff) | |
| download | bcm5719-llvm-e8c12a2979e384405ccdf5fe6e670a1586448ce6.tar.gz bcm5719-llvm-e8c12a2979e384405ccdf5fe6e670a1586448ce6.zip | |
Basic/Diagnostic: Add a DiagSate::getOrAddMappingInfo method.
 - Also, spell const_iterator as const_iterator.
llvm-svn: 140765
Diffstat (limited to 'clang/lib/Basic')
| -rw-r--r-- | clang/lib/Basic/DiagnosticIDs.cpp | 29 | 
1 files changed, 22 insertions, 7 deletions
| diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index 45d5102714e..f865e0b594e 100644 --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -234,6 +234,25 @@ namespace {    };  } +// Unfortunately, the split between DiagnosticIDs and Diagnostic is not +// particularly clean, but for now we just implement this method here so we can +// access GetDefaultDiagMapping. +DiagnosticMappingInfo &DiagnosticsEngine::DiagState::getOrAddMappingInfo( +  diag::kind Diag) +{ +  std::pair<iterator, bool> Result = DiagMap.insert( +    std::make_pair(Diag, DiagnosticMappingInfo::MakeUnset())); + +  // Initialize the entry if we added it. +  if (Result.second) { +    assert(Result.first->second.isUnset() && "unexpected unset entry"); +    Result.first->second = DiagnosticMappingInfo::MakeInfo( +      GetDefaultDiagMapping(Diag), /*IsUser=*/false, /*IsPragma=*/false); +  } + +  return Result.first->second; +} +  static const StaticDiagCategoryRec CategoryNameTable[] = {  #define GET_CATEGORY_TABLE  #define CATEGORY(X, ENUM) { X, STR_SIZE(X, uint8_t) }, @@ -506,13 +525,9 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,      Pos = Diag.GetDiagStatePointForLoc(Loc);    DiagnosticsEngine::DiagState *State = Pos->State; -  // Get the mapping information, if unset, compute it lazily. -  DiagnosticMappingInfo MappingInfo = State->getMappingInfo((diag::kind)DiagID); -  if (MappingInfo.isUnset()) { -    MappingInfo = DiagnosticMappingInfo::MakeInfo( -      GetDefaultDiagMapping(DiagID), /*IsUser=*/false, /*IsPragma=*/false); -    State->setMappingInfo((diag::kind) DiagID, MappingInfo); -  } +  // Get the mapping information, or compute it lazily. +  DiagnosticMappingInfo &MappingInfo = State->getOrAddMappingInfo( +    (diag::kind)DiagID);    bool ShouldEmitInSystemHeader = false; | 

