TypeLoc.h revision c3069d618f4661d923cb1b5c4525b082fce73b04
1b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===--- TypeLoc.h - Type Source Info Wrapper -------------------*- C++ -*-===//
2b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
3b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//                     The LLVM Compiler Infrastructure
4b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
5b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// This file is distributed under the University of Illinois Open Source
6b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// License. See LICENSE.TXT for details.
7b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
8b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===//
9b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
10b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//  This file defines the TypeLoc interface and subclasses.
11b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
12b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===//
13b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
14b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#ifndef LLVM_CLANG_AST_TYPELOC_H
15b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#define LLVM_CLANG_AST_TYPELOC_H
16b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
17b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#include "clang/AST/Type.h"
183c385c28cf1f27b193a620d2e51f814873362cebJohn McCall#include "clang/AST/Decl.h"
19833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h"
20ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor#include "clang/Basic/Specifiers.h"
21b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
22b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang {
23b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  class ParmVarDecl;
24a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall  class TypeSourceInfo;
2534a0447b8072e0da14c0980597da9d03a1495662John McCall  class UnqualTypeLoc;
26b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
2751bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes.
2851bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base)
2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \
3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  class Class##TypeLoc;
3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def"
3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
33b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info.
34b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis///
35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to
36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information.
37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc {
38b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected:
3934a0447b8072e0da14c0980597da9d03a1495662John McCall  // The correctness of this relies on the property that, for Type *Ty,
4034a0447b8072e0da14c0980597da9d03a1495662John McCall  //   QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
4134a0447b8072e0da14c0980597da9d03a1495662John McCall  void *Ty;
42b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void *Data;
431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
44b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
4551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// The kinds of TypeLocs.  Equivalent to the Type::TypeClass enum,
4651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// except it also defines a Qualified enum that corresponds to the
4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// QualifiedLoc class.
4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  enum TypeLocClass {
4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base)
5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \
5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Class = Type::Class,
5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def"
5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Qualified
5451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  };
5551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
5634a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc() : Ty(0), Data(0) { }
5734a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc(QualType ty, void *opaqueData)
5834a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { }
5934a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc(Type *ty, void *opaqueData)
6034a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty), Data(opaqueData) { }
61b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
6251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
63a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    if (getType().hasLocalQualifiers()) return Qualified;
6451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getType()->getTypeClass();
6551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
6651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
6734a0447b8072e0da14c0980597da9d03a1495662John McCall  bool isNull() const { return !Ty; }
6834a0447b8072e0da14c0980597da9d03a1495662John McCall  operator bool() const { return Ty; }
69b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
70b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of type source info data block for the given type.
71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static unsigned getFullDataSizeForType(QualType Ty);
72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
73b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the type for which this source info wrapper provides
74b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// information.
7551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getType() const {
7651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return QualType::getFromOpaquePtr(Ty);
7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
7834a0447b8072e0da14c0980597da9d03a1495662John McCall
7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  Type *getTypePtr() const {
8034a0447b8072e0da14c0980597da9d03a1495662John McCall    return QualType::getFromOpaquePtr(Ty).getTypePtr();
8134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
82b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
83b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis  /// \brief Get the pointer where source information is stored.
8451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void *getOpaqueData() const {
8551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Data;
8651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
87b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
88e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  /// \brief Get the begin source location.
89e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  SourceLocation getBeginLoc() const;
90e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara
91e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  /// \brief Get the end source location.
92e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  SourceLocation getEndLoc() const;
93e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara
94833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the full source range.
95bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getSourceRange() const {
96e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara    return SourceRange(getBeginLoc(), getEndLoc());
97833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
98833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
99833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the local source range.
100bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
101bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara    return getLocalSourceRangeImpl(*this);
10251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block.
10534a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
10651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getFullDataSizeForType(getType());
10734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
11151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLoc getNextTypeLoc() const {
11251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getNextTypeLocImpl(*this);
11351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
11534a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Skips past any qualifiers, if this is qualified.
11651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
11734a0447b8072e0da14c0980597da9d03a1495662John McCall
118723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  TypeLoc IgnoreParens() const {
119723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara    if (isa<ParenTypeLoc>(this))
120723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara      return IgnoreParensImpl(*this);
121723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara    return *this;
122723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  }
123140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara
1244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// \brief Initializes this to state that every location in this
1254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// type is the given location.
1264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  ///
1274ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// This method exists to provide a simple transition for code that
1284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// relies on location-less types.
1294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initialize(SourceLocation Loc) const {
1304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    initializeImpl(*this, Loc);
1314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
1324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
13345ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  /// \brief Initializes this by copying its information from another
13445ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  /// TypeLoc of the same type.
13545ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  void initializeFullCopy(TypeLoc Other) const {
136711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getType() == Other.getType());
137711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    size_t Size = getFullDataSize();
138711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
139711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  }
140711c52bb20d0c69063b52a99826fb7d2835501f1John McCall
141711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// \brief Initializes this by copying its information from another
142711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// TypeLoc of the same type.  The given size must be the full data
143711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// size.
144711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  void initializeFullCopy(TypeLoc Other, unsigned Size) const {
145711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getType() == Other.getType());
146711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getFullDataSize() == Size);
147711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
14845ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  }
14945ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein
150b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
151b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) {
155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return !(LHS == RHS);
156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static bool classof(const TypeLoc *TL) { return true; }
1594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate:
1614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  static void initializeImpl(TypeLoc TL, SourceLocation Loc);
16251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static TypeLoc getNextTypeLocImpl(TypeLoc TL);
163723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  static TypeLoc IgnoreParensImpl(TypeLoc TL);
164bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
165b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
166b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1673c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info.
1683c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const {
1694ab92891a53adda8c52c1947351371da58e33f64Gabor Greif  return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
1703c385c28cf1f27b193a620d2e51f814873362cebJohn McCall}
1713c385c28cf1f27b193a620d2e51f814873362cebJohn McCall
17234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
173489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers.
17434a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc {
17534a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
17634a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc() {}
17734a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc(Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
17834a0447b8072e0da14c0980597da9d03a1495662John McCall
17951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  Type *getTypePtr() const {
18034a0447b8072e0da14c0980597da9d03a1495662John McCall    return reinterpret_cast<Type*>(Ty);
18134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
18234a0447b8072e0da14c0980597da9d03a1495662John McCall
18351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
18451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getTypePtr()->getTypeClass();
18551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
18651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
18734a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
188a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return !TL->getType().hasLocalQualifiers();
18934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
19034a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const UnqualTypeLoc *TL) { return true; }
19134a0447b8072e0da14c0980597da9d03a1495662John McCall};
19234a0447b8072e0da14c0980597da9d03a1495662John McCall
19334a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
19434a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers.
19534a0447b8072e0da14c0980597da9d03a1495662John McCall///
19634a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for
19734a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers.
19851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc {
19934a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
200bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
20134a0447b8072e0da14c0980597da9d03a1495662John McCall    return SourceRange();
20234a0447b8072e0da14c0980597da9d03a1495662John McCall  }
20334a0447b8072e0da14c0980597da9d03a1495662John McCall
20434a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc getUnqualifiedLoc() const {
20551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return UnqualTypeLoc(getTypePtr(), Data);
20634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
20734a0447b8072e0da14c0980597da9d03a1495662John McCall
2084ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// Initializes the local data of this type source info block to
2094ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// provide no information.
2104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
2114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    // do nothing
2124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
2134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
2144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
2154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getUnqualifiedLoc();
2164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
2174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
21834a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block that is
21934a0447b8072e0da14c0980597da9d03a1495662John McCall  /// specific to this type.
22034a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
22134a0447b8072e0da14c0980597da9d03a1495662John McCall    // In fact, we don't currently preserve any location information
22234a0447b8072e0da14c0980597da9d03a1495662John McCall    // for qualifiers.
22334a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
22434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
22534a0447b8072e0da14c0980597da9d03a1495662John McCall
22634a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block.
22734a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
22834a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalDataSize() +
229fa1a06e80706846fa15e0bd44671bdc3dfc53d84Douglas Gregor      getFullDataSizeForType(getType().getLocalUnqualifiedType());
23034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
23134a0447b8072e0da14c0980597da9d03a1495662John McCall
23234a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
233a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return TL->getType().hasLocalQualifiers();
23434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
23551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const QualifiedTypeLoc *TL) { return true; }
23634a0447b8072e0da14c0980597da9d03a1495662John McCall};
23734a0447b8072e0da14c0980597da9d03a1495662John McCall
23834a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const {
23951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  if (isa<QualifiedTypeLoc>(this))
24051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc();
24134a0447b8072e0da14c0980597da9d03a1495662John McCall  return cast<UnqualTypeLoc>(*this);
24234a0447b8072e0da14c0980597da9d03a1495662John McCall}
24334a0447b8072e0da14c0980597da9d03a1495662John McCall
24434a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond
245f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass.  It is accepted for a single
246f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes.
24734a0447b8072e0da14c0980597da9d03a1495662John McCall///
24834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Base a class from which to derive
24934a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Derived the class deriving from this one
250f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// \param TypeClass the concrete Type subclass associated with this
251f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall///   location type
25234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param LocalData the structure type of local location data for
25334a0447b8072e0da14c0980597da9d03a1495662John McCall///   this type
25434a0447b8072e0da14c0980597da9d03a1495662John McCall///
25534a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or
25634a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end.
25734a0447b8072e0da14c0980597da9d03a1495662John McCall///
25834a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override
25934a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to
26034a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory.
26134a0447b8072e0da14c0980597da9d03a1495662John McCall///
262a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define
263a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall///   QualType getInnerType() const
264a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's
265a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data.
26651bd803fbdade51d674598ed45da3d54190a656cJohn McCall///
26751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be
26851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy.  It is also not
26951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide
27051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information.  It should be subclassed
27151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children
27251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type,
27351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from
27451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead.
27534a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData>
27634a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base {
27734a0447b8072e0da14c0980597da9d03a1495662John McCall
27834a0447b8072e0da14c0980597da9d03a1495662John McCall  const Derived *asDerived() const {
27934a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<const Derived*>(this);
28034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
28134a0447b8072e0da14c0980597da9d03a1495662John McCall
28234a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
28334a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
28434a0447b8072e0da14c0980597da9d03a1495662John McCall    return sizeof(LocalData) + asDerived()->getExtraLocalDataSize();
28534a0447b8072e0da14c0980597da9d03a1495662John McCall  }
28634a0447b8072e0da14c0980597da9d03a1495662John McCall  // Give a default implementation that's useful for leaf types.
28734a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
28834a0447b8072e0da14c0980597da9d03a1495662John McCall    return asDerived()->getLocalDataSize() + getInnerTypeSize();
28934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29034a0447b8072e0da14c0980597da9d03a1495662John McCall
29134a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classofType(const Type *Ty) {
29234a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeClass::classof(Ty);
29334a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29434a0447b8072e0da14c0980597da9d03a1495662John McCall
295e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const TypeLoc *TL) {
296e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return Derived::classofType(TL->getTypePtr());
297e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
298e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const UnqualTypeLoc *TL) {
299e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return Derived::classofType(TL->getTypePtr());
300e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
301e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const Derived *TL) {
302e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return true;
303e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
304e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
3054ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
3064ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getNextTypeLoc(asDerived()->getInnerType());
3074ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
3084ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
30934a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeClass *getTypePtr() const {
31051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
31134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
31234a0447b8072e0da14c0980597da9d03a1495662John McCall
31351bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected:
31434a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
31534a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
31634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
31734a0447b8072e0da14c0980597da9d03a1495662John McCall
31834a0447b8072e0da14c0980597da9d03a1495662John McCall  LocalData *getLocalData() const {
31934a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<LocalData*>(Base::Data);
32034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
32134a0447b8072e0da14c0980597da9d03a1495662John McCall
32234a0447b8072e0da14c0980597da9d03a1495662John McCall  /// Gets a pointer past the Info structure; useful for classes with
32334a0447b8072e0da14c0980597da9d03a1495662John McCall  /// local data that can't be captured in the Info (e.g. because it's
32434a0447b8072e0da14c0980597da9d03a1495662John McCall  /// of variable size).
32534a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getExtraLocalData() const {
32634a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData() + 1;
32734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
32834a0447b8072e0da14c0980597da9d03a1495662John McCall
32934a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getNonLocalData() const {
33034a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize();
33134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
33234a0447b8072e0da14c0980597da9d03a1495662John McCall
333a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  struct HasNoInnerType {};
334a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  HasNoInnerType getInnerType() const { return HasNoInnerType(); }
33534a0447b8072e0da14c0980597da9d03a1495662John McCall
33634a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc getInnerTypeLoc() const {
33734a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
33834a0447b8072e0da14c0980597da9d03a1495662John McCall  }
33934a0447b8072e0da14c0980597da9d03a1495662John McCall
34034a0447b8072e0da14c0980597da9d03a1495662John McCallprivate:
34134a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getInnerTypeSize() const {
342a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeSize(asDerived()->getInnerType());
343a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  }
344a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall
345a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(HasNoInnerType _) const {
34634a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
34734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
34834a0447b8072e0da14c0980597da9d03a1495662John McCall
349a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(QualType _) const {
350a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeLoc().getFullDataSize();
35134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
3524ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3534ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(HasNoInnerType _) const {
3544ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc();
3554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
3564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3574ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(QualType T) const {
3584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc(T, getNonLocalData());
3594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
36034a0447b8072e0da14c0980597da9d03a1495662John McCall};
36134a0447b8072e0da14c0980597da9d03a1495662John McCall
36251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract
36351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source
36451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information.  See the note on ConcreteTypeLoc.
36551bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass>
36651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base {
367b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
368713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor  static bool classofType(const Type *Ty) {
369713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor    return TypeClass::classof(Ty);
370713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor  }
371713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor
37251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const TypeLoc *TL) {
37351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
374b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
37551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const UnqualTypeLoc *TL) {
37651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
377b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
37851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const Derived *TL) {
37951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return true;
380b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
381b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
38251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeClass *getTypePtr() const {
38351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
3844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
38534a0447b8072e0da14c0980597da9d03a1495662John McCall};
386b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
387ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
38851bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo {
38934a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation NameLoc;
390b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
391b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
39251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to
39351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier.
394ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
395ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               TypeSpecTypeLoc,
396ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               Type,
397ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               TypeSpecLocInfo> {
398b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
399ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  enum { LocalDataSize = sizeof(TypeSpecLocInfo) };
400ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
401b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getNameLoc() const {
40251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->NameLoc;
403b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
404b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setNameLoc(SourceLocation Loc) {
40551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->NameLoc = Loc;
406b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
407bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
408b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getNameLoc(), getNameLoc());
409b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
4104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
4114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setNameLoc(Loc);
4124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
413ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
414ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  static bool classof(const TypeLoc *TL);
415ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  static bool classof(const TypeSpecTypeLoc *TL) { return true; }
41651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
4174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
418ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
419ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo {
420ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation BuiltinLoc;
421ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor};
422ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
423ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types.
424ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
425ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinTypeLoc,
426ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinType,
427ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinLocInfo> {
428ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic:
429ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  enum { LocalDataSize = sizeof(BuiltinLocInfo) };
430ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
431ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation getBuiltinLoc() const {
432ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getLocalData()->BuiltinLoc;
433ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
434ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setBuiltinLoc(SourceLocation Loc) {
435ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    getLocalData()->BuiltinLoc = Loc;
436ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
437ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
438ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation getNameLoc() const { return getBuiltinLoc(); }
439ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
440ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  WrittenBuiltinSpecs& getWrittenBuiltinSpecs() {
441ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
442ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
443ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const {
444ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
445ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
446ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
447ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool needsExtraLocalData() const {
448ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    BuiltinType::Kind bk = getTypePtr()->getKind();
449ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128)
450d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor      || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble)
451ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      || bk == BuiltinType::UChar
452ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      || bk == BuiltinType::SChar;
453ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
454ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
455ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  unsigned getExtraLocalDataSize() const {
456d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar    return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
457ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
458ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
459bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
460ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return SourceRange(getBuiltinLoc(), getBuiltinLoc());
461ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
462ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
463ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierSign getWrittenSignSpec() const {
464ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
465ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign);
466ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
467ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return TSS_unspecified;
468ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
469ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenSignSpec() const {
470ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenSignSpec() != TSS_unspecified;
471ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
472ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenSignSpec(TypeSpecifierSign written) {
473ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
474ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Sign = written;
475ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierWidth getWrittenWidthSpec() const {
478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width);
480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return TSW_unspecified;
482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenWidthSpec() const {
484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenWidthSpec() != TSW_unspecified;
485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenWidthSpec(TypeSpecifierWidth written) {
487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Width = written;
489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierType getWrittenTypeSpec() const;
492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenTypeSpec() const {
493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenTypeSpec() != TST_unspecified;
494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenTypeSpec(TypeSpecifierType written) {
496ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
497ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Type = written;
498ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
499ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
500ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasModeAttr() const {
501ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
502ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return getWrittenBuiltinSpecs().ModeAttr;
503ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
504ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return false;
505ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
506ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setModeAttr(bool written) {
507ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
508ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().ModeAttr = written;
509ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
510ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
511ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void initializeLocal(SourceLocation Loc) {
512ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    setBuiltinLoc(Loc);
513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData()) {
514ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs();
515ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Sign = TSS_unspecified;
516ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Width = TSW_unspecified;
517ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Type = TST_unspecified;
518ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.ModeAttr = false;
519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    }
520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor};
522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
52451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs.
525ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
526ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        TypedefTypeLoc,
527ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        TypedefType> {
52851bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
5299036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis  TypedefDecl *getTypedefDecl() const {
53034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getTypePtr()->getDecl();
5319036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis  }
53234a0447b8072e0da14c0980597da9d03a1495662John McCall};
5339036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis
5343cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class
5353cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates.
5363cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc :
5373cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
5383cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall                                     InjectedClassNameTypeLoc,
5393cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall                                     InjectedClassNameType> {
5403cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall};
5413cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall
542ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls.
543ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc :
544ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
545ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     UnresolvedUsingTypeLoc,
546ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     UnresolvedUsingType> {
547ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
548ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  UnresolvedUsingTypenameDecl *getDecl() const {
549ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    return getTypePtr()->getDecl();
550ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  }
551ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
552ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
553ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types.  Note that this only
554ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo'
555ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc.  We currently
556ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of
557ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C.
558ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
559ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                    TagTypeLoc,
560ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                    TagType> {
561ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
562ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
563ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
565ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types.
566ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
567ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       RecordTypeLoc,
568ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       RecordType> {
569ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
570ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
571ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
572ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
573ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types.
574ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
575ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                     EnumTypeLoc,
576ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                     EnumType> {
577ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
578ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
579ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
580b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
58149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters.
582ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc :
583ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
584ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     TemplateTypeParmTypeLoc,
585ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     TemplateTypeParmType> {
58649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
58749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall
58849a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters.
58949a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc :
590ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
591ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     SubstTemplateTypeParmTypeLoc,
592ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     SubstTemplateTypeParmType> {
59349a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
59451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
595c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor  /// \brief Wrapper for substituted template type parameters.
596c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc :
597c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
598c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor                                     SubstTemplateTypeParmPackTypeLoc,
599c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor                                     SubstTemplateTypeParmPackType> {
600c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor};
601c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor
6029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo {
6039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  union {
6049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    Expr *ExprOperand;
6059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    /// A raw SourceLocation.
6079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    unsigned EnumOperandLoc;
6089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  };
6099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange OperandParens;
6119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation AttrLoc;
6139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
6149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type.
6169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
6179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedTypeLoc,
6189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedType,
6199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedLocInfo> {
6209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic:
6219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  AttributedType::Kind getAttrKind() const {
6229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getAttrKind();
6239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrExprOperand() const {
6269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstExprOperandKind &&
6279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastExprOperandKind);
6289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrEnumOperand() const {
6319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstEnumOperandKind &&
6329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastEnumOperandKind);
6339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrOperand() const {
6369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return hasAttrExprOperand() || hasAttrEnumOperand();
6379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The modified type, which is generally canonically different from
6409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// the attribute type.
6419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    int main(int, char**) __attribute__((noreturn))
6429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    ~~~     ~~~~~~~~~~~~~
6439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  TypeLoc getModifiedLoc() const {
6449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getInnerTypeLoc();
6459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute name, i.e.
6489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    __attribute__((regparm(1000)))
6499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                   ^~~~~~~
6509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrNameLoc() const {
6519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->AttrLoc;
6529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrNameLoc(SourceLocation loc) {
6549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->AttrLoc = loc;
6559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The attribute's expression operand, if it has one.
6589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void *cur_thread __attribute__((address_space(21)))
6599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                                  ^~
6609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  Expr *getAttrExprOperand() const {
6619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->ExprOperand;
6639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrExprOperand(Expr *e) {
6659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->ExprOperand = e;
6679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute's enumerated operand, if it has one.
6709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
6719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                  ^~~~
6729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrEnumOperandLoc() const {
6739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc);
6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrEnumOperandLoc(SourceLocation loc) {
6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->EnumOperandLoc = loc.getRawEncoding();
6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the parentheses around the operand, if there is
6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// an operand.
6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                 ^    ^
6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getAttrOperandParensRange() const {
6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->OperandParens;
6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrOperandParensRange(SourceRange range) {
6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->OperandParens = range;
6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getLocalSourceRange() const {
6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // Note that this does *not* include the range of the attribute
6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // enclosure, e.g.:
6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    __attribute__((foo(bar)))
6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~~~~~~~~~~~~~~        ~~
6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // or
7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    [[foo(bar)]]
7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~        ~~
7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // That enclosure doesn't necessarily belong to a single attribute
7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // anyway.
7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    SourceRange range(getAttrNameLoc());
7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrOperand())
7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      range.setEnd(getAttrOperandParensRange().getEnd());
7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return range;
7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void initializeLocal(SourceLocation loc) {
7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    setAttrNameLoc(loc);
7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrExprOperand()) {
7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrExprOperand(0);
7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    } else if (hasAttrEnumOperand()) {
7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrEnumOperandLoc(loc);
7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    }
7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  QualType getInnerType() const {
7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getModifiedType();
7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
726eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
72734a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo {
72854e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation LAngleLoc;
72954e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation RAngleLoc;
730ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall  bool HasBaseTypeAsWritten;
731eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis};
732eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
73354e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with
73454e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols.
73554e14c4db764c0636160d26c5bbf491637c83a76John McCall//
73654e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or
73754e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType.
738c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
739c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectTypeLoc,
740c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectType,
741c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCProtocolListLocInfo> {
742f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  // SourceLocations are stored after Info, one for each Protocol.
743f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation *getProtocolLocArray() const {
74454e14c4db764c0636160d26c5bbf491637c83a76John McCall    return (SourceLocation*) this->getExtraLocalData();
74554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
74654e14c4db764c0636160d26c5bbf491637c83a76John McCall
747f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic:
748f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getLAngleLoc() const {
74954e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->LAngleLoc;
750f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
751f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setLAngleLoc(SourceLocation Loc) {
75254e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->LAngleLoc = Loc;
753f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
754f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
755f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getRAngleLoc() const {
75654e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->RAngleLoc;
757f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
758f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setRAngleLoc(SourceLocation Loc) {
75954e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->RAngleLoc = Loc;
760f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
761f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
762f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  unsigned getNumProtocols() const {
76354e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getTypePtr()->getNumProtocols();
764f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
765f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
766f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getProtocolLoc(unsigned i) const {
767f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
768f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return getProtocolLocArray()[i];
769f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
770f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setProtocolLoc(unsigned i, SourceLocation Loc) {
771f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
772f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    getProtocolLocArray()[i] = Loc;
773f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
774f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
775f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  ObjCProtocolDecl *getProtocol(unsigned i) const {
776f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
77754e14c4db764c0636160d26c5bbf491637c83a76John McCall    return *(this->getTypePtr()->qual_begin() + i);
778f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
779f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
780c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  bool hasBaseTypeAsWritten() const {
781ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    return getLocalData()->HasBaseTypeAsWritten;
782c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
783c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
784c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setHasBaseTypeAsWritten(bool HasBaseType) {
785ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    getLocalData()->HasBaseTypeAsWritten = HasBaseType;
786c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
787c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
788c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  TypeLoc getBaseLoc() const {
789c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getInnerTypeLoc();
790c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
791c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
792bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
793f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return SourceRange(getLAngleLoc(), getRAngleLoc());
794f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
795f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
7964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
797ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    setHasBaseTypeAsWritten(true);
798c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setLAngleLoc(Loc);
799c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setRAngleLoc(Loc);
800c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
801c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall      setProtocolLoc(i, Loc);
8024ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
8034ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
80434a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
80554e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getNumProtocols() * sizeof(SourceLocation);
80654e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
807c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
808c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  QualType getInnerType() const {
809c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getTypePtr()->getBaseType();
810c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
81154e14c4db764c0636160d26c5bbf491637c83a76John McCall};
81254e14c4db764c0636160d26c5bbf491637c83a76John McCall
81354e14c4db764c0636160d26c5bbf491637c83a76John McCall
814c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo {
81554e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation NameLoc;
81654e14c4db764c0636160d26c5bbf491637c83a76John McCall};
81754e14c4db764c0636160d26c5bbf491637c83a76John McCall
81854e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces.
819a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
820c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceTypeLoc,
821c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceType,
822c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceLocInfo> {
82354e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
82454e14c4db764c0636160d26c5bbf491637c83a76John McCall  ObjCInterfaceDecl *getIFaceDecl() const {
82554e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getDecl();
82654e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
82754e14c4db764c0636160d26c5bbf491637c83a76John McCall
82854e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation getNameLoc() const {
82954e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->NameLoc;
83054e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
83154e14c4db764c0636160d26c5bbf491637c83a76John McCall
83254e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setNameLoc(SourceLocation Loc) {
83354e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->NameLoc = Loc;
83454e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
83554e14c4db764c0636160d26c5bbf491637c83a76John McCall
836bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
837c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return SourceRange(getNameLoc());
83854e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
83954e14c4db764c0636160d26c5bbf491637c83a76John McCall
84054e14c4db764c0636160d26c5bbf491637c83a76John McCall  void initializeLocal(SourceLocation Loc) {
84154e14c4db764c0636160d26c5bbf491637c83a76John McCall    setNameLoc(Loc);
842f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
84354e14c4db764c0636160d26c5bbf491637c83a76John McCall};
84454e14c4db764c0636160d26c5bbf491637c83a76John McCall
845075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo {
846075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation LParenLoc;
847075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation RParenLoc;
848075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
849075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
850075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc
851075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
852075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara                           ParenLocInfo> {
853075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic:
854075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getLParenLoc() const {
855075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->LParenLoc;
856075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
857075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getRParenLoc() const {
858075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->RParenLoc;
859075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
860075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setLParenLoc(SourceLocation Loc) {
861075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->LParenLoc = Loc;
862075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
863075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setRParenLoc(SourceLocation Loc) {
864075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->RParenLoc = Loc;
865075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
866075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
867075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceRange getLocalSourceRange() const {
868075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return SourceRange(getLParenLoc(), getRParenLoc());
869075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
870075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
871075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
872075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setLParenLoc(Loc);
873075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setRParenLoc(Loc);
874075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
875075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
876075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  TypeLoc getInnerLoc() const {
877075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return getInnerTypeLoc();
878075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
879075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
880075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  QualType getInnerType() const {
881075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getTypePtr()->getInnerType();
882075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
883075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
884075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
885f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
88651bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo {
88734a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation StarLoc;
888f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis};
889f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
89051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A base class for
89151bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
89251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
89351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                  TypeClass, LocalData> {
894bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallpublic:
89551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getSigilLoc() const {
89651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->StarLoc;
897b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
89851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setSigilLoc(SourceLocation Loc) {
89951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->StarLoc = Loc;
900b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
901b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
902b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getPointeeLoc() const {
90351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getInnerTypeLoc();
904b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
905b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
906bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
90751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return SourceRange(getSigilLoc(), getSigilLoc());
908b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
909b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
9104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
91151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
9134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
91451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getInnerType() const {
91551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getTypePtr()->getPointeeType();
91651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
91734a0447b8072e0da14c0980597da9d03a1495662John McCall};
918b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
919b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
92051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers.
92151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
92251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 PointerType> {
92351bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
92451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getStarLoc() const {
92551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
92651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
92751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setStarLoc(SourceLocation Loc) {
92851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
92951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
930b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
931b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
93251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
933b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers.
93451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
93551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                      BlockPointerType> {
936b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
937b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getCaretLoc() const {
93851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
939b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
940b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setCaretLoc(SourceLocation Loc) {
94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
942b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
94334a0447b8072e0da14c0980597da9d03a1495662John McCall};
944b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
945b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
946b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers.
94751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
94851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                       MemberPointerType> {
949b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
950b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getStarLoc() const {
95151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
952b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
953b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setStarLoc(SourceLocation Loc) {
95451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
95634a0447b8072e0da14c0980597da9d03a1495662John McCall};
957b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
958c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information.
959c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc :
960c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
961c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                              ObjCObjectPointerType> {
962c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic:
963c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  SourceLocation getStarLoc() const {
964c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getSigilLoc();
965c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
966c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
967c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setStarLoc(SourceLocation Loc) {
968c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setSigilLoc(Loc);
969c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
970c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall};
971c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
972b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
97351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
97451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                   ReferenceType> {
97554e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
97654e14c4db764c0636160d26c5bbf491637c83a76John McCall  QualType getInnerType() const {
97754e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getPointeeTypeAsWritten();
97854e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
979b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
980b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
981bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc :
982bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
983bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceTypeLoc,
984bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceType> {
985b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
986b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getAmpLoc() const {
98751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
988b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
989b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setAmpLoc(SourceLocation Loc) {
99051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
991b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
99251bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
993b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
994bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc :
995bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
996bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceTypeLoc,
997bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceType> {
99851bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
99951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getAmpAmpLoc() const {
100051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
1001b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
100251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setAmpAmpLoc(SourceLocation Loc) {
100351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
1004b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
100551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
1006b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1007b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
100834a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo {
100934a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LParenLoc, RParenLoc;
1010dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool TrailingReturn;
1011b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1012b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1013b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions.
101451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
101551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionTypeLoc,
101651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionType,
101751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionLocInfo> {
1018b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1019b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLParenLoc() const {
102034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LParenLoc;
1021b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1022b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLParenLoc(SourceLocation Loc) {
102334a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LParenLoc = Loc;
1024b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1025b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1026b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRParenLoc() const {
102734a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RParenLoc;
1028b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1029b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRParenLoc(SourceLocation Loc) {
103034a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RParenLoc = Loc;
1031b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1032b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1033dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool getTrailingReturn() const {
1034dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    return getLocalData()->TrailingReturn;
1035dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1036dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  void setTrailingReturn(bool Trailing) {
1037dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    getLocalData()->TrailingReturn = Trailing;
1038dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1039dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor
1040a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  // ParmVarDecls* are stored after Info, one for each argument.
1041a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  ParmVarDecl **getParmArray() const {
1042a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor    return (ParmVarDecl**) getExtraLocalData();
1043a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  }
1044a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor
1045b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  unsigned getNumArgs() const {
104634a0447b8072e0da14c0980597da9d03a1495662John McCall    if (isa<FunctionNoProtoType>(getTypePtr()))
1047b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis      return 0;
104834a0447b8072e0da14c0980597da9d03a1495662John McCall    return cast<FunctionProtoType>(getTypePtr())->getNumArgs();
1049b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1050b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; }
1051b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1052b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1053b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getResultLoc() const {
105434a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1055b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1056b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1057bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1058b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLParenLoc(), getRParenLoc());
1059b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1060b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
10614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
10624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLParenLoc(Loc);
10634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRParenLoc(Loc);
1064dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    setTrailingReturn(false);
10654ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
10664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall      setArg(i, NULL);
10674ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
10684ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1069b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block that is
1070b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// specific to this type.
107134a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
107234a0447b8072e0da14c0980597da9d03a1495662John McCall    return getNumArgs() * sizeof(ParmVarDecl*);
1073b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1074b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
107534a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getResultType(); }
107634a0447b8072e0da14c0980597da9d03a1495662John McCall};
107734a0447b8072e0da14c0980597da9d03a1495662John McCall
107851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc :
107951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
108051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoTypeLoc,
108151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoType> {
108251bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
108351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
108451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc :
108551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
108651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoTypeLoc,
108751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoType> {
108851bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
108951bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1090b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
109134a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo {
109234a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LBracketLoc, RBracketLoc;
109334a0447b8072e0da14c0980597da9d03a1495662John McCall  Expr *Size;
1094b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1095b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1096b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays.
109751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
109851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayTypeLoc,
109951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayType,
110051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayLocInfo> {
1101b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1102b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLBracketLoc() const {
110334a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LBracketLoc;
1104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLBracketLoc(SourceLocation Loc) {
110634a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LBracketLoc = Loc;
1107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRBracketLoc() const {
111034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RBracketLoc;
1111b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1112b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRBracketLoc(SourceLocation Loc) {
111334a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RBracketLoc = Loc;
1114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1115b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
111685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  SourceRange getBracketsRange() const {
111785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall    return SourceRange(getLBracketLoc(), getRBracketLoc());
111885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  }
111985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall
1120b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  Expr *getSizeExpr() const {
112134a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->Size;
1122b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1123b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setSizeExpr(Expr *Size) {
112434a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->Size = Size;
1125b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1126b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1127b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getElementLoc() const {
112834a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1129b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1130b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1131bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLBracketLoc(), getRBracketLoc());
1133b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1134b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
11354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
11364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLBracketLoc(Loc);
11374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRBracketLoc(Loc);
11384ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setSizeExpr(NULL);
11394ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
11404ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
114134a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getElementType(); }
1142b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1143b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
114451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc :
114551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
114651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayTypeLoc,
114751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayType> {
114851bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
114951bd803fbdade51d674598ed45da3d54190a656cJohn McCall
115051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc :
115151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
115251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayTypeLoc,
115351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayType> {
115451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
115551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
115651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc :
115751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
115851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayTypeLoc,
115951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayType> {
116051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
116151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
116251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
116351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc :
116451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
116551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayTypeLoc,
116651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayType> {
116751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
116851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1169833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1170833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName.  Rudimentary for now.
1171833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo {
1172833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation NameLoc;
1173833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1174833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1175833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo {
1176833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation LAngleLoc;
1177833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation RAngleLoc;
1178833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1179833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1180833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc :
1181833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
1182833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationTypeLoc,
1183833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationType,
1184833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationLocInfo> {
1185833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic:
1186833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getLAngleLoc() const {
1187833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->LAngleLoc;
1188833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1189833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setLAngleLoc(SourceLocation Loc) {
1190833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->LAngleLoc = Loc;
1191833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1192833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1193833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getRAngleLoc() const {
1194833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->RAngleLoc;
1195833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1196833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setRAngleLoc(SourceLocation Loc) {
1197833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->RAngleLoc = Loc;
1198833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1199833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1200833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getNumArgs() const {
1201833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getTypePtr()->getNumArgs();
1202833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1203833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
1204833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getArgInfos()[i] = AI;
1205833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1206833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
1207833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getArgInfos()[i];
1208833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1209833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1210833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
1211833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
1212833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1213833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1214833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getTemplateNameLoc() const {
1215833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->NameLoc;
1216833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1217833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setTemplateNameLoc(SourceLocation Loc) {
1218833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->NameLoc = Loc;
1219833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1220833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1221833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief - Copy the location information from the given info.
1222833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void copy(TemplateSpecializationTypeLoc Loc) {
1223833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    unsigned size = getFullDataSize();
1224833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    assert(size == Loc.getFullDataSize());
1225833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1226833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // We're potentially copying Expr references here.  We don't
1227a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall    // bother retaining them because TypeSourceInfos live forever, so
1228833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // as long as the Expr was retained when originally written into
1229833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // the TypeLoc, we're okay.
1230833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    memcpy(Data, Loc.Data, size);
1231833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1232833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1233bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1234833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return SourceRange(getTemplateNameLoc(), getRAngleLoc());
1235833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1236833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1237833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void initializeLocal(SourceLocation Loc) {
1238833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setLAngleLoc(Loc);
1239833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setRAngleLoc(Loc);
1240833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setTemplateNameLoc(Loc);
124133500955d731c73717af52088b7fc0e7a85681e7John McCall    initializeArgLocs(getNumArgs(), getTypePtr()->getArgs(),
124233500955d731c73717af52088b7fc0e7a85681e7John McCall                      getArgInfos(), Loc);
124333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
1244833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
124533500955d731c73717af52088b7fc0e7a85681e7John McCall  static void initializeArgLocs(unsigned NumArgs,
124633500955d731c73717af52088b7fc0e7a85681e7John McCall                                const TemplateArgument *Args,
124733500955d731c73717af52088b7fc0e7a85681e7John McCall                                TemplateArgumentLocInfo *ArgInfos,
124833500955d731c73717af52088b7fc0e7a85681e7John McCall                                SourceLocation Loc) {
1249b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor    for (unsigned i = 0, e = NumArgs; i != e; ++i) {
1250b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor      // FIXME: We can generate better location info here for type arguments,
1251b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor      // template template arguments, and template template pack expansions (?).
12526939fff69a3dfff2552261a1d7f1f609380fe6b0Douglas Gregor      ArgInfos[i] = TemplateArgumentLocInfo();
1253b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor    }
1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1255833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1256833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getExtraLocalDataSize() const {
1257833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1258833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1259833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1260833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate:
1261833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo *getArgInfos() const {
1262833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1263833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1264833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1265833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1266ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
1267ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1268ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//  All of these need proper implementations.
1269ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1270ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
127151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1272ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we
1273ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax).
1274ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1275ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorTypeLoc,
1276ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorType> {
127751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
127851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1279ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations.
128051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
128151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorTypeLoc,
128251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorType> {
128351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
128451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1285ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations.
128651bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType.
128751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc :
1288ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1289ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorTypeLoc,
1290ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorType> {
129151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
129251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1293ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword.
1294ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1295ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexTypeLoc,
1296ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexType> {
129751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
129851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1299cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo {
1300cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation TypeofLoc;
1301cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation LParenLoc;
1302cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation RParenLoc;
130351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
130451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1305cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo {
1306cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1307cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1308cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo {
1309cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* UnderlyingTInfo;
1310cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1311cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1312cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1313cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc
1314cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1315cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1316cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getTypeofLoc() const {
1317cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->TypeofLoc;
1318cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1319cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setTypeofLoc(SourceLocation Loc) {
1320cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->TypeofLoc = Loc;
1321cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1322cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1323cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getLParenLoc() const {
1324cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->LParenLoc;
1325cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1326cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setLParenLoc(SourceLocation Loc) {
1327cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->LParenLoc = Loc;
1328cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1329cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1330cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getRParenLoc() const {
1331cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->RParenLoc;
1332cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1333cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setRParenLoc(SourceLocation Loc) {
1334cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->RParenLoc = Loc;
1335cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1336cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1337cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceRange getParensRange() const {
1338cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getLParenLoc(), getRParenLoc());
1339cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1340cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setParensRange(SourceRange range) {
1341cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setLParenLoc(range.getBegin());
1342cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setRParenLoc(range.getEnd());
1343cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1344cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1345bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1346cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getTypeofLoc(), getRParenLoc());
1347cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1348cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1349cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void initializeLocal(SourceLocation Loc) {
1350cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setTypeofLoc(Loc);
1351cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setLParenLoc(Loc);
1352cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setRParenLoc(Loc);
1353cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1354cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1355cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1356cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
1357cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprType,
1358cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprTypeLocInfo> {
1359cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1360cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  Expr* getUnderlyingExpr() const {
1361cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return getTypePtr()->getUnderlyingExpr();
1362cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1363cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // Reimplemented to account for GNU/C++ extension
1364cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  //     typeof unary-expression
1365cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // where there are no parentheses.
1366bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const;
1367cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1368cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1369cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc
1370cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
1371cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1372cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  QualType getUnderlyingType() const {
1373cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getTypePtr()->getUnderlyingType();
1374cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1375cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* getUnderlyingTInfo() const {
1376cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->UnderlyingTInfo;
1377cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1378cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setUnderlyingTInfo(TypeSourceInfo* TI) const {
1379cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->UnderlyingTInfo = TI;
1380cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
138151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
138251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1383ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens.
1384ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1385ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeTypeLoc,
1386ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeType> {
138751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
138851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1389e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo {
1390e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation KeywordLoc;
1391e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange QualifierRange;
1392e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1393e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1394e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1395e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedTypeLoc,
1396e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedType,
1397e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedLocInfo> {
1398e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
1399e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getKeywordLoc() const {
1400e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->KeywordLoc;
1401e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1402e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setKeywordLoc(SourceLocation Loc) {
1403e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->KeywordLoc = Loc;
1404e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1405e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1406e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange getQualifierRange() const {
1407e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->QualifierRange;
1408e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1409e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setQualifierRange(SourceRange Range) {
1410e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->QualifierRange = Range;
1411e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1412e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1413bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1414e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    if (getKeywordLoc().isValid())
1415e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      if (getQualifierRange().getEnd().isValid())
1416e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara        return SourceRange(getKeywordLoc(), getQualifierRange().getEnd());
1417e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      else
1418e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara        return SourceRange(getKeywordLoc());
1419e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
1420e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return getQualifierRange();
1421e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1422e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1423e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
1424e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setKeywordLoc(Loc);
1425e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setQualifierRange(SourceRange(Loc));
1426e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1427e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1428e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  TypeLoc getNamedTypeLoc() const {
1429e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getInnerTypeLoc();
1430e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1431e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1432e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  QualType getInnerType() const {
1433e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getTypePtr()->getNamedType();
1434e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1435e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1436e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(ElaboratedTypeLoc Loc) {
1437e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1438e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1439e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1440e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
144151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
144251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
144333500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner
144433500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc.
144533500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo {
1446e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation NameLoc;
1447e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1448e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1449e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1450e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameTypeLoc,
1451e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameType,
1452e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameLocInfo> {
1453e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
1454e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getKeywordLoc() const {
1455e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->KeywordLoc;
1456e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1457e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setKeywordLoc(SourceLocation Loc) {
1458e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->KeywordLoc = Loc;
1459e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1460e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1461e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange getQualifierRange() const {
1462e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->QualifierRange;
1463e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1464e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setQualifierRange(SourceRange Range) {
1465e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->QualifierRange = Range;
1466e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1467e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1468e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getNameLoc() const {
1469e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->NameLoc;
1470e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1471e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setNameLoc(SourceLocation Loc) {
1472e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->NameLoc = Loc;
1473e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1474e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1475bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1476e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    if (getKeywordLoc().isValid())
1477e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return SourceRange(getKeywordLoc(), getNameLoc());
1478e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
1479e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return SourceRange(getQualifierRange().getBegin(), getNameLoc());
1480e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1481e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1482e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(DependentNameTypeLoc Loc) {
1483e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1484e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1485e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1486e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1487e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1488e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
1489e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setKeywordLoc(Loc);
1490e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setQualifierRange(SourceRange(Loc));
1491e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setNameLoc(Loc);
1492e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
149351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
149451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
149533500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner
149633500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TemplateSpecializationTypeLoc.
149733500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo {
149833500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation LAngleLoc;
149933500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation RAngleLoc;
150033500955d731c73717af52088b7fc0e7a85681e7John McCall  // followed by a TemplateArgumentLocInfo[]
150133500955d731c73717af52088b7fc0e7a85681e7John McCall};
150233500955d731c73717af52088b7fc0e7a85681e7John McCall
150333500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc :
150433500955d731c73717af52088b7fc0e7a85681e7John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
150533500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationTypeLoc,
150633500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationType,
150733500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationLocInfo> {
150833500955d731c73717af52088b7fc0e7a85681e7John McCallpublic:
150933500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getKeywordLoc() const {
151033500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->KeywordLoc;
151133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151233500955d731c73717af52088b7fc0e7a85681e7John McCall  void setKeywordLoc(SourceLocation Loc) {
151333500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->KeywordLoc = Loc;
151433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151533500955d731c73717af52088b7fc0e7a85681e7John McCall
151633500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceRange getQualifierRange() const {
151733500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->QualifierRange;
151833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151933500955d731c73717af52088b7fc0e7a85681e7John McCall  void setQualifierRange(SourceRange Range) {
152033500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->QualifierRange = Range;
152133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152233500955d731c73717af52088b7fc0e7a85681e7John McCall
152333500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getNameLoc() const {
152433500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->NameLoc;
152533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152633500955d731c73717af52088b7fc0e7a85681e7John McCall  void setNameLoc(SourceLocation Loc) {
152733500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->NameLoc = Loc;
152833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152933500955d731c73717af52088b7fc0e7a85681e7John McCall
153033500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getLAngleLoc() const {
153133500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->LAngleLoc;
153233500955d731c73717af52088b7fc0e7a85681e7John McCall  }
153333500955d731c73717af52088b7fc0e7a85681e7John McCall  void setLAngleLoc(SourceLocation Loc) {
153433500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->LAngleLoc = Loc;
153533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
153633500955d731c73717af52088b7fc0e7a85681e7John McCall
153733500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getRAngleLoc() const {
153833500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->RAngleLoc;
153933500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154033500955d731c73717af52088b7fc0e7a85681e7John McCall  void setRAngleLoc(SourceLocation Loc) {
154133500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->RAngleLoc = Loc;
154233500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154333500955d731c73717af52088b7fc0e7a85681e7John McCall
154433500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getNumArgs() const {
154533500955d731c73717af52088b7fc0e7a85681e7John McCall    return getTypePtr()->getNumArgs();
154633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154733500955d731c73717af52088b7fc0e7a85681e7John McCall
154833500955d731c73717af52088b7fc0e7a85681e7John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
154933500955d731c73717af52088b7fc0e7a85681e7John McCall    getArgInfos()[i] = AI;
155033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
155133500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
155233500955d731c73717af52088b7fc0e7a85681e7John McCall    return getArgInfos()[i];
155333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
155433500955d731c73717af52088b7fc0e7a85681e7John McCall
155533500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
155633500955d731c73717af52088b7fc0e7a85681e7John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
155733500955d731c73717af52088b7fc0e7a85681e7John McCall  }
155833500955d731c73717af52088b7fc0e7a85681e7John McCall
155933500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceRange getLocalSourceRange() const {
156033500955d731c73717af52088b7fc0e7a85681e7John McCall    if (getKeywordLoc().isValid())
156133500955d731c73717af52088b7fc0e7a85681e7John McCall      return SourceRange(getKeywordLoc(), getRAngleLoc());
156233500955d731c73717af52088b7fc0e7a85681e7John McCall    else
156333500955d731c73717af52088b7fc0e7a85681e7John McCall      return SourceRange(getQualifierRange().getBegin(), getRAngleLoc());
156433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
156533500955d731c73717af52088b7fc0e7a85681e7John McCall
156633500955d731c73717af52088b7fc0e7a85681e7John McCall  void copy(DependentTemplateSpecializationTypeLoc Loc) {
156733500955d731c73717af52088b7fc0e7a85681e7John McCall    unsigned size = getFullDataSize();
156833500955d731c73717af52088b7fc0e7a85681e7John McCall    assert(size == Loc.getFullDataSize());
156933500955d731c73717af52088b7fc0e7a85681e7John McCall    memcpy(Data, Loc.Data, size);
157033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
157133500955d731c73717af52088b7fc0e7a85681e7John McCall
157233500955d731c73717af52088b7fc0e7a85681e7John McCall  void initializeLocal(SourceLocation Loc) {
157333500955d731c73717af52088b7fc0e7a85681e7John McCall    setKeywordLoc(Loc);
157433500955d731c73717af52088b7fc0e7a85681e7John McCall    setQualifierRange(SourceRange(Loc));
157533500955d731c73717af52088b7fc0e7a85681e7John McCall    setNameLoc(Loc);
157633500955d731c73717af52088b7fc0e7a85681e7John McCall    setLAngleLoc(Loc);
157733500955d731c73717af52088b7fc0e7a85681e7John McCall    setRAngleLoc(Loc);
157833500955d731c73717af52088b7fc0e7a85681e7John McCall    TemplateSpecializationTypeLoc::initializeArgLocs(getNumArgs(),
157933500955d731c73717af52088b7fc0e7a85681e7John McCall                                                     getTypePtr()->getArgs(),
158033500955d731c73717af52088b7fc0e7a85681e7John McCall                                                     getArgInfos(), Loc);
158133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
158233500955d731c73717af52088b7fc0e7a85681e7John McCall
158333500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getExtraLocalDataSize() const {
158433500955d731c73717af52088b7fc0e7a85681e7John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
158533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
158633500955d731c73717af52088b7fc0e7a85681e7John McCall
158733500955d731c73717af52088b7fc0e7a85681e7John McCallprivate:
158833500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo *getArgInfos() const {
158933500955d731c73717af52088b7fc0e7a85681e7John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
159033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
159133500955d731c73717af52088b7fc0e7a85681e7John McCall};
159233500955d731c73717af52088b7fc0e7a85681e7John McCall
15937536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
15947536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo {
15957536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation EllipsisLoc;
15967536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
15977536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
15987536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc
15997536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
16007536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor                           PackExpansionType, PackExpansionTypeLocInfo> {
16017536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic:
16027536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation getEllipsisLoc() const {
16037536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getLocalData()->EllipsisLoc;
16047536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16057536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16067536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  void setEllipsisLoc(SourceLocation Loc) {
16077536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    this->getLocalData()->EllipsisLoc = Loc;
16087536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16097536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16107536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceRange getLocalSourceRange() const {
16117536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return SourceRange(getEllipsisLoc(), getEllipsisLoc());
16127536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16137536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16147536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  void initializeLocal(SourceLocation Loc) {
16157536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    setEllipsisLoc(Loc);
16167536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16177536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16187536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  TypeLoc getPatternLoc() const {
16197536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return getInnerTypeLoc();
16207536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16217536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16227536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  QualType getInnerType() const {
16237536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getTypePtr()->getPattern();
16247536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16257536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
16267536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
1627b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}
1628b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1629b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif
1630