diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-01-15 04:07:35 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-01-15 04:07:35 +0000 |
commit | b6a5d05a8a6e9064b22987830f4ffa6b3f3d71f3 (patch) | |
tree | b7ccc1df3165160421835a40aa0d49da4fd22cfb | |
parent | 60534818a9d7b3d4e249a2e51af5f182dfd48434 (diff) | |
download | bcm5719-llvm-b6a5d05a8a6e9064b22987830f4ffa6b3f3d71f3.tar.gz bcm5719-llvm-b6a5d05a8a6e9064b22987830f4ffa6b3f3d71f3.zip |
Remove ASTConsumer::HandleVTable()'s bool parameter.
Sema calls HandleVTable() with a bool parameter which is then threaded through
three layers. The only effect of this bool is an early return at the last
layer.
Instead, remove this parameter and call HandleVTable() only if the bool is
true. No intended behavior change.
llvm-svn: 226096
-rw-r--r-- | clang/include/clang/AST/ASTConsumer.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Frontend/MultiplexConsumer.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 18 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/ModuleBuilder.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/MultiplexConsumer.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 3 |
8 files changed, 17 insertions, 27 deletions
diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 736a10bec9b..b2730e46222 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -129,11 +129,7 @@ public: /// required. /// /// \param RD The class whose vtable was used. - /// - /// \param DefinitionRequired Whether a definition of this vtable is - /// required in this translation unit; otherwise, it is only needed if - /// it was actually used. - virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) {} + virtual void HandleVTable(CXXRecordDecl *RD) {} /// \brief If the consumer is interested in entities getting modified after /// their initial creation, it should return a pointer to diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h b/clang/include/clang/Frontend/MultiplexConsumer.h index c9122dacb8f..2553275dac1 100644 --- a/clang/include/clang/Frontend/MultiplexConsumer.h +++ b/clang/include/clang/Frontend/MultiplexConsumer.h @@ -49,7 +49,7 @@ public: llvm::StringRef Value) override; void HandleDependentLibrary(llvm::StringRef Lib) override; void CompleteTentativeDefinition(VarDecl *D) override; - void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override; + void HandleVTable(CXXRecordDecl *RD) override; ASTMutationListener *GetASTMutationListener() override; ASTDeserializationListener *GetASTDeserializationListener() override; void PrintStats() override; diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index acb2a56fab3..5416d441672 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -747,19 +747,13 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { llvm_unreachable("Invalid TemplateSpecializationKind!"); } -/// This is a callback from Sema to tell us that it believes that a -/// particular v-table is required to be emitted in this translation -/// unit. +/// This is a callback from Sema to tell us that that a particular v-table is +/// required to be emitted in this translation unit. /// -/// The reason we don't simply trust this callback is because Sema -/// will happily report that something is used even when it's used -/// only in code that we don't actually have to emit. -/// -/// \param isRequired - if true, the v-table is mandatory, e.g. -/// because the translation unit defines the key function -void CodeGenModule::EmitVTable(CXXRecordDecl *theClass, bool isRequired) { - if (!isRequired) return; - +/// This is only called for vtables that _must_ be emitted (mainly due to key +/// functions). For weak vtables, CodeGen tracks when they are needed and +/// emits them as-needed. +void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) { VTables.GenerateClassData(theClass); } diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index a6f6fdef335..c459a210cee 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -196,8 +196,8 @@ namespace clang { Gen->CompleteTentativeDefinition(D); } - void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override { - Gen->HandleVTable(RD, DefinitionRequired); + void HandleVTable(CXXRecordDecl *RD) override { + Gen->HandleVTable(RD); } void HandleLinkerOptionPragma(llvm::StringRef Opts) override { diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 54f3a82feb2..ddcb414508a 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -993,7 +993,7 @@ public: void EmitTentativeDefinition(const VarDecl *D); - void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired); + void EmitVTable(CXXRecordDecl *Class); /// Emit the RTTI descriptors for the builtin types. void EmitFundamentalRTTIDescriptors(); diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 4f1a82e0248..f85de0d07fa 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -211,11 +211,11 @@ namespace { Builder->EmitTentativeDefinition(D); } - void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override { + void HandleVTable(CXXRecordDecl *RD) override { if (Diags.hasErrorOccurred()) return; - Builder->EmitVTable(RD, DefinitionRequired); + Builder->EmitVTable(RD); } void HandleLinkerOptionPragma(llvm::StringRef Opts) override { diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp b/clang/lib/Frontend/MultiplexConsumer.cpp index 019882833d4..3c4fed1d18e 100644 --- a/clang/lib/Frontend/MultiplexConsumer.cpp +++ b/clang/lib/Frontend/MultiplexConsumer.cpp @@ -292,10 +292,9 @@ void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) { Consumer->CompleteTentativeDefinition(D); } -void MultiplexConsumer::HandleVTable( - CXXRecordDecl *RD, bool DefinitionRequired) { +void MultiplexConsumer::HandleVTable(CXXRecordDecl *RD) { for (auto &Consumer : Consumers) - Consumer->HandleVTable(RD, DefinitionRequired); + Consumer->HandleVTable(RD); } ASTMutationListener *MultiplexConsumer::GetASTMutationListener() { diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 510738ea816..54de4b97939 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -13122,7 +13122,8 @@ bool Sema::DefineUsedVTables() { DefinedAnything = true; MarkVirtualMembersReferenced(Loc, Class); CXXRecordDecl *Canonical = cast<CXXRecordDecl>(Class->getCanonicalDecl()); - Consumer.HandleVTable(Class, VTablesUsed[Canonical]); + if (VTablesUsed[Canonical]) + Consumer.HandleVTable(Class); // Optionally warn if we're emitting a weak vtable. if (Class->isExternallyVisible() && |