Skip to content
Snippets Groups Projects
Commit 6fb58981 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

Fixed a 'not all control paths return a value' warning on MSVC builds

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280917 91177308-0d34-0410-b5e6-96231b3b80d8
parent 59873511
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ using namespace CodeGen; ...@@ -29,7 +29,7 @@ using namespace CodeGen;
CodeGenVTables::CodeGenVTables(CodeGenModule &CGM) CodeGenVTables::CodeGenVTables(CodeGenModule &CGM)
: CGM(CGM), VTContext(CGM.getContext().getVTableContext()) {} : CGM(CGM), VTContext(CGM.getContext().getVTableContext()) {}
llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD,
const ThunkInfo &Thunk) { const ThunkInfo &Thunk) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
...@@ -93,7 +93,7 @@ static RValue PerformReturnAdjustment(CodeGenFunction &CGF, ...@@ -93,7 +93,7 @@ static RValue PerformReturnAdjustment(CodeGenFunction &CGF,
AdjustNull = CGF.createBasicBlock("adjust.null"); AdjustNull = CGF.createBasicBlock("adjust.null");
AdjustNotNull = CGF.createBasicBlock("adjust.notnull"); AdjustNotNull = CGF.createBasicBlock("adjust.notnull");
AdjustEnd = CGF.createBasicBlock("adjust.end"); AdjustEnd = CGF.createBasicBlock("adjust.end");
llvm::Value *IsNull = CGF.Builder.CreateIsNull(ReturnValue); llvm::Value *IsNull = CGF.Builder.CreateIsNull(ReturnValue);
CGF.Builder.CreateCondBr(IsNull, AdjustNull, AdjustNotNull); CGF.Builder.CreateCondBr(IsNull, AdjustNull, AdjustNotNull);
CGF.EmitBlock(AdjustNotNull); CGF.EmitBlock(AdjustNotNull);
...@@ -110,14 +110,14 @@ static RValue PerformReturnAdjustment(CodeGenFunction &CGF, ...@@ -110,14 +110,14 @@ static RValue PerformReturnAdjustment(CodeGenFunction &CGF,
CGF.EmitBlock(AdjustNull); CGF.EmitBlock(AdjustNull);
CGF.Builder.CreateBr(AdjustEnd); CGF.Builder.CreateBr(AdjustEnd);
CGF.EmitBlock(AdjustEnd); CGF.EmitBlock(AdjustEnd);
llvm::PHINode *PHI = CGF.Builder.CreatePHI(ReturnValue->getType(), 2); llvm::PHINode *PHI = CGF.Builder.CreatePHI(ReturnValue->getType(), 2);
PHI->addIncoming(ReturnValue, AdjustNotNull); PHI->addIncoming(ReturnValue, AdjustNotNull);
PHI->addIncoming(llvm::Constant::getNullValue(ReturnValue->getType()), PHI->addIncoming(llvm::Constant::getNullValue(ReturnValue->getType()),
AdjustNull); AdjustNull);
ReturnValue = PHI; ReturnValue = PHI;
} }
return RValue::get(ReturnValue); return RValue::get(ReturnValue);
} }
...@@ -314,7 +314,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Value *Callee, ...@@ -314,7 +314,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Value *Callee,
CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect && CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect &&
!hasScalarEvaluationKind(CurFnInfo->getReturnType())) !hasScalarEvaluationKind(CurFnInfo->getReturnType()))
Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified()); Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified());
// Now emit our call. // Now emit our call.
llvm::Instruction *CallOrInvoke; llvm::Instruction *CallOrInvoke;
RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, MD, &CallOrInvoke); RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, MD, &CallOrInvoke);
...@@ -433,14 +433,14 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk, ...@@ -433,14 +433,14 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
// Remove the name from the old thunk function and get a new thunk. // Remove the name from the old thunk function and get a new thunk.
OldThunkFn->setName(StringRef()); OldThunkFn->setName(StringRef());
Entry = cast<llvm::GlobalValue>(CGM.GetAddrOfThunk(GD, Thunk)); Entry = cast<llvm::GlobalValue>(CGM.GetAddrOfThunk(GD, Thunk));
// If needed, replace the old thunk with a bitcast. // If needed, replace the old thunk with a bitcast.
if (!OldThunkFn->use_empty()) { if (!OldThunkFn->use_empty()) {
llvm::Constant *NewPtrForOldDecl = llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType()); llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType());
OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl); OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl);
} }
// Remove the old thunk. // Remove the old thunk.
OldThunkFn->eraseFromParent(); OldThunkFn->eraseFromParent();
} }
...@@ -500,7 +500,7 @@ void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD, ...@@ -500,7 +500,7 @@ void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD,
void CodeGenVTables::EmitThunks(GlobalDecl GD) void CodeGenVTables::EmitThunks(GlobalDecl GD)
{ {
const CXXMethodDecl *MD = const CXXMethodDecl *MD =
cast<CXXMethodDecl>(GD.getDecl())->getCanonicalDecl(); cast<CXXMethodDecl>(GD.getDecl())->getCanonicalDecl();
// We don't need to generate thunks for the base destructor. // We don't need to generate thunks for the base destructor.
...@@ -529,6 +529,9 @@ llvm::Constant *CodeGenVTables::CreateVTableComponent( ...@@ -529,6 +529,9 @@ llvm::Constant *CodeGenVTables::CreateVTableComponent(
}; };
switch (Component.getKind()) { switch (Component.getKind()) {
default:
llvm_unreachable("Unexpected vtable component kind");
case VTableComponent::CK_VCallOffset: case VTableComponent::CK_VCallOffset:
return OffsetConstant(Component.getVCallOffset()); return OffsetConstant(Component.getVCallOffset());
...@@ -636,9 +639,9 @@ CodeGenVTables::CreateVTableInitializer(const VTableLayout &VTLayout, ...@@ -636,9 +639,9 @@ CodeGenVTables::CreateVTableInitializer(const VTableLayout &VTLayout,
} }
llvm::GlobalVariable * llvm::GlobalVariable *
CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
const BaseSubobject &Base, const BaseSubobject &Base,
bool BaseIsVirtual, bool BaseIsVirtual,
llvm::GlobalVariable::LinkageTypes Linkage, llvm::GlobalVariable::LinkageTypes Linkage,
VTableAddressPointsMapTy& AddressPoints) { VTableAddressPointsMapTy& AddressPoints) {
if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
...@@ -671,7 +674,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, ...@@ -671,7 +674,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
Linkage = llvm::GlobalVariable::InternalLinkage; Linkage = llvm::GlobalVariable::InternalLinkage;
// Create the variable that will hold the construction vtable. // Create the variable that will hold the construction vtable.
llvm::GlobalVariable *VTable = llvm::GlobalVariable *VTable =
CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType, Linkage); CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType, Linkage);
CGM.setGlobalVisibility(VTable, RD); CGM.setGlobalVisibility(VTable, RD);
...@@ -684,7 +687,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, ...@@ -684,7 +687,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
// Create and set the initializer. // Create and set the initializer.
llvm::Constant *Init = CreateVTableInitializer(*VTLayout, RTTI); llvm::Constant *Init = CreateVTableInitializer(*VTLayout, RTTI);
VTable->setInitializer(Init); VTable->setInitializer(Init);
CGM.EmitVTableTypeMetadata(VTable, *VTLayout.get()); CGM.EmitVTableTypeMetadata(VTable, *VTLayout.get());
return VTable; return VTable;
...@@ -699,7 +702,7 @@ static bool shouldEmitAvailableExternallyVTable(const CodeGenModule &CGM, ...@@ -699,7 +702,7 @@ static bool shouldEmitAvailableExternallyVTable(const CodeGenModule &CGM,
/// Compute the required linkage of the vtable for the given class. /// Compute the required linkage of the vtable for the given class.
/// ///
/// Note that we only call this at the end of the translation unit. /// Note that we only call this at the end of the translation unit.
llvm::GlobalVariable::LinkageTypes llvm::GlobalVariable::LinkageTypes
CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
if (!RD->isExternallyVisible()) if (!RD->isExternallyVisible())
return llvm::GlobalVariable::InternalLinkage; return llvm::GlobalVariable::InternalLinkage;
...@@ -713,7 +716,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { ...@@ -713,7 +716,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
const FunctionDecl *def = nullptr; const FunctionDecl *def = nullptr;
if (keyFunction->hasBody(def)) if (keyFunction->hasBody(def))
keyFunction = cast<CXXMethodDecl>(def); keyFunction = cast<CXXMethodDecl>(def);
switch (keyFunction->getTemplateSpecializationKind()) { switch (keyFunction->getTemplateSpecializationKind()) {
case TSK_Undeclared: case TSK_Undeclared:
case TSK_ExplicitSpecialization: case TSK_ExplicitSpecialization:
...@@ -727,7 +730,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { ...@@ -727,7 +730,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
return !Context.getLangOpts().AppleKext ? return !Context.getLangOpts().AppleKext ?
llvm::GlobalVariable::LinkOnceODRLinkage : llvm::GlobalVariable::LinkOnceODRLinkage :
llvm::Function::InternalLinkage; llvm::Function::InternalLinkage;
return llvm::GlobalVariable::ExternalLinkage; return llvm::GlobalVariable::ExternalLinkage;
case TSK_ImplicitInstantiation: case TSK_ImplicitInstantiation:
...@@ -739,7 +742,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { ...@@ -739,7 +742,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
return !Context.getLangOpts().AppleKext ? return !Context.getLangOpts().AppleKext ?
llvm::GlobalVariable::WeakODRLinkage : llvm::GlobalVariable::WeakODRLinkage :
llvm::Function::InternalLinkage; llvm::Function::InternalLinkage;
case TSK_ExplicitInstantiationDeclaration: case TSK_ExplicitInstantiationDeclaration:
llvm_unreachable("Should not have been asked to emit this"); llvm_unreachable("Should not have been asked to emit this");
} }
...@@ -795,7 +798,7 @@ void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) { ...@@ -795,7 +798,7 @@ void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) {
VTables.GenerateClassData(theClass); VTables.GenerateClassData(theClass);
} }
void void
CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) { CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) {
if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
DI->completeClassData(RD); DI->completeClassData(RD);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment