[PATCH] D91129: Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion
Shivanshu Goyal via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 15 15:25:05 PST 2020
shivanshu3 marked an inline comment as done.
shivanshu3 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();
----------------
rsmith wrote:
> 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?
Yup, I like that better, thank you for the suggestion!
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