]> granicus.if.org Git - clang/commitdiff
Keep track of the right paren ')' source location in a function declarator.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Aug 2009 23:14:54 +0000 (23:14 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Aug 2009 23:14:54 +0000 (23:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79489 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/DeclSpec.h
lib/Parse/DeclSpec.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/ParseExpr.cpp
lib/Sema/SemaDecl.cpp

index ae1876689a0ca4ad4eded10d04e12b1cde2a5ae7..06d05f7bc718e6d034838e27ffb015fbf28c3a2a 100644 (file)
@@ -737,7 +737,8 @@ struct DeclaratorChunk {
                                      bool hasAnyExceptionSpec,
                                      ActionBase::TypeTy **Exceptions,
                                      SourceRange *ExceptionRanges,
-                                     unsigned NumExceptions, SourceLocation Loc,
+                                     unsigned NumExceptions,
+                                     SourceLocation LPLoc, SourceLocation RPLoc,
                                      Declarator &TheDeclarator);
   
   /// getBlockPointer - Return a DeclaratorChunk for a block.
index 674164a2604a4d3e09edfcf6a23507cf15c6bc61..ceb19a3b3b1a23c01b795b93afe4eeb5f0514534 100644 (file)
@@ -39,11 +39,13 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
                                              ActionBase::TypeTy **Exceptions,
                                              SourceRange *ExceptionRanges,
                                              unsigned NumExceptions,
-                                             SourceLocation Loc,
+                                             SourceLocation LPLoc,
+                                             SourceLocation RPLoc,
                                              Declarator &TheDeclarator) {
   DeclaratorChunk I;
   I.Kind                 = Function;
-  I.Loc                  = Loc;
+  I.Loc                  = LPLoc;
+  I.EndLoc               = RPLoc;
   I.Fun.hasPrototype     = hasProto;
   I.Fun.isVariadic       = isVariadic;
   I.Fun.EllipsisLoc      = EllipsisLoc.getRawEncoding();
index 9958bdf5668637dc971d4631d73e39a0cad1a482..d3d2cf06e35a3d71a69697119b60f2a7a5ff7ccf 100644 (file)
@@ -2451,7 +2451,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
       delete AttrList;
     }
 
-    SourceLocation Loc = ConsumeParen();  // Eat the closing ')'.
+    SourceLocation RParenLoc = ConsumeParen();  // Eat the closing ')'.
+    SourceLocation EndLoc = RParenLoc;
 
     // cv-qualifier-seq[opt].
     DeclSpec DS;
@@ -2463,13 +2464,13 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
     if (getLang().CPlusPlus) {
       ParseTypeQualifierListOpt(DS, false /*no attributes*/);
       if (!DS.getSourceRange().getEnd().isInvalid())
-        Loc = DS.getSourceRange().getEnd();
+        EndLoc = DS.getSourceRange().getEnd();
 
       // Parse exception-specification[opt].
       if (Tok.is(tok::kw_throw)) {
         hasExceptionSpec = true;
         ThrowLoc = Tok.getLocation();
-        ParseExceptionSpecification(Loc, Exceptions, ExceptionRanges,
+        ParseExceptionSpecification(EndLoc, Exceptions, ExceptionRanges,
                                     hasAnyExceptionSpec);
         assert(Exceptions.size() == ExceptionRanges.size() &&
                "Produced different number of exception types and ranges.");
@@ -2488,8 +2489,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
                                                Exceptions.data(),
                                                ExceptionRanges.data(),
                                                Exceptions.size(),
-                                               LParenLoc, D),
-                  Loc);
+                                               LParenLoc, RParenLoc, D),
+                  EndLoc);
     return;
   }
 
@@ -2629,7 +2630,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
   PrototypeScope.Exit();
   
   // If we have the closing ')', eat it.
-  SourceLocation Loc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+  SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+  SourceLocation EndLoc = RParenLoc;
 
   DeclSpec DS;
   bool hasExceptionSpec = false;
@@ -2641,13 +2643,13 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
     // Parse cv-qualifier-seq[opt].
     ParseTypeQualifierListOpt(DS, false /*no attributes*/);
       if (!DS.getSourceRange().getEnd().isInvalid())
-        Loc = DS.getSourceRange().getEnd();
+        EndLoc = DS.getSourceRange().getEnd();
 
     // Parse exception-specification[opt].
     if (Tok.is(tok::kw_throw)) {
       hasExceptionSpec = true;
       ThrowLoc = Tok.getLocation();
-      ParseExceptionSpecification(Loc, Exceptions, ExceptionRanges,
+      ParseExceptionSpecification(EndLoc, Exceptions, ExceptionRanges,
                                   hasAnyExceptionSpec);
       assert(Exceptions.size() == ExceptionRanges.size() &&
              "Produced different number of exception types and ranges.");
@@ -2663,8 +2665,9 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
                                              hasAnyExceptionSpec,
                                              Exceptions.data(),
                                              ExceptionRanges.data(),
-                                             Exceptions.size(), LParenLoc, D),
-                Loc);
+                                             Exceptions.size(),
+                                             LParenLoc, RParenLoc, D),
+                EndLoc);
 }
 
 /// ParseFunctionDeclaratorIdentifierList - While parsing a function declarator
@@ -2740,7 +2743,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
                                              /*TypeQuals*/0,
                                              /*exception*/false,
                                              SourceLocation(), false, 0, 0, 0,
-                                             LParenLoc, D),
+                                             LParenLoc, RLoc, D),
                 RLoc);
 }
 
index 57604a8dc9fb8e0c11f044055e4a6a8341adf8ea..7303f57ddeab54142e1dedca36533910b3d08b10 100644 (file)
@@ -1547,7 +1547,8 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
                                                        0, 0, 0,
                                                        false, SourceLocation(),
                                                        false, 0, 0, 0,
-                                                       CaretLoc, ParamInfo),
+                                                       CaretLoc, CaretLoc,
+                                                       ParamInfo),
                           CaretLoc);
 
     if (Tok.is(tok::kw___attribute)) {
index c2e8477c196c71ab2edbeb3b5a1df1b56aa686e3..f2a0ed7e04c9f54efd90d7a6d689346bbfcfb4a5 100644 (file)
@@ -3758,7 +3758,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
   Declarator D(DS, Declarator::BlockContext);
   D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, SourceLocation(), 0,
                                              0, 0, false, SourceLocation(),
-                                             false, 0,0,0, Loc, D),
+                                             false, 0,0,0, Loc, Loc, D),
                 SourceLocation());
   D.SetIdentifier(&II, Loc);