summaryrefslogtreecommitdiffstats
path: root/include/clang/AST
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-01-01 10:34:51 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-01-01 10:34:51 +0000
commitbb1e3bc1e0be2b8f891db46457a8943451bf4d8b (patch)
tree1e68501209c9133fbda8d45171e59f8d6f12dd55 /include/clang/AST
parent77212133072dc40f070a280af8217032f55a9eb4 (diff)
downloadFreeBSD-src-bb1e3bc1e0be2b8f891db46457a8943451bf4d8b.zip
FreeBSD-src-bb1e3bc1e0be2b8f891db46457a8943451bf4d8b.tar.gz
Updaet clang to 92395.
Diffstat (limited to 'include/clang/AST')
-rw-r--r--include/clang/AST/ASTContext.h42
-rw-r--r--include/clang/AST/CanonicalType.h2
-rw-r--r--include/clang/AST/CharUnits.h149
-rw-r--r--include/clang/AST/Decl.h80
-rw-r--r--include/clang/AST/DeclCXX.h16
-rw-r--r--include/clang/AST/DeclObjC.h6
-rw-r--r--include/clang/AST/Expr.h78
-rw-r--r--include/clang/AST/ExprCXX.h120
-rw-r--r--include/clang/AST/ExprObjC.h27
-rw-r--r--include/clang/AST/FullExpr.h89
-rw-r--r--include/clang/AST/RecordLayout.h2
-rw-r--r--include/clang/AST/Stmt.h24
-rw-r--r--include/clang/AST/StmtIterator.h37
-rw-r--r--include/clang/AST/TemplateBase.h2
-rw-r--r--include/clang/AST/Type.h52
-rw-r--r--include/clang/AST/TypeLoc.h7
-rw-r--r--include/clang/AST/TypeNodes.def2
17 files changed, 545 insertions, 190 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 3fc5aab..bcab46d 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -38,6 +38,7 @@ namespace clang {
class FileManager;
class ASTRecordLayout;
class BlockExpr;
+ class CharUnits;
class Expr;
class ExternalASTSource;
class IdentifierTable;
@@ -114,9 +115,6 @@ class ASTContext {
/// \brief Mapping from ObjCContainers to their ObjCImplementations.
llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
- llvm::DenseMap<unsigned, FixedWidthIntType*> SignedFixedWidthIntTypes;
- llvm::DenseMap<unsigned, FixedWidthIntType*> UnsignedFixedWidthIntTypes;
-
/// BuiltinVaListType - built-in va list type.
/// This is initially null and set by Sema::LazilyCreateBuiltin when
/// a builtin that takes a valist is encountered.
@@ -724,8 +722,6 @@ public:
void setBuiltinVaListType(QualType T);
QualType getBuiltinVaListType() const { return BuiltinVaListType; }
- QualType getFixedWidthIntType(unsigned Width, bool Signed);
-
/// getCVRQualifiedType - Returns a type with additional const,
/// volatile, or restrict qualifiers.
QualType getCVRQualifiedType(QualType T, unsigned CVR) {
@@ -812,19 +808,15 @@ public:
return getTypeInfo(T).first;
}
- /// getByteWidth - Return the size of a byte, in bits
- uint64_t getByteSize() {
+ /// getCharWidth - Return the size of the character type, in bits
+ uint64_t getCharWidth() {
return getTypeSize(CharTy);
}
- /// getTypeSizeInBytes - Return the size of the specified type, in bytes.
+ /// getTypeSizeInChars - Return the size of the specified type, in characters.
/// This method does not work on incomplete types.
- uint64_t getTypeSizeInBytes(QualType T) {
- return getTypeSize(T) / getByteSize();
- }
- uint64_t getTypeSizeInBytes(const Type *T) {
- return getTypeSize(T) / getByteSize();
- }
+ CharUnits getTypeSizeInChars(QualType T);
+ CharUnits getTypeSizeInChars(const Type *T);
/// getTypeAlign - Return the ABI-specified alignment of a type, in bits.
/// This method does not work on incomplete types.
@@ -906,12 +898,29 @@ public:
return getCanonicalType(T1) == getCanonicalType(T2);
}
+ /// \brief Returns this type as a completely-unqualified array type, capturing
+ /// the qualifiers in Quals. This only operates on canonical types in order
+ /// to ensure the ArrayType doesn't itself have qualifiers.
+ ///
+ /// \param T is the canonicalized QualType, which may be an ArrayType
+ ///
+ /// \param Quals will receive the full set of qualifiers that were
+ /// applied to the element type of the array.
+ ///
+ /// \returns if this is an array type, the completely unqualified array type
+ /// that corresponds to it. Otherwise, returns this->getUnqualifiedType().
+ QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals);
+
/// \brief Determine whether the given types are equivalent after
/// cvr-qualifiers have been removed.
bool hasSameUnqualifiedType(QualType T1, QualType T2) {
CanQualType CT1 = getCanonicalType(T1);
CanQualType CT2 = getCanonicalType(T2);
- return CT1.getUnqualifiedType() == CT2.getUnqualifiedType();
+
+ Qualifiers Quals;
+ QualType UnqualT1 = getUnqualifiedArrayType(CT1, Quals);
+ QualType UnqualT2 = getUnqualifiedArrayType(CT2, Quals);
+ return UnqualT1 == UnqualT2;
}
/// \brief Retrieves the "canonical" declaration of
@@ -1251,7 +1260,8 @@ inline void *operator new[](size_t Bytes, clang::ASTContext& C,
/// invoking it directly; see the new[] operator for more details. This operator
/// is called implicitly by the compiler if a placement new[] expression using
/// the ASTContext throws in the object constructor.
-inline void operator delete[](void *Ptr, clang::ASTContext &C) throw () {
+inline void operator delete[](void *Ptr, clang::ASTContext &C, size_t)
+ throw () {
C.Deallocate(Ptr);
}
diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h
index af8d236..93e41d3 100644
--- a/include/clang/AST/CanonicalType.h
+++ b/include/clang/AST/CanonicalType.h
@@ -559,7 +559,7 @@ template<>
struct CanProxyAdaptor<FunctionProtoType>
: public CanProxyBase<FunctionProtoType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getResultType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs);
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs)
CanQualType getArgType(unsigned i) const {
return CanQualType::CreateUnsafe(this->getTypePtr()->getArgType(i));
}
diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h
new file mode 100644
index 0000000..7b2833c
--- /dev/null
+++ b/include/clang/AST/CharUnits.h
@@ -0,0 +1,149 @@
+//===--- CharUnits.h - Character units for sizes and offsets ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the CharUnits class
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_CHARUNITS_H
+#define LLVM_CLANG_AST_CHARUNITS_H
+
+#include "llvm/System/DataTypes.h"
+
+namespace clang {
+
+ /// CharUnits - This is an opaque type for sizes expressed in character units.
+ /// Instances of this type represent a quantity as a multiple of the size
+ /// of the standard C type, char, on the target architecture. As an opaque
+ /// type, CharUnits protects you from accidentally combining operations on
+ /// quantities in bit units and character units.
+ ///
+ /// It should be noted that characters and bytes are distinct concepts. Bytes
+ /// refer to addressable units of data storage on the target machine, and
+ /// characters are members of a set of elements used for the organization,
+ /// control, or representation of data. According to C99, bytes are allowed
+ /// to exceed characters in size, although currently, clang only supports
+ /// architectures where the two are the same size.
+ ///
+ /// For portability, never assume that a target character is 8 bits wide. Use
+ /// CharUnit values whereever you calculate sizes, offsets, or alignments
+ /// in character units.
+ class CharUnits {
+ public:
+ typedef int64_t RawType;
+
+ private:
+ RawType Quantity;
+
+ explicit CharUnits(RawType C) : Quantity(C) {}
+
+ public:
+
+ /// CharUnits - A default constructor.
+ CharUnits() : Quantity(0) {}
+
+ /// Zero - Construct a CharUnits quantity of zero.
+ static CharUnits Zero() {
+ return CharUnits(0);
+ }
+
+ /// One - Construct a CharUnits quantity of one.
+ static CharUnits One() {
+ return CharUnits(1);
+ }
+
+ /// fromRaw - Construct a CharUnits quantity from a raw integer type.
+ static CharUnits fromRaw(RawType Quantity) {
+ return CharUnits(Quantity);
+ }
+
+ // Compound assignment.
+ CharUnits& operator+= (const CharUnits &Other) {
+ Quantity += Other.Quantity;
+ return *this;
+ }
+ CharUnits& operator-= (const CharUnits &Other) {
+ Quantity -= Other.Quantity;
+ return *this;
+ }
+
+ // Comparison operators.
+ bool operator== (const CharUnits &Other) const {
+ return Quantity == Other.Quantity;
+ }
+ bool operator!= (const CharUnits &Other) const {
+ return Quantity != Other.Quantity;
+ }
+
+ // Relational operators.
+ bool operator< (const CharUnits &Other) const {
+ return Quantity < Other.Quantity;
+ }
+ bool operator<= (const CharUnits &Other) const {
+ return Quantity <= Other.Quantity;
+ }
+ bool operator> (const CharUnits &Other) const {
+ return Quantity > Other.Quantity;
+ }
+ bool operator>= (const CharUnits &Other) const {
+ return Quantity >= Other.Quantity;
+ }
+
+ // Other predicates.
+
+ /// isZero - Test whether the quantity equals zero.
+ bool isZero() const { return Quantity == 0; }
+
+ /// isOne - Test whether the quantity equals one.
+ bool isOne() const { return Quantity == 1; }
+
+ /// isPositive - Test whether the quanity is greater than zero.
+ bool isPositive() const { return Quantity > 0; }
+
+ /// isNegative - Test whether the quantity is less than zero.
+ bool isNegative() const { return Quantity < 0; }
+
+ // Arithmetic operators.
+ CharUnits operator* (RawType N) const {
+ return CharUnits(Quantity * N);
+ }
+ CharUnits operator/ (RawType N) const {
+ return CharUnits(Quantity / N);
+ }
+ RawType operator/ (const CharUnits &Other) const {
+ return Quantity / Other.Quantity;
+ }
+ CharUnits operator% (RawType N) const {
+ return CharUnits(Quantity % N);
+ }
+ RawType operator% (const CharUnits &Other) const {
+ return Quantity % Other.Quantity;
+ }
+ CharUnits operator+ (const CharUnits &Other) const {
+ return CharUnits(Quantity + Other.Quantity);
+ }
+ CharUnits operator- (const CharUnits &Other) const {
+ return CharUnits(Quantity - Other.Quantity);
+ }
+
+ // Conversions.
+
+ /// getRaw - Get the raw integer representation of this quantity.
+ RawType getRaw() const { return Quantity; }
+
+
+ }; // class CharUnit
+} // namespace clang
+
+inline clang::CharUnits operator* (clang::CharUnits::RawType Scale,
+ const clang::CharUnits &CU) {
+ return CU * Scale;
+}
+
+#endif // LLVM_CLANG_AST_CHARUNITS_H
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index ff2b302..d0d94aa 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -21,6 +21,7 @@
#include "clang/AST/ExternalASTSource.h"
namespace clang {
+class CXXTemporary;
class Expr;
class FunctionTemplateDecl;
class Stmt;
@@ -84,13 +85,20 @@ public:
class TranslationUnitDecl : public Decl, public DeclContext {
ASTContext &Ctx;
+ /// The (most recently entered) anonymous namespace for this
+ /// translation unit, if one has been created.
+ NamespaceDecl *AnonymousNamespace;
+
explicit TranslationUnitDecl(ASTContext &ctx)
: Decl(TranslationUnit, 0, SourceLocation()),
DeclContext(TranslationUnit),
- Ctx(ctx) {}
+ Ctx(ctx), AnonymousNamespace(0) {}
public:
ASTContext &getASTContext() const { return Ctx; }
+ NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; }
+ void setAnonymousNamespace(NamespaceDecl *D) { AnonymousNamespace = D; }
+
static TranslationUnitDecl *Create(ASTContext &C);
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == TranslationUnit; }
@@ -198,6 +206,20 @@ public:
/// \brief Determine whether this declaration has linkage.
bool hasLinkage() const;
+ /// \brief Determine whether this declaration is a C++ class member.
+ bool isCXXClassMember() const {
+ const DeclContext *DC = getDeclContext();
+
+ // C++0x [class.mem]p1:
+ // The enumerators of an unscoped enumeration defined in
+ // the class are members of the class.
+ // FIXME: support C++0x scoped enumerations.
+ if (isa<EnumDecl>(DC))
+ DC = DC->getParent();
+
+ return DC->isRecord();
+ }
+
/// \brief Describes the different kinds of linkage
/// (C++ [basic.link], C99 6.2.2) that an entity may have.
enum Linkage {
@@ -246,10 +268,15 @@ class NamespaceDecl : public NamedDecl, public DeclContext {
// OrigNamespace of the first namespace decl points to itself.
NamespaceDecl *OrigNamespace, *NextNamespace;
+ // The (most recently entered) anonymous namespace inside this
+ // namespace.
+ NamespaceDecl *AnonymousNamespace;
+
NamespaceDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
: NamedDecl(Namespace, DC, L, Id), DeclContext(Namespace) {
OrigNamespace = this;
NextNamespace = 0;
+ AnonymousNamespace = 0;
}
public:
static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
@@ -277,6 +304,16 @@ public:
}
void setOriginalNamespace(NamespaceDecl *ND) { OrigNamespace = ND; }
+ NamespaceDecl *getAnonymousNamespace() const {
+ return AnonymousNamespace;
+ }
+
+ void setAnonymousNamespace(NamespaceDecl *D) {
+ assert(D->isAnonymousNamespace());
+ assert(D->getParent() == this);
+ AnonymousNamespace = D;
+ }
+
virtual NamespaceDecl *getCanonicalDecl() { return OrigNamespace; }
const NamespaceDecl *getCanonicalDecl() const { return OrigNamespace; }
@@ -769,14 +806,6 @@ class ParmVarDecl : public VarDecl {
/// in, inout, etc.
unsigned objcDeclQualifier : 6;
- /// \brief Retrieves the fake "value" of an unparsed
- static Expr *getUnparsedDefaultArgValue() {
- uintptr_t Value = (uintptr_t)-1;
- // Mask off the low bits
- Value &= ~(uintptr_t)0x07;
- return reinterpret_cast<Expr*> (Value);
- }
-
protected:
ParmVarDecl(Kind DK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
@@ -798,22 +827,21 @@ public:
objcDeclQualifier = QTVal;
}
+ Expr *getDefaultArg();
const Expr *getDefaultArg() const {
- assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
- assert(!hasUninstantiatedDefaultArg() &&
- "Default argument is not yet instantiated!");
- return getInit();
- }
- Expr *getDefaultArg() {
- assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
- assert(!hasUninstantiatedDefaultArg() &&
- "Default argument is not yet instantiated!");
- return getInit();
+ return const_cast<ParmVarDecl *>(this)->getDefaultArg();
}
+
void setDefaultArg(Expr *defarg) {
Init = reinterpret_cast<Stmt *>(defarg);
}
+ unsigned getNumDefaultArgTemporaries() const;
+ CXXTemporary *getDefaultArgTemporary(unsigned i);
+ const CXXTemporary *getDefaultArgTemporary(unsigned i) const {
+ return const_cast<ParmVarDecl *>(this)->getDefaultArgTemporary(i);
+ }
+
/// \brief Retrieve the source range that covers the entire default
/// argument.
SourceRange getDefaultArgRange() const;
@@ -1152,7 +1180,7 @@ public:
/// represents an C++ overloaded operator, e.g., "operator+".
bool isOverloadedOperator() const {
return getOverloadedOperator() != OO_None;
- };
+ }
OverloadedOperatorKind getOverloadedOperator() const;
@@ -1421,7 +1449,7 @@ public:
};
-class TypedefDecl : public TypeDecl {
+class TypedefDecl : public TypeDecl, public Redeclarable<TypedefDecl> {
/// UnderlyingType - This is the type the typedef is set to.
TypeSourceInfo *TInfo;
@@ -1429,7 +1457,7 @@ class TypedefDecl : public TypeDecl {
IdentifierInfo *Id, TypeSourceInfo *TInfo)
: TypeDecl(Typedef, DC, L, Id), TInfo(TInfo) {}
- virtual ~TypedefDecl() {}
+ virtual ~TypedefDecl();
public:
static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
@@ -1440,6 +1468,14 @@ public:
return TInfo;
}
+ /// Retrieves the canonical declaration of this typedef.
+ TypedefDecl *getCanonicalDecl() {
+ return getFirstDeclaration();
+ }
+ const TypedefDecl *getCanonicalDecl() const {
+ return getFirstDeclaration();
+ }
+
QualType getUnderlyingType() const {
return TInfo->getType();
}
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 5507e99..02581c1 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1178,14 +1178,14 @@ public:
/// X(const X&);
/// };
/// @endcode
- bool isCopyConstructor(ASTContext &Context, unsigned &TypeQuals) const;
+ bool isCopyConstructor(unsigned &TypeQuals) const;
/// isCopyConstructor - Whether this constructor is a copy
/// constructor (C++ [class.copy]p2, which can be used to copy the
/// class.
- bool isCopyConstructor(ASTContext &Context) const {
+ bool isCopyConstructor() const {
unsigned TypeQuals = 0;
- return isCopyConstructor(Context, TypeQuals);
+ return isCopyConstructor(TypeQuals);
}
/// isConvertingConstructor - Whether this constructor is a
@@ -1338,11 +1338,16 @@ private:
// Location of the 'friend' specifier.
SourceLocation FriendLoc;
+ // FIXME: Hack to keep track of whether this was a friend function
+ // template specialization.
+ bool WasSpecialization;
+
FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
SourceLocation FriendL)
: Decl(Decl::Friend, DC, L),
Friend(Friend),
- FriendLoc(FriendL) {
+ FriendLoc(FriendL),
+ WasSpecialization(false) {
}
public:
@@ -1369,6 +1374,9 @@ public:
return FriendLoc;
}
+ bool wasSpecialization() const { return WasSpecialization; }
+ void setSpecialization(bool WS) { WasSpecialization = WS; }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == Decl::Friend;
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index fd8c3ef..ba17eb1 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -527,7 +527,7 @@ public:
// Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'interface
SourceLocation getLocEnd() const { return EndLoc; }
- void setLocEnd(SourceLocation LE) { EndLoc = LE; };
+ void setLocEnd(SourceLocation LE) { EndLoc = LE; }
void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; }
SourceLocation getClassLoc() const { return ClassLoc; }
@@ -707,7 +707,7 @@ public:
// Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'protocol
SourceLocation getLocEnd() const { return EndLoc; }
- void setLocEnd(SourceLocation LE) { EndLoc = LE; };
+ void setLocEnd(SourceLocation LE) { EndLoc = LE; }
static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; }
static bool classof(const ObjCProtocolDecl *D) { return true; }
@@ -871,7 +871,7 @@ public:
// Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'interface
SourceLocation getLocEnd() const { return EndLoc; }
- void setLocEnd(SourceLocation LE) { EndLoc = LE; };
+ void setLocEnd(SourceLocation LE) { EndLoc = LE; }
static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; }
static bool classof(const ObjCCategoryDecl *D) { return true; }
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 469598f..0cb22df 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -53,14 +53,6 @@ protected:
/// (C++ [temp.dep.constexpr]).
bool ValueDependent : 1;
- // FIXME: Eventually, this constructor should go away and we should
- // require every subclass to provide type/value-dependence
- // information.
- Expr(StmtClass SC, QualType T)
- : Stmt(SC), TypeDependent(false), ValueDependent(false) {
- setType(T);
- }
-
Expr(StmtClass SC, QualType T, bool TD, bool VD)
: Stmt(SC), TypeDependent(TD), ValueDependent(VD) {
setType(T);
@@ -156,7 +148,8 @@ public:
LV_IncompleteVoidType,
LV_DuplicateVectorComponents,
LV_InvalidExpression,
- LV_MemberFunction
+ LV_MemberFunction,
+ LV_SubObjCPropertySetting
};
isLvalueResult isLvalue(ASTContext &Ctx) const;
@@ -185,7 +178,8 @@ public:
MLV_NotBlockQualified,
MLV_ReadonlyProperty,
MLV_NoSetterProperty,
- MLV_MemberFunction
+ MLV_MemberFunction,
+ MLV_SubObjCPropertySetting
};
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx,
SourceLocation *Loc = 0) const;
@@ -607,7 +601,7 @@ public:
// type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
// or UnsignedLongLongTy
IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l)
- : Expr(IntegerLiteralClass, type), Value(V), Loc(l) {
+ : Expr(IntegerLiteralClass, type, false, false), Value(V), Loc(l) {
assert(type->isIntegerType() && "Illegal type in IntegerLiteral");
}
@@ -641,7 +635,8 @@ class CharacterLiteral : public Expr {
public:
// type should be IntTy
CharacterLiteral(unsigned value, bool iswide, QualType type, SourceLocation l)
- : Expr(CharacterLiteralClass, type), Value(value), Loc(l), IsWide(iswide) {
+ : Expr(CharacterLiteralClass, type, false, false), Value(value), Loc(l),
+ IsWide(iswide) {
}
/// \brief Construct an empty character literal.
@@ -675,7 +670,8 @@ class FloatingLiteral : public Expr {
public:
FloatingLiteral(const llvm::APFloat &V, bool isexact,
QualType Type, SourceLocation L)
- : Expr(FloatingLiteralClass, Type), Value(V), IsExact(isexact), Loc(L) {}
+ : Expr(FloatingLiteralClass, Type, false, false), Value(V),
+ IsExact(isexact), Loc(L) {}
/// \brief Construct an empty floating-point literal.
explicit FloatingLiteral(EmptyShell Empty)
@@ -716,7 +712,7 @@ class ImaginaryLiteral : public Expr {
Stmt *Val;
public:
ImaginaryLiteral(Expr *val, QualType Ty)
- : Expr(ImaginaryLiteralClass, Ty), Val(val) {}
+ : Expr(ImaginaryLiteralClass, Ty, false, false), Val(val) {}
/// \brief Build an empty imaginary literal.
explicit ImaginaryLiteral(EmptyShell Empty)
@@ -760,7 +756,7 @@ class StringLiteral : public Expr {
unsigned NumConcatenated;
SourceLocation TokLocs[1];
- StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty) {}
+ StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty, false, false) {}
protected:
virtual void DoDestroy(ASTContext &C);
@@ -1174,6 +1170,11 @@ public:
Expr *getCallee() { return cast<Expr>(SubExprs[FN]); }
void setCallee(Expr *F) { SubExprs[FN] = F; }
+ Decl *getCalleeDecl();
+ const Decl *getCalleeDecl() const {
+ return const_cast<CallExpr*>(this)->getCalleeDecl();
+ }
+
/// \brief If the callee is a FunctionDecl, return it. Otherwise return 0.
FunctionDecl *getDirectCallee();
const FunctionDecl *getDirectCallee() const {
@@ -1459,10 +1460,11 @@ class CompoundLiteralExpr : public Expr {
Stmt *Init;
bool FileScope;
public:
+ // FIXME: Can compound literals be value-dependent?
CompoundLiteralExpr(SourceLocation lparenloc, QualType ty, Expr *init,
bool fileScope)
- : Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init),
- FileScope(fileScope) {}
+ : Expr(CompoundLiteralExprClass, ty, ty->isDependentType(), false),
+ LParenLoc(lparenloc), Init(init), FileScope(fileScope) {}
/// \brief Construct an empty compound literal.
explicit CompoundLiteralExpr(EmptyShell Empty)
@@ -1896,8 +1898,11 @@ public:
protected:
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
- SourceLocation oploc, bool dead)
- : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
+ SourceLocation opLoc, bool dead)
+ : Expr(CompoundAssignOperatorClass, ResTy,
+ lhs->isTypeDependent() || rhs->isTypeDependent(),
+ lhs->isValueDependent() || rhs->isValueDependent()),
+ Opc(opc), OpLoc(opLoc) {
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
}
@@ -2026,7 +2031,8 @@ class AddrLabelExpr : public Expr {
public:
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
QualType t)
- : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
+ : Expr(AddrLabelExprClass, t, false, false),
+ AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
/// \brief Build an empty address of a label expression.
explicit AddrLabelExpr(EmptyShell Empty)
@@ -2061,9 +2067,11 @@ class StmtExpr : public Expr {
Stmt *SubStmt;
SourceLocation LParenLoc, RParenLoc;
public:
+ // FIXME: Does type-dependence need to be computed differently?
StmtExpr(CompoundStmt *substmt, QualType T,
SourceLocation lp, SourceLocation rp) :
- Expr(StmtExprClass, T), SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
+ Expr(StmtExprClass, T, T->isDependentType(), false),
+ SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
/// \brief Build an empty statement expression.
explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
@@ -2102,8 +2110,8 @@ class TypesCompatibleExpr : public Expr {
public:
TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
QualType t1, QualType t2, SourceLocation RP) :
- Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
- BuiltinLoc(BLoc), RParenLoc(RP) {}
+ Expr(TypesCompatibleExprClass, ReturnType, false, false),
+ Type1(t1), Type2(t2), BuiltinLoc(BLoc), RParenLoc(RP) {}
/// \brief Build an empty __builtin_type_compatible_p expression.
explicit TypesCompatibleExpr(EmptyShell Empty)
@@ -2153,11 +2161,13 @@ protected:
virtual void DoDestroy(ASTContext &C);
public:
+ // FIXME: Can a shufflevector be value-dependent? Does type-dependence need
+ // to be computed differently?
ShuffleVectorExpr(ASTContext &C, Expr **args, unsigned nexpr,
QualType Type, SourceLocation BLoc,
SourceLocation RP) :
- Expr(ShuffleVectorExprClass, Type), BuiltinLoc(BLoc),
- RParenLoc(RP), NumExprs(nexpr) {
+ Expr(ShuffleVectorExprClass, Type, Type->isDependentType(), false),
+ BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(nexpr) {
SubExprs = new (C) Stmt*[nexpr];
for (unsigned i = 0; i < nexpr; i++)
@@ -2285,7 +2295,7 @@ class GNUNullExpr : public Expr {
public:
GNUNullExpr(QualType Ty, SourceLocation Loc)
- : Expr(GNUNullExprClass, Ty), TokenLoc(Loc) { }
+ : Expr(GNUNullExprClass, Ty, false, false), TokenLoc(Loc) { }
/// \brief Build an empty GNU __null expression.
explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }
@@ -2313,7 +2323,7 @@ class VAArgExpr : public Expr {
SourceLocation BuiltinLoc, RParenLoc;
public:
VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
- : Expr(VAArgExprClass, t),
+ : Expr(VAArgExprClass, t, t->isDependentType(), false),
Val(e),
BuiltinLoc(BLoc),
RParenLoc(RPLoc) { }
@@ -2795,7 +2805,7 @@ public:
class ImplicitValueInitExpr : public Expr {
public:
explicit ImplicitValueInitExpr(QualType ty)
- : Expr(ImplicitValueInitExprClass, ty) { }
+ : Expr(ImplicitValueInitExprClass, ty, false, false) { }
/// \brief Construct an empty implicit value initialization.
explicit ImplicitValueInitExpr(EmptyShell Empty)
@@ -2883,7 +2893,8 @@ class ExtVectorElementExpr : public Expr {
public:
ExtVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
SourceLocation loc)
- : Expr(ExtVectorElementExprClass, ty),
+ : Expr(ExtVectorElementExprClass, ty, base->isTypeDependent(),
+ base->isValueDependent()),
Base(base), Accessor(&accessor), AccessorLoc(loc) {}
/// \brief Build an empty vector element expression.
@@ -2938,7 +2949,7 @@ protected:
bool HasBlockDeclRefExprs;
public:
BlockExpr(BlockDecl *BD, QualType ty, bool hasBlockDeclRefExprs)
- : Expr(BlockExprClass, ty),
+ : Expr(BlockExprClass, ty, ty->isDependentType(), false),
TheBlock(BD), HasBlockDeclRefExprs(hasBlockDeclRefExprs) {}
/// \brief Build an empty block expression.
@@ -2983,10 +2994,11 @@ class BlockDeclRefExpr : public Expr {
bool IsByRef : 1;
bool ConstQualAdded : 1;
public:
+ // FIXME: Fix type/value dependence!
BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef,
- bool constAdded = false) :
- Expr(BlockDeclRefExprClass, t), D(d), Loc(l), IsByRef(ByRef),
- ConstQualAdded(constAdded) {}
+ bool constAdded = false)
+ : Expr(BlockDeclRefExprClass, t, false, false), D(d), Loc(l), IsByRef(ByRef),
+ ConstQualAdded(constAdded) {}
// \brief Build an empty reference to a declared variable in a
// block.
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 00ea202..d0e21f5 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -224,7 +224,7 @@ class CXXBoolLiteralExpr : public Expr {
SourceLocation Loc;
public:
CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
- Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
+ Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {}
bool getValue() const { return Value; }
@@ -245,7 +245,7 @@ class CXXNullPtrLiteralExpr : public Expr {
SourceLocation Loc;
public:
CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
- Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {}
+ Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
@@ -386,30 +386,70 @@ public:
/// parameter's default argument, when the call did not explicitly
/// supply arguments for all of the parameters.
class CXXDefaultArgExpr : public Expr {
- ParmVarDecl *Param;
+ /// \brief The parameter whose default is being used.
+ ///
+ /// When the bit is set, the subexpression is stored after the
+ /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
+ /// actual default expression is the subexpression.
+ llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
+ /// \brief The location where the default argument expression was used.
+ SourceLocation Loc;
+
protected:
- CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param)
- : Expr(SC, param->hasUnparsedDefaultArg() ?
- param->getType().getNonReferenceType()
- : param->getDefaultArg()->getType()),
- Param(param) { }
-
+ CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
+ : Expr(SC,
+ param->hasUnparsedDefaultArg()
+ ? param->getType().getNonReferenceType()
+ : param->getDefaultArg()->getType(),
+ false, false),
+ Param(param, false), Loc(Loc) { }
+
+ CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
+ Expr *SubExpr)
+ : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc)
+ {
+ *reinterpret_cast<Expr **>(this + 1) = SubExpr;
+ }
+
+protected:
+ virtual void DoDestroy(ASTContext &C);
+
public:
// Param is the parameter whose default argument is used by this
// expression.
- static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl *Param) {
- return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param);
+ static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
+ ParmVarDecl *Param) {
+ return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
}
+ // Param is the parameter whose default argument is used by this
+ // expression, and SubExpr is the expression that will actually be used.
+ static CXXDefaultArgExpr *Create(ASTContext &C,
+ SourceLocation Loc,
+ ParmVarDecl *Param,
+ Expr *SubExpr);
+
// Retrieve the parameter that the argument was created from.
- const ParmVarDecl *getParam() const { return Param; }
- ParmVarDecl *getParam() { return Param; }
+ const ParmVarDecl *getParam() const { return Param.getPointer(); }
+ ParmVarDecl *getParam() { return Param.getPointer(); }
// Retrieve the actual argument to the function call.
- const Expr *getExpr() const { return Param->getDefaultArg(); }
- Expr *getExpr() { return Param->getDefaultArg(); }
+ const Expr *getExpr() const {
+ if (Param.getInt())
+ return *reinterpret_cast<Expr const * const*> (this + 1);
+ return getParam()->getDefaultArg();
+ }
+ Expr *getExpr() {
+ if (Param.getInt())
+ return *reinterpret_cast<Expr **> (this + 1);
+ return getParam()->getDefaultArg();
+ }
+ /// \brief Retrieve the location where this default argument was actually
+ /// used.
+ SourceLocation getUsedLocation() const { return Loc; }
+
virtual SourceRange getSourceRange() const {
// Default argument expressions have no representation in the
// source, so they have an empty source range.
@@ -452,8 +492,8 @@ class CXXBindTemporaryExpr : public Expr {
Stmt *SubExpr;
CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
- : Expr(CXXBindTemporaryExprClass,
- subexpr->getType()), Temp(temp), SubExpr(subexpr) { }
+ : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
+ Temp(temp), SubExpr(subexpr) { }
~CXXBindTemporaryExpr() { }
protected:
@@ -489,15 +529,18 @@ public:
class CXXConstructExpr : public Expr {
CXXConstructorDecl *Constructor;
- bool Elidable;
-
+ SourceLocation Loc;
+ bool Elidable : 1;
+ bool ZeroInitialization : 1;
Stmt **Args;
unsigned NumArgs;
protected:
CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
+ SourceLocation Loc,
CXXConstructorDecl *d, bool elidable,
- Expr **args, unsigned numargs);
+ Expr **args, unsigned numargs,
+ bool ZeroInitialization = false);
~CXXConstructExpr() { }
virtual void DoDestroy(ASTContext &C);
@@ -508,17 +551,29 @@ public:
CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs);
static CXXConstructExpr *Create(ASTContext &C, QualType T,
+ SourceLocation Loc,
CXXConstructorDecl *D, bool Elidable,
- Expr **Args, unsigned NumArgs);
+ Expr **Args, unsigned NumArgs,
+ bool ZeroInitialization = false);
CXXConstructorDecl* getConstructor() const { return Constructor; }
void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
+ SourceLocation getLocation() const { return Loc; }
+ void setLocation(SourceLocation Loc) { this->Loc = Loc; }
+
/// \brief Whether this construction is elidable.
bool isElidable() const { return Elidable; }
void setElidable(bool E) { Elidable = E; }
+ /// \brief Whether this construction first requires
+ /// zero-initialization before the initializer is called.
+ bool requiresZeroInitialization() const { return ZeroInitialization; }
+ void setRequiresZeroInitialization(bool ZeroInit) {
+ ZeroInitialization = ZeroInit;
+ }
+
typedef ExprIterator arg_iterator;
typedef ConstExprIterator const_arg_iterator;
@@ -546,13 +601,7 @@ public:
Args[Arg] = ArgExpr;
}
- virtual SourceRange getSourceRange() const {
- // FIXME: Should we know where the parentheses are, if there are any?
- if (NumArgs == 0)
- return SourceRange();
-
- return SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd());
- }
+ virtual SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConstructExprClass ||
@@ -1264,10 +1313,8 @@ class CXXExprWithTemporaries : public Expr {
CXXTemporary **Temps;
unsigned NumTemps;
- bool ShouldDestroyTemps;
-
CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
- unsigned NumTemps, bool ShouldDestroyTemps);
+ unsigned NumTemps);
~CXXExprWithTemporaries();
protected:
@@ -1275,8 +1322,8 @@ protected:
public:
static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
- CXXTemporary **Temps, unsigned NumTemps,
- bool ShouldDestroyTemporaries);
+ CXXTemporary **Temps,
+ unsigned NumTemps);
unsigned getNumTemporaries() const { return NumTemps; }
CXXTemporary *getTemporary(unsigned i) {
@@ -1284,14 +1331,9 @@ public:
return Temps[i];
}
const CXXTemporary *getTemporary(unsigned i) const {
- assert(i < NumTemps && "Index out of range");
- return Temps[i];
+ return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
}
- bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; }
-
- void removeLastTemporary() { NumTemps--; }
-
Expr *getSubExpr() { return cast<Expr>(SubExpr); }
const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; }
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 0613f4c..0b0cd64 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -30,7 +30,7 @@ class ObjCStringLiteral : public Expr {
SourceLocation AtLoc;
public:
ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
- : Expr(ObjCStringLiteralClass, T), String(SL), AtLoc(L) {}
+ : Expr(ObjCStringLiteralClass, T, false, false), String(SL), AtLoc(L) {}
explicit ObjCStringLiteral(EmptyShell Empty)
: Expr(ObjCStringLiteralClass, Empty) {}
@@ -100,7 +100,8 @@ class ObjCSelectorExpr : public Expr {
public:
ObjCSelectorExpr(QualType T, Selector selInfo,
SourceLocation at, SourceLocation rp)
- : Expr(ObjCSelectorExprClass, T), SelName(selInfo), AtLoc(at), RParenLoc(rp){}
+ : Expr(ObjCSelectorExprClass, T, false, false), SelName(selInfo), AtLoc(at),
+ RParenLoc(rp){}
explicit ObjCSelectorExpr(EmptyShell Empty)
: Expr(ObjCSelectorExprClass, Empty) {}
@@ -139,7 +140,7 @@ class ObjCProtocolExpr : public Expr {
public:
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol,
SourceLocation at, SourceLocation rp)
- : Expr(ObjCProtocolExprClass, T), TheProtocol(protocol),
+ : Expr(ObjCProtocolExprClass, T, false, false), TheProtocol(protocol),
AtLoc(at), RParenLoc(rp) {}
explicit ObjCProtocolExpr(EmptyShell Empty)
: Expr(ObjCProtocolExprClass, Empty) {}
@@ -178,7 +179,7 @@ public:
ObjCIvarRefExpr(ObjCIvarDecl *d,
QualType t, SourceLocation l, Expr *base=0,
bool arrow = false, bool freeIvar = false) :
- Expr(ObjCIvarRefExprClass, t), D(d),
+ Expr(ObjCIvarRefExprClass, t, false, false), D(d),
Loc(l), Base(base), IsArrow(arrow),
IsFreeIvar(freeIvar) {}
@@ -227,7 +228,8 @@ private:
public:
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
SourceLocation l, Expr *base)
- : Expr(ObjCPropertyRefExprClass, t), AsProperty(PD), IdLoc(l), Base(base) {
+ : Expr(ObjCPropertyRefExprClass, t, false, false), AsProperty(PD),
+ IdLoc(l), Base(base) {
}
explicit ObjCPropertyRefExpr(EmptyShell Empty)
@@ -291,16 +293,17 @@ public:
QualType t,
ObjCMethodDecl *setter,
SourceLocation l, Expr *base)
- : Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter),
- Getter(getter), MemberLoc(l), Base(base), InterfaceDecl(0),
- ClassLoc(SourceLocation()) {
+ : Expr(ObjCImplicitSetterGetterRefExprClass, t, false, false),
+ Setter(setter), Getter(getter), MemberLoc(l), Base(base),
+ InterfaceDecl(0), ClassLoc(SourceLocation()) {
}
ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter,
QualType t,
ObjCMethodDecl *setter,
SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL)
- : Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter),
- Getter(getter), MemberLoc(l), Base(0), InterfaceDecl(C), ClassLoc(CL) {
+ : Expr(ObjCImplicitSetterGetterRefExprClass, t, false, false),
+ Setter(setter), Getter(getter), MemberLoc(l), Base(0), InterfaceDecl(C),
+ ClassLoc(CL) {
}
explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty)
: Expr(ObjCImplicitSetterGetterRefExprClass, Empty){}
@@ -488,7 +491,7 @@ class ObjCSuperExpr : public Expr {
SourceLocation Loc;
public:
ObjCSuperExpr(SourceLocation L, QualType Type)
- : Expr(ObjCSuperExprClass, Type), Loc(L) { }
+ : Expr(ObjCSuperExprClass, Type, false, false), Loc(L) { }
explicit ObjCSuperExpr(EmptyShell Empty) : Expr(ObjCSuperExprClass, Empty) {}
SourceLocation getLoc() const { return Loc; }
@@ -519,7 +522,7 @@ class ObjCIsaExpr : public Expr {
bool IsArrow;
public:
ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty)
- : Expr(ObjCIsaExprClass, ty),
+ : Expr(ObjCIsaExprClass, ty, false, false),
Base(base), IsaMemberLoc(l), IsArrow(isarrow) {}
/// \brief Build an empty expression.
diff --git a/include/clang/AST/FullExpr.h b/include/clang/AST/FullExpr.h
new file mode 100644
index 0000000..bb81bf0
--- /dev/null
+++ b/include/clang/AST/FullExpr.h
@@ -0,0 +1,89 @@
+//===--- FullExpr.h - C++ full expression class -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the FullExpr interface, to be used for type safe handling
+// of full expressions.
+//
+// Full expressions are described in C++ [intro.execution]p12.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_AST_FULLEXPR_H
+#define LLVM_CLANG_AST_FULLEXPR_H
+
+#include "llvm/ADT/PointerUnion.h"
+
+namespace clang {
+ class ASTContext;
+ class CXXTemporary;
+ class Expr;
+
+class FullExpr {
+ struct ExprAndTemporaries {
+ Expr *SubExpr;
+
+ unsigned NumTemps;
+
+ typedef CXXTemporary** temps_iterator;
+
+ temps_iterator temps_begin() {
+ return reinterpret_cast<CXXTemporary **>(this + 1);
+ }
+ temps_iterator temps_end() {
+ return temps_begin() + NumTemps;
+ }
+ };
+
+ typedef llvm::PointerUnion<Expr *, ExprAndTemporaries *> SubExprTy;
+ SubExprTy SubExpr;
+
+ FullExpr() { }
+
+public:
+ static FullExpr Create(ASTContext &Context, Expr *SubExpr,
+ CXXTemporary **Temps, unsigned NumTemps);
+ void Destroy(ASTContext &Context);
+
+ Expr *getExpr() {
+ if (Expr *E = SubExpr.dyn_cast<Expr *>())
+ return E;
+
+ return SubExpr.get<ExprAndTemporaries *>()->SubExpr;
+ }
+
+ const Expr *getExpr() const {
+ return const_cast<FullExpr*>(this)->getExpr();
+ }
+
+ typedef CXXTemporary** temps_iterator;
+
+ temps_iterator temps_begin() {
+ if (ExprAndTemporaries *ET = SubExpr.dyn_cast<ExprAndTemporaries *>())
+ return ET->temps_begin();
+
+ return 0;
+ }
+ temps_iterator temps_end() {
+ if (ExprAndTemporaries *ET = SubExpr.dyn_cast<ExprAndTemporaries *>())
+ return ET->temps_end();
+
+ return 0;
+ }
+
+ void *getAsOpaquePtr() const { return SubExpr.getOpaqueValue(); }
+
+ static FullExpr getFromOpaquePtr(void *Ptr) {
+ FullExpr E;
+ E.SubExpr = SubExprTy::getFromOpaqueValue(Ptr);
+ return E;
+ }
+};
+
+} // end namespace clang
+
+#endif
diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h
index a8334b6..e8d1788 100644
--- a/include/clang/AST/RecordLayout.h
+++ b/include/clang/AST/RecordLayout.h
@@ -53,7 +53,7 @@ public:
PrimaryBaseInfo() {}
PrimaryBaseInfo(const CXXRecordDecl *Base, bool IsVirtual)
- : Value(Base, IsVirtual) {}
+ : Value(Base, Base && IsVirtual) {}
/// Value - Points to the primary base. The single-bit value
/// will be non-zero when the primary base is virtual.
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index d6f6a83..33edadc 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -20,6 +20,7 @@
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/StmtIterator.h"
#include "clang/AST/DeclGroup.h"
+#include "clang/AST/FullExpr.h"
#include "llvm/ADT/SmallVector.h"
#include "clang/AST/ASTContext.h"
#include <string>
@@ -293,6 +294,9 @@ class DeclStmt : public Stmt {
DeclGroupRef DG;
SourceLocation StartLoc, EndLoc;
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
+
public:
DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
@@ -620,9 +624,9 @@ class IfStmt : public Stmt {
SourceLocation ElseLoc;
public:
- IfStmt(SourceLocation IL, VarDecl *Var, Expr *cond, Stmt *then,
+ IfStmt(SourceLocation IL, VarDecl *var, Expr *cond, Stmt *then,
SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
- : Stmt(IfStmtClass), Var(Var), IfLoc(IL), ElseLoc(EL) {
+ : Stmt(IfStmtClass), Var(var), IfLoc(IL), ElseLoc(EL) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[THEN] = then;
SubExprs[ELSE] = elsev;
@@ -670,9 +674,13 @@ public:
}
static bool classof(const IfStmt *) { return true; }
- // Iterators
+ // Iterators over subexpressions. The iterators will include iterating
+ // over the initialization expression referenced by the condition variable.
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
};
/// SwitchStmt - This represents a 'switch' stmt.
@@ -805,6 +813,9 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
};
/// DoStmt - This represents a 'do/while' stmt.
@@ -868,9 +879,9 @@ class ForStmt : public Stmt {
SourceLocation LParenLoc, RParenLoc;
public:
- ForStmt(Stmt *Init, Expr *Cond, VarDecl *CondVar, Expr *Inc, Stmt *Body,
+ ForStmt(Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body,
SourceLocation FL, SourceLocation LP, SourceLocation RP)
- : Stmt(ForStmtClass), CondVar(CondVar), ForLoc(FL), LParenLoc(LP),
+ : Stmt(ForStmtClass), CondVar(condVar), ForLoc(FL), LParenLoc(LP),
RParenLoc(RP)
{
SubExprs[INIT] = Init;
@@ -927,6 +938,9 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
};
/// GotoStmt - This represents a direct goto.
diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h
index f1aa2cd5..a48f4e6 100644
--- a/include/clang/AST/StmtIterator.h
+++ b/include/clang/AST/StmtIterator.h
@@ -28,11 +28,12 @@ class StmtIteratorBase {
protected:
enum { DeclMode = 0x1, SizeOfTypeVAMode = 0x2, DeclGroupMode = 0x3,
Flags = 0x3 };
-
- union { Stmt** stmt; Decl* decl; Decl** DGI; };
+
+ Stmt **stmt;
+ union { Decl *decl; Decl **DGI; };
uintptr_t RawVAPtr;
- Decl** DGE;
-
+ Decl **DGE;
+
bool inDecl() const {
return (RawVAPtr & Flags) == DeclMode;
}
@@ -64,11 +65,11 @@ protected:
Stmt*& GetDeclExpr() const;
- StmtIteratorBase(Stmt** s) : stmt(s), RawVAPtr(0) {}
- StmtIteratorBase(Decl* d);
- StmtIteratorBase(VariableArrayType* t);
- StmtIteratorBase(Decl** dgi, Decl** dge);
- StmtIteratorBase() : stmt(NULL), RawVAPtr(0) {}
+ StmtIteratorBase(Stmt **s) : stmt(s), decl(0), RawVAPtr(0) {}
+ StmtIteratorBase(Decl *d, Stmt **s);
+ StmtIteratorBase(VariableArrayType *t);
+ StmtIteratorBase(Decl **dgi, Decl **dge);
+ StmtIteratorBase() : stmt(0), decl(0), RawVAPtr(0) {}
};
@@ -81,9 +82,9 @@ protected:
StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {}
public:
StmtIteratorImpl() {}
- StmtIteratorImpl(Stmt** s) : StmtIteratorBase(s) {}
- StmtIteratorImpl(Decl** dgi, Decl** dge) : StmtIteratorBase(dgi, dge) {}
- StmtIteratorImpl(Decl* d) : StmtIteratorBase(d) {}
+ StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {}
+ StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {}
+ StmtIteratorImpl(Decl *d, Stmt **s) : StmtIteratorBase(d, s) {}
StmtIteratorImpl(VariableArrayType* t) : StmtIteratorBase(t) {}
DERIVED& operator++() {
@@ -106,11 +107,11 @@ public:
}
bool operator==(const DERIVED& RHS) const {
- return stmt == RHS.stmt && RawVAPtr == RHS.RawVAPtr;
+ return stmt == RHS.stmt && decl == RHS.decl && RawVAPtr == RHS.RawVAPtr;
}
bool operator!=(const DERIVED& RHS) const {
- return stmt != RHS.stmt || RawVAPtr != RHS.RawVAPtr;
+ return stmt != RHS.stmt || decl != RHS.decl || RawVAPtr != RHS.RawVAPtr;
}
REFERENCE operator*() const {
@@ -124,11 +125,15 @@ struct StmtIterator : public StmtIteratorImpl<StmtIterator,Stmt*&> {
explicit StmtIterator() : StmtIteratorImpl<StmtIterator,Stmt*&>() {}
StmtIterator(Stmt** S) : StmtIteratorImpl<StmtIterator,Stmt*&>(S) {}
+
StmtIterator(Decl** dgi, Decl** dge)
: StmtIteratorImpl<StmtIterator,Stmt*&>(dgi, dge) {}
- StmtIterator(VariableArrayType* t):StmtIteratorImpl<StmtIterator,Stmt*&>(t) {}
- StmtIterator(Decl* D) : StmtIteratorImpl<StmtIterator,Stmt*&>(D) {}
+ StmtIterator(VariableArrayType* t)
+ : StmtIteratorImpl<StmtIterator,Stmt*&>(t) {}
+
+ StmtIterator(Decl* D, Stmt **s = 0)
+ : StmtIteratorImpl<StmtIterator,Stmt*&>(D, s) {}
};
struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h
index fe03799..50a100c 100644
--- a/include/clang/AST/TemplateBase.h
+++ b/include/clang/AST/TemplateBase.h
@@ -221,7 +221,7 @@ public:
assert(Kind == Integral &&
"Cannot set the integral type of a non-integral template argument");
Integer.Type = T.getAsOpaquePtr();
- };
+ }
/// \brief Retrieve the template argument as an expression.
Expr *getAsExpr() const {
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index d22a646..9b0cdc3 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -531,7 +531,12 @@ public:
/// \brief Retrieve the set of CVR (const-volatile-restrict) qualifiers
/// applied to this type.
unsigned getCVRQualifiers() const;
-
+
+ /// \brief Retrieve the set of CVR (const-volatile-restrict) qualifiers
+ /// applied to this type, looking through any number of unqualified array
+ /// types to their element types' qualifiers.
+ unsigned getCVRQualifiersThroughArrayTypes() const;
+
bool isConstant(ASTContext& Ctx) const {
return QualType::isConstant(*this, Ctx);
}
@@ -1049,28 +1054,6 @@ public:
static bool classof(const BuiltinType *) { return true; }
};
-/// FixedWidthIntType - Used for arbitrary width types that we either don't
-/// want to or can't map to named integer types. These always have a lower
-/// integer rank than builtin types of the same width.
-class FixedWidthIntType : public Type {
-private:
- unsigned Width;
- bool Signed;
-public:
- FixedWidthIntType(unsigned W, bool S) : Type(FixedWidthInt, QualType(), false),
- Width(W), Signed(S) {}
-
- unsigned getWidth() const { return Width; }
- bool isSigned() const { return Signed; }
- const char *getName() const;
-
- bool isSugared() const { return false; }
- QualType desugar() const { return QualType(this, 0); }
-
- static bool classof(const Type *T) { return T->getTypeClass() == FixedWidthInt; }
- static bool classof(const FixedWidthIntType *) { return true; }
-};
-
/// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex
/// types (_Complex float etc) as well as the GCC integer complex extensions.
///
@@ -2708,7 +2691,20 @@ inline unsigned QualType::getCVRQualifiers() const {
return getLocalCVRQualifiers() |
getTypePtr()->getCanonicalTypeInternal().getLocalCVRQualifiers();
}
-
+
+/// getCVRQualifiersThroughArrayTypes - If there are CVR qualifiers for this
+/// type, returns them. Otherwise, if this is an array type, recurses
+/// on the element type until some qualifiers have been found or a non-array
+/// type reached.
+inline unsigned QualType::getCVRQualifiersThroughArrayTypes() const {
+ if (unsigned Quals = getCVRQualifiers())
+ return Quals;
+ QualType CT = getTypePtr()->getCanonicalTypeInternal();
+ if (const ArrayType *AT = dyn_cast<ArrayType>(CT))
+ return AT->getElementType().getCVRQualifiersThroughArrayTypes();
+ return 0;
+}
+
inline void QualType::removeConst() {
removeFastQualifiers(Qualifiers::Const);
}
@@ -2808,8 +2804,8 @@ inline bool QualType::getNoReturnAttr() const {
/// int".
inline bool QualType::isMoreQualifiedThan(QualType Other) const {
// FIXME: work on arbitrary qualifiers
- unsigned MyQuals = this->getCVRQualifiers();
- unsigned OtherQuals = Other.getCVRQualifiers();
+ unsigned MyQuals = this->getCVRQualifiersThroughArrayTypes();
+ unsigned OtherQuals = Other.getCVRQualifiersThroughArrayTypes();
if (getAddressSpace() != Other.getAddressSpace())
return false;
return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals;
@@ -2821,8 +2817,8 @@ inline bool QualType::isMoreQualifiedThan(QualType Other) const {
/// "int", and "const volatile int".
inline bool QualType::isAtLeastAsQualifiedAs(QualType Other) const {
// FIXME: work on arbitrary qualifiers
- unsigned MyQuals = this->getCVRQualifiers();
- unsigned OtherQuals = Other.getCVRQualifiers();
+ unsigned MyQuals = this->getCVRQualifiersThroughArrayTypes();
+ unsigned OtherQuals = Other.getCVRQualifiersThroughArrayTypes();
if (getAddressSpace() != Other.getAddressSpace())
return false;
return (MyQuals | OtherQuals) == MyQuals;
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index a9b7f7e..3e74d07 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -1023,13 +1023,6 @@ class DependentSizedExtVectorTypeLoc :
DependentSizedExtVectorType> {
};
-// FIXME: I'm not sure how you actually specify these; with attributes?
-class FixedWidthIntTypeLoc :
- public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
- FixedWidthIntTypeLoc,
- FixedWidthIntType> {
-};
-
// FIXME: location of the '_Complex' keyword.
class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
ComplexTypeLoc,
diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def
index b9d3799..575011a 100644
--- a/include/clang/AST/TypeNodes.def
+++ b/include/clang/AST/TypeNodes.def
@@ -52,7 +52,6 @@
#endif
TYPE(Builtin, Type)
-TYPE(FixedWidthInt, Type)
TYPE(Complex, Type)
TYPE(Pointer, Type)
TYPE(BlockPointer, Type)
@@ -92,7 +91,6 @@ TYPE(ObjCObjectPointer, Type)
#ifdef LEAF_TYPE
LEAF_TYPE(Enum)
LEAF_TYPE(Builtin)
-LEAF_TYPE(FixedWidthInt)
LEAF_TYPE(ObjCInterface)
LEAF_TYPE(TemplateTypeParm)
#undef LEAF_TYPE
OpenPOWER on IntegriCloud