[PATCH] D91821: Fix PR42049 - Crash when parsing bad decltype use within template argument list after name assumed to be a function template

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 20 14:40:37 PST 2020


rsmith added inline comments.


================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1055
+      // semi-colon.
+      EndLoc = PP.getLastCachedTokenLocation();
+    }
----------------
It seems to me that either `EndLoc` was miscomputed and should already point to the last token that we skipped over, in which case we should fix `ParseDecltypeSpecifier` to return the correct source location, or `EndLoc` is correct and we should revert back to the corresponding token and only annotate that portion of the token stream as the decltype specifier. (Or maybe a third option: `EndLoc` is meaningless when the type specifier is erroneous, in which case this code is still wrong because it's using that value in the case where backtracking is not enabled.)

Rolling back the token stream to the token corresponding to `EndLoc` seems likely to give us the best error recovery here, assuming that `EndLoc` is currently set to the token that we think is the last one that's intended to be part of the decltype specifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91821



More information about the cfe-commits mailing list