diff options
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 584dca1e387..997d967aa19 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -478,10 +478,8 @@ static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { /// Obtains a sorted list of functions that are undefined but ODR-used. void Sema::getUndefinedButUsed( SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) { - for (llvm::DenseMap<NamedDecl *, SourceLocation>::iterator - I = UndefinedButUsed.begin(), E = UndefinedButUsed.end(); - I != E; ++I) { - NamedDecl *ND = I->first; + for (const auto &UndefinedUse : UndefinedButUsed) { + NamedDecl *ND = UndefinedUse.first; // Ignore attributes that have become invalid. if (ND->isInvalidDecl()) continue; @@ -502,24 +500,8 @@ void Sema::getUndefinedButUsed( continue; } - Undefined.push_back(std::make_pair(ND, I->second)); + Undefined.push_back(std::make_pair(ND, UndefinedUse.second)); } - - // Sort (in order of use site) so that we're not dependent on the iteration - // order through an llvm::DenseMap. - SourceManager &SM = Context.getSourceManager(); - std::sort(Undefined.begin(), Undefined.end(), - [&SM](const std::pair<NamedDecl *, SourceLocation> &l, - const std::pair<NamedDecl *, SourceLocation> &r) { - if (l.second.isValid() && !r.second.isValid()) - return true; - if (!l.second.isValid() && r.second.isValid()) - return false; - if (l.second != r.second) - return SM.isBeforeInTranslationUnit(l.second, r.second); - return SM.isBeforeInTranslationUnit(l.first->getLocation(), - r.first->getLocation()); - }); } /// checkUndefinedButUsed - Check for undefined objects with internal linkage @@ -554,6 +536,8 @@ static void checkUndefinedButUsed(Sema &S) { if (I->second.isValid()) S.Diag(I->second, diag::note_used_here); } + + S.UndefinedButUsed.clear(); } void Sema::LoadExternalWeakUndeclaredIdentifiers() { @@ -749,6 +733,12 @@ void Sema::ActOnEndOfTranslationUnit() { !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation())) CheckDelegatingCtorCycles(); + if (!Diags.hasErrorOccurred()) { + if (ExternalSource) + ExternalSource->ReadUndefinedButUsed(UndefinedButUsed); + checkUndefinedButUsed(*this); + } + if (TUKind == TU_Module) { // If we are building a module, resolve all of the exported declarations // now. @@ -882,10 +872,6 @@ void Sema::ActOnEndOfTranslationUnit() { } } - if (ExternalSource) - ExternalSource->ReadUndefinedButUsed(UndefinedButUsed); - checkUndefinedButUsed(*this); - emitAndClearUnusedLocalTypedefWarnings(); } @@ -1271,8 +1257,7 @@ void ExternalSemaSource::ReadKnownNamespaces( } void ExternalSemaSource::ReadUndefinedButUsed( - llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) { -} + llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {} void ExternalSemaSource::ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {} |