[clang] [Sema]Use tag name lookup for class names (PR #112166)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 08:15:31 PDT 2024


================
@@ -357,9 +357,10 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
       return nullptr;
   }
 
-  // FIXME: LookupNestedNameSpecifierName isn't the right kind of
-  // lookup for class-names.
-  LookupNameKind Kind = isClassName ? LookupNestedNameSpecifierName :
+  // In case we know that the identifier is a class name, we know that it is
+  // a type declaration (struct, class, union or enum) so we can use tag name
+  // lookup.
+  LookupNameKind Kind = isClassName ? LookupTagName :
----------------
Sirraide wrote:

I’m no expert on lookup, but from what I can tell, this is indeed correct, but it is worth noting that the wording has changed since then; the current version of [[class.derived]p2](https://eel.is/c++draft/class.derived#general-2) states:
> The lookup for the component name of the [type-name](https://eel.is/c++draft/dcl.type.simple#nt:type-name) or [simple-template-id](https://eel.is/c++draft/temp.names#nt:simple-template-id) is type-only ([[basic.lookup]](https://eel.is/c++draft/basic.lookup))[.](https://eel.is/c++draft/class.derived#general-2.sentence-4)

I think it would be nice to cite the standard in this comment here.

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


More information about the cfe-commits mailing list