diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -296,10 +296,10 @@ if (LexicalDC->isRecord()) Kind = DefaultArgument; } else if (VarDecl *Var = dyn_cast(ManglingContextDecl)) { - if (Var->getDeclContext()->isRecord()) - Kind = StaticDataMember; - else if (Var->getMostRecentDecl()->isInline()) + if (Var->getMostRecentDecl()->isInline()) Kind = InlineVariable; + else if (Var->getDeclContext()->isRecord()) + Kind = StaticDataMember; else if (Var->getDescribedVarTemplate()) Kind = VariableTemplate; else if (auto *VTS = dyn_cast(Var)) { diff --git a/clang/test/CodeGenCXX/mangle-lambdas.cpp b/clang/test/CodeGenCXX/mangle-lambdas.cpp --- a/clang/test/CodeGenCXX/mangle-lambdas.cpp +++ b/clang/test/CodeGenCXX/mangle-lambdas.cpp @@ -290,6 +290,17 @@ // CHECK-LABEL: define linkonce_odr noundef i32 @_ZZZ3ft4IiEvvEN2lc2mfEiEd_NKUlvE_clEv +extern int ExternalVariable; +struct StaticInlineMember { + static constexpr auto x = [] { return ExternalVariable; }; +}; + +// CHECK-LABEL: define void @_Z23test_StaticInlineMemberv +// CHECK: call {{.*}} @_ZNK18StaticInlineMember1xMUlvE_clEv +void test_StaticInlineMember() { + StaticInlineMember::x(); +} + // Check linkage of the various lambdas. // CHECK-LABEL: define linkonce_odr noundef i32 @_ZZ11inline_funciENKUlvE_clEv // CHECK: ret i32 1