[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 1 01:12:16 PDT 2024


================
@@ -1012,7 +1012,14 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C<Class<T>> and C<Class> are
   // perceived identical.
   std::optional<Sema::ContextRAII> ContextScope;
-  if (auto *RD = dyn_cast<CXXRecordDecl>(DeclInfo.getDeclContext())) {
+  const DeclContext *DC = [&] {
+    if (!DeclInfo.getDecl())
+      return DeclInfo.getDeclContext();
+    return DeclInfo.getDecl()->getFriendObjectKind()
+               ? DeclInfo.getLexicalDeclContext()
+               : DeclInfo.getDeclContext();
----------------
cor3ntin wrote:

I wonder if we should have a function that handles that logic of getting a lexical context for friends - we do it in a few places

https://github.com/llvm/llvm-project/pull/106890


More information about the cfe-commits mailing list