[PATCH] D20428: Tracking exception specification source locations

don hinton via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 09:33:05 PDT 2016


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);
   }
 
----------------
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());
> ```
Pasted the wrong test -- this one does the range:

```
TEST(RangeVerifier, WrongRange) {
  RangeVerifier<VarDecl> Verifier;
  Verifier.expectRange(1, 1, 1, 1);
  EXPECT_FALSE(Verifier.match("int i;", varDecl()));
}
```


http://reviews.llvm.org/D20428





More information about the cfe-commits mailing list