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//===----------------------------------------------------------------------===// 95013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// 105013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// \file 115013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// \brief Defines the clang::TypeLoc interface and its subclasses. 125013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// 13b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 14b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 15b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#ifndef LLVM_CLANG_AST_TYPELOC_H 16b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#define LLVM_CLANG_AST_TYPELOC_H 17b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 183c385c28cf1f27b193a620d2e51f814873362cebJohn McCall#include "clang/AST/Decl.h" 19833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h" 2030a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/Type.h" 21ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor#include "clang/Basic/Specifiers.h" 22aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h" 23b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 24b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang { 25c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor class ASTContext; 26b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis class ParmVarDecl; 27a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall class TypeSourceInfo; 2834a0447b8072e0da14c0980597da9d03a1495662John McCall class UnqualTypeLoc; 29b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes. 3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base) 3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \ 3351bd803fbdade51d674598ed45da3d54190a656cJohn McCall class Class##TypeLoc; 3451bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def" 3551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info. 37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// 385013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// A client should use the TypeLoc subclasses through castAs()/getAs() 395013fcf1236980bd164ad070df298a0364e1e45fJames Dennett/// in order to get at the actual information. 40b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc { 41b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected: 4234a0447b8072e0da14c0980597da9d03a1495662John McCall // The correctness of this relies on the property that, for Type *Ty, 4334a0447b8072e0da14c0980597da9d03a1495662John McCall // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty 44f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const void *Ty; 45b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void *Data; 461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 47b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 48464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// \brief Convert to the specified TypeLoc type, asserting that this TypeLoc 49464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// is of the desired type. 505013fcf1236980bd164ad070df298a0364e1e45fJames Dennett /// 515013fcf1236980bd164ad070df298a0364e1e45fJames Dennett /// \pre T::isKind(*this) 5239e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie template<typename T> 5339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T castAs() const { 5465124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie assert(T::isKind(*this)); 5539e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T t; 5639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc& tl = t; 5739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie tl = *this; 5839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return t; 5939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie } 60464011827c5f9047caaba7e245556d66a65a15b6David Blaikie 61464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// \brief Convert to the specified TypeLoc type, returning a null TypeLoc if 62464011827c5f9047caaba7e245556d66a65a15b6David Blaikie /// this TypeLoc is not of the desired type. 6339e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie template<typename T> 6439e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T getAs() const { 6565124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie if (!T::isKind(*this)) 6639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return T(); 6739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie T t; 6839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc& tl = t; 6939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie tl = *this; 7039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return t; 7139e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie } 7239e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie 7351bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum, 7451bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// except it also defines a Qualified enum that corresponds to the 7551bd803fbdade51d674598ed45da3d54190a656cJohn McCall /// QualifiedLoc class. 7651bd803fbdade51d674598ed45da3d54190a656cJohn McCall enum TypeLocClass { 7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base) 7851bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \ 7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall Class = Type::Class, 8051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def" 8151bd803fbdade51d674598ed45da3d54190a656cJohn McCall Qualified 8251bd803fbdade51d674598ed45da3d54190a656cJohn McCall }; 8351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 846bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines TypeLoc() : Ty(nullptr), Data(nullptr) { } 8534a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc(QualType ty, void *opaqueData) 8634a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { } 87f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall TypeLoc(const Type *ty, void *opaqueData) 8834a0447b8072e0da14c0980597da9d03a1495662John McCall : Ty(ty), Data(opaqueData) { } 89b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 9051bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 91a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor if (getType().hasLocalQualifiers()) return Qualified; 9251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getType()->getTypeClass(); 9351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 9451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 9534a0447b8072e0da14c0980597da9d03a1495662John McCall bool isNull() const { return !Ty; } 960e2c34f92f00628d48968dfea096d36381f494cbStephen Hines explicit operator bool() const { return Ty; } 97b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 98b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of type source info data block for the given type. 99b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis static unsigned getFullDataSizeForType(QualType Ty); 100b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 10144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// \brief Returns the alignment of type source info data block for 10244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// the given type. 10344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman static unsigned getLocalAlignmentForType(QualType Ty); 10444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the type for which this source info wrapper provides 106b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// information. 10751bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getType() const { 10851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return QualType::getFromOpaquePtr(Ty); 10951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 11034a0447b8072e0da14c0980597da9d03a1495662John McCall 111f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 11234a0447b8072e0da14c0980597da9d03a1495662John McCall return QualType::getFromOpaquePtr(Ty).getTypePtr(); 11334a0447b8072e0da14c0980597da9d03a1495662John McCall } 114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 115b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis /// \brief Get the pointer where source information is stored. 11651bd803fbdade51d674598ed45da3d54190a656cJohn McCall void *getOpaqueData() const { 11751bd803fbdade51d674598ed45da3d54190a656cJohn McCall return Data; 11851bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 119b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 120e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the begin source location. 121e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getBeginLoc() const; 122e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 123e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara /// \brief Get the end source location. 124e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara SourceLocation getEndLoc() const; 125e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara 126833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the full source range. 127aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceRange getSourceRange() const LLVM_READONLY { 128e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara return SourceRange(getBeginLoc(), getEndLoc()); 129833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 130aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } 131aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } 132833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 133833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Get the local source range. 134bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 135bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara return getLocalSourceRangeImpl(*this); 13651bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 137b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 138b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block. 13934a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getFullDataSize() const { 14051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getFullDataSizeForType(getType()); 14134a0447b8072e0da14c0980597da9d03a1495662John McCall } 142b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 143b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the 144b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// TypeLoc is a PointerLoc and next TypeLoc is for "int". 14551bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLoc getNextTypeLoc() const { 14651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getNextTypeLocImpl(*this); 14751bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 148b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 14934a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Skips past any qualifiers, if this is qualified. 15051bd803fbdade51d674598ed45da3d54190a656cJohn McCall UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header 15134a0447b8072e0da14c0980597da9d03a1495662John McCall 15239e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie TypeLoc IgnoreParens() const; 153140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara 15487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Find a type with the location of an explicit type qualifier. 15587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// 15687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// The result, if non-null, will be one of: 15787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// QualifiedTypeLoc 15887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// AtomicTypeLoc 15987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// AttributedTypeLoc, for those type attributes that behave as qualifiers 16087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar TypeLoc findExplicitQualifierLoc() const; 16187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 1624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// \brief Initializes this to state that every location in this 1634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// type is the given location. 1644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// 1654ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// This method exists to provide a simple transition for code that 1664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// relies on location-less types. 167c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initialize(ASTContext &Context, SourceLocation Loc) const { 168c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeImpl(Context, *this, Loc); 1694ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1704ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 17145ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// \brief Initializes this by copying its information from another 17245ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein /// TypeLoc of the same type. 17387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void initializeFullCopy(TypeLoc Other) { 174711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 17587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar copy(Other); 176711c52bb20d0c69063b52a99826fb7d2835501f1John McCall } 177711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 178711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// \brief Initializes this by copying its information from another 179711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// TypeLoc of the same type. The given size must be the full data 180711c52bb20d0c69063b52a99826fb7d2835501f1John McCall /// size. 18187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void initializeFullCopy(TypeLoc Other, unsigned Size) { 182711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getType() == Other.getType()); 183711c52bb20d0c69063b52a99826fb7d2835501f1John McCall assert(getFullDataSize() == Size); 18487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar copy(Other); 18545ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein } 18645ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein 18787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// Copies the other type loc into this one. 18887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void copy(TypeLoc other); 18987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 190b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) { 191b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data; 192b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 193b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 194b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) { 195b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return !(LHS == RHS); 196b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 197b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 19887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// Find the location of the nullability specifier (__nonnull, 19987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// __nullable, or __null_unspecifier), if there is one. 20087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation findNullabilityLoc() const; 20187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 2024ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate: 20365124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc&) { 20465124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return true; 20565124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie } 20665124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie 207ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static void initializeImpl(ASTContext &Context, TypeLoc TL, 208ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation Loc); 20951bd803fbdade51d674598ed45da3d54190a656cJohn McCall static TypeLoc getNextTypeLocImpl(TypeLoc TL); 210723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara static TypeLoc IgnoreParensImpl(TypeLoc TL); 211bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara static SourceRange getLocalSourceRangeImpl(TypeLoc TL); 212b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 213b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 2143c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info. 2153c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const { 21687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // TODO: is this alignment already sufficient? 2174ab92891a53adda8c52c1947351371da58e33f64Gabor Greif return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1))); 2183c385c28cf1f27b193a620d2e51f814873362cebJohn McCall} 2193c385c28cf1f27b193a620d2e51f814873362cebJohn McCall 22034a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 221489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers. 22234a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc { 22334a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 22434a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc() {} 225f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {} 22634a0447b8072e0da14c0980597da9d03a1495662John McCall 227f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const Type *getTypePtr() const { 228f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall return reinterpret_cast<const Type*>(Ty); 22934a0447b8072e0da14c0980597da9d03a1495662John McCall } 23034a0447b8072e0da14c0980597da9d03a1495662John McCall 23151bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeLocClass getTypeLocClass() const { 23251bd803fbdade51d674598ed45da3d54190a656cJohn McCall return (TypeLocClass) getTypePtr()->getTypeClass(); 23351bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 23451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 23539e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 23639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 23765124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 23865124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return !TL.getType().hasLocalQualifiers(); 23934a0447b8072e0da14c0980597da9d03a1495662John McCall } 24034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 24134a0447b8072e0da14c0980597da9d03a1495662John McCall 24234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with 24334a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers. 24434a0447b8072e0da14c0980597da9d03a1495662John McCall/// 24534a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for 24634a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers. 24751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc { 24834a0447b8072e0da14c0980597da9d03a1495662John McCallpublic: 249bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 25034a0447b8072e0da14c0980597da9d03a1495662John McCall return SourceRange(); 25134a0447b8072e0da14c0980597da9d03a1495662John McCall } 25234a0447b8072e0da14c0980597da9d03a1495662John McCall 25334a0447b8072e0da14c0980597da9d03a1495662John McCall UnqualTypeLoc getUnqualifiedLoc() const { 25444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned align = 25544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman TypeLoc::getLocalAlignmentForType(QualType(getTypePtr(), 0)); 25644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman uintptr_t dataInt = reinterpret_cast<uintptr_t>(Data); 2574967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar dataInt = llvm::alignTo(dataInt, align); 25844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return UnqualTypeLoc(getTypePtr(), reinterpret_cast<void*>(dataInt)); 25934a0447b8072e0da14c0980597da9d03a1495662John McCall } 26034a0447b8072e0da14c0980597da9d03a1495662John McCall 2614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// Initializes the local data of this type source info block to 2624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall /// provide no information. 263c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 2644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall // do nothing 2654ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 26787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void copyLocal(TypeLoc other) { 26887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // do nothing 26987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 27087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 2714ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 2724ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getUnqualifiedLoc(); 2734ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 2744ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 27534a0447b8072e0da14c0980597da9d03a1495662John McCall /// \brief Returns the size of the type source info data block that is 27634a0447b8072e0da14c0980597da9d03a1495662John McCall /// specific to this type. 27734a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getLocalDataSize() const { 27834a0447b8072e0da14c0980597da9d03a1495662John McCall // In fact, we don't currently preserve any location information 27934a0447b8072e0da14c0980597da9d03a1495662John McCall // for qualifiers. 28034a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 28134a0447b8072e0da14c0980597da9d03a1495662John McCall } 28234a0447b8072e0da14c0980597da9d03a1495662John McCall 28344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// \brief Returns the alignment of the type source info data block that is 28444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman /// specific to this type. 28544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataAlignment() const { 28644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman // We don't preserve any location information. 28744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 28834a0447b8072e0da14c0980597da9d03a1495662John McCall } 28934a0447b8072e0da14c0980597da9d03a1495662John McCall 29039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 29139e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 29265124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 29365124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return TL.getType().hasLocalQualifiers(); 29434a0447b8072e0da14c0980597da9d03a1495662John McCall } 29534a0447b8072e0da14c0980597da9d03a1495662John McCall}; 29634a0447b8072e0da14c0980597da9d03a1495662John McCall 29734a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const { 29839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie if (QualifiedTypeLoc Loc = getAs<QualifiedTypeLoc>()) 29939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return Loc.getUnqualifiedLoc(); 30039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return castAs<UnqualTypeLoc>(); 30134a0447b8072e0da14c0980597da9d03a1495662John McCall} 30234a0447b8072e0da14c0980597da9d03a1495662John McCall 30334a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond 304f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass. It is accepted for a single 305f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes. 30634a0447b8072e0da14c0980597da9d03a1495662John McCall/// 30770517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Base a class from which to derive 30870517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam Derived the class deriving from this one 30970517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam TypeClass the concrete Type subclass associated with this 310f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// location type 31170517ca5c07c4b41ff8662b94ee22047b0299f8cDmitri Gribenko/// \tparam LocalData the structure type of local location data for 31234a0447b8072e0da14c0980597da9d03a1495662John McCall/// this type 31334a0447b8072e0da14c0980597da9d03a1495662John McCall/// 31434a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override 31534a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to 31634a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory. 31734a0447b8072e0da14c0980597da9d03a1495662John McCall/// 318a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define 319a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// QualType getInnerType() const 320a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's 321a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data. 32251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// 32351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be 32451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy. It is also not 32551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide 32651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information. It should be subclassed 32751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children 32851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type, 32951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from 33051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead. 33134a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData> 33234a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base { 33334a0447b8072e0da14c0980597da9d03a1495662John McCall 33434a0447b8072e0da14c0980597da9d03a1495662John McCall const Derived *asDerived() const { 33534a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<const Derived*>(this); 33634a0447b8072e0da14c0980597da9d03a1495662John McCall } 33734a0447b8072e0da14c0980597da9d03a1495662John McCall 33839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 33965124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 34044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return !TL.getType().hasLocalQualifiers() && 34144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman Derived::classofType(TL.getTypePtr()); 34234a0447b8072e0da14c0980597da9d03a1495662John McCall } 34334a0447b8072e0da14c0980597da9d03a1495662John McCall 34434a0447b8072e0da14c0980597da9d03a1495662John McCall static bool classofType(const Type *Ty) { 34534a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeClass::classof(Ty); 34634a0447b8072e0da14c0980597da9d03a1495662John McCall } 34734a0447b8072e0da14c0980597da9d03a1495662John McCall 34839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikiepublic: 34944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataAlignment() const { 35044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return std::max(llvm::alignOf<LocalData>(), 35144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman asDerived()->getExtraLocalDataAlignment()); 35220387efff0870da2c8b30bb62ae661239a903021Manuel Klimek } 35344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getLocalDataSize() const { 35444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned size = sizeof(LocalData); 35544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); 3564967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar size = llvm::alignTo(size, extraAlign); 35744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman size += asDerived()->getExtraLocalDataSize(); 35844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return size; 359e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 360e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 36187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void copyLocal(Derived other) { 36287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // Some subclasses have no data to copy. 36387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (asDerived()->getLocalDataSize() == 0) return; 36487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 36587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // Copy the fixed-sized local data. 36687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar memcpy(getLocalData(), other.getLocalData(), sizeof(LocalData)); 36787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 36887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // Copy the variable-sized local data. We need to do this 36987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // separately because the padding in the source and the padding in 37087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // the destination might be different. 37187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar memcpy(getExtraLocalData(), other.getExtraLocalData(), 37287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar asDerived()->getExtraLocalDataSize()); 37387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 37487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 3754ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc() const { 3764ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return getNextTypeLoc(asDerived()->getInnerType()); 3774ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 3784ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 379f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 38051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 38134a0447b8072e0da14c0980597da9d03a1495662John McCall } 38234a0447b8072e0da14c0980597da9d03a1495662John McCall 38351bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected: 38434a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 38534a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 38634a0447b8072e0da14c0980597da9d03a1495662John McCall } 38734a0447b8072e0da14c0980597da9d03a1495662John McCall 38844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 38944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 39044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 39144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 39234a0447b8072e0da14c0980597da9d03a1495662John McCall LocalData *getLocalData() const { 39334a0447b8072e0da14c0980597da9d03a1495662John McCall return static_cast<LocalData*>(Base::Data); 39434a0447b8072e0da14c0980597da9d03a1495662John McCall } 39534a0447b8072e0da14c0980597da9d03a1495662John McCall 39634a0447b8072e0da14c0980597da9d03a1495662John McCall /// Gets a pointer past the Info structure; useful for classes with 39734a0447b8072e0da14c0980597da9d03a1495662John McCall /// local data that can't be captured in the Info (e.g. because it's 39834a0447b8072e0da14c0980597da9d03a1495662John McCall /// of variable size). 39934a0447b8072e0da14c0980597da9d03a1495662John McCall void *getExtraLocalData() const { 40044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned size = sizeof(LocalData); 40144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); 4024967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar size = llvm::alignTo(size, extraAlign); 40344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return reinterpret_cast<char*>(Base::Data) + size; 40434a0447b8072e0da14c0980597da9d03a1495662John McCall } 405ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 40634a0447b8072e0da14c0980597da9d03a1495662John McCall void *getNonLocalData() const { 40744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman uintptr_t data = reinterpret_cast<uintptr_t>(Base::Data); 40844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman data += asDerived()->getLocalDataSize(); 4094967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar data = llvm::alignTo(data, getNextTypeAlign()); 41044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return reinterpret_cast<void*>(data); 41134a0447b8072e0da14c0980597da9d03a1495662John McCall } 41234a0447b8072e0da14c0980597da9d03a1495662John McCall 413a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall struct HasNoInnerType {}; 414a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall HasNoInnerType getInnerType() const { return HasNoInnerType(); } 41534a0447b8072e0da14c0980597da9d03a1495662John McCall 41634a0447b8072e0da14c0980597da9d03a1495662John McCall TypeLoc getInnerTypeLoc() const { 41734a0447b8072e0da14c0980597da9d03a1495662John McCall return TypeLoc(asDerived()->getInnerType(), getNonLocalData()); 41834a0447b8072e0da14c0980597da9d03a1495662John McCall } 41934a0447b8072e0da14c0980597da9d03a1495662John McCall 42034a0447b8072e0da14c0980597da9d03a1495662John McCallprivate: 42134a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getInnerTypeSize() const { 422a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeSize(asDerived()->getInnerType()); 423a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall } 424a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall 425a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(HasNoInnerType _) const { 42634a0447b8072e0da14c0980597da9d03a1495662John McCall return 0; 42734a0447b8072e0da14c0980597da9d03a1495662John McCall } 42834a0447b8072e0da14c0980597da9d03a1495662John McCall 429a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall unsigned getInnerTypeSize(QualType _) const { 430a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall return getInnerTypeLoc().getFullDataSize(); 43134a0447b8072e0da14c0980597da9d03a1495662John McCall } 4324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 43344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign() const { 43444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return getNextTypeAlign(asDerived()->getInnerType()); 43544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 43644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 43744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign(HasNoInnerType _) const { 43844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return 1; 43944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 44044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 44144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getNextTypeAlign(QualType T) const { 44244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return TypeLoc::getLocalAlignmentForType(T); 44344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 44444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 4454ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(HasNoInnerType _) const { 4464ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(); 4474ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 4484ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 4494ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall TypeLoc getNextTypeLoc(QualType T) const { 4504ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall return TypeLoc(T, getNonLocalData()); 4514ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 45234a0447b8072e0da14c0980597da9d03a1495662John McCall}; 45334a0447b8072e0da14c0980597da9d03a1495662John McCall 45451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract 45551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source 45651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information. See the note on ConcreteTypeLoc. 45751bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass> 45851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base { 45939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 460713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor static bool classofType(const Type *Ty) { 461713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor return TypeClass::classof(Ty); 462713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor } 463713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor 46465124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL) { 46544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return !TL.getType().hasLocalQualifiers() && 46644ee0a710c59d8e6793189f903bae21c16814324Eli Friedman Derived::classofType(TL.getTypePtr()); 467b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 46865124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const UnqualTypeLoc &TL) { 46965124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie return Derived::classofType(TL.getTypePtr()); 470b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 471b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 47239e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikiepublic: 473f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall const TypeClass *getTypePtr() const { 47451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return cast<TypeClass>(Base::getTypePtr()); 4754ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 47634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 477b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 478ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 47951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo { 48034a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation NameLoc; 481b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 482b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 48351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to 48451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier. 485ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikieclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 486ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc, 487ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Type, 488ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecLocInfo> { 489b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 49044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman enum { LocalDataSize = sizeof(TypeSpecLocInfo), 49144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman LocalDataAlignment = llvm::AlignOf<TypeSpecLocInfo>::Alignment }; 492ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 493b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getNameLoc() const { 49451bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->NameLoc; 495b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 496b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setNameLoc(SourceLocation Loc) { 49751bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->NameLoc = Loc; 498b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 499bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 500b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getNameLoc(), getNameLoc()); 501b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 502c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 5034ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setNameLoc(Loc); 5044ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 505ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 50639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieprivate: 50739e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie friend class TypeLoc; 50865124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie static bool isKind(const TypeLoc &TL); 50951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 5104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 511ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 512ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo { 513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation BuiltinLoc; 514ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 515ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 516ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types. 517ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 518ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc, 519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType, 520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinLocInfo> { 521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic: 522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getBuiltinLoc() const { 523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getLocalData()->BuiltinLoc; 524ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 525ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setBuiltinLoc(SourceLocation Loc) { 526ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getLocalData()->BuiltinLoc = Loc; 527ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 528ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 529ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor SourceLocation getNameLoc() const { return getBuiltinLoc(); } 530ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 531ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs& getWrittenBuiltinSpecs() { 532ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 533ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 534ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { 535ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData())); 536ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 537ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 538ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool needsExtraLocalData() const { 539ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinType::Kind bk = getTypePtr()->getKind(); 540ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) 5414967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar || (bk >= BuiltinType::Short && bk <= BuiltinType::Float128) 542ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::UChar 543ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor || bk == BuiltinType::SChar; 544ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 545ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 546ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor unsigned getExtraLocalDataSize() const { 547d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; 548ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 549ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 55044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 55144ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return needsExtraLocalData() ? llvm::alignOf<WrittenBuiltinSpecs>() : 1; 55244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 55344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 554bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 555ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return SourceRange(getBuiltinLoc(), getBuiltinLoc()); 556ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 557ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 558ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierSign getWrittenSignSpec() const { 559ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 560ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); 561ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 562ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSS_unspecified; 563ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 564ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenSignSpec() const { 565ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenSignSpec() != TSS_unspecified; 566ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 567ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenSignSpec(TypeSpecifierSign written) { 568ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 569ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Sign = written; 570ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 571ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 572ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierWidth getWrittenWidthSpec() const { 573ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 574ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); 575ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 576ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return TSW_unspecified; 577ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 578ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenWidthSpec() const { 579ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenWidthSpec() != TSW_unspecified; 580ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 581ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenWidthSpec(TypeSpecifierWidth written) { 582ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 583ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Width = written; 584ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 585ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 586ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor TypeSpecifierType getWrittenTypeSpec() const; 587ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasWrittenTypeSpec() const { 588ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenTypeSpec() != TST_unspecified; 589ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 590ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setWrittenTypeSpec(TypeSpecifierType written) { 591ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 592ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().Type = written; 593ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 594ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 595ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor bool hasModeAttr() const { 596ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 597ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return getWrittenBuiltinSpecs().ModeAttr; 598ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor else 599ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return false; 600ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 601ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor void setModeAttr(bool written) { 602ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) 603ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor getWrittenBuiltinSpecs().ModeAttr = written; 604ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 605ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 606c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 607ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor setBuiltinLoc(Loc); 608ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (needsExtraLocalData()) { 609ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); 610ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Sign = TSS_unspecified; 611ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Width = TSW_unspecified; 612ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.Type = TST_unspecified; 613ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor wbs.ModeAttr = false; 614ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 615ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor } 616ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor}; 617ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 618ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor 61951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs. 620ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 621ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefTypeLoc, 622ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypedefType> { 62351bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 624162e1c1b487352434552147967c3dd296ebee2f7Richard Smith TypedefNameDecl *getTypedefNameDecl() const { 62534a0447b8072e0da14c0980597da9d03a1495662John McCall return getTypePtr()->getDecl(); 6269036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis } 62734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 6289036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis 6293cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class 6303cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates. 6313cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc : 6323cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 6333cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameTypeLoc, 6343cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall InjectedClassNameType> { 635427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 636427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis CXXRecordDecl *getDecl() const { 637427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis return getTypePtr()->getDecl(); 638427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis } 6393cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall}; 6403cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 641ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls. 642ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc : 643ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 644ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypeLoc, 645ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType> { 646ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 647ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingTypenameDecl *getDecl() const { 648ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return getTypePtr()->getDecl(); 649ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 650ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 651ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 652ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types. Note that this only 653ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo' 654ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc. We currently 655ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of 656ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C. 657ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 658ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagTypeLoc, 659ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagType> { 660ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 661ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TagDecl *getDecl() const { return getTypePtr()->getDecl(); } 6626f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis 663ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief True if the tag was defined in this type specifier. 6646f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis bool isDefinition() const { 665a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis TagDecl *D = getDecl(); 666a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis return D->isCompleteDefinition() && 6676bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc()); 6686f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis } 669ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 670ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 671ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types. 672ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 673ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordTypeLoc, 674ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordType> { 675ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 676ed97649e9574b9d854fa4d6109c9333ae0993554John McCall RecordDecl *getDecl() const { return getTypePtr()->getDecl(); } 677ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 678ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 679ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types. 680ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc, 681ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumTypeLoc, 682ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumType> { 683ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic: 684ed97649e9574b9d854fa4d6109c9333ae0993554John McCall EnumDecl *getDecl() const { return getTypePtr()->getDecl(); } 685ed97649e9574b9d854fa4d6109c9333ae0993554John McCall}; 686b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 68749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters. 688ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc : 689ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 690ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmTypeLoc, 691ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TemplateTypeParmType> { 692960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruthpublic: 693960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruth TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } 69449a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 69549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 69649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters. 69749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc : 698ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 699ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmTypeLoc, 700ed97649e9574b9d854fa4d6109c9333ae0993554John McCall SubstTemplateTypeParmType> { 70149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall}; 70251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 703c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor /// \brief Wrapper for substituted template type parameters. 704c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc : 705c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 706c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackTypeLoc, 707c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor SubstTemplateTypeParmPackType> { 708c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor}; 709c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor 7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo { 7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall union { 7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *ExprOperand; 7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// A raw SourceLocation. 7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall unsigned EnumOperandLoc; 7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall }; 7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange OperandParens; 7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation AttrLoc; 7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type. 7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc, 7269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType, 7279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedLocInfo> { 7289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic: 7299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedType::Kind getAttrKind() const { 7309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getAttrKind(); 7319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrExprOperand() const { 7349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstExprOperandKind && 7359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastExprOperandKind); 7369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrEnumOperand() const { 7399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return (getAttrKind() >= AttributedType::FirstEnumOperandKind && 7409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getAttrKind() <= AttributedType::LastEnumOperandKind); 7419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall bool hasAttrOperand() const { 7449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return hasAttrExprOperand() || hasAttrEnumOperand(); 7459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 74787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool isQualifier() const { 74887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return getTypePtr()->isQualifier(); 74987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 75087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 7519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The modified type, which is generally canonically different from 7529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// the attribute type. 7539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// int main(int, char**) __attribute__((noreturn)) 7549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ~~~ ~~~~~~~~~~~~~ 7559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall TypeLoc getModifiedLoc() const { 7569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getInnerTypeLoc(); 7579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute name, i.e. 7609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// __attribute__((regparm(1000))) 7619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~~~~ 7629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrNameLoc() const { 7639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->AttrLoc; 7649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrNameLoc(SourceLocation loc) { 7669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->AttrLoc = loc; 7679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The attribute's expression operand, if it has one. 7709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void *cur_thread __attribute__((address_space(21))) 7719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~ 7729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall Expr *getAttrExprOperand() const { 7739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 7749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->ExprOperand; 7759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrExprOperand(Expr *e) { 7779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrExprOperand()); 7789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->ExprOperand = e; 7799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the attribute's enumerated operand, if it has one. 7829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 7839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^~~~ 7849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceLocation getAttrEnumOperandLoc() const { 7859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 7869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc); 7879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrEnumOperandLoc(SourceLocation loc) { 7899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrEnumOperand()); 7909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->EnumOperandLoc = loc.getRawEncoding(); 7919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 7929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 7939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// The location of the parentheses around the operand, if there is 7949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// an operand. 7959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// void * __attribute__((objc_gc(weak))) 7969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall /// ^ ^ 7979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getAttrOperandParensRange() const { 7989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 7999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getLocalData()->OperandParens; 8009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall void setAttrOperandParensRange(SourceRange range) { 8029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall assert(hasAttrOperand()); 8039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall getLocalData()->OperandParens = range; 8049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 8069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange getLocalSourceRange() const { 8079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // Note that this does *not* include the range of the attribute 8089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // enclosure, e.g.: 8099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // __attribute__((foo(bar))) 8109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~~~~~~~~~~~~~~ ~~ 8119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // or 8129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // [[foo(bar)]] 8139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // ^~ ~~ 8149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // That enclosure doesn't necessarily belong to a single attribute 8159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // anyway. 8169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall SourceRange range(getAttrNameLoc()); 8179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrOperand()) 8189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall range.setEnd(getAttrOperandParensRange().getEnd()); 8199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return range; 8209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 822c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation loc) { 8239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrNameLoc(loc); 8249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (hasAttrExprOperand()) { 8259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 8266bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines setAttrExprOperand(nullptr); 8279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } else if (hasAttrEnumOperand()) { 8289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrOperandParensRange(SourceRange(loc)); 8299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall setAttrEnumOperandLoc(loc); 8309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 8339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType getInnerType() const { 8349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return getTypePtr()->getModifiedType(); 8359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 8369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall}; 8379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 838eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 83987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstruct ObjCObjectTypeLocInfo { 84087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation TypeArgsLAngleLoc; 84187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation TypeArgsRAngleLoc; 84287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation ProtocolLAngleLoc; 84387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation ProtocolRAngleLoc; 844ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall bool HasBaseTypeAsWritten; 845eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis}; 846eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis 84754e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with 84854e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols. 84954e14c4db764c0636160d26c5bbf491637c83a76John McCall// 85054e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or 85154e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType. 852c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 853c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectTypeLoc, 854c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectType, 85587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ObjCObjectTypeLocInfo> { 85687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // TypeSourceInfo*'s are stored after Info, one for each type argument. 85787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar TypeSourceInfo **getTypeArgLocArray() const { 85887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return (TypeSourceInfo**)this->getExtraLocalData(); 85987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 86087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 86187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // SourceLocations are stored after the type argument information, one for 86287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // each Protocol. 863f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation *getProtocolLocArray() const { 86487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs()); 86554e14c4db764c0636160d26c5bbf491637c83a76John McCall } 86654e14c4db764c0636160d26c5bbf491637c83a76John McCall 867f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic: 86887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation getTypeArgsLAngleLoc() const { 86987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getLocalData()->TypeArgsLAngleLoc; 87087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 87187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void setTypeArgsLAngleLoc(SourceLocation Loc) { 87287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar this->getLocalData()->TypeArgsLAngleLoc = Loc; 873f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 87487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 87587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation getTypeArgsRAngleLoc() const { 87687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getLocalData()->TypeArgsRAngleLoc; 87787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 87887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void setTypeArgsRAngleLoc(SourceLocation Loc) { 87987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar this->getLocalData()->TypeArgsRAngleLoc = Loc; 88087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 88187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 88287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar unsigned getNumTypeArgs() const { 88387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getTypePtr()->getTypeArgsAsWritten().size(); 88487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 88587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 88687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar TypeSourceInfo *getTypeArgTInfo(unsigned i) const { 88787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar assert(i < getNumTypeArgs() && "Index is out of bounds!"); 88887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return getTypeArgLocArray()[i]; 88987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 89087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 89187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) { 89287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar assert(i < getNumTypeArgs() && "Index is out of bounds!"); 89387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar getTypeArgLocArray()[i] = TInfo; 894f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 895f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 89687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation getProtocolLAngleLoc() const { 89787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getLocalData()->ProtocolLAngleLoc; 898f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 89987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void setProtocolLAngleLoc(SourceLocation Loc) { 90087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar this->getLocalData()->ProtocolLAngleLoc = Loc; 90187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 90287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 90387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation getProtocolRAngleLoc() const { 90487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getLocalData()->ProtocolRAngleLoc; 90587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 90687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void setProtocolRAngleLoc(SourceLocation Loc) { 90787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar this->getLocalData()->ProtocolRAngleLoc = Loc; 908f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 909f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 910f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis unsigned getNumProtocols() const { 91154e14c4db764c0636160d26c5bbf491637c83a76John McCall return this->getTypePtr()->getNumProtocols(); 912f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 913f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 914f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis SourceLocation getProtocolLoc(unsigned i) const { 915f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 916f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis return getProtocolLocArray()[i]; 917f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 918f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis void setProtocolLoc(unsigned i, SourceLocation Loc) { 919f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 920f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis getProtocolLocArray()[i] = Loc; 921f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 922f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 923f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis ObjCProtocolDecl *getProtocol(unsigned i) const { 924f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis assert(i < getNumProtocols() && "Index is out of bounds!"); 92554e14c4db764c0636160d26c5bbf491637c83a76John McCall return *(this->getTypePtr()->qual_begin() + i); 926f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 927ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 92887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 92987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ArrayRef<SourceLocation> getProtocolLocs() const { 93087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return llvm::makeArrayRef(getProtocolLocArray(), getNumProtocols()); 93187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 93287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 933c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall bool hasBaseTypeAsWritten() const { 934ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall return getLocalData()->HasBaseTypeAsWritten; 935c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 936c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 937c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setHasBaseTypeAsWritten(bool HasBaseType) { 938ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall getLocalData()->HasBaseTypeAsWritten = HasBaseType; 939c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 940c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 941c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TypeLoc getBaseLoc() const { 942c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getInnerTypeLoc(); 943c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 944c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 945bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 94687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation start = getTypeArgsLAngleLoc(); 94787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (start.isInvalid()) 94887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar start = getProtocolLAngleLoc(); 94987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SourceLocation end = getProtocolRAngleLoc(); 95087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (end.isInvalid()) 95187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar end = getTypeArgsRAngleLoc(); 95287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return SourceRange(start, end); 953f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 954f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 95587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void initializeLocal(ASTContext &Context, SourceLocation Loc); 9564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 95734a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 95887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return this->getNumTypeArgs() * sizeof(TypeSourceInfo *) 95987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar + this->getNumProtocols() * sizeof(SourceLocation); 96054e14c4db764c0636160d26c5bbf491637c83a76John McCall } 961c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 96244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 96387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar assert(llvm::alignOf<ObjCObjectTypeLoc>() 96487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar >= llvm::alignOf<TypeSourceInfo *>() && 96587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar "not enough alignment for tail-allocated data"); 96687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return llvm::alignOf<TypeSourceInfo *>(); 96744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 96844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 969c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall QualType getInnerType() const { 970c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getTypePtr()->getBaseType(); 971c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 97254e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 97354e14c4db764c0636160d26c5bbf491637c83a76John McCall 97454e14c4db764c0636160d26c5bbf491637c83a76John McCall 975c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo { 97654e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation NameLoc; 9771de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation NameEndLoc; 97854e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 97954e14c4db764c0636160d26c5bbf491637c83a76John McCall 98054e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces. 981a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc, 982c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceTypeLoc, 983c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceType, 984c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCInterfaceLocInfo> { 98554e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 98654e14c4db764c0636160d26c5bbf491637c83a76John McCall ObjCInterfaceDecl *getIFaceDecl() const { 98754e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getDecl(); 98854e14c4db764c0636160d26c5bbf491637c83a76John McCall } 98954e14c4db764c0636160d26c5bbf491637c83a76John McCall 99054e14c4db764c0636160d26c5bbf491637c83a76John McCall SourceLocation getNameLoc() const { 99154e14c4db764c0636160d26c5bbf491637c83a76John McCall return getLocalData()->NameLoc; 99254e14c4db764c0636160d26c5bbf491637c83a76John McCall } 99354e14c4db764c0636160d26c5bbf491637c83a76John McCall 99454e14c4db764c0636160d26c5bbf491637c83a76John McCall void setNameLoc(SourceLocation Loc) { 99554e14c4db764c0636160d26c5bbf491637c83a76John McCall getLocalData()->NameLoc = Loc; 99654e14c4db764c0636160d26c5bbf491637c83a76John McCall } 9971de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 998bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 9991de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return SourceRange(getNameLoc(), getNameEndLoc()); 10001de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 10011de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 10021de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian SourceLocation getNameEndLoc() const { 10031de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian return getLocalData()->NameEndLoc; 10041de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian } 10051de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian 10061de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian void setNameEndLoc(SourceLocation Loc) { 10071de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian getLocalData()->NameEndLoc = Loc; 100854e14c4db764c0636160d26c5bbf491637c83a76John McCall } 100954e14c4db764c0636160d26c5bbf491637c83a76John McCall 1010c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 101154e14c4db764c0636160d26c5bbf491637c83a76John McCall setNameLoc(Loc); 10126c2fd0d71406c5f311ff00208448a63fa9071453Benjamin Kramer setNameEndLoc(Loc); 1013f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis } 101454e14c4db764c0636160d26c5bbf491637c83a76John McCall}; 101554e14c4db764c0636160d26c5bbf491637c83a76John McCall 1016075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo { 1017075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation LParenLoc; 1018075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation RParenLoc; 1019075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 1020075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 1021075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc 1022075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType, 1023075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenLocInfo> { 1024075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic: 1025075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getLParenLoc() const { 1026075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->LParenLoc; 1027075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1028075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceLocation getRParenLoc() const { 1029075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getLocalData()->RParenLoc; 1030075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1031075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setLParenLoc(SourceLocation Loc) { 1032075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->LParenLoc = Loc; 1033075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1034075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara void setRParenLoc(SourceLocation Loc) { 1035075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara this->getLocalData()->RParenLoc = Loc; 1036075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1037075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 1038075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara SourceRange getLocalSourceRange() const { 1039075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 1040075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1041075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 1042c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1043075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setLParenLoc(Loc); 1044075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara setRParenLoc(Loc); 1045075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1046075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 1047075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara TypeLoc getInnerLoc() const { 1048075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return getInnerTypeLoc(); 1049075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1050075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 1051075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType getInnerType() const { 1052075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return this->getTypePtr()->getInnerType(); 1053075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 1054075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara}; 1055075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 105639e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikieinline TypeLoc TypeLoc::IgnoreParens() const { 105765124fe81f61eed98b845c87e3a78a780f3deb11David Blaikie if (ParenTypeLoc::isKind(*this)) 105839e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return IgnoreParensImpl(*this); 105939e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie return *this; 106039e6ab4be93d9c5e729a578ddd9d415cd2d49872David Blaikie} 1061f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 106212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 1063651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesstruct AdjustedLocInfo { }; // Nothing. 106412df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 1065651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesclass AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc, 1066651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines AdjustedType, AdjustedLocInfo> { 106712df246d6dea2ee1f92c186f922f1afcf499647aReid Klecknerpublic: 106812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner TypeLoc getOriginalLoc() const { 106912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return getInnerTypeLoc(); 107012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 107112df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 107212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner void initializeLocal(ASTContext &Context, SourceLocation Loc) { 107312df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // do nothing 107412df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 107512df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 107612df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner QualType getInnerType() const { 107712df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // The inner type is the undecayed type, since that's what we have source 107812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // location information for. 107912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return getTypePtr()->getOriginalType(); 108012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 108112df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 108212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner SourceRange getLocalSourceRange() const { 108312df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return SourceRange(); 108412df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 108512df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 108612df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner unsigned getLocalDataSize() const { 1087651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique 108812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner // anyway. TypeLocBuilder can't handle data sizes of 1. 108912df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner return 0; // No data. 109012df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner } 109112df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner}; 109212df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 1093651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \brief Wrapper for source info for pointers decayed from arrays and 1094651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// functions. 1095651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesclass DecayedTypeLoc : public InheritingConcreteTypeLoc< 1096651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines AdjustedTypeLoc, DecayedTypeLoc, DecayedType> { 1097651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines}; 109812df246d6dea2ee1f92c186f922f1afcf499647aReid Kleckner 109951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo { 110034a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation StarLoc; 1101f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis}; 1102f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis 1103ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// A base class for 110451bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> 110551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, 110651bd803fbdade51d674598ed45da3d54190a656cJohn McCall TypeClass, LocalData> { 1107ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 110851bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getSigilLoc() const { 110951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getLocalData()->StarLoc; 1110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 111151bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setSigilLoc(SourceLocation Loc) { 111251bd803fbdade51d674598ed45da3d54190a656cJohn McCall this->getLocalData()->StarLoc = Loc; 1113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1115b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getPointeeLoc() const { 111651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getInnerTypeLoc(); 1117b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1119bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 112051bd803fbdade51d674598ed45da3d54190a656cJohn McCall return SourceRange(getSigilLoc(), getSigilLoc()); 1121b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1122b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1123c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 112451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 11254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 11264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 112751bd803fbdade51d674598ed45da3d54190a656cJohn McCall QualType getInnerType() const { 112851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return this->getTypePtr()->getPointeeType(); 112951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 113034a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 113351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers. 113451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc, 113551bd803fbdade51d674598ed45da3d54190a656cJohn McCall PointerType> { 113651bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 113751bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getStarLoc() const { 113851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 113951bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 114051bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setStarLoc(SourceLocation Loc) { 114151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 114251bd803fbdade51d674598ed45da3d54190a656cJohn McCall } 1143b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1144b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 114551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1146b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers. 114751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc, 114851bd803fbdade51d674598ed45da3d54190a656cJohn McCall BlockPointerType> { 1149b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1150b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getCaretLoc() const { 115151bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setCaretLoc(SourceLocation Loc) { 115451bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 115634a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1158b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnarastruct MemberPointerLocInfo : public PointerLikeLocInfo { 1159b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *ClassTInfo; 1160b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara}; 1161b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1162b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers. 116351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc, 1164b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerType, 1165b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara MemberPointerLocInfo> { 1166b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1167b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getStarLoc() const { 116851bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1169b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1170b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setStarLoc(SourceLocation Loc) { 117151bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 11724ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 1173b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1174b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara const Type *getClass() const { 1175b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getTypePtr()->getClass(); 1176b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1177b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara TypeSourceInfo *getClassTInfo() const { 1178b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return getLocalData()->ClassTInfo; 1179b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1180b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void setClassTInfo(TypeSourceInfo* TI) { 1181b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara getLocalData()->ClassTInfo = TI; 1182b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1183b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1184b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1185b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara setSigilLoc(Loc); 11866bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines setClassTInfo(nullptr); 1187b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 1188b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara 1189b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara SourceRange getLocalSourceRange() const { 1190b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara if (TypeSourceInfo *TI = getClassTInfo()) 1191b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc()); 1192b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara else 1193b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara return SourceRange(getStarLoc()); 1194b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara } 119534a0447b8072e0da14c0980597da9d03a1495662John McCall}; 1196b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1197c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information. 1198c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc : 1199c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc, 1200c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerType> { 1201c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic: 1202c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall SourceLocation getStarLoc() const { 1203c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return getSigilLoc(); 1204c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1205c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1206c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall void setStarLoc(SourceLocation Loc) { 1207c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall setSigilLoc(Loc); 1208c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall } 1209c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall}; 1210c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 1211b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 121251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc, 121351bd803fbdade51d674598ed45da3d54190a656cJohn McCall ReferenceType> { 121454e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic: 121554e14c4db764c0636160d26c5bbf491637c83a76John McCall QualType getInnerType() const { 121654e14c4db764c0636160d26c5bbf491637c83a76John McCall return getTypePtr()->getPointeeTypeAsWritten(); 121754e14c4db764c0636160d26c5bbf491637c83a76John McCall } 1218b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1219b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1220bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc : 1221bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1222bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceTypeLoc, 1223bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall LValueReferenceType> { 1224b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1225b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getAmpLoc() const { 122651bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1227b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1228b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setAmpLoc(SourceLocation Loc) { 122951bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1230b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 123151bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1232b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1233bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc : 1234bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall public InheritingConcreteTypeLoc<ReferenceTypeLoc, 1235bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceTypeLoc, 1236bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall RValueReferenceType> { 123751bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic: 123851bd803fbdade51d674598ed45da3d54190a656cJohn McCall SourceLocation getAmpAmpLoc() const { 123951bd803fbdade51d674598ed45da3d54190a656cJohn McCall return getSigilLoc(); 1240b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 124151bd803fbdade51d674598ed45da3d54190a656cJohn McCall void setAmpAmpLoc(SourceLocation Loc) { 124251bd803fbdade51d674598ed45da3d54190a656cJohn McCall setSigilLoc(Loc); 1243b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 124451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 1245b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1246b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 124734a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo { 1248796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeBegin; 124959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation LParenLoc; 125059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation RParenLoc; 1251796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation LocalRangeEnd; 1252b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1253b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1254b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions. 125551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 125651bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionTypeLoc, 125751bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionType, 125851bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionLocInfo> { 1259b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1260796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeBegin() const { 1261796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeBegin; 1262b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1263796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeBegin(SourceLocation L) { 1264796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeBegin = L; 1265b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1266b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1267796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara SourceLocation getLocalRangeEnd() const { 1268796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return getLocalData()->LocalRangeEnd; 1269b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1270796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara void setLocalRangeEnd(SourceLocation L) { 1271796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara getLocalData()->LocalRangeEnd = L; 1272b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1273b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 127459c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation getLParenLoc() const { 127559c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return this->getLocalData()->LParenLoc; 127659c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 127759c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara void setLParenLoc(SourceLocation Loc) { 127859c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara this->getLocalData()->LParenLoc = Loc; 127959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 128059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 128159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceLocation getRParenLoc() const { 128259c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return this->getLocalData()->RParenLoc; 128359c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 128459c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara void setRParenLoc(SourceLocation Loc) { 128559c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara this->getLocalData()->RParenLoc = Loc; 128659c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 128759c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 128859c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara SourceRange getParensRange() const { 128959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara return SourceRange(getLParenLoc(), getRParenLoc()); 129059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara } 129159c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara 1292ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman ArrayRef<ParmVarDecl *> getParams() const { 1293176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines return llvm::makeArrayRef(getParmArray(), getNumParams()); 1294ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman } 1295ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman 1296651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines // ParmVarDecls* are stored after Info, one for each parameter. 1297a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **getParmArray() const { 1298a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor return (ParmVarDecl**) getExtraLocalData(); 1299a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor } 1300a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor 1301651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines unsigned getNumParams() const { 130234a0447b8072e0da14c0980597da9d03a1495662John McCall if (isa<FunctionNoProtoType>(getTypePtr())) 1303b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return 0; 1304651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines return cast<FunctionProtoType>(getTypePtr())->getNumParams(); 1305b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1306651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; } 1307651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; } 1308b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1309651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines TypeLoc getReturnLoc() const { 131034a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1311b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1312b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1313bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1314796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara return SourceRange(getLocalRangeBegin(), getLocalRangeEnd()); 1315b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1316b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1317c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1318796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeBegin(Loc); 131959c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara setLParenLoc(Loc); 132059c0a818a79be850f7ae8fdafd57a1710e5b809aAbramo Bagnara setRParenLoc(Loc); 1321796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara setLocalRangeEnd(Loc); 1322651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines for (unsigned i = 0, e = getNumParams(); i != e; ++i) 13236bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines setParam(i, nullptr); 13244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 13254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 1326b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// \brief Returns the size of the type source info data block that is 1327b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis /// specific to this type. 132834a0447b8072e0da14c0980597da9d03a1495662John McCall unsigned getExtraLocalDataSize() const { 1329651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines return getNumParams() * sizeof(ParmVarDecl *); 1330b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1331b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 133244ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 133344ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<ParmVarDecl*>(); 133444ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 133544ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 1336651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines QualType getInnerType() const { return getTypePtr()->getReturnType(); } 133734a0447b8072e0da14c0980597da9d03a1495662John McCall}; 133834a0447b8072e0da14c0980597da9d03a1495662John McCall 133951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc : 134051bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 134151bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoTypeLoc, 134251bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionProtoType> { 134351bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 134451bd803fbdade51d674598ed45da3d54190a656cJohn McCall 134551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc : 134651bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<FunctionTypeLoc, 134751bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoTypeLoc, 134851bd803fbdade51d674598ed45da3d54190a656cJohn McCall FunctionNoProtoType> { 134951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 135051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1351b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 135234a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo { 135334a0447b8072e0da14c0980597da9d03a1495662John McCall SourceLocation LBracketLoc, RBracketLoc; 135434a0447b8072e0da14c0980597da9d03a1495662John McCall Expr *Size; 1355b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1356b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1357b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays. 135851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 135951bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayTypeLoc, 136051bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayType, 136151bd803fbdade51d674598ed45da3d54190a656cJohn McCall ArrayLocInfo> { 1362b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic: 1363b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getLBracketLoc() const { 136434a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->LBracketLoc; 1365b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1366b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setLBracketLoc(SourceLocation Loc) { 136734a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->LBracketLoc = Loc; 1368b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1369b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1370b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis SourceLocation getRBracketLoc() const { 137134a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->RBracketLoc; 1372b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1373b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setRBracketLoc(SourceLocation Loc) { 137434a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->RBracketLoc = Loc; 1375b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1376b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 137785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange getBracketsRange() const { 137885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return SourceRange(getLBracketLoc(), getRBracketLoc()); 137985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 138085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 1381b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis Expr *getSizeExpr() const { 138234a0447b8072e0da14c0980597da9d03a1495662John McCall return getLocalData()->Size; 1383b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1384b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis void setSizeExpr(Expr *Size) { 138534a0447b8072e0da14c0980597da9d03a1495662John McCall getLocalData()->Size = Size; 1386b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1387b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1388b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis TypeLoc getElementLoc() const { 138934a0447b8072e0da14c0980597da9d03a1495662John McCall return getInnerTypeLoc(); 1390b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1391b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1392bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1393b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis return SourceRange(getLBracketLoc(), getRBracketLoc()); 1394b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis } 1395b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 1396c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 13974ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setLBracketLoc(Loc); 13984ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall setRBracketLoc(Loc); 13996bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines setSizeExpr(nullptr); 14004ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall } 14014ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall 140234a0447b8072e0da14c0980597da9d03a1495662John McCall QualType getInnerType() const { return getTypePtr()->getElementType(); } 1403b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}; 1404b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 140551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc : 140651bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 140751bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayTypeLoc, 140851bd803fbdade51d674598ed45da3d54190a656cJohn McCall ConstantArrayType> { 140951bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 141051bd803fbdade51d674598ed45da3d54190a656cJohn McCall 141151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc : 141251bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 141351bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayTypeLoc, 141451bd803fbdade51d674598ed45da3d54190a656cJohn McCall IncompleteArrayType> { 141551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 141651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 141751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc : 141851bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 141951bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayTypeLoc, 142051bd803fbdade51d674598ed45da3d54190a656cJohn McCall DependentSizedArrayType> { 142151bd803fbdade51d674598ed45da3d54190a656cJohn McCall 142251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 142351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 142451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc : 142551bd803fbdade51d674598ed45da3d54190a656cJohn McCall public InheritingConcreteTypeLoc<ArrayTypeLoc, 142651bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayTypeLoc, 142751bd803fbdade51d674598ed45da3d54190a656cJohn McCall VariableArrayType> { 142851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 142951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1430833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1431833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName. Rudimentary for now. 1432833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo { 1433833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation NameLoc; 1434833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1435833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1436833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo { 143755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation TemplateKWLoc; 1438833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc; 1439833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation RAngleLoc; 1440833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1441833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1442833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc : 1443833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall public ConcreteTypeLoc<UnqualTypeLoc, 1444833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc, 1445833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationType, 1446833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationLocInfo> { 1447833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic: 144855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateKeywordLoc() const { 144955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return getLocalData()->TemplateKWLoc; 145055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 145155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 145255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara getLocalData()->TemplateKWLoc = Loc; 145355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara } 145455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara 1455833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getLAngleLoc() const { 1456833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->LAngleLoc; 1457833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1458833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setLAngleLoc(SourceLocation Loc) { 1459833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->LAngleLoc = Loc; 1460833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1461833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1462833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getRAngleLoc() const { 1463833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->RAngleLoc; 1464833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1465833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setRAngleLoc(SourceLocation Loc) { 1466833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->RAngleLoc = Loc; 1467833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1468833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1469833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getNumArgs() const { 1470833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getTypePtr()->getNumArgs(); 1471833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1472833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 1473833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getArgInfos()[i] = AI; 1474833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1475833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 1476833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getArgInfos()[i]; 1477833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1478833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1479833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 1480833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 1481833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1482833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1483833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation getTemplateNameLoc() const { 1484833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getLocalData()->NameLoc; 1485833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1486833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void setTemplateNameLoc(SourceLocation Loc) { 1487833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getLocalData()->NameLoc = Loc; 1488833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1489833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1490833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief - Copy the location information from the given info. 1491833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void copy(TemplateSpecializationTypeLoc Loc) { 1492833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned size = getFullDataSize(); 1493833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall assert(size == Loc.getFullDataSize()); 1494833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1495833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // We're potentially copying Expr references here. We don't 1496a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall // bother retaining them because TypeSourceInfos live forever, so 1497833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // as long as the Expr was retained when originally written into 1498833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // the TypeLoc, we're okay. 1499833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall memcpy(Data, Loc.Data, size); 1500833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1501833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1502bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 150355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getTemplateKeywordLoc().isValid()) 150455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 150555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara else 150655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 1507833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1508833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1509c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 151055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateKeywordLoc(Loc); 151155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara setTemplateNameLoc(Loc); 1512833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setLAngleLoc(Loc); 1513833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall setRAngleLoc(Loc); 1514c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(), 151533500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos(), Loc); 151633500955d731c73717af52088b7fc0e7a85681e7John McCall } 1517833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1518c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, 151933500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgument *Args, 152033500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *ArgInfos, 1521c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor SourceLocation Loc); 1522833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1523833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall unsigned getExtraLocalDataSize() const { 1524833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 1525833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1526833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 152744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 152844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<TemplateArgumentLocInfo>(); 152944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 153044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 1531833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate: 1532833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo *getArgInfos() const { 1533833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 1534833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 1535833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall}; 1536833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 1537ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 1538ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1539ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// All of these need proper implementations. 1540ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// 1541ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===// 154251bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1543ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we 1544ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax). 1545ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1546ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorTypeLoc, 1547ed97649e9574b9d854fa4d6109c9333ae0993554John McCall VectorType> { 154851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 154951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1550ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations. 155151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc, 155251bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorTypeLoc, 155351bd803fbdade51d674598ed45da3d54190a656cJohn McCall ExtVectorType> { 155451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 155551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1556ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations. 155751bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType. 155851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc : 1559ed97649e9574b9d854fa4d6109c9333ae0993554John McCall public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1560ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorTypeLoc, 1561ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DependentSizedExtVectorType> { 156251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 156351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword. 1565ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1566ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexTypeLoc, 1567ed97649e9574b9d854fa4d6109c9333ae0993554John McCall ComplexType> { 156851bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 156951bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1570cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo { 1571cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation TypeofLoc; 1572cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation LParenLoc; 1573cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation RParenLoc; 157451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 157551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1576cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo { 1577cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1578cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1579cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo { 1580cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* UnderlyingTInfo; 1581cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1582cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1583cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo> 1584cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc 1585cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> { 1586cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1587cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getTypeofLoc() const { 1588cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->TypeofLoc; 1589cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1590cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setTypeofLoc(SourceLocation Loc) { 1591cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->TypeofLoc = Loc; 1592cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1593cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1594cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getLParenLoc() const { 1595cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->LParenLoc; 1596cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1597cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setLParenLoc(SourceLocation Loc) { 1598cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->LParenLoc = Loc; 1599cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1600cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1601cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceLocation getRParenLoc() const { 1602cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->RParenLoc; 1603cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1604cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setRParenLoc(SourceLocation Loc) { 1605cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->RParenLoc = Loc; 1606cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1607cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1608cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall SourceRange getParensRange() const { 1609cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getLParenLoc(), getRParenLoc()); 1610cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1611cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setParensRange(SourceRange range) { 1612cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(range.getBegin()); 1613cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(range.getEnd()); 1614cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1615cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1616bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 1617cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return SourceRange(getTypeofLoc(), getRParenLoc()); 1618cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1619cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1620c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1621cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setTypeofLoc(Loc); 1622cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setLParenLoc(Loc); 1623cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall setRParenLoc(Loc); 1624cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1625cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1626cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1627cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc, 1628cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprType, 1629cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeOfExprTypeLocInfo> { 1630cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1631cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Expr* getUnderlyingExpr() const { 1632cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return getTypePtr()->getUnderlyingExpr(); 1633cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1634cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // Reimplemented to account for GNU/C++ extension 1635cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // typeof unary-expression 1636cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall // where there are no parentheses. 1637bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const; 1638cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall}; 1639cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall 1640cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc 1641cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> { 1642cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic: 1643cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall QualType getUnderlyingType() const { 1644cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getTypePtr()->getUnderlyingType(); 1645cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1646cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* getUnderlyingTInfo() const { 1647cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall return this->getLocalData()->UnderlyingTInfo; 1648cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1649cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall void setUnderlyingTInfo(TypeSourceInfo* TI) const { 1650cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall this->getLocalData()->UnderlyingTInfo = TI; 1651cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall } 1652176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 1653176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void initializeLocal(ASTContext &Context, SourceLocation Loc); 165451bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 165551bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1656ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens. 1657ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 1658ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeTypeLoc, 1659ed97649e9574b9d854fa4d6109c9333ae0993554John McCall DecltypeType> { 1660427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic: 1661427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); } 166251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 166351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 1664ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntstruct UnaryTransformTypeLocInfo { 1665ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // FIXME: While there's only one unary transform right now, future ones may 1666ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt // need different representations 1667ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation KWLoc, LParenLoc, RParenLoc; 1668ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo *UnderlyingTInfo; 1669ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1670ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1671ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntclass UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1672ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLoc, 1673ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformType, 1674ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt UnaryTransformTypeLocInfo> { 1675ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntpublic: 1676ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getKWLoc() const { return getLocalData()->KWLoc; } 1677ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; } 1678ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1679ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; } 1680ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; } 1681ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1682ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; } 1683ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; } 1684ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1685ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt TypeSourceInfo* getUnderlyingTInfo() const { 1686ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return getLocalData()->UnderlyingTInfo; 1687ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1688ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setUnderlyingTInfo(TypeSourceInfo *TInfo) { 1689ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt getLocalData()->UnderlyingTInfo = TInfo; 1690ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1691ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1692ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getLocalSourceRange() const { 1693ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getKWLoc(), getRParenLoc()); 1694ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1695ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1696ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt SourceRange getParensRange() const { 1697ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt return SourceRange(getLParenLoc(), getRParenLoc()); 1698ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1699ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void setParensRange(SourceRange Range) { 1700ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Range.getBegin()); 1701ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Range.getEnd()); 1702ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1703ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 1704ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt void initializeLocal(ASTContext &Context, SourceLocation Loc) { 1705ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setKWLoc(Loc); 1706ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setRParenLoc(Loc); 1707ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt setLParenLoc(Loc); 1708ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt } 1709ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt}; 1710ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt 171134b41d939a1328f484511c6002ba2456db879a29Richard Smithclass AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, 171234b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoTypeLoc, 171334b41d939a1328f484511c6002ba2456db879a29Richard Smith AutoType> { 171434b41d939a1328f484511c6002ba2456db879a29Richard Smith}; 171534b41d939a1328f484511c6002ba2456db879a29Richard Smith 1716e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo { 171738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation ElaboratedKWLoc; 171838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara /// \brief Data associated with the nested-name-specifier location. 17199e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void *QualifierData; 1720e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1721e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1722e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1723e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc, 1724e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedType, 1725e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedLocInfo> { 1726e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 172738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 172838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1729e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 173038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 173138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1732e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1733e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 17349e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1735ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 17369e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData); 1737e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1738ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 17399e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1740ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 17419e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor == getTypePtr()->getQualifier() && 17429e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor "Inconsistent nested-name-specifier pointer"); 17439e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1744e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1745e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1746bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 174738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 17489e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor if (getQualifierLoc()) 174938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), 175038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara getQualifierLoc().getEndLoc()); 1751e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 175238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc()); 1753e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 17549e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor return getQualifierLoc().getSourceRange(); 1755e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1756e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 17579e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 1758e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1759e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara TypeLoc getNamedTypeLoc() const { 1760e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getInnerTypeLoc(); 1761e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1762e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1763e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType getInnerType() const { 1764e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return getTypePtr()->getNamedType(); 1765e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1766e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1767e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(ElaboratedTypeLoc Loc) { 1768e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1769e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1770e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1771e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 177251bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 177351bd803fbdade51d674598ed45da3d54190a656cJohn McCall 177433500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner 177533500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc. 177633500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo { 1777e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation NameLoc; 1778e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara}; 1779e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1780e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, 1781e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc, 1782e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameType, 1783e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameLocInfo> { 1784e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic: 178538a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 178638a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 1787e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 178838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 178938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 1790e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1791e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 17922494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 1793ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 17942494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData); 1795e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1796ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 17972494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 1798ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 17992494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor == getTypePtr()->getQualifier() && 18002494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor "Inconsistent nested-name-specifier pointer"); 18012494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 1802e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1803ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1804e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation getNameLoc() const { 1805e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return this->getLocalData()->NameLoc; 1806e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1807e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void setNameLoc(SourceLocation Loc) { 1808e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara this->getLocalData()->NameLoc = Loc; 1809e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1810e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1811bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara SourceRange getLocalSourceRange() const { 181238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 181338a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getNameLoc()); 1814e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara else 18152494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc()); 1816e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1817e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 1818e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara void copy(DependentNameTypeLoc Loc) { 1819e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara unsigned size = getFullDataSize(); 1820e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara assert(size == Loc.getFullDataSize()); 1821e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara memcpy(Data, Loc.Data, size); 1822e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 1823e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 18242494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 182551bd803fbdade51d674598ed45da3d54190a656cJohn McCall}; 182651bd803fbdade51d674598ed45da3d54190a656cJohn McCall 182794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregorstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo { 182866581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation TemplateKWLoc; 182933500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation LAngleLoc; 183033500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation RAngleLoc; 183133500955d731c73717af52088b7fc0e7a85681e7John McCall // followed by a TemplateArgumentLocInfo[] 183233500955d731c73717af52088b7fc0e7a85681e7John McCall}; 183333500955d731c73717af52088b7fc0e7a85681e7John McCall 183433500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc : 183533500955d731c73717af52088b7fc0e7a85681e7John McCall public ConcreteTypeLoc<UnqualTypeLoc, 183633500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationTypeLoc, 183733500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType, 183833500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationLocInfo> { 183933500955d731c73717af52088b7fc0e7a85681e7John McCallpublic: 184055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getElaboratedKeywordLoc() const { 184155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return this->getLocalData()->ElaboratedKWLoc; 184233500955d731c73717af52088b7fc0e7a85681e7John McCall } 184355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setElaboratedKeywordLoc(SourceLocation Loc) { 184455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara this->getLocalData()->ElaboratedKWLoc = Loc; 184533500955d731c73717af52088b7fc0e7a85681e7John McCall } 184633500955d731c73717af52088b7fc0e7a85681e7John McCall 184794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { 184894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!getLocalData()->QualifierData) 184994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return NestedNameSpecifierLoc(); 1850ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1851ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), 185294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData); 185333500955d731c73717af52088b7fc0e7a85681e7John McCall } 1854ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 185594fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { 185694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor if (!QualifierLoc) { 1857ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie // Even if we have a nested-name-specifier in the dependent 185894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // template specialization type, we won't record the nested-name-specifier 185994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // location information when this type-source location information is 186094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor // part of a nested-name-specifier. 18616bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines getLocalData()->QualifierData = nullptr; 186294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return; 186394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor } 1864ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1865ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(QualifierLoc.getNestedNameSpecifier() 186694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor == getTypePtr()->getQualifier() && 186794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor "Inconsistent nested-name-specifier pointer"); 186894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); 186933500955d731c73717af52088b7fc0e7a85681e7John McCall } 187033500955d731c73717af52088b7fc0e7a85681e7John McCall 187166581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara SourceLocation getTemplateKeywordLoc() const { 187266581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return getLocalData()->TemplateKWLoc; 187366581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 187466581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara void setTemplateKeywordLoc(SourceLocation Loc) { 187566581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara getLocalData()->TemplateKWLoc = Loc; 187666581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara } 187766581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara 187855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara SourceLocation getTemplateNameLoc() const { 187933500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->NameLoc; 188033500955d731c73717af52088b7fc0e7a85681e7John McCall } 188155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara void setTemplateNameLoc(SourceLocation Loc) { 188233500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->NameLoc = Loc; 188333500955d731c73717af52088b7fc0e7a85681e7John McCall } 188433500955d731c73717af52088b7fc0e7a85681e7John McCall 188533500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getLAngleLoc() const { 188633500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->LAngleLoc; 188733500955d731c73717af52088b7fc0e7a85681e7John McCall } 188833500955d731c73717af52088b7fc0e7a85681e7John McCall void setLAngleLoc(SourceLocation Loc) { 188933500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->LAngleLoc = Loc; 189033500955d731c73717af52088b7fc0e7a85681e7John McCall } 189133500955d731c73717af52088b7fc0e7a85681e7John McCall 189233500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation getRAngleLoc() const { 189333500955d731c73717af52088b7fc0e7a85681e7John McCall return this->getLocalData()->RAngleLoc; 189433500955d731c73717af52088b7fc0e7a85681e7John McCall } 189533500955d731c73717af52088b7fc0e7a85681e7John McCall void setRAngleLoc(SourceLocation Loc) { 189633500955d731c73717af52088b7fc0e7a85681e7John McCall this->getLocalData()->RAngleLoc = Loc; 189733500955d731c73717af52088b7fc0e7a85681e7John McCall } 189833500955d731c73717af52088b7fc0e7a85681e7John McCall 189933500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getNumArgs() const { 190033500955d731c73717af52088b7fc0e7a85681e7John McCall return getTypePtr()->getNumArgs(); 190133500955d731c73717af52088b7fc0e7a85681e7John McCall } 190233500955d731c73717af52088b7fc0e7a85681e7John McCall 190333500955d731c73717af52088b7fc0e7a85681e7John McCall void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) { 190433500955d731c73717af52088b7fc0e7a85681e7John McCall getArgInfos()[i] = AI; 190533500955d731c73717af52088b7fc0e7a85681e7John McCall } 190633500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo getArgLocInfo(unsigned i) const { 190733500955d731c73717af52088b7fc0e7a85681e7John McCall return getArgInfos()[i]; 190833500955d731c73717af52088b7fc0e7a85681e7John McCall } 190933500955d731c73717af52088b7fc0e7a85681e7John McCall 191033500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLoc getArgLoc(unsigned i) const { 191133500955d731c73717af52088b7fc0e7a85681e7John McCall return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i)); 191233500955d731c73717af52088b7fc0e7a85681e7John McCall } 191333500955d731c73717af52088b7fc0e7a85681e7John McCall 191433500955d731c73717af52088b7fc0e7a85681e7John McCall SourceRange getLocalSourceRange() const { 191555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara if (getElaboratedKeywordLoc().isValid()) 191655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getElaboratedKeywordLoc(), getRAngleLoc()); 191794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor else if (getQualifierLoc()) 191894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc()); 191966581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara else if (getTemplateKeywordLoc().isValid()) 192066581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara return SourceRange(getTemplateKeywordLoc(), getRAngleLoc()); 19219e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor else 192255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara return SourceRange(getTemplateNameLoc(), getRAngleLoc()); 192333500955d731c73717af52088b7fc0e7a85681e7John McCall } 192433500955d731c73717af52088b7fc0e7a85681e7John McCall 192533500955d731c73717af52088b7fc0e7a85681e7John McCall void copy(DependentTemplateSpecializationTypeLoc Loc) { 192633500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned size = getFullDataSize(); 192733500955d731c73717af52088b7fc0e7a85681e7John McCall assert(size == Loc.getFullDataSize()); 192833500955d731c73717af52088b7fc0e7a85681e7John McCall memcpy(Data, Loc.Data, size); 192933500955d731c73717af52088b7fc0e7a85681e7John McCall } 193033500955d731c73717af52088b7fc0e7a85681e7John McCall 193194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc); 193233500955d731c73717af52088b7fc0e7a85681e7John McCall 193333500955d731c73717af52088b7fc0e7a85681e7John McCall unsigned getExtraLocalDataSize() const { 193433500955d731c73717af52088b7fc0e7a85681e7John McCall return getNumArgs() * sizeof(TemplateArgumentLocInfo); 193533500955d731c73717af52088b7fc0e7a85681e7John McCall } 193633500955d731c73717af52088b7fc0e7a85681e7John McCall 193744ee0a710c59d8e6793189f903bae21c16814324Eli Friedman unsigned getExtraLocalDataAlignment() const { 193844ee0a710c59d8e6793189f903bae21c16814324Eli Friedman return llvm::alignOf<TemplateArgumentLocInfo>(); 193944ee0a710c59d8e6793189f903bae21c16814324Eli Friedman } 194044ee0a710c59d8e6793189f903bae21c16814324Eli Friedman 194133500955d731c73717af52088b7fc0e7a85681e7John McCallprivate: 194233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentLocInfo *getArgInfos() const { 194333500955d731c73717af52088b7fc0e7a85681e7John McCall return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData()); 194433500955d731c73717af52088b7fc0e7a85681e7John McCall } 194533500955d731c73717af52088b7fc0e7a85681e7John McCall}; 194633500955d731c73717af52088b7fc0e7a85681e7John McCall 19477536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19487536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo { 19497536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation EllipsisLoc; 19507536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 19517536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19527536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc 1953ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc, 19547536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor PackExpansionType, PackExpansionTypeLocInfo> { 19557536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic: 19567536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceLocation getEllipsisLoc() const { 19577536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getLocalData()->EllipsisLoc; 19587536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19597536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19607536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor void setEllipsisLoc(SourceLocation Loc) { 19617536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor this->getLocalData()->EllipsisLoc = Loc; 19627536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19637536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19647536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor SourceRange getLocalSourceRange() const { 19657536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return SourceRange(getEllipsisLoc(), getEllipsisLoc()); 19667536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19677536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1968c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor void initializeLocal(ASTContext &Context, SourceLocation Loc) { 19697536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor setEllipsisLoc(Loc); 19707536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19717536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19727536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor TypeLoc getPatternLoc() const { 19737536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return getInnerTypeLoc(); 19747536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19757536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 19767536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor QualType getInnerType() const { 19777536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return this->getTypePtr()->getPattern(); 19787536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor } 19797536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor}; 19807536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 1981b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanstruct AtomicTypeLocInfo { 1982b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation KWLoc, LParenLoc, RParenLoc; 1983b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 1984b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1985b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanclass AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc, 1986b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman AtomicType, AtomicTypeLocInfo> { 1987ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 1988b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman TypeLoc getValueLoc() const { 1989b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getInnerTypeLoc(); 1990b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1991b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1992b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getLocalSourceRange() const { 1993b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getKWLoc(), getRParenLoc()); 1994b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1995b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 1996b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getKWLoc() const { 1997b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->KWLoc; 1998b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 1999b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setKWLoc(SourceLocation Loc) { 2000b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->KWLoc = Loc; 2001b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2002b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 2003b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getLParenLoc() const { 2004b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->LParenLoc; 2005b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2006b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setLParenLoc(SourceLocation Loc) { 2007b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->LParenLoc = Loc; 2008b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2009b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 2010b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceLocation getRParenLoc() const { 2011b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getLocalData()->RParenLoc; 2012b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2013b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setRParenLoc(SourceLocation Loc) { 2014b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman this->getLocalData()->RParenLoc = Loc; 2015b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2016b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 2017b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman SourceRange getParensRange() const { 2018b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return SourceRange(getLParenLoc(), getRParenLoc()); 2019b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2020b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void setParensRange(SourceRange Range) { 2021b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Range.getBegin()); 2022b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Range.getEnd()); 2023b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2024b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 2025b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void initializeLocal(ASTContext &Context, SourceLocation Loc) { 2026b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setKWLoc(Loc); 2027b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setLParenLoc(Loc); 2028b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman setRParenLoc(Loc); 2029b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2030b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 2031b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman QualType getInnerType() const { 2032b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman return this->getTypePtr()->getValueType(); 2033b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman } 2034b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman}; 2035b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 20364967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainarstruct PipeTypeLocInfo { 20374967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation KWLoc; 20384967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar}; 20394967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 20404967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainarclass PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType, 20414967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar PipeTypeLocInfo> { 20424967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainarpublic: 20434967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); } 20444967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 20454967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceRange getLocalSourceRange() const { return SourceRange(getKWLoc()); } 20464967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 20474967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; } 20484967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; } 2049b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 20504967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar void initializeLocal(ASTContext &Context, SourceLocation Loc) { 20514967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar setKWLoc(Loc); 20524967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar } 20534967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 20544967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar QualType getInnerType() const { return this->getTypePtr()->getElementType(); } 20554967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar}; 2056b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis} 2057b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis 2058b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif 2059