From: Richard Smith Date: Thu, 10 Jan 2013 23:43:47 +0000 (+0000) Subject: Truth in advertising: LocallyScopedExternalDecls actually only contains X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ea6ef490547917426d5e2ed14c9f36521bbeacf;p=clang Truth in advertising: LocallyScopedExternalDecls actually only contains external declarations with C language linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172150 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/ExternalSemaSource.h b/include/clang/Sema/ExternalSemaSource.h index 7a598498ff..a730f67984 100644 --- a/include/clang/Sema/ExternalSemaSource.h +++ b/include/clang/Sema/ExternalSemaSource.h @@ -130,7 +130,7 @@ public: /// declarations to the given vector of declarations. Note that this routine /// may be invoked multiple times; the external source should take care not /// to introduce the same declarations repeatedly. - virtual void ReadLocallyScopedExternalDecls( + virtual void ReadLocallyScopedExternCDecls( SmallVectorImpl &Decls) {} /// \brief Read the set of referenced selectors known to the diff --git a/include/clang/Sema/MultiplexExternalSemaSource.h b/include/clang/Sema/MultiplexExternalSemaSource.h index 2d9e229c94..052af98732 100644 --- a/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/include/clang/Sema/MultiplexExternalSemaSource.h @@ -309,14 +309,14 @@ public: /// introduce the same declarations repeatedly. virtual void ReadDynamicClasses(SmallVectorImpl &Decls); - /// \brief Read the set of locally-scoped external declarations known to the + /// \brief Read the set of locally-scoped extern "C" declarations known to the /// external Sema source. /// /// The external source should append its own locally-scoped external - /// declarations to the given vector of declarations. Note that this routine - /// may be invoked multiple times; the external source should take care not + /// declarations to the given vector of declarations. Note that this routine + /// may be invoked multiple times; the external source should take care not /// to introduce the same declarations repeatedly. - virtual void ReadLocallyScopedExternalDecls(SmallVectorImpl&Decls); + virtual void ReadLocallyScopedExternCDecls(SmallVectorImpl&Decls); /// \brief Read the set of referenced selectors known to the /// external Sema source. diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index e3d7b0c4df..5971ff5788 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -301,35 +301,35 @@ public: llvm::SmallPtrSet ParsingInitForAutoVars; /// \brief A mapping from external names to the most recent - /// locally-scoped external declaration with that name. + /// locally-scoped extern "C" declaration with that name. /// /// This map contains external declarations introduced in local - /// scoped, e.g., + /// scopes, e.g., /// /// \code - /// void f() { + /// extern "C" void f() { /// void foo(int, int); /// } /// \endcode /// - /// Here, the name "foo" will be associated with the declaration on + /// Here, the name "foo" will be associated with the declaration of /// "foo" within f. This name is not visible outside of /// "f". However, we still find it in two cases: /// - /// - If we are declaring another external with the name "foo", we - /// can find "foo" as a previous declaration, so that the types - /// of this external declaration can be checked for - /// compatibility. + /// - If we are declaring another global or extern "C" entity with + /// the name "foo", we can find "foo" as a previous declaration, + /// so that the types of this external declaration can be checked + /// for compatibility. /// /// - If we would implicitly declare "foo" (e.g., due to a call to /// "foo" in C when no prototype or definition is visible), then /// we find this declaration of "foo" and complain that it is /// not visible. - llvm::DenseMap LocallyScopedExternalDecls; + llvm::DenseMap LocallyScopedExternCDecls; - /// \brief Look for a locally scoped external declaration by the given name. + /// \brief Look for a locally scoped extern "C" declaration by the given name. llvm::DenseMap::iterator - findLocallyScopedExternalDecl(DeclarationName Name); + findLocallyScopedExternCDecl(DeclarationName Name); typedef LazyVector diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 0810d15391..2dbe136e89 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -368,9 +368,9 @@ namespace clang { /// \brief Record code for the array of tentative definitions. TENTATIVE_DEFINITIONS = 9, - /// \brief Record code for the array of locally-scoped external + /// \brief Record code for the array of locally-scoped extern "C" /// declarations. - LOCALLY_SCOPED_EXTERNAL_DECLS = 10, + LOCALLY_SCOPED_EXTERN_C_DECLS = 10, /// \brief Record code for the table of offsets into the /// Objective-C method pool. diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 328cd7b336..816dfef024 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -638,11 +638,11 @@ private: /// \brief Fields containing data that is used for semantic analysis //@{ - /// \brief The IDs of all locally scoped external decls in the chain. + /// \brief The IDs of all locally scoped extern "C" decls in the chain. /// /// Sema tracks these to validate that the types are consistent across all - /// local external declarations. - SmallVector LocallyScopedExternalDecls; + /// local extern "C" declarations. + SmallVector LocallyScopedExternCDecls; /// \brief The IDs of all dynamic class declarations in the chain. /// @@ -1488,7 +1488,7 @@ public: virtual void ReadDynamicClasses(SmallVectorImpl &Decls); - virtual void ReadLocallyScopedExternalDecls( + virtual void ReadLocallyScopedExternCDecls( SmallVectorImpl &Decls); virtual void ReadReferencedSelectors( diff --git a/lib/Sema/MultiplexExternalSemaSource.cpp b/lib/Sema/MultiplexExternalSemaSource.cpp index dca0a3549d..bee69c46e5 100644 --- a/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/lib/Sema/MultiplexExternalSemaSource.cpp @@ -238,10 +238,10 @@ void MultiplexExternalSemaSource::ReadDynamicClasses( Sources[i]->ReadDynamicClasses(Decls); } -void MultiplexExternalSemaSource::ReadLocallyScopedExternalDecls( +void MultiplexExternalSemaSource::ReadLocallyScopedExternCDecls( SmallVectorImpl &Decls) { for(size_t i = 0; i < Sources.size(); ++i) - Sources[i]->ReadLocallyScopedExternalDecls(Decls); + Sources[i]->ReadLocallyScopedExternCDecls(Decls); } void MultiplexExternalSemaSource::ReadReferencedSelectors( diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d7a204325f..59343f6670 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4004,7 +4004,7 @@ TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, return FixedTInfo; } -/// \brief Register the given locally-scoped external C declaration so +/// \brief Register the given locally-scoped extern "C" declaration so /// that it can be found later for redeclarations void Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, @@ -4013,15 +4013,15 @@ Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, assert(ND->getLexicalDeclContext()->isFunctionOrMethod() && "Decl is not a locally-scoped decl!"); // Note that we have a locally-scoped external with this name. - LocallyScopedExternalDecls[ND->getDeclName()] = ND; + LocallyScopedExternCDecls[ND->getDeclName()] = ND; if (!Previous.isSingleResult()) return; NamedDecl *PrevDecl = Previous.getFoundDecl(); - // If there was a previous declaration of this variable, it may be - // in our identifier chain. Update the identifier chain with the new + // If there was a previous declaration of this entity, it may be in + // our identifier chain. Update the identifier chain with the new // declaration. if (S && IdResolver.ReplaceDecl(PrevDecl, ND)) { // The previous declaration was found on the identifer resolver @@ -4045,20 +4045,20 @@ Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, } llvm::DenseMap::iterator -Sema::findLocallyScopedExternalDecl(DeclarationName Name) { +Sema::findLocallyScopedExternCDecl(DeclarationName Name) { if (ExternalSource) { // Load locally-scoped external decls from the external source. SmallVector Decls; - ExternalSource->ReadLocallyScopedExternalDecls(Decls); + ExternalSource->ReadLocallyScopedExternCDecls(Decls); for (unsigned I = 0, N = Decls.size(); I != N; ++I) { llvm::DenseMap::iterator Pos - = LocallyScopedExternalDecls.find(Decls[I]->getDeclName()); - if (Pos == LocallyScopedExternalDecls.end()) - LocallyScopedExternalDecls[Decls[I]->getDeclName()] = Decls[I]; + = LocallyScopedExternCDecls.find(Decls[I]->getDeclName()); + if (Pos == LocallyScopedExternCDecls.end()) + LocallyScopedExternCDecls[Decls[I]->getDeclName()] = Decls[I]; } } - return LocallyScopedExternalDecls.find(Name); + return LocallyScopedExternCDecls.find(Name); } /// \brief Diagnose function specifiers on a declaration of an identifier that @@ -4798,8 +4798,8 @@ bool Sema::CheckVariableDeclaration(VarDecl *NewVD, // an extern "C" variable, look for a non-visible extern "C" // declaration with the same name. llvm::DenseMap::iterator Pos - = findLocallyScopedExternalDecl(NewVD->getDeclName()); - if (Pos != LocallyScopedExternalDecls.end()) + = findLocallyScopedExternCDecl(NewVD->getDeclName()); + if (Pos != LocallyScopedExternCDecls.end()) Previous.addDecl(Pos->second); } @@ -6151,8 +6151,8 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, // an extern "C" function, look for a non-visible extern "C" // declaration with the same name. llvm::DenseMap::iterator Pos - = findLocallyScopedExternalDecl(NewFD->getDeclName()); - if (Pos != LocallyScopedExternalDecls.end()) + = findLocallyScopedExternCDecl(NewFD->getDeclName()); + if (Pos != LocallyScopedExternCDecls.end()) Previous.addDecl(Pos->second); } @@ -8291,8 +8291,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, // this name as a function or variable. If so, use that // (non-visible) declaration, and complain about it. llvm::DenseMap::iterator Pos - = findLocallyScopedExternalDecl(&II); - if (Pos != LocallyScopedExternalDecls.end()) { + = findLocallyScopedExternCDecl(&II); + if (Pos != LocallyScopedExternCDecls.end()) { Diag(Loc, diag::warn_use_out_of_scope_declaration) << Pos->second; Diag(Pos->second->getLocation(), diag::note_previous_declaration); return Pos->second; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index eca9918a79..f32d53fd8a 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2119,9 +2119,9 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { } break; - case LOCALLY_SCOPED_EXTERNAL_DECLS: + case LOCALLY_SCOPED_EXTERN_C_DECLS: for (unsigned I = 0, N = Record.size(); I != N; ++I) - LocallyScopedExternalDecls.push_back(getGlobalDeclID(F, Record[I])); + LocallyScopedExternCDecls.push_back(getGlobalDeclID(F, Record[I])); break; case SELECTOR_OFFSETS: { @@ -5961,14 +5961,14 @@ void ASTReader::ReadDynamicClasses(SmallVectorImpl &Decls) { } void -ASTReader::ReadLocallyScopedExternalDecls(SmallVectorImpl &Decls) { - for (unsigned I = 0, N = LocallyScopedExternalDecls.size(); I != N; ++I) { - NamedDecl *D - = dyn_cast_or_null(GetDecl(LocallyScopedExternalDecls[I])); +ASTReader::ReadLocallyScopedExternCDecls(SmallVectorImpl &Decls) { + for (unsigned I = 0, N = LocallyScopedExternCDecls.size(); I != N; ++I) { + NamedDecl *D + = dyn_cast_or_null(GetDecl(LocallyScopedExternCDecls[I])); if (D) Decls.push_back(D); } - LocallyScopedExternalDecls.clear(); + LocallyScopedExternCDecls.clear(); } void ASTReader::ReadReferencedSelectors( diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index ac2409833f..4f24abdac0 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -798,7 +798,7 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(STATISTICS); RECORD(TENTATIVE_DEFINITIONS); RECORD(UNUSED_FILESCOPED_DECLS); - RECORD(LOCALLY_SCOPED_EXTERNAL_DECLS); + RECORD(LOCALLY_SCOPED_EXTERN_C_DECLS); RECORD(SELECTOR_OFFSETS); RECORD(METHOD_POOL); RECORD(PP_COUNTER_VALUE); @@ -3506,18 +3506,18 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, } } - // Build a record containing all of the locally-scoped external + // Build a record containing all of the locally-scoped extern "C" // declarations in this header file. Generally, this record will be // empty. - RecordData LocallyScopedExternalDecls; + RecordData LocallyScopedExternCDecls; // FIXME: This is filling in the AST file in densemap order which is // nondeterminstic! for (llvm::DenseMap::iterator - TD = SemaRef.LocallyScopedExternalDecls.begin(), - TDEnd = SemaRef.LocallyScopedExternalDecls.end(); + TD = SemaRef.LocallyScopedExternCDecls.begin(), + TDEnd = SemaRef.LocallyScopedExternCDecls.end(); TD != TDEnd; ++TD) { if (!TD->second->isFromASTFile()) - AddDeclRef(TD->second, LocallyScopedExternalDecls); + AddDeclRef(TD->second, LocallyScopedExternCDecls); } // Build a record containing all of the ext_vector declarations. @@ -3749,10 +3749,10 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, Stream.EmitRecord(WEAK_UNDECLARED_IDENTIFIERS, WeakUndeclaredIdentifiers); - // Write the record containing locally-scoped external definitions. - if (!LocallyScopedExternalDecls.empty()) - Stream.EmitRecord(LOCALLY_SCOPED_EXTERNAL_DECLS, - LocallyScopedExternalDecls); + // Write the record containing locally-scoped extern "C" definitions. + if (!LocallyScopedExternCDecls.empty()) + Stream.EmitRecord(LOCALLY_SCOPED_EXTERN_C_DECLS, + LocallyScopedExternCDecls); // Write the record containing ext_vector type names. if (!ExtVectorDecls.empty())