[PATCH] D20428: Tracking exception specification source locations

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 10:10:48 PDT 2016


aaron.ballman 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);
   }
 
----------------
hintonda wrote:
> 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:
> 
> ```
> 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());
> ```
Ah, how interesting; I would have assumed the range would be the full range of the source involved, but I forgot, that's what char ranges are for.


http://reviews.llvm.org/D20428





More information about the cfe-commits mailing list