TypeLoc.h revision ca63c200346c0ca9e00194ec6e34a5a7b0ed9321
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 { 23c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor class ASTContext; 24b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis class ParmVarDecl; 25a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall class TypeSourceInfo; 2634a0447b8072e0da14c0980597da9d03a1495662John McCall class UnqualTypeLoc; 27b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 2851bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes. 2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base) 3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \ 3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall class Class##TypeLoc; 3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def" 3351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 34b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info. 35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// 36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to 37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information. 38b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc { 39b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected: 4034a0447b8072e0da14c0980597da9d03a1495662John McCall // The correctness of this relies on the property that, for Type *Ty, 4134a0447b8072e0da14c0980597da9d03a1495662John McCall // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty 42f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const void *Ty; 43b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void *Data; 441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 45b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 4651bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum, 4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// except it also defines a Qualified enum that corresponds to the 4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// QualifiedLoc class. 4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall enum TypeLocClass { 5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base) 5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \ 5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall Class = Type::Class, 5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def" 5451bd803fbdade51d674598ed45da3d54190a656cJohn McCall Qualified 5551bd803fbdade51d674598ed45da3d54190a656cJohn McCall }; 5651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 5734a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc() : Ty(0), Data(0) { } 5834a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(QualType ty, void *opaqueData) 5934a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } 60f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall TypeLoc(const Type *ty, void *opaqueData) 6134a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty), Data(opaqueData) { } 62b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 6351bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 64a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor if (getType().hasLocalQualifiers()) return Qualified; 6551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getType()->getTypeClass(); 6651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 6751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 6834a0447b8072e0da14c0980597da9d03a1495662John McCall bool isNull() const { return !Ty; } 6934a0447b8072e0da14c0980597da9d03a1495662John McCall operator bool() const { return Ty; } 70b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of type source info data block for the given type. 72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static unsigned getFullDataSizeForType(QualType Ty); 73b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 74b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the type for which this source info wrapper provides 75b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// information. 7651bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getType() const { 7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return QualType::getFromOpaquePtr(Ty); 7851bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 7934a0447b8072e0da14c0980597da9d03a1495662John McCall 80f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 8134a0447b8072e0da14c0980597da9d03a1495662John McCall return QualType::getFromOpaquePtr(Ty).getTypePtr(); 8234a0447b8072e0da14c0980597da9d03a1495662John McCall } 83b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 84b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis /// \brief Get the pointer where source information is stored. 8551bd803fbdade51d674598ed45da3d54190a656cJohn McCall void *getOpaqueData() const { 8651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Data; 8751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 88b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 89e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the begin source location. 90e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getBeginLoc() const; 91e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 92e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the end source location. 93e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getEndLoc() const; 94e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 95833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the full source range. 96bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getSourceRange() const { 97e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara return SourceRange(getBeginLoc(), getEndLoc()); 98833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 99833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 100833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the local source range. 101bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 102bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara return getLocalSourceRangeImpl(*this); 10351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block. 10634a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 10751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getFullDataSizeForType(getType()); 10834a0447b8072e0da14c0980597da9d03a1495662John McCall } 109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the 111b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// TypeLoc is a PointerLoc and next TypeLoc is for "int". 11251bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLoc getNextTypeLoc() const { 11351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getNextTypeLocImpl(*this); 11451bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 115b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 11634a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Skips past any qualifiers, if this is qualified. 11751bd803fbdade51d674598ed45da3d54190a656cJohn McCall UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header 11834a0447b8072e0da14c0980597da9d03a1495662John McCall 119723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara TypeLoc IgnoreParens() const { 120723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara if (isa<ParenTypeLoc>(this)) 121723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara return IgnoreParensImpl(*this); 122723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara return *this; 123723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara } 124140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara 1254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// \brief Initializes this to state that every location in this 1264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// type is the given location. 1274ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// 1284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// This method exists to provide a simple transition for code that 1294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// relies on location-less types. 130c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initialize(ASTContext &Context, SourceLocation Loc) const { 131c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeImpl(Context, *this, Loc); 1324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1334ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 13445ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// \brief Initializes this by copying its information from another 13545ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// TypeLoc of the same type. 13645ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein void initializeFullCopy(TypeLoc Other) const { 137711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 138711c52bb20d0c69063b52a99826fb7d2835501f1John McCall size_t Size = getFullDataSize(); 139711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 140711c52bb20d0c69063b52a99826fb7d2835501f1John McCall } 141711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 142711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// \brief Initializes this by copying its information from another 143711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// TypeLoc of the same type. The given size must be the full data 144711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// size. 145711c52bb20d0c69063b52a99826fb7d2835501f1John McCall void initializeFullCopy(TypeLoc Other, unsigned Size) const { 146711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 147711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getFullDataSize() == Size); 148711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 14945ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein } 15045ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein 151b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { 152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; 153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) { 156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return !(LHS == RHS); 157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 159b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static bool classof(const TypeLoc *TL) { return true; } 1604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate: 162c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor static void initializeImpl(ASTContext &Context, TypeLoc TL, SourceLocation Loc); 16351bd803fbdade51d674598ed45da3d54190a656cJohn McCall static TypeLoc getNextTypeLocImpl(TypeLoc TL); 164723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara static TypeLoc IgnoreParensImpl(TypeLoc TL); 165bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara static SourceRange getLocalSourceRangeImpl(TypeLoc TL); 166b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 167b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1683c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info. 1693c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const { 1704ab92891a53adda8c52c1947351371da58e33f64Gabor Greif return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); 1713c385c28cf1f27b193a620d2e51f814873362cebJohn McCall} 1723c385c28cf1f27b193a620d2e51f814873362cebJohn McCall 17334a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 174489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers. 17534a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc { 17634a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 17734a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc() {} 178f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {} 17934a0447b8072e0da14c0980597da9d03a1495662John McCall 180f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 181f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall return reinterpret_cast<const Type*>(Ty); 18234a0447b8072e0da14c0980597da9d03a1495662John McCall } 18334a0447b8072e0da14c0980597da9d03a1495662John McCall 18451bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 18551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getTypePtr()->getTypeClass(); 18651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 18751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 18834a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 189a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return !TL->getType().hasLocalQualifiers(); 19034a0447b8072e0da14c0980597da9d03a1495662John McCall } 19134a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const UnqualTypeLoc *TL) { return true; } 19234a0447b8072e0da14c0980597da9d03a1495662John McCall}; 19334a0447b8072e0da14c0980597da9d03a1495662John McCall 19434a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 19534a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers. 19634a0447b8072e0da14c0980597da9d03a1495662John McCall/// 19734a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for 19834a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers. 19951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc { 20034a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 201bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 20234a0447b8072e0da14c0980597da9d03a1495662John McCall return SourceRange(); 20334a0447b8072e0da14c0980597da9d03a1495662John McCall } 20434a0447b8072e0da14c0980597da9d03a1495662John McCall 20534a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc getUnqualifiedLoc() const { 20651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return UnqualTypeLoc(getTypePtr(), Data); 20734a0447b8072e0da14c0980597da9d03a1495662John McCall } 20834a0447b8072e0da14c0980597da9d03a1495662John McCall 2094ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// Initializes the local data of this type source info block to 2104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// provide no information. 211c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 2124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall // do nothing 2134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 2154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 2164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getUnqualifiedLoc(); 2174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 21934a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block that is 22034a0447b8072e0da14c0980597da9d03a1495662John McCall /// specific to this type. 22134a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 22234a0447b8072e0da14c0980597da9d03a1495662John McCall // In fact, we don't currently preserve any location information 22334a0447b8072e0da14c0980597da9d03a1495662John McCall // for qualifiers. 22434a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 22534a0447b8072e0da14c0980597da9d03a1495662John McCall } 22634a0447b8072e0da14c0980597da9d03a1495662John McCall 22734a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block. 22834a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 22934a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalDataSize() + 230fa1a06e80706846fa15e0bd44671bdc3dfc53d84Douglas Gregor getFullDataSizeForType(getType().getLocalUnqualifiedType()); 23134a0447b8072e0da14c0980597da9d03a1495662John McCall } 23234a0447b8072e0da14c0980597da9d03a1495662John McCall 23334a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 234a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return TL->getType().hasLocalQualifiers(); 23534a0447b8072e0da14c0980597da9d03a1495662John McCall } 23651bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const QualifiedTypeLoc *TL) { return true; } 23734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 23834a0447b8072e0da14c0980597da9d03a1495662John McCall 23934a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { 24051bd803fbdade51d674598ed45da3d54190a656cJohn McCall if (isa<QualifiedTypeLoc>(this)) 24151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc(); 24234a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<UnqualTypeLoc>(*this); 24334a0447b8072e0da14c0980597da9d03a1495662John McCall} 24434a0447b8072e0da14c0980597da9d03a1495662John McCall 24534a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond 246f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass. It is accepted for a single 247f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes. 24834a0447b8072e0da14c0980597da9d03a1495662John McCall/// 24934a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Base a class from which to derive 25034a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Derived the class deriving from this one 251f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// \param TypeClass the concrete Type subclass associated with this 252f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// location type 25334a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param LocalData the structure type of local location data for 25434a0447b8072e0da14c0980597da9d03a1495662John McCall/// this type 25534a0447b8072e0da14c0980597da9d03a1495662John McCall/// 25634a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or 25734a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end. 25834a0447b8072e0da14c0980597da9d03a1495662John McCall/// 25934a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override 26034a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to 26134a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory. 26234a0447b8072e0da14c0980597da9d03a1495662John McCall/// 263a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define 264a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// QualType getInnerType() const 265a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's 266a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data. 26751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// 26851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be 26951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy. It is also not 27051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide 27151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information. It should be subclassed 27251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children 27351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type, 27451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from 27551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead. 27634a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData> 27734a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base { 27834a0447b8072e0da14c0980597da9d03a1495662John McCall 27934a0447b8072e0da14c0980597da9d03a1495662John McCall const Derived *asDerived() const { 28034a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<const Derived*>(this); 28134a0447b8072e0da14c0980597da9d03a1495662John McCall } 28234a0447b8072e0da14c0980597da9d03a1495662John McCall 28334a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 28434a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 28534a0447b8072e0da14c0980597da9d03a1495662John McCall return sizeof(LocalData) + asDerived()->getExtraLocalDataSize(); 28634a0447b8072e0da14c0980597da9d03a1495662John McCall } 28734a0447b8072e0da14c0980597da9d03a1495662John McCall // Give a default implementation that's useful for leaf types. 28834a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 28934a0447b8072e0da14c0980597da9d03a1495662John McCall return asDerived()->getLocalDataSize() + getInnerTypeSize(); 29034a0447b8072e0da14c0980597da9d03a1495662John McCall } 29134a0447b8072e0da14c0980597da9d03a1495662John McCall 29234a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classofType(const Type *Ty) { 29334a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeClass::classof(Ty); 29434a0447b8072e0da14c0980597da9d03a1495662John McCall } 29534a0447b8072e0da14c0980597da9d03a1495662John McCall 296e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const TypeLoc *TL) { 297e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 298e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 299e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const UnqualTypeLoc *TL) { 300e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 301e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 302e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const Derived *TL) { 303e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return true; 304e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 305e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 3064ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 3074ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getNextTypeLoc(asDerived()->getInnerType()); 3084ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3094ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 310f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 31151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 31234a0447b8072e0da14c0980597da9d03a1495662John McCall } 31334a0447b8072e0da14c0980597da9d03a1495662John McCall 31451bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected: 31534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 31634a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 31734a0447b8072e0da14c0980597da9d03a1495662John McCall } 31834a0447b8072e0da14c0980597da9d03a1495662John McCall 31934a0447b8072e0da14c0980597da9d03a1495662John McCall LocalData *getLocalData() const { 32034a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<LocalData*>(Base::Data); 32134a0447b8072e0da14c0980597da9d03a1495662John McCall } 32234a0447b8072e0da14c0980597da9d03a1495662John McCall 32334a0447b8072e0da14c0980597da9d03a1495662John McCall /// Gets a pointer past the Info structure; useful for classes with 32434a0447b8072e0da14c0980597da9d03a1495662John McCall /// local data that can't be captured in the Info (e.g. because it's 32534a0447b8072e0da14c0980597da9d03a1495662John McCall /// of variable size). 32634a0447b8072e0da14c0980597da9d03a1495662John McCall void *getExtraLocalData() const { 32734a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData() + 1; 32834a0447b8072e0da14c0980597da9d03a1495662John McCall } 32934a0447b8072e0da14c0980597da9d03a1495662John McCall 33034a0447b8072e0da14c0980597da9d03a1495662John McCall void *getNonLocalData() const { 33134a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize(); 33234a0447b8072e0da14c0980597da9d03a1495662John McCall } 33334a0447b8072e0da14c0980597da9d03a1495662John McCall 334a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall struct HasNoInnerType {}; 335a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall HasNoInnerType getInnerType() const { return HasNoInnerType(); } 33634a0447b8072e0da14c0980597da9d03a1495662John McCall 33734a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc getInnerTypeLoc() const { 33834a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); 33934a0447b8072e0da14c0980597da9d03a1495662John McCall } 34034a0447b8072e0da14c0980597da9d03a1495662John McCall 34134a0447b8072e0da14c0980597da9d03a1495662John McCallprivate: 34234a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getInnerTypeSize() const { 343a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeSize(asDerived()->getInnerType()); 344a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall } 345a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall 346a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(HasNoInnerType _) const { 34734a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 34834a0447b8072e0da14c0980597da9d03a1495662John McCall } 34934a0447b8072e0da14c0980597da9d03a1495662John McCall 350a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(QualType _) const { 351a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeLoc().getFullDataSize(); 35234a0447b8072e0da14c0980597da9d03a1495662John McCall } 3534ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3544ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(HasNoInnerType _) const { 3554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(); 3564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3574ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(QualType T) const { 3594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(T, getNonLocalData()); 3604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 36134a0447b8072e0da14c0980597da9d03a1495662John McCall}; 36234a0447b8072e0da14c0980597da9d03a1495662John McCall 36351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract 36451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source 36551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information. See the note on ConcreteTypeLoc. 36651bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass> 36751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base { 368b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 369713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor static bool classofType(const Type *Ty) { 370713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor return TypeClass::classof(Ty); 371713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor } 372713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor 37351bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const TypeLoc *TL) { 37451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 375b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 37651bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const UnqualTypeLoc *TL) { 37751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 378b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 37951bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const Derived *TL) { 38051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return true; 381b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 382b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 383f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 38451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 3854ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 38634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 387b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 388ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 38951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo { 39034a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation NameLoc; 391b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 392b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 39351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to 39451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier. 395ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 396ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc, 397ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Type, 398ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecLocInfo> { 399b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 400ed97649e9574b9d854fa4d6109c9333ae0993554John McCall enum { LocalDataSize = sizeof(TypeSpecLocInfo) }; 401ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 402b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getNameLoc() const { 40351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->NameLoc; 404b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 405b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setNameLoc(SourceLocation Loc) { 40651bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->NameLoc = Loc; 407b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 408bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 409b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getNameLoc(), getNameLoc()); 410b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 411c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 4124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setNameLoc(Loc); 4134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 414ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 415ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeLoc *TL); 416ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeSpecTypeLoc *TL) { return true; } 41751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 4184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 419ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 420ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo { 421ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation BuiltinLoc; 422ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 423ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 424ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types. 425ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 426ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc, 427ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType, 428ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinLocInfo> { 429ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic: 430ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor enum { LocalDataSize = sizeof(BuiltinLocInfo) }; 431ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 432ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getBuiltinLoc() const { 433ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getLocalData()->BuiltinLoc; 434ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 435ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setBuiltinLoc(SourceLocation Loc) { 436ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getLocalData()->BuiltinLoc = Loc; 437ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 438ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 439ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getNameLoc() const { return getBuiltinLoc(); } 440ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 441ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs& getWrittenBuiltinSpecs() { 442ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 443ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 444ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { 445ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 446ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 447ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 448ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool needsExtraLocalData() const { 449ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType::Kind bk = getTypePtr()->getKind(); 450ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) 451d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble) 452ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::UChar 453ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::SChar; 454ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 455ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 456ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor unsigned getExtraLocalDataSize() const { 457d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; 458ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 459ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 460bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 461ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return SourceRange(getBuiltinLoc(), getBuiltinLoc()); 462ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 463ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 464ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierSign getWrittenSignSpec() const { 465ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 466ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); 467ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 468ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSS_unspecified; 469ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 470ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenSignSpec() const { 471ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenSignSpec() != TSS_unspecified; 472ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 473ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenSignSpec(TypeSpecifierSign written) { 474ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 475ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Sign = written; 476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierWidth getWrittenWidthSpec() const { 479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); 481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSW_unspecified; 483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenWidthSpec() const { 485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenWidthSpec() != TSW_unspecified; 486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenWidthSpec(TypeSpecifierWidth written) { 488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Width = written; 490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierType getWrittenTypeSpec() const; 493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenTypeSpec() const { 494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenTypeSpec() != TST_unspecified; 495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 496ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenTypeSpec(TypeSpecifierType written) { 497ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 498ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Type = written; 499ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 500ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 501ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasModeAttr() const { 502ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 503ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenBuiltinSpecs().ModeAttr; 504ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 505ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return false; 506ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 507ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setModeAttr(bool written) { 508ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 509ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().ModeAttr = written; 510ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 511ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 512c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor setBuiltinLoc(Loc); 514ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) { 515ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); 516ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Sign = TSS_unspecified; 517ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Width = TSW_unspecified; 518ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Type = TST_unspecified; 519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.ModeAttr = false; 520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 524ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 52551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs. 526ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 527ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefTypeLoc, 528ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefType> { 52951bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 530162e1c1b487352434552147967c3dd296ebee2f7Richard Smith TypedefNameDecl *getTypedefNameDecl() const { 53134a0447b8072e0da14c0980597da9d03a1495662John McCall return getTypePtr()->getDecl(); 5329036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis } 53334a0447b8072e0da14c0980597da9d03a1495662John McCall}; 5349036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis 5353cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class 5363cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates. 5373cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc : 5383cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 5393cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameTypeLoc, 5403cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameType> { 5413cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall}; 5423cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 543ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls. 544ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc : 545ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 546ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypeLoc, 547ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType> { 548ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 549ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypenameDecl *getDecl() const { 550ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return getTypePtr()->getDecl(); 551ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 552ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 553ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 554ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types. Note that this only 555ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo' 556ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc. We currently 557ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of 558ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C. 559ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 560ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagTypeLoc, 561ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagType> { 562ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 563ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagDecl *getDecl() const { return getTypePtr()->getDecl(); } 564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 565ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 566ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types. 567ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 568ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordTypeLoc, 569ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordType> { 570ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 571ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordDecl *getDecl() const { return getTypePtr()->getDecl(); } 572ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 573ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 574ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types. 575ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 576ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumTypeLoc, 577ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumType> { 578ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 579ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumDecl *getDecl() const { return getTypePtr()->getDecl(); } 580ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 581b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 58249a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters. 583ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc : 584ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 585ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmTypeLoc, 586ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmType> { 587960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruthpublic: 588960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruth TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } 58949a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 59049a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 59149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters. 59249a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc : 593ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 594ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmTypeLoc, 595ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmType> { 59649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 59751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 598c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor /// \brief Wrapper for substituted template type parameters. 599c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc : 600c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 601c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackTypeLoc, 602c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackType> { 603c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor}; 604c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor 6059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo { 6069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall union { 6079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *ExprOperand; 6089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// A raw SourceLocation. 6109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall unsigned EnumOperandLoc; 6119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall }; 6129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange OperandParens; 6149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation AttrLoc; 6169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 6179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type. 6199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 6209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc, 6219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType, 6229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedLocInfo> { 6239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic: 6249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType::Kind getAttrKind() const { 6259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getAttrKind(); 6269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrExprOperand() const { 6299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstExprOperandKind && 6309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastExprOperandKind); 6319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrEnumOperand() const { 6349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstEnumOperandKind && 6359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastEnumOperandKind); 6369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrOperand() const { 6399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return hasAttrExprOperand() || hasAttrEnumOperand(); 6409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The modified type, which is generally canonically different from 6439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// the attribute type. 6449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// int main(int, char**) __attribute__((noreturn)) 6459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ~~~ ~~~~~~~~~~~~~ 6469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall TypeLoc getModifiedLoc() const { 6479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getInnerTypeLoc(); 6489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute name, i.e. 6519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// __attribute__((regparm(1000))) 6529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~~~~ 6539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrNameLoc() const { 6549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->AttrLoc; 6559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrNameLoc(SourceLocation loc) { 6579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->AttrLoc = loc; 6589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The attribute's expression operand, if it has one. 6619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void *cur_thread __attribute__((address_space(21))) 6629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~ 6639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *getAttrExprOperand() const { 6649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 6659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->ExprOperand; 6669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrExprOperand(Expr *e) { 6689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 6699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->ExprOperand = e; 6709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute's enumerated operand, if it has one. 6739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~ 6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrEnumOperandLoc() const { 6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc); 6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrEnumOperandLoc(SourceLocation loc) { 6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->EnumOperandLoc = loc.getRawEncoding(); 6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the parentheses around the operand, if there is 6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// an operand. 6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^ ^ 6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getAttrOperandParensRange() const { 6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->OperandParens; 6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrOperandParensRange(SourceRange range) { 6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->OperandParens = range; 6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getLocalSourceRange() const { 6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // Note that this does *not* include the range of the attribute 6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // enclosure, e.g.: 7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // __attribute__((foo(bar))) 7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~~~~~~~~~~~~~~ ~~ 7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // or 7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // [[foo(bar)]] 7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~ ~~ 7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // That enclosure doesn't necessarily belong to a single attribute 7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // anyway. 7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange range(getAttrNameLoc()); 7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrOperand()) 7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall range.setEnd(getAttrOperandParensRange().getEnd()); 7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return range; 7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 713c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation loc) { 7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrNameLoc(loc); 7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrExprOperand()) { 7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrExprOperand(0); 7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } else if (hasAttrEnumOperand()) { 7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrEnumOperandLoc(loc); 7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType getInnerType() const { 7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getModifiedType(); 7269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 7289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 729eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 73034a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo { 73154e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation LAngleLoc; 73254e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation RAngleLoc; 733ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall bool HasBaseTypeAsWritten; 734eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis}; 735eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 73654e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with 73754e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols. 73854e14c4db764c0636160d26c5bbf491637c83a76John McCall// 73954e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or 74054e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType. 741c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 742c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectTypeLoc, 743c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectType, 744c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCProtocolListLocInfo> { 745f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis // SourceLocations are stored after Info, one for each Protocol. 746f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation *getProtocolLocArray() const { 74754e14c4db764c0636160d26c5bbf491637c83a76John McCall return (SourceLocation*) this->getExtraLocalData(); 74854e14c4db764c0636160d26c5bbf491637c83a76John McCall } 74954e14c4db764c0636160d26c5bbf491637c83a76John McCall 750f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic: 751f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getLAngleLoc() const { 75254e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->LAngleLoc; 753f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 754f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setLAngleLoc(SourceLocation Loc) { 75554e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->LAngleLoc = Loc; 756f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 757f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 758f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getRAngleLoc() const { 75954e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->RAngleLoc; 760f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 761f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setRAngleLoc(SourceLocation Loc) { 76254e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->RAngleLoc = Loc; 763f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 764f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 765f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis unsigned getNumProtocols() const { 76654e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getTypePtr()->getNumProtocols(); 767f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 768f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 769f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getProtocolLoc(unsigned i) const { 770f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 771f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return getProtocolLocArray()[i]; 772f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 773f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setProtocolLoc(unsigned i, SourceLocation Loc) { 774f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 775f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis getProtocolLocArray()[i] = Loc; 776f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 777f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 778f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis ObjCProtocolDecl *getProtocol(unsigned i) const { 779f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 78054e14c4db764c0636160d26c5bbf491637c83a76John McCall return *(this->getTypePtr()->qual_begin() + i); 781f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 782f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 783c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall bool hasBaseTypeAsWritten() const { 784ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall return getLocalData()->HasBaseTypeAsWritten; 785c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 786c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 787c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setHasBaseTypeAsWritten(bool HasBaseType) { 788ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall getLocalData()->HasBaseTypeAsWritten = HasBaseType; 789c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 790c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 791c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TypeLoc getBaseLoc() const { 792c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getInnerTypeLoc(); 793c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 794c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 795bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 796f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return SourceRange(getLAngleLoc(), getRAngleLoc()); 797f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 798f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 799c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 800ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall setHasBaseTypeAsWritten(true); 801c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setLAngleLoc(Loc); 802c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setRAngleLoc(Loc); 803c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall for (unsigned i = 0, e = getNumProtocols(); i != e; ++i) 804c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setProtocolLoc(i, Loc); 8054ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 8064ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 80734a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 80854e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getNumProtocols() * sizeof(SourceLocation); 80954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 810c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 811c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall QualType getInnerType() const { 812c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getTypePtr()->getBaseType(); 813c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 81454e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 81554e14c4db764c0636160d26c5bbf491637c83a76John McCall 81654e14c4db764c0636160d26c5bbf491637c83a76John McCall 817c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo { 81854e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation NameLoc; 81954e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 82054e14c4db764c0636160d26c5bbf491637c83a76John McCall 82154e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces. 822a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc, 823c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceTypeLoc, 824c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceType, 825c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceLocInfo> { 82654e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 82754e14c4db764c0636160d26c5bbf491637c83a76John McCall ObjCInterfaceDecl *getIFaceDecl() const { 82854e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getDecl(); 82954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 83054e14c4db764c0636160d26c5bbf491637c83a76John McCall 83154e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation getNameLoc() const { 83254e14c4db764c0636160d26c5bbf491637c83a76John McCall return getLocalData()->NameLoc; 83354e14c4db764c0636160d26c5bbf491637c83a76John McCall } 83454e14c4db764c0636160d26c5bbf491637c83a76John McCall 83554e14c4db764c0636160d26c5bbf491637c83a76John McCall void setNameLoc(SourceLocation Loc) { 83654e14c4db764c0636160d26c5bbf491637c83a76John McCall getLocalData()->NameLoc = Loc; 83754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 83854e14c4db764c0636160d26c5bbf491637c83a76John McCall 839bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 840c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return SourceRange(getNameLoc()); 84154e14c4db764c0636160d26c5bbf491637c83a76John McCall } 84254e14c4db764c0636160d26c5bbf491637c83a76John McCall 843c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 84454e14c4db764c0636160d26c5bbf491637c83a76John McCall setNameLoc(Loc); 845f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 84654e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 84754e14c4db764c0636160d26c5bbf491637c83a76John McCall 848075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo { 849075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation LParenLoc; 850075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation RParenLoc; 851075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 852075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 853075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc 854075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType, 855075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenLocInfo> { 856075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic: 857075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getLParenLoc() const { 858075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->LParenLoc; 859075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 860075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getRParenLoc() const { 861075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->RParenLoc; 862075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 863075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setLParenLoc(SourceLocation Loc) { 864075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->LParenLoc = Loc; 865075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 866075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setRParenLoc(SourceLocation Loc) { 867075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->RParenLoc = Loc; 868075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 869075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 870075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceRange getLocalSourceRange() const { 871075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 872075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 873075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 874c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 875075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setLParenLoc(Loc); 876075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setRParenLoc(Loc); 877075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 878075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 879075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara TypeLoc getInnerLoc() const { 880075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return getInnerTypeLoc(); 881075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 882075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 883075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType getInnerType() const { 884075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getTypePtr()->getInnerType(); 885075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 886075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 887075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 888f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 88951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo { 89034a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation StarLoc; 891f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis}; 892f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 89351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A base class for 89451bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> 89551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, 89651bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass, LocalData> { 897bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallpublic: 89851bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getSigilLoc() const { 89951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->StarLoc; 900b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 90151bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setSigilLoc(SourceLocation Loc) { 90251bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->StarLoc = Loc; 903b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 904b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 905b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getPointeeLoc() const { 90651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getInnerTypeLoc(); 907b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 908b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 909bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 91051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return SourceRange(getSigilLoc(), getSigilLoc()); 911b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 912b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 913c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 91451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 9154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 9164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 91751bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getInnerType() const { 91851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getTypePtr()->getPointeeType(); 91951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 92034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 921b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 922b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 92351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers. 92451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc, 92551bd803fbdade51d674598ed45da3d54190a656cJohn McCall PointerType> { 92651bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 92751bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getStarLoc() const { 92851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 92951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 93051bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setStarLoc(SourceLocation Loc) { 93151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 93251bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 933b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 934b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 93551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 936b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers. 93751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc, 93851bd803fbdade51d674598ed45da3d54190a656cJohn McCall BlockPointerType> { 939b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 940b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getCaretLoc() const { 94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 942b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 943b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setCaretLoc(SourceLocation Loc) { 94451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 945b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 94634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 947b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 948b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnarastruct MemberPointerLocInfo : public PointerLikeLocInfo { 949b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *ClassTInfo; 950b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara}; 951b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 952b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers. 95351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc, 954b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerType, 955b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerLocInfo> { 956b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 957b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getStarLoc() const { 95851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 959b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 960b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setStarLoc(SourceLocation Loc) { 96151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 9624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 963b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 964b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara const Type *getClass() const { 965b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getTypePtr()->getClass(); 966b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 967b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *getClassTInfo() const { 968b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getLocalData()->ClassTInfo; 969b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 970b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void setClassTInfo(TypeSourceInfo* TI) { 971b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara getLocalData()->ClassTInfo = TI; 972b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 973b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 974b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void initializeLocal(ASTContext &Context, SourceLocation Loc) { 975b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setSigilLoc(Loc); 976b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setClassTInfo(0); 977b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 978b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 979b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara SourceRange getLocalSourceRange() const { 980b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara if (TypeSourceInfo *TI = getClassTInfo()) 981b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc()); 982b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara else 983b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(getStarLoc()); 984b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 98534a0447b8072e0da14c0980597da9d03a1495662John McCall}; 986b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 987c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information. 988c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc : 989c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc, 990c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerType> { 991c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic: 992c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall SourceLocation getStarLoc() const { 993c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getSigilLoc(); 994c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 995c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 996c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setStarLoc(SourceLocation Loc) { 997c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setSigilLoc(Loc); 998c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 999c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall}; 1000c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1001b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 100251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc, 100351bd803fbdade51d674598ed45da3d54190a656cJohn McCall ReferenceType> { 100454e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 100554e14c4db764c0636160d26c5bbf491637c83a76John McCall QualType getInnerType() const { 100654e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getPointeeTypeAsWritten(); 100754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 1008b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1009b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1010bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc : 1011bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1012bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceTypeLoc, 1013bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceType> { 1014b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1015b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getAmpLoc() const { 101651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1017b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1018b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setAmpLoc(SourceLocation Loc) { 101951bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1020b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 102151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1022b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1023bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc : 1024bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1025bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceTypeLoc, 1026bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceType> { 102751bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 102851bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getAmpAmpLoc() const { 102951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1030b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 103151bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setAmpAmpLoc(SourceLocation Loc) { 103251bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1033b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 103451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1035b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1036b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 103734a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo { 1038796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeBegin; 1039796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeEnd; 1040dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor bool TrailingReturn; 1041b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1042b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1043b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions. 104451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 104551bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionTypeLoc, 104651bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionType, 104751bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionLocInfo> { 1048b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1049796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeBegin() const { 1050796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeBegin; 1051b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1052796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeBegin(SourceLocation L) { 1053796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeBegin = L; 1054b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1055b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1056796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeEnd() const { 1057796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeEnd; 1058b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1059796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeEnd(SourceLocation L) { 1060796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeEnd = L; 1061b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1062b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1063dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor bool getTrailingReturn() const { 1064dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor return getLocalData()->TrailingReturn; 1065dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor } 1066dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor void setTrailingReturn(bool Trailing) { 1067dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor getLocalData()->TrailingReturn = Trailing; 1068dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor } 1069dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 1070a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor // ParmVarDecls* are stored after Info, one for each argument. 1071a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **getParmArray() const { 1072a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor return (ParmVarDecl**) getExtraLocalData(); 1073a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor } 1074a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor 1075b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis unsigned getNumArgs() const { 107634a0447b8072e0da14c0980597da9d03a1495662John McCall if (isa<FunctionNoProtoType>(getTypePtr())) 1077b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return 0; 107834a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<FunctionProtoType>(getTypePtr())->getNumArgs(); 1079b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1080b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; } 1081b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } 1082b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1083b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getResultLoc() const { 108434a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1085b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1086b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1087bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1088796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return SourceRange(getLocalRangeBegin(), getLocalRangeEnd()); 1089b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1090b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1091c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1092796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeBegin(Loc); 1093796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeEnd(Loc); 1094dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor setTrailingReturn(false); 10954ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall for (unsigned i = 0, e = getNumArgs(); i != e; ++i) 10964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setArg(i, NULL); 10974ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 10984ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1099b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block that is 1100b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// specific to this type. 110134a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 110234a0447b8072e0da14c0980597da9d03a1495662John McCall return getNumArgs() * sizeof(ParmVarDecl*); 1103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 110534a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getResultType(); } 110634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 110734a0447b8072e0da14c0980597da9d03a1495662John McCall 110851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc : 110951bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 111051bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoTypeLoc, 111151bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoType> { 111251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 111351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 111451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc : 111551bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 111651bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoTypeLoc, 111751bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoType> { 111851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 111951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1120b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 112134a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo { 112234a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LBracketLoc, RBracketLoc; 112334a0447b8072e0da14c0980597da9d03a1495662John McCall Expr *Size; 1124b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1125b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1126b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays. 112751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 112851bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayTypeLoc, 112951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayType, 113051bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayLocInfo> { 1131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLBracketLoc() const { 113334a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LBracketLoc; 1134b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1135b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLBracketLoc(SourceLocation Loc) { 113634a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LBracketLoc = Loc; 1137b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1138b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1139b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRBracketLoc() const { 114034a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RBracketLoc; 1141b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1142b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRBracketLoc(SourceLocation Loc) { 114334a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RBracketLoc = Loc; 1144b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1145b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 114685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange getBracketsRange() const { 114785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return SourceRange(getLBracketLoc(), getRBracketLoc()); 114885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 114985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 1150b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis Expr *getSizeExpr() const { 115134a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->Size; 1152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setSizeExpr(Expr *Size) { 115434a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->Size = Size; 1155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getElementLoc() const { 115834a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1159b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1160b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1161bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1162b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLBracketLoc(), getRBracketLoc()); 1163b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1164b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1165c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 11664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLBracketLoc(Loc); 11674ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRBracketLoc(Loc); 11684ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setSizeExpr(NULL); 11694ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 11704ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 117134a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getElementType(); } 1172b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1173b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 117451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc : 117551bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 117651bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayTypeLoc, 117751bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayType> { 117851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 117951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 118051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc : 118151bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 118251bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayTypeLoc, 118351bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayType> { 118451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 118551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 118651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc : 118751bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 118851bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayTypeLoc, 118951bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayType> { 119051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 119151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 119251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 119351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc : 119451bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 119551bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayTypeLoc, 119651bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayType> { 119751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 119851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1199833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1200833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName. Rudimentary for now. 1201833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo { 1202833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation NameLoc; 1203833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1204833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1205833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo { 1206833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc; 1207833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation RAngleLoc; 1208833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1209833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1210833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc : 1211833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall public ConcreteTypeLoc<UnqualTypeLoc, 1212833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc, 1213833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationType, 1214833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationLocInfo> { 1215833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic: 1216833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getLAngleLoc() const { 1217833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->LAngleLoc; 1218833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1219833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setLAngleLoc(SourceLocation Loc) { 1220833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->LAngleLoc = Loc; 1221833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1222833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1223833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getRAngleLoc() const { 1224833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->RAngleLoc; 1225833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1226833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setRAngleLoc(SourceLocation Loc) { 1227833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->RAngleLoc = Loc; 1228833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1229833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1230833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getNumArgs() const { 1231833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getTypePtr()->getNumArgs(); 1232833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1233833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 1234833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getArgInfos()[i] = AI; 1235833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1236833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 1237833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getArgInfos()[i]; 1238833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1239833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1240833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 1241833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 1242833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1243833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1244833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getTemplateNameLoc() const { 1245833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->NameLoc; 1246833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1247833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setTemplateNameLoc(SourceLocation Loc) { 1248833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->NameLoc = Loc; 1249833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1250833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1251833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief - Copy the location information from the given info. 1252833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void copy(TemplateSpecializationTypeLoc Loc) { 1253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned size = getFullDataSize(); 1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall assert(size == Loc.getFullDataSize()); 1255833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1256833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // We're potentially copying Expr references here. We don't 1257a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall // bother retaining them because TypeSourceInfos live forever, so 1258833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // as long as the Expr was retained when originally written into 1259833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // the TypeLoc, we're okay. 1260833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall memcpy(Data, Loc.Data, size); 1261833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1262833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1263bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1264833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 1265833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1266833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1267c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1268833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setLAngleLoc(Loc); 1269833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setRAngleLoc(Loc); 1270833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setTemplateNameLoc(Loc); 1271c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(), 127233500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 127333500955d731c73717af52088b7fc0e7a85681e7John McCall } 1274833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1275c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, 127633500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgument *Args, 127733500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *ArgInfos, 1278c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor SourceLocation Loc); 1279833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1280833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getExtraLocalDataSize() const { 1281833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 1282833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1283833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1284833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate: 1285833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo *getArgInfos() const { 1286833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 1287833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1288833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1289833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1290ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 1291ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1292ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// All of these need proper implementations. 1293ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1294ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 129551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1296ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we 1297ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax). 1298ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1299ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorTypeLoc, 1300ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorType> { 130151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 130251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1303ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations. 130451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc, 130551bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorTypeLoc, 130651bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorType> { 130751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 130851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1309ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations. 131051bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType. 131151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc : 1312ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1313ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorTypeLoc, 1314ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorType> { 131551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 131651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1317ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword. 1318ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1319ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexTypeLoc, 1320ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexType> { 132151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 132251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1323cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo { 1324cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation TypeofLoc; 1325cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation LParenLoc; 1326cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation RParenLoc; 132751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 132851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1329cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo { 1330cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1331cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1332cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo { 1333cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* UnderlyingTInfo; 1334cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1335cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1336cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo> 1337cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc 1338cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { 1339cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1340cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getTypeofLoc() const { 1341cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->TypeofLoc; 1342cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1343cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setTypeofLoc(SourceLocation Loc) { 1344cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->TypeofLoc = Loc; 1345cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1346cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1347cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getLParenLoc() const { 1348cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->LParenLoc; 1349cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1350cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setLParenLoc(SourceLocation Loc) { 1351cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->LParenLoc = Loc; 1352cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1353cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1354cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getRParenLoc() const { 1355cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->RParenLoc; 1356cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1357cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setRParenLoc(SourceLocation Loc) { 1358cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->RParenLoc = Loc; 1359cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1360cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1361cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceRange getParensRange() const { 1362cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getLParenLoc(), getRParenLoc()); 1363cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1364cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setParensRange(SourceRange range) { 1365cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(range.getBegin()); 1366cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(range.getEnd()); 1367cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1368cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1369bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1370cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getTypeofLoc(), getRParenLoc()); 1371cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1372cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1373c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1374cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setTypeofLoc(Loc); 1375cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(Loc); 1376cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(Loc); 1377cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1378cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1379cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1380cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, 1381cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprType, 1382cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprTypeLocInfo> { 1383cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1384cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Expr* getUnderlyingExpr() const { 1385cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return getTypePtr()->getUnderlyingExpr(); 1386cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1387cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // Reimplemented to account for GNU/C++ extension 1388cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // typeof unary-expression 1389cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // where there are no parentheses. 1390bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const; 1391cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1392cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1393cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc 1394cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { 1395cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1396cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall QualType getUnderlyingType() const { 1397cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getTypePtr()->getUnderlyingType(); 1398cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1399cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* getUnderlyingTInfo() const { 1400cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->UnderlyingTInfo; 1401cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1402cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setUnderlyingTInfo(TypeSourceInfo* TI) const { 1403cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->UnderlyingTInfo = TI; 1404cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 140551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 140651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1407ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens. 1408ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1409ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeTypeLoc, 1410ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeType> { 141151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 141251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1413ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntstruct UnaryTransformTypeLocInfo { 1414ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // FIXME: While there's only one unary transform right now, future ones may 1415ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // need different representations 1416ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation KWLoc, LParenLoc, RParenLoc; 1417ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo *UnderlyingTInfo; 1418ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1419ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1420ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntclass UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1421ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLoc, 1422ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformType, 1423ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLocInfo> { 1424ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntpublic: 1425ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getKWLoc() const { return getLocalData()->KWLoc; } 1426ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; } 1427ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1428ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; } 1429ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; } 1430ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1431ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; } 1432ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; } 1433ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1434ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo* getUnderlyingTInfo() const { 1435ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return getLocalData()->UnderlyingTInfo; 1436ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1437ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setUnderlyingTInfo(TypeSourceInfo *TInfo) { 1438ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt getLocalData()->UnderlyingTInfo = TInfo; 1439ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1440ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1441ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getLocalSourceRange() const { 1442ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getKWLoc(), getRParenLoc()); 1443ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1444ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1445ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getParensRange() const { 1446ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getLParenLoc(), getRParenLoc()); 1447ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1448ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setParensRange(SourceRange Range) { 1449ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Range.getBegin()); 1450ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Range.getEnd()); 1451ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1452ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1453ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1454ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setKWLoc(Loc); 1455ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Loc); 1456ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Loc); 1457ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1458ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1459ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 146034b41d939a1328f484511c6002ba2456db879a29Richard Smithclass AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 146134b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoTypeLoc, 146234b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoType> { 146334b41d939a1328f484511c6002ba2456db879a29Richard Smith}; 146434b41d939a1328f484511c6002ba2456db879a29Richard Smith 1465e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo { 1466e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation KeywordLoc; 14679e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor 14689e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor /// \brief Opaque data pointer used to reconstruct a nested-name-specifier 14699e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor /// from 14709e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void *QualifierData; 1471e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1472e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1473e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1474e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc, 1475e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedType, 1476e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedLocInfo> { 1477e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 1478e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getKeywordLoc() const { 1479e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->KeywordLoc; 1480e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1481e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setKeywordLoc(SourceLocation Loc) { 1482e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->KeywordLoc = Loc; 1483e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1484e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 14859e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 14869e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 14879e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData); 1488e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 14899e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor 14909e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 14919e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor assert(QualifierLoc.getNestedNameSpecifier() 14929e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor == getTypePtr()->getQualifier() && 14939e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor "Inconsistent nested-name-specifier pointer"); 14949e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1495e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1496e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1497bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1498e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (getKeywordLoc().isValid()) 14999e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor if (getQualifierLoc()) 15009e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return SourceRange(getKeywordLoc(), getQualifierLoc().getEndLoc()); 1501e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 1502e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getKeywordLoc()); 1503e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 15049e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return getQualifierLoc().getSourceRange(); 1505e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1506e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15079e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 1508e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1509e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara TypeLoc getNamedTypeLoc() const { 1510e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getInnerTypeLoc(); 1511e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1512e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1513e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType getInnerType() const { 1514e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getTypePtr()->getNamedType(); 1515e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1516e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1517e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(ElaboratedTypeLoc Loc) { 1518e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1519e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1520e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1521e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 152251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 152351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 152433500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 152533500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc. 152633500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo { 1527e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation NameLoc; 15282494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor 15292494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor /// \brief Data associated with the nested-name-specifier location. 15302494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void *QualifierData; 1531e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1532e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1533e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1534e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc, 1535e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameType, 1536e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameLocInfo> { 1537e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 1538e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getKeywordLoc() const { 1539e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->KeywordLoc; 1540e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1541e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setKeywordLoc(SourceLocation Loc) { 1542e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->KeywordLoc = Loc; 1543e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1544e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15452494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 15462494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 15472494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData); 1548e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 15492494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor 15502494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 15512494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor assert(QualifierLoc.getNestedNameSpecifier() 15522494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor == getTypePtr()->getQualifier() && 15532494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor "Inconsistent nested-name-specifier pointer"); 15542494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1555e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 15562494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor 1557e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getNameLoc() const { 1558e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->NameLoc; 1559e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1560e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setNameLoc(SourceLocation Loc) { 1561e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->NameLoc = Loc; 1562e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1563e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1564bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1565e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (getKeywordLoc().isValid()) 1566e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SourceRange(getKeywordLoc(), getNameLoc()); 1567e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 15682494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc()); 1569e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1570e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1571e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(DependentNameTypeLoc Loc) { 1572e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1573e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1574e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1575e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1576e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15772494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 157851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 157951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 158094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregorstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { 15819e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor SourceLocation KeywordLoc; 158233500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation LAngleLoc; 158333500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation RAngleLoc; 158433500955d731c73717af52088b7fc0e7a85681e7John McCall // followed by a TemplateArgumentLocInfo[] 158533500955d731c73717af52088b7fc0e7a85681e7John McCall}; 158633500955d731c73717af52088b7fc0e7a85681e7John McCall 158733500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc : 158833500955d731c73717af52088b7fc0e7a85681e7John McCall public ConcreteTypeLoc<UnqualTypeLoc, 158933500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationTypeLoc, 159033500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType, 159133500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationLocInfo> { 159233500955d731c73717af52088b7fc0e7a85681e7John McCallpublic: 159333500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getKeywordLoc() const { 159433500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->KeywordLoc; 159533500955d731c73717af52088b7fc0e7a85681e7John McCall } 159633500955d731c73717af52088b7fc0e7a85681e7John McCall void setKeywordLoc(SourceLocation Loc) { 159733500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->KeywordLoc = Loc; 159833500955d731c73717af52088b7fc0e7a85681e7John McCall } 159933500955d731c73717af52088b7fc0e7a85681e7John McCall 160094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 160194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!getLocalData()->QualifierData) 160294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return NestedNameSpecifierLoc(); 160394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor 160494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 160594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData); 160633500955d731c73717af52088b7fc0e7a85681e7John McCall } 160794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor 160894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 160994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!QualifierLoc) { 161094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // Even if we have a nested-name-specifier in the dependent 161194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // template specialization type, we won't record the nested-name-specifier 161294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // location information when this type-source location information is 161394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // part of a nested-name-specifier. 161494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = 0; 161594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return; 161694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor } 161794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor 161894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor assert(QualifierLoc.getNestedNameSpecifier() 161994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor == getTypePtr()->getQualifier() && 162094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor "Inconsistent nested-name-specifier pointer"); 162194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 162233500955d731c73717af52088b7fc0e7a85681e7John McCall } 162333500955d731c73717af52088b7fc0e7a85681e7John McCall 162433500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getNameLoc() const { 162533500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->NameLoc; 162633500955d731c73717af52088b7fc0e7a85681e7John McCall } 162733500955d731c73717af52088b7fc0e7a85681e7John McCall void setNameLoc(SourceLocation Loc) { 162833500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->NameLoc = Loc; 162933500955d731c73717af52088b7fc0e7a85681e7John McCall } 163033500955d731c73717af52088b7fc0e7a85681e7John McCall 163133500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getLAngleLoc() const { 163233500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->LAngleLoc; 163333500955d731c73717af52088b7fc0e7a85681e7John McCall } 163433500955d731c73717af52088b7fc0e7a85681e7John McCall void setLAngleLoc(SourceLocation Loc) { 163533500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->LAngleLoc = Loc; 163633500955d731c73717af52088b7fc0e7a85681e7John McCall } 163733500955d731c73717af52088b7fc0e7a85681e7John McCall 163833500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getRAngleLoc() const { 163933500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->RAngleLoc; 164033500955d731c73717af52088b7fc0e7a85681e7John McCall } 164133500955d731c73717af52088b7fc0e7a85681e7John McCall void setRAngleLoc(SourceLocation Loc) { 164233500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->RAngleLoc = Loc; 164333500955d731c73717af52088b7fc0e7a85681e7John McCall } 164433500955d731c73717af52088b7fc0e7a85681e7John McCall 164533500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getNumArgs() const { 164633500955d731c73717af52088b7fc0e7a85681e7John McCall return getTypePtr()->getNumArgs(); 164733500955d731c73717af52088b7fc0e7a85681e7John McCall } 164833500955d731c73717af52088b7fc0e7a85681e7John McCall 164933500955d731c73717af52088b7fc0e7a85681e7John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 165033500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos()[i] = AI; 165133500955d731c73717af52088b7fc0e7a85681e7John McCall } 165233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 165333500955d731c73717af52088b7fc0e7a85681e7John McCall return getArgInfos()[i]; 165433500955d731c73717af52088b7fc0e7a85681e7John McCall } 165533500955d731c73717af52088b7fc0e7a85681e7John McCall 165633500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 165733500955d731c73717af52088b7fc0e7a85681e7John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 165833500955d731c73717af52088b7fc0e7a85681e7John McCall } 165933500955d731c73717af52088b7fc0e7a85681e7John McCall 166033500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getLocalSourceRange() const { 166133500955d731c73717af52088b7fc0e7a85681e7John McCall if (getKeywordLoc().isValid()) 166233500955d731c73717af52088b7fc0e7a85681e7John McCall return SourceRange(getKeywordLoc(), getRAngleLoc()); 166394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor else if (getQualifierLoc()) 166494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc()); 16659e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor else 16669e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return SourceRange(getNameLoc(), getRAngleLoc()); 166733500955d731c73717af52088b7fc0e7a85681e7John McCall } 166833500955d731c73717af52088b7fc0e7a85681e7John McCall 166933500955d731c73717af52088b7fc0e7a85681e7John McCall void copy(DependentTemplateSpecializationTypeLoc Loc) { 167033500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned size = getFullDataSize(); 167133500955d731c73717af52088b7fc0e7a85681e7John McCall assert(size == Loc.getFullDataSize()); 167233500955d731c73717af52088b7fc0e7a85681e7John McCall memcpy(Data, Loc.Data, size); 167333500955d731c73717af52088b7fc0e7a85681e7John McCall } 167433500955d731c73717af52088b7fc0e7a85681e7John McCall 167594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 167633500955d731c73717af52088b7fc0e7a85681e7John McCall 167733500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getExtraLocalDataSize() const { 167833500955d731c73717af52088b7fc0e7a85681e7John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 167933500955d731c73717af52088b7fc0e7a85681e7John McCall } 168033500955d731c73717af52088b7fc0e7a85681e7John McCall 168133500955d731c73717af52088b7fc0e7a85681e7John McCallprivate: 168233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *getArgInfos() const { 168333500955d731c73717af52088b7fc0e7a85681e7John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 168433500955d731c73717af52088b7fc0e7a85681e7John McCall } 168533500955d731c73717af52088b7fc0e7a85681e7John McCall}; 168633500955d731c73717af52088b7fc0e7a85681e7John McCall 16877536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 16887536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo { 16897536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation EllipsisLoc; 16907536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 16917536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 16927536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc 16937536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc, 16947536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor PackExpansionType, PackExpansionTypeLocInfo> { 16957536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic: 16967536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation getEllipsisLoc() const { 16977536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getLocalData()->EllipsisLoc; 16987536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 16997536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17007536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor void setEllipsisLoc(SourceLocation Loc) { 17017536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor this->getLocalData()->EllipsisLoc = Loc; 17027536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17037536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17047536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceRange getLocalSourceRange() const { 17057536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return SourceRange(getEllipsisLoc(), getEllipsisLoc()); 17067536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17077536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1708c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 17097536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor setEllipsisLoc(Loc); 17107536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17117536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17127536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor TypeLoc getPatternLoc() const { 17137536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return getInnerTypeLoc(); 17147536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17157536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17167536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor QualType getInnerType() const { 17177536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getTypePtr()->getPattern(); 17187536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17197536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 17207536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1721b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis} 1722b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1723b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif 1724