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: > aaron.ballman wrote: > > 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. > 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())); > } > ``` Sorry, looked at wrong tests -- should have looked at multi-character ending tokens. ``` NoexceptRange = SourceRange( Tok.getLocation(), Tok.getLocation().getLocWithOffset(Tok.getLength())); ``` http://reviews.llvm.org/D20428 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits