diff --git a/clang/include/clang/Sema/ExternalSemaSource.h b/clang/include/clang/Sema/ExternalSemaSource.h --- a/clang/include/clang/Sema/ExternalSemaSource.h +++ b/clang/include/clang/Sema/ExternalSemaSource.h @@ -199,8 +199,8 @@ /// and variable decls which may cause deferred diags. Note that this routine /// may be invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector &Decls) {} + virtual void + ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector &Decls) {} /// \copydoc Sema::CorrectTypo /// \note LookupKind must correspond to a valid Sema::LookupNameKind diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h --- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -337,7 +337,7 @@ /// may be invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector &Decls) override; + llvm::SmallSetVector &Decls) override; /// \copydoc ExternalSemaSource::CorrectTypo /// \note Returns the first nonempty correction. diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1786,7 +1786,7 @@ private: /// Function or variable declarations to be checked for whether the deferred /// diagnostics should be emitted. - SmallVector DeclsToCheckForDeferredDiags; + llvm::SmallSetVector DeclsToCheckForDeferredDiags; public: // Emit all deferred diagnostics. diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -767,21 +767,21 @@ /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks /// in the chain. The referenced declarations are deserialized and passed to /// the consumer eagerly. - SmallVector EagerlyDeserializedDecls; + SmallVector EagerlyDeserializedDecls; /// The IDs of all tentative definitions stored in the chain. /// /// Sema keeps track of all tentative definitions in a TU because it has to /// complete them and pass them on to CodeGen. Thus, tentative definitions in /// the PCH chain must be eagerly deserialized. - SmallVector TentativeDefinitions; + SmallVector TentativeDefinitions; /// The IDs of all CXXRecordDecls stored in the chain whose VTables are /// used. /// /// CodeGen has to emit VTables for these records, so they have to be eagerly /// deserialized. - SmallVector VTableUses; + SmallVector VTableUses; /// A snapshot of the pending instantiations in the chain. /// @@ -789,7 +789,7 @@ /// end of the TU. It consists of a pair of values for every pending /// instantiation where the first value is the ID of the decl and the second /// is the instantiation location. - SmallVector PendingInstantiations; + SmallVector PendingInstantiations; //@} @@ -799,24 +799,24 @@ /// A snapshot of Sema's unused file-scoped variable tracking, for /// generating warnings. - SmallVector UnusedFileScopedDecls; + SmallVector UnusedFileScopedDecls; /// A list of all the delegating constructors we've seen, to diagnose /// cycles. - SmallVector DelegatingCtorDecls; + SmallVector DelegatingCtorDecls; /// Method selectors used in a @selector expression. Used for /// implementation of -Wselector. - SmallVector ReferencedSelectorsData; + SmallVector ReferencedSelectorsData; /// A snapshot of Sema's weak undeclared identifier tracking, for /// generating warnings. - SmallVector WeakUndeclaredIdentifiers; + SmallVector WeakUndeclaredIdentifiers; /// The IDs of type aliases for ext_vectors that exist in the chain. /// /// Used by Sema for finding sugared names for ext_vectors in diagnostics. - SmallVector ExtVectorDecls; + SmallVector ExtVectorDecls; //@} @@ -827,7 +827,7 @@ /// The IDs of all potentially unused typedef names in the chain. /// /// Sema tracks these to emit warnings. - SmallVector UnusedLocalTypedefNameCandidates; + SmallVector UnusedLocalTypedefNameCandidates; /// Our current depth in #pragma cuda force_host_device begin/end /// macros. @@ -836,18 +836,18 @@ /// The IDs of the declarations Sema stores directly. /// /// Sema tracks a few important decls, such as namespace std, directly. - SmallVector SemaDeclRefs; + SmallVector SemaDeclRefs; /// The IDs of the types ASTContext stores directly. /// /// The AST context tracks a few important types, such as va_list, directly. - SmallVector SpecialTypes; + SmallVector SpecialTypes; /// The IDs of CUDA-specific declarations ASTContext stores directly. /// /// The AST context tracks a few important decls, currently cudaConfigureCall, /// directly. - SmallVector CUDASpecialDeclRefs; + SmallVector CUDASpecialDeclRefs; /// The floating point pragma option settings. SmallVector FPPragmaOptions; @@ -896,11 +896,11 @@ llvm::DenseMap> OpenCLDeclExtMap; /// A list of the namespaces we've seen. - SmallVector KnownNamespaces; + SmallVector KnownNamespaces; /// A list of undefined decls with internal linkage followed by the /// SourceLocation of a matching ODR-use. - SmallVector UndefinedButUsed; + SmallVector UndefinedButUsed; /// Delete expressions to analyze at the end of translation unit. SmallVector DelayedDeleteExprs; @@ -912,8 +912,7 @@ /// The IDs of all decls to be checked for deferred diags. /// /// Sema tracks these to emit deferred diags. - SmallVector DeclsToCheckForDeferredDiags; - + llvm::SmallSetVector DeclsToCheckForDeferredDiags; public: struct ImportedSubmodule { @@ -2016,7 +2015,7 @@ llvm::SmallSetVector &Decls) override; void ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector &Decls) override; + llvm::SmallSetVector &Decls) override; void ReadReferencedSelectors( SmallVectorImpl> &Sels) override; diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -402,8 +402,8 @@ /// headers. The declarations themselves are stored as declaration /// IDs, since they will be written out to an EAGERLY_DESERIALIZED_DECLS /// record. - SmallVector EagerlyDeserializedDecls; - SmallVector ModularCodegenDecls; + SmallVector EagerlyDeserializedDecls; + SmallVector ModularCodegenDecls; /// DeclContexts that have received extensions since their serialized /// form. diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp b/clang/lib/Sema/MultiplexExternalSemaSource.cpp --- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp @@ -268,7 +268,7 @@ } void MultiplexExternalSemaSource::ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector &Decls) { + llvm::SmallSetVector &Decls) { for(size_t i = 0; i < Sources.size(); ++i) Sources[i]->ReadDeclsToCheckForDeferredDiags(Decls); } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12539,7 +12539,7 @@ } if (LangOpts.OpenMP && VDecl->isFileVarDecl()) - DeclsToCheckForDeferredDiags.push_back(VDecl); + DeclsToCheckForDeferredDiags.insert(VDecl); CheckCompleteVariableDeclaration(VDecl); } @@ -14773,7 +14773,7 @@ auto ES = getEmissionStatus(FD); if (ES == Sema::FunctionEmissionStatus::Emitted || ES == Sema::FunctionEmissionStatus::Unknown) - DeclsToCheckForDeferredDiags.push_back(FD); + DeclsToCheckForDeferredDiags.insert(FD); } return dcl; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3810,7 +3810,7 @@ case DECLS_TO_CHECK_FOR_DEFERRED_DIAGS: for (unsigned I = 0, N = Record.size(); I != N; ++I) - DeclsToCheckForDeferredDiags.push_back(getGlobalDeclID(F, Record[I])); + DeclsToCheckForDeferredDiags.insert(getGlobalDeclID(F, Record[I])); break; } } @@ -8333,18 +8333,15 @@ } void ASTReader::ReadDeclsToCheckForDeferredDiags( - llvm::SmallVector &Decls) { - for (unsigned I = 0, N = DeclsToCheckForDeferredDiags.size(); I != N; - ++I) { - auto *D = dyn_cast_or_null( - GetDecl(DeclsToCheckForDeferredDiags[I])); + llvm::SmallSetVector &Decls) { + for (auto I : DeclsToCheckForDeferredDiags) { + auto *D = dyn_cast_or_null(GetDecl(I)); if (D) - Decls.push_back(D); + Decls.insert(D); } DeclsToCheckForDeferredDiags.clear(); } - void ASTReader::ReadReferencedSelectors( SmallVectorImpl> &Sels) { if (ReferencedSelectorsData.empty()) diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4667,9 +4667,9 @@ } // Build a record containing all of the DeclsToCheckForDeferredDiags. - RecordData DeclsToCheckForDeferredDiags; + SmallVector DeclsToCheckForDeferredDiags; for (auto *D : SemaRef.DeclsToCheckForDeferredDiags) - AddDeclRef(D, DeclsToCheckForDeferredDiags); + DeclsToCheckForDeferredDiags.push_back(GetDeclRef(D)); RecordData DeclUpdatesOffsetsRecord;