[PATCH] D134334: [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 11:54:29 PDT 2022


shafik added a comment.

In D134334#3805590 <https://reviews.llvm.org/D134334#3805590>, @erichkeane wrote:

> I have no real idea what is going on here, the parser isn't an area where I spend much time.  Can you ELI5?

I am going to try but perhaps fail to explain this in more detail and more clearly.

IIUC we are trying to error recover, we get to

  	  // Try to resolve the name. If it doesn't exist, assume it was
            // intended to name a type and keep disambiguating.
            switch (TryAnnotateName()) {

At this point we know the current token is `::` and the next token is an identifier. We are trying to annotate the name and it could be a C++17 class template argument deduction case: https://en.cppreference.com/w/cpp/language/class_template_argument_deduction

If we annotate it we should not be left with current token as `::` and the next token as an identifier, this is what the assert verifies here:

  // Annotated it, check again.
  assert(Tok.isNot(tok::annot_cxxscope) ||
         NextToken().isNot(tok::identifier));

So the line I modified says we should only break if we actually annotated and therefore the next token IS NOT an identifier b/c we would have advanced.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134334/new/

https://reviews.llvm.org/D134334



More information about the cfe-commits mailing list