<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54556>54556</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [win] Clang 14 regression: frontend crash in clang::CodeGen::CreateGNUObjCRuntime() building Objective-C++ code
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          triplef
      </td>
    </tr>
</table>

<pre>
    The following Objective-C++ code causes a frontend crash with Clang 14.0.0 on Win64 and Win32. The same code does not crash with Clang 13.0.1 (both using pre-built binaries from GitHub). It also does not crash on macOS.

This seems to happen with any C++ object type as the Objective-C method argument.

```objc
#include <string>

__attribute__((objc_root_class))
@interface Test
-(void)test:(std::string)buffer;
@end

@implementation Test
-(void)test:(std::string)buffer {}
@end

int main()
{
        Test *test;
        [test test:NULL];
}
```

```
Stack dump:
0.      Program arguments: "C:\\Program Files\\LLVM-14\\bin\\clang.exe" -emit-llvm -Xclang -disable-llvm-passes -c clang-14-crash.mm
1.      <eof> parser at end of file
2.      clang-14-crash.mm:12:5: LLVM IR generation of declaration 'main'
3.      clang-14-crash.mm:12:5: Generating code for declaration 'main'
 #0 0x00007ff702ab36e9 clang::CodeGen::CreateGNUObjCRuntime(class clang::CodeGen::CodeGenModule &) (clang.exe+0x11f36e9)
 #1 0x00007ff702a27332 clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(class clang::ObjCMessageExpr const *, class clang::CodeGen::ReturnValueSlot) (clang.exe+0x1167332)
 #2 0x00007ff702bc4bfb clang::CodeGen::CodeGenFunction::ShouldNullCheckClassCastValue(class clang::CastExpr const *) (clang.exe+0x1304bfb)
 #3 0x00007ff702bc47cb clang::CodeGen::CodeGenFunction::ShouldNullCheckClassCastValue(class clang::CastExpr const *) (clang.exe+0x13047cb)
 #4 0x00007ff702bbfb6f clang::CodeGen::CodeGenFunction::EmitScalarExpr(class clang::Expr const *, bool) (clang.exe+0x12ffb6f)
 #5 0x00007ff702a70c65 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(class clang::Expr const *) (clang.exe+0x11b0c65)
 #6 0x00007ff702b92bd0 clang::CodeGen::CodeGenFunction::EmitStmt(class clang::Stmt const *, class llvm::ArrayRef<class clang::Attr const *>) (clang.exe+0x12d2bd0)
 #7 0x00007ff702b8ebec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(class clang::CompoundStmt const &, bool, class clang::CodeGen::AggValueSlot) (clang.exe+0x12cebec)
 #8 0x00007ff702a5a3a5 clang::CodeGen::CodeGenFunction::GenerateCode(class clang::GlobalDecl, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &) (clang.exe+0x119a3a5)
 #9 0x00007ff70294f6b0 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) (clang.exe+0x108f6b0)
#10 0x00007ff70294f2ef clang::CodeGen::CodeGenModule::EmitGlobalDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) (clang.exe+0x108f2ef)
#11 0x00007ff70294ee1b clang::CodeGen::CodeGenModule::EmitGlobal(class clang::GlobalDecl) (clang.exe+0x108ee1b)
#12 0x00007ff702952334 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(class clang::Decl *) (clang.exe+0x1092334)
#13 0x00007ff704aec6af clang::CodeGenerator::GetModule(void) (clang.exe+0x322c6af)
#14 0x00007ff704ae7a16 clang::BackendConsumer::HandleTopLevelDecl(class clang::DeclGroupRef) (clang.exe+0x3227a16)
#15 0x00007ff703a7fe47 clang::ParseAST(class clang::Sema &, bool, bool) (clang.exe+0x21bfe47)
#16 0x00007ff702f14f87 clang::ASTFrontendAction::ExecuteAction(void) (clang.exe+0x1654f87)
#17 0x00007ff704ae6e78 clang::CodeGenAction::ExecuteAction(void) (clang.exe+0x3226e78)
#18 0x00007ff702f14a02 clang::FrontendAction::Execute(void) (clang.exe+0x1654a02)
#19 0x00007ff702ede802 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) (clang.exe+0x161e802)
#20 0x00007ff702f81228 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) (clang.exe+0x16c1228)
#21 0x00007ff701935c32 clang::CodeGen::TargetCodeGenInfo::testFPKind(class llvm::Value *, unsigned int, class clang::CodeGen::CGBuilderTy &, class clang::CodeGen::CodeGenModule &) const (clang.exe+0x75c32)
#22 0x00007ff701930b67 clang::ChainedDiagnosticConsumer::EndSourceFile(void) (clang.exe+0x70b67)
#23 0x00007ff702dfe917 clang::driver::toolchains::BareMetal::handlesTarget(class llvm::Triple const &) (clang.exe+0x153e917)
#24 0x00007ff70269709f llvm::CrashRecoveryContext::RunSafely(class llvm::function_ref<(void)>) (clang.exe+0xdd709f)
#25 0x00007ff702dfef70 clang::driver::CC1Command::Execute(class llvm::ArrayRef<class llvm::Optional<class llvm::StringRef>>, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> *, bool *) const (clang.exe+0x153ef70)
#26 0x00007ff702d7d2e0 clang::driver::Compilation::ExecuteCommand(class clang::driver::Command const &, class clang::driver::Command const *&) const (clang.exe+0x14bd2e0)
#27 0x00007ff702d7d62d clang::driver::Compilation::ExecuteJobs(class clang::driver::JobList const &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) const (clang.exe+0x14bd62d)
#28 0x00007ff702d64d48 clang::driver::Driver::ExecuteCompilation(class clang::driver::Compilation &, class llvm::SmallVectorImpl<struct std::pair<int, class clang::driver::Command const *>> &) (clang.exe+0x14a4d48)
#29 0x00007ff701932e6b llvm::slpvectorizer::BoUpSLP::BlockScheduling::ReadyList::insert(struct llvm::slpvectorizer::BoUpSLP::ScheduleData *) (clang.exe+0x72e6b)
#30 0x00007ff704887c8c clang::Preprocessor::LexUnexpandedNonComment(class clang::Token &) (clang.exe+0x2fc7c8c)
#31 0x00007ffb3c0554e0 (C:\WINDOWS\System32\KERNEL32.DLL+0x154e0)
#32 0x00007ffb3d7c485b (C:\WINDOWS\SYSTEM32\ntdll.dll+0x485b)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM-14\bin
clang: note: diagnostic msg:
********************
```

