aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Parse/ParseDecl.cpp62
-rw-r--r--lib/Parse/ParseDeclCXX.cpp64
-rw-r--r--lib/Parse/ParseExpr.cpp30
-rw-r--r--lib/Parse/ParseExprCXX.cpp53
-rw-r--r--lib/Parse/ParseInit.cpp12
-rw-r--r--lib/Parse/ParseObjc.cpp33
-rw-r--r--lib/Parse/ParseTemplate.cpp20
-rw-r--r--lib/Parse/Parser.cpp20
-rw-r--r--lib/Sema/Action.cpp66
-rw-r--r--lib/Sema/AttributeList.cpp4
-rw-r--r--lib/Sema/DeclSpec.cpp71
-rw-r--r--lib/Sema/SemaCXXCast.cpp2
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp15
-rw-r--r--lib/Sema/SemaCodeComplete.cpp10
-rw-r--r--lib/Sema/SemaDecl.cpp65
-rw-r--r--lib/Sema/SemaDeclAttr.cpp4
-rw-r--r--lib/Sema/SemaDeclCXX.cpp6
-rw-r--r--lib/Sema/SemaDeclObjC.cpp2
-rw-r--r--lib/Sema/SemaExpr.cpp14
-rw-r--r--lib/Sema/SemaExprCXX.cpp67
-rw-r--r--lib/Sema/SemaExprObjC.cpp12
-rw-r--r--lib/Sema/SemaTemplate.cpp30
-rw-r--r--lib/Sema/SemaType.cpp51
-rw-r--r--lib/Sema/TreeTransform.h24
24 files changed, 371 insertions, 366 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 814f203158..ea468b0458 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -773,7 +773,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// This is almost certainly an invalid type name. Let the action emit a
// diagnostic and attempt to recover.
- Action::TypeTy *T = 0;
+ ParsedType T;
if (Actions.DiagnoseUnknownTypeName(*Tok.getIdentifierInfo(), Loc,
getCurScope(), SS, T)) {
// The action emitted a diagnostic, so we don't have to.
@@ -783,8 +783,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// name token, and we're done.
const char *PrevSpec;
unsigned DiagID;
- DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
- false);
+ DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T);
DS.SetRangeEnd(Tok.getLocation());
ConsumeToken();
@@ -981,10 +980,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
if (Next.is(tok::annot_typename)) {
DS.getTypeSpecScope() = SS;
ConsumeToken(); // The C++ scope.
- if (Tok.getAnnotationValue())
+ if (Tok.getAnnotationValue()) {
+ ParsedType T = getTypeAnnotation(Tok);
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc,
- PrevSpec, DiagID,
- Tok.getAnnotationValue());
+ PrevSpec, DiagID, T);
+ }
else
DS.SetTypeSpecError();
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
@@ -1013,8 +1013,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
<< Next.getIdentifierInfo();
}
- TypeTy *TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
- Next.getLocation(), getCurScope(), &SS);
+ ParsedType TypeRep = Actions.getTypeName(*Next.getIdentifierInfo(),
+ Next.getLocation(),
+ getCurScope(), &SS);
// If the referenced identifier is not a type, then this declspec is
// erroneous: We already checked about that it has no type specifier, and
@@ -1041,10 +1042,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
}
case tok::annot_typename: {
- if (Tok.getAnnotationValue())
+ if (Tok.getAnnotationValue()) {
+ ParsedType T = getTypeAnnotation(Tok);
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
- DiagID, Tok.getAnnotationValue());
- else
+ DiagID, T);
+ } else
DS.SetTypeSpecError();
if (isInvalid)
@@ -1097,12 +1099,13 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
break;
// It has to be available as a typedef too!
- TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(),
- Tok.getLocation(), getCurScope());
+ ParsedType TypeRep =
+ Actions.getTypeName(*Tok.getIdentifierInfo(),
+ Tok.getLocation(), getCurScope());
// If this is not a typedef name, don't parse it as part of the declspec,
// it must be an implicit int or an error.
- if (TypeRep == 0) {
+ if (!TypeRep) {
if (ParseImplicitInt(DS, 0, TemplateInfo, AS)) continue;
goto DoneWithDeclSpec;
}
@@ -1520,10 +1523,10 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
// simple-type-specifier:
case tok::annot_typename: {
- if (Tok.getAnnotationValue())
+ if (ParsedType T = getTypeAnnotation(Tok)) {
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
- DiagID, Tok.getAnnotationValue());
- else
+ DiagID, T);
+ } else
DS.SetTypeSpecError();
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeToken(); // The typename
@@ -1930,7 +1933,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
CXXScopeSpec &SS = DS.getTypeSpecScope();
if (getLang().CPlusPlus) {
- if (ParseOptionalCXXScopeSpecifier(SS, 0, false))
+ if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false))
return;
if (SS.isSet() && Tok.isNot(tok::identifier)) {
@@ -2016,7 +2019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
}
if (DS.SetTypeSpecType(DeclSpec::TST_typename, TSTLoc, PrevSpec, DiagID,
- Type.get(), false))
+ Type.get()))
Diag(StartLoc, DiagID) << PrevSpec;
return;
@@ -2037,8 +2040,8 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
if (Tok.is(tok::l_brace))
ParseEnumBody(StartLoc, TagDecl);
- // FIXME: The DeclSpec should keep the locations of both the keyword and the
- // name (if there is one).
+ // FIXME: The DeclSpec should keep the locations of both the keyword
+ // and the name (if there is one).
if (DS.SetTypeSpecType(DeclSpec::TST_enum, TSTLoc, PrevSpec, DiagID,
TagDecl, Owned))
Diag(StartLoc, DiagID) << PrevSpec;
@@ -2371,7 +2374,7 @@ bool Parser::isConstructorDeclarator() {
// Parse the C++ scope specifier.
CXXScopeSpec SS;
- if (ParseOptionalCXXScopeSpecifier(SS, 0, true)) {
+ if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true)) {
TPA.Revert();
return false;
}
@@ -2527,7 +2530,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
(Tok.is(tok::coloncolon) || Tok.is(tok::identifier) ||
Tok.is(tok::annot_cxxscope))) {
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true); // ignore fail
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true); // ignore fail
if (SS.isNotEmpty()) {
if (Tok.isNot(tok::star)) {
@@ -2686,8 +2689,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
if (getLang().CPlusPlus && D.mayHaveIdentifier()) {
// ParseDeclaratorInternal might already have parsed the scope.
if (D.getCXXScopeSpec().isEmpty()) {
- ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), /*ObjectType=*/0,
- true);
+ ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), ParsedType(), true);
}
if (D.getCXXScopeSpec().isValid()) {
@@ -2716,7 +2718,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
/*EnteringContext=*/true,
/*AllowDestructorName=*/true,
AllowConstructorName,
- /*ObjectType=*/0,
+ ParsedType(),
D.getName()) ||
// Once we're past the identifier, if the scope was bad, mark the
// whole declarator bad.
@@ -2951,7 +2953,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
bool hasExceptionSpec = false;
SourceLocation ThrowLoc;
bool hasAnyExceptionSpec = false;
- llvm::SmallVector<TypeTy*, 2> Exceptions;
+ llvm::SmallVector<ParsedType, 2> Exceptions;
llvm::SmallVector<SourceRange, 2> ExceptionRanges;
if (getLang().CPlusPlus) {
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
@@ -3178,7 +3180,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
bool hasExceptionSpec = false;
SourceLocation ThrowLoc;
bool hasAnyExceptionSpec = false;
- llvm::SmallVector<TypeTy*, 2> Exceptions;
+ llvm::SmallVector<ParsedType, 2> Exceptions;
llvm::SmallVector<SourceRange, 2> ExceptionRanges;
if (getLang().CPlusPlus) {
@@ -3418,7 +3420,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
const bool hasParens = Tok.is(tok::l_paren);
bool isCastExpr;
- TypeTy *CastTy;
+ ParsedType CastTy;
SourceRange CastRange;
OwningExprResult Operand = ParseExprAfterTypeofSizeofAlignof(OpTok,
isCastExpr,
@@ -3458,7 +3460,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
unsigned DiagID;
// Check for duplicate type specifiers (e.g. "int typeof(int)").
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
- DiagID, Operand.release()))
+ DiagID, Operand.get()))
Diag(StartLoc, DiagID) << PrevSpec;
}
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index c56a1b4e7c..c8cab42d2d 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -141,7 +141,7 @@ Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
CXXScopeSpec SS;
// Parse (optional) nested-name-specifier.
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
if (SS.isInvalid() || Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_namespace_name);
@@ -274,7 +274,7 @@ Decl *Parser::ParseUsingDirective(unsigned Context,
CXXScopeSpec SS;
// Parse (optional) nested-name-specifier.
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
IdentifierInfo *NamespcName = 0;
SourceLocation IdentLoc = SourceLocation();
@@ -336,7 +336,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
IsTypeName = false;
// Parse nested-name-specifier.
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
// Check nested-name specifier.
if (SS.isInvalid()) {
@@ -352,7 +352,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
/*EnteringContext=*/false,
/*AllowDestructorName=*/true,
/*AllowConstructorName=*/true,
- /*ObjectType=*/0,
+ ParsedType(),
Name)) {
SkipUntil(tok::semi);
return 0;
@@ -485,7 +485,7 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
AnnotateTemplateIdTokenAsType(SS);
assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
- TypeTy *Type = Tok.getAnnotationValue();
+ ParsedType Type = getTypeAnnotation(Tok);
EndLocation = Tok.getAnnotationEndLoc();
ConsumeToken();
@@ -538,13 +538,13 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
// Retrieve the type from the annotation token, consume that token, and
// return.
EndLocation = Tok.getAnnotationEndLoc();
- TypeTy *Type = Tok.getAnnotationValue();
+ ParsedType Type = getTypeAnnotation(Tok);
ConsumeToken();
return Type;
}
// We have an identifier; check whether it is actually a type.
- TypeTy *Type = Actions.getTypeName(*Id, IdLoc, getCurScope(), SS, true);
+ ParsedType Type = Actions.getTypeName(*Id, IdLoc, getCurScope(), SS, true);
if (!Type) {
Diag(IdLoc, diag::err_expected_class_name);
return true;
@@ -682,7 +682,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// "FOO : BAR" is not a potential typo for "FOO::BAR".
ColonProtectionRAIIObject X(*this);
- if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true))
+ if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true))
DS.SetTypeSpecError();
if (SS.isSet())
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
@@ -962,27 +962,25 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
}
- void *Result;
+ // FIXME: The DeclSpec should keep the locations of both the keyword and the
+ // name (if there is one).
+ SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
+
+ const char *PrevSpec = 0;
+ unsigned DiagID;
+ bool Result;
if (!TypeResult.isInvalid()) {
- TagType = DeclSpec::TST_typename;
- Result = TypeResult.get();
- Owned = false;
+ Result = DS.SetTypeSpecType(DeclSpec::TST_typename, TSTLoc,
+ PrevSpec, DiagID, TypeResult.get());
} else if (!TagOrTempResult.isInvalid()) {
- Result = TagOrTempResult.get();
+ Result = DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID,
+ TagOrTempResult.get(), Owned);
} else {
DS.SetTypeSpecError();
return;
}
- const char *PrevSpec = 0;
- unsigned DiagID;
-
- // FIXME: The DeclSpec should keep the locations of both the keyword and the
- // name (if there is one).
- SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
-
- if (DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID,
- Result, Owned))
+ if (Result)
Diag(StartLoc, DiagID) << PrevSpec;
// At this point, we've successfully parsed a class-specifier in 'definition'
@@ -1138,8 +1136,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(Decl *ClassDecl) {
// Parse optional '::' and optional nested-name-specifier.
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0,
- /*EnteringContext=*/false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
// The location of the base class itself.
SourceLocation BaseLoc = Tok.getLocation();
@@ -1252,11 +1249,11 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (isAccessDecl) {
// Collect the scope specifier token we annotated earlier.
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType*/ 0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
// Try to parse an unqualified-id.
UnqualifiedId Name;
- if (ParseUnqualifiedId(SS, false, true, true, /*ObjectType*/ 0, Name)) {
+ if (ParseUnqualifiedId(SS, false, true, true, ParsedType(), Name)) {
SkipUntil(tok::semi);
return;
}
@@ -1748,8 +1745,8 @@ void Parser::ParseConstructorInitializer(Decl *ConstructorDecl) {
Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
// parse '::'[opt] nested-name-specifier[opt]
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
- TypeTy *TemplateTypeTy = 0;
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
+ ParsedType TemplateTypeTy;
if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
@@ -1757,7 +1754,7 @@ Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
TemplateId->Kind == TNK_Dependent_template_name) {
AnnotateTemplateIdTokenAsType(&SS);
assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
- TemplateTypeTy = Tok.getAnnotationValue();
+ TemplateTypeTy = getTypeAnnotation(Tok);
}
}
if (!TemplateTypeTy && Tok.isNot(tok::identifier)) {
@@ -1806,9 +1803,9 @@ Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
/// type-id-list ',' type-id
///
bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc,
- llvm::SmallVector<TypeTy*, 2>
+ llvm::SmallVectorImpl<ParsedType>
&Exceptions,
- llvm::SmallVector<SourceRange, 2>
+ llvm::SmallVectorImpl<SourceRange>
&Ranges,
bool &hasAnyExceptionSpec) {
assert(Tok.is(tok::kw_throw) && "expected throw");
@@ -2068,9 +2065,10 @@ Parser::OwningExprResult Parser::ParseCXX0XAlignArgument(SourceLocation Start) {
EnterExpressionEvaluationContext Unevaluated(Actions,
Action::Unevaluated);
SourceLocation TypeLoc = Tok.getLocation();
- TypeTy *Ty = ParseTypeName().get();
+ ParsedType Ty = ParseTypeName().get();
SourceRange TypeRange(Start, Tok.getLocation());
- return Actions.ActOnSizeOfAlignOfExpr(TypeLoc, false, true, Ty, TypeRange);
+ return Actions.ActOnSizeOfAlignOfExpr(TypeLoc, false, true,
+ Ty.getAsOpaquePtr(), TypeRange);
} else
return ParseConstantExpression();
}
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 626a7ec006..fac5473d4c 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -244,7 +244,7 @@ Parser::OwningExprResult Parser::ParseAssignmentExpression() {
Parser::OwningExprResult
Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
SourceLocation SuperLoc,
- TypeTy *ReceiverType,
+ ParsedType ReceiverType,
Expr *ReceiverExpr) {
OwningExprResult R
= ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
@@ -423,7 +423,7 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, prec::Level MinPrec) {
///
Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
- TypeTy *TypeOfCast) {
+ ParsedType TypeOfCast) {
bool NotCastExpr;
OwningExprResult Res = ParseCastExpression(isUnaryExpression,
isAddressOfOperand,
@@ -548,7 +548,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
bool &NotCastExpr,
- TypeTy *TypeOfCast) {
+ ParsedType TypeOfCast) {
OwningExprResult Res;
tok::TokenKind SavedKind = Tok.getKind();
NotCastExpr = false;
@@ -570,7 +570,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// not start a cast expression.
ParenParseOption ParenExprType =
(isUnaryExpression && !getLang().CPlusPlus)? CompoundLiteral : CastExpr;
- TypeTy *CastTy;
+ ParsedType CastTy;
SourceLocation LParenLoc = Tok.getLocation();
SourceLocation RParenLoc;
@@ -826,7 +826,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// type, translate it into a type and continue parsing as a
// cast expression.
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
AnnotateTemplateIdTokenAsType(&SS);
return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
NotCastExpr, TypeOfCast);
@@ -1027,7 +1027,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
SourceLocation OpLoc = ConsumeToken(); // Eat the "." or "->" token.
CXXScopeSpec SS;
- Action::TypeTy *ObjectType = 0;
+ ParsedType ObjectType;
bool MayBePseudoDestructor = false;
if (getLang().CPlusPlus && !LHS.isInvalid()) {
LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), LHS.take(),
@@ -1039,7 +1039,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
ParseOptionalCXXScopeSpecifier(SS, ObjectType, false,
&MayBePseudoDestructor);
if (SS.isNotEmpty())
- ObjectType = 0;
+ ObjectType = ParsedType();
}
if (Tok.is(tok::code_completion)) {
@@ -1108,7 +1108,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
Parser::OwningExprResult
Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
bool &isCastExpr,
- TypeTy *&CastTy,
+ ParsedType &CastTy,
SourceRange &CastRange) {
assert((OpTok.is(tok::kw_typeof) || OpTok.is(tok::kw_sizeof) ||
@@ -1151,8 +1151,7 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
EnterExpressionEvaluationContext Unevaluated(Actions,
Action::Unevaluated);
Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/,
- 0/*TypeOfCast*/,
- CastTy, RParenLoc);
+ ParsedType(), CastTy, RParenLoc);
CastRange = SourceRange(LParenLoc, RParenLoc);
// If ParseParenExpression parsed a '(typename)' sequence only, then this is
@@ -1192,7 +1191,7 @@ Parser::OwningExprResult Parser::ParseSizeofAlignofExpression() {
ConsumeToken();
bool isCastExpr;
- TypeTy *CastTy;
+ ParsedType CastTy;
SourceRange CastRange;
OwningExprResult Operand = ParseExprAfterTypeofSizeofAlignof(OpTok,
isCastExpr,
@@ -1202,7 +1201,8 @@ Parser::OwningExprResult Parser::ParseSizeofAlignofExpression() {
if (isCastExpr)
return Actions.ActOnSizeOfAlignOfExpr(OpTok.getLocation(),
OpTok.is(tok::kw_sizeof),
- /*isType=*/true, CastTy,
+ /*isType=*/true,
+ CastTy.getAsOpaquePtr(),
CastRange);
// If we get here, the operand to the sizeof/alignof was an expresion.
@@ -1414,14 +1414,14 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
///
Parser::OwningExprResult
Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
- TypeTy *TypeOfCast, TypeTy *&CastTy,
+ ParsedType TypeOfCast, ParsedType &CastTy,
SourceLocation &RParenLoc) {
assert(Tok.is(tok::l_paren) && "Not a paren expr!");
GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
SourceLocation OpenLoc = ConsumeParen();
OwningExprResult Result(true);
bool isAmbiguousTypeId;
- CastTy = 0;
+ CastTy = ParsedType();
if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
Diag(Tok, diag::ext_gnu_statement_expr);
@@ -1532,7 +1532,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
/// '(' type-name ')' '{' initializer-list ',' '}'
///
Parser::OwningExprResult
-Parser::ParseCompoundLiteralExpression(TypeTy *Ty,
+Parser::ParseCompoundLiteralExpression(ParsedType Ty,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
assert(Tok.is(tok::l_brace) && "Not a compound literal!");
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 82c5970f12..b8c16a2257 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -57,7 +57,7 @@ using namespace clang;
///
/// \returns true if there was an error parsing a scope specifier
bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
- Action::TypeTy *ObjectType,
+ ParsedType ObjectType,
bool EnteringContext,
bool *MayBePseudoDestructor) {
assert(getLang().CPlusPlus &&
@@ -104,7 +104,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
//
// To implement this, we clear out the object type as soon as we've
// seen a leading '::' or part of a nested-name-specifier.
- ObjectType = 0;
+ ObjectType = ParsedType();
if (Tok.is(tok::code_completion)) {
// Code completion for a nested-name-specifier, where the code
@@ -212,13 +212,13 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
HasScopeSpecifier = true;
}
- if (TypeToken.getAnnotationValue())
- SS.setScopeRep(
- Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS,
- TypeToken.getAnnotationValue(),
+ if (ParsedType T = getTypeAnnotation(TypeToken)) {
+ CXXScopeTy *Scope =
+ Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, T,
TypeToken.getAnnotationRange(),
- CCLoc));
- else
+ CCLoc);
+ SS.setScopeRep(Scope);
+ } else
SS.setScopeRep(0);
SS.setEndLoc(CCLoc);
continue;
@@ -403,14 +403,14 @@ Parser::OwningExprResult Parser::ParseCXXIdExpression(bool isAddressOfOperand) {
// '::' unqualified-id
//
CXXScopeSpec SS;
- ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
+ ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
UnqualifiedId Name;
if (ParseUnqualifiedId(SS,
/*EnteringContext=*/false,
/*AllowDestructorName=*/false,
/*AllowConstructorName=*/false,
- /*ObjectType=*/0,
+ /*ObjectType=*/ ParsedType(),
Name))
return ExprError();
@@ -519,7 +519,7 @@ Parser::OwningExprResult Parser::ParseCXXTypeid() {
return ExprError();
Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/true,
- Ty.get(), RParenLoc);
+ Ty.get().getAsOpaquePtr(), RParenLoc);
} else {
// C++0x [expr.typeid]p3:
// When typeid is applied to an expression other than an lvalue of a
@@ -565,7 +565,7 @@ Parser::OwningExprResult
Parser::ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind,
CXXScopeSpec &SS,
- Action::TypeTy *ObjectType) {
+ ParsedType ObjectType) {
// We're parsing either a pseudo-destructor-name or a dependent
// member access that has the same form as a
// pseudo-destructor-name. We parse both in the same way and let
@@ -680,7 +680,7 @@ Parser::OwningExprResult Parser::ParseCXXThis() {
Parser::OwningExprResult
Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
- TypeTy *TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
+ ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
assert(Tok.is(tok::l_paren) && "Expected '('!");
SourceLocation LParenLoc = ConsumeParen();
@@ -876,7 +876,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
// type-name
case tok::annot_typename: {
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID,
- Tok.getAnnotationValue());
+ getTypeAnnotation(Tok));
break;
}
@@ -1004,7 +1004,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
IdentifierInfo *Name,
SourceLocation NameLoc,
bool EnteringContext,
- TypeTy *ObjectType,
+ ParsedType ObjectType,
UnqualifiedId &Id,
bool AssumeTemplateId,
SourceLocation TemplateKWLoc) {
@@ -1085,7 +1085,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
EnteringContext, Template,
MemberOfUnknownSpecialization);
- if (TNK == TNK_Non_template && Id.DestructorName == 0) {
+ if (TNK == TNK_Non_template && !Id.DestructorName.get()) {
Diag(NameLoc, diag::err_destructor_template_id)
<< Name << SS.getRange();
return true;
@@ -1203,7 +1203,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
///
/// \returns true if parsing fails, false otherwise.
bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
- TypeTy *ObjectType,
+ ParsedType ObjectType,
UnqualifiedId &Result) {
assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword");
@@ -1382,7 +1382,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
bool AllowDestructorName,
bool AllowConstructorName,
- TypeTy *ObjectType,
+ ParsedType ObjectType,
UnqualifiedId &Result) {
// Handle 'A::template B'. This is for template-ids which have not
@@ -1516,17 +1516,17 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
SourceLocation ClassNameLoc = ConsumeToken();
if (TemplateSpecified || Tok.is(tok::less)) {
- Result.setDestructorName(TildeLoc, 0, ClassNameLoc);
+ Result.setDestructorName(TildeLoc, ParsedType(), ClassNameLoc);
return ParseUnqualifiedIdTemplateId(SS, ClassName, ClassNameLoc,
EnteringContext, ObjectType, Result,
TemplateSpecified, TemplateKWLoc);
}
// Note that this is a destructor name.
- Action::TypeTy *Ty = Actions.getDestructorName(TildeLoc, *ClassName,
- ClassNameLoc, getCurScope(),
- SS, ObjectType,
- EnteringContext);
+ ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName,
+ ClassNameLoc, getCurScope(),
+ SS, ObjectType,
+ EnteringContext);
if (!Ty)
return true;
@@ -1804,7 +1804,7 @@ Parser::OwningExprResult Parser::ParseUnaryTypeTrait() {
/// based on the context past the parens.
Parser::OwningExprResult
Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
- TypeTy *&CastTy,
+ ParsedType &CastTy,
SourceLocation LParenLoc,
SourceLocation &RParenLoc) {
assert(getLang().CPlusPlus && "Should only be called for C++!");
@@ -1812,7 +1812,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
assert(isTypeIdInParens() && "Not a type-id!");
OwningExprResult Result(true);
- CastTy = 0;
+ CastTy = ParsedType();
// We need to disambiguate a very ugly part of the C++ syntax:
//
@@ -1857,7 +1857,8 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
// will be consumed.
Result = ParseCastExpression(false/*isUnaryExpression*/,
false/*isAddressofOperand*/,
- NotCastExpr, 0/*TypeOfCast*/);
+ NotCastExpr,
+ ParsedType()/*TypeOfCast*/);
}
// If we parsed a cast-expression, it's really a type-id, otherwise it's
diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp
index 3be43d8eb5..8d2bc83e97 100644
--- a/lib/Parse/ParseInit.cpp
+++ b/lib/Parse/ParseInit.cpp
@@ -149,7 +149,8 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope()) {
CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
- ConsumeToken(), 0,
+