TypeLoc.h revision a4923eb7c4b04d360cb2747641a5e92818edf804
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"
18833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h"
19b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
20b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisnamespace clang {
21b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  class ParmVarDecl;
22b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  class DeclaratorInfo;
2334a0447b8072e0da14c0980597da9d03a1495662John McCall  class UnqualTypeLoc;
24b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
2551bd803fbdade51d674598ed45da3d54190a656cJohn McCall// Predeclare all the type nodes.
2651bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPELOC(Class, Base)
2751bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPELOC(Class, Base) \
2851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  class Class##TypeLoc;
2951bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeLocNodes.def"
3051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
31b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Base wrapper for a particular "section" of type source info.
32b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis///
33b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// A client should use the TypeLoc subclasses through cast/dyn_cast in order to
34b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// get at the actual information.
35b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisclass TypeLoc {
36b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidisprotected:
3734a0447b8072e0da14c0980597da9d03a1495662John McCall  // The correctness of this relies on the property that, for Type *Ty,
3834a0447b8072e0da14c0980597da9d03a1495662John McCall  //   QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
3934a0447b8072e0da14c0980597da9d03a1495662John McCall  void *Ty;
40b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void *Data;
411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
42b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
4351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// The kinds of TypeLocs.  Equivalent to the Type::TypeClass enum,
4451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// except it also defines a Qualified enum that corresponds to the
4551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  /// QualifiedLoc class.
4651bd803fbdade51d674598ed45da3d54190a656cJohn McCall  enum TypeLocClass {
4751bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define ABSTRACT_TYPE(Class, Base)
4851bd803fbdade51d674598ed45da3d54190a656cJohn McCall#define TYPE(Class, Base) \
4951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Class = Type::Class,
5051bd803fbdade51d674598ed45da3d54190a656cJohn McCall#include "clang/AST/TypeNodes.def"
5151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    Qualified
5251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  };
5351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
5434a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc() : Ty(0), Data(0) { }
5534a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc(QualType ty, void *opaqueData)
5634a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty.getAsOpaquePtr()), Data(opaqueData) { }
5734a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc(Type *ty, void *opaqueData)
5834a0447b8072e0da14c0980597da9d03a1495662John McCall    : Ty(ty), Data(opaqueData) { }
59b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
6051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
61a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    if (getType().hasLocalQualifiers()) return Qualified;
6251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getType()->getTypeClass();
6351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
6451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
6534a0447b8072e0da14c0980597da9d03a1495662John McCall  bool isNull() const { return !Ty; }
6634a0447b8072e0da14c0980597da9d03a1495662John McCall  operator bool() const { return Ty; }
67b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
68b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of type source info data block for the given type.
69b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static unsigned getFullDataSizeForType(QualType Ty);
70b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
71b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the type for which this source info wrapper provides
72b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// information.
7351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getType() const {
7451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return QualType::getFromOpaquePtr(Ty);
7551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
7634a0447b8072e0da14c0980597da9d03a1495662John McCall
7751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  Type *getTypePtr() const {
7834a0447b8072e0da14c0980597da9d03a1495662John McCall    return QualType::getFromOpaquePtr(Ty).getTypePtr();
7934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
80b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
81b735471f3848065120d7210e557b5f0d37ed4c43Argyrios Kyrtzidis  /// \brief Get the pointer where source information is stored.
8251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void *getOpaqueData() const {
8351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Data;
8451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
85b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
86833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the full source range.
87833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceRange getFullSourceRange() const {
88833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    SourceLocation End = getSourceRange().getEnd();
89833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    TypeLoc Cur = *this;
90833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    while (true) {
91833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall      TypeLoc Next = Cur.getNextTypeLoc();
92833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall      if (Next.isNull()) break;
93833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall      Cur = Next;
94833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    }
95833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return SourceRange(Cur.getSourceRange().getBegin(), End);
96833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
97833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
98833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief Get the local source range.
9951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceRange getSourceRange() const {
10051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSourceRangeImpl(*this);
10151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
102b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
103b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block.
10434a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
10551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getFullDataSizeForType(getType());
10634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
107b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
108b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
109b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
11051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLoc getNextTypeLoc() const {
11151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getNextTypeLocImpl(*this);
11251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
113b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
11434a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Skips past any qualifiers, if this is qualified.
11551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
11634a0447b8072e0da14c0980597da9d03a1495662John McCall
1174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// \brief Initializes this to state that every location in this
1184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// type is the given location.
1194ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  ///
1204ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// This method exists to provide a simple transition for code that
1214ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// relies on location-less types.
1224ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initialize(SourceLocation Loc) const {
1234ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    initializeImpl(*this, Loc);
1244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
1254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
126b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
127b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
128b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
129b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
130b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) {
131b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return !(LHS == RHS);
132b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
133b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
134b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  static bool classof(const TypeLoc *TL) { return true; }
1354ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1364ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCallprivate:
1374ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  static void initializeImpl(TypeLoc TL, SourceLocation Loc);
13851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static TypeLoc getNextTypeLocImpl(TypeLoc TL);
13951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static SourceRange getSourceRangeImpl(TypeLoc TL);
140b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
141b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
14234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
14334a0447b8072e0da14c0980597da9d03a1495662John McCall/// no direct quqlaifiers.
14434a0447b8072e0da14c0980597da9d03a1495662John McCallclass UnqualTypeLoc : public TypeLoc {
14534a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
14634a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc() {}
14734a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc(Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
14834a0447b8072e0da14c0980597da9d03a1495662John McCall
14951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  Type *getTypePtr() const {
15034a0447b8072e0da14c0980597da9d03a1495662John McCall    return reinterpret_cast<Type*>(Ty);
15134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
15234a0447b8072e0da14c0980597da9d03a1495662John McCall
15351bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeLocClass getTypeLocClass() const {
15451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return (TypeLocClass) getTypePtr()->getTypeClass();
15551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
15651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
15734a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
158a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return !TL->getType().hasLocalQualifiers();
15934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
16034a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const UnqualTypeLoc *TL) { return true; }
16134a0447b8072e0da14c0980597da9d03a1495662John McCall};
16234a0447b8072e0da14c0980597da9d03a1495662John McCall
16334a0447b8072e0da14c0980597da9d03a1495662John McCall/// \brief Wrapper of type source information for a type with
16434a0447b8072e0da14c0980597da9d03a1495662John McCall/// non-trivial direct qualifiers.
16534a0447b8072e0da14c0980597da9d03a1495662John McCall///
16634a0447b8072e0da14c0980597da9d03a1495662John McCall/// Currently, we intentionally do not provide source location for
16734a0447b8072e0da14c0980597da9d03a1495662John McCall/// type qualifiers.
16851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedTypeLoc : public TypeLoc {
16934a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
17034a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceRange getSourceRange() const {
17134a0447b8072e0da14c0980597da9d03a1495662John McCall    return SourceRange();
17234a0447b8072e0da14c0980597da9d03a1495662John McCall  }
17334a0447b8072e0da14c0980597da9d03a1495662John McCall
17434a0447b8072e0da14c0980597da9d03a1495662John McCall  UnqualTypeLoc getUnqualifiedLoc() const {
17551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return UnqualTypeLoc(getTypePtr(), Data);
17634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
17734a0447b8072e0da14c0980597da9d03a1495662John McCall
1784ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// Initializes the local data of this type source info block to
1794ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  /// provide no information.
1804ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
1814ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    // do nothing
1824ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
1834ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
1844ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
1854ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getUnqualifiedLoc();
1864ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
1874ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
18834a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block that is
18934a0447b8072e0da14c0980597da9d03a1495662John McCall  /// specific to this type.
19034a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
19134a0447b8072e0da14c0980597da9d03a1495662John McCall    // In fact, we don't currently preserve any location information
19234a0447b8072e0da14c0980597da9d03a1495662John McCall    // for qualifiers.
19334a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
19434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
19534a0447b8072e0da14c0980597da9d03a1495662John McCall
19634a0447b8072e0da14c0980597da9d03a1495662John McCall  /// \brief Returns the size of the type source info data block.
19734a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
19834a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalDataSize() +
19951bd803fbdade51d674598ed45da3d54190a656cJohn McCall      getFullDataSizeForType(getType().getUnqualifiedType());
20034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
20134a0447b8072e0da14c0980597da9d03a1495662John McCall
20234a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classof(const TypeLoc *TL) {
203a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor    return TL->getType().hasLocalQualifiers();
20434a0447b8072e0da14c0980597da9d03a1495662John McCall  }
20551bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const QualifiedTypeLoc *TL) { return true; }
20634a0447b8072e0da14c0980597da9d03a1495662John McCall};
20734a0447b8072e0da14c0980597da9d03a1495662John McCall
20834a0447b8072e0da14c0980597da9d03a1495662John McCallinline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const {
20951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  if (isa<QualifiedTypeLoc>(this))
21051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<QualifiedTypeLoc>(this)->getUnqualifiedLoc();
21134a0447b8072e0da14c0980597da9d03a1495662John McCall  return cast<UnqualTypeLoc>(*this);
21234a0447b8072e0da14c0980597da9d03a1495662John McCall}
21334a0447b8072e0da14c0980597da9d03a1495662John McCall
21434a0447b8072e0da14c0980597da9d03a1495662John McCall/// A metaprogramming base class for TypeLoc classes which correspond
215f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// to a particular Type subclass.  It is accepted for a single
216f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// TypeLoc class to correspond to multiple Type classes.
21734a0447b8072e0da14c0980597da9d03a1495662John McCall///
21834a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Base a class from which to derive
21934a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param Derived the class deriving from this one
220f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall/// \param TypeClass the concrete Type subclass associated with this
221f2130a6e3cef10b435feadf6ad8bebaaf9a81a88John McCall///   location type
22234a0447b8072e0da14c0980597da9d03a1495662John McCall/// \param LocalData the structure type of local location data for
22334a0447b8072e0da14c0980597da9d03a1495662John McCall///   this type
22434a0447b8072e0da14c0980597da9d03a1495662John McCall///
22534a0447b8072e0da14c0980597da9d03a1495662John McCall/// sizeof(LocalData) needs to be a multiple of sizeof(void*) or
22634a0447b8072e0da14c0980597da9d03a1495662John McCall/// else the world will end.
22734a0447b8072e0da14c0980597da9d03a1495662John McCall///
22834a0447b8072e0da14c0980597da9d03a1495662John McCall/// TypeLocs with non-constant amounts of local data should override
22934a0447b8072e0da14c0980597da9d03a1495662John McCall/// getExtraLocalDataSize(); getExtraLocalData() will then point to
23034a0447b8072e0da14c0980597da9d03a1495662John McCall/// this extra memory.
23134a0447b8072e0da14c0980597da9d03a1495662John McCall///
232a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// TypeLocs with an inner type should define
233a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall///   QualType getInnerType() const
234a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// and getInnerTypeLoc() will then point to this inner type's
235a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall/// location data.
23651bd803fbdade51d674598ed45da3d54190a656cJohn McCall///
23751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A word about hierarchies: this template is not designed to be
23851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// derived from multiple times in a hierarchy.  It is also not
23951bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// designed to be used for classes where subtypes might provide
24051bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// different amounts of source information.  It should be subclassed
24151bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// only at the deepest portion of the hierarchy where all children
24251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// have identical source information; if that's an abstract type,
24351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// then further descendents should inherit from
24451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// InheritingConcreteTypeLoc instead.
24534a0447b8072e0da14c0980597da9d03a1495662John McCalltemplate <class Base, class Derived, class TypeClass, class LocalData>
24634a0447b8072e0da14c0980597da9d03a1495662John McCallclass ConcreteTypeLoc : public Base {
24734a0447b8072e0da14c0980597da9d03a1495662John McCall
24834a0447b8072e0da14c0980597da9d03a1495662John McCall  const Derived *asDerived() const {
24934a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<const Derived*>(this);
25034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
25134a0447b8072e0da14c0980597da9d03a1495662John McCall
25234a0447b8072e0da14c0980597da9d03a1495662John McCallpublic:
25334a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getLocalDataSize() const {
25434a0447b8072e0da14c0980597da9d03a1495662John McCall    return sizeof(LocalData) + asDerived()->getExtraLocalDataSize();
25534a0447b8072e0da14c0980597da9d03a1495662John McCall  }
25634a0447b8072e0da14c0980597da9d03a1495662John McCall  // Give a default implementation that's useful for leaf types.
25734a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getFullDataSize() const {
25834a0447b8072e0da14c0980597da9d03a1495662John McCall    return asDerived()->getLocalDataSize() + getInnerTypeSize();
25934a0447b8072e0da14c0980597da9d03a1495662John McCall  }
26034a0447b8072e0da14c0980597da9d03a1495662John McCall
26134a0447b8072e0da14c0980597da9d03a1495662John McCall  static bool classofType(const Type *Ty) {
26234a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeClass::classof(Ty);
26334a0447b8072e0da14c0980597da9d03a1495662John McCall  }
26434a0447b8072e0da14c0980597da9d03a1495662John McCall
2654ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc() const {
2664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return getNextTypeLoc(asDerived()->getInnerType());
2674ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
2684ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
26934a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeClass *getTypePtr() const {
27051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
27134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
27234a0447b8072e0da14c0980597da9d03a1495662John McCall
27351bd803fbdade51d674598ed45da3d54190a656cJohn McCallprotected:
27434a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
27534a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
27634a0447b8072e0da14c0980597da9d03a1495662John McCall  }
27734a0447b8072e0da14c0980597da9d03a1495662John McCall
27834a0447b8072e0da14c0980597da9d03a1495662John McCall  LocalData *getLocalData() const {
27934a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<LocalData*>(Base::Data);
28034a0447b8072e0da14c0980597da9d03a1495662John McCall  }
28134a0447b8072e0da14c0980597da9d03a1495662John McCall
28234a0447b8072e0da14c0980597da9d03a1495662John McCall  /// Gets a pointer past the Info structure; useful for classes with
28334a0447b8072e0da14c0980597da9d03a1495662John McCall  /// local data that can't be captured in the Info (e.g. because it's
28434a0447b8072e0da14c0980597da9d03a1495662John McCall  /// of variable size).
28534a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getExtraLocalData() const {
28634a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData() + 1;
28734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
28834a0447b8072e0da14c0980597da9d03a1495662John McCall
28934a0447b8072e0da14c0980597da9d03a1495662John McCall  void *getNonLocalData() const {
29034a0447b8072e0da14c0980597da9d03a1495662John McCall    return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize();
29134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29234a0447b8072e0da14c0980597da9d03a1495662John McCall
293a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  struct HasNoInnerType {};
294a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  HasNoInnerType getInnerType() const { return HasNoInnerType(); }
29534a0447b8072e0da14c0980597da9d03a1495662John McCall
29634a0447b8072e0da14c0980597da9d03a1495662John McCall  TypeLoc getInnerTypeLoc() const {
29734a0447b8072e0da14c0980597da9d03a1495662John McCall    return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
29834a0447b8072e0da14c0980597da9d03a1495662John McCall  }
29934a0447b8072e0da14c0980597da9d03a1495662John McCall
30034a0447b8072e0da14c0980597da9d03a1495662John McCallprivate:
30134a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getInnerTypeSize() const {
302a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeSize(asDerived()->getInnerType());
303a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  }
304a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall
305a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(HasNoInnerType _) const {
30634a0447b8072e0da14c0980597da9d03a1495662John McCall    return 0;
30734a0447b8072e0da14c0980597da9d03a1495662John McCall  }
30834a0447b8072e0da14c0980597da9d03a1495662John McCall
309a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall  unsigned getInnerTypeSize(QualType _) const {
310a6f56429aa9a02e71426e99db8b0ae94d0115215John McCall    return getInnerTypeLoc().getFullDataSize();
31134a0447b8072e0da14c0980597da9d03a1495662John McCall  }
3124ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3134ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(HasNoInnerType _) const {
3144ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc();
3154ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
3164ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
3174ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  TypeLoc getNextTypeLoc(QualType T) const {
3184ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    return TypeLoc(T, getNonLocalData());
3194ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
32034a0447b8072e0da14c0980597da9d03a1495662John McCall};
32134a0447b8072e0da14c0980597da9d03a1495662John McCall
32251bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A metaprogramming class designed for concrete subtypes of abstract
32351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types where all subtypes share equivalently-structured source
32451bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// information.  See the note on ConcreteTypeLoc.
32551bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Base, class Derived, class TypeClass>
32651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass InheritingConcreteTypeLoc : public Base {
327b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
32851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const TypeLoc *TL) {
32951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
330b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
33151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const UnqualTypeLoc *TL) {
33251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return Derived::classofType(TL->getTypePtr());
333b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
33451bd803fbdade51d674598ed45da3d54190a656cJohn McCall  static bool classof(const Derived *TL) {
33551bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return true;
336b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
337b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
33851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  TypeClass *getTypePtr() const {
33951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return cast<TypeClass>(Base::getTypePtr());
3404ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
34134a0447b8072e0da14c0980597da9d03a1495662John McCall};
342b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
34351bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct TypeSpecLocInfo {
34434a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation NameLoc;
345b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
346b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
34751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief A reasonable base class for TypeLocs that correspond to
34851bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// types that are written as a type-specifier.
34951bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = TypeSpecLocInfo>
35051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TypeSpecTypeLoc
35151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
352b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
353b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getNameLoc() const {
35451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->NameLoc;
355b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
356b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setNameLoc(SourceLocation Loc) {
35751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->NameLoc = Loc;
358b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
359b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceRange getSourceRange() const {
360b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getNameLoc(), getNameLoc());
361b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
3624ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
3634ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setNameLoc(Loc);
3644ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
36551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
3664ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
36751bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for typedefs.
36851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TypedefTypeLoc : public TypeSpecTypeLoc<TypedefTypeLoc,TypedefType> {
36951bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
3709036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis  TypedefDecl *getTypedefDecl() const {
37134a0447b8072e0da14c0980597da9d03a1495662John McCall    return getTypePtr()->getDecl();
3729036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis  }
37334a0447b8072e0da14c0980597da9d03a1495662John McCall};
3749036d5e369aae65e3baccdeed74c796e3d367b3dArgyrios Kyrtzidis
375b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
37651bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for builtin types.
37751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BuiltinTypeLoc : public TypeSpecTypeLoc<BuiltinTypeLoc,
37851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                              BuiltinType> {
379b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
380b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
38149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for template type parameters.
38249a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass TemplateTypeParmTypeLoc : public TypeSpecTypeLoc<TemplateTypeParmTypeLoc,
38349a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall                                                       TemplateTypeParmType> {
38449a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
38549a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall
38649a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall/// \brief Wrapper for substituted template type parameters.
38749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallclass SubstTemplateTypeParmTypeLoc :
38849a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall    public TypeSpecTypeLoc<SubstTemplateTypeParmTypeLoc,
38949a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall                           SubstTemplateTypeParmType> {
39049a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall};
39151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
392eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
39334a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ObjCProtocolListLocInfo {
39454e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation LAngleLoc;
39554e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation RAngleLoc;
396eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis};
397eb66759e9a1d7c041354d132a14674b2d948059bArgyrios Kyrtzidis
39854e14c4db764c0636160d26c5bbf491637c83a76John McCall// A helper class for defining ObjC TypeLocs that can qualified with
39954e14c4db764c0636160d26c5bbf491637c83a76John McCall// protocols.
40054e14c4db764c0636160d26c5bbf491637c83a76John McCall//
40154e14c4db764c0636160d26c5bbf491637c83a76John McCall// TypeClass basically has to be either ObjCInterfaceType or
40254e14c4db764c0636160d26c5bbf491637c83a76John McCall// ObjCObjectPointerType.
40354e14c4db764c0636160d26c5bbf491637c83a76John McCalltemplate <class Derived, class TypeClass, class LocalData>
40454e14c4db764c0636160d26c5bbf491637c83a76John McCallclass ObjCProtocolListTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
40554e14c4db764c0636160d26c5bbf491637c83a76John McCall                                                       Derived,
40654e14c4db764c0636160d26c5bbf491637c83a76John McCall                                                       TypeClass,
40754e14c4db764c0636160d26c5bbf491637c83a76John McCall                                                       LocalData> {
408f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  // SourceLocations are stored after Info, one for each Protocol.
409f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation *getProtocolLocArray() const {
41054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return (SourceLocation*) this->getExtraLocalData();
41154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
41254e14c4db764c0636160d26c5bbf491637c83a76John McCall
41354e14c4db764c0636160d26c5bbf491637c83a76John McCallprotected:
41454e14c4db764c0636160d26c5bbf491637c83a76John McCall  void initializeLocalBase(SourceLocation Loc) {
41554e14c4db764c0636160d26c5bbf491637c83a76John McCall    setLAngleLoc(Loc);
41654e14c4db764c0636160d26c5bbf491637c83a76John McCall    setRAngleLoc(Loc);
41754e14c4db764c0636160d26c5bbf491637c83a76John McCall    for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
41854e14c4db764c0636160d26c5bbf491637c83a76John McCall      setProtocolLoc(i, Loc);
419f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
420f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
421f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidispublic:
422f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getLAngleLoc() const {
42354e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->LAngleLoc;
424f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
425f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setLAngleLoc(SourceLocation Loc) {
42654e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->LAngleLoc = Loc;
427f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
428f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
429f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getRAngleLoc() const {
43054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getLocalData()->RAngleLoc;
431f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
432f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setRAngleLoc(SourceLocation Loc) {
43354e14c4db764c0636160d26c5bbf491637c83a76John McCall    this->getLocalData()->RAngleLoc = Loc;
434f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
435f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
436f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  unsigned getNumProtocols() const {
43754e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getTypePtr()->getNumProtocols();
438f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
439f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
440f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceLocation getProtocolLoc(unsigned i) const {
441f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
442f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return getProtocolLocArray()[i];
443f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
444f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  void setProtocolLoc(unsigned i, SourceLocation Loc) {
445f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
446f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    getProtocolLocArray()[i] = Loc;
447f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
448f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
449f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  ObjCProtocolDecl *getProtocol(unsigned i) const {
450f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    assert(i < getNumProtocols() && "Index is out of bounds!");
45154e14c4db764c0636160d26c5bbf491637c83a76John McCall    return *(this->getTypePtr()->qual_begin() + i);
452f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
453f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
454f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  SourceRange getSourceRange() const {
455f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis    return SourceRange(getLAngleLoc(), getRAngleLoc());
456f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
457f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
4584ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
45954e14c4db764c0636160d26c5bbf491637c83a76John McCall    initializeLocalBase(Loc);
4604ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
4614ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
46234a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
46354e14c4db764c0636160d26c5bbf491637c83a76John McCall    return this->getNumProtocols() * sizeof(SourceLocation);
46454e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
46554e14c4db764c0636160d26c5bbf491637c83a76John McCall};
46654e14c4db764c0636160d26c5bbf491637c83a76John McCall
46754e14c4db764c0636160d26c5bbf491637c83a76John McCall
46854e14c4db764c0636160d26c5bbf491637c83a76John McCallstruct ObjCInterfaceLocInfo : ObjCProtocolListLocInfo {
46954e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation NameLoc;
47054e14c4db764c0636160d26c5bbf491637c83a76John McCall};
47154e14c4db764c0636160d26c5bbf491637c83a76John McCall
47254e14c4db764c0636160d26c5bbf491637c83a76John McCall/// \brief Wrapper for source info for ObjC interfaces.
47354e14c4db764c0636160d26c5bbf491637c83a76John McCallclass ObjCInterfaceTypeLoc :
47454e14c4db764c0636160d26c5bbf491637c83a76John McCall    public ObjCProtocolListTypeLoc<ObjCInterfaceTypeLoc,
47554e14c4db764c0636160d26c5bbf491637c83a76John McCall                                   ObjCInterfaceType,
47654e14c4db764c0636160d26c5bbf491637c83a76John McCall                                   ObjCInterfaceLocInfo> {
47754e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
47854e14c4db764c0636160d26c5bbf491637c83a76John McCall  ObjCInterfaceDecl *getIFaceDecl() const {
47954e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getDecl();
48054e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
48154e14c4db764c0636160d26c5bbf491637c83a76John McCall
48254e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation getNameLoc() const {
48354e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->NameLoc;
48454e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
48554e14c4db764c0636160d26c5bbf491637c83a76John McCall
48654e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setNameLoc(SourceLocation Loc) {
48754e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->NameLoc = Loc;
48854e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
48954e14c4db764c0636160d26c5bbf491637c83a76John McCall
49054e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceRange getSourceRange() const {
49154e14c4db764c0636160d26c5bbf491637c83a76John McCall    if (getNumProtocols())
49254e14c4db764c0636160d26c5bbf491637c83a76John McCall      return SourceRange(getNameLoc(), getRAngleLoc());
49354e14c4db764c0636160d26c5bbf491637c83a76John McCall    else
49454e14c4db764c0636160d26c5bbf491637c83a76John McCall      return SourceRange(getNameLoc(), getNameLoc());
49554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
49654e14c4db764c0636160d26c5bbf491637c83a76John McCall
49754e14c4db764c0636160d26c5bbf491637c83a76John McCall  void initializeLocal(SourceLocation Loc) {
49854e14c4db764c0636160d26c5bbf491637c83a76John McCall    initializeLocalBase(Loc);
49954e14c4db764c0636160d26c5bbf491637c83a76John McCall    setNameLoc(Loc);
500f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis  }
50154e14c4db764c0636160d26c5bbf491637c83a76John McCall};
50254e14c4db764c0636160d26c5bbf491637c83a76John McCall
503f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
50454e14c4db764c0636160d26c5bbf491637c83a76John McCallstruct ObjCObjectPointerLocInfo : ObjCProtocolListLocInfo {
50554e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation StarLoc;
50654e14c4db764c0636160d26c5bbf491637c83a76John McCall  bool HasProtocols;
50754e14c4db764c0636160d26c5bbf491637c83a76John McCall  bool HasBaseType;
50834a0447b8072e0da14c0980597da9d03a1495662John McCall};
509f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
51054e14c4db764c0636160d26c5bbf491637c83a76John McCall/// Wraps an ObjCPointerType with source location information.  Note
51154e14c4db764c0636160d26c5bbf491637c83a76John McCall/// that not all ObjCPointerTypes actually have a star location; nor
51254e14c4db764c0636160d26c5bbf491637c83a76John McCall/// are protocol locations necessarily written in the source just
51354e14c4db764c0636160d26c5bbf491637c83a76John McCall/// because they're present on the type.
51454e14c4db764c0636160d26c5bbf491637c83a76John McCallclass ObjCObjectPointerTypeLoc :
51554e14c4db764c0636160d26c5bbf491637c83a76John McCall    public ObjCProtocolListTypeLoc<ObjCObjectPointerTypeLoc,
51654e14c4db764c0636160d26c5bbf491637c83a76John McCall                                   ObjCObjectPointerType,
51754e14c4db764c0636160d26c5bbf491637c83a76John McCall                                   ObjCObjectPointerLocInfo> {
51854e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
51954e14c4db764c0636160d26c5bbf491637c83a76John McCall  bool hasProtocolsAsWritten() const {
52054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->HasProtocols;
52154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
52254e14c4db764c0636160d26c5bbf491637c83a76John McCall
52354e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setHasProtocolsAsWritten(bool HasProtocols) {
52454e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->HasProtocols = HasProtocols;
52554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
52654e14c4db764c0636160d26c5bbf491637c83a76John McCall
52754e14c4db764c0636160d26c5bbf491637c83a76John McCall  bool hasBaseTypeAsWritten() const {
52854e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->HasBaseType;
52954e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
53054e14c4db764c0636160d26c5bbf491637c83a76John McCall
53154e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setHasBaseTypeAsWritten(bool HasBaseType) {
53254e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->HasBaseType = HasBaseType;
53354e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
53454e14c4db764c0636160d26c5bbf491637c83a76John McCall
53554e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceLocation getStarLoc() const {
53654e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getLocalData()->StarLoc;
53754e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
53854e14c4db764c0636160d26c5bbf491637c83a76John McCall
53954e14c4db764c0636160d26c5bbf491637c83a76John McCall  void setStarLoc(SourceLocation Loc) {
54054e14c4db764c0636160d26c5bbf491637c83a76John McCall    getLocalData()->StarLoc = Loc;
54154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
54254e14c4db764c0636160d26c5bbf491637c83a76John McCall
54354e14c4db764c0636160d26c5bbf491637c83a76John McCall  SourceRange getSourceRange() const {
54454e14c4db764c0636160d26c5bbf491637c83a76John McCall    // Being written with protocols is incompatible with being written
54554e14c4db764c0636160d26c5bbf491637c83a76John McCall    // with a star.
54654e14c4db764c0636160d26c5bbf491637c83a76John McCall    if (hasProtocolsAsWritten())
54754e14c4db764c0636160d26c5bbf491637c83a76John McCall      return SourceRange(getLAngleLoc(), getRAngleLoc());
54854e14c4db764c0636160d26c5bbf491637c83a76John McCall    else
54954e14c4db764c0636160d26c5bbf491637c83a76John McCall      return SourceRange(getStarLoc(), getStarLoc());
55054e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
55154e14c4db764c0636160d26c5bbf491637c83a76John McCall
55254e14c4db764c0636160d26c5bbf491637c83a76John McCall  void initializeLocal(SourceLocation Loc) {
55354e14c4db764c0636160d26c5bbf491637c83a76John McCall    initializeLocalBase(Loc);
55454e14c4db764c0636160d26c5bbf491637c83a76John McCall    setHasProtocolsAsWritten(false);
55554e14c4db764c0636160d26c5bbf491637c83a76John McCall    setHasBaseTypeAsWritten(false);
55654e14c4db764c0636160d26c5bbf491637c83a76John McCall    setStarLoc(Loc);
55754e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
55854e14c4db764c0636160d26c5bbf491637c83a76John McCall
55954e14c4db764c0636160d26c5bbf491637c83a76John McCall  TypeLoc getBaseTypeLoc() const {
56054e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getInnerTypeLoc();
56154e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
56254e14c4db764c0636160d26c5bbf491637c83a76John McCall
56354e14c4db764c0636160d26c5bbf491637c83a76John McCall  QualType getInnerType() const {
56454e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getPointeeType();
56554e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
56654e14c4db764c0636160d26c5bbf491637c83a76John McCall};
56734a0447b8072e0da14c0980597da9d03a1495662John McCall
56851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
56951bd803fbdade51d674598ed45da3d54190a656cJohn McCallstruct PointerLikeLocInfo {
57034a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation StarLoc;
571f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis};
572f352bddf015e537350416c296dd2963524f554f9Argyrios Kyrtzidis
57351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// A base class for
57451bd803fbdade51d674598ed45da3d54190a656cJohn McCalltemplate <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
57551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
57651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                  TypeClass, LocalData> {
577bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallpublic:
57851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getSigilLoc() const {
57951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getLocalData()->StarLoc;
580b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
58151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setSigilLoc(SourceLocation Loc) {
58251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    this->getLocalData()->StarLoc = Loc;
583b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
584b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
585b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getPointeeLoc() const {
58651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getInnerTypeLoc();
587b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
588b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
589b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceRange getSourceRange() const {
59051bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return SourceRange(getSigilLoc(), getSigilLoc());
591b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
592b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
5934ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
59451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
5954ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
5964ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
59751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  QualType getInnerType() const {
59851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return this->getTypePtr()->getPointeeType();
59951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
60034a0447b8072e0da14c0980597da9d03a1495662John McCall};
601b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
602b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
60351bd803fbdade51d674598ed45da3d54190a656cJohn McCall/// \brief Wrapper for source info for pointers.
60451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
60551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 PointerType> {
60651bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
60751bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getStarLoc() const {
60851bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
60951bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
61051bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setStarLoc(SourceLocation Loc) {
61151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
61251bd803fbdade51d674598ed45da3d54190a656cJohn McCall  }
613b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
614b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
61551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
616b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for block pointers.
61751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
61851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                      BlockPointerType> {
619b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
620b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getCaretLoc() const {
62151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
622b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
623b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setCaretLoc(SourceLocation Loc) {
62451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
625b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
62634a0447b8072e0da14c0980597da9d03a1495662John McCall};
627b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
628b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
629b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for member pointers.
63051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
63151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                       MemberPointerType> {
632b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
633b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getStarLoc() const {
63451bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
635b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
636b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setStarLoc(SourceLocation Loc) {
63751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
6384ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
63934a0447b8072e0da14c0980597da9d03a1495662John McCall};
640b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
641b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
64251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
64351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                   ReferenceType> {
64454e14c4db764c0636160d26c5bbf491637c83a76John McCallpublic:
64554e14c4db764c0636160d26c5bbf491637c83a76John McCall  QualType getInnerType() const {
64654e14c4db764c0636160d26c5bbf491637c83a76John McCall    return getTypePtr()->getPointeeTypeAsWritten();
64754e14c4db764c0636160d26c5bbf491637c83a76John McCall  }
648b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
649b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
650bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass LValueReferenceTypeLoc :
651bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
652bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceTypeLoc,
653bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     LValueReferenceType> {
654b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
655b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getAmpLoc() const {
65651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
657b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
658b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setAmpLoc(SourceLocation Loc) {
65951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
660b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
66151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
662b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
663bb833dcc562f686a0652865d1945cfa3a421379cJohn McCallclass RValueReferenceTypeLoc :
664bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall    public InheritingConcreteTypeLoc<ReferenceTypeLoc,
665bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceTypeLoc,
666bb833dcc562f686a0652865d1945cfa3a421379cJohn McCall                                     RValueReferenceType> {
66751bd803fbdade51d674598ed45da3d54190a656cJohn McCallpublic:
66851bd803fbdade51d674598ed45da3d54190a656cJohn McCall  SourceLocation getAmpAmpLoc() const {
66951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    return getSigilLoc();
670b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
67151bd803fbdade51d674598ed45da3d54190a656cJohn McCall  void setAmpAmpLoc(SourceLocation Loc) {
67251bd803fbdade51d674598ed45da3d54190a656cJohn McCall    setSigilLoc(Loc);
673b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
67451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
675b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
676b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
67734a0447b8072e0da14c0980597da9d03a1495662John McCallstruct FunctionLocInfo {
67834a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LParenLoc, RParenLoc;
679b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
680b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
681b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for functions.
68251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
68351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionTypeLoc,
68451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionType,
68551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               FunctionLocInfo> {
686b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  // ParmVarDecls* are stored after Info, one for each argument.
687b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  ParmVarDecl **getParmArray() const {
68834a0447b8072e0da14c0980597da9d03a1495662John McCall    return (ParmVarDecl**) getExtraLocalData();
689b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
690b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
691b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
692b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLParenLoc() const {
69334a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LParenLoc;
694b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
695b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLParenLoc(SourceLocation Loc) {
69634a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LParenLoc = Loc;
697b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
698b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
699b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRParenLoc() const {
70034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RParenLoc;
701b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
702b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRParenLoc(SourceLocation Loc) {
70334a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RParenLoc = Loc;
704b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
705b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
706b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  unsigned getNumArgs() const {
70734a0447b8072e0da14c0980597da9d03a1495662John McCall    if (isa<FunctionNoProtoType>(getTypePtr()))
708b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis      return 0;
70934a0447b8072e0da14c0980597da9d03a1495662John McCall    return cast<FunctionProtoType>(getTypePtr())->getNumArgs();
710b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
711b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  ParmVarDecl *getArg(unsigned i) const { return getParmArray()[i]; }
712b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setArg(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
713b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
714b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getArgLoc(unsigned i) const;
715b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
716b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getResultLoc() const {
71734a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
718b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
719b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
720b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceRange getSourceRange() const {
721b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLParenLoc(), getRParenLoc());
722b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
723b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
7244ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
7254ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLParenLoc(Loc);
7264ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRParenLoc(Loc);
7274ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
7284ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall      setArg(i, NULL);
7294ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
7304ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
731b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// \brief Returns the size of the type source info data block that is
732b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  /// specific to this type.
73334a0447b8072e0da14c0980597da9d03a1495662John McCall  unsigned getExtraLocalDataSize() const {
73434a0447b8072e0da14c0980597da9d03a1495662John McCall    return getNumArgs() * sizeof(ParmVarDecl*);
735b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
736b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
73734a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getResultType(); }
73834a0447b8072e0da14c0980597da9d03a1495662John McCall};
73934a0447b8072e0da14c0980597da9d03a1495662John McCall
74051bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionProtoTypeLoc :
74151bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
74251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoTypeLoc,
74351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionProtoType> {
74451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
74551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
74651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FunctionNoProtoTypeLoc :
74751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<FunctionTypeLoc,
74851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoTypeLoc,
74951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     FunctionNoProtoType> {
75051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
75151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
752b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
75334a0447b8072e0da14c0980597da9d03a1495662John McCallstruct ArrayLocInfo {
75434a0447b8072e0da14c0980597da9d03a1495662John McCall  SourceLocation LBracketLoc, RBracketLoc;
75534a0447b8072e0da14c0980597da9d03a1495662John McCall  Expr *Size;
756b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
757b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
758b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis/// \brief Wrapper for source info for arrays.
75951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
76051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayTypeLoc,
76151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayType,
76251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                            ArrayLocInfo> {
763b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidispublic:
764b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getLBracketLoc() const {
76534a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->LBracketLoc;
766b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
767b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setLBracketLoc(SourceLocation Loc) {
76834a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->LBracketLoc = Loc;
769b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
770b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
771b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceLocation getRBracketLoc() const {
77234a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->RBracketLoc;
773b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
774b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setRBracketLoc(SourceLocation Loc) {
77534a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->RBracketLoc = Loc;
776b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
777b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
77885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  SourceRange getBracketsRange() const {
77985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall    return SourceRange(getLBracketLoc(), getRBracketLoc());
78085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall  }
78185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall
782b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  Expr *getSizeExpr() const {
78334a0447b8072e0da14c0980597da9d03a1495662John McCall    return getLocalData()->Size;
784b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
785b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  void setSizeExpr(Expr *Size) {
78634a0447b8072e0da14c0980597da9d03a1495662John McCall    getLocalData()->Size = Size;
787b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
788b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
789b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  TypeLoc getElementLoc() const {
79034a0447b8072e0da14c0980597da9d03a1495662John McCall    return getInnerTypeLoc();
791b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
792b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
793b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  SourceRange getSourceRange() const {
794b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis    return SourceRange(getLBracketLoc(), getRBracketLoc());
795b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis  }
796b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
7974ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  void initializeLocal(SourceLocation Loc) {
7984ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setLBracketLoc(Loc);
7994ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setRBracketLoc(Loc);
8004ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall    setSizeExpr(NULL);
8014ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall  }
8024ce74bd425dccd9d9ad6ccfc9ffbc01698a6e71aJohn McCall
80334a0447b8072e0da14c0980597da9d03a1495662John McCall  QualType getInnerType() const { return getTypePtr()->getElementType(); }
804b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis};
805b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
80651bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ConstantArrayTypeLoc :
80751bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
80851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayTypeLoc,
80951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     ConstantArrayType> {
81051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
81151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
81251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass IncompleteArrayTypeLoc :
81351bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
81451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayTypeLoc,
81551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     IncompleteArrayType> {
81651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
81751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
81851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedArrayTypeLoc :
81951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
82051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayTypeLoc,
82151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     DependentSizedArrayType> {
82251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
82351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
82451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
82551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VariableArrayTypeLoc :
82651bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public InheritingConcreteTypeLoc<ArrayTypeLoc,
82751bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayTypeLoc,
82851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                     VariableArrayType> {
82951bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
83051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
831833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
832833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall// Location information for a TemplateName.  Rudimentary for now.
833833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateNameLocInfo {
834833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation NameLoc;
835833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
836833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
837833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallstruct TemplateSpecializationLocInfo : TemplateNameLocInfo {
838833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation LAngleLoc;
839833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation RAngleLoc;
840833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
841833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
842833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallclass TemplateSpecializationTypeLoc :
843833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    public ConcreteTypeLoc<UnqualTypeLoc,
844833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationTypeLoc,
845833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationType,
846833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall                           TemplateSpecializationLocInfo> {
847833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallpublic:
848833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getLAngleLoc() const {
849833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->LAngleLoc;
850833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
851833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setLAngleLoc(SourceLocation Loc) {
852833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->LAngleLoc = Loc;
853833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
854833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
855833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getRAngleLoc() const {
856833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->RAngleLoc;
857833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
858833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setRAngleLoc(SourceLocation Loc) {
859833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->RAngleLoc = Loc;
860833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
861833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
862833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getNumArgs() const {
863833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getTypePtr()->getNumArgs();
864833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
865833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
866833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#ifndef NDEBUG
867833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    AI.validateForArgument(getTypePtr()->getArg(i));
868833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#endif
869833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getArgInfos()[i] = AI;
870833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
871833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
872833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getArgInfos()[i];
873833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
874833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
875833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLoc getArgLoc(unsigned i) const {
876833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
877833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
878833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
879833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceLocation getTemplateNameLoc() const {
880833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getLocalData()->NameLoc;
881833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
882833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void setTemplateNameLoc(SourceLocation Loc) {
883833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    getLocalData()->NameLoc = Loc;
884833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
885833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
886833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  /// \brief - Copy the location information from the given info.
887833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void copy(TemplateSpecializationTypeLoc Loc) {
888833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    unsigned size = getFullDataSize();
889833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    assert(size == Loc.getFullDataSize());
890833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
891833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // We're potentially copying Expr references here.  We don't
892833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // bother retaining them because DeclaratorInfos live forever, so
893833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // as long as the Expr was retained when originally written into
894833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    // the TypeLoc, we're okay.
895833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    memcpy(Data, Loc.Data, size);
896833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
897833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
898833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  SourceRange getSourceRange() const {
899833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return SourceRange(getTemplateNameLoc(), getRAngleLoc());
900833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
901833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
902833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  void initializeLocal(SourceLocation Loc) {
903833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setLAngleLoc(Loc);
904833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setRAngleLoc(Loc);
905833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    setTemplateNameLoc(Loc);
906833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
907828bff2079b6a91ecd7ed5b842c59527d7682789John McCall    for (unsigned i = 0, e = getNumArgs(); i != e; ++i) {
908cbe12738371bec6ff20372e1d3426cffc85d8323John McCall      TemplateArgumentLocInfo Info;
909828bff2079b6a91ecd7ed5b842c59527d7682789John McCall#ifndef NDEBUG
910828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      // If asserts are enabled, be sure to initialize the argument
911828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      // loc with the right kind of pointer.
912828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      switch (getTypePtr()->getArg(i).getKind()) {
913828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Expression:
914828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Declaration:
915828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        Info = TemplateArgumentLocInfo((Expr*) 0);
916828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        break;
917828bff2079b6a91ecd7ed5b842c59527d7682789John McCall
918828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Type:
919828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        Info = TemplateArgumentLocInfo((DeclaratorInfo*) 0);
920828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        break;
921828bff2079b6a91ecd7ed5b842c59527d7682789John McCall
922788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor      case TemplateArgument::Template:
923788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor        Info = TemplateArgumentLocInfo(SourceRange(), SourceLocation());
924788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor        break;
925788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor
926828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Integral:
927828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Pack:
928828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      case TemplateArgument::Null:
929828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        // K_None is fine.
930828bff2079b6a91ecd7ed5b842c59527d7682789John McCall        break;
931828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      }
932828bff2079b6a91ecd7ed5b842c59527d7682789John McCall#endif
933828bff2079b6a91ecd7ed5b842c59527d7682789John McCall      getArgInfos()[i] = Info;
934828bff2079b6a91ecd7ed5b842c59527d7682789John McCall    }
935833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
936833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
937833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  unsigned getExtraLocalDataSize() const {
938833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return getNumArgs() * sizeof(TemplateArgumentLocInfo);
939833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
940833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
941833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallprivate:
942833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  TemplateArgumentLocInfo *getArgInfos() const {
943833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall    return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
944833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  }
945833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall};
946833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall
94751bd803fbdade51d674598ed45da3d54190a656cJohn McCall// None of these types have proper implementations yet.
94851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
94951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass VectorTypeLoc : public TypeSpecTypeLoc<VectorTypeLoc, VectorType> {
95051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
95151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
95251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
95351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorTypeLoc,
95451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                          ExtVectorType> {
95551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
95651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
95751bd803fbdade51d674598ed45da3d54190a656cJohn McCall// For some reason, this isn't a subtype of VectorType.
95851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DependentSizedExtVectorTypeLoc :
95951bd803fbdade51d674598ed45da3d54190a656cJohn McCall    public TypeSpecTypeLoc<DependentSizedExtVectorTypeLoc,
96051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                           DependentSizedExtVectorType> {
96151bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
96251bd803fbdade51d674598ed45da3d54190a656cJohn McCall
96351bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass FixedWidthIntTypeLoc : public TypeSpecTypeLoc<FixedWidthIntTypeLoc,
96451bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                    FixedWidthIntType> {
96551bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
96651bd803fbdade51d674598ed45da3d54190a656cJohn McCall
96751bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ComplexTypeLoc : public TypeSpecTypeLoc<ComplexTypeLoc,
96851bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                              ComplexType> {
96951bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
97051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
97151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TypeOfExprTypeLoc : public TypeSpecTypeLoc<TypeOfExprTypeLoc,
97251bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 TypeOfExprType> {
97351bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
97451bd803fbdade51d674598ed45da3d54190a656cJohn McCall
97551bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TypeOfTypeLoc : public TypeSpecTypeLoc<TypeOfTypeLoc, TypeOfType> {
97651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
97751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
97851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass DecltypeTypeLoc : public TypeSpecTypeLoc<DecltypeTypeLoc, DecltypeType> {
97951bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
98051bd803fbdade51d674598ed45da3d54190a656cJohn McCall
98151bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TagTypeLoc : public TypeSpecTypeLoc<TagTypeLoc, TagType> {
98251bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
98351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
98451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
98551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                       RecordTypeLoc,
98651bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                       RecordType> {
98751bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
98851bd803fbdade51d674598ed45da3d54190a656cJohn McCall
98951bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
99051bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                     EnumTypeLoc,
99151bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                     EnumType> {
99251bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
99351bd803fbdade51d674598ed45da3d54190a656cJohn McCall
99451bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass ElaboratedTypeLoc : public TypeSpecTypeLoc<ElaboratedTypeLoc,
99551bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                 ElaboratedType> {
99651bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
99751bd803fbdade51d674598ed45da3d54190a656cJohn McCall
99851bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass QualifiedNameTypeLoc : public TypeSpecTypeLoc<QualifiedNameTypeLoc,
99951bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                                    QualifiedNameType> {
100051bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
100151bd803fbdade51d674598ed45da3d54190a656cJohn McCall
100251bd803fbdade51d674598ed45da3d54190a656cJohn McCallclass TypenameTypeLoc : public TypeSpecTypeLoc<TypenameTypeLoc,
100351bd803fbdade51d674598ed45da3d54190a656cJohn McCall                                               TypenameType> {
100451bd803fbdade51d674598ed45da3d54190a656cJohn McCall};
100551bd803fbdade51d674598ed45da3d54190a656cJohn McCall
1006b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis}
1007b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis
1008b17166c8077cd900cca83a895c43b30ea6660598Argyrios Kyrtzidis#endif
1009