TypeLoc.h revision 1de6a6cb485fb58b4fb100282bb3cf298eedacd9
1b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===--- TypeLoc.h - Type Source Info Wrapper -------------------*- C++ -*-===//
2b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
3b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//                     The LLVM Compiler Infrastructure
4b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
5b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// This file is distributed under the University of Illinois Open Source
6b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis// License. See LICENSE.TXT for details.
7b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
8b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===//
9b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
10b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//  This file defines the TypeLoc interface and subclasses.
11b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//
12b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis//===----------------------------------------------------------------------===//
13b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
14b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#ifndef LLVM_CLANG_AST_TYPELOC_H
15b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#define LLVM_CLANG_AST_TYPELOC_H
16b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
17b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#include "clang/AST/Type.h"
183c385c28cf1f27b193a620d2e51f814873362cebJohn McCall#include "clang/AST/Decl.h"
19833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h"
20ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor#include "clang/Basic/Specifiers.h"
21aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h"
22b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
23b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang {
24c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  class ASTContext;
25b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  class ParmVarDecl;
26a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall  class TypeSourceInfo;
2734a0447b8072e0da14c0980597da9d03a1495662John McCall  class UnqualTypeLoc;
28b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes.
3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base)
3151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \
3251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  class Class##TypeLoc;
3351bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def"
3451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info.
36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis///
37b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to
38b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information.
39b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc {
40b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected:
4134a0447b8072e0da14c0980597da9d03a1495662John McCall  // The correctness of this relies on the property that, for Type *Ty,
4234a0447b8072e0da14c0980597da9d03a1495662John McCall  //   QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
43f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const void *Ty;
44b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void *Data;
451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
46b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// The kinds of TypeLocs.  Equivalent to the Type::TypeClass enum,
4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// except it also defines a Qualified enum that corresponds to the
4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// QualifiedLoc class.
5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  enum TypeLocClass {
5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base)
5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \
5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Class = Type::Class,
5451bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def"
5551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Qualified
5651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  };
5751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
5834a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc() : Ty(0), Data(0) { }
5934a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc(QualType ty, void *opaqueData)
6034a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { }
61f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  TypeLoc(const Type *ty, void *opaqueData)
6234a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty), Data(opaqueData) { }
63b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
6451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
65a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    if (getType().hasLocalQualifiers()) return Qualified;
6651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getType()->getTypeClass();
6751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
6851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
6934a0447b8072e0da14c0980597da9d03a1495662John McCall  bool isNull() const { return !Ty; }
7034a0447b8072e0da14c0980597da9d03a1495662John McCall  operator bool() const { return Ty; }
71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of type source info data block for the given type.
73b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static unsigned getFullDataSizeForType(QualType Ty);
74b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
75b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the type for which this source info wrapper provides
76b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// information.
7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getType() const {
7851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return QualType::getFromOpaquePtr(Ty);
7951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
8034a0447b8072e0da14c0980597da9d03a1495662John McCall
81f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const Type *getTypePtr() const {
8234a0447b8072e0da14c0980597da9d03a1495662John McCall    return QualType::getFromOpaquePtr(Ty).getTypePtr();
8334a0447b8072e0da14c0980597da9d03a1495662John McCall  }
84b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
85b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis  /// \brief Get the pointer where source information is stored.
8651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void *getOpaqueData() const {
8751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Data;
8851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
89b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
90e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  /// \brief Get the begin source location.
91e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  SourceLocation getBeginLoc() const;
92e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara
93e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  /// \brief Get the end source location.
94e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara  SourceLocation getEndLoc() const;
95e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara
96833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the full source range.
97aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceRange getSourceRange() const LLVM_READONLY {
98e4aec0eae303e926643c7239cf7b0197ea9f63e2Abramo Bagnara    return SourceRange(getBeginLoc(), getEndLoc());
99833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
100aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
101aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
102833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
103833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the local source range.
104bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
105bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara    return getLocalSourceRangeImpl(*this);
10651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block.
10934a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
11051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getFullDataSizeForType(getType());
11134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
112b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
11551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLoc getNextTypeLoc() const {
11651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getNextTypeLocImpl(*this);
11751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
11934a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Skips past any qualifiers, if this is qualified.
12051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
12134a0447b8072e0da14c0980597da9d03a1495662John McCall
122723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  TypeLoc IgnoreParens() const {
123723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara    if (isa<ParenTypeLoc>(this))
124723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara      return IgnoreParensImpl(*this);
125723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara    return *this;
126723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  }
127140a2bd77539b4537010d8cd6a0a3805ce724b3eAbramo Bagnara
1284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// \brief Initializes this to state that every location in this
1294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// type is the given location.
1304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  ///
1314ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// This method exists to provide a simple transition for code that
1324ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// relies on location-less types.
133c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initialize(ASTContext &Context, SourceLocation Loc) const {
134c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor    initializeImpl(Context, *this, Loc);
1354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
1364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
13745ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  /// \brief Initializes this by copying its information from another
13845ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  /// TypeLoc of the same type.
13945ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  void initializeFullCopy(TypeLoc Other) const {
140711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getType() == Other.getType());
141711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    size_t Size = getFullDataSize();
142711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
143711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  }
144711c52bb20d0c69063b52a99826fb7d2835501f1John McCall
145711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// \brief Initializes this by copying its information from another
146711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// TypeLoc of the same type.  The given size must be the full data
147711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  /// size.
148711c52bb20d0c69063b52a99826fb7d2835501f1John McCall  void initializeFullCopy(TypeLoc Other, unsigned Size) const {
149711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getType() == Other.getType());
150711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    assert(getFullDataSize() == Size);
151711c52bb20d0c69063b52a99826fb7d2835501f1John McCall    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
15245ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein  }
15345ab4b5f8961dadcef6545ed6956da5daf95c6cbCraig Silverstein
154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
155b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
156b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
157b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
158b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) {
159b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return !(LHS == RHS);
160b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
161b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
162b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static bool classof(const TypeLoc *TL) { return true; }
1634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate:
165ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  static void initializeImpl(ASTContext &Context, TypeLoc TL,
166ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                             SourceLocation Loc);
16751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static TypeLoc getNextTypeLocImpl(TypeLoc TL);
168723df245307a530da5433dfb43accf187dc3e243Abramo Bagnara  static TypeLoc IgnoreParensImpl(TypeLoc TL);
169bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
170b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
171b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1723c385c28cf1f27b193a620d2e51f814873362cebJohn McCall/// \brief Return the TypeLoc for a type source info.
1733c385c28cf1f27b193a620d2e51f814873362cebJohn McCallinline TypeLoc TypeSourceInfo::getTypeLoc() const {
1744ab92891a53adda8c52c1947351371da58e33f64Gabor Greif  return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
1753c385c28cf1f27b193a620d2e51f814873362cebJohn McCall}
1763c385c28cf1f27b193a620d2e51f814873362cebJohn McCall
17734a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
178489f7131d0f7746525de3b26204c8eb523d84505Gabor Greif/// no direct qualifiers.
17934a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc {
18034a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
18134a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc() {}
182f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
18334a0447b8072e0da14c0980597da9d03a1495662John McCall
184f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const Type *getTypePtr() const {
185f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall    return reinterpret_cast<const Type*>(Ty);
18634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
18734a0447b8072e0da14c0980597da9d03a1495662John McCall
18851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
18951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getTypePtr()->getTypeClass();
19051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
19151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
19234a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
193a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return !TL->getType().hasLocalQualifiers();
19434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
19534a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const UnqualTypeLoc *TL) { return true; }
19634a0447b8072e0da14c0980597da9d03a1495662John McCall};
19734a0447b8072e0da14c0980597da9d03a1495662John McCall
19834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
19934a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers.
20034a0447b8072e0da14c0980597da9d03a1495662John McCall///
20134a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for
20234a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers.
20351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc {
20434a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
205bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
20634a0447b8072e0da14c0980597da9d03a1495662John McCall    return SourceRange();
20734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
20834a0447b8072e0da14c0980597da9d03a1495662John McCall
20934a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc getUnqualifiedLoc() const {
21051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return UnqualTypeLoc(getTypePtr(), Data);
21134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
21234a0447b8072e0da14c0980597da9d03a1495662John McCall
2134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// Initializes the local data of this type source info block to
2144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// provide no information.
215c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
2164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    // do nothing
2174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
2184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
2194ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
2204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getUnqualifiedLoc();
2214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
2224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
22334a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block that is
22434a0447b8072e0da14c0980597da9d03a1495662John McCall  /// specific to this type.
22534a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
22634a0447b8072e0da14c0980597da9d03a1495662John McCall    // In fact, we don't currently preserve any location information
22734a0447b8072e0da14c0980597da9d03a1495662John McCall    // for qualifiers.
22834a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
22934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
23034a0447b8072e0da14c0980597da9d03a1495662John McCall
23134a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block.
23234a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
233ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return getLocalDataSize() +
234fa1a06e80706846fa15e0bd44671bdc3dfc53d84Douglas Gregor      getFullDataSizeForType(getType().getLocalUnqualifiedType());
23534a0447b8072e0da14c0980597da9d03a1495662John McCall  }
23634a0447b8072e0da14c0980597da9d03a1495662John McCall
23734a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
238a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return TL->getType().hasLocalQualifiers();
23934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
24051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const QualifiedTypeLoc *TL) { return true; }
24134a0447b8072e0da14c0980597da9d03a1495662John McCall};
24234a0447b8072e0da14c0980597da9d03a1495662John McCall
24334a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const {
24451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  if (isa<QualifiedTypeLoc>(this))
24551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc();
24634a0447b8072e0da14c0980597da9d03a1495662John McCall  return cast<UnqualTypeLoc>(*this);
24734a0447b8072e0da14c0980597da9d03a1495662John McCall}
24834a0447b8072e0da14c0980597da9d03a1495662John McCall
24934a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond
250f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass.  It is accepted for a single
251f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes.
25234a0447b8072e0da14c0980597da9d03a1495662John McCall///
25334a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Base a class from which to derive
25434a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Derived the class deriving from this one
255f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// \param TypeClass the concrete Type subclass associated with this
256f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall///   location type
25734a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param LocalData the structure type of local location data for
25834a0447b8072e0da14c0980597da9d03a1495662John McCall///   this type
25934a0447b8072e0da14c0980597da9d03a1495662John McCall///
26034a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or
26134a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end.
26234a0447b8072e0da14c0980597da9d03a1495662John McCall///
26334a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override
26434a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to
26534a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory.
26634a0447b8072e0da14c0980597da9d03a1495662John McCall///
267a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define
268a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall///   QualType getInnerType() const
269a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's
270a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data.
27151bd803fbdade51d674598ed45da3d54190a656cJohn McCall///
27251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be
27351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy.  It is also not
27451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide
27551bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information.  It should be subclassed
27651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children
27751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type,
27851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from
27951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead.
28034a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData>
28134a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base {
28234a0447b8072e0da14c0980597da9d03a1495662John McCall
28334a0447b8072e0da14c0980597da9d03a1495662John McCall  const Derived *asDerived() const {
28434a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<const Derived*>(this);
28534a0447b8072e0da14c0980597da9d03a1495662John McCall  }
28634a0447b8072e0da14c0980597da9d03a1495662John McCall
28734a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
28834a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
28934a0447b8072e0da14c0980597da9d03a1495662John McCall    return sizeof(LocalData) + asDerived()->getExtraLocalDataSize();
29034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29134a0447b8072e0da14c0980597da9d03a1495662John McCall  // Give a default implementation that's useful for leaf types.
29234a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
29334a0447b8072e0da14c0980597da9d03a1495662John McCall    return asDerived()->getLocalDataSize() + getInnerTypeSize();
29434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29534a0447b8072e0da14c0980597da9d03a1495662John McCall
29634a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classofType(const Type *Ty) {
29734a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeClass::classof(Ty);
29834a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29934a0447b8072e0da14c0980597da9d03a1495662John McCall
300e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const TypeLoc *TL) {
301e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return Derived::classofType(TL->getTypePtr());
302e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
303e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const UnqualTypeLoc *TL) {
304e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return Derived::classofType(TL->getTypePtr());
305e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
306e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  static bool classof(const Derived *TL) {
307e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return true;
308e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
309e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
3104ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
3114ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getNextTypeLoc(asDerived()->getInnerType());
3124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
3134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
314f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const TypeClass *getTypePtr() const {
31551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
31634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
31734a0447b8072e0da14c0980597da9d03a1495662John McCall
31851bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected:
31934a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
32034a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
32134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
32234a0447b8072e0da14c0980597da9d03a1495662John McCall
32334a0447b8072e0da14c0980597da9d03a1495662John McCall  LocalData *getLocalData() const {
32434a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<LocalData*>(Base::Data);
32534a0447b8072e0da14c0980597da9d03a1495662John McCall  }
32634a0447b8072e0da14c0980597da9d03a1495662John McCall
32734a0447b8072e0da14c0980597da9d03a1495662John McCall  /// Gets a pointer past the Info structure; useful for classes with
32834a0447b8072e0da14c0980597da9d03a1495662John McCall  /// local data that can't be captured in the Info (e.g. because it's
32934a0447b8072e0da14c0980597da9d03a1495662John McCall  /// of variable size).
33034a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getExtraLocalData() const {
33134a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData() + 1;
33234a0447b8072e0da14c0980597da9d03a1495662John McCall  }
333ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
33434a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getNonLocalData() const {
33534a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize();
33634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
33734a0447b8072e0da14c0980597da9d03a1495662John McCall
338a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  struct HasNoInnerType {};
339a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  HasNoInnerType getInnerType() const { return HasNoInnerType(); }
34034a0447b8072e0da14c0980597da9d03a1495662John McCall
34134a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc getInnerTypeLoc() const {
34234a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
34334a0447b8072e0da14c0980597da9d03a1495662John McCall  }
34434a0447b8072e0da14c0980597da9d03a1495662John McCall
34534a0447b8072e0da14c0980597da9d03a1495662John McCallprivate:
34634a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getInnerTypeSize() const {
347a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeSize(asDerived()->getInnerType());
348a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  }
349a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall
350a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(HasNoInnerType _) const {
35134a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
35234a0447b8072e0da14c0980597da9d03a1495662John McCall  }
35334a0447b8072e0da14c0980597da9d03a1495662John McCall
354a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(QualType _) const {
355a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeLoc().getFullDataSize();
35634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
3574ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(HasNoInnerType _) const {
3594ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc();
3604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
3614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(QualType T) const {
3634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc(T, getNonLocalData());
3644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
36534a0447b8072e0da14c0980597da9d03a1495662John McCall};
36634a0447b8072e0da14c0980597da9d03a1495662John McCall
36751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract
36851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source
36951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information.  See the note on ConcreteTypeLoc.
37051bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass>
37151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base {
372b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
373713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor  static bool classofType(const Type *Ty) {
374713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor    return TypeClass::classof(Ty);
375713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor  }
376713da40fb093cb6ab50ddc57e1697fddf9802104Douglas Gregor
37751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const TypeLoc *TL) {
37851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
379b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
38051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const UnqualTypeLoc *TL) {
38151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
382b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
38351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const Derived *TL) {
38451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return true;
385b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
386b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
387f4c7371fb1d3cebcfb40abad4537bb82515704eaJohn McCall  const TypeClass *getTypePtr() const {
38851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
3894ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
39034a0447b8072e0da14c0980597da9d03a1495662John McCall};
391b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
392ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
39351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo {
39434a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation NameLoc;
395b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
396b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
39751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to
39851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier.
399ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikieclass TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
400ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               TypeSpecTypeLoc,
401ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               Type,
402ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                               TypeSpecLocInfo> {
403b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
404ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  enum { LocalDataSize = sizeof(TypeSpecLocInfo) };
405ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
406b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getNameLoc() const {
40751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->NameLoc;
408b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
409b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setNameLoc(SourceLocation Loc) {
41051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->NameLoc = Loc;
411b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
412bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
413b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getNameLoc(), getNameLoc());
414b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
415c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
4164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setNameLoc(Loc);
4174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
418ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
419ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  static bool classof(const TypeLoc *TL);
420ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  static bool classof(const TypeSpecTypeLoc *TL) { return true; }
42151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
4224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
423ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
424ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorstruct BuiltinLocInfo {
425ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation BuiltinLoc;
426ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor};
427ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
428ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor/// \brief Wrapper for source info for builtin types.
429ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorclass BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
430ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinTypeLoc,
431ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinType,
432ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor                                              BuiltinLocInfo> {
433ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregorpublic:
434ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  enum { LocalDataSize = sizeof(BuiltinLocInfo) };
435ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
436ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation getBuiltinLoc() const {
437ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getLocalData()->BuiltinLoc;
438ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
439ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setBuiltinLoc(SourceLocation Loc) {
440ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    getLocalData()->BuiltinLoc = Loc;
441ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
442ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
443ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  SourceLocation getNameLoc() const { return getBuiltinLoc(); }
444ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
445ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  WrittenBuiltinSpecs& getWrittenBuiltinSpecs() {
446ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
447ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
448ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const {
449ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
450ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
451ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
452ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool needsExtraLocalData() const {
453ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    BuiltinType::Kind bk = getTypePtr()->getKind();
454ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128)
455d038f361d2b4368af7ab85bd04d5aafcc3ea649dDouglas Gregor      || (bk >= BuiltinType::Short && bk <= BuiltinType::LongDouble)
456ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      || bk == BuiltinType::UChar
457ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      || bk == BuiltinType::SChar;
458ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
459ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
460ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  unsigned getExtraLocalDataSize() const {
461d31351288e25e8a7a2a919c99ffe281c2a41b53cDaniel Dunbar    return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
462ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
463ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
464bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
465ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return SourceRange(getBuiltinLoc(), getBuiltinLoc());
466ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
467ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
468ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierSign getWrittenSignSpec() const {
469ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
470ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign);
471ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
472ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return TSS_unspecified;
473ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
474ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenSignSpec() const {
475ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenSignSpec() != TSS_unspecified;
476ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
477ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenSignSpec(TypeSpecifierSign written) {
478ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
479ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Sign = written;
480ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
481ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
482ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierWidth getWrittenWidthSpec() const {
483ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
484ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width);
485ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
486ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return TSW_unspecified;
487ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
488ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenWidthSpec() const {
489ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenWidthSpec() != TSW_unspecified;
490ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
491ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenWidthSpec(TypeSpecifierWidth written) {
492ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
493ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Width = written;
494ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
495ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
496ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  TypeSpecifierType getWrittenTypeSpec() const;
497ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasWrittenTypeSpec() const {
498ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    return getWrittenTypeSpec() != TST_unspecified;
499ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
500ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setWrittenTypeSpec(TypeSpecifierType written) {
501ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
502ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().Type = written;
503ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
504ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
505ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  bool hasModeAttr() const {
506ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
507ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return getWrittenBuiltinSpecs().ModeAttr;
508ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    else
509ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      return false;
510ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
511ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  void setModeAttr(bool written) {
512ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData())
513ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      getWrittenBuiltinSpecs().ModeAttr = written;
514ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
515ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
516c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
517ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    setBuiltinLoc(Loc);
518ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    if (needsExtraLocalData()) {
519ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs();
520ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Sign = TSS_unspecified;
521ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Width = TSW_unspecified;
522ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.Type = TST_unspecified;
523ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor      wbs.ModeAttr = false;
524ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor    }
525ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor  }
526ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor};
527ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
528ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor
52951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs.
530ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
531ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        TypedefTypeLoc,
532ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        TypedefType> {
53351bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
534162e1c1b487352434552147967c3dd296ebee2f7Richard Smith  TypedefNameDecl *getTypedefNameDecl() const {
53534a0447b8072e0da14c0980597da9d03a1495662John McCall    return getTypePtr()->getDecl();
5369036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis  }
53734a0447b8072e0da14c0980597da9d03a1495662John McCall};
5389036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis
5393cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// \brief Wrapper for source info for injected class names of class
5403cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall/// templates.
5413cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallclass InjectedClassNameTypeLoc :
5423cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
5433cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall                                     InjectedClassNameTypeLoc,
5443cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall                                     InjectedClassNameType> {
545427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic:
546427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis  CXXRecordDecl *getDecl() const {
547427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis    return getTypePtr()->getDecl();
548427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis  }
5493cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall};
5503cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall
551ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for unresolved typename using decls.
552ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass UnresolvedUsingTypeLoc :
553ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
554ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     UnresolvedUsingTypeLoc,
555ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     UnresolvedUsingType> {
556ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
557ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  UnresolvedUsingTypenameDecl *getDecl() const {
558ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    return getTypePtr()->getDecl();
559ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  }
560ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
561ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
562ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for tag types.  Note that this only
563ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// records source info for the name itself; a type written 'struct foo'
564ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// should be represented as an ElaboratedTypeLoc.  We currently
565ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// only do that when C++ is enabled because of the expense of
566ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// creating an ElaboratedType node for so many type references in C.
567ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
568ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                    TagTypeLoc,
569ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                    TagType> {
570ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
571ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
5726f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis
573ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  /// \brief True if the tag was defined in this type specifier.
5746f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis  bool isDefinition() const {
575a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis    TagDecl *D = getDecl();
576a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis    return D->isCompleteDefinition() &&
577a346efaaad5cd779cdfd5be73c2b258748ad1f06Argyrios Kyrtzidis         (D->getIdentifier() == 0 || D->getLocation() == getNameLoc());
5786f155de99c59af890817146ec8526bafb6560f1fArgyrios Kyrtzidis  }
579ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
580ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
581ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for record types.
582ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
583ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       RecordTypeLoc,
584ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       RecordType> {
585ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
586ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
587ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
588ed97649e9574b9d854fa4d6109c9333ae0993554John McCall
589ed97649e9574b9d854fa4d6109c9333ae0993554John McCall/// \brief Wrapper for source info for enum types.
590ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
591ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                     EnumTypeLoc,
592ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                     EnumType> {
593ed97649e9574b9d854fa4d6109c9333ae0993554John McCallpublic:
594ed97649e9574b9d854fa4d6109c9333ae0993554John McCall  EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
595ed97649e9574b9d854fa4d6109c9333ae0993554John McCall};
596b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
59749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters.
598ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass TemplateTypeParmTypeLoc :
599ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
600ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     TemplateTypeParmTypeLoc,
601ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     TemplateTypeParmType> {
602960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruthpublic:
603960d13dde337a59dacc9dc3936c26d4aa8478986Chandler Carruth  TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); }
60449a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
60549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall
60649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters.
60749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc :
608ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
609ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     SubstTemplateTypeParmTypeLoc,
610ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     SubstTemplateTypeParmType> {
61149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
61251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
613c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor  /// \brief Wrapper for substituted template type parameters.
614c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregorclass SubstTemplateTypeParmPackTypeLoc :
615c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
616c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor                                     SubstTemplateTypeParmPackTypeLoc,
617c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor                                     SubstTemplateTypeParmPackType> {
618c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor};
619c3069d618f4661d923cb1b5c4525b082fce73b04Douglas Gregor
6209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallstruct AttributedLocInfo {
6219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  union {
6229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    Expr *ExprOperand;
6239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    /// A raw SourceLocation.
6259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    unsigned EnumOperandLoc;
6269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  };
6279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6289d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange OperandParens;
6299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation AttrLoc;
6319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
6329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall/// \brief Type source information for an attributed type.
6349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallclass AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
6359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedTypeLoc,
6369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedType,
6379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall                                                 AttributedLocInfo> {
6389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallpublic:
6399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  AttributedType::Kind getAttrKind() const {
6409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getAttrKind();
6419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrExprOperand() const {
6449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstExprOperandKind &&
6459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastExprOperandKind);
6469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrEnumOperand() const {
6499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return (getAttrKind() >= AttributedType::FirstEnumOperandKind &&
6509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall            getAttrKind() <= AttributedType::LastEnumOperandKind);
6519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  bool hasAttrOperand() const {
6549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return hasAttrExprOperand() || hasAttrEnumOperand();
6559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The modified type, which is generally canonically different from
6589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// the attribute type.
6599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    int main(int, char**) __attribute__((noreturn))
6609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    ~~~     ~~~~~~~~~~~~~
6619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  TypeLoc getModifiedLoc() const {
6629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getInnerTypeLoc();
6639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute name, i.e.
6669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    __attribute__((regparm(1000)))
6679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                   ^~~~~~~
6689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrNameLoc() const {
6699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->AttrLoc;
6709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrNameLoc(SourceLocation loc) {
6729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->AttrLoc = loc;
6739d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6749d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6759d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The attribute's expression operand, if it has one.
6769d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void *cur_thread __attribute__((address_space(21)))
6779d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                                  ^~
6789d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  Expr *getAttrExprOperand() const {
6799d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6809d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->ExprOperand;
6819d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6829d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrExprOperand(Expr *e) {
6839d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrExprOperand());
6849d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->ExprOperand = e;
6859d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6869d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6879d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the attribute's enumerated operand, if it has one.
6889d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
6899d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                  ^~~~
6909d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceLocation getAttrEnumOperandLoc() const {
6919d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6929d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return SourceLocation::getFromRawEncoding(getLocalData()->EnumOperandLoc);
6939d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6949d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrEnumOperandLoc(SourceLocation loc) {
6959d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrEnumOperand());
6969d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->EnumOperandLoc = loc.getRawEncoding();
6979d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
6989d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
6999d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// The location of the parentheses around the operand, if there is
7009d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  /// an operand.
7019d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///    void * __attribute__((objc_gc(weak)))
7029d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  ///                                 ^    ^
7039d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getAttrOperandParensRange() const {
7049d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
7059d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getLocalData()->OperandParens;
7069d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7079d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  void setAttrOperandParensRange(SourceRange range) {
7089d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    assert(hasAttrOperand());
7099d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    getLocalData()->OperandParens = range;
7109d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7119d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7129d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  SourceRange getLocalSourceRange() const {
7139d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // Note that this does *not* include the range of the attribute
7149d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // enclosure, e.g.:
7159d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    __attribute__((foo(bar)))
7169d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~~~~~~~~~~~~~~        ~~
7179d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // or
7189d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    [[foo(bar)]]
7199d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    //    ^~        ~~
7209d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // That enclosure doesn't necessarily belong to a single attribute
7219d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    // anyway.
7229d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    SourceRange range(getAttrNameLoc());
7239d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrOperand())
7249d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      range.setEnd(getAttrOperandParensRange().getEnd());
7259d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return range;
7269d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7279d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
728c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation loc) {
7299d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    setAttrNameLoc(loc);
7309d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    if (hasAttrExprOperand()) {
7319d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7329d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrExprOperand(0);
7339d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    } else if (hasAttrEnumOperand()) {
7349d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrOperandParensRange(SourceRange(loc));
7359d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall      setAttrEnumOperandLoc(loc);
7369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    }
7379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
7399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  QualType getInnerType() const {
7409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall    return getTypePtr()->getModifiedType();
7419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall  }
7429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall};
7439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall
744eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
74534a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo {
74654e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation LAngleLoc;
74754e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation RAngleLoc;
748ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall  bool HasBaseTypeAsWritten;
749eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis};
750eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
75154e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with
75254e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols.
75354e14c4db764c0636160d26c5bbf491637c83a76John McCall//
75454e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or
75554e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType.
756c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
757c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectTypeLoc,
758c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCObjectType,
759c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                 ObjCProtocolListLocInfo> {
760f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  // SourceLocations are stored after Info, one for each Protocol.
761f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation *getProtocolLocArray() const {
76254e14c4db764c0636160d26c5bbf491637c83a76John McCall    return (SourceLocation*) this->getExtraLocalData();
76354e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
76454e14c4db764c0636160d26c5bbf491637c83a76John McCall
765f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic:
766f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getLAngleLoc() const {
76754e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->LAngleLoc;
768f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
769f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setLAngleLoc(SourceLocation Loc) {
77054e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->LAngleLoc = Loc;
771f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
772f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
773f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getRAngleLoc() const {
77454e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->RAngleLoc;
775f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
776f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setRAngleLoc(SourceLocation Loc) {
77754e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->RAngleLoc = Loc;
778f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
779f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
780f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  unsigned getNumProtocols() const {
78154e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getTypePtr()->getNumProtocols();
782f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
783f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
784f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getProtocolLoc(unsigned i) const {
785f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
786f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return getProtocolLocArray()[i];
787f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
788f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setProtocolLoc(unsigned i, SourceLocation Loc) {
789f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
790f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    getProtocolLocArray()[i] = Loc;
791f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
792f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
793f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  ObjCProtocolDecl *getProtocol(unsigned i) const {
794f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
79554e14c4db764c0636160d26c5bbf491637c83a76John McCall    return *(this->getTypePtr()->qual_begin() + i);
796f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
797ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
798c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  bool hasBaseTypeAsWritten() const {
799ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    return getLocalData()->HasBaseTypeAsWritten;
800c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
801c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
802c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setHasBaseTypeAsWritten(bool HasBaseType) {
803ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    getLocalData()->HasBaseTypeAsWritten = HasBaseType;
804c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
805c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
806c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  TypeLoc getBaseLoc() const {
807c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getInnerTypeLoc();
808c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
809c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
810bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
811f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return SourceRange(getLAngleLoc(), getRAngleLoc());
812f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
813f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
814c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
815ca6773808f8e75ffa86847e9d12885c69e9de53eJohn McCall    setHasBaseTypeAsWritten(true);
816c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setLAngleLoc(Loc);
817c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setRAngleLoc(Loc);
818c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
819c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall      setProtocolLoc(i, Loc);
8204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
8214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
82234a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
82354e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getNumProtocols() * sizeof(SourceLocation);
82454e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
825c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
826c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  QualType getInnerType() const {
827c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getTypePtr()->getBaseType();
828c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
82954e14c4db764c0636160d26c5bbf491637c83a76John McCall};
83054e14c4db764c0636160d26c5bbf491637c83a76John McCall
83154e14c4db764c0636160d26c5bbf491637c83a76John McCall
832c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallstruct ObjCInterfaceLocInfo {
83354e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation NameLoc;
8341de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian  SourceLocation NameEndLoc;
83554e14c4db764c0636160d26c5bbf491637c83a76John McCall};
83654e14c4db764c0636160d26c5bbf491637c83a76John McCall
83754e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces.
838a8bef693d8761e31845a26e136f8d3a0983d2f46Nick Lewyckyclass ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
839c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceTypeLoc,
840c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceType,
841c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                                                    ObjCInterfaceLocInfo> {
84254e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
84354e14c4db764c0636160d26c5bbf491637c83a76John McCall  ObjCInterfaceDecl *getIFaceDecl() const {
84454e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getDecl();
84554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
84654e14c4db764c0636160d26c5bbf491637c83a76John McCall
84754e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation getNameLoc() const {
84854e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->NameLoc;
84954e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
85054e14c4db764c0636160d26c5bbf491637c83a76John McCall
85154e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setNameLoc(SourceLocation Loc) {
85254e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->NameLoc = Loc;
85354e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
8541de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian
855bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
8561de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian    return SourceRange(getNameLoc(), getNameEndLoc());
8571de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian  }
8581de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian
8591de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian  SourceLocation getNameEndLoc() const {
8601de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian    return getLocalData()->NameEndLoc;
8611de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian  }
8621de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian
8631de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian  void setNameEndLoc(SourceLocation Loc) {
8641de6a6cb485fb58b4fb100282bb3cf298eedacd9Fariborz Jahanian    getLocalData()->NameEndLoc = Loc;
86554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
86654e14c4db764c0636160d26c5bbf491637c83a76John McCall
867c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
86854e14c4db764c0636160d26c5bbf491637c83a76John McCall    setNameLoc(Loc);
869f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
87054e14c4db764c0636160d26c5bbf491637c83a76John McCall};
87154e14c4db764c0636160d26c5bbf491637c83a76John McCall
872075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarastruct ParenLocInfo {
873075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation LParenLoc;
874075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation RParenLoc;
875075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
876075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
877075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaraclass ParenTypeLoc
878075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
879075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara                           ParenLocInfo> {
880075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnarapublic:
881075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getLParenLoc() const {
882075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->LParenLoc;
883075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
884075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceLocation getRParenLoc() const {
885075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getLocalData()->RParenLoc;
886075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
887075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setLParenLoc(SourceLocation Loc) {
888075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->LParenLoc = Loc;
889075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
890075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  void setRParenLoc(SourceLocation Loc) {
891075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    this->getLocalData()->RParenLoc = Loc;
892075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
893075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
894075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  SourceRange getLocalSourceRange() const {
895075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return SourceRange(getLParenLoc(), getRParenLoc());
896075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
897075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
898c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
899075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setLParenLoc(Loc);
900075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    setRParenLoc(Loc);
901075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
902075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
903075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  TypeLoc getInnerLoc() const {
904075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return getInnerTypeLoc();
905075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
906075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
907075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  QualType getInnerType() const {
908075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara    return this->getTypePtr()->getInnerType();
909075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara  }
910075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara};
911075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara
912f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
91351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo {
91434a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation StarLoc;
915f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis};
916f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
917ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// A base class for
91851bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
91951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
92051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                  TypeClass, LocalData> {
921ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic:
92251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getSigilLoc() const {
92351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->StarLoc;
924b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
92551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setSigilLoc(SourceLocation Loc) {
92651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->StarLoc = Loc;
927b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
928b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
929b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getPointeeLoc() const {
93051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getInnerTypeLoc();
931b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
932b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
933bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
93451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return SourceRange(getSigilLoc(), getSigilLoc());
935b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
936b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
937c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
93851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9394ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
9404ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
94151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getInnerType() const {
94251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getTypePtr()->getPointeeType();
94351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
94434a0447b8072e0da14c0980597da9d03a1495662John McCall};
945b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
946b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
94751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers.
94851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
94951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 PointerType> {
95051bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
95151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getStarLoc() const {
95251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
95351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
95451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setStarLoc(SourceLocation Loc) {
95551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
95651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
957b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
958b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
95951bd803fbdade51d674598ed45da3d54190a656cJohn McCall
960b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers.
96151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
96251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                      BlockPointerType> {
963b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
964b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getCaretLoc() const {
96551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
966b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
967b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setCaretLoc(SourceLocation Loc) {
96851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
969b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
97034a0447b8072e0da14c0980597da9d03a1495662John McCall};
971b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
972b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnarastruct MemberPointerLocInfo : public PointerLikeLocInfo {
973b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  TypeSourceInfo *ClassTInfo;
974b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara};
975b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
976b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers.
97751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
978b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara                                                       MemberPointerType,
979b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara                                                       MemberPointerLocInfo> {
980b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
981b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getStarLoc() const {
98251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
983b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
984b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setStarLoc(SourceLocation Loc) {
98551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
9864ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
987b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara
988b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  const Type *getClass() const {
989b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    return getTypePtr()->getClass();
990b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  }
991b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  TypeSourceInfo *getClassTInfo() const {
992b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    return getLocalData()->ClassTInfo;
993b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  }
994b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  void setClassTInfo(TypeSourceInfo* TI) {
995b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    getLocalData()->ClassTInfo = TI;
996b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  }
997b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara
998b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
999b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    setSigilLoc(Loc);
1000b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    setClassTInfo(0);
1001b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  }
1002b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara
1003b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  SourceRange getLocalSourceRange() const {
1004b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    if (TypeSourceInfo *TI = getClassTInfo())
1005b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara      return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
1006b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara    else
1007b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara      return SourceRange(getStarLoc());
1008b6ab6c1ca733fda2302a1c5066bdfc6218c89e41Abramo Bagnara  }
100934a0447b8072e0da14c0980597da9d03a1495662John McCall};
1010b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1011c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall/// Wraps an ObjCPointerType with source location information.
1012c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallclass ObjCObjectPointerTypeLoc :
1013c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1014c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall                              ObjCObjectPointerType> {
1015c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallpublic:
1016c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  SourceLocation getStarLoc() const {
1017c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    return getSigilLoc();
1018c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
1019c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
1020c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  void setStarLoc(SourceLocation Loc) {
1021c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall    setSigilLoc(Loc);
1022c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall  }
1023c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall};
1024c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall
1025b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
102651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
102751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                   ReferenceType> {
102854e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
102954e14c4db764c0636160d26c5bbf491637c83a76John McCall  QualType getInnerType() const {
103054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getPointeeTypeAsWritten();
103154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
1032b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1033b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1034bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc :
1035bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1036bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceTypeLoc,
1037bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceType> {
1038b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1039b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getAmpLoc() const {
104051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
1041b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1042b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setAmpLoc(SourceLocation Loc) {
104351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
1044b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
104551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
1046b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1047bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc :
1048bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1049bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceTypeLoc,
1050bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceType> {
105151bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
105251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getAmpAmpLoc() const {
105351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
1054b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
105551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setAmpAmpLoc(SourceLocation Loc) {
105651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
1057b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
105851bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
1059b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1060b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
106134a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo {
1062796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  SourceLocation LocalRangeBegin;
1063796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  SourceLocation LocalRangeEnd;
1064dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool TrailingReturn;
1065b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1066b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1067b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions.
106851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
106951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionTypeLoc,
107051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionType,
107151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionLocInfo> {
1072b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1073796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  SourceLocation getLocalRangeBegin() const {
1074796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    return getLocalData()->LocalRangeBegin;
1075b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1076796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  void setLocalRangeBegin(SourceLocation L) {
1077796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    getLocalData()->LocalRangeBegin = L;
1078b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1079b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1080796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  SourceLocation getLocalRangeEnd() const {
1081796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    return getLocalData()->LocalRangeEnd;
1082b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1083796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara  void setLocalRangeEnd(SourceLocation L) {
1084796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    getLocalData()->LocalRangeEnd = L;
1085b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1086b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1087dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  bool getTrailingReturn() const {
1088dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    return getLocalData()->TrailingReturn;
1089dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1090dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  void setTrailingReturn(bool Trailing) {
1091dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    getLocalData()->TrailingReturn = Trailing;
1092dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  }
1093dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor
1094ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman  ArrayRef<ParmVarDecl *> getParams() const {
1095ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman    return ArrayRef<ParmVarDecl *>(getParmArray(), getNumArgs());
1096ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman  }
1097ec9ea7200718478e8a976529defbe21942a11c9cEli Friedman
1098a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  // ParmVarDecls* are stored after Info, one for each argument.
1099a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  ParmVarDecl **getParmArray() const {
1100a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor    return (ParmVarDecl**) getExtraLocalData();
1101a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor  }
1102a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor
1103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  unsigned getNumArgs() const {
110434a0447b8072e0da14c0980597da9d03a1495662John McCall    if (isa<FunctionNoProtoType>(getTypePtr()))
1105b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis      return 0;
110634a0447b8072e0da14c0980597da9d03a1495662John McCall    return cast<FunctionProtoType>(getTypePtr())->getNumArgs();
1107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; }
1109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1110b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1111b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getResultLoc() const {
111234a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1114b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1115bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1116796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    return SourceRange(getLocalRangeBegin(), getLocalRangeEnd());
1117b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1118b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1119c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1120796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    setLocalRangeBegin(Loc);
1121796aa443ab5ed036f42ef33fed629e1b4b34871bAbramo Bagnara    setLocalRangeEnd(Loc);
1122dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor    setTrailingReturn(false);
11234ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
11244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall      setArg(i, NULL);
11254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
11264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1127b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block that is
1128b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// specific to this type.
112934a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
113034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getNumArgs() * sizeof(ParmVarDecl*);
1131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
113334a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getResultType(); }
113434a0447b8072e0da14c0980597da9d03a1495662John McCall};
113534a0447b8072e0da14c0980597da9d03a1495662John McCall
113651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc :
113751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
113851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoTypeLoc,
113951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoType> {
114051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
114151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
114251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc :
114351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
114451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoTypeLoc,
114551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoType> {
114651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
114751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1148b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
114934a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo {
115034a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LBracketLoc, RBracketLoc;
115134a0447b8072e0da14c0980597da9d03a1495662John McCall  Expr *Size;
1152b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1153b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1154b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays.
115551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
115651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayTypeLoc,
115751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayType,
115851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayLocInfo> {
1159b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
1160b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLBracketLoc() const {
116134a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LBracketLoc;
1162b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1163b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLBracketLoc(SourceLocation Loc) {
116434a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LBracketLoc = Loc;
1165b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1166b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1167b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRBracketLoc() const {
116834a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RBracketLoc;
1169b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1170b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRBracketLoc(SourceLocation Loc) {
117134a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RBracketLoc = Loc;
1172b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1173b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
117485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  SourceRange getBracketsRange() const {
117585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall    return SourceRange(getLBracketLoc(), getRBracketLoc());
117685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  }
117785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall
1178b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  Expr *getSizeExpr() const {
117934a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->Size;
1180b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1181b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setSizeExpr(Expr *Size) {
118234a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->Size = Size;
1183b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1184b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1185b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getElementLoc() const {
118634a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
1187b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1188b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1189bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1190b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLBracketLoc(), getRBracketLoc());
1191b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
1192b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1193c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
11944ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLBracketLoc(Loc);
11954ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRBracketLoc(Loc);
11964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setSizeExpr(NULL);
11974ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
11984ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
119934a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getElementType(); }
1200b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
1201b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
120251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc :
120351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
120451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayTypeLoc,
120551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayType> {
120651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
120751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
120851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc :
120951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
121051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayTypeLoc,
121151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayType> {
121251bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
121351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
121451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc :
121551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
121651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayTypeLoc,
121751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayType> {
121851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
121951bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
122051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
122151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc :
122251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
122351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayTypeLoc,
122451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayType> {
122551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
122651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1227833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1228833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName.  Rudimentary for now.
1229833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo {
1230833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation NameLoc;
1231833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1232833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1233833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo {
123455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  SourceLocation TemplateKWLoc;
1235833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation LAngleLoc;
1236833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation RAngleLoc;
1237833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1238833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1239833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc :
1240833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
1241833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationTypeLoc,
1242833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationType,
1243833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationLocInfo> {
1244833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic:
124555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  SourceLocation getTemplateKeywordLoc() const {
124655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    return getLocalData()->TemplateKWLoc;
124755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  }
124855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  void setTemplateKeywordLoc(SourceLocation Loc) {
124955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    getLocalData()->TemplateKWLoc = Loc;
125055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  }
125155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara
1252833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getLAngleLoc() const {
1253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->LAngleLoc;
1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1255833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setLAngleLoc(SourceLocation Loc) {
1256833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->LAngleLoc = Loc;
1257833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1258833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1259833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getRAngleLoc() const {
1260833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->RAngleLoc;
1261833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1262833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setRAngleLoc(SourceLocation Loc) {
1263833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->RAngleLoc = Loc;
1264833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1265833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1266833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getNumArgs() const {
1267833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getTypePtr()->getNumArgs();
1268833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1269833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
1270833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getArgInfos()[i] = AI;
1271833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1272833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
1273833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getArgInfos()[i];
1274833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1275833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1276833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
1277833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
1278833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1279833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1280833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getTemplateNameLoc() const {
1281833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->NameLoc;
1282833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1283833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setTemplateNameLoc(SourceLocation Loc) {
1284833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->NameLoc = Loc;
1285833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1286833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1287833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief - Copy the location information from the given info.
1288833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void copy(TemplateSpecializationTypeLoc Loc) {
1289833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    unsigned size = getFullDataSize();
1290833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    assert(size == Loc.getFullDataSize());
1291833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1292833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // We're potentially copying Expr references here.  We don't
1293a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall    // bother retaining them because TypeSourceInfos live forever, so
1294833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // as long as the Expr was retained when originally written into
1295833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // the TypeLoc, we're okay.
1296833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    memcpy(Data, Loc.Data, size);
1297833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1298833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1299bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
130055d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    if (getTemplateKeywordLoc().isValid())
130155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara      return SourceRange(getTemplateKeywordLoc(), getRAngleLoc());
130255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    else
130355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara      return SourceRange(getTemplateNameLoc(), getRAngleLoc());
1304833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1305833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1306c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
130755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    setTemplateKeywordLoc(Loc);
130855d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    setTemplateNameLoc(Loc);
1309833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setLAngleLoc(Loc);
1310833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setRAngleLoc(Loc);
1311c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor    initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(),
131233500955d731c73717af52088b7fc0e7a85681e7John McCall                      getArgInfos(), Loc);
131333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
1314833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1315c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  static void initializeArgLocs(ASTContext &Context, unsigned NumArgs,
131633500955d731c73717af52088b7fc0e7a85681e7John McCall                                const TemplateArgument *Args,
131733500955d731c73717af52088b7fc0e7a85681e7John McCall                                TemplateArgumentLocInfo *ArgInfos,
1318c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor                                SourceLocation Loc);
1319833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1320833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getExtraLocalDataSize() const {
1321833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1322833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1323833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1324833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate:
1325833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo *getArgInfos() const {
1326833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1327833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
1328833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
1329833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
1330ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
1331ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1332ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//  All of these need proper implementations.
1333ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//
1334ed97649e9574b9d854fa4d6109c9333ae0993554John McCall//===----------------------------------------------------------------------===//
133551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1336ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations (or keyword if we
1337ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// ever fully support altivec syntax).
1338ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1339ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorTypeLoc,
1340ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                       VectorType> {
134151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
134251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1343ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: size expression and attribute locations.
134451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
134551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorTypeLoc,
134651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorType> {
134751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
134851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1349ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: attribute locations.
135051bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType.
135151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc :
1352ed97649e9574b9d854fa4d6109c9333ae0993554John McCall    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1353ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorTypeLoc,
1354ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                     DependentSizedExtVectorType> {
135551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
135651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1357ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the '_Complex' keyword.
1358ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1359ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexTypeLoc,
1360ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                        ComplexType> {
136151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
136251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1363cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeofLocInfo {
1364cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation TypeofLoc;
1365cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation LParenLoc;
1366cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation RParenLoc;
136751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
136851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1369cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfExprTypeLocInfo : public TypeofLocInfo {
1370cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1371cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1372cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallstruct TypeOfTypeLocInfo : public TypeofLocInfo {
1373cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* UnderlyingTInfo;
1374cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1375cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1376cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1377cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeofLikeTypeLoc
1378cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1379cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1380cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getTypeofLoc() const {
1381cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->TypeofLoc;
1382cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1383cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setTypeofLoc(SourceLocation Loc) {
1384cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->TypeofLoc = Loc;
1385cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1386cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1387cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getLParenLoc() const {
1388cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->LParenLoc;
1389cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1390cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setLParenLoc(SourceLocation Loc) {
1391cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->LParenLoc = Loc;
1392cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1393cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1394cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceLocation getRParenLoc() const {
1395cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->RParenLoc;
1396cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1397cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setRParenLoc(SourceLocation Loc) {
1398cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->RParenLoc = Loc;
1399cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1400cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1401cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  SourceRange getParensRange() const {
1402cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getLParenLoc(), getRParenLoc());
1403cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1404cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setParensRange(SourceRange range) {
1405cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setLParenLoc(range.getBegin());
1406cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall      setRParenLoc(range.getEnd());
1407cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1408cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1409bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
1410cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return SourceRange(getTypeofLoc(), getRParenLoc());
1411cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1412cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1413c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1414cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setTypeofLoc(Loc);
1415cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setLParenLoc(Loc);
1416cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    setRParenLoc(Loc);
1417cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1418cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1419cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1420cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
1421cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprType,
1422cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall                                                   TypeOfExprTypeLocInfo> {
1423cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1424cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  Expr* getUnderlyingExpr() const {
1425cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return getTypePtr()->getUnderlyingExpr();
1426cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1427cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // Reimplemented to account for GNU/C++ extension
1428cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  //     typeof unary-expression
1429cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  // where there are no parentheses.
1430bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const;
1431cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall};
1432cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall
1433cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallclass TypeOfTypeLoc
1434cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
1435cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCallpublic:
1436cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  QualType getUnderlyingType() const {
1437cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getTypePtr()->getUnderlyingType();
1438cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1439cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  TypeSourceInfo* getUnderlyingTInfo() const {
1440cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    return this->getLocalData()->UnderlyingTInfo;
1441cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
1442cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  void setUnderlyingTInfo(TypeSourceInfo* TI) const {
1443cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall    this->getLocalData()->UnderlyingTInfo = TI;
1444cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall  }
144551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
144651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1447ed97649e9574b9d854fa4d6109c9333ae0993554John McCall// FIXME: location of the 'decltype' and parens.
1448ed97649e9574b9d854fa4d6109c9333ae0993554John McCallclass DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1449ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeTypeLoc,
1450ed97649e9574b9d854fa4d6109c9333ae0993554John McCall                                                         DecltypeType> {
1451427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidispublic:
1452427964e15f1b9595659cea3fcb4dd808a00f37b5Argyrios Kyrtzidis  Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); }
145351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
145451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1455ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntstruct UnaryTransformTypeLocInfo {
1456ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  // FIXME: While there's only one unary transform right now, future ones may
1457ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  // need different representations
1458ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceLocation KWLoc, LParenLoc, RParenLoc;
1459ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  TypeSourceInfo *UnderlyingTInfo;
1460ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt};
1461ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1462ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntclass UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1463ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt                                                    UnaryTransformTypeLoc,
1464ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt                                                    UnaryTransformType,
1465ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt                                                    UnaryTransformTypeLocInfo> {
1466ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Huntpublic:
1467ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceLocation getKWLoc() const { return getLocalData()->KWLoc; }
1468ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; }
1469ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1470ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; }
1471ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; }
1472ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1473ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; }
1474ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; }
1475ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1476ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  TypeSourceInfo* getUnderlyingTInfo() const {
1477ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    return getLocalData()->UnderlyingTInfo;
1478ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1479ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void setUnderlyingTInfo(TypeSourceInfo *TInfo) {
1480ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    getLocalData()->UnderlyingTInfo = TInfo;
1481ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1482ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1483ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceRange getLocalSourceRange() const {
1484ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    return SourceRange(getKWLoc(), getRParenLoc());
1485ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1486ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1487ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  SourceRange getParensRange() const {
1488ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    return SourceRange(getLParenLoc(), getRParenLoc());
1489ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1490ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void setParensRange(SourceRange Range) {
1491ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    setLParenLoc(Range.getBegin());
1492ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    setRParenLoc(Range.getEnd());
1493ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1494ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
1495ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1496ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    setKWLoc(Loc);
1497ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    setRParenLoc(Loc);
1498ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt    setLParenLoc(Loc);
1499ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt  }
1500ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt};
1501ca63c200346c0ca9e00194ec6e34a5a7b0ed9321Sean Hunt
150234b41d939a1328f484511c6002ba2456db879a29Richard Smithclass AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
150334b41d939a1328f484511c6002ba2456db879a29Richard Smith                                                        AutoTypeLoc,
150434b41d939a1328f484511c6002ba2456db879a29Richard Smith                                                        AutoType> {
150534b41d939a1328f484511c6002ba2456db879a29Richard Smith};
150634b41d939a1328f484511c6002ba2456db879a29Richard Smith
1507e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarastruct ElaboratedLocInfo {
150838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  SourceLocation ElaboratedKWLoc;
150938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  /// \brief Data associated with the nested-name-specifier location.
15109e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor  void *QualifierData;
1511e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1512e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1513e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1514e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedTypeLoc,
1515e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedType,
1516e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                 ElaboratedLocInfo> {
1517e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
151838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  SourceLocation getElaboratedKeywordLoc() const {
151938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    return this->getLocalData()->ElaboratedKWLoc;
1520e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
152138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  void setElaboratedKeywordLoc(SourceLocation Loc) {
152238a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    this->getLocalData()->ElaboratedKWLoc = Loc;
1523e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1524e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
15259e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor  NestedNameSpecifierLoc getQualifierLoc() const {
1526ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
15279e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor                                  getLocalData()->QualifierData);
1528e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1529ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
15309e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor  void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
1531ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    assert(QualifierLoc.getNestedNameSpecifier()
15329e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor                                            == getTypePtr()->getQualifier() &&
15339e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor           "Inconsistent nested-name-specifier pointer");
15349e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor    getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
1535e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1536e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1537bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
153838a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    if (getElaboratedKeywordLoc().isValid())
15399e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor      if (getQualifierLoc())
154038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara        return SourceRange(getElaboratedKeywordLoc(),
154138a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara                           getQualifierLoc().getEndLoc());
1542e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara      else
154338a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara        return SourceRange(getElaboratedKeywordLoc());
1544e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
15459e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor      return getQualifierLoc().getSourceRange();
1546e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1547e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
15489e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc);
1549e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1550e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  TypeLoc getNamedTypeLoc() const {
1551e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getInnerTypeLoc();
1552e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1553e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1554e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  QualType getInnerType() const {
1555e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return getTypePtr()->getNamedType();
1556e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1557e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1558e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(ElaboratedTypeLoc Loc) {
1559e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1560e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1561e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1562e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
156351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
156451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
156533500955d731c73717af52088b7fc0e7a85681e7John McCall// This is exactly the structure of an ElaboratedTypeLoc whose inner
156633500955d731c73717af52088b7fc0e7a85681e7John McCall// type is some sort of TypeDeclTypeLoc.
156733500955d731c73717af52088b7fc0e7a85681e7John McCallstruct DependentNameLocInfo : ElaboratedLocInfo {
1568e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation NameLoc;
1569e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara};
1570e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1571e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnaraclass DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1572e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameTypeLoc,
1573e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameType,
1574e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara                                                    DependentNameLocInfo> {
1575e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnarapublic:
157638a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  SourceLocation getElaboratedKeywordLoc() const {
157738a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    return this->getLocalData()->ElaboratedKWLoc;
1578e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
157938a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara  void setElaboratedKeywordLoc(SourceLocation Loc) {
158038a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    this->getLocalData()->ElaboratedKWLoc = Loc;
1581e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1582e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
15832494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor  NestedNameSpecifierLoc getQualifierLoc() const {
1584ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
15852494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor                                  getLocalData()->QualifierData);
1586e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1587ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
15882494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor  void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
1589ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    assert(QualifierLoc.getNestedNameSpecifier()
15902494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor                                            == getTypePtr()->getQualifier() &&
15912494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor           "Inconsistent nested-name-specifier pointer");
15922494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor    getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
1593e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1594ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1595e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  SourceLocation getNameLoc() const {
1596e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    return this->getLocalData()->NameLoc;
1597e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1598e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void setNameLoc(SourceLocation Loc) {
1599e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    this->getLocalData()->NameLoc = Loc;
1600e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1601e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1602bd054dba8a3023821f2a0951b0fae05e3522a7c9Abramo Bagnara  SourceRange getLocalSourceRange() const {
160338a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara    if (getElaboratedKeywordLoc().isValid())
160438a42916cb07fd368d9e2ae1e7915fa896f9ec06Abramo Bagnara      return SourceRange(getElaboratedKeywordLoc(), getNameLoc());
1605e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    else
16062494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor      return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc());
1607e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1608e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
1609e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  void copy(DependentNameTypeLoc Loc) {
1610e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    unsigned size = getFullDataSize();
1611e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    assert(size == Loc.getFullDataSize());
1612e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara    memcpy(Data, Loc.Data, size);
1613e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara  }
1614e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara
16152494dd024b392b8def58bf067cc94b51c214cf77Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc);
161651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
161751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
161894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregorstruct DependentTemplateSpecializationLocInfo : DependentNameLocInfo {
161966581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara  SourceLocation TemplateKWLoc;
162033500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation LAngleLoc;
162133500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation RAngleLoc;
162233500955d731c73717af52088b7fc0e7a85681e7John McCall  // followed by a TemplateArgumentLocInfo[]
162333500955d731c73717af52088b7fc0e7a85681e7John McCall};
162433500955d731c73717af52088b7fc0e7a85681e7John McCall
162533500955d731c73717af52088b7fc0e7a85681e7John McCallclass DependentTemplateSpecializationTypeLoc :
162633500955d731c73717af52088b7fc0e7a85681e7John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
162733500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationTypeLoc,
162833500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationType,
162933500955d731c73717af52088b7fc0e7a85681e7John McCall                           DependentTemplateSpecializationLocInfo> {
163033500955d731c73717af52088b7fc0e7a85681e7John McCallpublic:
163155d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  SourceLocation getElaboratedKeywordLoc() const {
163255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    return this->getLocalData()->ElaboratedKWLoc;
163333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
163455d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  void setElaboratedKeywordLoc(SourceLocation Loc) {
163555d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    this->getLocalData()->ElaboratedKWLoc = Loc;
163633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
163733500955d731c73717af52088b7fc0e7a85681e7John McCall
163894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor  NestedNameSpecifierLoc getQualifierLoc() const {
163994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor    if (!getLocalData()->QualifierData)
164094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      return NestedNameSpecifierLoc();
1641ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1642ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
164394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor                                  getLocalData()->QualifierData);
164433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
1645ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
164694fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor  void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
164794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor    if (!QualifierLoc) {
1648ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie      // Even if we have a nested-name-specifier in the dependent
164994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      // template specialization type, we won't record the nested-name-specifier
165094fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      // location information when this type-source location information is
165194fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      // part of a nested-name-specifier.
165294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      getLocalData()->QualifierData = 0;
165394fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      return;
165494fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor    }
1655ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
1656ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    assert(QualifierLoc.getNestedNameSpecifier()
165794fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor                                        == getTypePtr()->getQualifier() &&
165894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor           "Inconsistent nested-name-specifier pointer");
165994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor    getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
166033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
166133500955d731c73717af52088b7fc0e7a85681e7John McCall
166266581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara  SourceLocation getTemplateKeywordLoc() const {
166366581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara    return getLocalData()->TemplateKWLoc;
166466581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara  }
166566581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara  void setTemplateKeywordLoc(SourceLocation Loc) {
166666581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara    getLocalData()->TemplateKWLoc = Loc;
166766581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara  }
166866581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara
166955d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  SourceLocation getTemplateNameLoc() const {
167033500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->NameLoc;
167133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
167255d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara  void setTemplateNameLoc(SourceLocation Loc) {
167333500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->NameLoc = Loc;
167433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
167533500955d731c73717af52088b7fc0e7a85681e7John McCall
167633500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getLAngleLoc() const {
167733500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->LAngleLoc;
167833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
167933500955d731c73717af52088b7fc0e7a85681e7John McCall  void setLAngleLoc(SourceLocation Loc) {
168033500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->LAngleLoc = Loc;
168133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
168233500955d731c73717af52088b7fc0e7a85681e7John McCall
168333500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceLocation getRAngleLoc() const {
168433500955d731c73717af52088b7fc0e7a85681e7John McCall    return this->getLocalData()->RAngleLoc;
168533500955d731c73717af52088b7fc0e7a85681e7John McCall  }
168633500955d731c73717af52088b7fc0e7a85681e7John McCall  void setRAngleLoc(SourceLocation Loc) {
168733500955d731c73717af52088b7fc0e7a85681e7John McCall    this->getLocalData()->RAngleLoc = Loc;
168833500955d731c73717af52088b7fc0e7a85681e7John McCall  }
168933500955d731c73717af52088b7fc0e7a85681e7John McCall
169033500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getNumArgs() const {
169133500955d731c73717af52088b7fc0e7a85681e7John McCall    return getTypePtr()->getNumArgs();
169233500955d731c73717af52088b7fc0e7a85681e7John McCall  }
169333500955d731c73717af52088b7fc0e7a85681e7John McCall
169433500955d731c73717af52088b7fc0e7a85681e7John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
169533500955d731c73717af52088b7fc0e7a85681e7John McCall    getArgInfos()[i] = AI;
169633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
169733500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
169833500955d731c73717af52088b7fc0e7a85681e7John McCall    return getArgInfos()[i];
169933500955d731c73717af52088b7fc0e7a85681e7John McCall  }
170033500955d731c73717af52088b7fc0e7a85681e7John McCall
170133500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
170233500955d731c73717af52088b7fc0e7a85681e7John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
170333500955d731c73717af52088b7fc0e7a85681e7John McCall  }
170433500955d731c73717af52088b7fc0e7a85681e7John McCall
170533500955d731c73717af52088b7fc0e7a85681e7John McCall  SourceRange getLocalSourceRange() const {
170655d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara    if (getElaboratedKeywordLoc().isValid())
170755d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara      return SourceRange(getElaboratedKeywordLoc(), getRAngleLoc());
170894fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor    else if (getQualifierLoc())
170994fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor      return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc());
171066581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara    else if (getTemplateKeywordLoc().isValid())
171166581d41527628d4b37f7b05c288f77be7415d7dAbramo Bagnara      return SourceRange(getTemplateKeywordLoc(), getRAngleLoc());
17129e876876afc13aa671cc11a17c19907c599b9ab9Douglas Gregor    else
171355d23c925b058be29b792008ddb7d68f6c4fa9a0Abramo Bagnara      return SourceRange(getTemplateNameLoc(), getRAngleLoc());
171433500955d731c73717af52088b7fc0e7a85681e7John McCall  }
171533500955d731c73717af52088b7fc0e7a85681e7John McCall
171633500955d731c73717af52088b7fc0e7a85681e7John McCall  void copy(DependentTemplateSpecializationTypeLoc Loc) {
171733500955d731c73717af52088b7fc0e7a85681e7John McCall    unsigned size = getFullDataSize();
171833500955d731c73717af52088b7fc0e7a85681e7John McCall    assert(size == Loc.getFullDataSize());
171933500955d731c73717af52088b7fc0e7a85681e7John McCall    memcpy(Data, Loc.Data, size);
172033500955d731c73717af52088b7fc0e7a85681e7John McCall  }
172133500955d731c73717af52088b7fc0e7a85681e7John McCall
172294fdffa4a572fc14ac296f5f1aae9db3734c72f1Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc);
172333500955d731c73717af52088b7fc0e7a85681e7John McCall
172433500955d731c73717af52088b7fc0e7a85681e7John McCall  unsigned getExtraLocalDataSize() const {
172533500955d731c73717af52088b7fc0e7a85681e7John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
172633500955d731c73717af52088b7fc0e7a85681e7John McCall  }
172733500955d731c73717af52088b7fc0e7a85681e7John McCall
172833500955d731c73717af52088b7fc0e7a85681e7John McCallprivate:
172933500955d731c73717af52088b7fc0e7a85681e7John McCall  TemplateArgumentLocInfo *getArgInfos() const {
173033500955d731c73717af52088b7fc0e7a85681e7John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
173133500955d731c73717af52088b7fc0e7a85681e7John McCall  }
173233500955d731c73717af52088b7fc0e7a85681e7John McCall};
173333500955d731c73717af52088b7fc0e7a85681e7John McCall
17347536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17357536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct PackExpansionTypeLocInfo {
17367536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation EllipsisLoc;
17377536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
17387536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17397536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorclass PackExpansionTypeLoc
1740ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie  : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
17417536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor                           PackExpansionType, PackExpansionTypeLocInfo> {
17427536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorpublic:
17437536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceLocation getEllipsisLoc() const {
17447536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getLocalData()->EllipsisLoc;
17457536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17467536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17477536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  void setEllipsisLoc(SourceLocation Loc) {
17487536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    this->getLocalData()->EllipsisLoc = Loc;
17497536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17507536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17517536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  SourceRange getLocalSourceRange() const {
17527536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return SourceRange(getEllipsisLoc(), getEllipsisLoc());
17537536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17547536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
1755c21c7e9c2cded68f91be15be6847c9649242dc17Douglas Gregor  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
17567536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    setEllipsisLoc(Loc);
17577536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17587536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17597536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  TypeLoc getPatternLoc() const {
17607536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return getInnerTypeLoc();
17617536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17627536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
17637536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  QualType getInnerType() const {
17647536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor    return this->getTypePtr()->getPattern();
17657536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  }
17667536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
17677536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
1768b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanstruct AtomicTypeLocInfo {
1769b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceLocation KWLoc, LParenLoc, RParenLoc;
1770b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman};
1771b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1772b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedmanclass AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
1773b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman                                             AtomicType, AtomicTypeLocInfo> {
1774ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic:
1775b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  TypeLoc getValueLoc() const {
1776b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return this->getInnerTypeLoc();
1777b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1778b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1779b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceRange getLocalSourceRange() const {
1780b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return SourceRange(getKWLoc(), getRParenLoc());
1781b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1782b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1783b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceLocation getKWLoc() const {
1784b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return this->getLocalData()->KWLoc;
1785b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1786b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  void setKWLoc(SourceLocation Loc) {
1787b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    this->getLocalData()->KWLoc = Loc;
1788b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1789b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1790b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceLocation getLParenLoc() const {
1791b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return this->getLocalData()->LParenLoc;
1792b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1793b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  void setLParenLoc(SourceLocation Loc) {
1794b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    this->getLocalData()->LParenLoc = Loc;
1795b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1796b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1797b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceLocation getRParenLoc() const {
1798b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return this->getLocalData()->RParenLoc;
1799b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1800b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  void setRParenLoc(SourceLocation Loc) {
1801b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    this->getLocalData()->RParenLoc = Loc;
1802b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1803b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1804b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  SourceRange getParensRange() const {
1805b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return SourceRange(getLParenLoc(), getRParenLoc());
1806b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1807b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  void setParensRange(SourceRange Range) {
1808b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    setLParenLoc(Range.getBegin());
1809b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    setRParenLoc(Range.getEnd());
1810b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1811b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1812b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1813b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    setKWLoc(Loc);
1814b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    setLParenLoc(Loc);
1815b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    setRParenLoc(Loc);
1816b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1817b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1818b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  QualType getInnerType() const {
1819b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman    return this->getTypePtr()->getValueType();
1820b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman  }
1821b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman};
1822b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1823b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman
1824b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}
1825b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1826b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif
1827