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" 21aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h" 22b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 23b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang { 24c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor class ASTContext; 25b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis class ParmVarDecl; 26a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall class TypeSourceInfo; 2734a0447b8072e0da14c0980597da9d03a1495662John McCall class UnqualTypeLoc; 28b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes. 3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base) 3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \ 3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall class Class##TypeLoc; 3351bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def" 3451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info. 36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// 37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to 38b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information. 39b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc { 40b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected: 4134a0447b8072e0da14c0980597da9d03a1495662John McCall // The correctness of this relies on the property that, for Type *Ty, 4234a0447b8072e0da14c0980597da9d03a1495662John McCall // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty 43f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const void *Ty; 44b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void *Data; 451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum, 4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// except it also defines a Qualified enum that corresponds to the 4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// QualifiedLoc class. 5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall enum TypeLocClass { 5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base) 5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \ 5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall Class = Type::Class, 5451bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def" 5551bd803fbdade51d674598ed45da3d54190a656cJohn McCall Qualified 5651bd803fbdade51d674598ed45da3d54190a656cJohn McCall }; 5751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 5834a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc() : Ty(0), Data(0) { } 5934a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(QualType ty, void *opaqueData) 6034a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } 61f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall TypeLoc(const Type *ty, void *opaqueData) 6234a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty), Data(opaqueData) { } 63b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 6451bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 65a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor if (getType().hasLocalQualifiers()) return Qualified; 6651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getType()->getTypeClass(); 6751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 6851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 6934a0447b8072e0da14c0980597da9d03a1495662John McCall bool isNull() const { return !Ty; } 7034a0447b8072e0da14c0980597da9d03a1495662John McCall operator bool() const { return Ty; } 71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of type source info data block for the given type. 73b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static unsigned getFullDataSizeForType(QualType Ty); 74b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 75b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the type for which this source info wrapper provides 76b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// information. 7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getType() const { 7851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return QualType::getFromOpaquePtr(Ty); 7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 8034a0447b8072e0da14c0980597da9d03a1495662John McCall 81f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 8234a0447b8072e0da14c0980597da9d03a1495662John McCall return QualType::getFromOpaquePtr(Ty).getTypePtr(); 8334a0447b8072e0da14c0980597da9d03a1495662John McCall } 84b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 85b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis /// \brief Get the pointer where source information is stored. 8651bd803fbdade51d674598ed45da3d54190a656cJohn McCall void *getOpaqueData() const { 8751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Data; 8851bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 89b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 90e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the begin source location. 91e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getBeginLoc() const; 92e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 93e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the end source location. 94e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getEndLoc() const; 95e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 96833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the full source range. 97aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceRange getSourceRange() const LLVM_READONLY { 98e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara return SourceRange(getBeginLoc(), getEndLoc()); 99833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 100aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } 101aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } 102833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 103833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the local source range. 104bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 105bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara return getLocalSourceRangeImpl(*this); 10651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block. 10934a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 11051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getFullDataSizeForType(getType()); 11134a0447b8072e0da14c0980597da9d03a1495662John McCall } 112b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the 114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// TypeLoc is a PointerLoc and next TypeLoc is for "int". 11551bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLoc getNextTypeLoc() const { 11651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getNextTypeLocImpl(*this); 11751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 11934a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Skips past any qualifiers, if this is qualified. 12051bd803fbdade51d674598ed45da3d54190a656cJohn McCall UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header 12134a0447b8072e0da14c0980597da9d03a1495662John McCall 122723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara TypeLoc IgnoreParens() const { 123723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara if (isa<ParenTypeLoc>(this)) 124723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara return IgnoreParensImpl(*this); 125723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara return *this; 126723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara } 127140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara 1284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// \brief Initializes this to state that every location in this 1294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// type is the given location. 1304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// 1314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// This method exists to provide a simple transition for code that 1324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// relies on location-less types. 133c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initialize(ASTContext &Context, SourceLocation Loc) const { 134c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeImpl(Context, *this, Loc); 1354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 13745ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// \brief Initializes this by copying its information from another 13845ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// TypeLoc of the same type. 13945ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein void initializeFullCopy(TypeLoc Other) const { 140711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 141711c52bb20d0c69063b52a99826fb7d2835501f1John McCall size_t Size = getFullDataSize(); 142711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 143711c52bb20d0c69063b52a99826fb7d2835501f1John McCall } 144711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 145711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// \brief Initializes this by copying its information from another 146711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// TypeLoc of the same type. The given size must be the full data 147711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// size. 148711c52bb20d0c69063b52a99826fb7d2835501f1John McCall void initializeFullCopy(TypeLoc Other, unsigned Size) const { 149711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 150711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getFullDataSize() == Size); 151711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 15245ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein } 15345ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein 154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { 155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; 156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) { 159b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return !(LHS == RHS); 160b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 161b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 162b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static bool classof(const TypeLoc *TL) { return true; } 1634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate: 165ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static void initializeImpl(ASTContext &Context, TypeLoc TL, 166ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation Loc); 16751bd803fbdade51d674598ed45da3d54190a656cJohn McCall static TypeLoc getNextTypeLocImpl(TypeLoc TL); 168723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara static TypeLoc IgnoreParensImpl(TypeLoc TL); 169bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara static SourceRange getLocalSourceRangeImpl(TypeLoc TL); 170b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 171b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1723c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info. 1733c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const { 1744ab92891a53adda8c52c1947351371da58e33f64Gabor Greif return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); 1753c385c28cf1f27b193a620d2e51f814873362cebJohn McCall} 1763c385c28cf1f27b193a620d2e51f814873362cebJohn McCall 17734a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 178489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers. 17934a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc { 18034a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 18134a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc() {} 182f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {} 18334a0447b8072e0da14c0980597da9d03a1495662John McCall 184f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 185f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall return reinterpret_cast<const Type*>(Ty); 18634a0447b8072e0da14c0980597da9d03a1495662John McCall } 18734a0447b8072e0da14c0980597da9d03a1495662John McCall 18851bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 18951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getTypePtr()->getTypeClass(); 19051bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 19151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 19234a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 193a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return !TL->getType().hasLocalQualifiers(); 19434a0447b8072e0da14c0980597da9d03a1495662John McCall } 19534a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const UnqualTypeLoc *TL) { return true; } 19634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 19734a0447b8072e0da14c0980597da9d03a1495662John McCall 19834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 19934a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers. 20034a0447b8072e0da14c0980597da9d03a1495662John McCall/// 20134a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for 20234a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers. 20351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc { 20434a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 205bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 20634a0447b8072e0da14c0980597da9d03a1495662John McCall return SourceRange(); 20734a0447b8072e0da14c0980597da9d03a1495662John McCall } 20834a0447b8072e0da14c0980597da9d03a1495662John McCall 20934a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc getUnqualifiedLoc() const { 21051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return UnqualTypeLoc(getTypePtr(), Data); 21134a0447b8072e0da14c0980597da9d03a1495662John McCall } 21234a0447b8072e0da14c0980597da9d03a1495662John McCall 2134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// Initializes the local data of this type source info block to 2144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// provide no information. 215c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 2164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall // do nothing 2174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 2194ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 2204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getUnqualifiedLoc(); 2214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 22334a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block that is 22434a0447b8072e0da14c0980597da9d03a1495662John McCall /// specific to this type. 22534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 22634a0447b8072e0da14c0980597da9d03a1495662John McCall // In fact, we don't currently preserve any location information 22734a0447b8072e0da14c0980597da9d03a1495662John McCall // for qualifiers. 22834a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 22934a0447b8072e0da14c0980597da9d03a1495662John McCall } 23034a0447b8072e0da14c0980597da9d03a1495662John McCall 23134a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block. 23234a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 233ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return getLocalDataSize() + 234fa1a06e80706846fa15e0bd44671bdc3dfc53d84Douglas Gregor getFullDataSizeForType(getType().getLocalUnqualifiedType()); 23534a0447b8072e0da14c0980597da9d03a1495662John McCall } 23634a0447b8072e0da14c0980597da9d03a1495662John McCall 23734a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classof(const TypeLoc *TL) { 238a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor return TL->getType().hasLocalQualifiers(); 23934a0447b8072e0da14c0980597da9d03a1495662John McCall } 24051bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const QualifiedTypeLoc *TL) { return true; } 24134a0447b8072e0da14c0980597da9d03a1495662John McCall}; 24234a0447b8072e0da14c0980597da9d03a1495662John McCall 24334a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { 24451bd803fbdade51d674598ed45da3d54190a656cJohn McCall if (isa<QualifiedTypeLoc>(this)) 24551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc(); 24634a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<UnqualTypeLoc>(*this); 24734a0447b8072e0da14c0980597da9d03a1495662John McCall} 24834a0447b8072e0da14c0980597da9d03a1495662John McCall 24934a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond 250f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass. It is accepted for a single 251f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes. 25234a0447b8072e0da14c0980597da9d03a1495662John McCall/// 25370517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Base a class from which to derive 25470517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Derived the class deriving from this one 25570517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam TypeClass the concrete Type subclass associated with this 256f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// location type 25770517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam LocalData the structure type of local location data for 25834a0447b8072e0da14c0980597da9d03a1495662John McCall/// this type 25934a0447b8072e0da14c0980597da9d03a1495662John McCall/// 26034a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or 26134a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end. 26234a0447b8072e0da14c0980597da9d03a1495662John McCall/// 26334a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override 26434a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to 26534a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory. 26634a0447b8072e0da14c0980597da9d03a1495662John McCall/// 267a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define 268a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// QualType getInnerType() const 269a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's 270a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data. 27151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// 27251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be 27351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy. It is also not 27451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide 27551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information. It should be subclassed 27651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children 27751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type, 27851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from 27951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead. 28034a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData> 28134a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base { 28234a0447b8072e0da14c0980597da9d03a1495662John McCall 28334a0447b8072e0da14c0980597da9d03a1495662John McCall const Derived *asDerived() const { 28434a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<const Derived*>(this); 28534a0447b8072e0da14c0980597da9d03a1495662John McCall } 28634a0447b8072e0da14c0980597da9d03a1495662John McCall 28734a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 28834a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 28934a0447b8072e0da14c0980597da9d03a1495662John McCall return sizeof(LocalData) + asDerived()->getExtraLocalDataSize(); 29034a0447b8072e0da14c0980597da9d03a1495662John McCall } 29134a0447b8072e0da14c0980597da9d03a1495662John McCall // Give a default implementation that's useful for leaf types. 29234a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 29334a0447b8072e0da14c0980597da9d03a1495662John McCall return asDerived()->getLocalDataSize() + getInnerTypeSize(); 29434a0447b8072e0da14c0980597da9d03a1495662John McCall } 29534a0447b8072e0da14c0980597da9d03a1495662John McCall 29634a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classofType(const Type *Ty) { 29734a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeClass::classof(Ty); 29834a0447b8072e0da14c0980597da9d03a1495662John McCall } 29934a0447b8072e0da14c0980597da9d03a1495662John McCall 300e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const TypeLoc *TL) { 301e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 302e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 303e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const UnqualTypeLoc *TL) { 304e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return Derived::classofType(TL->getTypePtr()); 305e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 306e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara static bool classof(const Derived *TL) { 307e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return true; 308e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 309e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 3104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 3114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getNextTypeLoc(asDerived()->getInnerType()); 3124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 314f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 31551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 31634a0447b8072e0da14c0980597da9d03a1495662John McCall } 31734a0447b8072e0da14c0980597da9d03a1495662John McCall 31851bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected: 31934a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 32034a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 32134a0447b8072e0da14c0980597da9d03a1495662John McCall } 32234a0447b8072e0da14c0980597da9d03a1495662John McCall 32334a0447b8072e0da14c0980597da9d03a1495662John McCall LocalData *getLocalData() const { 32434a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<LocalData*>(Base::Data); 32534a0447b8072e0da14c0980597da9d03a1495662John McCall } 32634a0447b8072e0da14c0980597da9d03a1495662John McCall 32734a0447b8072e0da14c0980597da9d03a1495662John McCall /// Gets a pointer past the Info structure; useful for classes with 32834a0447b8072e0da14c0980597da9d03a1495662John McCall /// local data that can't be captured in the Info (e.g. because it's 32934a0447b8072e0da14c0980597da9d03a1495662John McCall /// of variable size). 33034a0447b8072e0da14c0980597da9d03a1495662John McCall void *getExtraLocalData() const { 33134a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData() + 1; 33234a0447b8072e0da14c0980597da9d03a1495662John McCall } 333ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 33434a0447b8072e0da14c0980597da9d03a1495662John McCall void *getNonLocalData() const { 33534a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize(); 33634a0447b8072e0da14c0980597da9d03a1495662John McCall } 33734a0447b8072e0da14c0980597da9d03a1495662John McCall 338a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall struct HasNoInnerType {}; 339a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall HasNoInnerType getInnerType() const { return HasNoInnerType(); } 34034a0447b8072e0da14c0980597da9d03a1495662John McCall 34134a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc getInnerTypeLoc() const { 34234a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); 34334a0447b8072e0da14c0980597da9d03a1495662John McCall } 34434a0447b8072e0da14c0980597da9d03a1495662John McCall 34534a0447b8072e0da14c0980597da9d03a1495662John McCallprivate: 34634a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getInnerTypeSize() const { 347a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeSize(asDerived()->getInnerType()); 348a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall } 349a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall 350a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(HasNoInnerType _) const { 35134a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 35234a0447b8072e0da14c0980597da9d03a1495662John McCall } 35334a0447b8072e0da14c0980597da9d03a1495662John McCall 354a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(QualType _) const { 355a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeLoc().getFullDataSize(); 35634a0447b8072e0da14c0980597da9d03a1495662John McCall } 3574ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(HasNoInnerType _) const { 3594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(); 3604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 3624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(QualType T) const { 3634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(T, getNonLocalData()); 3644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 36534a0447b8072e0da14c0980597da9d03a1495662John McCall}; 36634a0447b8072e0da14c0980597da9d03a1495662John McCall 36751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract 36851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source 36951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information. See the note on ConcreteTypeLoc. 37051bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass> 37151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base { 372b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 373713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor static bool classofType(const Type *Ty) { 374713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor return TypeClass::classof(Ty); 375713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor } 376713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor 37751bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const TypeLoc *TL) { 37851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 379b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 38051bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const UnqualTypeLoc *TL) { 38151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Derived::classofType(TL->getTypePtr()); 382b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 38351bd803fbdade51d674598ed45da3d54190a656cJohn McCall static bool classof(const Derived *TL) { 38451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return true; 385b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 386b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 387f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 38851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 3894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 39034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 391b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 392ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 39351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo { 39434a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation NameLoc; 395b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 396b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 39751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to 39851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier. 399ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikieclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 400ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc, 401ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Type, 402ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecLocInfo> { 403b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 404ed97649e9574b9d854fa4d6109c9333ae0993554John McCall enum { LocalDataSize = sizeof(TypeSpecLocInfo) }; 405ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 406b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getNameLoc() const { 40751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->NameLoc; 408b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 409b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setNameLoc(SourceLocation Loc) { 41051bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->NameLoc = Loc; 411b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 412bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 413b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getNameLoc(), getNameLoc()); 414b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 415c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 4164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setNameLoc(Loc); 4174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 418ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 419ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeLoc *TL); 420ed97649e9574b9d854fa4d6109c9333ae0993554John McCall static bool classof(const TypeSpecTypeLoc *TL) { return true; } 42151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 4224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 423ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 424ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo { 425ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation BuiltinLoc; 426ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 427ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 428ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types. 429ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 430ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc, 431ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType, 432ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinLocInfo> { 433ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic: 434ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor enum { LocalDataSize = sizeof(BuiltinLocInfo) }; 435ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 436ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getBuiltinLoc() const { 437ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getLocalData()->BuiltinLoc; 438ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 439ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setBuiltinLoc(SourceLocation Loc) { 440ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getLocalData()->BuiltinLoc = Loc; 441ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 442ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 443ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getNameLoc() const { return getBuiltinLoc(); } 444ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 445ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs& getWrittenBuiltinSpecs() { 446ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 447ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 448ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { 449ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 450ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 451ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 452ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool needsExtraLocalData() const { 453ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType::Kind bk = getTypePtr()->getKind(); 454ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) 455d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble) 456ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::UChar 457ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::SChar; 458ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 459ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 460ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor unsigned getExtraLocalDataSize() const { 461d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; 462ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 463ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 464bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 465ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return SourceRange(getBuiltinLoc(), getBuiltinLoc()); 466ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 467ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 468ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierSign getWrittenSignSpec() const { 469ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 470ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); 471ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 472ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSS_unspecified; 473ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 474ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenSignSpec() const { 475ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenSignSpec() != TSS_unspecified; 476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenSignSpec(TypeSpecifierSign written) { 478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Sign = written; 480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierWidth getWrittenWidthSpec() const { 483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); 485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSW_unspecified; 487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenWidthSpec() const { 489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenWidthSpec() != TSW_unspecified; 490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenWidthSpec(TypeSpecifierWidth written) { 492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Width = written; 494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 496ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierType getWrittenTypeSpec() const; 497ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenTypeSpec() const { 498ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenTypeSpec() != TST_unspecified; 499ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 500ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenTypeSpec(TypeSpecifierType written) { 501ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 502ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Type = written; 503ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 504ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 505ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasModeAttr() const { 506ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 507ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenBuiltinSpecs().ModeAttr; 508ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 509ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return false; 510ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 511ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setModeAttr(bool written) { 512ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().ModeAttr = written; 514ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 515ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 516c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 517ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor setBuiltinLoc(Loc); 518ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) { 519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); 520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Sign = TSS_unspecified; 521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Width = TSW_unspecified; 522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Type = TST_unspecified; 523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.ModeAttr = false; 524ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 525ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 526ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 527ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 528ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 52951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs. 530ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 531ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefTypeLoc, 532ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefType> { 53351bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 534162e1c1b487352434552147967c3dd296ebee2f7Richard Smith TypedefNameDecl *getTypedefNameDecl() const { 53534a0447b8072e0da14c0980597da9d03a1495662John McCall return getTypePtr()->getDecl(); 5369036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis } 53734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 5389036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis 5393cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class 5403cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates. 5413cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc : 5423cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 5433cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameTypeLoc, 5443cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameType> { 545427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 546427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis CXXRecordDecl *getDecl() const { 547427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis return getTypePtr()->getDecl(); 548427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis } 5493cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall}; 5503cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 551ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls. 552ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc : 553ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 554ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypeLoc, 555ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType> { 556ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 557ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypenameDecl *getDecl() const { 558ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return getTypePtr()->getDecl(); 559ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 560ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 561ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 562ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types. Note that this only 563ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo' 564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc. We currently 565ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of 566ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C. 567ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 568ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagTypeLoc, 569ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagType> { 570ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 571ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagDecl *getDecl() const { return getTypePtr()->getDecl(); } 5726f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis 573ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief True if the tag was defined in this type specifier. 5746f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis bool isDefinition() const { 575a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis TagDecl *D = getDecl(); 576a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis return D->isCompleteDefinition() && 577a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis (D->getIdentifier() == 0 || D->getLocation() == getNameLoc()); 5786f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis } 579ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 580ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 581ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types. 582ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 583ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordTypeLoc, 584ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordType> { 585ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 586ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordDecl *getDecl() const { return getTypePtr()->getDecl(); } 587ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 588ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 589ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types. 590ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 591ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumTypeLoc, 592ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumType> { 593ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 594ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumDecl *getDecl() const { return getTypePtr()->getDecl(); } 595ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 596b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 59749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters. 598ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc : 599ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 600ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmTypeLoc, 601ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmType> { 602960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruthpublic: 603960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruth TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } 60449a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 60549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 60649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters. 60749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc : 608ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 609ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmTypeLoc, 610ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmType> { 61149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 61251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 613c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor /// \brief Wrapper for substituted template type parameters. 614c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc : 615c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 616c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackTypeLoc, 617c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackType> { 618c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor}; 619c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor 6209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo { 6219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall union { 6229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *ExprOperand; 6239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// A raw SourceLocation. 6259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall unsigned EnumOperandLoc; 6269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall }; 6279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange OperandParens; 6299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation AttrLoc; 6319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 6329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type. 6349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 6359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc, 6369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType, 6379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedLocInfo> { 6389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic: 6399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType::Kind getAttrKind() const { 6409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getAttrKind(); 6419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrExprOperand() const { 6449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstExprOperandKind && 6459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastExprOperandKind); 6469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrEnumOperand() const { 6499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstEnumOperandKind && 6509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastEnumOperandKind); 6519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrOperand() const { 6549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return hasAttrExprOperand() || hasAttrEnumOperand(); 6559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The modified type, which is generally canonically different from 6589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// the attribute type. 6599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// int main(int, char**) __attribute__((noreturn)) 6609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ~~~ ~~~~~~~~~~~~~ 6619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall TypeLoc getModifiedLoc() const { 6629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getInnerTypeLoc(); 6639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute name, i.e. 6669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// __attribute__((regparm(1000))) 6679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~~~~ 6689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrNameLoc() const { 6699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->AttrLoc; 6709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrNameLoc(SourceLocation loc) { 6729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->AttrLoc = loc; 6739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The attribute's expression operand, if it has one. 6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void *cur_thread __attribute__((address_space(21))) 6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~ 6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *getAttrExprOperand() const { 6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->ExprOperand; 6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrExprOperand(Expr *e) { 6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->ExprOperand = e; 6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute's enumerated operand, if it has one. 6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~ 6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrEnumOperandLoc() const { 6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc); 6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrEnumOperandLoc(SourceLocation loc) { 6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->EnumOperandLoc = loc.getRawEncoding(); 6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the parentheses around the operand, if there is 7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// an operand. 7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^ ^ 7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getAttrOperandParensRange() const { 7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->OperandParens; 7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrOperandParensRange(SourceRange range) { 7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->OperandParens = range; 7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getLocalSourceRange() const { 7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // Note that this does *not* include the range of the attribute 7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // enclosure, e.g.: 7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // __attribute__((foo(bar))) 7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~~~~~~~~~~~~~~ ~~ 7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // or 7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // [[foo(bar)]] 7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~ ~~ 7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // That enclosure doesn't necessarily belong to a single attribute 7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // anyway. 7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange range(getAttrNameLoc()); 7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrOperand()) 7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall range.setEnd(getAttrOperandParensRange().getEnd()); 7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return range; 7269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 728c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation loc) { 7299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrNameLoc(loc); 7309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrExprOperand()) { 7319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrExprOperand(0); 7339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } else if (hasAttrEnumOperand()) { 7349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrEnumOperandLoc(loc); 7369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType getInnerType() const { 7409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getModifiedType(); 7419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 7439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 744eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 74534a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo { 74654e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation LAngleLoc; 74754e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation RAngleLoc; 748ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall bool HasBaseTypeAsWritten; 749eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis}; 750eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 75154e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with 75254e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols. 75354e14c4db764c0636160d26c5bbf491637c83a76John McCall// 75454e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or 75554e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType. 756c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 757c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectTypeLoc, 758c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectType, 759c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCProtocolListLocInfo> { 760f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis // SourceLocations are stored after Info, one for each Protocol. 761f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation *getProtocolLocArray() const { 76254e14c4db764c0636160d26c5bbf491637c83a76John McCall return (SourceLocation*) this->getExtraLocalData(); 76354e14c4db764c0636160d26c5bbf491637c83a76John McCall } 76454e14c4db764c0636160d26c5bbf491637c83a76John McCall 765f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic: 766f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getLAngleLoc() const { 76754e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->LAngleLoc; 768f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 769f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setLAngleLoc(SourceLocation Loc) { 77054e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->LAngleLoc = Loc; 771f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 772f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 773f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getRAngleLoc() const { 77454e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->RAngleLoc; 775f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 776f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setRAngleLoc(SourceLocation Loc) { 77754e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->RAngleLoc = Loc; 778f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 779f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 780f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis unsigned getNumProtocols() const { 78154e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getTypePtr()->getNumProtocols(); 782f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 783f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 784f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getProtocolLoc(unsigned i) const { 785f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 786f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return getProtocolLocArray()[i]; 787f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 788f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setProtocolLoc(unsigned i, SourceLocation Loc) { 789f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 790f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis getProtocolLocArray()[i] = Loc; 791f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 792f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 793f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis ObjCProtocolDecl *getProtocol(unsigned i) const { 794f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 79554e14c4db764c0636160d26c5bbf491637c83a76John McCall return *(this->getTypePtr()->qual_begin() + i); 796f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 797ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 798c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall bool hasBaseTypeAsWritten() const { 799ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall return getLocalData()->HasBaseTypeAsWritten; 800c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 801c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 802c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setHasBaseTypeAsWritten(bool HasBaseType) { 803ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall getLocalData()->HasBaseTypeAsWritten = HasBaseType; 804c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 805c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 806c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TypeLoc getBaseLoc() const { 807c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getInnerTypeLoc(); 808c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 809c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 810bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 811f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return SourceRange(getLAngleLoc(), getRAngleLoc()); 812f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 813f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 814c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 815ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall setHasBaseTypeAsWritten(true); 816c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setLAngleLoc(Loc); 817c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setRAngleLoc(Loc); 818c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall for (unsigned i = 0, e = getNumProtocols(); i != e; ++i) 819c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setProtocolLoc(i, Loc); 8204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 8214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 82234a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 82354e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getNumProtocols() * sizeof(SourceLocation); 82454e14c4db764c0636160d26c5bbf491637c83a76John McCall } 825c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 826c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall QualType getInnerType() const { 827c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getTypePtr()->getBaseType(); 828c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 82954e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 83054e14c4db764c0636160d26c5bbf491637c83a76John McCall 83154e14c4db764c0636160d26c5bbf491637c83a76John McCall 832c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo { 83354e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation NameLoc; 8341de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation NameEndLoc; 83554e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 83654e14c4db764c0636160d26c5bbf491637c83a76John McCall 83754e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces. 838a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc, 839c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceTypeLoc, 840c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceType, 841c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceLocInfo> { 84254e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 84354e14c4db764c0636160d26c5bbf491637c83a76John McCall ObjCInterfaceDecl *getIFaceDecl() const { 84454e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getDecl(); 84554e14c4db764c0636160d26c5bbf491637c83a76John McCall } 84654e14c4db764c0636160d26c5bbf491637c83a76John McCall 84754e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation getNameLoc() const { 84854e14c4db764c0636160d26c5bbf491637c83a76John McCall return getLocalData()->NameLoc; 84954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 85054e14c4db764c0636160d26c5bbf491637c83a76John McCall 85154e14c4db764c0636160d26c5bbf491637c83a76John McCall void setNameLoc(SourceLocation Loc) { 85254e14c4db764c0636160d26c5bbf491637c83a76John McCall getLocalData()->NameLoc = Loc; 85354e14c4db764c0636160d26c5bbf491637c83a76John McCall } 8541de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 855bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 8561de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return SourceRange(getNameLoc(), getNameEndLoc()); 8571de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 8581de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 8591de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation getNameEndLoc() const { 8601de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return getLocalData()->NameEndLoc; 8611de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 8621de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 8631de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian void setNameEndLoc(SourceLocation Loc) { 8641de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian getLocalData()->NameEndLoc = Loc; 86554e14c4db764c0636160d26c5bbf491637c83a76John McCall } 86654e14c4db764c0636160d26c5bbf491637c83a76John McCall 867c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 86854e14c4db764c0636160d26c5bbf491637c83a76John McCall setNameLoc(Loc); 869f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 87054e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 87154e14c4db764c0636160d26c5bbf491637c83a76John McCall 872075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo { 873075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation LParenLoc; 874075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation RParenLoc; 875075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 876075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 877075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc 878075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType, 879075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenLocInfo> { 880075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic: 881075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getLParenLoc() const { 882075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->LParenLoc; 883075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 884075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getRParenLoc() const { 885075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->RParenLoc; 886075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 887075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setLParenLoc(SourceLocation Loc) { 888075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->LParenLoc = Loc; 889075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 890075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setRParenLoc(SourceLocation Loc) { 891075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->RParenLoc = Loc; 892075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 893075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 894075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceRange getLocalSourceRange() const { 895075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 896075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 897075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 898c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 899075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setLParenLoc(Loc); 900075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setRParenLoc(Loc); 901075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 902075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 903075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara TypeLoc getInnerLoc() const { 904075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return getInnerTypeLoc(); 905075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 906075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 907075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType getInnerType() const { 908075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getTypePtr()->getInnerType(); 909075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 910075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 911075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 912f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 91351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo { 91434a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation StarLoc; 915f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis}; 916f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 917ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// A base class for 91851bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> 91951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, 92051bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass, LocalData> { 921ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 92251bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getSigilLoc() const { 92351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->StarLoc; 924b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 92551bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setSigilLoc(SourceLocation Loc) { 92651bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->StarLoc = Loc; 927b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 928b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 929b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getPointeeLoc() const { 93051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getInnerTypeLoc(); 931b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 932b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 933bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 93451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return SourceRange(getSigilLoc(), getSigilLoc()); 935b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 936b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 937c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 93851bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 9394ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 9404ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getInnerType() const { 94251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getTypePtr()->getPointeeType(); 94351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 94434a0447b8072e0da14c0980597da9d03a1495662John McCall}; 945b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 946b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 94751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers. 94851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc, 94951bd803fbdade51d674598ed45da3d54190a656cJohn McCall PointerType> { 95051bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 95151bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getStarLoc() const { 95251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 95351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 95451bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setStarLoc(SourceLocation Loc) { 95551bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 95651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 957b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 958b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 95951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 960b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers. 96151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc, 96251bd803fbdade51d674598ed45da3d54190a656cJohn McCall BlockPointerType> { 963b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 964b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getCaretLoc() const { 96551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 966b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 967b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setCaretLoc(SourceLocation Loc) { 96851bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 969b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 97034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 971b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 972b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnarastruct MemberPointerLocInfo : public PointerLikeLocInfo { 973b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *ClassTInfo; 974b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara}; 975b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 976b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers. 97751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc, 978b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerType, 979b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerLocInfo> { 980b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 981b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getStarLoc() const { 98251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 983b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 984b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setStarLoc(SourceLocation Loc) { 98551bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 9864ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 987b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 988b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara const Type *getClass() const { 989b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getTypePtr()->getClass(); 990b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 991b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *getClassTInfo() const { 992b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getLocalData()->ClassTInfo; 993b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 994b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void setClassTInfo(TypeSourceInfo* TI) { 995b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara getLocalData()->ClassTInfo = TI; 996b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 997b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 998b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void initializeLocal(ASTContext &Context, SourceLocation Loc) { 999b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setSigilLoc(Loc); 1000b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setClassTInfo(0); 1001b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1002b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1003b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara SourceRange getLocalSourceRange() const { 1004b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara if (TypeSourceInfo *TI = getClassTInfo()) 1005b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc()); 1006b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara else 1007b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(getStarLoc()); 1008b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 100934a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1010b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1011c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information. 1012c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc : 1013c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc, 1014c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerType> { 1015c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic: 1016c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall SourceLocation getStarLoc() const { 1017c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getSigilLoc(); 1018c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1019c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1020c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setStarLoc(SourceLocation Loc) { 1021c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setSigilLoc(Loc); 1022c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1023c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall}; 1024c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1025b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 102651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc, 102751bd803fbdade51d674598ed45da3d54190a656cJohn McCall ReferenceType> { 102854e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 102954e14c4db764c0636160d26c5bbf491637c83a76John McCall QualType getInnerType() const { 103054e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getPointeeTypeAsWritten(); 103154e14c4db764c0636160d26c5bbf491637c83a76John McCall } 1032b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1033b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1034bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc : 1035bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1036bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceTypeLoc, 1037bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceType> { 1038b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1039b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getAmpLoc() const { 104051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1041b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1042b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setAmpLoc(SourceLocation Loc) { 104351bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1044b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 104551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1046b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1047bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc : 1048bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1049bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceTypeLoc, 1050bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceType> { 105151bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 105251bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getAmpAmpLoc() const { 105351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1054b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 105551bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setAmpAmpLoc(SourceLocation Loc) { 105651bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1057b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 105851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1059b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1060b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 106134a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo { 1062796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeBegin; 1063796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeEnd; 1064b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1065b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1066b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions. 106751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 106851bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionTypeLoc, 106951bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionType, 107051bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionLocInfo> { 1071b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1072796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeBegin() const { 1073796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeBegin; 1074b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1075796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeBegin(SourceLocation L) { 1076796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeBegin = L; 1077b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1078b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1079796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeEnd() const { 1080796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeEnd; 1081b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1082796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeEnd(SourceLocation L) { 1083796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeEnd = L; 1084b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1085b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1086ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman ArrayRef<ParmVarDecl *> getParams() const { 1087ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman return ArrayRef<ParmVarDecl *>(getParmArray(), getNumArgs()); 1088ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman } 1089ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman 1090a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor // ParmVarDecls* are stored after Info, one for each argument. 1091a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **getParmArray() const { 1092a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor return (ParmVarDecl**) getExtraLocalData(); 1093a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor } 1094a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor 1095b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis unsigned getNumArgs() const { 109634a0447b8072e0da14c0980597da9d03a1495662John McCall if (isa<FunctionNoProtoType>(getTypePtr())) 1097b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return 0; 109834a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<FunctionProtoType>(getTypePtr())->getNumArgs(); 1099b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1100b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; } 1101b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } 1102b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getResultLoc() const { 110434a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1106b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1107bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1108796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return SourceRange(getLocalRangeBegin(), getLocalRangeEnd()); 1109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1111c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1112796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeBegin(Loc); 1113796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeEnd(Loc); 11144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall for (unsigned i = 0, e = getNumArgs(); i != e; ++i) 11154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setArg(i, NULL); 11164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 11174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block that is 1119b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// specific to this type. 112034a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 112134a0447b8072e0da14c0980597da9d03a1495662John McCall return getNumArgs() * sizeof(ParmVarDecl*); 1122b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1123b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 112434a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getResultType(); } 112534a0447b8072e0da14c0980597da9d03a1495662John McCall}; 112634a0447b8072e0da14c0980597da9d03a1495662John McCall 112751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc : 112851bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 112951bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoTypeLoc, 113051bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoType> { 113151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 113251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 113351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc : 113451bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 113551bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoTypeLoc, 113651bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoType> { 113751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 113851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1139b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 114034a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo { 114134a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LBracketLoc, RBracketLoc; 114234a0447b8072e0da14c0980597da9d03a1495662John McCall Expr *Size; 1143b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1144b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1145b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays. 114651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 114751bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayTypeLoc, 114851bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayType, 114951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayLocInfo> { 1150b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1151b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLBracketLoc() const { 115234a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LBracketLoc; 1153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLBracketLoc(SourceLocation Loc) { 115534a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LBracketLoc = Loc; 1156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRBracketLoc() const { 115934a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RBracketLoc; 1160b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1161b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRBracketLoc(SourceLocation Loc) { 116234a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RBracketLoc = Loc; 1163b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1164b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 116585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange getBracketsRange() const { 116685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return SourceRange(getLBracketLoc(), getRBracketLoc()); 116785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 116885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 1169b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis Expr *getSizeExpr() const { 117034a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->Size; 1171b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1172b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setSizeExpr(Expr *Size) { 117334a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->Size = Size; 1174b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1175b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1176b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getElementLoc() const { 117734a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1178b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1179b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1180bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1181b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLBracketLoc(), getRBracketLoc()); 1182b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1183b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1184c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 11854ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLBracketLoc(Loc); 11864ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRBracketLoc(Loc); 11874ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setSizeExpr(NULL); 11884ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 11894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 119034a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getElementType(); } 1191b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1192b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 119351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc : 119451bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 119551bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayTypeLoc, 119651bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayType> { 119751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 119851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 119951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc : 120051bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 120151bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayTypeLoc, 120251bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayType> { 120351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 120451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 120551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc : 120651bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 120751bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayTypeLoc, 120851bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayType> { 120951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 121051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 121151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 121251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc : 121351bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 121451bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayTypeLoc, 121551bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayType> { 121651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 121751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1218833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1219833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName. Rudimentary for now. 1220833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo { 1221833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation NameLoc; 1222833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1223833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1224833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo { 122555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation TemplateKWLoc; 1226833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc; 1227833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation RAngleLoc; 1228833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1229833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1230833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc : 1231833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall public ConcreteTypeLoc<UnqualTypeLoc, 1232833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc, 1233833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationType, 1234833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationLocInfo> { 1235833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic: 123655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateKeywordLoc() const { 123755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return getLocalData()->TemplateKWLoc; 123855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 123955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 124055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara getLocalData()->TemplateKWLoc = Loc; 124155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 124255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara 1243833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getLAngleLoc() const { 1244833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->LAngleLoc; 1245833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1246833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setLAngleLoc(SourceLocation Loc) { 1247833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->LAngleLoc = Loc; 1248833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1249833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1250833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getRAngleLoc() const { 1251833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->RAngleLoc; 1252833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setRAngleLoc(SourceLocation Loc) { 1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->RAngleLoc = Loc; 1255833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1256833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1257833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getNumArgs() const { 1258833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getTypePtr()->getNumArgs(); 1259833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1260833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 1261833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getArgInfos()[i] = AI; 1262833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1263833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 1264833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getArgInfos()[i]; 1265833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1266833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1267833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 1268833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 1269833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1270833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1271833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getTemplateNameLoc() const { 1272833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->NameLoc; 1273833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1274833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setTemplateNameLoc(SourceLocation Loc) { 1275833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->NameLoc = Loc; 1276833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1277833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1278833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief - Copy the location information from the given info. 1279833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void copy(TemplateSpecializationTypeLoc Loc) { 1280833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned size = getFullDataSize(); 1281833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall assert(size == Loc.getFullDataSize()); 1282833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1283833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // We're potentially copying Expr references here. We don't 1284a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall // bother retaining them because TypeSourceInfos live forever, so 1285833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // as long as the Expr was retained when originally written into 1286833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // the TypeLoc, we're okay. 1287833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall memcpy(Data, Loc.Data, size); 1288833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1289833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1290bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 129155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getTemplateKeywordLoc().isValid()) 129255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 129355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara else 129455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 1295833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1296833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1297c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 129855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateKeywordLoc(Loc); 129955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateNameLoc(Loc); 1300833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setLAngleLoc(Loc); 1301833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setRAngleLoc(Loc); 1302c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(), 130333500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 130433500955d731c73717af52088b7fc0e7a85681e7John McCall } 1305833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1306c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, 130733500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgument *Args, 130833500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *ArgInfos, 1309c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor SourceLocation Loc); 1310833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1311833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getExtraLocalDataSize() const { 1312833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 1313833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1314833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1315833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate: 1316833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo *getArgInfos() const { 1317833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 1318833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1319833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1320833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1321ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 1322ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1323ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// All of these need proper implementations. 1324ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1325ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 132651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1327ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we 1328ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax). 1329ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1330ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorTypeLoc, 1331ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorType> { 133251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 133351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1334ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations. 133551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc, 133651bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorTypeLoc, 133751bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorType> { 133851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 133951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1340ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations. 134151bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType. 134251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc : 1343ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1344ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorTypeLoc, 1345ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorType> { 134651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 134751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1348ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword. 1349ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1350ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexTypeLoc, 1351ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexType> { 135251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 135351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1354cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo { 1355cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation TypeofLoc; 1356cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation LParenLoc; 1357cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation RParenLoc; 135851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 135951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1360cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo { 1361cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1362cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1363cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo { 1364cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* UnderlyingTInfo; 1365cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1366cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1367cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo> 1368cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc 1369cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { 1370cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1371cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getTypeofLoc() const { 1372cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->TypeofLoc; 1373cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1374cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setTypeofLoc(SourceLocation Loc) { 1375cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->TypeofLoc = Loc; 1376cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1377cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1378cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getLParenLoc() const { 1379cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->LParenLoc; 1380cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1381cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setLParenLoc(SourceLocation Loc) { 1382cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->LParenLoc = Loc; 1383cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1384cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1385cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getRParenLoc() const { 1386cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->RParenLoc; 1387cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1388cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setRParenLoc(SourceLocation Loc) { 1389cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->RParenLoc = Loc; 1390cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1391cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1392cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceRange getParensRange() const { 1393cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getLParenLoc(), getRParenLoc()); 1394cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1395cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setParensRange(SourceRange range) { 1396cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(range.getBegin()); 1397cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(range.getEnd()); 1398cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1399cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1400bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1401cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getTypeofLoc(), getRParenLoc()); 1402cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1403cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1404c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1405cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setTypeofLoc(Loc); 1406cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(Loc); 1407cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(Loc); 1408cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1409cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1410cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1411cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, 1412cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprType, 1413cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprTypeLocInfo> { 1414cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1415cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Expr* getUnderlyingExpr() const { 1416cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return getTypePtr()->getUnderlyingExpr(); 1417cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1418cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // Reimplemented to account for GNU/C++ extension 1419cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // typeof unary-expression 1420cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // where there are no parentheses. 1421bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const; 1422cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1423cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1424cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc 1425cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { 1426cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1427cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall QualType getUnderlyingType() const { 1428cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getTypePtr()->getUnderlyingType(); 1429cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1430cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* getUnderlyingTInfo() const { 1431cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->UnderlyingTInfo; 1432cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1433cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setUnderlyingTInfo(TypeSourceInfo* TI) const { 1434cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->UnderlyingTInfo = TI; 1435cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 143651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 143751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1438ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens. 1439ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1440ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeTypeLoc, 1441ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeType> { 1442427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 1443427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); } 144451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 144551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1446ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntstruct UnaryTransformTypeLocInfo { 1447ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // FIXME: While there's only one unary transform right now, future ones may 1448ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // need different representations 1449ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation KWLoc, LParenLoc, RParenLoc; 1450ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo *UnderlyingTInfo; 1451ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1452ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1453ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntclass UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1454ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLoc, 1455ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformType, 1456ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLocInfo> { 1457ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntpublic: 1458ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getKWLoc() const { return getLocalData()->KWLoc; } 1459ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; } 1460ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1461ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; } 1462ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; } 1463ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1464ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; } 1465ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; } 1466ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1467ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo* getUnderlyingTInfo() const { 1468ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return getLocalData()->UnderlyingTInfo; 1469ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1470ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setUnderlyingTInfo(TypeSourceInfo *TInfo) { 1471ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt getLocalData()->UnderlyingTInfo = TInfo; 1472ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1473ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1474ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getLocalSourceRange() const { 1475ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getKWLoc(), getRParenLoc()); 1476ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1477ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1478ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getParensRange() const { 1479ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getLParenLoc(), getRParenLoc()); 1480ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1481ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setParensRange(SourceRange Range) { 1482ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Range.getBegin()); 1483ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Range.getEnd()); 1484ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1485ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1486ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1487ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setKWLoc(Loc); 1488ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Loc); 1489ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Loc); 1490ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1491ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1492ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 149334b41d939a1328f484511c6002ba2456db879a29Richard Smithclass AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 149434b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoTypeLoc, 149534b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoType> { 149634b41d939a1328f484511c6002ba2456db879a29Richard Smith}; 149734b41d939a1328f484511c6002ba2456db879a29Richard Smith 1498e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo { 149938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation ElaboratedKWLoc; 150038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara /// \brief Data associated with the nested-name-specifier location. 15019e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void *QualifierData; 1502e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1503e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1504e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1505e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc, 1506e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedType, 1507e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedLocInfo> { 1508e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 150938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 151038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1511e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 151238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 151338a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1514e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1515e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15169e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1517ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 15189e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData); 1519e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1520ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 15219e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1522ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 15239e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor == getTypePtr()->getQualifier() && 15249e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor "Inconsistent nested-name-specifier pointer"); 15259e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1526e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1527e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1528bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 152938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 15309e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor if (getQualifierLoc()) 153138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), 153238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara getQualifierLoc().getEndLoc()); 1533e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 153438a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc()); 1535e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 15369e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return getQualifierLoc().getSourceRange(); 1537e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1538e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15399e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 1540e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1541e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara TypeLoc getNamedTypeLoc() const { 1542e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getInnerTypeLoc(); 1543e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1544e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1545e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType getInnerType() const { 1546e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getTypePtr()->getNamedType(); 1547e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1548e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1549e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(ElaboratedTypeLoc Loc) { 1550e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1551e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1552e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1553e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 155451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 155551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 155633500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 155733500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc. 155833500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo { 1559e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation NameLoc; 1560e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1561e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1562e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1563e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc, 1564e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameType, 1565e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameLocInfo> { 1566e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 156738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 156838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1569e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 157038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 157138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1572e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1573e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 15742494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1575ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 15762494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData); 1577e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1578ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 15792494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1580ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 15812494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor == getTypePtr()->getQualifier() && 15822494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor "Inconsistent nested-name-specifier pointer"); 15832494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1584e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1585ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1586e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getNameLoc() const { 1587e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->NameLoc; 1588e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1589e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setNameLoc(SourceLocation Loc) { 1590e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->NameLoc = Loc; 1591e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1592e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1593bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 159438a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 159538a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getNameLoc()); 1596e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 15972494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc()); 1598e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1599e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1600e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(DependentNameTypeLoc Loc) { 1601e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1602e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1603e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1604e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1605e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 16062494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 160751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 160851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 160994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregorstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { 161066581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation TemplateKWLoc; 161133500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation LAngleLoc; 161233500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation RAngleLoc; 161333500955d731c73717af52088b7fc0e7a85681e7John McCall // followed by a TemplateArgumentLocInfo[] 161433500955d731c73717af52088b7fc0e7a85681e7John McCall}; 161533500955d731c73717af52088b7fc0e7a85681e7John McCall 161633500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc : 161733500955d731c73717af52088b7fc0e7a85681e7John McCall public ConcreteTypeLoc<UnqualTypeLoc, 161833500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationTypeLoc, 161933500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType, 162033500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationLocInfo> { 162133500955d731c73717af52088b7fc0e7a85681e7John McCallpublic: 162255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 162355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 162433500955d731c73717af52088b7fc0e7a85681e7John McCall } 162555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 162655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 162733500955d731c73717af52088b7fc0e7a85681e7John McCall } 162833500955d731c73717af52088b7fc0e7a85681e7John McCall 162994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 163094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!getLocalData()->QualifierData) 163194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return NestedNameSpecifierLoc(); 1632ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1633ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 163494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData); 163533500955d731c73717af52088b7fc0e7a85681e7John McCall } 1636ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 163794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 163894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!QualifierLoc) { 1639ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie // Even if we have a nested-name-specifier in the dependent 164094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // template specialization type, we won't record the nested-name-specifier 164194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // location information when this type-source location information is 164294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // part of a nested-name-specifier. 164394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = 0; 164494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return; 164594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor } 1646ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1647ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 164894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor == getTypePtr()->getQualifier() && 164994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor "Inconsistent nested-name-specifier pointer"); 165094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 165133500955d731c73717af52088b7fc0e7a85681e7John McCall } 165233500955d731c73717af52088b7fc0e7a85681e7John McCall 165366581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation getTemplateKeywordLoc() const { 165466581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return getLocalData()->TemplateKWLoc; 165566581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 165666581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 165766581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara getLocalData()->TemplateKWLoc = Loc; 165866581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 165966581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara 166055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateNameLoc() const { 166133500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->NameLoc; 166233500955d731c73717af52088b7fc0e7a85681e7John McCall } 166355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateNameLoc(SourceLocation Loc) { 166433500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->NameLoc = Loc; 166533500955d731c73717af52088b7fc0e7a85681e7John McCall } 166633500955d731c73717af52088b7fc0e7a85681e7John McCall 166733500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getLAngleLoc() const { 166833500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->LAngleLoc; 166933500955d731c73717af52088b7fc0e7a85681e7John McCall } 167033500955d731c73717af52088b7fc0e7a85681e7John McCall void setLAngleLoc(SourceLocation Loc) { 167133500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->LAngleLoc = Loc; 167233500955d731c73717af52088b7fc0e7a85681e7John McCall } 167333500955d731c73717af52088b7fc0e7a85681e7John McCall 167433500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getRAngleLoc() const { 167533500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->RAngleLoc; 167633500955d731c73717af52088b7fc0e7a85681e7John McCall } 167733500955d731c73717af52088b7fc0e7a85681e7John McCall void setRAngleLoc(SourceLocation Loc) { 167833500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->RAngleLoc = Loc; 167933500955d731c73717af52088b7fc0e7a85681e7John McCall } 168033500955d731c73717af52088b7fc0e7a85681e7John McCall 168133500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getNumArgs() const { 168233500955d731c73717af52088b7fc0e7a85681e7John McCall return getTypePtr()->getNumArgs(); 168333500955d731c73717af52088b7fc0e7a85681e7John McCall } 168433500955d731c73717af52088b7fc0e7a85681e7John McCall 168533500955d731c73717af52088b7fc0e7a85681e7John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 168633500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos()[i] = AI; 168733500955d731c73717af52088b7fc0e7a85681e7John McCall } 168833500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 168933500955d731c73717af52088b7fc0e7a85681e7John McCall return getArgInfos()[i]; 169033500955d731c73717af52088b7fc0e7a85681e7John McCall } 169133500955d731c73717af52088b7fc0e7a85681e7John McCall 169233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 169333500955d731c73717af52088b7fc0e7a85681e7John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 169433500955d731c73717af52088b7fc0e7a85681e7John McCall } 169533500955d731c73717af52088b7fc0e7a85681e7John McCall 169633500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getLocalSourceRange() const { 169755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 169855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getRAngleLoc()); 169994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor else if (getQualifierLoc()) 170094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc()); 170166581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara else if (getTemplateKeywordLoc().isValid()) 170266581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 17039e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor else 170455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 170533500955d731c73717af52088b7fc0e7a85681e7John McCall } 170633500955d731c73717af52088b7fc0e7a85681e7John McCall 170733500955d731c73717af52088b7fc0e7a85681e7John McCall void copy(DependentTemplateSpecializationTypeLoc Loc) { 170833500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned size = getFullDataSize(); 170933500955d731c73717af52088b7fc0e7a85681e7John McCall assert(size == Loc.getFullDataSize()); 171033500955d731c73717af52088b7fc0e7a85681e7John McCall memcpy(Data, Loc.Data, size); 171133500955d731c73717af52088b7fc0e7a85681e7John McCall } 171233500955d731c73717af52088b7fc0e7a85681e7John McCall 171394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 171433500955d731c73717af52088b7fc0e7a85681e7John McCall 171533500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getExtraLocalDataSize() const { 171633500955d731c73717af52088b7fc0e7a85681e7John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 171733500955d731c73717af52088b7fc0e7a85681e7John McCall } 171833500955d731c73717af52088b7fc0e7a85681e7John McCall 171933500955d731c73717af52088b7fc0e7a85681e7John McCallprivate: 172033500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *getArgInfos() const { 172133500955d731c73717af52088b7fc0e7a85681e7John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 172233500955d731c73717af52088b7fc0e7a85681e7John McCall } 172333500955d731c73717af52088b7fc0e7a85681e7John McCall}; 172433500955d731c73717af52088b7fc0e7a85681e7John McCall 17257536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17267536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo { 17277536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation EllipsisLoc; 17287536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 17297536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17307536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc 1731ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc, 17327536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor PackExpansionType, PackExpansionTypeLocInfo> { 17337536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic: 17347536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation getEllipsisLoc() const { 17357536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getLocalData()->EllipsisLoc; 17367536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17377536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17387536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor void setEllipsisLoc(SourceLocation Loc) { 17397536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor this->getLocalData()->EllipsisLoc = Loc; 17407536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17417536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17427536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceRange getLocalSourceRange() const { 17437536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return SourceRange(getEllipsisLoc(), getEllipsisLoc()); 17447536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17457536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1746c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 17477536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor setEllipsisLoc(Loc); 17487536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17497536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17507536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor TypeLoc getPatternLoc() const { 17517536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return getInnerTypeLoc(); 17527536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17537536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 17547536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor QualType getInnerType() const { 17557536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getTypePtr()->getPattern(); 17567536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 17577536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 17587536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1759b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanstruct AtomicTypeLocInfo { 1760b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation KWLoc, LParenLoc, RParenLoc; 1761b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 1762b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1763b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanclass AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc, 1764b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman AtomicType, AtomicTypeLocInfo> { 1765ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 1766b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman TypeLoc getValueLoc() const { 1767b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getInnerTypeLoc(); 1768b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1769b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1770b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getLocalSourceRange() const { 1771b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getKWLoc(), getRParenLoc()); 1772b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1773b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1774b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getKWLoc() const { 1775b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->KWLoc; 1776b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1777b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setKWLoc(SourceLocation Loc) { 1778b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->KWLoc = Loc; 1779b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1780b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1781b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getLParenLoc() const { 1782b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->LParenLoc; 1783b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1784b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setLParenLoc(SourceLocation Loc) { 1785b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->LParenLoc = Loc; 1786b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1787b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1788b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getRParenLoc() const { 1789b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->RParenLoc; 1790b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1791b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setRParenLoc(SourceLocation Loc) { 1792b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->RParenLoc = Loc; 1793b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1794b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1795b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getParensRange() const { 1796b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getLParenLoc(), getRParenLoc()); 1797b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1798b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setParensRange(SourceRange Range) { 1799b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Range.getBegin()); 1800b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Range.getEnd()); 1801b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1802b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1803b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1804b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setKWLoc(Loc); 1805b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Loc); 1806b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Loc); 1807b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1808b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1809b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman QualType getInnerType() const { 1810b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getTypePtr()->getValueType(); 1811b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1812b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 1813b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1814b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1815b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis} 1816b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1817b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif 1818