@@ -442,9 +442,15 @@ ClangExpressionParser::ClangExpressionParser(
442442 m_compiler->getTargetOpts ().Triple .find (" ios" ) != std::string::npos) {
443443 m_compiler->getTargetOpts ().ABI = " apcs-gnu" ;
444444 }
445+
445446 // Supported subsets of x86
446447 if (target_machine == llvm::Triple::x86 ||
447448 target_machine == llvm::Triple::x86_64) {
449+ // FIXME: shouldn't this be placed after
450+ // `auto target_info = TargetInfo::CreateTargetInfo(...)`
451+ // (see `if (target_machine == llvm::Triple::aarch64)`)?
452+ // It computes `Features` from `FeatureMap` and `FeaturesAsWritten` and
453+ // erases initial `Features` vector.
448454 m_compiler->getTargetOpts ().Features .push_back (" +sse" );
449455 m_compiler->getTargetOpts ().Features .push_back (" +sse2" );
450456 }
@@ -467,6 +473,10 @@ ClangExpressionParser::ClangExpressionParser(
467473
468474 auto target_info = TargetInfo::CreateTargetInfo (
469475 m_compiler->getDiagnostics (), m_compiler->getInvocation ().TargetOpts );
476+ if (target_machine == llvm::Triple::aarch64) {
477+ // TODO: enable this depending on corresponding tag section in ELF
478+ target_info->getTargetOpts ().Features .push_back (" +pauth" );
479+ }
470480 if (log) {
471481 LLDB_LOGF (log, " Target datalayout string: '%s'" ,
472482 target_info->getDataLayoutString ());
@@ -612,6 +622,12 @@ ClangExpressionParser::ClangExpressionParser(
612622 // additionally enabling them as expandable builtins is breaking Clang.
613623 lang_opts.NoBuiltin = true ;
614624
625+ lang_opts.PointerAuthCalls = true ;
626+ lang_opts.PointerAuthReturns = true ;
627+ lang_opts.PointerAuthVTPtrAddressDiscrimination = true ;
628+ lang_opts.PointerAuthVTPtrTypeDiscrimination = true ;
629+ lang_opts.PointerAuthInitFini = true ;
630+
615631 // Set CodeGen options
616632 m_compiler->getCodeGenOpts ().EmitDeclMetadata = true ;
617633 m_compiler->getCodeGenOpts ().InstrumentFunctions = false ;
@@ -622,6 +638,10 @@ ClangExpressionParser::ClangExpressionParser(
622638 else
623639 m_compiler->getCodeGenOpts ().setDebugInfo (codegenoptions::NoDebugInfo);
624640
641+ CompilerInvocation::setDefaultPointerAuthOptions (
642+ m_compiler->getCodeGenOpts ().PointerAuth , lang_opts,
643+ target_arch.GetTriple ());
644+
625645 // Disable some warnings.
626646 SetupDefaultClangDiagnostics (*m_compiler);
627647
0 commit comments