Skip to content

Commit 0d649c6

Browse files
committedJan 25, 2019
Simplify LangOpts initalization in ClangExpressionParser [NFC]
Reviewers: davide Reviewed By: davide Subscribers: shafik, davide, lldb-commits Differential Revision: https://reviews.llvm.org/D57222 llvm-svn: 352249
1 parent 31f47b8 commit 0d649c6

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed
 

‎lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

+28-31
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
362362

363363
// 5. Set language options.
364364
lldb::LanguageType language = expr.Language();
365+
LangOptions &lang_opts = m_compiler->getLangOpts();
365366

366367
switch (language) {
367368
case lldb::eLanguageTypeC:
@@ -373,85 +374,81 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
373374
// For now, the expression parser must use C++ anytime the language is a C
374375
// family language, because the expression parser uses features of C++ to
375376
// capture values.
376-
m_compiler->getLangOpts().CPlusPlus = true;
377+
lang_opts.CPlusPlus = true;
377378
break;
378379
case lldb::eLanguageTypeObjC:
379-
m_compiler->getLangOpts().ObjC = true;
380+
lang_opts.ObjC = true;
380381
// FIXME: the following language option is a temporary workaround,
381382
// to "ask for ObjC, get ObjC++" (see comment above).
382-
m_compiler->getLangOpts().CPlusPlus = true;
383+
lang_opts.CPlusPlus = true;
383384

384385
// Clang now sets as default C++14 as the default standard (with
385386
// GNU extensions), so we do the same here to avoid mismatches that
386387
// cause compiler error when evaluating expressions (e.g. nullptr not found
387388
// as it's a C++11 feature). Currently lldb evaluates C++14 as C++11 (see
388389
// two lines below) so we decide to be consistent with that, but this could
389390
// be re-evaluated in the future.
390-
m_compiler->getLangOpts().CPlusPlus11 = true;
391+
lang_opts.CPlusPlus11 = true;
391392
break;
392393
case lldb::eLanguageTypeC_plus_plus:
393394
case lldb::eLanguageTypeC_plus_plus_11:
394395
case lldb::eLanguageTypeC_plus_plus_14:
395-
m_compiler->getLangOpts().CPlusPlus11 = true;
396+
lang_opts.CPlusPlus11 = true;
396397
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
397398
LLVM_FALLTHROUGH;
398399
case lldb::eLanguageTypeC_plus_plus_03:
399-
m_compiler->getLangOpts().CPlusPlus = true;
400+
lang_opts.CPlusPlus = true;
400401
if (process_sp)
401-
m_compiler->getLangOpts().ObjC =
402+
lang_opts.ObjC =
402403
process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
403404
break;
404405
case lldb::eLanguageTypeObjC_plus_plus:
405406
case lldb::eLanguageTypeUnknown:
406407
default:
407-
m_compiler->getLangOpts().ObjC = true;
408-
m_compiler->getLangOpts().CPlusPlus = true;
409-
m_compiler->getLangOpts().CPlusPlus11 = true;
408+
lang_opts.ObjC = true;
409+
lang_opts.CPlusPlus = true;
410+
lang_opts.CPlusPlus11 = true;
410411
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
411412
break;
412413
}
413414

414-
m_compiler->getLangOpts().Bool = true;
415-
m_compiler->getLangOpts().WChar = true;
416-
m_compiler->getLangOpts().Blocks = true;
417-
m_compiler->getLangOpts().DebuggerSupport =
415+
lang_opts.Bool = true;
416+
lang_opts.WChar = true;
417+
lang_opts.Blocks = true;
418+
lang_opts.DebuggerSupport =
418419
true; // Features specifically for debugger clients
419420
if (expr.DesiredResultType() == Expression::eResultTypeId)
420-
m_compiler->getLangOpts().DebuggerCastResultToId = true;
421+
lang_opts.DebuggerCastResultToId = true;
421422

422-
m_compiler->getLangOpts().CharIsSigned =
423-
ArchSpec(m_compiler->getTargetOpts().Triple.c_str())
424-
.CharIsSignedByDefault();
423+
lang_opts.CharIsSigned = ArchSpec(m_compiler->getTargetOpts().Triple.c_str())
424+
.CharIsSignedByDefault();
425425

426426
// Spell checking is a nice feature, but it ends up completing a lot of types
427427
// that we didn't strictly speaking need to complete. As a result, we spend a
428428
// long time parsing and importing debug information.
429-
m_compiler->getLangOpts().SpellChecking = false;
429+
lang_opts.SpellChecking = false;
430430

431-
if (process_sp && m_compiler->getLangOpts().ObjC) {
431+
if (process_sp && lang_opts.ObjC) {
432432
if (process_sp->GetObjCLanguageRuntime()) {
433433
if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() ==
434434
ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)
435-
m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX,
436-
VersionTuple(10, 7));
435+
lang_opts.ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
437436
else
438-
m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX,
439-
VersionTuple(10, 7));
437+
lang_opts.ObjCRuntime.set(ObjCRuntime::FragileMacOSX,
438+
VersionTuple(10, 7));
440439

441440
if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
442-
m_compiler->getLangOpts().DebuggerObjCLiteral = true;
441+
lang_opts.DebuggerObjCLiteral = true;
443442
}
444443
}
445444

446-
m_compiler->getLangOpts().ThreadsafeStatics = false;
447-
m_compiler->getLangOpts().AccessControl =
448-
false; // Debuggers get universal access
449-
m_compiler->getLangOpts().DollarIdents =
450-
true; // $ indicates a persistent variable name
445+
lang_opts.ThreadsafeStatics = false;
446+
lang_opts.AccessControl = false; // Debuggers get universal access
447+
lang_opts.DollarIdents = true; // $ indicates a persistent variable name
451448
// We enable all builtin functions beside the builtins from libc/libm (e.g.
452449
// 'fopen'). Those libc functions are already correctly handled by LLDB, and
453450
// additionally enabling them as expandable builtins is breaking Clang.
454-
m_compiler->getLangOpts().NoBuiltin = true;
451+
lang_opts.NoBuiltin = true;
455452

456453
// Set CodeGen options
457454
m_compiler->getCodeGenOpts().EmitDeclMetadata = true;

0 commit comments

Comments
 (0)
Please sign in to comment.