[cfe-commits] r79489 - in /cfe/trunk: include/clang/Parse/DeclSpec.h lib/Parse/DeclSpec.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Sema/SemaDecl.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Wed Aug 19 16:14:54 PDT 2009


Author: akirtzidis
Date: Wed Aug 19 18:14:54 2009
New Revision: 79489

URL: http://llvm.org/viewvc/llvm-project?rev=79489&view=rev
Log:
Keep track of the right paren ')' source location in a function declarator.

Modified:
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/lib/Parse/DeclSpec.cpp
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=79489&r1=79488&r2=79489&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Aug 19 18:14:54 2009
@@ -737,7 +737,8 @@
                                      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.

Modified: cfe/trunk/lib/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/DeclSpec.cpp?rev=79489&r1=79488&r2=79489&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Parse/DeclSpec.cpp Wed Aug 19 18:14:54 2009
@@ -39,11 +39,13 @@
                                              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();

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=79489&r1=79488&r2=79489&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Aug 19 18:14:54 2009
@@ -2451,7 +2451,8 @@
       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 @@
     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 @@
                                                Exceptions.data(),
                                                ExceptionRanges.data(),
                                                Exceptions.size(),
-                                               LParenLoc, D),
-                  Loc);
+                                               LParenLoc, RParenLoc, D),
+                  EndLoc);
     return;
   }
 
@@ -2629,7 +2630,8 @@
   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 @@
     // 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 @@
                                              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 @@
                                              /*TypeQuals*/0,
                                              /*exception*/false,
                                              SourceLocation(), false, 0, 0, 0,
-                                             LParenLoc, D),
+                                             LParenLoc, RLoc, D),
                 RLoc);
 }
 

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=79489&r1=79488&r2=79489&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Aug 19 18:14:54 2009
@@ -1547,7 +1547,8 @@
                                                        0, 0, 0,
                                                        false, SourceLocation(),
                                                        false, 0, 0, 0,
-                                                       CaretLoc, ParamInfo),
+                                                       CaretLoc, CaretLoc,
+                                                       ParamInfo),
                           CaretLoc);
 
     if (Tok.is(tok::kw___attribute)) {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=79489&r1=79488&r2=79489&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Aug 19 18:14:54 2009
@@ -3758,7 +3758,7 @@
   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);
 





More information about the cfe-commits mailing list