Author: rksimon Date: Thu Sep 8 04:59:58 2016 New Revision: 280917 URL: http://llvm.org/viewvc/llvm-project?rev=280917&view=rev Log: Fixed a 'not all control paths return a value' warning on MSVC builds
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=280917&r1=280916&r2=280917&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original) +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Sep 8 04:59:58 2016 @@ -29,7 +29,7 @@ using namespace CodeGen; CodeGenVTables::CodeGenVTables(CodeGenModule &CGM) : CGM(CGM), VTContext(CGM.getContext().getVTableContext()) {} -llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, +llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk) { const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); @@ -93,7 +93,7 @@ static RValue PerformReturnAdjustment(Co AdjustNull = CGF.createBasicBlock("adjust.null"); AdjustNotNull = CGF.createBasicBlock("adjust.notnull"); AdjustEnd = CGF.createBasicBlock("adjust.end"); - + llvm::Value *IsNull = CGF.Builder.CreateIsNull(ReturnValue); CGF.Builder.CreateCondBr(IsNull, AdjustNull, AdjustNotNull); CGF.EmitBlock(AdjustNotNull); @@ -110,14 +110,14 @@ static RValue PerformReturnAdjustment(Co CGF.EmitBlock(AdjustNull); CGF.Builder.CreateBr(AdjustEnd); CGF.EmitBlock(AdjustEnd); - + llvm::PHINode *PHI = CGF.Builder.CreatePHI(ReturnValue->getType(), 2); PHI->addIncoming(ReturnValue, AdjustNotNull); - PHI->addIncoming(llvm::Constant::getNullValue(ReturnValue->getType()), + PHI->addIncoming(llvm::Constant::getNullValue(ReturnValue->getType()), AdjustNull); ReturnValue = PHI; } - + return RValue::get(ReturnValue); } @@ -314,7 +314,7 @@ void CodeGenFunction::EmitCallAndReturnF CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect && !hasScalarEvaluationKind(CurFnInfo->getReturnType())) Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified()); - + // Now emit our call. llvm::Instruction *CallOrInvoke; RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, MD, &CallOrInvoke); @@ -433,14 +433,14 @@ void CodeGenVTables::emitThunk(GlobalDec // Remove the name from the old thunk function and get a new thunk. OldThunkFn->setName(StringRef()); Entry = cast<llvm::GlobalValue>(CGM.GetAddrOfThunk(GD, Thunk)); - + // If needed, replace the old thunk with a bitcast. if (!OldThunkFn->use_empty()) { llvm::Constant *NewPtrForOldDecl = llvm::ConstantExpr::getBitCast(Entry, OldThunkFn->getType()); OldThunkFn->replaceAllUsesWith(NewPtrForOldDecl); } - + // Remove the old thunk. OldThunkFn->eraseFromParent(); } @@ -500,7 +500,7 @@ void CodeGenVTables::maybeEmitThunkForVT void CodeGenVTables::EmitThunks(GlobalDecl GD) { - const CXXMethodDecl *MD = + const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl())->getCanonicalDecl(); // We don't need to generate thunks for the base destructor. @@ -529,6 +529,9 @@ llvm::Constant *CodeGenVTables::CreateVT }; switch (Component.getKind()) { + default: + llvm_unreachable("Unexpected vtable component kind"); + case VTableComponent::CK_VCallOffset: return OffsetConstant(Component.getVCallOffset()); @@ -636,9 +639,9 @@ CodeGenVTables::CreateVTableInitializer( } llvm::GlobalVariable * -CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, - const BaseSubobject &Base, - bool BaseIsVirtual, +CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, + const BaseSubobject &Base, + bool BaseIsVirtual, llvm::GlobalVariable::LinkageTypes Linkage, VTableAddressPointsMapTy& AddressPoints) { if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) @@ -671,7 +674,7 @@ CodeGenVTables::GenerateConstructionVTab Linkage = llvm::GlobalVariable::InternalLinkage; // Create the variable that will hold the construction vtable. - llvm::GlobalVariable *VTable = + llvm::GlobalVariable *VTable = CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType, Linkage); CGM.setGlobalVisibility(VTable, RD); @@ -684,7 +687,7 @@ CodeGenVTables::GenerateConstructionVTab // Create and set the initializer. llvm::Constant *Init = CreateVTableInitializer(*VTLayout, RTTI); VTable->setInitializer(Init); - + CGM.EmitVTableTypeMetadata(VTable, *VTLayout.get()); return VTable; @@ -699,7 +702,7 @@ static bool shouldEmitAvailableExternall /// Compute the required linkage of the vtable for the given class. /// /// Note that we only call this at the end of the translation unit. -llvm::GlobalVariable::LinkageTypes +llvm::GlobalVariable::LinkageTypes CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { if (!RD->isExternallyVisible()) return llvm::GlobalVariable::InternalLinkage; @@ -713,7 +716,7 @@ CodeGenModule::getVTableLinkage(const CX const FunctionDecl *def = nullptr; if (keyFunction->hasBody(def)) keyFunction = cast<CXXMethodDecl>(def); - + switch (keyFunction->getTemplateSpecializationKind()) { case TSK_Undeclared: case TSK_ExplicitSpecialization: @@ -727,7 +730,7 @@ CodeGenModule::getVTableLinkage(const CX return !Context.getLangOpts().AppleKext ? llvm::GlobalVariable::LinkOnceODRLinkage : llvm::Function::InternalLinkage; - + return llvm::GlobalVariable::ExternalLinkage; case TSK_ImplicitInstantiation: @@ -739,7 +742,7 @@ CodeGenModule::getVTableLinkage(const CX return !Context.getLangOpts().AppleKext ? llvm::GlobalVariable::WeakODRLinkage : llvm::Function::InternalLinkage; - + case TSK_ExplicitInstantiationDeclaration: llvm_unreachable("Should not have been asked to emit this"); } @@ -795,7 +798,7 @@ void CodeGenModule::EmitVTable(CXXRecord VTables.GenerateClassData(theClass); } -void +void CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) { if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) DI->completeClassData(RD); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits