summaryrefslogtreecommitdiff
path: root/include/clang/Sema/DeclSpec.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Sema/DeclSpec.h')
-rw-r--r--include/clang/Sema/DeclSpec.h89
1 files changed, 53 insertions, 36 deletions
diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h
index 2e70203c6cc08..8d6f0bc9148bf 100644
--- a/include/clang/Sema/DeclSpec.h
+++ b/include/clang/Sema/DeclSpec.h
@@ -505,8 +505,8 @@ public:
const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
SourceRange getSourceRange() const LLVM_READONLY { return Range; }
- SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
- SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
+ SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
+ SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); }
SourceRange getTypeSpecWidthRange() const { return TSWRange; }
@@ -593,6 +593,18 @@ public:
FS_noreturnLoc = SourceLocation();
}
+ /// This method calls the passed in handler on each CVRU qual being
+ /// set.
+ /// Handle - a handler to be invoked.
+ void forEachCVRUQualifier(
+ llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle);
+
+ /// This method calls the passed in handler on each qual being
+ /// set.
+ /// Handle - a handler to be invoked.
+ void forEachQualifier(
+ llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle);
+
/// Return true if any type-specifier has been found.
bool hasTypeSpecifier() const {
return getTypeSpecType() != DeclSpec::TST_unspecified ||
@@ -683,6 +695,8 @@ public:
ExprRep = Rep;
}
+ bool SetTypeQual(TQ T, SourceLocation Loc);
+
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID, const LangOptions &Lang);
@@ -1120,8 +1134,8 @@ public:
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(StartLocation, EndLocation);
}
- SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
- SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
+ SourceLocation getBeginLoc() const LLVM_READONLY { return StartLocation; }
+ SourceLocation getEndLoc() const LLVM_READONLY { return EndLocation; }
};
/// A set of tokens that has been cached for later parsing.
@@ -1250,10 +1264,6 @@ struct DeclaratorChunk {
/// Otherwise, it's an rvalue reference.
unsigned RefQualifierIsLValueRef : 1;
- /// The type qualifiers: const/volatile/restrict/__unaligned
- /// The qualifier bitmask values are the same as in QualType.
- unsigned TypeQuals : 4;
-
/// ExceptionSpecType - An ExceptionSpecificationType value.
unsigned ExceptionSpecType : 4;
@@ -1287,21 +1297,6 @@ struct DeclaratorChunk {
/// If this is an invalid location, there is no ref-qualifier.
unsigned RefQualifierLoc;
- /// The location of the const-qualifier, if any.
- ///
- /// If this is an invalid location, there is no const-qualifier.
- unsigned ConstQualifierLoc;
-
- /// The location of the volatile-qualifier, if any.
- ///
- /// If this is an invalid location, there is no volatile-qualifier.
- unsigned VolatileQualifierLoc;
-
- /// The location of the restrict-qualifier, if any.
- ///
- /// If this is an invalid location, there is no restrict-qualifier.
- unsigned RestrictQualifierLoc;
-
/// The location of the 'mutable' qualifer in a lambda-declarator, if
/// any.
unsigned MutableLoc;
@@ -1317,6 +1312,12 @@ struct DeclaratorChunk {
/// there are no parameters specified.
ParamInfo *Params;
+ /// DeclSpec for the function with the qualifier related info.
+ DeclSpec *MethodQualifiers;
+
+ /// AtttibuteFactory for the MethodQualifiers.
+ AttributeFactory *QualAttrFactory;
+
union {
/// Pointer to a new[]'d array of TypeAndRange objects that
/// contain the types in the function's dynamic exception specification
@@ -1356,6 +1357,8 @@ struct DeclaratorChunk {
void destroy() {
freeParams();
+ delete QualAttrFactory;
+ delete MethodQualifiers;
switch (getExceptionSpecType()) {
default:
break;
@@ -1372,6 +1375,14 @@ struct DeclaratorChunk {
}
}
+ DeclSpec &getOrCreateMethodQualifiers() {
+ if (!MethodQualifiers) {
+ QualAttrFactory = new AttributeFactory();
+ MethodQualifiers = new DeclSpec(*QualAttrFactory);
+ }
+ return *MethodQualifiers;
+ }
+
/// isKNRPrototype - Return true if this is a K&R style identifier list,
/// like "void foo(a,b,c)". In a function definition, this will be followed
/// by the parameter type definitions.
@@ -1406,19 +1417,22 @@ struct DeclaratorChunk {
return SourceLocation::getFromRawEncoding(RefQualifierLoc);
}
- /// Retrieve the location of the 'const' qualifier, if any.
+ /// Retrieve the location of the 'const' qualifier.
SourceLocation getConstQualifierLoc() const {
- return SourceLocation::getFromRawEncoding(ConstQualifierLoc);
+ assert(MethodQualifiers);
+ return MethodQualifiers->getConstSpecLoc();
}
- /// Retrieve the location of the 'volatile' qualifier, if any.
+ /// Retrieve the location of the 'volatile' qualifier.
SourceLocation getVolatileQualifierLoc() const {
- return SourceLocation::getFromRawEncoding(VolatileQualifierLoc);
+ assert(MethodQualifiers);
+ return MethodQualifiers->getVolatileSpecLoc();
}
- /// Retrieve the location of the 'restrict' qualifier, if any.
+ /// Retrieve the location of the 'restrict' qualifier.
SourceLocation getRestrictQualifierLoc() const {
- return SourceLocation::getFromRawEncoding(RestrictQualifierLoc);
+ assert(MethodQualifiers);
+ return MethodQualifiers->getRestrictSpecLoc();
}
/// Retrieve the location of the 'mutable' qualifier, if any.
@@ -1434,6 +1448,12 @@ struct DeclaratorChunk {
/// qualifier.
bool hasMutableQualifier() const { return getMutableLoc().isValid(); }
+ /// Determine whether this method has qualifiers.
+ bool hasMethodTypeQualifiers() const {
+ return MethodQualifiers && (MethodQualifiers->getTypeQualifiers() ||
+ MethodQualifiers->getAttributes().size());
+ }
+
/// Get the type of exception specification this function has.
ExceptionSpecificationType getExceptionSpecType() const {
return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
@@ -1574,12 +1594,8 @@ struct DeclaratorChunk {
ParamInfo *Params, unsigned NumParams,
SourceLocation EllipsisLoc,
SourceLocation RParenLoc,
- unsigned TypeQuals,
bool RefQualifierIsLvalueRef,
SourceLocation RefQualifierLoc,
- SourceLocation ConstQualifierLoc,
- SourceLocation VolatileQualifierLoc,
- SourceLocation RestrictQualifierLoc,
SourceLocation MutableLoc,
ExceptionSpecificationType ESpecType,
SourceRange ESpecRange,
@@ -1593,7 +1609,8 @@ struct DeclaratorChunk {
SourceLocation LocalRangeEnd,
Declarator &TheDeclarator,
TypeResult TrailingReturnType =
- TypeResult());
+ TypeResult(),
+ DeclSpec *MethodQualifiers = nullptr);
/// Return a DeclaratorChunk for a block.
static DeclaratorChunk getBlockPointer(unsigned TypeQuals,
@@ -1870,8 +1887,8 @@ public:
/// Get the source range that spans this declarator.
SourceRange getSourceRange() const LLVM_READONLY { return Range; }
- SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
- SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
+ SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
+ SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
void SetSourceRange(SourceRange R) { Range = R; }
/// SetRangeBegin - Set the start of the source range to Loc, unless it's