Preprocessed source and associated run script:
[clang-14-crash.zip](https://github.com/llvm/llvm-project/files/8351651/clang-14-crash.zip)

@rjmccall I saw you made some changes to the non-Darwin runtime for llvm-14. I’d appreciate if you could take a look at this to see if this is related.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNWVtzozoS_jXOi8oubgb8kIfETnKyx5OZijMzu08pIRqbM4AoELmcX7_dAmzLwXEyW7V1UiQBIXV_X3er1UKRjF_PHzbAEpll8jkt1uxr9BcIlT7BeD5yLvFiQsbABG9qqBlnSSULBUXMRMXrDXtO1YbNM44jbW9iTSwmC_YzLXyPceyEd64zYaSi5jm0smKJkgqpBkS4KMJmIyeMJDY2NSEqKxhHTZopFqUFr1IcjCBydpOqP5po5Mwm7FYxntXyUDJCybn4upqMrMXIumj_PmzSmtUAec2UZBtellC0GHjxynrSUpuBqdcSGMeeSGDPMiwHtZEx49W6yaFQhoKRb7UXyhBdk-OmhcgaJD9y57WqkNfIvdof9fjIFbZHjYLHRzQAXjT-sZJSPYqM1zUypasd41kpuqFKuAD2ALVqm8c46kmmMfZT1Oii5rBWMd24F51eZxY1SQLVyL3cCkOHGhRQfF5mQNy4StGOv6mDjYLLUbA4pgc5oIfSQvPtqQU9LGtGWjEaLlpFu_bR9JKaWAfg7vtyOZoudj22GntXDPqnfVwpLn6xuMlLYqCbrAnTP98qua54vnVzjT0QjjOnntM5Xn2P6zSDum1aLn98Gdte-4AR294Iiu8JvAAOZ2PIUzXOsqecjf-t37BxnNY8ykC3jkt0N0byWDD9FsWNdURP8rxFaHcIMZpAJhhKrORVjfbmitHklAlLEFLb2ek6v5XlXtgO_pkS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