[PATCH] D20428: Tracking exception specification source locations
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri May 27 10:11:36 PDT 2016
On Fri, May 27, 2016 at 12:19 PM, don hinton <hintonda at gmail.com> wrote:
> hintonda added inline comments.
>
> ================
> Comment at: lib/Parse/ParseDeclCXX.cpp:3403-3428
> @@ -3402,6 +3402,7 @@
> // If we already had a dynamic specification, parse the noexcept for,
> // recovery, but emit a diagnostic and don't store the results.
> - SourceRange NoexceptRange;
> + SourceRange NoexceptRange(Tok.getLocation(),
> + Tok.getEndLoc().getLocWithOffset(-1));
> ExceptionSpecificationType NoexceptType = EST_None;
>
> SourceLocation KeywordLoc = ConsumeToken();
>
> @@ -3424,6 +3425,5 @@
> } else {
> // There is no argument.
> NoexceptType = EST_BasicNoexcept;
> - NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
> }
>
> ----------------
> The range for a single token is a single location. The problem is your test. The range for "throw()" ends at the start of the ')' token. For "noexcept", the beginning and end are the same location, e.g., here's how "int" is tested:
That's right! I forgot that source ranges are not *char* source ranges
but token source ranges. Thank you for the reminder.
~Aaron
>
> ```
> TEST(MatchVerifier, ParseError) {
> LocationVerifier<VarDecl> Verifier;
> Verifier.expectLocation(1, 1);
> EXPECT_FALSE(Verifier.match("int i", varDecl()));
> }
> ```
>
> I think you should use this instead:
>
> ```
> SourceRange NoexceptRange(Tok.getLocation());
> ```
>
>
> http://reviews.llvm.org/D20428
>
>
>
More information about the cfe-commits
mailing list