TypeLoc.h revision a009b59fc2c550a229b9146aabda8e33fe3a7771
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
5959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo {
5969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  union {
5979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    Expr *ExprOperand;
5989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
5999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    /// A raw SourceLocation.
6009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    unsigned EnumOperandLoc;
6019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  };
6029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange OperandParens;
6049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation AttrLoc;
6069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
6079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type.
6099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
6109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedTypeLoc,
6119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedType,
6129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedLocInfo> {
6139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic:
6149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  AttributedType::Kind getAttrKind() const {
6159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getAttrKind();
6169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrExprOperand() const {
6199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstExprOperandKind &&
6209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastExprOperandKind);
6219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrEnumOperand() const {
6249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstEnumOperandKind &&
6259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastEnumOperandKind);
6269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrOperand() const {
6299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return hasAttrExprOperand() || hasAttrEnumOperand();
6309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The modified type, which is generally canonically different from
6339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// the attribute type.
6349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    int main(int, char**) __attribute__((noreturn))
6359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    ~~~     ~~~~~~~~~~~~~
6369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  TypeLoc getModifiedLoc() const {
6379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getInnerTypeLoc();
6389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute name, i.e.
6419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    __attribute__((regparm(1000)))
6429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                   ^~~~~~~
6439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrNameLoc() const {
6449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->AttrLoc;
6459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrNameLoc(SourceLocation loc) {
6479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->AttrLoc = loc;
6489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The attribute's expression operand, if it has one.
6519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void *cur_thread __attribute__((address_space(21)))
6529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                                  ^~
6539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  Expr *getAttrExprOperand() const {
6549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->ExprOperand;
6569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrExprOperand(Expr *e) {
6589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->ExprOperand = e;
6609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute's enumerated operand, if it has one.
6639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
6649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                  ^~~~
6659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrEnumOperandLoc() const {
6669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc);
6689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrEnumOperandLoc(SourceLocation loc) {
6709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->EnumOperandLoc = loc.getRawEncoding();
6729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the parentheses around the operand, if there is
6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// an operand.
6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                 ^    ^
6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getAttrOperandParensRange() const {
6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->OperandParens;
6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrOperandParensRange(SourceRange range) {
6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->OperandParens = range;
6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getLocalSourceRange() const {
6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // Note that this does *not* include the range of the attribute
6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // enclosure, e.g.:
6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    __attribute__((foo(bar)))
6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~~~~~~~~~~~~~~        ~~
6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // or
6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    [[foo(bar)]]
6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~        ~~
6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // That enclosure doesn't necessarily belong to a single attribute
6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // anyway.
6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    SourceRange range(getAttrNameLoc());
6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrOperand())
6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      range.setEnd(getAttrOperandParensRange().getEnd());
7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return range;
7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void initializeLocal(SourceLocation loc) {
7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    setAttrNameLoc(loc);
7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrExprOperand()) {
7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrExprOperand(0);
7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    } else if (hasAttrEnumOperand()) {
7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrEnumOperandLoc(loc);
7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    }
7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  QualType getInnerType() const {
7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getModifiedType();
7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
719eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
72034a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo {
72154e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation LAngleLoc;
72254e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation RAngleLoc;
723ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall  bool HasBaseTypeAsWritten;
724eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis};
725eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
72654e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with
72754e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols.
72854e14c4db764c0636160d26c5bbf491637c83a76John McCall//
72954e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or
73054e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType.
731c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
732c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectTypeLoc,
733c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectType,
734c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCProtocolListLocInfo> {
735f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  // SourceLocations are stored after Info, one for each Protocol.
736f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation *getProtocolLocArray() const {
73754e14c4db764c0636160d26c5bbf491637c83a76John McCall    return (SourceLocation*) this->getExtraLocalData();
73854e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
73954e14c4db764c0636160d26c5bbf491637c83a76John McCall
740f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic:
741f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getLAngleLoc() const {
74254e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->LAngleLoc;
743f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
744f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setLAngleLoc(SourceLocation Loc) {
74554e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->LAngleLoc = Loc;
746f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
747f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
748f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getRAngleLoc() const {
74954e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->RAngleLoc;
750f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
751f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setRAngleLoc(SourceLocation Loc) {
75254e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->RAngleLoc = Loc;
753f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
754f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
755f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  unsigned getNumProtocols() const {
75654e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getTypePtr()->getNumProtocols();
757f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
758f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
759f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getProtocolLoc(unsigned i) const {
760f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
761f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return getProtocolLocArray()[i];
762f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
763f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setProtocolLoc(unsigned i, SourceLocation Loc) {
764f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
765f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    getProtocolLocArray()[i] = Loc;
766f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
767f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
768f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  ObjCProtocolDecl *getProtocol(unsigned i) const {
769f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
77054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return *(this->getTypePtr()->qual_begin() + i);
771f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
772f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
773c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  bool hasBaseTypeAsWritten() const {
774ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    return getLocalData()->HasBaseTypeAsWritten;
775c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
776c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
777c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setHasBaseTypeAsWritten(bool HasBaseType) {
778ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    getLocalData()->HasBaseTypeAsWritten = HasBaseType;
779c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
780c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
781c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  TypeLoc getBaseLoc() const {
782c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getInnerTypeLoc();
783c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
784c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
785bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
786f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return SourceRange(getLAngleLoc(), getRAngleLoc());
787f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
788f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
7894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
790ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    setHasBaseTypeAsWritten(true);
791c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setLAngleLoc(Loc);
792c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setRAngleLoc(Loc);
793c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
794c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall      setProtocolLoc(i, Loc);
7954ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
7964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
79734a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
79854e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getNumProtocols() * sizeof(SourceLocation);
79954e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
800c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
801c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  QualType getInnerType() const {
802c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getTypePtr()->getBaseType();
803c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
80454e14c4db764c0636160d26c5bbf491637c83a76John McCall};
80554e14c4db764c0636160d26c5bbf491637c83a76John McCall
80654e14c4db764c0636160d26c5bbf491637c83a76John McCall
807c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo {
80854e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation NameLoc;
80954e14c4db764c0636160d26c5bbf491637c83a76John McCall};
81054e14c4db764c0636160d26c5bbf491637c83a76John McCall
81154e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces.
812a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
813c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceTypeLoc,
814c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceType,
815c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceLocInfo> {
81654e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
81754e14c4db764c0636160d26c5bbf491637c83a76John McCall  ObjCInterfaceDecl *getIFaceDecl() const {
81854e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getDecl();
81954e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
82054e14c4db764c0636160d26c5bbf491637c83a76John McCall
82154e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation getNameLoc() const {
82254e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->NameLoc;
82354e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
82454e14c4db764c0636160d26c5bbf491637c83a76John McCall
82554e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setNameLoc(SourceLocation Loc) {
82654e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->NameLoc = Loc;
82754e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
82854e14c4db764c0636160d26c5bbf491637c83a76John McCall
829bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
830c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return SourceRange(getNameLoc());
83154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
83254e14c4db764c0636160d26c5bbf491637c83a76John McCall
83354e14c4db764c0636160d26c5bbf491637c83a76John McCall  void initializeLocal(SourceLocation Loc) {
83454e14c4db764c0636160d26c5bbf491637c83a76John McCall    setNameLoc(Loc);
835f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
83654e14c4db764c0636160d26c5bbf491637c83a76John McCall};
83754e14c4db764c0636160d26c5bbf491637c83a76John McCall
838075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo {
839075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation LParenLoc;
840075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation RParenLoc;
841075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
842075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
843075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc
844075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
845075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara                           ParenLocInfo> {
846075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic:
847075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getLParenLoc() const {
848075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->LParenLoc;
849075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
850075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getRParenLoc() const {
851075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->RParenLoc;
852075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
853075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setLParenLoc(SourceLocation Loc) {
854075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->LParenLoc = Loc;
855075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
856075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setRParenLoc(SourceLocation Loc) {
857075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->RParenLoc = Loc;
858075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
859075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
860075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceRange getLocalSourceRange() const {
861075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return SourceRange(getLParenLoc(), getRParenLoc());
862075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
863075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
864075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
865075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setLParenLoc(Loc);
866075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setRParenLoc(Loc);
867075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
868075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
869075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  TypeLoc getInnerLoc() const {
870075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return getInnerTypeLoc();
871075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
872075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
873075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  QualType getInnerType() const {
874075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getTypePtr()->getInnerType();
875075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
876075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
877075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
878f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
87951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo {
88034a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation StarLoc;
881f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis};
882f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
88351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A base class for
88451bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
88551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
88651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                  TypeClass, LocalData> {
887bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallpublic:
88851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getSigilLoc() const {
88951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->StarLoc;
890b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
89151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setSigilLoc(SourceLocation Loc) {
89251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->StarLoc = Loc;
893b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
894b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
895b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getPointeeLoc() const {
89651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getInnerTypeLoc();
897b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
898b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
899bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
90051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return SourceRange(getSigilLoc(), getSigilLoc());
901b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
902b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
9034ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
90451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9054ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
9064ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
90751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getInnerType() const {
90851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getTypePtr()->getPointeeType();
90951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
91034a0447b8072e0da14c0980597da9d03a1495662John McCall};
911b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
912b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
91351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers.
91451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
91551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 PointerType> {
91651bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
91751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getStarLoc() const {
91851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
91951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
92051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setStarLoc(SourceLocation Loc) {
92151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
92251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
923b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
924b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
92551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
926b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers.
92751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
92851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                      BlockPointerType> {
929b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
930b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getCaretLoc() const {
93151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
932b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
933b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setCaretLoc(SourceLocation Loc) {
93451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
935b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
93634a0447b8072e0da14c0980597da9d03a1495662John McCall};
937b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
938b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
939b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers.
94051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                       MemberPointerType> {
942b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
943b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getStarLoc() const {
94451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
945b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
946b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setStarLoc(SourceLocation Loc) {
94751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9484ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
94934a0447b8072e0da14c0980597da9d03a1495662John McCall};
950b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
951c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information.
952c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc :
953c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
954c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                              ObjCObjectPointerType> {
955c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic:
956c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  SourceLocation getStarLoc() const {
957c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getSigilLoc();
958c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
959c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
960c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setStarLoc(SourceLocation Loc) {
961c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setSigilLoc(Loc);
962c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
963c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall};
964c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
965b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
96651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
96751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                   ReferenceType> {
96854e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
96954e14c4db764c0636160d26c5bbf491637c83a76John McCall  QualType getInnerType() const {
97054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getPointeeTypeAsWritten();
97154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
972b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
973b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
974bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc :
975bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
976bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceTypeLoc,
977bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceType> {
978b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
979b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getAmpLoc() const {
98051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
981b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
982b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setAmpLoc(SourceLocation Loc) {
98351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
984b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
98551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
986b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
987bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc :
988bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
989bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceTypeLoc,
990bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceType> {
99151bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
99251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getAmpAmpLoc() const {
99351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
994b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
99551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setAmpAmpLoc(SourceLocation Loc) {
99651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
997b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
99851bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
999b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1000b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
100134a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo {
100234a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LParenLoc, RParenLoc;
1003dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool TrailingReturn;
1004b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1005b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1006b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions.
100751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
100851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionTypeLoc,
100951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionType,
101051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionLocInfo> {
1011b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1012b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLParenLoc() const {
101334a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LParenLoc;
1014b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1015b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLParenLoc(SourceLocation Loc) {
101634a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LParenLoc = Loc;
1017b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1018b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1019b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRParenLoc() const {
102034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RParenLoc;
1021b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1022b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRParenLoc(SourceLocation Loc) {
102334a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RParenLoc = Loc;
1024b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1025b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1026dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool getTrailingReturn() const {
1027dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    return getLocalData()->TrailingReturn;
1028dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1029dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  void setTrailingReturn(bool Trailing) {
1030dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    getLocalData()->TrailingReturn = Trailing;
1031dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1032dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor
1033a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  // ParmVarDecls* are stored after Info, one for each argument.
1034a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  ParmVarDecl **getParmArray() const {
1035a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor    return (ParmVarDecl**) getExtraLocalData();
1036a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  }
1037a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor
1038b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  unsigned getNumArgs() const {
103934a0447b8072e0da14c0980597da9d03a1495662John McCall    if (isa<FunctionNoProtoType>(getTypePtr()))
1040b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis      return 0;
104134a0447b8072e0da14c0980597da9d03a1495662John McCall    return cast<FunctionProtoType>(getTypePtr())->getNumArgs();
1042b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1043b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; }
1044b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1045b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1046b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getResultLoc() const {
104734a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1048b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1049b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1050bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1051b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLParenLoc(), getRParenLoc());
1052b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1053b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
10544ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
10554ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLParenLoc(Loc);
10564ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRParenLoc(Loc);
1057dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    setTrailingReturn(false);
10584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
10594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall      setArg(i, NULL);
10604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
10614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1062b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block that is
1063b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// specific to this type.
106434a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
106534a0447b8072e0da14c0980597da9d03a1495662John McCall    return getNumArgs() * sizeof(ParmVarDecl*);
1066b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1067b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
106834a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getResultType(); }
106934a0447b8072e0da14c0980597da9d03a1495662John McCall};
107034a0447b8072e0da14c0980597da9d03a1495662John McCall
107151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc :
107251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
107351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoTypeLoc,
107451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoType> {
107551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
107651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
107751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc :
107851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
107951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoTypeLoc,
108051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoType> {
108151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
108251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1083b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
108434a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo {
108534a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LBracketLoc, RBracketLoc;
108634a0447b8072e0da14c0980597da9d03a1495662John McCall  Expr *Size;
1087b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1088b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1089b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays.
109051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
109151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayTypeLoc,
109251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayType,
109351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayLocInfo> {
1094b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1095b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLBracketLoc() const {
109634a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LBracketLoc;
1097b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1098b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLBracketLoc(SourceLocation Loc) {
109934a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LBracketLoc = Loc;
1100b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1101b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1102b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRBracketLoc() const {
110334a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RBracketLoc;
1104b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRBracketLoc(SourceLocation Loc) {
110634a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RBracketLoc = Loc;
1107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
110985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  SourceRange getBracketsRange() const {
111085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall    return SourceRange(getLBracketLoc(), getRBracketLoc());
111185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  }
111285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall
1113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  Expr *getSizeExpr() const {
111434a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->Size;
1115b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1116b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setSizeExpr(Expr *Size) {
111734a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->Size = Size;
1118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1119b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1120b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getElementLoc() const {
112134a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1122b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1123b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1124bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1125b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLBracketLoc(), getRBracketLoc());
1126b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1127b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
11284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
11294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLBracketLoc(Loc);
11304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRBracketLoc(Loc);
11314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setSizeExpr(NULL);
11324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
11334ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
113434a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getElementType(); }
1135b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1136b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
113751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc :
113851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
113951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayTypeLoc,
114051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayType> {
114151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
114251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
114351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc :
114451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
114551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayTypeLoc,
114651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayType> {
114751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
114851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
114951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc :
115051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
115151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayTypeLoc,
115251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayType> {
115351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
115451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
115551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
115651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc :
115751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
115851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayTypeLoc,
115951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayType> {
116051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
116151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1162833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1163833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName.  Rudimentary for now.
1164833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo {
1165833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation NameLoc;
1166833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1167833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1168833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo {
1169833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation LAngleLoc;
1170833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation RAngleLoc;
1171833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1172833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1173833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc :
1174833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
1175833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationTypeLoc,
1176833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationType,
1177833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationLocInfo> {
1178833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic:
1179833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getLAngleLoc() const {
1180833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->LAngleLoc;
1181833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1182833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setLAngleLoc(SourceLocation Loc) {
1183833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->LAngleLoc = Loc;
1184833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1185833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1186833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getRAngleLoc() const {
1187833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->RAngleLoc;
1188833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1189833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setRAngleLoc(SourceLocation Loc) {
1190833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->RAngleLoc = Loc;
1191833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1192833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1193833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getNumArgs() const {
1194833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getTypePtr()->getNumArgs();
1195833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1196833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
1197833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getArgInfos()[i] = AI;
1198833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1199833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
1200833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getArgInfos()[i];
1201833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1202833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1203833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
1204833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
1205833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1206833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1207833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getTemplateNameLoc() const {
1208833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->NameLoc;
1209833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1210833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setTemplateNameLoc(SourceLocation Loc) {
1211833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->NameLoc = Loc;
1212833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1213833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1214833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief - Copy the location information from the given info.
1215833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void copy(TemplateSpecializationTypeLoc Loc) {
1216833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    unsigned size = getFullDataSize();
1217833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    assert(size == Loc.getFullDataSize());
1218833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1219833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // We're potentially copying Expr references here.  We don't
1220a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall    // bother retaining them because TypeSourceInfos live forever, so
1221833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // as long as the Expr was retained when originally written into
1222833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // the TypeLoc, we're okay.
1223833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    memcpy(Data, Loc.Data, size);
1224833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1225833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1226bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1227833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return SourceRange(getTemplateNameLoc(), getRAngleLoc());
1228833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1229833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1230833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void initializeLocal(SourceLocation Loc) {
1231833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setLAngleLoc(Loc);
1232833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setRAngleLoc(Loc);
1233833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setTemplateNameLoc(Loc);
123433500955d731c73717af52088b7fc0e7a85681e7John McCall    initializeArgLocs(getNumArgs(), getTypePtr()->getArgs(),
123533500955d731c73717af52088b7fc0e7a85681e7John McCall                      getArgInfos(), Loc);
123633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
1237833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
123833500955d731c73717af52088b7fc0e7a85681e7John McCall  static void initializeArgLocs(unsigned NumArgs,
123933500955d731c73717af52088b7fc0e7a85681e7John McCall                                const TemplateArgument *Args,
124033500955d731c73717af52088b7fc0e7a85681e7John McCall                                TemplateArgumentLocInfo *ArgInfos,
124133500955d731c73717af52088b7fc0e7a85681e7John McCall                                SourceLocation Loc) {
1242b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor    for (unsigned i = 0, e = NumArgs; i != e; ++i) {
1243b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor      // FIXME: We can generate better location info here for type arguments,
1244b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor      // template template arguments, and template template pack expansions (?).
12456939fff69a3dfff2552261a1d7f1f609380fe6b0Douglas Gregor      ArgInfos[i] = TemplateArgumentLocInfo();
1246b0ddf3aeb2f119cac42468b029584e8839b354ccDouglas Gregor    }
1247833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1248833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1249833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getExtraLocalDataSize() const {
1250833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1251833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1252833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate:
1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo *getArgInfos() const {
1255833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1256833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1257833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1258833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1259ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
1260ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1261ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//  All of these need proper implementations.
1262ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1263ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
126451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1265ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we
1266ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax).
1267ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1268ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorTypeLoc,
1269ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorType> {
127051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
127151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1272ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations.
127351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
127451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorTypeLoc,
127551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorType> {
127651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
127751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1278ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations.
127951bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType.
128051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc :
1281ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1282ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorTypeLoc,
1283ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorType> {
128451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
128551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1286ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword.
1287ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1288ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexTypeLoc,
1289ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexType> {
129051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
129151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1292cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo {
1293cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation TypeofLoc;
1294cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation LParenLoc;
1295cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation RParenLoc;
129651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
129751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1298cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo {
1299cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1300cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1301cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo {
1302cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* UnderlyingTInfo;
1303cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1304cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1305cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1306cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc
1307cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1308cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1309cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getTypeofLoc() const {
1310cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->TypeofLoc;
1311cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1312cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setTypeofLoc(SourceLocation Loc) {
1313cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->TypeofLoc = Loc;
1314cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1315cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1316cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getLParenLoc() const {
1317cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->LParenLoc;
1318cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1319cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setLParenLoc(SourceLocation Loc) {
1320cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->LParenLoc = Loc;
1321cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1322cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1323cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getRParenLoc() const {
1324cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->RParenLoc;
1325cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1326cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setRParenLoc(SourceLocation Loc) {
1327cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->RParenLoc = Loc;
1328cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1329cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1330cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceRange getParensRange() const {
1331cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getLParenLoc(), getRParenLoc());
1332cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1333cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setParensRange(SourceRange range) {
1334cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setLParenLoc(range.getBegin());
1335cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setRParenLoc(range.getEnd());
1336cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1337cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1338bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1339cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getTypeofLoc(), getRParenLoc());
1340cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1341cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1342cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void initializeLocal(SourceLocation Loc) {
1343cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setTypeofLoc(Loc);
1344cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setLParenLoc(Loc);
1345cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setRParenLoc(Loc);
1346cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1347cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1348cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1349cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
1350cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprType,
1351cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprTypeLocInfo> {
1352cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1353cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  Expr* getUnderlyingExpr() const {
1354cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return getTypePtr()->getUnderlyingExpr();
1355cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1356cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // Reimplemented to account for GNU/C++ extension
1357cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  //     typeof unary-expression
1358cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // where there are no parentheses.
1359bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const;
1360cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1361cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1362cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc
1363cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
1364cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1365cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  QualType getUnderlyingType() const {
1366cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getTypePtr()->getUnderlyingType();
1367cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1368cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* getUnderlyingTInfo() const {
1369cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->UnderlyingTInfo;
1370cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1371cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setUnderlyingTInfo(TypeSourceInfo* TI) const {
1372cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->UnderlyingTInfo = TI;
1373cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
137451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
137551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1376ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens.
1377ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1378ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeTypeLoc,
1379ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeType> {
138051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
138151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1382e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo {
1383e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation KeywordLoc;
1384e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange QualifierRange;
1385e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1386e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1387e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1388e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedTypeLoc,
1389e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedType,
1390e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedLocInfo> {
1391e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
1392e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getKeywordLoc() const {
1393e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->KeywordLoc;
1394e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1395e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setKeywordLoc(SourceLocation Loc) {
1396e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->KeywordLoc = Loc;
1397e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1398e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1399e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange getQualifierRange() const {
1400e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->QualifierRange;
1401e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1402e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setQualifierRange(SourceRange Range) {
1403e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->QualifierRange = Range;
1404e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1405e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1406bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1407e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    if (getKeywordLoc().isValid())
1408e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      if (getQualifierRange().getEnd().isValid())
1409e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara        return SourceRange(getKeywordLoc(), getQualifierRange().getEnd());
1410e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      else
1411e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara        return SourceRange(getKeywordLoc());
1412e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
1413e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return getQualifierRange();
1414e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1415e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1416e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
1417e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setKeywordLoc(Loc);
1418e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setQualifierRange(SourceRange(Loc));
1419e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1420e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1421e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  TypeLoc getNamedTypeLoc() const {
1422e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getInnerTypeLoc();
1423e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1424e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1425e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  QualType getInnerType() const {
1426e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getTypePtr()->getNamedType();
1427e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1428e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1429e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(ElaboratedTypeLoc Loc) {
1430e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1431e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1432e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1433e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
143451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
143551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
143633500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner
143733500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc.
143833500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo {
1439e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation NameLoc;
1440e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1441e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1442e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1443e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameTypeLoc,
1444e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameType,
1445e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameLocInfo> {
1446e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
1447e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getKeywordLoc() const {
1448e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->KeywordLoc;
1449e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1450e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setKeywordLoc(SourceLocation Loc) {
1451e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->KeywordLoc = Loc;
1452e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1453e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1454e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceRange getQualifierRange() const {
1455e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->QualifierRange;
1456e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1457e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setQualifierRange(SourceRange Range) {
1458e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->QualifierRange = Range;
1459e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1460e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1461e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getNameLoc() const {
1462e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->NameLoc;
1463e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1464e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setNameLoc(SourceLocation Loc) {
1465e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->NameLoc = Loc;
1466e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1467e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1468bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1469e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    if (getKeywordLoc().isValid())
1470e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return SourceRange(getKeywordLoc(), getNameLoc());
1471e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
1472e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      return SourceRange(getQualifierRange().getBegin(), getNameLoc());
1473e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1474e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1475e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(DependentNameTypeLoc Loc) {
1476e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1477e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1478e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1479e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1480e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1481e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void initializeLocal(SourceLocation Loc) {
1482e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setKeywordLoc(Loc);
1483e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setQualifierRange(SourceRange(Loc));
1484e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    setNameLoc(Loc);
1485e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
148651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
148751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
148833500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner
148933500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TemplateSpecializationTypeLoc.
149033500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo {
149133500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation LAngleLoc;
149233500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation RAngleLoc;
149333500955d731c73717af52088b7fc0e7a85681e7John McCall  // followed by a TemplateArgumentLocInfo[]
149433500955d731c73717af52088b7fc0e7a85681e7John McCall};
149533500955d731c73717af52088b7fc0e7a85681e7John McCall
149633500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc :
149733500955d731c73717af52088b7fc0e7a85681e7John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
149833500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationTypeLoc,
149933500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationType,
150033500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationLocInfo> {
150133500955d731c73717af52088b7fc0e7a85681e7John McCallpublic:
150233500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getKeywordLoc() const {
150333500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->KeywordLoc;
150433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
150533500955d731c73717af52088b7fc0e7a85681e7John McCall  void setKeywordLoc(SourceLocation Loc) {
150633500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->KeywordLoc = Loc;
150733500955d731c73717af52088b7fc0e7a85681e7John McCall  }
150833500955d731c73717af52088b7fc0e7a85681e7John McCall
150933500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceRange getQualifierRange() const {
151033500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->QualifierRange;
151133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151233500955d731c73717af52088b7fc0e7a85681e7John McCall  void setQualifierRange(SourceRange Range) {
151333500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->QualifierRange = Range;
151433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151533500955d731c73717af52088b7fc0e7a85681e7John McCall
151633500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getNameLoc() const {
151733500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->NameLoc;
151833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
151933500955d731c73717af52088b7fc0e7a85681e7John McCall  void setNameLoc(SourceLocation Loc) {
152033500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->NameLoc = Loc;
152133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152233500955d731c73717af52088b7fc0e7a85681e7John McCall
152333500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getLAngleLoc() const {
152433500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->LAngleLoc;
152533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152633500955d731c73717af52088b7fc0e7a85681e7John McCall  void setLAngleLoc(SourceLocation Loc) {
152733500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->LAngleLoc = Loc;
152833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
152933500955d731c73717af52088b7fc0e7a85681e7John McCall
153033500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getRAngleLoc() const {
153133500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->RAngleLoc;
153233500955d731c73717af52088b7fc0e7a85681e7John McCall  }
153333500955d731c73717af52088b7fc0e7a85681e7John McCall  void setRAngleLoc(SourceLocation Loc) {
153433500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->RAngleLoc = Loc;
153533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
153633500955d731c73717af52088b7fc0e7a85681e7John McCall
153733500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getNumArgs() const {
153833500955d731c73717af52088b7fc0e7a85681e7John McCall    return getTypePtr()->getNumArgs();
153933500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154033500955d731c73717af52088b7fc0e7a85681e7John McCall
154133500955d731c73717af52088b7fc0e7a85681e7John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
154233500955d731c73717af52088b7fc0e7a85681e7John McCall    getArgInfos()[i] = AI;
154333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154433500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
154533500955d731c73717af52088b7fc0e7a85681e7John McCall    return getArgInfos()[i];
154633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
154733500955d731c73717af52088b7fc0e7a85681e7John McCall
154833500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
154933500955d731c73717af52088b7fc0e7a85681e7John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
155033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
155133500955d731c73717af52088b7fc0e7a85681e7John McCall
155233500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceRange getLocalSourceRange() const {
155333500955d731c73717af52088b7fc0e7a85681e7John McCall    if (getKeywordLoc().isValid())
155433500955d731c73717af52088b7fc0e7a85681e7John McCall      return SourceRange(getKeywordLoc(), getRAngleLoc());
155533500955d731c73717af52088b7fc0e7a85681e7John McCall    else
155633500955d731c73717af52088b7fc0e7a85681e7John McCall      return SourceRange(getQualifierRange().getBegin(), getRAngleLoc());
155733500955d731c73717af52088b7fc0e7a85681e7John McCall  }
155833500955d731c73717af52088b7fc0e7a85681e7John McCall
155933500955d731c73717af52088b7fc0e7a85681e7John McCall  void copy(DependentTemplateSpecializationTypeLoc Loc) {
156033500955d731c73717af52088b7fc0e7a85681e7John McCall    unsigned size = getFullDataSize();
156133500955d731c73717af52088b7fc0e7a85681e7John McCall    assert(size == Loc.getFullDataSize());
156233500955d731c73717af52088b7fc0e7a85681e7John McCall    memcpy(Data, Loc.Data, size);
156333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
156433500955d731c73717af52088b7fc0e7a85681e7John McCall
156533500955d731c73717af52088b7fc0e7a85681e7John McCall  void initializeLocal(SourceLocation Loc) {
156633500955d731c73717af52088b7fc0e7a85681e7John McCall    setKeywordLoc(Loc);
156733500955d731c73717af52088b7fc0e7a85681e7John McCall    setQualifierRange(SourceRange(Loc));
156833500955d731c73717af52088b7fc0e7a85681e7John McCall    setNameLoc(Loc);
156933500955d731c73717af52088b7fc0e7a85681e7John McCall    setLAngleLoc(Loc);
157033500955d731c73717af52088b7fc0e7a85681e7John McCall    setRAngleLoc(Loc);
157133500955d731c73717af52088b7fc0e7a85681e7John McCall    TemplateSpecializationTypeLoc::initializeArgLocs(getNumArgs(),
157233500955d731c73717af52088b7fc0e7a85681e7John McCall                                                     getTypePtr()->getArgs(),
157333500955d731c73717af52088b7fc0e7a85681e7John McCall                                                     getArgInfos(), Loc);
157433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
157533500955d731c73717af52088b7fc0e7a85681e7John McCall
157633500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getExtraLocalDataSize() const {
157733500955d731c73717af52088b7fc0e7a85681e7John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
157833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
157933500955d731c73717af52088b7fc0e7a85681e7John McCall
158033500955d731c73717af52088b7fc0e7a85681e7John McCallprivate:
158133500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo *getArgInfos() const {
158233500955d731c73717af52088b7fc0e7a85681e7John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
158333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
158433500955d731c73717af52088b7fc0e7a85681e7John McCall};
158533500955d731c73717af52088b7fc0e7a85681e7John McCall
15867536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
15877536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo {
15887536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation EllipsisLoc;
15897536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
15907536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
15917536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc
15927536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
15937536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor                           PackExpansionType, PackExpansionTypeLocInfo> {
15947536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic:
15957536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation getEllipsisLoc() const {
15967536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getLocalData()->EllipsisLoc;
15977536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
15987536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
15997536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  void setEllipsisLoc(SourceLocation Loc) {
16007536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    this->getLocalData()->EllipsisLoc = Loc;
16017536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16027536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16037536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceRange getLocalSourceRange() const {
16047536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return SourceRange(getEllipsisLoc(), getEllipsisLoc());
16057536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16067536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16077536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  void initializeLocal(SourceLocation Loc) {
16087536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    setEllipsisLoc(Loc);
16097536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16107536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16117536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  TypeLoc getPatternLoc() const {
16127536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return getInnerTypeLoc();
16137536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16147536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
16157536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  QualType getInnerType() const {
16167536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getTypePtr()->getPattern();
16177536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
16187536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
16197536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
1620b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}
1621b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1622b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif
1623