[PATCH] D53847: [C++2a] P0634r3: Down with typename!

Nicolas Lesser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 14 22:39:45 PST 2018


Rakete1111 added inline comments.


================
Comment at: lib/Sema/Sema.cpp:2006-2019
+bool Sema::isDeclaratorFunctionLike(const Declarator &D) {
+  assert(D.getCXXScopeSpec().isSet() &&
+         "can only be called for qualified names");
+  LookupResult LR(*this, D.getIdentifier(), D.getBeginLoc(), LookupOrdinaryName,
+                  ForVisibleRedeclaration);
+  DeclContext *DC = computeDeclContext(D.getCXXScopeSpec());
+  if (!DC)
----------------
rsmith wrote:
> Some thoughts on this:
> 
>  * Can this be unified with the lookup code in `HandleDeclarator`? This is really the same lookup, repeated in two places.
>  * It'd be nice to cache this lookup, rather than performing it three times (once when disambiguating a parenthesized initializer from a function declaration, once when we're about to parse a parameter-declaration-clause, and once in `HandleDeclarator` after parsing completes -- though at least that's reduced to two lookups if you make the change I suggested in `ParseParameterDeclarationClause`)
>  * If we don't do the caching, what happens if lookup fails due to ambiguity? Do we get the same error multiple times (once for each time we perform the lookup)?
I don't think so, because `HandleDeclarator` is called after having already parsed the function declaration. I cached it now, but the cleanest solution that I could think of is to use `new`. Is this appropriate? Or do you have an alternative suggestion?


Repository:
  rC Clang

https://reviews.llvm.org/D53847





More information about the cfe-commits mailing list