]> granicus.if.org Git - clang/commitdiff
Add 'mutable' to the function declarator chunk, to be used when
authorDouglas Gregor <dgregor@apple.com>
Wed, 13 Jul 2011 21:47:47 +0000 (21:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 13 Jul 2011 21:47:47 +0000 (21:47 +0000)
parsing lambda expressions, from John Freeman!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135090 91177308-0d34-0410-b5e6-96231b3b80d8

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

index cbf47e8b050d50d0f813bf95a92d14ae02ae069e..a66649955c8c5355d36f11cd3cf4ca18826afc3e 100644 (file)
@@ -1097,6 +1097,10 @@ struct DeclaratorChunk {
     /// If this is an invalid location, there is no ref-qualifier.
     unsigned RefQualifierLoc;
 
+    /// \brief The location of the 'mutable' qualifer in a lambda-declarator, if
+    /// any.
+    unsigned MutableLoc;
+
     /// \brief When ExceptionSpecType isn't EST_None or EST_Delayed, the
     /// location of the keyword introducing the spec.
     unsigned ExceptionSpecLoc;
@@ -1158,10 +1162,19 @@ struct DeclaratorChunk {
       return SourceLocation::getFromRawEncoding(RefQualifierLoc);
     }
 
+    /// \brief Retrieve the location of the 'mutable' qualifier, if any.
+    SourceLocation getMutableLoc() const {
+      return SourceLocation::getFromRawEncoding(MutableLoc);
+    }
+
     /// \brief Determine whether this function declaration contains a 
     /// ref-qualifier.
     bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); }
 
+    /// \brief Determine whether this lambda-declarator contains a 'mutable'
+    /// qualifier.
+    bool hasMutableQualifier() const { return getMutableLoc().isValid(); }
+
     /// \brief Get the type of exception specification this function has.
     ExceptionSpecificationType getExceptionSpecType() const {
       return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
@@ -1285,6 +1298,7 @@ struct DeclaratorChunk {
                                      unsigned TypeQuals, 
                                      bool RefQualifierIsLvalueRef,
                                      SourceLocation RefQualifierLoc,
+                                     SourceLocation MutableLoc,
                                      ExceptionSpecificationType ESpecType,
                                      SourceLocation ESpecLoc,
                                      ParsedType *Exceptions,
index f2588c875f44cc21484f6b0a3ea45c3ee69aa748..0e17295858b9e955c3d40a02403937b5ceac4940 100644 (file)
@@ -3761,6 +3761,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
                                              DS.getTypeQualifiers(),
                                              RefQualifierIsLValueRef,
                                              RefQualifierLoc,
+                                             /*MutableLoc=*/SourceLocation(),
                                              ESpecType, ESpecRange.getBegin(),
                                              DynamicExceptions.data(),
                                              DynamicExceptionRanges.data(),
index d423bd3fb0682363e276addbc8dbd28b4da78a9f..a4b275de13899dc9420d7b00fdd7c08b608fcb1d 100644 (file)
@@ -2233,6 +2233,7 @@ ExprResult Parser::ParseBlockLiteralExpression() {
                                                        SourceLocation(),
                                                        0, 0, 0,
                                                        true, SourceLocation(),
+                                                       SourceLocation(),
                                                        EST_None,
                                                        SourceLocation(),
                                                        0, 0, 0, 0,
index a61188c3c47a337c1ece5e7836516468342c1f49..c87f2cff54896cc1aeaef85337971e84f544bebc 100644 (file)
@@ -149,6 +149,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
                                              unsigned TypeQuals,
                                              bool RefQualifierIsLvalueRef,
                                              SourceLocation RefQualifierLoc,
+                                             SourceLocation MutableLoc,
                                              ExceptionSpecificationType
                                                  ESpecType,
                                              SourceLocation ESpecLoc,
@@ -174,6 +175,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
   I.Fun.ArgInfo                 = 0;
   I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
   I.Fun.RefQualifierLoc         = RefQualifierLoc.getRawEncoding();
+  I.Fun.MutableLoc              = MutableLoc.getRawEncoding();
   I.Fun.ExceptionSpecType       = ESpecType;
   I.Fun.ExceptionSpecLoc        = ESpecLoc.getRawEncoding();
   I.Fun.NumExceptions           = 0;
index f650724535be32e7c9a88797ebbeb37ea69acfdb..ebb1324dcd0e0b88ff9ccfc77750b4c2aacff496 100644 (file)
@@ -6585,6 +6585,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
   Declarator D(DS, Declarator::BlockContext);
   D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, SourceLocation(), 0,
                                              0, 0, true, SourceLocation(),
+                                             SourceLocation(),
                                              EST_None, SourceLocation(),
                                              0, 0, 0, 0, Loc, Loc, D),
                 DS.getAttributes(),
index a9b416b349460293bbe80054df4db54e50c79b6d..f3e73ec5a723c87f411a5feb7512e92b3e3912df 100644 (file)
@@ -555,6 +555,7 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state,
                              /*args*/ 0, 0,
                              /*type quals*/ 0,
                              /*ref-qualifier*/true, SourceLocation(),
+                             /*mutable qualifier*/SourceLocation(),
                              /*EH*/ EST_None, SourceLocation(), 0, 0, 0, 0,
                              /*parens*/ loc, loc,
                              declarator));