TypeLoc.h revision a8bef693d8761e31845a26e136f8d3a0983d2f46
1b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===--- TypeLoc.h - Type Source Info Wrapper -------------------*- C++ -*-===// 2b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// 3b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// The LLVM Compiler Infrastructure 4b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// 5b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// This file is distributed under the University of Illinois Open Source 6b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// License. See LICENSE.TXT for details. 7b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// 8b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 9b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// 10b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// This file defines the TypeLoc interface and subclasses. 11b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// 12b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 13b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 14b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#ifndef LLVM_CLANG_AST_TYPELOC_H 15b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#define LLVM_CLANG_AST_TYPELOC_H 16b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 17b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#include "clang/AST/Type.h" 183c385c28cf1f27b193a620d2e51f814873362cebJohn McCall#include "clang/AST/Decl.h" 19833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h" 20ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor#include "clang/Basic/Specifiers.h" 21b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 22b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang { 23b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis class ParmVarDecl; 24a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall class TypeSourceInfo; 2534a0447b8072e0da14c0980597da9d03a1495662John McCall class UnqualTypeLoc; 26b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 2751bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes. 2851bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base) 2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \ 3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall class Class##TypeLoc; 3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def" 3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 33b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info. 34b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// 35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to 36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information. 37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc { 38b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected: 3934a0447b8072e0da14c0980597da9d03a1495662John McCall // The correctness of this relies on the property that, for Type *Ty, 4034a0447b8072e0da14c0980597da9d03a1495662John McCall // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty 4134a0447b8072e0da14c0980597da9d03a1495662John McCall void *Ty; 42b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void *Data; 431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 44b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 4551bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum, 4651bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// except it also defines a Qualified enum that corresponds to the 4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// QualifiedLoc class. 4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall enum TypeLocClass { 4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base) 5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \ 5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall Class = Type::Class, 5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def" 5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall Qualified 5451bd803fbdade51d674598ed45da3d54190a656cJohn McCall }; 5551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 5634a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc() : Ty(0), Data(0) { } 5734a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(QualType ty, void *opaqueData) 5834a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } 5934a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(Type *ty, void *opaqueData) 6034a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty), Data(opaqueData) { } 61b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 6251bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 63a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor if (getType().hasLocalQualifiers()) return Qualified; 6451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getType()->getTypeClass(); 6551bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 6651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 6734a0447b8072e0da14c0980597da9d03a1495662John McCall bool isNull() const { return !Ty; } 6834a0447b8072e0da14c0980597da9d03a1495662John McCall operator bool() const { return Ty; } 69b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 70b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of type source info data block for the given type. 71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static unsigned getFullDataSizeForType(QualType Ty); 72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 73b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the type for which this source info wrapper provides 74b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// information. 7551bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getType() const { 7651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return QualType::getFromOpaquePtr(Ty); 7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 7834a0447b8072e0da14c0980597da9d03a1495662John McCall 7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall Type *getTypePtr() const { 8034a0447b8072e0da14c0980597da9d03a1495662John McCall return QualType::getFromOpaquePtr(Ty).getTypePtr(); 8134a0447b8072e0da14c0980597da9d03a1495662John McCall } 82b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 83b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis /// \brief Get the pointer where source information is stored. 8451bd803fbdade51d674598ed45da3d54190a656cJohn McCall void *getOpaqueData() const { 8551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Data; 8651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 87b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 88e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the begin source location. 89e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getBeginLoc() const; 90e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 91e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the end source location. 92e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getEndLoc() const; 93e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 94833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the full source range. 95bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getSourceRange() const { 96e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara return SourceRange(getBeginLoc(), getEndLoc()); 97833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 98833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 99833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the local source range. 100bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 101bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara return getLocalSourceRangeImpl(*this); 10251bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block. 10534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 10651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getFullDataSizeForType(getType()); 10734a0447b8072e0da14c0980597da9d03a1495662John McCall } 108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the 110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// TypeLoc is a PointerLoc and next TypeLoc is for "int". 11151bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLoc getNextTypeLoc() const { 11251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getNextTypeLocImpl(*this); 11351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 11534a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Skips past any qualifiers, if this is qualified. 11651bd803fbdade51d674598ed45da3d54190a656cJohn McCall UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header 11734a0447b8072e0da14c0980597da9d03a1495662John McCall 1184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// \brief Initializes this to state that every location in this 1194ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// type is the given location. 1204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// 1214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// This method exists to provide a simple transition for code that 1224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// relies on location-less types. 1234ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initialize(SourceLocation Loc) const { 1244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall initializeImpl(*this, Loc); 1254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 127b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { 128b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; 129b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 130b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) { 132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return !(LHS == RHS); 133b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 134b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 135b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static bool classof(const TypeLoc *TL) { return true; } 1364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate: 1384ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall static void initializeImpl(TypeLoc TL, SourceLocation Loc); 13951bd803fbdade51d674598ed45da3d54190a656cJohn McCall static TypeLoc getNextTypeLocImpl(TypeLoc TL); 140bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara static SourceRange getLocalSourceRangeImpl(TypeLoc TL); 141b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 142b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1433c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info. 1443c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const { 1454ab92891a53adda8c52c1947351371da58e33f64Gabor Greif return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); 1463c385c28cf1f27b193a620d2e51f814873362cebJohn McCall} 1473c385c28cf1f27b193a620d2e51f814873362cebJohn McCall 14834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 14934a0447b8072e0da14c0980597da9d03a1495662John McCall/// no direct quqlaifiers. 15034a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc { 15134a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 15234a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc() {} 15334a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc(Type *Ty, void *Data) : TypeLoc(Ty, Data) {} 15434a0447b8072e0da14c0980597da9d03a1495662John McCall 15551bd803fbdade51d674598ed45da3d54190a656cJohn McCall Type *getTypePtr() const { 15634a0447b8072e0da14c0980597da9d03a1495662John McCall return reinterpret_cast<Type*>(Ty); 15734a0447b8072e0da14c0980597da9d03a1495662John McCall } 15834a0447b8072e0da14c0980597da9d03a1495662John McCall 15951bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 16051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getTypePtr()->getTypeClass(); 16151bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 16251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 16334a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 164a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return !TL->getType().hasLocalQualifiers(); 16534a0447b8072e0da14c0980597da9d03a1495662John McCall } 16634a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const UnqualTypeLoc *TL) { return true; } 16734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 16834a0447b8072e0da14c0980597da9d03a1495662John McCall 16934a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 17034a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers. 17134a0447b8072e0da14c0980597da9d03a1495662John McCall/// 17234a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for 17334a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers. 17451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc { 17534a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 176bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 17734a0447b8072e0da14c0980597da9d03a1495662John McCall return SourceRange(); 17834a0447b8072e0da14c0980597da9d03a1495662John McCall } 17934a0447b8072e0da14c0980597da9d03a1495662John McCall 18034a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc getUnqualifiedLoc() const { 18151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return UnqualTypeLoc(getTypePtr(), Data); 18234a0447b8072e0da14c0980597da9d03a1495662John McCall } 18334a0447b8072e0da14c0980597da9d03a1495662John McCall 1844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// Initializes the local data of this type source info block to 1854ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// provide no information. 1864ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 1874ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall // do nothing 1884ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1904ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 1914ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getUnqualifiedLoc(); 1924ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1934ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 19434a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block that is 19534a0447b8072e0da14c0980597da9d03a1495662John McCall /// specific to this type. 19634a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 19734a0447b8072e0da14c0980597da9d03a1495662John McCall // In fact, we don't currently preserve any location information 19834a0447b8072e0da14c0980597da9d03a1495662John McCall // for qualifiers. 19934a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 20034a0447b8072e0da14c0980597da9d03a1495662John McCall } 20134a0447b8072e0da14c0980597da9d03a1495662John McCall 20234a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block. 20334a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 20434a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalDataSize() + 205fa1a06e80706846fa15e0bd44671bdc3dfc53d84Douglas Gregor getFullDataSizeForType(getType().getLocalUnqualifiedType()); 20634a0447b8072e0da14c0980597da9d03a1495662John McCall } 20734a0447b8072e0da14c0980597da9d03a1495662John McCall 20834a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 209a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return TL->getType().hasLocalQualifiers(); 21034a0447b8072e0da14c0980597da9d03a1495662John McCall } 21151bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const QualifiedTypeLoc *TL) { return true; } 21234a0447b8072e0da14c0980597da9d03a1495662John McCall}; 21334a0447b8072e0da14c0980597da9d03a1495662John McCall 21434a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { 21551bd803fbdade51d674598ed45da3d54190a656cJohn McCall if (isa<QualifiedTypeLoc>(this)) 21651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc(); 21734a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<UnqualTypeLoc>(*this); 21834a0447b8072e0da14c0980597da9d03a1495662John McCall} 21934a0447b8072e0da14c0980597da9d03a1495662John McCall 22034a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond 221f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass. It is accepted for a single 222f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes. 22334a0447b8072e0da14c0980597da9d03a1495662John McCall/// 22434a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Base a class from which to derive 22534a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Derived the class deriving from this one 226f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// \param TypeClass the concrete Type subclass associated with this 227f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// location type 22834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param LocalData the structure type of local location data for 22934a0447b8072e0da14c0980597da9d03a1495662John McCall/// this type 23034a0447b8072e0da14c0980597da9d03a1495662John McCall/// 23134a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or 23234a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end. 23334a0447b8072e0da14c0980597da9d03a1495662John McCall/// 23434a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override 23534a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to 23634a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory. 23734a0447b8072e0da14c0980597da9d03a1495662John McCall/// 238a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define 239a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// QualType getInnerType() const 240a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's 241a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data. 24251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// 24351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be 24451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy. It is also not 24551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide 24651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information. It should be subclassed 24751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children 24851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type, 24951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from 25051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead. 25134a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData> 25234a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base { 25334a0447b8072e0da14c0980597da9d03a1495662John McCall 25434a0447b8072e0da14c0980597da9d03a1495662John McCall const Derived *asDerived() const { 25534a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<const Derived*>(this); 25634a0447b8072e0da14c0980597da9d03a1495662John McCall } 25734a0447b8072e0da14c0980597da9d03a1495662John McCall 25834a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 25934a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 26034a0447b8072e0da14c0980597da9d03a1495662John McCall return sizeof(LocalData) + asDerived()->getExtraLocalDataSize(); 26134a0447b8072e0da14c0980597da9d03a1495662John McCall } 26234a0447b8072e0da14c0980597da9d03a1495662John McCall // Give a default implementation that's useful for leaf types. 26334a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 26434a0447b8072e0da14c0980597da9d03a1495662John McCall return asDerived()->getLocalDataSize() + getInnerTypeSize(); 26534a0447b8072e0da14c0980597da9d03a1495662John McCall } 26634a0447b8072e0da14c0980597da9d03a1495662John McCall 26734a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classofType(const Type *Ty) { 26834a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeClass::classof(Ty); 26934a0447b8072e0da14c0980597da9d03a1495662John McCall } 27034a0447b8072e0da14c0980597da9d03a1495662John McCall 271e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const TypeLoc *TL) { 272e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 273e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 274e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const UnqualTypeLoc *TL) { 275e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 276e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 277e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const Derived *TL) { 278e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return true; 279e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 280e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 2814ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 2824ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getNextTypeLoc(asDerived()->getInnerType()); 2834ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 28534a0447b8072e0da14c0980597da9d03a1495662John McCall TypeClass *getTypePtr() const { 28651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 28734a0447b8072e0da14c0980597da9d03a1495662John McCall } 28834a0447b8072e0da14c0980597da9d03a1495662John McCall 28951bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected: 29034a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 29134a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 29234a0447b8072e0da14c0980597da9d03a1495662John McCall } 29334a0447b8072e0da14c0980597da9d03a1495662John McCall 29434a0447b8072e0da14c0980597da9d03a1495662John McCall LocalData *getLocalData() const { 29534a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<LocalData*>(Base::Data); 29634a0447b8072e0da14c0980597da9d03a1495662John McCall } 29734a0447b8072e0da14c0980597da9d03a1495662John McCall 29834a0447b8072e0da14c0980597da9d03a1495662John McCall /// Gets a pointer past the Info structure; useful for classes with 29934a0447b8072e0da14c0980597da9d03a1495662John McCall /// local data that can't be captured in the Info (e.g. because it's 30034a0447b8072e0da14c0980597da9d03a1495662John McCall /// of variable size). 30134a0447b8072e0da14c0980597da9d03a1495662John McCall void *getExtraLocalData() const { 30234a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData() + 1; 30334a0447b8072e0da14c0980597da9d03a1495662John McCall } 30434a0447b8072e0da14c0980597da9d03a1495662John McCall 30534a0447b8072e0da14c0980597da9d03a1495662John McCall void *getNonLocalData() const { 30634a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize(); 30734a0447b8072e0da14c0980597da9d03a1495662John McCall } 30834a0447b8072e0da14c0980597da9d03a1495662John McCall 309a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall struct HasNoInnerType {}; 310a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall HasNoInnerType getInnerType() const { return HasNoInnerType(); } 31134a0447b8072e0da14c0980597da9d03a1495662John McCall 31234a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc getInnerTypeLoc() const { 31334a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); 31434a0447b8072e0da14c0980597da9d03a1495662John McCall } 31534a0447b8072e0da14c0980597da9d03a1495662John McCall 31634a0447b8072e0da14c0980597da9d03a1495662John McCallprivate: 31734a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getInnerTypeSize() const { 318a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeSize(asDerived()->getInnerType()); 319a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall } 320a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall 321a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(HasNoInnerType _) const { 32234a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 32334a0447b8072e0da14c0980597da9d03a1495662John McCall } 32434a0447b8072e0da14c0980597da9d03a1495662John McCall 325a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(QualType _) const { 326a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeLoc().getFullDataSize(); 32734a0447b8072e0da14c0980597da9d03a1495662John McCall } 3284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(HasNoInnerType _) const { 3304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(); 3314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3334ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(QualType T) const { 3344ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(T, getNonLocalData()); 3354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 33634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 33734a0447b8072e0da14c0980597da9d03a1495662John McCall 33851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract 33951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source 34051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information. See the note on ConcreteTypeLoc. 34151bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass> 34251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base { 343b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 34451bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const TypeLoc *TL) { 34551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 346b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 34751bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const UnqualTypeLoc *TL) { 34851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 349b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 35051bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const Derived *TL) { 35151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return true; 352b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 353b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 35451bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass *getTypePtr() const { 35551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 3564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 35734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 358b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 359ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 36051bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo { 36134a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation NameLoc; 362b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 363b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 36451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to 36551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier. 366ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 367ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc, 368ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Type, 369ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecLocInfo> { 370b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 371ed97649e9574b9d854fa4d6109c9333ae0993554John McCall enum { LocalDataSize = sizeof(TypeSpecLocInfo) }; 372ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 373b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getNameLoc() const { 37451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->NameLoc; 375b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 376b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setNameLoc(SourceLocation Loc) { 37751bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->NameLoc = Loc; 378b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 379bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 380b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getNameLoc(), getNameLoc()); 381b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 3824ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 3834ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setNameLoc(Loc); 3844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 385ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 386ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeLoc *TL); 387ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeSpecTypeLoc *TL) { return true; } 38851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 3894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 390ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 391ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo { 392ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation BuiltinLoc; 393ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 394ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 395ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types. 396ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 397ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc, 398ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType, 399ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinLocInfo> { 400ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic: 401ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor enum { LocalDataSize = sizeof(BuiltinLocInfo) }; 402ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 403ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getBuiltinLoc() const { 404ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getLocalData()->BuiltinLoc; 405ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 406ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setBuiltinLoc(SourceLocation Loc) { 407ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getLocalData()->BuiltinLoc = Loc; 408ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 409ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 410ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getNameLoc() const { return getBuiltinLoc(); } 411ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 412ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs& getWrittenBuiltinSpecs() { 413ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 414ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 415ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { 416ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 417ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 418ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 419ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool needsExtraLocalData() const { 420ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType::Kind bk = getTypePtr()->getKind(); 421ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) 422d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble) 423ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::UChar 424ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::SChar; 425ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 426ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 427ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor unsigned getExtraLocalDataSize() const { 428d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; 429ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 430ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 431bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 432ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return SourceRange(getBuiltinLoc(), getBuiltinLoc()); 433ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 434ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 435ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierSign getWrittenSignSpec() const { 436ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 437ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); 438ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 439ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSS_unspecified; 440ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 441ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenSignSpec() const { 442ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenSignSpec() != TSS_unspecified; 443ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 444ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenSignSpec(TypeSpecifierSign written) { 445ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 446ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Sign = written; 447ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 448ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 449ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierWidth getWrittenWidthSpec() const { 450ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 451ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); 452ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 453ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSW_unspecified; 454ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 455ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenWidthSpec() const { 456ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenWidthSpec() != TSW_unspecified; 457ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 458ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenWidthSpec(TypeSpecifierWidth written) { 459ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 460ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Width = written; 461ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 462ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 463ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierType getWrittenTypeSpec() const; 464ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenTypeSpec() const { 465ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenTypeSpec() != TST_unspecified; 466ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 467ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenTypeSpec(TypeSpecifierType written) { 468ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 469ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Type = written; 470ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 471ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 472ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasModeAttr() const { 473ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 474ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenBuiltinSpecs().ModeAttr; 475ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return false; 477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setModeAttr(bool written) { 479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().ModeAttr = written; 481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void initializeLocal(SourceLocation Loc) { 484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor setBuiltinLoc(Loc); 485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) { 486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); 487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Sign = TSS_unspecified; 488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Width = TSW_unspecified; 489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Type = TST_unspecified; 490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.ModeAttr = false; 491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 49651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs. 497ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 498ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefTypeLoc, 499ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefType> { 50051bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 5019036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis TypedefDecl *getTypedefDecl() const { 50234a0447b8072e0da14c0980597da9d03a1495662John McCall return getTypePtr()->getDecl(); 5039036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis } 50434a0447b8072e0da14c0980597da9d03a1495662John McCall}; 5059036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis 5063cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class 5073cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates. 5083cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc : 5093cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 5103cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameTypeLoc, 5113cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameType> { 5123cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall}; 5133cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 514ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls. 515ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc : 516ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 517ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypeLoc, 518ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType> { 519ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 520ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypenameDecl *getDecl() const { 521ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return getTypePtr()->getDecl(); 522ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 523ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 524ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 525ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types. Note that this only 526ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo' 527ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc. We currently 528ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of 529ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C. 530ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 531ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagTypeLoc, 532ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagType> { 533ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 534ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagDecl *getDecl() const { return getTypePtr()->getDecl(); } 535ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 536ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 537ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types. 538ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 539ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordTypeLoc, 540ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordType> { 541ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 542ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordDecl *getDecl() const { return getTypePtr()->getDecl(); } 543ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 544ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 545ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types. 546ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 547ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumTypeLoc, 548ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumType> { 549ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 550ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumDecl *getDecl() const { return getTypePtr()->getDecl(); } 551ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 552b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 55349a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters. 554ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc : 555ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 556ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmTypeLoc, 557ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmType> { 55849a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 55949a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 56049a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters. 56149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc : 562ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 563ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmTypeLoc, 564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmType> { 56549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 56651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 567eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 56834a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo { 56954e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation LAngleLoc; 57054e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation RAngleLoc; 571ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall bool HasBaseTypeAsWritten; 572eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis}; 573eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 57454e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with 57554e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols. 57654e14c4db764c0636160d26c5bbf491637c83a76John McCall// 57754e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or 57854e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType. 579c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 580c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectTypeLoc, 581c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectType, 582c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCProtocolListLocInfo> { 583f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis // SourceLocations are stored after Info, one for each Protocol. 584f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation *getProtocolLocArray() const { 58554e14c4db764c0636160d26c5bbf491637c83a76John McCall return (SourceLocation*) this->getExtraLocalData(); 58654e14c4db764c0636160d26c5bbf491637c83a76John McCall } 58754e14c4db764c0636160d26c5bbf491637c83a76John McCall 588f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic: 589f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getLAngleLoc() const { 59054e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->LAngleLoc; 591f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 592f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setLAngleLoc(SourceLocation Loc) { 59354e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->LAngleLoc = Loc; 594f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 595f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 596f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getRAngleLoc() const { 59754e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->RAngleLoc; 598f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 599f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setRAngleLoc(SourceLocation Loc) { 60054e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->RAngleLoc = Loc; 601f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 602f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 603f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis unsigned getNumProtocols() const { 60454e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getTypePtr()->getNumProtocols(); 605f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 606f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 607f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getProtocolLoc(unsigned i) const { 608f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 609f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return getProtocolLocArray()[i]; 610f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 611f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setProtocolLoc(unsigned i, SourceLocation Loc) { 612f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 613f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis getProtocolLocArray()[i] = Loc; 614f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 615f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 616f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis ObjCProtocolDecl *getProtocol(unsigned i) const { 617f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 61854e14c4db764c0636160d26c5bbf491637c83a76John McCall return *(this->getTypePtr()->qual_begin() + i); 619f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 620f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 621c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall bool hasBaseTypeAsWritten() const { 622ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall return getLocalData()->HasBaseTypeAsWritten; 623c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 624c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 625c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setHasBaseTypeAsWritten(bool HasBaseType) { 626ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall getLocalData()->HasBaseTypeAsWritten = HasBaseType; 627c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 628c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 629c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TypeLoc getBaseLoc() const { 630c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getInnerTypeLoc(); 631c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 632c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 633bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 634f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return SourceRange(getLAngleLoc(), getRAngleLoc()); 635f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 636f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 6374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 638ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall setHasBaseTypeAsWritten(true); 639c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setLAngleLoc(Loc); 640c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setRAngleLoc(Loc); 641c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall for (unsigned i = 0, e = getNumProtocols(); i != e; ++i) 642c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setProtocolLoc(i, Loc); 6434ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 6444ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 64534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 64654e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getNumProtocols() * sizeof(SourceLocation); 64754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 648c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 649c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall QualType getInnerType() const { 650c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getTypePtr()->getBaseType(); 651c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 65254e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 65354e14c4db764c0636160d26c5bbf491637c83a76John McCall 65454e14c4db764c0636160d26c5bbf491637c83a76John McCall 655c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo { 65654e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation NameLoc; 65754e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 65854e14c4db764c0636160d26c5bbf491637c83a76John McCall 65954e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces. 660a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc, 661c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceTypeLoc, 662c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceType, 663c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceLocInfo> { 66454e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 66554e14c4db764c0636160d26c5bbf491637c83a76John McCall ObjCInterfaceDecl *getIFaceDecl() const { 66654e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getDecl(); 66754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 66854e14c4db764c0636160d26c5bbf491637c83a76John McCall 66954e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation getNameLoc() const { 67054e14c4db764c0636160d26c5bbf491637c83a76John McCall return getLocalData()->NameLoc; 67154e14c4db764c0636160d26c5bbf491637c83a76John McCall } 67254e14c4db764c0636160d26c5bbf491637c83a76John McCall 67354e14c4db764c0636160d26c5bbf491637c83a76John McCall void setNameLoc(SourceLocation Loc) { 67454e14c4db764c0636160d26c5bbf491637c83a76John McCall getLocalData()->NameLoc = Loc; 67554e14c4db764c0636160d26c5bbf491637c83a76John McCall } 67654e14c4db764c0636160d26c5bbf491637c83a76John McCall 677bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 678c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return SourceRange(getNameLoc()); 67954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 68054e14c4db764c0636160d26c5bbf491637c83a76John McCall 68154e14c4db764c0636160d26c5bbf491637c83a76John McCall void initializeLocal(SourceLocation Loc) { 68254e14c4db764c0636160d26c5bbf491637c83a76John McCall setNameLoc(Loc); 683f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 68454e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 68554e14c4db764c0636160d26c5bbf491637c83a76John McCall 686f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 68751bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo { 68834a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation StarLoc; 689f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis}; 690f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 69151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A base class for 69251bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> 69351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, 69451bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass, LocalData> { 695bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallpublic: 69651bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getSigilLoc() const { 69751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->StarLoc; 698b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 69951bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setSigilLoc(SourceLocation Loc) { 70051bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->StarLoc = Loc; 701b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 702b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 703b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getPointeeLoc() const { 70451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getInnerTypeLoc(); 705b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 706b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 707bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 70851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return SourceRange(getSigilLoc(), getSigilLoc()); 709b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 710b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 7114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 71251bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 7134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 7144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 71551bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getInnerType() const { 71651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getTypePtr()->getPointeeType(); 71751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 71834a0447b8072e0da14c0980597da9d03a1495662John McCall}; 719b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 720b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 72151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers. 72251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc, 72351bd803fbdade51d674598ed45da3d54190a656cJohn McCall PointerType> { 72451bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 72551bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getStarLoc() const { 72651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 72751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 72851bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setStarLoc(SourceLocation Loc) { 72951bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 73051bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 731b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 732b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 73351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 734b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers. 73551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc, 73651bd803fbdade51d674598ed45da3d54190a656cJohn McCall BlockPointerType> { 737b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 738b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getCaretLoc() const { 73951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 740b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 741b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setCaretLoc(SourceLocation Loc) { 74251bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 743b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 74434a0447b8072e0da14c0980597da9d03a1495662John McCall}; 745b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 746b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 747b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers. 74851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc, 74951bd803fbdade51d674598ed45da3d54190a656cJohn McCall MemberPointerType> { 750b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 751b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getStarLoc() const { 75251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 753b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 754b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setStarLoc(SourceLocation Loc) { 75551bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 7564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 75734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 758b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 759c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information. 760c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc : 761c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc, 762c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerType> { 763c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic: 764c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall SourceLocation getStarLoc() const { 765c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getSigilLoc(); 766c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 767c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 768c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setStarLoc(SourceLocation Loc) { 769c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setSigilLoc(Loc); 770c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 771c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall}; 772c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 773b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 77451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc, 77551bd803fbdade51d674598ed45da3d54190a656cJohn McCall ReferenceType> { 77654e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 77754e14c4db764c0636160d26c5bbf491637c83a76John McCall QualType getInnerType() const { 77854e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getPointeeTypeAsWritten(); 77954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 780b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 781b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 782bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc : 783bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 784bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceTypeLoc, 785bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceType> { 786b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 787b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getAmpLoc() const { 78851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 789b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 790b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setAmpLoc(SourceLocation Loc) { 79151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 792b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 79351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 794b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 795bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc : 796bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 797bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceTypeLoc, 798bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceType> { 79951bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 80051bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getAmpAmpLoc() const { 80151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 802b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 80351bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setAmpAmpLoc(SourceLocation Loc) { 80451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 805b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 80651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 807b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 808b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 80934a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo { 81034a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LParenLoc, RParenLoc; 811b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 812b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 813b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions. 81451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 81551bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionTypeLoc, 81651bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionType, 81751bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionLocInfo> { 818b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis // ParmVarDecls* are stored after Info, one for each argument. 819b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis ParmVarDecl **getParmArray() const { 82034a0447b8072e0da14c0980597da9d03a1495662John McCall return (ParmVarDecl**) getExtraLocalData(); 821b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 822b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 823b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 824b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLParenLoc() const { 82534a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LParenLoc; 826b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 827b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLParenLoc(SourceLocation Loc) { 82834a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LParenLoc = Loc; 829b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 830b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 831b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRParenLoc() const { 83234a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RParenLoc; 833b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 834b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRParenLoc(SourceLocation Loc) { 83534a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RParenLoc = Loc; 836b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 837b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 838b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis unsigned getNumArgs() const { 83934a0447b8072e0da14c0980597da9d03a1495662John McCall if (isa<FunctionNoProtoType>(getTypePtr())) 840b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return 0; 84134a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<FunctionProtoType>(getTypePtr())->getNumArgs(); 842b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 843b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; } 844b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } 845b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 846b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getResultLoc() const { 84734a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 848b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 849b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 850bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 851b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLParenLoc(), getRParenLoc()); 852b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 853b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 8544ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 8554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLParenLoc(Loc); 8564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRParenLoc(Loc); 8574ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall for (unsigned i = 0, e = getNumArgs(); i != e; ++i) 8584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setArg(i, NULL); 8594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 8604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 861b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block that is 862b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// specific to this type. 86334a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 86434a0447b8072e0da14c0980597da9d03a1495662John McCall return getNumArgs() * sizeof(ParmVarDecl*); 865b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 866b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 86734a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getResultType(); } 86834a0447b8072e0da14c0980597da9d03a1495662John McCall}; 86934a0447b8072e0da14c0980597da9d03a1495662John McCall 87051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc : 87151bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 87251bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoTypeLoc, 87351bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoType> { 87451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 87551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 87651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc : 87751bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 87851bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoTypeLoc, 87951bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoType> { 88051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 88151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 882b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 88334a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo { 88434a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LBracketLoc, RBracketLoc; 88534a0447b8072e0da14c0980597da9d03a1495662John McCall Expr *Size; 886b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 887b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 888b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays. 88951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 89051bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayTypeLoc, 89151bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayType, 89251bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayLocInfo> { 893b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 894b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLBracketLoc() const { 89534a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LBracketLoc; 896b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 897b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLBracketLoc(SourceLocation Loc) { 89834a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LBracketLoc = Loc; 899b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 900b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 901b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRBracketLoc() const { 90234a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RBracketLoc; 903b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 904b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRBracketLoc(SourceLocation Loc) { 90534a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RBracketLoc = Loc; 906b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 907b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 90885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange getBracketsRange() const { 90985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return SourceRange(getLBracketLoc(), getRBracketLoc()); 91085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 91185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 912b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis Expr *getSizeExpr() const { 91334a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->Size; 914b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 915b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setSizeExpr(Expr *Size) { 91634a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->Size = Size; 917b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 918b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 919b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getElementLoc() const { 92034a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 921b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 922b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 923bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 924b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLBracketLoc(), getRBracketLoc()); 925b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 926b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 9274ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall void initializeLocal(SourceLocation Loc) { 9284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLBracketLoc(Loc); 9294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRBracketLoc(Loc); 9304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setSizeExpr(NULL); 9314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 9324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 93334a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getElementType(); } 934b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 935b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 93651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc : 93751bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 93851bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayTypeLoc, 93951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayType> { 94051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 94251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc : 94351bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 94451bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayTypeLoc, 94551bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayType> { 94651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 94751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 94851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc : 94951bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 95051bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayTypeLoc, 95151bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayType> { 95251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 95351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 95451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 95551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc : 95651bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 95751bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayTypeLoc, 95851bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayType> { 95951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 96051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 961833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 962833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName. Rudimentary for now. 963833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo { 964833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation NameLoc; 965833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 966833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 967833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo { 968833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc; 969833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation RAngleLoc; 970833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 971833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 972833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc : 973833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall public ConcreteTypeLoc<UnqualTypeLoc, 974833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc, 975833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationType, 976833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationLocInfo> { 977833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic: 978833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getLAngleLoc() const { 979833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->LAngleLoc; 980833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 981833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setLAngleLoc(SourceLocation Loc) { 982833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->LAngleLoc = Loc; 983833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 984833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 985833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getRAngleLoc() const { 986833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->RAngleLoc; 987833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 988833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setRAngleLoc(SourceLocation Loc) { 989833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->RAngleLoc = Loc; 990833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 991833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 992833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getNumArgs() const { 993833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getTypePtr()->getNumArgs(); 994833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 995833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 996833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#ifndef NDEBUG 997833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall AI.validateForArgument(getTypePtr()->getArg(i)); 998833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#endif 999833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getArgInfos()[i] = AI; 1000833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1001833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 1002833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getArgInfos()[i]; 1003833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1004833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1005833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 1006833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 1007833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1008833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1009833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getTemplateNameLoc() const { 1010833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->NameLoc; 1011833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1012833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setTemplateNameLoc(SourceLocation Loc) { 1013833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->NameLoc = Loc; 1014833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1015833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1016833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief - Copy the location information from the given info. 1017833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void copy(TemplateSpecializationTypeLoc Loc) { 1018833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned size = getFullDataSize(); 1019833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall assert(size == Loc.getFullDataSize()); 1020833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1021833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // We're potentially copying Expr references here. We don't 1022a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall // bother retaining them because TypeSourceInfos live forever, so 1023833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // as long as the Expr was retained when originally written into 1024833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // the TypeLoc, we're okay. 1025833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall memcpy(Data, Loc.Data, size); 1026833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1027833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1028bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1029833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 1030833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1031833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1032833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void initializeLocal(SourceLocation Loc) { 1033833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setLAngleLoc(Loc); 1034833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setRAngleLoc(Loc); 1035833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setTemplateNameLoc(Loc); 103633500955d731c73717af52088b7fc0e7a85681e7John McCall initializeArgLocs(getNumArgs(), getTypePtr()->getArgs(), 103733500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 103833500955d731c73717af52088b7fc0e7a85681e7John McCall } 1039833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 104033500955d731c73717af52088b7fc0e7a85681e7John McCall static void initializeArgLocs(unsigned NumArgs, 104133500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgument *Args, 104233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *ArgInfos, 104333500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation Loc) { 104433500955d731c73717af52088b7fc0e7a85681e7John McCall for (unsigned i = 0, e = NumArgs; i != e; ++i) { 1045cbe12738371bec6ff20372e1d3426cffc85d8323John McCall TemplateArgumentLocInfo Info; 1046828bff2079b6a91ecd7ed5b842c59527d7682789John McCall#ifndef NDEBUG 1047828bff2079b6a91ecd7ed5b842c59527d7682789John McCall // If asserts are enabled, be sure to initialize the argument 1048828bff2079b6a91ecd7ed5b842c59527d7682789John McCall // loc with the right kind of pointer. 104933500955d731c73717af52088b7fc0e7a85681e7John McCall switch (Args[i].getKind()) { 1050828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Expression: 1051828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Declaration: 1052828bff2079b6a91ecd7ed5b842c59527d7682789John McCall Info = TemplateArgumentLocInfo((Expr*) 0); 1053828bff2079b6a91ecd7ed5b842c59527d7682789John McCall break; 1054828bff2079b6a91ecd7ed5b842c59527d7682789John McCall 1055828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Type: 1056a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall Info = TemplateArgumentLocInfo((TypeSourceInfo*) 0); 1057828bff2079b6a91ecd7ed5b842c59527d7682789John McCall break; 1058828bff2079b6a91ecd7ed5b842c59527d7682789John McCall 1059788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor case TemplateArgument::Template: 106033500955d731c73717af52088b7fc0e7a85681e7John McCall Info = TemplateArgumentLocInfo(SourceRange(Loc), Loc); 1061788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor break; 1062788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor 1063828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Integral: 1064828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Pack: 1065828bff2079b6a91ecd7ed5b842c59527d7682789John McCall case TemplateArgument::Null: 1066828bff2079b6a91ecd7ed5b842c59527d7682789John McCall // K_None is fine. 1067828bff2079b6a91ecd7ed5b842c59527d7682789John McCall break; 1068828bff2079b6a91ecd7ed5b842c59527d7682789John McCall } 1069828bff2079b6a91ecd7ed5b842c59527d7682789John McCall#endif 107033500955d731c73717af52088b7fc0e7a85681e7John McCall ArgInfos[i] = Info; 1071828bff2079b6a91ecd7ed5b842c59527d7682789John McCall } 1072833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1073833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1074833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getExtraLocalDataSize() const { 1075833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 1076833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1077833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1078833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate: 1079833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo *getArgInfos() const { 1080833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 1081833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1082833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1083833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1084ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 1085ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1086ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// All of these need proper implementations. 1087ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1088ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 108951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1090ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we 1091ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax). 1092ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1093ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorTypeLoc, 1094ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorType> { 109551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 109651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1097ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations. 109851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc, 109951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorTypeLoc, 110051bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorType> { 110151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 110251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1103ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations. 110451bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType. 110551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc : 1106ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1107ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorTypeLoc, 1108ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorType> { 110951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 111051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1111ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword. 1112ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1113ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexTypeLoc, 1114ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexType> { 111551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 111651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1117cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo { 1118cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation TypeofLoc; 1119cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation LParenLoc; 1120cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation RParenLoc; 112151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 112251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1123cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo { 1124cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1125cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1126cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo { 1127cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* UnderlyingTInfo; 1128cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1129cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1130cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo> 1131cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc 1132cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { 1133cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1134cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getTypeofLoc() const { 1135cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->TypeofLoc; 1136cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1137cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setTypeofLoc(SourceLocation Loc) { 1138cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->TypeofLoc = Loc; 1139cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1140cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1141cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getLParenLoc() const { 1142cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->LParenLoc; 1143cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1144cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setLParenLoc(SourceLocation Loc) { 1145cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->LParenLoc = Loc; 1146cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1147cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1148cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getRParenLoc() const { 1149cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->RParenLoc; 1150cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1151cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setRParenLoc(SourceLocation Loc) { 1152cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->RParenLoc = Loc; 1153cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1154cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1155cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceRange getParensRange() const { 1156cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getLParenLoc(), getRParenLoc()); 1157cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1158cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setParensRange(SourceRange range) { 1159cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(range.getBegin()); 1160cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(range.getEnd()); 1161cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1162cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1163bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1164cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getTypeofLoc(), getRParenLoc()); 1165cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1166cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1167cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void initializeLocal(SourceLocation Loc) { 1168cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setTypeofLoc(Loc); 1169cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(Loc); 1170cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(Loc); 1171cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1172cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1173cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1174cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, 1175cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprType, 1176cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprTypeLocInfo> { 1177cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1178cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Expr* getUnderlyingExpr() const { 1179cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return getTypePtr()->getUnderlyingExpr(); 1180cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1181cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // Reimplemented to account for GNU/C++ extension 1182cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // typeof unary-expression 1183cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // where there are no parentheses. 1184bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const; 1185cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1186cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1187cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc 1188cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { 1189cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1190cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall QualType getUnderlyingType() const { 1191cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getTypePtr()->getUnderlyingType(); 1192cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1193cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* getUnderlyingTInfo() const { 1194cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->UnderlyingTInfo; 1195cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1196cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setUnderlyingTInfo(TypeSourceInfo* TI) const { 1197cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->UnderlyingTInfo = TI; 1198cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 119951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 120051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1201ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens. 1202ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1203ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeTypeLoc, 1204ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeType> { 120551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 120651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1207e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo { 1208e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation KeywordLoc; 1209e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceRange QualifierRange; 1210e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1211e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1212e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1213e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc, 1214e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedType, 1215e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedLocInfo> { 1216e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 1217e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getKeywordLoc() const { 1218e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->KeywordLoc; 1219e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1220e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setKeywordLoc(SourceLocation Loc) { 1221e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->KeywordLoc = Loc; 1222e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1223e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1224e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceRange getQualifierRange() const { 1225e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->QualifierRange; 1226e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1227e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setQualifierRange(SourceRange Range) { 1228e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->QualifierRange = Range; 1229e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1230e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1231bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1232e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (getKeywordLoc().isValid()) 1233e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (getQualifierRange().getEnd().isValid()) 1234e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getKeywordLoc(), getQualifierRange().getEnd()); 1235e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 1236e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getKeywordLoc()); 1237e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 1238e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getQualifierRange(); 1239e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1240e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1241e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void initializeLocal(SourceLocation Loc) { 1242e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara setKeywordLoc(Loc); 1243e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara setQualifierRange(SourceRange(Loc)); 1244e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1245e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1246e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara TypeLoc getNamedTypeLoc() const { 1247e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getInnerTypeLoc(); 1248e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1249e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1250e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType getInnerType() const { 1251e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getTypePtr()->getNamedType(); 1252e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1253e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1254e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(ElaboratedTypeLoc Loc) { 1255e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1256e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1257e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1258e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 125951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 126051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 126133500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 126233500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc. 126333500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo { 1264e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation NameLoc; 1265e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1266e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1267e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1268e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc, 1269e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameType, 1270e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameLocInfo> { 1271e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 1272e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getKeywordLoc() const { 1273e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->KeywordLoc; 1274e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1275e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setKeywordLoc(SourceLocation Loc) { 1276e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->KeywordLoc = Loc; 1277e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1278e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1279e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceRange getQualifierRange() const { 1280e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->QualifierRange; 1281e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1282e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setQualifierRange(SourceRange Range) { 1283e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->QualifierRange = Range; 1284e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1285e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1286e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getNameLoc() const { 1287e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->NameLoc; 1288e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1289e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setNameLoc(SourceLocation Loc) { 1290e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->NameLoc = Loc; 1291e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1292e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1293bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1294e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (getKeywordLoc().isValid()) 1295e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getKeywordLoc(), getNameLoc()); 1296e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 1297e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getQualifierRange().getBegin(), getNameLoc()); 1298e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1299e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1300e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(DependentNameTypeLoc Loc) { 1301e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1302e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1303e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1304e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1305e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1306e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void initializeLocal(SourceLocation Loc) { 1307e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara setKeywordLoc(Loc); 1308e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara setQualifierRange(SourceRange(Loc)); 1309e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara setNameLoc(Loc); 1310e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 131151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 131251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 131333500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 131433500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TemplateSpecializationTypeLoc. 131533500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { 131633500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation LAngleLoc; 131733500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation RAngleLoc; 131833500955d731c73717af52088b7fc0e7a85681e7John McCall // followed by a TemplateArgumentLocInfo[] 131933500955d731c73717af52088b7fc0e7a85681e7John McCall}; 132033500955d731c73717af52088b7fc0e7a85681e7John McCall 132133500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc : 132233500955d731c73717af52088b7fc0e7a85681e7John McCall public ConcreteTypeLoc<UnqualTypeLoc, 132333500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationTypeLoc, 132433500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType, 132533500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationLocInfo> { 132633500955d731c73717af52088b7fc0e7a85681e7John McCallpublic: 132733500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getKeywordLoc() const { 132833500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->KeywordLoc; 132933500955d731c73717af52088b7fc0e7a85681e7John McCall } 133033500955d731c73717af52088b7fc0e7a85681e7John McCall void setKeywordLoc(SourceLocation Loc) { 133133500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->KeywordLoc = Loc; 133233500955d731c73717af52088b7fc0e7a85681e7John McCall } 133333500955d731c73717af52088b7fc0e7a85681e7John McCall 133433500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getQualifierRange() const { 133533500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->QualifierRange; 133633500955d731c73717af52088b7fc0e7a85681e7John McCall } 133733500955d731c73717af52088b7fc0e7a85681e7John McCall void setQualifierRange(SourceRange Range) { 133833500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->QualifierRange = Range; 133933500955d731c73717af52088b7fc0e7a85681e7John McCall } 134033500955d731c73717af52088b7fc0e7a85681e7John McCall 134133500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getNameLoc() const { 134233500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->NameLoc; 134333500955d731c73717af52088b7fc0e7a85681e7John McCall } 134433500955d731c73717af52088b7fc0e7a85681e7John McCall void setNameLoc(SourceLocation Loc) { 134533500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->NameLoc = Loc; 134633500955d731c73717af52088b7fc0e7a85681e7John McCall } 134733500955d731c73717af52088b7fc0e7a85681e7John McCall 134833500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getLAngleLoc() const { 134933500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->LAngleLoc; 135033500955d731c73717af52088b7fc0e7a85681e7John McCall } 135133500955d731c73717af52088b7fc0e7a85681e7John McCall void setLAngleLoc(SourceLocation Loc) { 135233500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->LAngleLoc = Loc; 135333500955d731c73717af52088b7fc0e7a85681e7John McCall } 135433500955d731c73717af52088b7fc0e7a85681e7John McCall 135533500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getRAngleLoc() const { 135633500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->RAngleLoc; 135733500955d731c73717af52088b7fc0e7a85681e7John McCall } 135833500955d731c73717af52088b7fc0e7a85681e7John McCall void setRAngleLoc(SourceLocation Loc) { 135933500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->RAngleLoc = Loc; 136033500955d731c73717af52088b7fc0e7a85681e7John McCall } 136133500955d731c73717af52088b7fc0e7a85681e7John McCall 136233500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getNumArgs() const { 136333500955d731c73717af52088b7fc0e7a85681e7John McCall return getTypePtr()->getNumArgs(); 136433500955d731c73717af52088b7fc0e7a85681e7John McCall } 136533500955d731c73717af52088b7fc0e7a85681e7John McCall 136633500955d731c73717af52088b7fc0e7a85681e7John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 136733500955d731c73717af52088b7fc0e7a85681e7John McCall#ifndef NDEBUG 136833500955d731c73717af52088b7fc0e7a85681e7John McCall AI.validateForArgument(getTypePtr()->getArg(i)); 136933500955d731c73717af52088b7fc0e7a85681e7John McCall#endif 137033500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos()[i] = AI; 137133500955d731c73717af52088b7fc0e7a85681e7John McCall } 137233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 137333500955d731c73717af52088b7fc0e7a85681e7John McCall return getArgInfos()[i]; 137433500955d731c73717af52088b7fc0e7a85681e7John McCall } 137533500955d731c73717af52088b7fc0e7a85681e7John McCall 137633500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 137733500955d731c73717af52088b7fc0e7a85681e7John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 137833500955d731c73717af52088b7fc0e7a85681e7John McCall } 137933500955d731c73717af52088b7fc0e7a85681e7John McCall 138033500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getLocalSourceRange() const { 138133500955d731c73717af52088b7fc0e7a85681e7John McCall if (getKeywordLoc().isValid()) 138233500955d731c73717af52088b7fc0e7a85681e7John McCall return SourceRange(getKeywordLoc(), getRAngleLoc()); 138333500955d731c73717af52088b7fc0e7a85681e7John McCall else 138433500955d731c73717af52088b7fc0e7a85681e7John McCall return SourceRange(getQualifierRange().getBegin(), getRAngleLoc()); 138533500955d731c73717af52088b7fc0e7a85681e7John McCall } 138633500955d731c73717af52088b7fc0e7a85681e7John McCall 138733500955d731c73717af52088b7fc0e7a85681e7John McCall void copy(DependentTemplateSpecializationTypeLoc Loc) { 138833500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned size = getFullDataSize(); 138933500955d731c73717af52088b7fc0e7a85681e7John McCall assert(size == Loc.getFullDataSize()); 139033500955d731c73717af52088b7fc0e7a85681e7John McCall memcpy(Data, Loc.Data, size); 139133500955d731c73717af52088b7fc0e7a85681e7John McCall } 139233500955d731c73717af52088b7fc0e7a85681e7John McCall 139333500955d731c73717af52088b7fc0e7a85681e7John McCall void initializeLocal(SourceLocation Loc) { 139433500955d731c73717af52088b7fc0e7a85681e7John McCall setKeywordLoc(Loc); 139533500955d731c73717af52088b7fc0e7a85681e7John McCall setQualifierRange(SourceRange(Loc)); 139633500955d731c73717af52088b7fc0e7a85681e7John McCall setNameLoc(Loc); 139733500955d731c73717af52088b7fc0e7a85681e7John McCall setLAngleLoc(Loc); 139833500955d731c73717af52088b7fc0e7a85681e7John McCall setRAngleLoc(Loc); 139933500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateSpecializationTypeLoc::initializeArgLocs(getNumArgs(), 140033500955d731c73717af52088b7fc0e7a85681e7John McCall getTypePtr()->getArgs(), 140133500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 140233500955d731c73717af52088b7fc0e7a85681e7John McCall } 140333500955d731c73717af52088b7fc0e7a85681e7John McCall 140433500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getExtraLocalDataSize() const { 140533500955d731c73717af52088b7fc0e7a85681e7John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 140633500955d731c73717af52088b7fc0e7a85681e7John McCall } 140733500955d731c73717af52088b7fc0e7a85681e7John McCall 140833500955d731c73717af52088b7fc0e7a85681e7John McCallprivate: 140933500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *getArgInfos() const { 141033500955d731c73717af52088b7fc0e7a85681e7John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 141133500955d731c73717af52088b7fc0e7a85681e7John McCall } 141233500955d731c73717af52088b7fc0e7a85681e7John McCall}; 141333500955d731c73717af52088b7fc0e7a85681e7John McCall 1414b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis} 1415b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1416b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif 1417