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 173c385c28cf1f27b193a620d2e51f814873362cebJohn McCall#include "clang/AST/Decl.h" 18833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h" 1930a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/Type.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: 47464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// \brief Convert to the specified TypeLoc type, asserting that this TypeLoc 48464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// is of the desired type. 4939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie template<typename T> 5039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T castAs() const { 5165124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie assert(T::isKind(*this)); 5239e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T t; 5339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc& tl = t; 5439e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie tl = *this; 5539e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return t; 5639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie } 57464011827c5f9047caaba7e245556d66a65a15b6David Blaikie 58464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// \brief Convert to the specified TypeLoc type, returning a null TypeLoc if 59464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// this TypeLoc is not of the desired type. 6039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie template<typename T> 6139e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T getAs() const { 6265124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie if (!T::isKind(*this)) 6339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return T(); 6439e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T t; 6539e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc& tl = t; 6639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie tl = *this; 6739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return t; 6839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie } 6939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie 7051bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum, 7151bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// except it also defines a Qualified enum that corresponds to the 7251bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// QualifiedLoc class. 7351bd803fbdade51d674598ed45da3d54190a656cJohn McCall enum TypeLocClass { 7451bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base) 7551bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \ 7651bd803fbdade51d674598ed45da3d54190a656cJohn McCall Class = Type::Class, 7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def" 7851bd803fbdade51d674598ed45da3d54190a656cJohn McCall Qualified 7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall }; 8051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 8134a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc() : Ty(0), Data(0) { } 8234a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(QualType ty, void *opaqueData) 8334a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } 84f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall TypeLoc(const Type *ty, void *opaqueData) 8534a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty), Data(opaqueData) { } 86b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 8751bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 88a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor if (getType().hasLocalQualifiers()) return Qualified; 8951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getType()->getTypeClass(); 9051bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 9151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 9234a0447b8072e0da14c0980597da9d03a1495662John McCall bool isNull() const { return !Ty; } 937247c88d1e41514a41085f83ebf03dd5220e054aDavid Blaikie LLVM_EXPLICIT operator bool() const { return Ty; } 94b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 95b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of type source info data block for the given type. 96b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static unsigned getFullDataSizeForType(QualType Ty); 97b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 9844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// \brief Returns the alignment of type source info data block for 9944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// the given type. 10044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman static unsigned getLocalAlignmentForType(QualType Ty); 10144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 102b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the type for which this source info wrapper provides 103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// information. 10451bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getType() const { 10551bd803fbdade51d674598ed45da3d54190a656cJohn McCall return QualType::getFromOpaquePtr(Ty); 10651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 10734a0447b8072e0da14c0980597da9d03a1495662John McCall 108f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 10934a0447b8072e0da14c0980597da9d03a1495662John McCall return QualType::getFromOpaquePtr(Ty).getTypePtr(); 11034a0447b8072e0da14c0980597da9d03a1495662John McCall } 111b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 112b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis /// \brief Get the pointer where source information is stored. 11351bd803fbdade51d674598ed45da3d54190a656cJohn McCall void *getOpaqueData() const { 11451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Data; 11551bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 116b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 117e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the begin source location. 118e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getBeginLoc() const; 119e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 120e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the end source location. 121e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getEndLoc() const; 122e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 123833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the full source range. 124aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceRange getSourceRange() const LLVM_READONLY { 125e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara return SourceRange(getBeginLoc(), getEndLoc()); 126833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 127aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } 128aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } 129833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 130833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the local source range. 131bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 132bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara return getLocalSourceRangeImpl(*this); 13351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 134b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 135b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block. 13634a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 13751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getFullDataSizeForType(getType()); 13834a0447b8072e0da14c0980597da9d03a1495662John McCall } 139b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 140b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the 141b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// TypeLoc is a PointerLoc and next TypeLoc is for "int". 14251bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLoc getNextTypeLoc() const { 14351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getNextTypeLocImpl(*this); 14451bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 145b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 14634a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Skips past any qualifiers, if this is qualified. 14751bd803fbdade51d674598ed45da3d54190a656cJohn McCall UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header 14834a0447b8072e0da14c0980597da9d03a1495662John McCall 14939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc IgnoreParens() const; 150140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara 1514ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// \brief Initializes this to state that every location in this 1524ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// type is the given location. 1534ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// 1544ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// This method exists to provide a simple transition for code that 1554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// relies on location-less types. 156c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initialize(ASTContext &Context, SourceLocation Loc) const { 157c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeImpl(Context, *this, Loc); 1584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 16045ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// \brief Initializes this by copying its information from another 16145ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// TypeLoc of the same type. 16245ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein void initializeFullCopy(TypeLoc Other) const { 163711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 164711c52bb20d0c69063b52a99826fb7d2835501f1John McCall size_t Size = getFullDataSize(); 165711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 166711c52bb20d0c69063b52a99826fb7d2835501f1John McCall } 167711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 168711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// \brief Initializes this by copying its information from another 169711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// TypeLoc of the same type. The given size must be the full data 170711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// size. 171711c52bb20d0c69063b52a99826fb7d2835501f1John McCall void initializeFullCopy(TypeLoc Other, unsigned Size) const { 172711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 173711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getFullDataSize() == Size); 174711c52bb20d0c69063b52a99826fb7d2835501f1John McCall memcpy(getOpaqueData(), Other.getOpaqueData(), Size); 17545ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein } 17645ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein 177b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { 178b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; 179b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 180b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 181b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) { 182b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return !(LHS == RHS); 183b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 184b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1854ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate: 18665124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc&) { 18765124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return true; 18865124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie } 18965124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie 190ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static void initializeImpl(ASTContext &Context, TypeLoc TL, 191ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation Loc); 19251bd803fbdade51d674598ed45da3d54190a656cJohn McCall static TypeLoc getNextTypeLocImpl(TypeLoc TL); 193723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara static TypeLoc IgnoreParensImpl(TypeLoc TL); 194bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara static SourceRange getLocalSourceRangeImpl(TypeLoc TL); 195b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 196b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1973c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info. 1983c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const { 1994ab92891a53adda8c52c1947351371da58e33f64Gabor Greif return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); 2003c385c28cf1f27b193a620d2e51f814873362cebJohn McCall} 2013c385c28cf1f27b193a620d2e51f814873362cebJohn McCall 20234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 203489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers. 20434a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc { 20534a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 20634a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc() {} 207f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {} 20834a0447b8072e0da14c0980597da9d03a1495662John McCall 209f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 210f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall return reinterpret_cast<const Type*>(Ty); 21134a0447b8072e0da14c0980597da9d03a1495662John McCall } 21234a0447b8072e0da14c0980597da9d03a1495662John McCall 21351bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 21451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getTypePtr()->getTypeClass(); 21551bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 21651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 21739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 21839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 21965124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 22065124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return !TL.getType().hasLocalQualifiers(); 22134a0447b8072e0da14c0980597da9d03a1495662John McCall } 22234a0447b8072e0da14c0980597da9d03a1495662John McCall}; 22334a0447b8072e0da14c0980597da9d03a1495662John McCall 22434a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 22534a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers. 22634a0447b8072e0da14c0980597da9d03a1495662John McCall/// 22734a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for 22834a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers. 22951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc { 23034a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 231bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 23234a0447b8072e0da14c0980597da9d03a1495662John McCall return SourceRange(); 23334a0447b8072e0da14c0980597da9d03a1495662John McCall } 23434a0447b8072e0da14c0980597da9d03a1495662John McCall 23534a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc getUnqualifiedLoc() const { 23644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned align = 23744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman TypeLoc::getLocalAlignmentForType(QualType(getTypePtr(), 0)); 23844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman uintptr_t dataInt = reinterpret_cast<uintptr_t>(Data); 23944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman dataInt = llvm::RoundUpToAlignment(dataInt, align); 24044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return UnqualTypeLoc(getTypePtr(), reinterpret_cast<void*>(dataInt)); 24134a0447b8072e0da14c0980597da9d03a1495662John McCall } 24234a0447b8072e0da14c0980597da9d03a1495662John McCall 2434ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// Initializes the local data of this type source info block to 2444ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// provide no information. 245c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 2464ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall // do nothing 2474ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2484ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 2494ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 2504ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getUnqualifiedLoc(); 2514ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2524ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 25334a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block that is 25434a0447b8072e0da14c0980597da9d03a1495662John McCall /// specific to this type. 25534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 25634a0447b8072e0da14c0980597da9d03a1495662John McCall // In fact, we don't currently preserve any location information 25734a0447b8072e0da14c0980597da9d03a1495662John McCall // for qualifiers. 25834a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 25934a0447b8072e0da14c0980597da9d03a1495662John McCall } 26034a0447b8072e0da14c0980597da9d03a1495662John McCall 26144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// \brief Returns the alignment of the type source info data block that is 26244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// specific to this type. 26344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataAlignment() const { 26444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman // We don't preserve any location information. 26544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 26634a0447b8072e0da14c0980597da9d03a1495662John McCall } 26734a0447b8072e0da14c0980597da9d03a1495662John McCall 26839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 26939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 27065124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 27165124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return TL.getType().hasLocalQualifiers(); 27234a0447b8072e0da14c0980597da9d03a1495662John McCall } 27334a0447b8072e0da14c0980597da9d03a1495662John McCall}; 27434a0447b8072e0da14c0980597da9d03a1495662John McCall 27534a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { 27639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie if (QualifiedTypeLoc Loc = getAs<QualifiedTypeLoc>()) 27739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return Loc.getUnqualifiedLoc(); 27839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return castAs<UnqualTypeLoc>(); 27934a0447b8072e0da14c0980597da9d03a1495662John McCall} 28034a0447b8072e0da14c0980597da9d03a1495662John McCall 28134a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond 282f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass. It is accepted for a single 283f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes. 28434a0447b8072e0da14c0980597da9d03a1495662John McCall/// 28570517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Base a class from which to derive 28670517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Derived the class deriving from this one 28770517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam TypeClass the concrete Type subclass associated with this 288f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// location type 28970517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam LocalData the structure type of local location data for 29034a0447b8072e0da14c0980597da9d03a1495662John McCall/// this type 29134a0447b8072e0da14c0980597da9d03a1495662John McCall/// 29234a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override 29334a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to 29434a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory. 29534a0447b8072e0da14c0980597da9d03a1495662John McCall/// 296a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define 297a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// QualType getInnerType() const 298a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's 299a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data. 30051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// 30151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be 30251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy. It is also not 30351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide 30451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information. It should be subclassed 30551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children 30651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type, 30751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from 30851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead. 30934a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData> 31034a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base { 31134a0447b8072e0da14c0980597da9d03a1495662John McCall 31234a0447b8072e0da14c0980597da9d03a1495662John McCall const Derived *asDerived() const { 31334a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<const Derived*>(this); 31434a0447b8072e0da14c0980597da9d03a1495662John McCall } 31534a0447b8072e0da14c0980597da9d03a1495662John McCall 31639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 31765124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 31844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return !TL.getType().hasLocalQualifiers() && 31944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman Derived::classofType(TL.getTypePtr()); 32034a0447b8072e0da14c0980597da9d03a1495662John McCall } 32134a0447b8072e0da14c0980597da9d03a1495662John McCall 32234a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classofType(const Type *Ty) { 32334a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeClass::classof(Ty); 32434a0447b8072e0da14c0980597da9d03a1495662John McCall } 32534a0447b8072e0da14c0980597da9d03a1495662John McCall 32639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikiepublic: 32744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataAlignment() const { 32844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return std::max(llvm::alignOf<LocalData>(), 32944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman asDerived()->getExtraLocalDataAlignment()); 33020387efff0870da2c8b30bb62ae661239a903021Manuel Klimek } 33144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataSize() const { 33244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned size = sizeof(LocalData); 33344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); 33444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman size = llvm::RoundUpToAlignment(size, extraAlign); 33544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman size += asDerived()->getExtraLocalDataSize(); 33644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return size; 337e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 338e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 3394ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 3404ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getNextTypeLoc(asDerived()->getInnerType()); 3414ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3424ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 343f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 34451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 34534a0447b8072e0da14c0980597da9d03a1495662John McCall } 34634a0447b8072e0da14c0980597da9d03a1495662John McCall 34751bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected: 34834a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 34934a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 35034a0447b8072e0da14c0980597da9d03a1495662John McCall } 35134a0447b8072e0da14c0980597da9d03a1495662John McCall 35244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 35344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 35444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 35544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 35634a0447b8072e0da14c0980597da9d03a1495662John McCall LocalData *getLocalData() const { 35734a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<LocalData*>(Base::Data); 35834a0447b8072e0da14c0980597da9d03a1495662John McCall } 35934a0447b8072e0da14c0980597da9d03a1495662John McCall 36034a0447b8072e0da14c0980597da9d03a1495662John McCall /// Gets a pointer past the Info structure; useful for classes with 36134a0447b8072e0da14c0980597da9d03a1495662John McCall /// local data that can't be captured in the Info (e.g. because it's 36234a0447b8072e0da14c0980597da9d03a1495662John McCall /// of variable size). 36334a0447b8072e0da14c0980597da9d03a1495662John McCall void *getExtraLocalData() const { 36444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned size = sizeof(LocalData); 36544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); 36644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman size = llvm::RoundUpToAlignment(size, extraAlign); 36744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return reinterpret_cast<char*>(Base::Data) + size; 36834a0447b8072e0da14c0980597da9d03a1495662John McCall } 369ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 37034a0447b8072e0da14c0980597da9d03a1495662John McCall void *getNonLocalData() const { 37144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman uintptr_t data = reinterpret_cast<uintptr_t>(Base::Data); 37244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman data += asDerived()->getLocalDataSize(); 37344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman data = llvm::RoundUpToAlignment(data, getNextTypeAlign()); 37444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return reinterpret_cast<void*>(data); 37534a0447b8072e0da14c0980597da9d03a1495662John McCall } 37634a0447b8072e0da14c0980597da9d03a1495662John McCall 377a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall struct HasNoInnerType {}; 378a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall HasNoInnerType getInnerType() const { return HasNoInnerType(); } 37934a0447b8072e0da14c0980597da9d03a1495662John McCall 38034a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc getInnerTypeLoc() const { 38134a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); 38234a0447b8072e0da14c0980597da9d03a1495662John McCall } 38334a0447b8072e0da14c0980597da9d03a1495662John McCall 38434a0447b8072e0da14c0980597da9d03a1495662John McCallprivate: 38534a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getInnerTypeSize() const { 386a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeSize(asDerived()->getInnerType()); 387a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall } 388a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall 389a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(HasNoInnerType _) const { 39034a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 39134a0447b8072e0da14c0980597da9d03a1495662John McCall } 39234a0447b8072e0da14c0980597da9d03a1495662John McCall 393a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(QualType _) const { 394a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeLoc().getFullDataSize(); 39534a0447b8072e0da14c0980597da9d03a1495662John McCall } 3964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 39744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign() const { 39844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return getNextTypeAlign(asDerived()->getInnerType()); 39944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 40044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 40144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign(HasNoInnerType _) const { 40244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 40344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 40444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 40544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign(QualType T) const { 40644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return TypeLoc::getLocalAlignmentForType(T); 40744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 40844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 4094ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(HasNoInnerType _) const { 4104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(); 4114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 4124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 4134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(QualType T) const { 4144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(T, getNonLocalData()); 4154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 41634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 41734a0447b8072e0da14c0980597da9d03a1495662John McCall 41851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract 41951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source 42051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information. See the note on ConcreteTypeLoc. 42151bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass> 42251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base { 42339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 424713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor static bool classofType(const Type *Ty) { 425713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor return TypeClass::classof(Ty); 426713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor } 427713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor 42865124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 42944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return !TL.getType().hasLocalQualifiers() && 43044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman Derived::classofType(TL.getTypePtr()); 431b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 43265124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const UnqualTypeLoc &TL) { 43365124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return Derived::classofType(TL.getTypePtr()); 434b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 435b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 43639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikiepublic: 437f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 43851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 4394ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 44034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 441b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 442ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 44351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo { 44434a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation NameLoc; 445b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 446b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 44751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to 44851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier. 449ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikieclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 450ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc, 451ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Type, 452ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecLocInfo> { 453b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 45444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman enum { LocalDataSize = sizeof(TypeSpecLocInfo), 45544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman LocalDataAlignment = llvm::AlignOf<TypeSpecLocInfo>::Alignment }; 456ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 457b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getNameLoc() const { 45851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->NameLoc; 459b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 460b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setNameLoc(SourceLocation Loc) { 46151bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->NameLoc = Loc; 462b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 463bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 464b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getNameLoc(), getNameLoc()); 465b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 466c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 4674ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setNameLoc(Loc); 4684ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 469ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 47039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 47139e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 47265124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL); 47351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 4744ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 475ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo { 477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation BuiltinLoc; 478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types. 481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc, 483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType, 484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinLocInfo> { 485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic: 486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getBuiltinLoc() const { 487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getLocalData()->BuiltinLoc; 488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setBuiltinLoc(SourceLocation Loc) { 490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getLocalData()->BuiltinLoc = Loc; 491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getNameLoc() const { return getBuiltinLoc(); } 494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs& getWrittenBuiltinSpecs() { 496ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 497ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 498ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { 499ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 500ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 501ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 502ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool needsExtraLocalData() const { 503ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType::Kind bk = getTypePtr()->getKind(); 504ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) 505d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble) 506ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::UChar 507ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::SChar; 508ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 509ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 510ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor unsigned getExtraLocalDataSize() const { 511d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; 512ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 51444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 51544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return needsExtraLocalData() ? llvm::alignOf<WrittenBuiltinSpecs>() : 1; 51644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 51744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 518bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return SourceRange(getBuiltinLoc(), getBuiltinLoc()); 520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierSign getWrittenSignSpec() const { 523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 524ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); 525ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 526ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSS_unspecified; 527ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 528ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenSignSpec() const { 529ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenSignSpec() != TSS_unspecified; 530ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 531ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenSignSpec(TypeSpecifierSign written) { 532ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 533ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Sign = written; 534ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 535ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 536ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierWidth getWrittenWidthSpec() const { 537ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 538ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); 539ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 540ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSW_unspecified; 541ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 542ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenWidthSpec() const { 543ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenWidthSpec() != TSW_unspecified; 544ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 545ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenWidthSpec(TypeSpecifierWidth written) { 546ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 547ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Width = written; 548ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 549ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 550ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierType getWrittenTypeSpec() const; 551ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenTypeSpec() const { 552ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenTypeSpec() != TST_unspecified; 553ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 554ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenTypeSpec(TypeSpecifierType written) { 555ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 556ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Type = written; 557ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 558ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 559ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasModeAttr() const { 560ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 561ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenBuiltinSpecs().ModeAttr; 562ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 563ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return false; 564ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 565ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setModeAttr(bool written) { 566ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 567ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().ModeAttr = written; 568ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 569ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 570c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 571ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor setBuiltinLoc(Loc); 572ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) { 573ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); 574ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Sign = TSS_unspecified; 575ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Width = TSW_unspecified; 576ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Type = TST_unspecified; 577ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.ModeAttr = false; 578ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 579ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 580ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 581ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 582ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 58351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs. 584ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 585ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefTypeLoc, 586ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefType> { 58751bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 588162e1c1b487352434552147967c3dd296ebee2f7Richard Smith TypedefNameDecl *getTypedefNameDecl() const { 58934a0447b8072e0da14c0980597da9d03a1495662John McCall return getTypePtr()->getDecl(); 5909036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis } 59134a0447b8072e0da14c0980597da9d03a1495662John McCall}; 5929036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis 5933cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class 5943cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates. 5953cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc : 5963cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 5973cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameTypeLoc, 5983cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameType> { 599427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 600427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis CXXRecordDecl *getDecl() const { 601427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis return getTypePtr()->getDecl(); 602427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis } 6033cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall}; 6043cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 605ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls. 606ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc : 607ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 608ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypeLoc, 609ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType> { 610ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 611ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypenameDecl *getDecl() const { 612ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return getTypePtr()->getDecl(); 613ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 614ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 615ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 616ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types. Note that this only 617ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo' 618ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc. We currently 619ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of 620ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C. 621ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 622ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagTypeLoc, 623ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagType> { 624ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 625ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagDecl *getDecl() const { return getTypePtr()->getDecl(); } 6266f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis 627ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief True if the tag was defined in this type specifier. 6286f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis bool isDefinition() const { 629a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis TagDecl *D = getDecl(); 630a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis return D->isCompleteDefinition() && 631a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis (D->getIdentifier() == 0 || D->getLocation() == getNameLoc()); 6326f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis } 633ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 634ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 635ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types. 636ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 637ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordTypeLoc, 638ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordType> { 639ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 640ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordDecl *getDecl() const { return getTypePtr()->getDecl(); } 641ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 642ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 643ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types. 644ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 645ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumTypeLoc, 646ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumType> { 647ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 648ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumDecl *getDecl() const { return getTypePtr()->getDecl(); } 649ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 650b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 65149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters. 652ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc : 653ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 654ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmTypeLoc, 655ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmType> { 656960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruthpublic: 657960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruth TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } 65849a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 65949a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 66049a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters. 66149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc : 662ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 663ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmTypeLoc, 664ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmType> { 66549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 66651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 667c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor /// \brief Wrapper for substituted template type parameters. 668c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc : 669c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 670c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackTypeLoc, 671c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackType> { 672c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor}; 673c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor 6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo { 6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall union { 6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *ExprOperand; 6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// A raw SourceLocation. 6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall unsigned EnumOperandLoc; 6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall }; 6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange OperandParens; 6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation AttrLoc; 6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type. 6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc, 6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType, 6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedLocInfo> { 6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic: 6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType::Kind getAttrKind() const { 6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getAttrKind(); 6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrExprOperand() const { 6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstExprOperandKind && 6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastExprOperandKind); 7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrEnumOperand() const { 7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstEnumOperandKind && 7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastEnumOperandKind); 7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrOperand() const { 7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return hasAttrExprOperand() || hasAttrEnumOperand(); 7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The modified type, which is generally canonically different from 7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// the attribute type. 7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// int main(int, char**) __attribute__((noreturn)) 7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ~~~ ~~~~~~~~~~~~~ 7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall TypeLoc getModifiedLoc() const { 7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getInnerTypeLoc(); 7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute name, i.e. 7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// __attribute__((regparm(1000))) 7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~~~~ 7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrNameLoc() const { 7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->AttrLoc; 7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrNameLoc(SourceLocation loc) { 7269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->AttrLoc = loc; 7279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The attribute's expression operand, if it has one. 7309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void *cur_thread __attribute__((address_space(21))) 7319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~ 7329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *getAttrExprOperand() const { 7339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 7349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->ExprOperand; 7359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrExprOperand(Expr *e) { 7379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 7389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->ExprOperand = e; 7399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute's enumerated operand, if it has one. 7429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 7439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~ 7449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrEnumOperandLoc() const { 7459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 7469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc); 7479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrEnumOperandLoc(SourceLocation loc) { 7499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 7509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->EnumOperandLoc = loc.getRawEncoding(); 7519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the parentheses around the operand, if there is 7549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// an operand. 7559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 7569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^ ^ 7579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getAttrOperandParensRange() const { 7589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 7599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->OperandParens; 7609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrOperandParensRange(SourceRange range) { 7629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 7639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->OperandParens = range; 7649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getLocalSourceRange() const { 7679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // Note that this does *not* include the range of the attribute 7689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // enclosure, e.g.: 7699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // __attribute__((foo(bar))) 7709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~~~~~~~~~~~~~~ ~~ 7719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // or 7729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // [[foo(bar)]] 7739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~ ~~ 7749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // That enclosure doesn't necessarily belong to a single attribute 7759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // anyway. 7769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange range(getAttrNameLoc()); 7779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrOperand()) 7789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall range.setEnd(getAttrOperandParensRange().getEnd()); 7799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return range; 7809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 782c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation loc) { 7839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrNameLoc(loc); 7849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrExprOperand()) { 7859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrExprOperand(0); 7879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } else if (hasAttrEnumOperand()) { 7889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 7899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrEnumOperandLoc(loc); 7909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType getInnerType() const { 7949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getModifiedType(); 7959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 7979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 798eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 79934a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo { 80054e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation LAngleLoc; 80154e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation RAngleLoc; 802ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall bool HasBaseTypeAsWritten; 803eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis}; 804eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 80554e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with 80654e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols. 80754e14c4db764c0636160d26c5bbf491637c83a76John McCall// 80854e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or 80954e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType. 810c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 811c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectTypeLoc, 812c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectType, 813c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCProtocolListLocInfo> { 814f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis // SourceLocations are stored after Info, one for each Protocol. 815f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation *getProtocolLocArray() const { 81654e14c4db764c0636160d26c5bbf491637c83a76John McCall return (SourceLocation*) this->getExtraLocalData(); 81754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 81854e14c4db764c0636160d26c5bbf491637c83a76John McCall 819f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic: 820f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getLAngleLoc() const { 82154e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->LAngleLoc; 822f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 823f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setLAngleLoc(SourceLocation Loc) { 82454e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->LAngleLoc = Loc; 825f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 826f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 827f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getRAngleLoc() const { 82854e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getLocalData()->RAngleLoc; 829f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 830f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setRAngleLoc(SourceLocation Loc) { 83154e14c4db764c0636160d26c5bbf491637c83a76John McCall this->getLocalData()->RAngleLoc = Loc; 832f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 833f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 834f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis unsigned getNumProtocols() const { 83554e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getTypePtr()->getNumProtocols(); 836f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 837f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 838f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getProtocolLoc(unsigned i) const { 839f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 840f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return getProtocolLocArray()[i]; 841f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 842f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setProtocolLoc(unsigned i, SourceLocation Loc) { 843f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 844f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis getProtocolLocArray()[i] = Loc; 845f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 846f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 847f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis ObjCProtocolDecl *getProtocol(unsigned i) const { 848f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 84954e14c4db764c0636160d26c5bbf491637c83a76John McCall return *(this->getTypePtr()->qual_begin() + i); 850f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 851ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 852c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall bool hasBaseTypeAsWritten() const { 853ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall return getLocalData()->HasBaseTypeAsWritten; 854c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 855c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 856c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setHasBaseTypeAsWritten(bool HasBaseType) { 857ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall getLocalData()->HasBaseTypeAsWritten = HasBaseType; 858c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 859c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 860c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TypeLoc getBaseLoc() const { 861c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getInnerTypeLoc(); 862c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 863c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 864bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 865f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return SourceRange(getLAngleLoc(), getRAngleLoc()); 866f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 867f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 868c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 869ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall setHasBaseTypeAsWritten(true); 870c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setLAngleLoc(Loc); 871c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setRAngleLoc(Loc); 872c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall for (unsigned i = 0, e = getNumProtocols(); i != e; ++i) 873c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setProtocolLoc(i, Loc); 8744ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 8754ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 87634a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 87754e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getNumProtocols() * sizeof(SourceLocation); 87854e14c4db764c0636160d26c5bbf491637c83a76John McCall } 879c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 88044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 88144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<SourceLocation>(); 88244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 88344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 884c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall QualType getInnerType() const { 885c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getTypePtr()->getBaseType(); 886c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 88754e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 88854e14c4db764c0636160d26c5bbf491637c83a76John McCall 88954e14c4db764c0636160d26c5bbf491637c83a76John McCall 890c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo { 89154e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation NameLoc; 8921de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation NameEndLoc; 89354e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 89454e14c4db764c0636160d26c5bbf491637c83a76John McCall 89554e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces. 896a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc, 897c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceTypeLoc, 898c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceType, 899c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceLocInfo> { 90054e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 90154e14c4db764c0636160d26c5bbf491637c83a76John McCall ObjCInterfaceDecl *getIFaceDecl() const { 90254e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getDecl(); 90354e14c4db764c0636160d26c5bbf491637c83a76John McCall } 90454e14c4db764c0636160d26c5bbf491637c83a76John McCall 90554e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation getNameLoc() const { 90654e14c4db764c0636160d26c5bbf491637c83a76John McCall return getLocalData()->NameLoc; 90754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 90854e14c4db764c0636160d26c5bbf491637c83a76John McCall 90954e14c4db764c0636160d26c5bbf491637c83a76John McCall void setNameLoc(SourceLocation Loc) { 91054e14c4db764c0636160d26c5bbf491637c83a76John McCall getLocalData()->NameLoc = Loc; 91154e14c4db764c0636160d26c5bbf491637c83a76John McCall } 9121de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 913bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 9141de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return SourceRange(getNameLoc(), getNameEndLoc()); 9151de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 9161de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 9171de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation getNameEndLoc() const { 9181de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return getLocalData()->NameEndLoc; 9191de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 9201de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 9211de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian void setNameEndLoc(SourceLocation Loc) { 9221de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian getLocalData()->NameEndLoc = Loc; 92354e14c4db764c0636160d26c5bbf491637c83a76John McCall } 92454e14c4db764c0636160d26c5bbf491637c83a76John McCall 925c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 92654e14c4db764c0636160d26c5bbf491637c83a76John McCall setNameLoc(Loc); 9276c2fd0d71406c5f311ff00208448a63fa9071453Benjamin Kramer setNameEndLoc(Loc); 928f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 92954e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 93054e14c4db764c0636160d26c5bbf491637c83a76John McCall 931075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo { 932075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation LParenLoc; 933075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation RParenLoc; 934075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 935075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 936075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc 937075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType, 938075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenLocInfo> { 939075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic: 940075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getLParenLoc() const { 941075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->LParenLoc; 942075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 943075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getRParenLoc() const { 944075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->RParenLoc; 945075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 946075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setLParenLoc(SourceLocation Loc) { 947075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->LParenLoc = Loc; 948075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 949075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setRParenLoc(SourceLocation Loc) { 950075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->RParenLoc = Loc; 951075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 952075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 953075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceRange getLocalSourceRange() const { 954075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 955075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 956075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 957c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 958075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setLParenLoc(Loc); 959075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setRParenLoc(Loc); 960075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 961075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 962075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara TypeLoc getInnerLoc() const { 963075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return getInnerTypeLoc(); 964075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 965075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 966075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType getInnerType() const { 967075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getTypePtr()->getInnerType(); 968075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 969075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 970075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 97139e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieinline TypeLoc TypeLoc::IgnoreParens() const { 97265124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie if (ParenTypeLoc::isKind(*this)) 97339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return IgnoreParensImpl(*this); 97439e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return *this; 97539e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie} 976f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 97712df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 97812df246d6dea2ee1f92c186f922f1afcf499647aReid Klecknerstruct DecayedLocInfo { }; // Nothing. 97912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 98012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner/// \brief Wrapper for source info for pointers decayed from arrays and 981cd9c2f247dd354d8bb5f549f986a9c4ccf08f1dbReid Kleckner/// functions. 98212df246d6dea2ee1f92c186f922f1afcf499647aReid Klecknerclass DecayedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, DecayedTypeLoc, 98312df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner DecayedType, DecayedLocInfo> { 98412df246d6dea2ee1f92c186f922f1afcf499647aReid Klecknerpublic: 98512df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner TypeLoc getOriginalLoc() const { 98612df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return getInnerTypeLoc(); 98712df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 98812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 98912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner void initializeLocal(ASTContext &Context, SourceLocation Loc) { 99012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // do nothing 99112df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 99212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 99312df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner QualType getInnerType() const { 99412df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // The inner type is the undecayed type, since that's what we have source 99512df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // location information for. 99612df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return getTypePtr()->getOriginalType(); 99712df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 99812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 99912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner SourceRange getLocalSourceRange() const { 100012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return SourceRange(); 100112df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 100212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 100312df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner unsigned getLocalDataSize() const { 100412df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // sizeof(DecayedLocInfo) is 1, but we don't need its address to be unique 100512df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // anyway. TypeLocBuilder can't handle data sizes of 1. 100612df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return 0; // No data. 100712df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 100812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner}; 100912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 101012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 101151bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo { 101234a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation StarLoc; 1013f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis}; 1014f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 1015ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// A base class for 101651bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> 101751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, 101851bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass, LocalData> { 1019ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 102051bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getSigilLoc() const { 102151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->StarLoc; 1022b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 102351bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setSigilLoc(SourceLocation Loc) { 102451bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->StarLoc = Loc; 1025b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1026b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1027b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getPointeeLoc() const { 102851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getInnerTypeLoc(); 1029b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1030b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1031bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 103251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return SourceRange(getSigilLoc(), getSigilLoc()); 1033b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1034b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1035c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 103651bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 10374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 10384ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 103951bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getInnerType() const { 104051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getTypePtr()->getPointeeType(); 104151bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 104234a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1043b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1044b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 104551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers. 104651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc, 104751bd803fbdade51d674598ed45da3d54190a656cJohn McCall PointerType> { 104851bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 104951bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getStarLoc() const { 105051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 105151bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 105251bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setStarLoc(SourceLocation Loc) { 105351bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 105451bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 1055b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1056b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 105751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1058b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers. 105951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc, 106051bd803fbdade51d674598ed45da3d54190a656cJohn McCall BlockPointerType> { 1061b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1062b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getCaretLoc() const { 106351bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1064b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1065b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setCaretLoc(SourceLocation Loc) { 106651bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1067b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 106834a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1069b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1070b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnarastruct MemberPointerLocInfo : public PointerLikeLocInfo { 1071b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *ClassTInfo; 1072b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara}; 1073b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1074b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers. 107551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc, 1076b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerType, 1077b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerLocInfo> { 1078b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1079b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getStarLoc() const { 108051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1081b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1082b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setStarLoc(SourceLocation Loc) { 108351bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 10844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1085b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1086b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara const Type *getClass() const { 1087b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getTypePtr()->getClass(); 1088b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1089b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *getClassTInfo() const { 1090b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getLocalData()->ClassTInfo; 1091b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1092b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void setClassTInfo(TypeSourceInfo* TI) { 1093b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara getLocalData()->ClassTInfo = TI; 1094b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1095b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1096b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1097b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setSigilLoc(Loc); 1098b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setClassTInfo(0); 1099b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1100b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1101b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara SourceRange getLocalSourceRange() const { 1102b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara if (TypeSourceInfo *TI = getClassTInfo()) 1103b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc()); 1104b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara else 1105b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(getStarLoc()); 1106b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 110734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1109c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information. 1110c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc : 1111c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc, 1112c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerType> { 1113c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic: 1114c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall SourceLocation getStarLoc() const { 1115c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getSigilLoc(); 1116c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1117c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1118c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setStarLoc(SourceLocation Loc) { 1119c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setSigilLoc(Loc); 1120c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1121c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall}; 1122c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1123b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 112451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc, 112551bd803fbdade51d674598ed45da3d54190a656cJohn McCall ReferenceType> { 112654e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 112754e14c4db764c0636160d26c5bbf491637c83a76John McCall QualType getInnerType() const { 112854e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getPointeeTypeAsWritten(); 112954e14c4db764c0636160d26c5bbf491637c83a76John McCall } 1130b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1132bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc : 1133bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1134bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceTypeLoc, 1135bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceType> { 1136b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1137b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getAmpLoc() const { 113851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1139b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1140b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setAmpLoc(SourceLocation Loc) { 114151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1142b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 114351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1144b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1145bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc : 1146bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1147bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceTypeLoc, 1148bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceType> { 114951bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 115051bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getAmpAmpLoc() const { 115151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 115351bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setAmpAmpLoc(SourceLocation Loc) { 115451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 115651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 115934a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo { 1160796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeBegin; 116159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation LParenLoc; 116259c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation RParenLoc; 1163796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeEnd; 1164b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1165b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1166b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions. 116751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 116851bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionTypeLoc, 116951bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionType, 117051bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionLocInfo> { 1171b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1172796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeBegin() const { 1173796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeBegin; 1174b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1175796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeBegin(SourceLocation L) { 1176796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeBegin = L; 1177b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1178b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1179796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeEnd() const { 1180796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeEnd; 1181b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1182796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeEnd(SourceLocation L) { 1183796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeEnd = L; 1184b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1185b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 118659c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation getLParenLoc() const { 118759c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return this->getLocalData()->LParenLoc; 118859c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 118959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara void setLParenLoc(SourceLocation Loc) { 119059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara this->getLocalData()->LParenLoc = Loc; 119159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 119259c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 119359c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation getRParenLoc() const { 119459c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return this->getLocalData()->RParenLoc; 119559c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 119659c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara void setRParenLoc(SourceLocation Loc) { 119759c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara this->getLocalData()->RParenLoc = Loc; 119859c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 119959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 120059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceRange getParensRange() const { 120159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 120259c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 120359c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 1204ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman ArrayRef<ParmVarDecl *> getParams() const { 1205ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman return ArrayRef<ParmVarDecl *>(getParmArray(), getNumArgs()); 1206ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman } 1207ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman 1208a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor // ParmVarDecls* are stored after Info, one for each argument. 1209a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **getParmArray() const { 1210a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor return (ParmVarDecl**) getExtraLocalData(); 1211a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor } 1212a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor 1213b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis unsigned getNumArgs() const { 121434a0447b8072e0da14c0980597da9d03a1495662John McCall if (isa<FunctionNoProtoType>(getTypePtr())) 1215b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return 0; 121634a0447b8072e0da14c0980597da9d03a1495662John McCall return cast<FunctionProtoType>(getTypePtr())->getNumArgs(); 1217b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1218b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; } 1219b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } 1220b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1221b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getResultLoc() const { 122234a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1223b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1224b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1225bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1226796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return SourceRange(getLocalRangeBegin(), getLocalRangeEnd()); 1227b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1228b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1229c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1230796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeBegin(Loc); 123159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara setLParenLoc(Loc); 123259c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara setRParenLoc(Loc); 1233796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeEnd(Loc); 12344ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall for (unsigned i = 0, e = getNumArgs(); i != e; ++i) 12354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setArg(i, NULL); 12364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 12374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1238b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block that is 1239b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// specific to this type. 124034a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 124134a0447b8072e0da14c0980597da9d03a1495662John McCall return getNumArgs() * sizeof(ParmVarDecl*); 1242b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1243b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 124444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 124544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<ParmVarDecl*>(); 124644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 124744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 124834a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getResultType(); } 124934a0447b8072e0da14c0980597da9d03a1495662John McCall}; 125034a0447b8072e0da14c0980597da9d03a1495662John McCall 125151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc : 125251bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 125351bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoTypeLoc, 125451bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoType> { 125551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 125651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 125751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc : 125851bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 125951bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoTypeLoc, 126051bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoType> { 126151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 126251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1263b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 126434a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo { 126534a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LBracketLoc, RBracketLoc; 126634a0447b8072e0da14c0980597da9d03a1495662John McCall Expr *Size; 1267b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1268b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1269b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays. 127051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 127151bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayTypeLoc, 127251bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayType, 127351bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayLocInfo> { 1274b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1275b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLBracketLoc() const { 127634a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LBracketLoc; 1277b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1278b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLBracketLoc(SourceLocation Loc) { 127934a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LBracketLoc = Loc; 1280b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1281b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1282b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRBracketLoc() const { 128334a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RBracketLoc; 1284b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1285b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRBracketLoc(SourceLocation Loc) { 128634a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RBracketLoc = Loc; 1287b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1288b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 128985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange getBracketsRange() const { 129085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return SourceRange(getLBracketLoc(), getRBracketLoc()); 129185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 129285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 1293b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis Expr *getSizeExpr() const { 129434a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->Size; 1295b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1296b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setSizeExpr(Expr *Size) { 129734a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->Size = Size; 1298b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1299b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1300b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getElementLoc() const { 130134a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1302b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1303b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1304bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1305b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLBracketLoc(), getRBracketLoc()); 1306b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1307b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1308c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 13094ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLBracketLoc(Loc); 13104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRBracketLoc(Loc); 13114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setSizeExpr(NULL); 13124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 13134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 131434a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getElementType(); } 1315b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1316b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 131751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc : 131851bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 131951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayTypeLoc, 132051bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayType> { 132151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 132251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 132351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc : 132451bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 132551bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayTypeLoc, 132651bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayType> { 132751bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 132851bd803fbdade51d674598ed45da3d54190a656cJohn McCall 132951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc : 133051bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 133151bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayTypeLoc, 133251bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayType> { 133351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 133451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 133551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 133651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc : 133751bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 133851bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayTypeLoc, 133951bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayType> { 134051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 134151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1342833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1343833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName. Rudimentary for now. 1344833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo { 1345833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation NameLoc; 1346833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1347833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1348833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo { 134955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation TemplateKWLoc; 1350833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc; 1351833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation RAngleLoc; 1352833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1353833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1354833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc : 1355833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall public ConcreteTypeLoc<UnqualTypeLoc, 1356833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc, 1357833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationType, 1358833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationLocInfo> { 1359833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic: 136055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateKeywordLoc() const { 136155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return getLocalData()->TemplateKWLoc; 136255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 136355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 136455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara getLocalData()->TemplateKWLoc = Loc; 136555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 136655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara 1367833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getLAngleLoc() const { 1368833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->LAngleLoc; 1369833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1370833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setLAngleLoc(SourceLocation Loc) { 1371833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->LAngleLoc = Loc; 1372833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1373833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1374833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getRAngleLoc() const { 1375833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->RAngleLoc; 1376833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1377833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setRAngleLoc(SourceLocation Loc) { 1378833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->RAngleLoc = Loc; 1379833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1380833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1381833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getNumArgs() const { 1382833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getTypePtr()->getNumArgs(); 1383833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1384833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 1385833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getArgInfos()[i] = AI; 1386833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1387833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 1388833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getArgInfos()[i]; 1389833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1390833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1391833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 1392833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 1393833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1394833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1395833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getTemplateNameLoc() const { 1396833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->NameLoc; 1397833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1398833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setTemplateNameLoc(SourceLocation Loc) { 1399833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->NameLoc = Loc; 1400833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1401833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1402833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief - Copy the location information from the given info. 1403833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void copy(TemplateSpecializationTypeLoc Loc) { 1404833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned size = getFullDataSize(); 1405833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall assert(size == Loc.getFullDataSize()); 1406833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1407833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // We're potentially copying Expr references here. We don't 1408a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall // bother retaining them because TypeSourceInfos live forever, so 1409833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // as long as the Expr was retained when originally written into 1410833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // the TypeLoc, we're okay. 1411833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall memcpy(Data, Loc.Data, size); 1412833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1413833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1414bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 141555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getTemplateKeywordLoc().isValid()) 141655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 141755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara else 141855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 1419833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1420833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1421c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 142255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateKeywordLoc(Loc); 142355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateNameLoc(Loc); 1424833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setLAngleLoc(Loc); 1425833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setRAngleLoc(Loc); 1426c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(), 142733500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 142833500955d731c73717af52088b7fc0e7a85681e7John McCall } 1429833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1430c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, 143133500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgument *Args, 143233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *ArgInfos, 1433c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor SourceLocation Loc); 1434833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1435833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getExtraLocalDataSize() const { 1436833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 1437833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1438833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 143944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 144044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<TemplateArgumentLocInfo>(); 144144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 144244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 1443833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate: 1444833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo *getArgInfos() const { 1445833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 1446833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1447833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1448833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1449ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 1450ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1451ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// All of these need proper implementations. 1452ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1453ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 145451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1455ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we 1456ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax). 1457ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1458ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorTypeLoc, 1459ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorType> { 146051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 146151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1462ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations. 146351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc, 146451bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorTypeLoc, 146551bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorType> { 146651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 146751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1468ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations. 146951bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType. 147051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc : 1471ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1472ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorTypeLoc, 1473ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorType> { 147451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 147551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1476ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword. 1477ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1478ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexTypeLoc, 1479ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexType> { 148051bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 148151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1482cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo { 1483cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation TypeofLoc; 1484cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation LParenLoc; 1485cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation RParenLoc; 148651bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 148751bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1488cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo { 1489cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1490cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1491cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo { 1492cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* UnderlyingTInfo; 1493cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1494cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1495cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo> 1496cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc 1497cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { 1498cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1499cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getTypeofLoc() const { 1500cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->TypeofLoc; 1501cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1502cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setTypeofLoc(SourceLocation Loc) { 1503cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->TypeofLoc = Loc; 1504cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1505cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1506cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getLParenLoc() const { 1507cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->LParenLoc; 1508cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1509cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setLParenLoc(SourceLocation Loc) { 1510cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->LParenLoc = Loc; 1511cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1512cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1513cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getRParenLoc() const { 1514cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->RParenLoc; 1515cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1516cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setRParenLoc(SourceLocation Loc) { 1517cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->RParenLoc = Loc; 1518cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1519cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1520cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceRange getParensRange() const { 1521cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getLParenLoc(), getRParenLoc()); 1522cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1523cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setParensRange(SourceRange range) { 1524cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(range.getBegin()); 1525cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(range.getEnd()); 1526cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1527cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1528bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1529cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getTypeofLoc(), getRParenLoc()); 1530cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1531cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1532c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1533cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setTypeofLoc(Loc); 1534cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(Loc); 1535cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(Loc); 1536cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1537cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1538cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1539cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, 1540cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprType, 1541cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprTypeLocInfo> { 1542cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1543cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Expr* getUnderlyingExpr() const { 1544cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return getTypePtr()->getUnderlyingExpr(); 1545cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1546cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // Reimplemented to account for GNU/C++ extension 1547cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // typeof unary-expression 1548cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // where there are no parentheses. 1549bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const; 1550cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1551cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1552cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc 1553cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { 1554cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1555cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall QualType getUnderlyingType() const { 1556cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getTypePtr()->getUnderlyingType(); 1557cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1558cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* getUnderlyingTInfo() const { 1559cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->UnderlyingTInfo; 1560cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1561cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setUnderlyingTInfo(TypeSourceInfo* TI) const { 1562cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->UnderlyingTInfo = TI; 1563cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 156451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 156551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1566ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens. 1567ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1568ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeTypeLoc, 1569ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeType> { 1570427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 1571427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); } 157251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 157351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1574ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntstruct UnaryTransformTypeLocInfo { 1575ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // FIXME: While there's only one unary transform right now, future ones may 1576ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // need different representations 1577ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation KWLoc, LParenLoc, RParenLoc; 1578ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo *UnderlyingTInfo; 1579ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1580ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1581ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntclass UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1582ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLoc, 1583ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformType, 1584ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLocInfo> { 1585ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntpublic: 1586ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getKWLoc() const { return getLocalData()->KWLoc; } 1587ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; } 1588ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1589ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; } 1590ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; } 1591ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1592ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; } 1593ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; } 1594ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1595ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo* getUnderlyingTInfo() const { 1596ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return getLocalData()->UnderlyingTInfo; 1597ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1598ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setUnderlyingTInfo(TypeSourceInfo *TInfo) { 1599ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt getLocalData()->UnderlyingTInfo = TInfo; 1600ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1601ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1602ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getLocalSourceRange() const { 1603ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getKWLoc(), getRParenLoc()); 1604ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1605ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1606ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getParensRange() const { 1607ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getLParenLoc(), getRParenLoc()); 1608ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1609ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setParensRange(SourceRange Range) { 1610ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Range.getBegin()); 1611ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Range.getEnd()); 1612ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1613ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1614ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1615ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setKWLoc(Loc); 1616ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Loc); 1617ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Loc); 1618ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1619ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1620ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 162134b41d939a1328f484511c6002ba2456db879a29Richard Smithclass AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 162234b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoTypeLoc, 162334b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoType> { 162434b41d939a1328f484511c6002ba2456db879a29Richard Smith}; 162534b41d939a1328f484511c6002ba2456db879a29Richard Smith 1626e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo { 162738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation ElaboratedKWLoc; 162838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara /// \brief Data associated with the nested-name-specifier location. 16299e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void *QualifierData; 1630e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1631e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1632e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1633e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc, 1634e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedType, 1635e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedLocInfo> { 1636e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 163738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 163838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1639e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 164038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 164138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1642e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1643e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 16449e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1645ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 16469e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData); 1647e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1648ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16499e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1650ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 16519e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor == getTypePtr()->getQualifier() && 16529e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor "Inconsistent nested-name-specifier pointer"); 16539e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1654e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1655e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1656bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 165738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 16589e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor if (getQualifierLoc()) 165938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), 166038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara getQualifierLoc().getEndLoc()); 1661e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 166238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc()); 1663e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 16649e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return getQualifierLoc().getSourceRange(); 1665e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1666e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 16679e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 1668e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1669e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara TypeLoc getNamedTypeLoc() const { 1670e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getInnerTypeLoc(); 1671e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1672e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1673e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType getInnerType() const { 1674e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getTypePtr()->getNamedType(); 1675e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1676e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1677e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(ElaboratedTypeLoc Loc) { 1678e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1679e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1680e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1681e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 168251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 168351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 168433500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 168533500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc. 168633500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo { 1687e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation NameLoc; 1688e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1689e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1690e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1691e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc, 1692e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameType, 1693e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameLocInfo> { 1694e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 169538a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 169638a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1697e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 169838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 169938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1700e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1701e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 17022494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1703ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 17042494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData); 1705e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1706ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 17072494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1708ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 17092494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor == getTypePtr()->getQualifier() && 17102494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor "Inconsistent nested-name-specifier pointer"); 17112494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1712e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1713ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1714e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getNameLoc() const { 1715e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->NameLoc; 1716e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1717e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setNameLoc(SourceLocation Loc) { 1718e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->NameLoc = Loc; 1719e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1720e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1721bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 172238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 172338a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getNameLoc()); 1724e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 17252494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc()); 1726e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1727e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1728e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(DependentNameTypeLoc Loc) { 1729e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1730e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1731e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1732e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1733e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 17342494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 173551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 173651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 173794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregorstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { 173866581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation TemplateKWLoc; 173933500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation LAngleLoc; 174033500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation RAngleLoc; 174133500955d731c73717af52088b7fc0e7a85681e7John McCall // followed by a TemplateArgumentLocInfo[] 174233500955d731c73717af52088b7fc0e7a85681e7John McCall}; 174333500955d731c73717af52088b7fc0e7a85681e7John McCall 174433500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc : 174533500955d731c73717af52088b7fc0e7a85681e7John McCall public ConcreteTypeLoc<UnqualTypeLoc, 174633500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationTypeLoc, 174733500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType, 174833500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationLocInfo> { 174933500955d731c73717af52088b7fc0e7a85681e7John McCallpublic: 175055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 175155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 175233500955d731c73717af52088b7fc0e7a85681e7John McCall } 175355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 175455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 175533500955d731c73717af52088b7fc0e7a85681e7John McCall } 175633500955d731c73717af52088b7fc0e7a85681e7John McCall 175794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 175894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!getLocalData()->QualifierData) 175994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return NestedNameSpecifierLoc(); 1760ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1761ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 176294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData); 176333500955d731c73717af52088b7fc0e7a85681e7John McCall } 1764ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 176594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 176694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!QualifierLoc) { 1767ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie // Even if we have a nested-name-specifier in the dependent 176894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // template specialization type, we won't record the nested-name-specifier 176994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // location information when this type-source location information is 177094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // part of a nested-name-specifier. 177194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = 0; 177294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return; 177394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor } 1774ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1775ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 177694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor == getTypePtr()->getQualifier() && 177794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor "Inconsistent nested-name-specifier pointer"); 177894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 177933500955d731c73717af52088b7fc0e7a85681e7John McCall } 178033500955d731c73717af52088b7fc0e7a85681e7John McCall 178166581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation getTemplateKeywordLoc() const { 178266581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return getLocalData()->TemplateKWLoc; 178366581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 178466581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 178566581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara getLocalData()->TemplateKWLoc = Loc; 178666581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 178766581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara 178855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateNameLoc() const { 178933500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->NameLoc; 179033500955d731c73717af52088b7fc0e7a85681e7John McCall } 179155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateNameLoc(SourceLocation Loc) { 179233500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->NameLoc = Loc; 179333500955d731c73717af52088b7fc0e7a85681e7John McCall } 179433500955d731c73717af52088b7fc0e7a85681e7John McCall 179533500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getLAngleLoc() const { 179633500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->LAngleLoc; 179733500955d731c73717af52088b7fc0e7a85681e7John McCall } 179833500955d731c73717af52088b7fc0e7a85681e7John McCall void setLAngleLoc(SourceLocation Loc) { 179933500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->LAngleLoc = Loc; 180033500955d731c73717af52088b7fc0e7a85681e7John McCall } 180133500955d731c73717af52088b7fc0e7a85681e7John McCall 180233500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getRAngleLoc() const { 180333500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->RAngleLoc; 180433500955d731c73717af52088b7fc0e7a85681e7John McCall } 180533500955d731c73717af52088b7fc0e7a85681e7John McCall void setRAngleLoc(SourceLocation Loc) { 180633500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->RAngleLoc = Loc; 180733500955d731c73717af52088b7fc0e7a85681e7John McCall } 180833500955d731c73717af52088b7fc0e7a85681e7John McCall 180933500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getNumArgs() const { 181033500955d731c73717af52088b7fc0e7a85681e7John McCall return getTypePtr()->getNumArgs(); 181133500955d731c73717af52088b7fc0e7a85681e7John McCall } 181233500955d731c73717af52088b7fc0e7a85681e7John McCall 181333500955d731c73717af52088b7fc0e7a85681e7John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 181433500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos()[i] = AI; 181533500955d731c73717af52088b7fc0e7a85681e7John McCall } 181633500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 181733500955d731c73717af52088b7fc0e7a85681e7John McCall return getArgInfos()[i]; 181833500955d731c73717af52088b7fc0e7a85681e7John McCall } 181933500955d731c73717af52088b7fc0e7a85681e7John McCall 182033500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 182133500955d731c73717af52088b7fc0e7a85681e7John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 182233500955d731c73717af52088b7fc0e7a85681e7John McCall } 182333500955d731c73717af52088b7fc0e7a85681e7John McCall 182433500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getLocalSourceRange() const { 182555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 182655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getRAngleLoc()); 182794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor else if (getQualifierLoc()) 182894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc()); 182966581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara else if (getTemplateKeywordLoc().isValid()) 183066581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 18319e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor else 183255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 183333500955d731c73717af52088b7fc0e7a85681e7John McCall } 183433500955d731c73717af52088b7fc0e7a85681e7John McCall 183533500955d731c73717af52088b7fc0e7a85681e7John McCall void copy(DependentTemplateSpecializationTypeLoc Loc) { 183633500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned size = getFullDataSize(); 183733500955d731c73717af52088b7fc0e7a85681e7John McCall assert(size == Loc.getFullDataSize()); 183833500955d731c73717af52088b7fc0e7a85681e7John McCall memcpy(Data, Loc.Data, size); 183933500955d731c73717af52088b7fc0e7a85681e7John McCall } 184033500955d731c73717af52088b7fc0e7a85681e7John McCall 184194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 184233500955d731c73717af52088b7fc0e7a85681e7John McCall 184333500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getExtraLocalDataSize() const { 184433500955d731c73717af52088b7fc0e7a85681e7John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 184533500955d731c73717af52088b7fc0e7a85681e7John McCall } 184633500955d731c73717af52088b7fc0e7a85681e7John McCall 184744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 184844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<TemplateArgumentLocInfo>(); 184944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 185044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 185133500955d731c73717af52088b7fc0e7a85681e7John McCallprivate: 185233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *getArgInfos() const { 185333500955d731c73717af52088b7fc0e7a85681e7John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 185433500955d731c73717af52088b7fc0e7a85681e7John McCall } 185533500955d731c73717af52088b7fc0e7a85681e7John McCall}; 185633500955d731c73717af52088b7fc0e7a85681e7John McCall 18577536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18587536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo { 18597536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation EllipsisLoc; 18607536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 18617536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18627536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc 1863ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc, 18647536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor PackExpansionType, PackExpansionTypeLocInfo> { 18657536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic: 18667536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation getEllipsisLoc() const { 18677536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getLocalData()->EllipsisLoc; 18687536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18697536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18707536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor void setEllipsisLoc(SourceLocation Loc) { 18717536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor this->getLocalData()->EllipsisLoc = Loc; 18727536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18737536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18747536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceRange getLocalSourceRange() const { 18757536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return SourceRange(getEllipsisLoc(), getEllipsisLoc()); 18767536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18777536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1878c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 18797536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor setEllipsisLoc(Loc); 18807536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18817536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18827536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor TypeLoc getPatternLoc() const { 18837536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return getInnerTypeLoc(); 18847536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18857536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 18867536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor QualType getInnerType() const { 18877536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getTypePtr()->getPattern(); 18887536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 18897536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 18907536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1891b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanstruct AtomicTypeLocInfo { 1892b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation KWLoc, LParenLoc, RParenLoc; 1893b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 1894b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1895b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanclass AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc, 1896b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman AtomicType, AtomicTypeLocInfo> { 1897ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 1898b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman TypeLoc getValueLoc() const { 1899b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getInnerTypeLoc(); 1900b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1901b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1902b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getLocalSourceRange() const { 1903b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getKWLoc(), getRParenLoc()); 1904b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1905b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1906b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getKWLoc() const { 1907b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->KWLoc; 1908b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1909b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setKWLoc(SourceLocation Loc) { 1910b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->KWLoc = Loc; 1911b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1912b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1913b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getLParenLoc() const { 1914b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->LParenLoc; 1915b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1916b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setLParenLoc(SourceLocation Loc) { 1917b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->LParenLoc = Loc; 1918b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1919b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1920b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getRParenLoc() const { 1921b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->RParenLoc; 1922b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1923b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setRParenLoc(SourceLocation Loc) { 1924b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->RParenLoc = Loc; 1925b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1926b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1927b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getParensRange() const { 1928b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getLParenLoc(), getRParenLoc()); 1929b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1930b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setParensRange(SourceRange Range) { 1931b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Range.getBegin()); 1932b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Range.getEnd()); 1933b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1934b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1935b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1936b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setKWLoc(Loc); 1937b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Loc); 1938b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Loc); 1939b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1940b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1941b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman QualType getInnerType() const { 1942b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getTypePtr()->getValueType(); 1943b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1944b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 1945b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1946b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1947b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis} 1948b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1949b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif 1950