[PATCH] D91129: Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 15 14:37:36 PST 2020
rsmith added inline comments.
================
Comment at: clang/lib/Parse/ParseExpr.cpp:2267-2280
+ SourceLocation OpTokLoc = OpTok.getLocation();
+ if (OpTokLoc.isMacroID()) {
+ SourceLocation OpTokExpansionLoc =
+ PP.getSourceManager().getFileLoc(OpTokLoc);
+ Diag(OpTokExpansionLoc,
+ diag::err_expected_parentheses_around_typename)
+ << OpTok.getName();
----------------
I don't think we should be assuming that `getLocForEndOfToken` will fail if and only if the token is a macro -- that seems brittle. It would seem better to check whether it actually failed and respond to that directly. Would something like this suggestion work?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91129/new/
https://reviews.llvm.org/D91129
More information about the cfe-commits
mailing list