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
This commit is contained in:
Nico Weber 2015-01-15 04:07:35 +00:00
parent 60534818a9
commit b6a5d05a8a
8 changed files with 17 additions and 27 deletions

View File

@ -129,11 +129,7 @@ public:
/// required. /// required.
/// ///
/// \param RD The class whose vtable was used. /// \param RD The class whose vtable was used.
/// virtual void HandleVTable(CXXRecordDecl *RD) {}
/// \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) {}
/// \brief If the consumer is interested in entities getting modified after /// \brief If the consumer is interested in entities getting modified after
/// their initial creation, it should return a pointer to /// their initial creation, it should return a pointer to

View File

@ -49,7 +49,7 @@ public:
llvm::StringRef Value) override; llvm::StringRef Value) override;
void HandleDependentLibrary(llvm::StringRef Lib) override; void HandleDependentLibrary(llvm::StringRef Lib) override;
void CompleteTentativeDefinition(VarDecl *D) override; void CompleteTentativeDefinition(VarDecl *D) override;
void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override; void HandleVTable(CXXRecordDecl *RD) override;
ASTMutationListener *GetASTMutationListener() override; ASTMutationListener *GetASTMutationListener() override;
ASTDeserializationListener *GetASTDeserializationListener() override; ASTDeserializationListener *GetASTDeserializationListener() override;
void PrintStats() override; void PrintStats() override;

View File

@ -747,19 +747,13 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
llvm_unreachable("Invalid TemplateSpecializationKind!"); llvm_unreachable("Invalid TemplateSpecializationKind!");
} }
/// This is a callback from Sema to tell us that it believes that a /// This is a callback from Sema to tell us that that a particular v-table is
/// particular v-table is required to be emitted in this translation /// required to be emitted in this translation unit.
/// unit.
/// ///
/// The reason we don't simply trust this callback is because Sema /// This is only called for vtables that _must_ be emitted (mainly due to key
/// will happily report that something is used even when it's used /// functions). For weak vtables, CodeGen tracks when they are needed and
/// only in code that we don't actually have to emit. /// emits them as-needed.
/// void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) {
/// \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;
VTables.GenerateClassData(theClass); VTables.GenerateClassData(theClass);
} }

View File

@ -196,8 +196,8 @@ namespace clang {
Gen->CompleteTentativeDefinition(D); Gen->CompleteTentativeDefinition(D);
} }
void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override { void HandleVTable(CXXRecordDecl *RD) override {
Gen->HandleVTable(RD, DefinitionRequired); Gen->HandleVTable(RD);
} }
void HandleLinkerOptionPragma(llvm::StringRef Opts) override { void HandleLinkerOptionPragma(llvm::StringRef Opts) override {

View File

@ -993,7 +993,7 @@ public:
void EmitTentativeDefinition(const VarDecl *D); void EmitTentativeDefinition(const VarDecl *D);
void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired); void EmitVTable(CXXRecordDecl *Class);
/// Emit the RTTI descriptors for the builtin types. /// Emit the RTTI descriptors for the builtin types.
void EmitFundamentalRTTIDescriptors(); void EmitFundamentalRTTIDescriptors();

View File

@ -211,11 +211,11 @@ namespace {
Builder->EmitTentativeDefinition(D); Builder->EmitTentativeDefinition(D);
} }
void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override { void HandleVTable(CXXRecordDecl *RD) override {
if (Diags.hasErrorOccurred()) if (Diags.hasErrorOccurred())
return; return;
Builder->EmitVTable(RD, DefinitionRequired); Builder->EmitVTable(RD);
} }
void HandleLinkerOptionPragma(llvm::StringRef Opts) override { void HandleLinkerOptionPragma(llvm::StringRef Opts) override {

View File

@ -292,10 +292,9 @@ void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) {
Consumer->CompleteTentativeDefinition(D); Consumer->CompleteTentativeDefinition(D);
} }
void MultiplexConsumer::HandleVTable( void MultiplexConsumer::HandleVTable(CXXRecordDecl *RD) {
CXXRecordDecl *RD, bool DefinitionRequired) {
for (auto &Consumer : Consumers) for (auto &Consumer : Consumers)
Consumer->HandleVTable(RD, DefinitionRequired); Consumer->HandleVTable(RD);
} }
ASTMutationListener *MultiplexConsumer::GetASTMutationListener() { ASTMutationListener *MultiplexConsumer::GetASTMutationListener() {

View File

@ -13122,7 +13122,8 @@ bool Sema::DefineUsedVTables() {
DefinedAnything = true; DefinedAnything = true;
MarkVirtualMembersReferenced(Loc, Class); MarkVirtualMembersReferenced(Loc, Class);
CXXRecordDecl *Canonical = cast<CXXRecordDecl>(Class->getCanonicalDecl()); 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. // Optionally warn if we're emitting a weak vtable.
if (Class->isExternallyVisible() && if (Class->isExternallyVisible() &&