diff options
Diffstat (limited to 'include/clang/AST')
| -rw-r--r-- | include/clang/AST/APValue.h | 31 | ||||
| -rw-r--r-- | include/clang/AST/ASTContext.h | 22 | ||||
| -rw-r--r-- | include/clang/AST/Attr.h | 88 | ||||
| -rw-r--r-- | include/clang/AST/CharUnits.h | 28 | ||||
| -rw-r--r-- | include/clang/AST/Decl.h | 2 | ||||
| -rw-r--r-- | include/clang/AST/DeclCXX.h | 3 | ||||
| -rw-r--r-- | include/clang/AST/DeclObjC.h | 14 | ||||
| -rw-r--r-- | include/clang/AST/DeclarationName.h | 9 | ||||
| -rw-r--r-- | include/clang/AST/Expr.h | 14 | ||||
| -rw-r--r-- | include/clang/AST/ExprCXX.h | 10 | ||||
| -rw-r--r-- | include/clang/AST/Stmt.h | 7 | ||||
| -rw-r--r-- | include/clang/AST/TypeLoc.h | 90 |
12 files changed, 208 insertions, 110 deletions
diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h index 94d258d9e4e6d..9d4bff893f02f 100644 --- a/include/clang/AST/APValue.h +++ b/include/clang/AST/APValue.h @@ -18,6 +18,7 @@ #include "llvm/ADT/APFloat.h" namespace clang { + class CharUnits; class Expr; /// APValue - This class implements a discriminated union of [uninitialized] @@ -47,10 +48,6 @@ private: ComplexAPFloat() : Real(0.0), Imag(0.0) {} }; - struct LV { - Expr* Base; - uint64_t Offset; - }; struct Vec { APValue *Elts; unsigned NumElts; @@ -88,9 +85,11 @@ public: APValue(const APValue &RHS) : Kind(Uninitialized) { *this = RHS; } - APValue(Expr* B, uint64_t O) : Kind(Uninitialized) { + APValue(Expr* B, const CharUnits &O) : Kind(Uninitialized) { MakeLValue(); setLValue(B, O); } + APValue(Expr* B); + ~APValue() { MakeUninit(); } @@ -164,14 +163,8 @@ public: return const_cast<APValue*>(this)->getComplexFloatImag(); } - Expr* getLValueBase() const { - assert(isLValue() && "Invalid accessor"); - return ((const LV*)(const void*)Data)->Base; - } - uint64_t getLValueOffset() const { - assert(isLValue() && "Invalid accessor"); - return ((const LV*)(const void*)Data)->Offset; - } + Expr* getLValueBase() const; + CharUnits getLValueOffset() const; void setInt(const APSInt &I) { assert(isInt() && "Invalid accessor"); @@ -202,11 +195,7 @@ public: ((ComplexAPFloat*)(char*)Data)->Real = R; ((ComplexAPFloat*)(char*)Data)->Imag = I; } - void setLValue(Expr *B, uint64_t O) { - assert(isLValue() && "Invalid accessor"); - ((LV*)(char*)Data)->Base = B; - ((LV*)(char*)Data)->Offset = O; - } + void setLValue(Expr *B, const CharUnits &O); const APValue &operator=(const APValue &RHS); @@ -237,11 +226,7 @@ private: new ((void*)(char*)Data) ComplexAPFloat(); Kind = ComplexFloat; } - void MakeLValue() { - assert(isUninit() && "Bad state change"); - new ((void*)(char*)Data) LV(); - Kind = LValue; - } + void MakeLValue(); }; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const APValue &V) { diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index bcab46d0f5ed4..5db8e20e7e482 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -699,8 +699,8 @@ public: ObjCProtocolDecl *rProto); /// getObjCEncodingTypeSize returns size of type for objective-c encoding - /// purpose. - int getObjCEncodingTypeSize(QualType t); + /// purpose in characters. + CharUnits getObjCEncodingTypeSize(QualType t); /// This setter/getter represents the ObjC 'id' type. It is setup lazily, by /// Sema. id is always a (typedef for a) pointer type, a pointer to a struct. @@ -898,17 +898,18 @@ 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. + /// \brief Returns this type as a completely-unqualified array type, + /// capturing the qualifiers in Quals. This will remove the minimal amount of + /// sugaring from the types, similar to the behavior of + /// QualType::getUnqualifiedType(). /// - /// \param T is the canonicalized QualType, which may be an ArrayType + /// \param T is the qualified type, which may be an ArrayType /// /// \param Quals will receive the full set of qualifiers that were - /// applied to the element type of the array. + /// applied to the array. /// /// \returns if this is an array type, the completely unqualified array type - /// that corresponds to it. Otherwise, returns this->getUnqualifiedType(). + /// that corresponds to it. Otherwise, returns T.getUnqualifiedType(). QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals); /// \brief Determine whether the given types are equivalent after @@ -996,7 +997,10 @@ public: const IncompleteArrayType *getAsIncompleteArrayType(QualType T) { return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T)); } - + const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T) { + return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T)); + } + /// getBaseElementType - Returns the innermost element type of an array type. /// For example, will return "int" for int[m][n] QualType getBaseElementType(const ArrayType *VAT); diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 2c7ab9d67e953..03ab0f07020b3 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -55,8 +55,6 @@ public: Cleanup, Const, Constructor, - DLLExport, - DLLImport, Deprecated, Destructor, FastCall, @@ -93,7 +91,12 @@ public: Visibility, WarnUnusedResult, Weak, - WeakImport + WeakImport, + + FIRST_TARGET_ATTRIBUTE, + DLLExport, + DLLImport, + MSP430Interrupt }; private: @@ -158,7 +161,7 @@ public: class ATTR##Attr : public Attr { \ public: \ ATTR##Attr() : Attr(ATTR) {} \ - virtual Attr *clone(ASTContext &C) const { return ::new (C) ATTR##Attr; }\ + virtual Attr *clone(ASTContext &C) const; \ static bool classof(const Attr *A) { return A->getKind() == ATTR; } \ static bool classof(const ATTR##Attr *A) { return true; } \ } @@ -174,9 +177,7 @@ public: /// getAlignment - The specified alignment in bits. unsigned getAlignment() const { return Alignment; } - virtual Attr* clone(ASTContext &C) const { - return ::new (C) PragmaPackAttr(Alignment); - } + virtual Attr* clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -203,9 +204,7 @@ public: return Alignment; } - virtual Attr* clone(ASTContext &C) const { - return ::new (C) AlignedAttr(Alignment); - } + virtual Attr* clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -221,7 +220,7 @@ public: const std::string& getAnnotation() const { return Annotation; } - virtual Attr* clone(ASTContext &C) const { return ::new (C) AnnotateAttr(Annotation); } + virtual Attr* clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -237,7 +236,7 @@ public: const std::string& getLabel() const { return Label; } - virtual Attr* clone(ASTContext &C) const { return ::new (C) AsmLabelAttr(Label); } + virtual Attr* clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -255,7 +254,7 @@ public: const std::string& getAliasee() const { return Aliasee; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) AliasAttr(Aliasee); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Alias; } @@ -269,7 +268,7 @@ public: int getPriority() const { return priority; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) ConstructorAttr(priority); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Constructor; } @@ -283,7 +282,7 @@ public: int getPriority() const { return priority; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) DestructorAttr(priority); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Destructor; } @@ -294,7 +293,7 @@ class GNUInlineAttr : public Attr { public: GNUInlineAttr() : Attr(GNUInline) {} - virtual Attr *clone(ASTContext &C) const { return ::new (C) GNUInlineAttr; } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -307,7 +306,7 @@ class IBOutletAttr : public Attr { public: IBOutletAttr() : Attr(IBOutletKind) {} - virtual Attr *clone(ASTContext &C) const { return ::new (C) IBOutletAttr; } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -329,7 +328,7 @@ public: const std::string& getName() const { return Name; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) SectionAttr(Name); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -374,7 +373,7 @@ public: return ArgNums ? std::binary_search(ArgNums, ArgNums+Size, arg) : true; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) NonNullAttr(ArgNums, Size); } + virtual Attr *clone(ASTContext &C) const; static bool classof(const Attr *A) { return A->getKind() == NonNull; } static bool classof(const NonNullAttr *A) { return true; } @@ -392,9 +391,7 @@ public: int getFormatIdx() const { return formatIdx; } int getFirstArg() const { return firstArg; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) FormatAttr(Type, formatIdx, firstArg); - } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Format; } @@ -407,9 +404,7 @@ public: FormatArgAttr(int idx) : Attr(FormatArg), formatIdx(idx) {} int getFormatIdx() const { return formatIdx; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) FormatArgAttr(formatIdx); - } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == FormatArg; } @@ -424,9 +419,7 @@ public: int getSentinel() const { return sentinel; } int getNullPos() const { return NullPos; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) SentinelAttr(sentinel, NullPos); - } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Sentinel; } @@ -449,15 +442,13 @@ public: VisibilityTypes getVisibility() const { return VisibilityType; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) VisibilityAttr(VisibilityType); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Visibility; } static bool classof(const VisibilityAttr *A) { return true; } }; -DEF_SIMPLE_ATTR(DLLImport); -DEF_SIMPLE_ATTR(DLLExport); DEF_SIMPLE_ATTR(FastCall); DEF_SIMPLE_ATTR(StdCall); DEF_SIMPLE_ATTR(CDecl); @@ -471,9 +462,7 @@ public: virtual bool isMerged() const { return false; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) OverloadableAttr; - } + virtual Attr *clone(ASTContext &C) const; static bool classof(const Attr *A) { return A->getKind() == Overloadable; } static bool classof(const OverloadableAttr *) { return true; } @@ -491,7 +480,7 @@ public: BlocksAttrTypes getType() const { return BlocksAttrType; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) BlocksAttr(BlocksAttrType); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Blocks; } @@ -508,7 +497,7 @@ public: const FunctionDecl *getFunctionDecl() const { return FD; } - virtual Attr *clone(ASTContext &C) const { return ::new (C) CleanupAttr(FD); } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Cleanup; } @@ -527,9 +516,7 @@ public: unsigned getNumParams() const { return NumParams; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) RegparmAttr(NumParams); - } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Regparm; } @@ -546,9 +533,7 @@ public: unsigned getYDim() const { return Y; } unsigned getZDim() const { return Z; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) ReqdWorkGroupSizeAttr(X, Y, Z); - } + virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { @@ -566,6 +551,25 @@ DEF_SIMPLE_ATTR(BaseCheck); DEF_SIMPLE_ATTR(Hiding); DEF_SIMPLE_ATTR(Override); +// Target-specific attributes +DEF_SIMPLE_ATTR(DLLImport); +DEF_SIMPLE_ATTR(DLLExport); + +class MSP430InterruptAttr : public Attr { + unsigned Number; + +public: + MSP430InterruptAttr(unsigned n) : Attr(MSP430Interrupt), Number(n) {} + + unsigned getNumber() const { return Number; } + + virtual Attr *clone(ASTContext &C) const; + + // Implement isa/cast/dyncast/etc. + static bool classof(const Attr *A) { return A->getKind() == MSP430Interrupt; } + static bool classof(const MSP430InterruptAttr *A) { return true; } +}; + #undef DEF_SIMPLE_ATTR } // end namespace clang diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h index 7b2833c53ffa5..0bb4b769d0f35 100644 --- a/include/clang/AST/CharUnits.h +++ b/include/clang/AST/CharUnits.h @@ -36,12 +36,12 @@ namespace clang { /// in character units. class CharUnits { public: - typedef int64_t RawType; + typedef int64_t QuantityType; private: - RawType Quantity; + QuantityType Quantity; - explicit CharUnits(RawType C) : Quantity(C) {} + explicit CharUnits(QuantityType C) : Quantity(C) {} public: @@ -58,8 +58,8 @@ namespace clang { return CharUnits(1); } - /// fromRaw - Construct a CharUnits quantity from a raw integer type. - static CharUnits fromRaw(RawType Quantity) { + /// fromQuantity - Construct a CharUnits quantity from a raw integer type. + static CharUnits fromQuantity(QuantityType Quantity) { return CharUnits(Quantity); } @@ -103,26 +103,26 @@ namespace clang { /// isOne - Test whether the quantity equals one. bool isOne() const { return Quantity == 1; } - /// isPositive - Test whether the quanity is greater than zero. + /// isPositive - Test whether the quantity 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 { + CharUnits operator* (QuantityType N) const { return CharUnits(Quantity * N); } - CharUnits operator/ (RawType N) const { + CharUnits operator/ (QuantityType N) const { return CharUnits(Quantity / N); } - RawType operator/ (const CharUnits &Other) const { + QuantityType operator/ (const CharUnits &Other) const { return Quantity / Other.Quantity; } - CharUnits operator% (RawType N) const { + CharUnits operator% (QuantityType N) const { return CharUnits(Quantity % N); } - RawType operator% (const CharUnits &Other) const { + QuantityType operator% (const CharUnits &Other) const { return Quantity % Other.Quantity; } CharUnits operator+ (const CharUnits &Other) const { @@ -134,14 +134,14 @@ namespace clang { // Conversions. - /// getRaw - Get the raw integer representation of this quantity. - RawType getRaw() const { return Quantity; } + /// getQuantity - Get the raw integer representation of this quantity. + QuantityType getQuantity() const { return Quantity; } }; // class CharUnit } // namespace clang -inline clang::CharUnits operator* (clang::CharUnits::RawType Scale, +inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU) { return CU * Scale; } diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index d0d94aafb8d04..21b59099138a8 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1184,6 +1184,8 @@ public: OverloadedOperatorKind getOverloadedOperator() const; + const IdentifierInfo *getLiteralIdentifier() const; + /// \brief If this function is an instantiation of a member function /// of a class template specialization, retrieves the function from /// which it was instantiated. diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 02581c1241a4c..336a895de8cfb 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -393,6 +393,9 @@ public: return reverse_base_class_const_iterator(vbases_begin()); } + /// \brief Determine whether this class has any dependent base classes. + bool hasAnyDependentBases() const; + /// Iterator access to method members. The method iterator visits /// all method members of the class, including non-instance methods, /// special methods, etc. diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index ba17eb1c1d605..920d31fc7ce40 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -289,7 +289,9 @@ struct ObjCMethodList { /// ObjCProtocolDecl, and ObjCImplDecl. /// class ObjCContainerDecl : public NamedDecl, public DeclContext { - SourceLocation AtEndLoc; // marks the end of the method container. + // These two locations in the range mark the end of the method container. + // The first points to the '@' token, and the second to the 'end' token. + SourceRange AtEnd; public: ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, @@ -351,11 +353,15 @@ public: IdentifierInfo *PropertyId) const; // Marks the end of the container. - SourceLocation getAtEndLoc() const { return AtEndLoc; } - void setAtEndLoc(SourceLocation L) { AtEndLoc = L; } + SourceRange getAtEndRange() const { + return AtEnd; + } + void setAtEndRange(SourceRange atEnd) { + AtEnd = atEnd; + } virtual SourceRange getSourceRange() const { - return SourceRange(getLocation(), getAtEndLoc()); + return SourceRange(getLocation(), getAtEndRange().getEnd()); } // Implement isa/cast/dyncast/etc. diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index fcb4ae52e7eb4..59d7e439e570a 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -190,6 +190,14 @@ public: /// getNameKind - Determine what kind of name this is. NameKind getNameKind() const; + /// \brief Determines whether the name itself is dependent, e.g., because it + /// involves a C++ type that is itself dependent. + /// + /// Note that this does not capture all of the notions of "dependent name", + /// because an identifier can be a dependent name if it is used as the + /// callee in a call expression with dependent arguments. + bool isDependentName() const; + /// getName - Retrieve the human-readable string for this name. std::string getAsString() const; @@ -301,6 +309,7 @@ inline bool operator>=(DeclarationName LHS, DeclarationName RHS) { class DeclarationNameTable { void *CXXSpecialNamesImpl; // Actually a FoldingSet<CXXSpecialName> * CXXOperatorIdName *CXXOperatorNames; // Operator names + void *CXXLiteralOperatorNames; // Actually a FoldingSet<...> * DeclarationNameTable(const DeclarationNameTable&); // NONCOPYABLE DeclarationNameTable& operator=(const DeclarationNameTable&); // NONCOPYABLE diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 0cb22df92ff75..cfbae9fb2cbf5 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -241,6 +241,11 @@ public: /// stack based objects. bool EvaluateAsAny(EvalResult &Result, ASTContext &Ctx) const; + /// EvaluateAsBooleanCondition - Return true if this is a constant + /// which we we can fold and convert to a boolean condition using + /// any crazy technique that we want to. + bool EvaluateAsBooleanCondition(bool &Result, ASTContext &Ctx) const; + /// isEvaluatable - Call Evaluate to see if this expression can be constant /// folded, but discard the result. bool isEvaluatable(ASTContext &Ctx) const; @@ -2552,7 +2557,7 @@ private: unsigned NumSubExprs : 16; - DesignatedInitExpr(QualType Ty, unsigned NumDesignators, + DesignatedInitExpr(ASTContext &C, QualType Ty, unsigned NumDesignators, const Designator *Designators, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr **IndexExprs, unsigned NumIndexExprs, @@ -2565,6 +2570,8 @@ private: protected: virtual void DoDestroy(ASTContext &C); + void DestroyDesignators(ASTContext &C); + public: /// A field designator, e.g., ".x". struct FieldDesignator { @@ -2732,7 +2739,8 @@ public: Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; } - void setDesignators(const Designator *Desigs, unsigned NumDesigs); + void setDesignators(ASTContext &C, const Designator *Desigs, + unsigned NumDesigs); Expr *getArrayIndex(const Designator& D); Expr *getArrayRangeStart(const Designator& D); @@ -2779,7 +2787,7 @@ public: /// \brief Replaces the designator at index @p Idx with the series /// of designators in [First, Last). - void ExpandDesignator(unsigned Idx, const Designator *First, + void ExpandDesignator(ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last); virtual SourceRange getSourceRange() const; diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index d0e21f576d75e..55d5108e6174a 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -324,17 +324,21 @@ public: /// @endcode class CXXThisExpr : public Expr { SourceLocation Loc; - + bool Implicit : 1; + public: - CXXThisExpr(SourceLocation L, QualType Type) + CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) : Expr(CXXThisExprClass, Type, // 'this' is type-dependent if the class type of the enclosing // member function is dependent (C++ [temp.dep.expr]p2) Type->isDependentType(), Type->isDependentType()), - Loc(L) { } + Loc(L), Implicit(isImplicit) { } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } + bool isImplicit() const { return Implicit; } + void setImplicit(bool I) { Implicit = I; } + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXThisExprClass; } diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 33edadc3a5e64..d058f838a0084 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1116,6 +1116,7 @@ class AsmStmt : public Stmt { bool IsSimple; bool IsVolatile; + bool MSAsm; unsigned NumOutputs; unsigned NumInputs; @@ -1126,7 +1127,7 @@ class AsmStmt : public Stmt { llvm::SmallVector<StringLiteral*, 4> Clobbers; public: - AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, + AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, bool msasm, unsigned numoutputs, unsigned numinputs, std::string *names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, @@ -1143,7 +1144,9 @@ public: bool isVolatile() const { return IsVolatile; } void setVolatile(bool V) { IsVolatile = V; } bool isSimple() const { return IsSimple; } - void setSimple(bool V) { IsSimple = false; } + void setSimple(bool V) { IsSimple = V; } + bool isMSAsm() const { return MSAsm; } + void setMSAsm(bool V) { MSAsm = V; } //===--- Asm String Analysis ---===// diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 3e74d07ff7f34..c36c0ffde32ed 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1029,18 +1029,88 @@ class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, ComplexType> { }; -// FIXME: location of the 'typeof' and parens (the expression is -// carried by the type). -class TypeOfExprTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, - TypeOfExprTypeLoc, - TypeOfExprType> { +struct TypeofLocInfo { + SourceLocation TypeofLoc; + SourceLocation LParenLoc; + SourceLocation RParenLoc; }; -// FIXME: location of the 'typeof' and parens; also the TypeSourceInfo -// for the inner type, or (maybe) just express that inline to the TypeLoc. -class TypeOfTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, - TypeOfTypeLoc, - TypeOfType> { +struct TypeOfExprTypeLocInfo : public TypeofLocInfo { +}; + +struct TypeOfTypeLocInfo : public TypeofLocInfo { + TypeSourceInfo* UnderlyingTInfo; +}; + +template <class Derived, class TypeClass, class LocalData = TypeofLocInfo> +class TypeofLikeTypeLoc + : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { +public: + SourceLocation getTypeofLoc() const { + return this->getLocalData()->TypeofLoc; + } + void setTypeofLoc(SourceLocation Loc) { + this->getLocalData()->TypeofLoc = Loc; + } + + SourceLocation getLParenLoc() const { + return this->getLocalData()->LParenLoc; + } + void setLParenLoc(SourceLocation Loc) { + this->getLocalData()->LParenLoc = Loc; + } + + SourceLocation getRParenLoc() const { + return this->getLocalData()->RParenLoc; + } + void setRParenLoc(SourceLocation Loc) { + this->getLocalData()->RParenLoc = Loc; + } + + SourceRange getParensRange() const { + return SourceRange(getLParenLoc(), getRParenLoc()); + } + void setParensRange(SourceRange range) { + setLParenLoc(range.getBegin()); + setRParenLoc(range.getEnd()); + } + + SourceRange getSourceRange() const { + return SourceRange(getTypeofLoc(), getRParenLoc()); + } + + void initializeLocal(SourceLocation Loc) { + setTypeofLoc(Loc); + setLParenLoc(Loc); + setRParenLoc(Loc); + } +}; + +class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, + TypeOfExprType, + TypeOfExprTypeLocInfo> { +public: + Expr* getUnderlyingExpr() const { + return getTypePtr()->getUnderlyingExpr(); + } + // Reimplemented to account for GNU/C++ extension + // typeof unary-expression + // where there are no parentheses. + SourceRange getSourceRange() const; +}; + +class TypeOfTypeLoc + : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { +public: + QualType getUnderlyingType() const { + return this->getTypePtr()->getUnderlyingType(); + } + TypeSourceInfo* getUnderlyingTInfo() const { + return this->getLocalData()->UnderlyingTInfo; + } + void setUnderlyingTInfo(TypeSourceInfo* TI) const { + this->getLocalData()->UnderlyingTInfo = TI; + } }; // FIXME: location of the 'decltype' and parens. |
