@@ -131,28 +131,29 @@ const EHPersonality EHPersonality::ZOS_CPlusPlus = {"__zos_cxx_personality_v2",
131
131
nullptr };
132
132
133
133
static const EHPersonality &getCPersonality (const TargetInfo &Target,
134
- const LangOptions &L ) {
134
+ const CodeGenOptions &CGOpts ) {
135
135
const llvm::Triple &T = Target.getTriple ();
136
136
if (T.isWindowsMSVCEnvironment ())
137
137
return EHPersonality::MSVC_CxxFrameHandler3;
138
- if (L .hasSjLjExceptions ())
138
+ if (CGOpts .hasSjLjExceptions ())
139
139
return EHPersonality::GNU_C_SJLJ;
140
- if (L .hasDWARFExceptions ())
140
+ if (CGOpts .hasDWARFExceptions ())
141
141
return EHPersonality::GNU_C;
142
- if (L .hasSEHExceptions ())
142
+ if (CGOpts .hasSEHExceptions ())
143
143
return EHPersonality::GNU_C_SEH;
144
144
return EHPersonality::GNU_C;
145
145
}
146
146
147
147
static const EHPersonality &getObjCPersonality (const TargetInfo &Target,
148
+ const CodeGenOptions &CGOpts,
148
149
const LangOptions &L) {
149
150
const llvm::Triple &T = Target.getTriple ();
150
151
if (T.isWindowsMSVCEnvironment ())
151
152
return EHPersonality::MSVC_CxxFrameHandler3;
152
153
153
154
switch (L.ObjCRuntime .getKind ()) {
154
155
case ObjCRuntime::FragileMacOSX:
155
- return getCPersonality (Target, L );
156
+ return getCPersonality (Target, CGOpts );
156
157
case ObjCRuntime::MacOSX:
157
158
case ObjCRuntime::iOS:
158
159
case ObjCRuntime::WatchOS:
@@ -165,29 +166,29 @@ static const EHPersonality &getObjCPersonality(const TargetInfo &Target,
165
166
[[fallthrough]];
166
167
case ObjCRuntime::GCC:
167
168
case ObjCRuntime::ObjFW:
168
- if (L .hasSjLjExceptions ())
169
+ if (CGOpts .hasSjLjExceptions ())
169
170
return EHPersonality::GNU_ObjC_SJLJ;
170
- if (L .hasSEHExceptions ())
171
+ if (CGOpts .hasSEHExceptions ())
171
172
return EHPersonality::GNU_ObjC_SEH;
172
173
return EHPersonality::GNU_ObjC;
173
174
}
174
175
llvm_unreachable (" bad runtime kind" );
175
176
}
176
177
177
178
static const EHPersonality &getCXXPersonality (const TargetInfo &Target,
178
- const LangOptions &L ) {
179
+ const CodeGenOptions &CGOpts ) {
179
180
const llvm::Triple &T = Target.getTriple ();
180
181
if (T.isWindowsMSVCEnvironment ())
181
182
return EHPersonality::MSVC_CxxFrameHandler3;
182
183
if (T.isOSAIX ())
183
184
return EHPersonality::XL_CPlusPlus;
184
- if (L .hasSjLjExceptions ())
185
+ if (CGOpts .hasSjLjExceptions ())
185
186
return EHPersonality::GNU_CPlusPlus_SJLJ;
186
- if (L .hasDWARFExceptions ())
187
+ if (CGOpts .hasDWARFExceptions ())
187
188
return EHPersonality::GNU_CPlusPlus;
188
- if (L .hasSEHExceptions ())
189
+ if (CGOpts .hasSEHExceptions ())
189
190
return EHPersonality::GNU_CPlusPlus_SEH;
190
- if (L .hasWasmExceptions ())
191
+ if (CGOpts .hasWasmExceptions ())
191
192
return EHPersonality::GNU_Wasm_CPlusPlus;
192
193
if (T.isOSzOS ())
193
194
return EHPersonality::ZOS_CPlusPlus;
@@ -197,6 +198,7 @@ static const EHPersonality &getCXXPersonality(const TargetInfo &Target,
197
198
// / Determines the personality function to use when both C++
198
199
// / and Objective-C exceptions are being caught.
199
200
static const EHPersonality &getObjCXXPersonality (const TargetInfo &Target,
201
+ const CodeGenOptions &CGOpts,
200
202
const LangOptions &L) {
201
203
if (Target.getTriple ().isWindowsMSVCEnvironment ())
202
204
return EHPersonality::MSVC_CxxFrameHandler3;
@@ -205,15 +207,15 @@ static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
205
207
// In the fragile ABI, just use C++ exception handling and hope
206
208
// they're not doing crazy exception mixing.
207
209
case ObjCRuntime::FragileMacOSX:
208
- return getCXXPersonality (Target, L );
210
+ return getCXXPersonality (Target, CGOpts );
209
211
210
212
// The ObjC personality defers to the C++ personality for non-ObjC
211
213
// handlers. Unlike the C++ case, we use the same personality
212
214
// function on targets using (backend-driven) SJLJ EH.
213
215
case ObjCRuntime::MacOSX:
214
216
case ObjCRuntime::iOS:
215
217
case ObjCRuntime::WatchOS:
216
- return getObjCPersonality (Target, L);
218
+ return getObjCPersonality (Target, CGOpts, L);
217
219
218
220
case ObjCRuntime::GNUstep:
219
221
return Target.getTriple ().isOSCygMing () ? EHPersonality::GNU_CPlusPlus_SEH
@@ -223,7 +225,7 @@ static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
223
225
// mixed EH. Use the ObjC personality just to avoid returning null.
224
226
case ObjCRuntime::GCC:
225
227
case ObjCRuntime::ObjFW:
226
- return getObjCPersonality (Target, L);
228
+ return getObjCPersonality (Target, CGOpts, L);
227
229
}
228
230
llvm_unreachable (" bad runtime kind" );
229
231
}
@@ -237,6 +239,7 @@ static const EHPersonality &getSEHPersonalityMSVC(const llvm::Triple &T) {
237
239
const EHPersonality &EHPersonality::get (CodeGenModule &CGM,
238
240
const FunctionDecl *FD) {
239
241
const llvm::Triple &T = CGM.getTarget ().getTriple ();
242
+ const CodeGenOptions &CGOpts = CGM.getCodeGenOpts ();
240
243
const LangOptions &L = CGM.getLangOpts ();
241
244
const TargetInfo &Target = CGM.getTarget ();
242
245
@@ -245,10 +248,10 @@ const EHPersonality &EHPersonality::get(CodeGenModule &CGM,
245
248
return getSEHPersonalityMSVC (T);
246
249
247
250
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 );
252
255
}
253
256
254
257
const EHPersonality &EHPersonality::get (CodeGenFunction &CGF) {
@@ -344,7 +347,7 @@ void CodeGenModule::SimplifyPersonality() {
344
347
return ;
345
348
346
349
const EHPersonality &ObjCXX = EHPersonality::get (*this , /* FD=*/ nullptr );
347
- const EHPersonality &CXX = getCXXPersonality (getTarget (), LangOpts );
350
+ const EHPersonality &CXX = getCXXPersonality (getTarget (), CodeGenOpts );
348
351
if (&ObjCXX == &CXX)
349
352
return ;
350
353
@@ -500,7 +503,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
500
503
// In Wasm EH we currently treat 'throw()' in the same way as 'noexcept'. In
501
504
// case of throw with types, we ignore it and print a warning for now.
502
505
// TODO Correctly handle exception specification in Wasm EH
503
- if (CGM.getLangOpts ().hasWasmExceptions ()) {
506
+ if (CGM.getCodeGenOpts ().hasWasmExceptions ()) {
504
507
if (EST == EST_DynamicNone)
505
508
EHStack.pushTerminate ();
506
509
else
@@ -515,8 +518,8 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
515
518
// throw with types.
516
519
// TODO Correctly handle exception specification in Emscripten EH
517
520
if (getTarget ().getCXXABI () == TargetCXXABI::WebAssembly &&
518
- CGM.getLangOpts ().getExceptionHandling () ==
519
- LangOptions ::ExceptionHandlingKind::None &&
521
+ CGM.getCodeGenOpts ().getExceptionHandling () ==
522
+ CodeGenOptions ::ExceptionHandlingKind::None &&
520
523
EST == EST_Dynamic)
521
524
CGM.getDiags ().Report (D->getLocation (),
522
525
diag::warn_wasm_dynamic_exception_spec_ignored)
@@ -604,7 +607,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
604
607
// In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
605
608
// case of throw with types, we ignore it and print a warning for now.
606
609
// TODO Correctly handle exception specification in wasm
607
- if (CGM.getLangOpts ().hasWasmExceptions ()) {
610
+ if (CGM.getCodeGenOpts ().hasWasmExceptions ()) {
608
611
if (EST == EST_DynamicNone)
609
612
EHStack.popTerminate ();
610
613
return ;
0 commit comments