diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h index 60e1020b99..c319c062ef 100644 --- a/lib/CodeGen/CGCXXABI.h +++ b/lib/CodeGen/CGCXXABI.h @@ -296,9 +296,12 @@ public: llvm::Constant *addr); }; -/// Creates an instance of a C++ ABI class. -CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM); +// Create an instance of a C++ ABI class: + +/// Creates an Itanium-family ABI. CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM); + +/// Creates a Microsoft-family ABI. CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM); } diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 9d7854975e..225ff8b350 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -53,12 +53,12 @@ static const char AnnotationSection[] = "llvm.metadata"; static CGCXXABI &createCXXABI(CodeGenModule &CGM) { switch (CGM.getContext().getTargetInfo().getCXXABI().getKind()) { - // For IR-generation purposes, there's no significant difference - // between the ARM and iOS ABIs. - case TargetCXXABI::GenericARM: return *CreateARMCXXABI(CGM); - case TargetCXXABI::iOS: return *CreateARMCXXABI(CGM); - case TargetCXXABI::GenericItanium: return *CreateItaniumCXXABI(CGM); - case TargetCXXABI::Microsoft: return *CreateMicrosoftCXXABI(CGM); + case TargetCXXABI::GenericARM: + case TargetCXXABI::iOS: + case TargetCXXABI::GenericItanium: + return *CreateItaniumCXXABI(CGM); + case TargetCXXABI::Microsoft: + return *CreateMicrosoftCXXABI(CGM); } llvm_unreachable("invalid C++ ABI kind"); diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 9fce392352..354887f446 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -174,11 +174,20 @@ private: } CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) { - return new ItaniumCXXABI(CGM); -} + switch (CGM.getContext().getTargetInfo().getCXXABI().getKind()) { + // For IR-generation purposes, there's no significant difference + // between the ARM and iOS ABIs. + case TargetCXXABI::GenericARM: + case TargetCXXABI::iOS: + return new ARMCXXABI(CGM); -CodeGen::CGCXXABI *CodeGen::CreateARMCXXABI(CodeGenModule &CGM) { - return new ARMCXXABI(CGM); + case TargetCXXABI::GenericItanium: + return new ItaniumCXXABI(CGM); + + case TargetCXXABI::Microsoft: + llvm_unreachable("Microsoft ABI is not Itanium-based"); + } + llvm_unreachable("bad ABI kind"); } llvm::Type *