@@ -131,28 +131,29 @@ const EHPersonality EHPersonality::ZOS_CPlusPlus = {"__zos_cxx_personality_v2",
131131 nullptr };
132132
133133static const EHPersonality &getCPersonality (const TargetInfo &Target,
134- const LangOptions &L ) {
134+ const CodeGenOptions &CGOpts ) {
135135 const llvm::Triple &T = Target.getTriple ();
136136 if (T.isWindowsMSVCEnvironment ())
137137 return EHPersonality::MSVC_CxxFrameHandler3;
138- if (L .hasSjLjExceptions ())
138+ if (CGOpts .hasSjLjExceptions ())
139139 return EHPersonality::GNU_C_SJLJ;
140- if (L .hasDWARFExceptions ())
140+ if (CGOpts .hasDWARFExceptions ())
141141 return EHPersonality::GNU_C;
142- if (L .hasSEHExceptions ())
142+ if (CGOpts .hasSEHExceptions ())
143143 return EHPersonality::GNU_C_SEH;
144144 return EHPersonality::GNU_C;
145145}
146146
147147static const EHPersonality &getObjCPersonality (const TargetInfo &Target,
148+ const CodeGenOptions &CGOpts,
148149 const LangOptions &L) {
149150 const llvm::Triple &T = Target.getTriple ();
150151 if (T.isWindowsMSVCEnvironment ())
151152 return EHPersonality::MSVC_CxxFrameHandler3;
152153
153154 switch (L.ObjCRuntime .getKind ()) {
154155 case ObjCRuntime::FragileMacOSX:
155- return getCPersonality (Target, L );
156+ return getCPersonality (Target, CGOpts );
156157 case ObjCRuntime::MacOSX:
157158 case ObjCRuntime::iOS:
158159 case ObjCRuntime::WatchOS:
@@ -165,29 +166,29 @@ static const EHPersonality &getObjCPersonality(const TargetInfo &Target,
165166 [[fallthrough]];
166167 case ObjCRuntime::GCC:
167168 case ObjCRuntime::ObjFW:
168- if (L .hasSjLjExceptions ())
169+ if (CGOpts .hasSjLjExceptions ())
169170 return EHPersonality::GNU_ObjC_SJLJ;
170- if (L .hasSEHExceptions ())
171+ if (CGOpts .hasSEHExceptions ())
171172 return EHPersonality::GNU_ObjC_SEH;
172173 return EHPersonality::GNU_ObjC;
173174 }
174175 llvm_unreachable (" bad runtime kind" );
175176}
176177
177178static const EHPersonality &getCXXPersonality (const TargetInfo &Target,
178- const LangOptions &L ) {
179+ const CodeGenOptions &CGOpts ) {
179180 const llvm::Triple &T = Target.getTriple ();
180181 if (T.isWindowsMSVCEnvironment ())
181182 return EHPersonality::MSVC_CxxFrameHandler3;
182183 if (T.isOSAIX ())
183184 return EHPersonality::XL_CPlusPlus;
184- if (L .hasSjLjExceptions ())
185+ if (CGOpts .hasSjLjExceptions ())
185186 return EHPersonality::GNU_CPlusPlus_SJLJ;
186- if (L .hasDWARFExceptions ())
187+ if (CGOpts .hasDWARFExceptions ())
187188 return EHPersonality::GNU_CPlusPlus;
188- if (L .hasSEHExceptions ())
189+ if (CGOpts .hasSEHExceptions ())
189190 return EHPersonality::GNU_CPlusPlus_SEH;
190- if (L .hasWasmExceptions ())
191+ if (CGOpts .hasWasmExceptions ())
191192 return EHPersonality::GNU_Wasm_CPlusPlus;
192193 if (T.isOSzOS ())
193194 return EHPersonality::ZOS_CPlusPlus;
@@ -197,6 +198,7 @@ static const EHPersonality &getCXXPersonality(const TargetInfo &Target,
197198// / Determines the personality function to use when both C++
198199// / and Objective-C exceptions are being caught.
199200static const EHPersonality &getObjCXXPersonality (const TargetInfo &Target,
201+ const CodeGenOptions &CGOpts,
200202 const LangOptions &L) {
201203 if (Target.getTriple ().isWindowsMSVCEnvironment ())
202204 return EHPersonality::MSVC_CxxFrameHandler3;
@@ -205,15 +207,15 @@ static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
205207 // In the fragile ABI, just use C++ exception handling and hope
206208 // they're not doing crazy exception mixing.
207209 case ObjCRuntime::FragileMacOSX:
208- return getCXXPersonality (Target, L );
210+ return getCXXPersonality (Target, CGOpts );
209211
210212 // The ObjC personality defers to the C++ personality for non-ObjC
211213 // handlers. Unlike the C++ case, we use the same personality
212214 // function on targets using (backend-driven) SJLJ EH.
213215 case ObjCRuntime::MacOSX:
214216 case ObjCRuntime::iOS:
215217 case ObjCRuntime::WatchOS:
216- return getObjCPersonality (Target, L);
218+ return getObjCPersonality (Target, CGOpts, L);
217219
218220 case ObjCRuntime::GNUstep:
219221 return Target.getTriple ().isOSCygMing () ? EHPersonality::GNU_CPlusPlus_SEH
@@ -223,7 +225,7 @@ static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
223225 // mixed EH. Use the ObjC personality just to avoid returning null.
224226 case ObjCRuntime::GCC:
225227 case ObjCRuntime::ObjFW:
226- return getObjCPersonality (Target, L);
228+ return getObjCPersonality (Target, CGOpts, L);
227229 }
228230 llvm_unreachable (" bad runtime kind" );
229231}
@@ -237,6 +239,7 @@ static const EHPersonality &getSEHPersonalityMSVC(const llvm::Triple &T) {
237239const EHPersonality &EHPersonality::get (CodeGenModule &CGM,
238240 const FunctionDecl *FD) {
239241 const llvm::Triple &T = CGM.getTarget ().getTriple ();
242+ const CodeGenOptions &CGOpts = CGM.getCodeGenOpts ();
240243 const LangOptions &L = CGM.getLangOpts ();
241244 const TargetInfo &Target = CGM.getTarget ();
242245
@@ -245,10 +248,10 @@ const EHPersonality &EHPersonality::get(CodeGenModule &CGM,
245248 return getSEHPersonalityMSVC (T);
246249
247250 if (L.ObjC )
248- return L.CPlusPlus ? getObjCXXPersonality (Target, L)
249- : getObjCPersonality (Target, L);
250- return L.CPlusPlus ? getCXXPersonality (Target, L )
251- : getCPersonality (Target, L );
251+ return L.CPlusPlus ? getObjCXXPersonality (Target, CGOpts, L)
252+ : getObjCPersonality (Target, CGOpts, L);
253+ return L.CPlusPlus ? getCXXPersonality (Target, CGOpts )
254+ : getCPersonality (Target, CGOpts );
252255}
253256
254257const EHPersonality &EHPersonality::get (CodeGenFunction &CGF) {
@@ -344,7 +347,7 @@ void CodeGenModule::SimplifyPersonality() {
344347 return ;
345348
346349 const EHPersonality &ObjCXX = EHPersonality::get (*this , /* FD=*/ nullptr );
347- const EHPersonality &CXX = getCXXPersonality (getTarget (), LangOpts );
350+ const EHPersonality &CXX = getCXXPersonality (getTarget (), CodeGenOpts );
348351 if (&ObjCXX == &CXX)
349352 return ;
350353
@@ -500,7 +503,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
500503 // In Wasm EH we currently treat 'throw()' in the same way as 'noexcept'. In
501504 // case of throw with types, we ignore it and print a warning for now.
502505 // TODO Correctly handle exception specification in Wasm EH
503- if (CGM.getLangOpts ().hasWasmExceptions ()) {
506+ if (CGM.getCodeGenOpts ().hasWasmExceptions ()) {
504507 if (EST == EST_DynamicNone)
505508 EHStack.pushTerminate ();
506509 else
@@ -515,8 +518,8 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
515518 // throw with types.
516519 // TODO Correctly handle exception specification in Emscripten EH
517520 if (getTarget ().getCXXABI () == TargetCXXABI::WebAssembly &&
518- CGM.getLangOpts ().getExceptionHandling () ==
519- LangOptions ::ExceptionHandlingKind::None &&
521+ CGM.getCodeGenOpts ().getExceptionHandling () ==
522+ CodeGenOptions ::ExceptionHandlingKind::None &&
520523 EST == EST_Dynamic)
521524 CGM.getDiags ().Report (D->getLocation (),
522525 diag::warn_wasm_dynamic_exception_spec_ignored)
@@ -604,7 +607,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
604607 // In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
605608 // case of throw with types, we ignore it and print a warning for now.
606609 // TODO Correctly handle exception specification in wasm
607- if (CGM.getLangOpts ().hasWasmExceptions ()) {
610+ if (CGM.getCodeGenOpts ().hasWasmExceptions ()) {
608611 if (EST == EST_DynamicNone)
609612 EHStack.popTerminate ();
610613 return ;
0 commit comments