1 //===--- LocInfoType.h - Parsed Type with Location Information---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the LocInfoType class, which holds a type and its
11 // source-location information.
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H
15 #define LLVM_CLANG_SEMA_LOCINFOTYPE_H
17 #include "clang/AST/Type.h"
23 /// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
26 /// LocInfoType is a "transient" type, only needed for passing to/from Parser
27 /// and Sema, when we want to preserve type source info for a parsed type.
28 /// It will not participate in the type system semantics in any way.
29 class LocInfoType : public Type {
31 // The last number that can fit in Type's TC.
32 // Avoids conflict with an existing Type class.
33 LocInfo = Type::TypeLast + 1
36 TypeSourceInfo *DeclInfo;
38 LocInfoType(QualType ty, TypeSourceInfo *TInfo)
39 : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
40 ty->isInstantiationDependentType(),
41 ty->isVariablyModifiedType(),
42 ty->containsUnexpandedParameterPack()),
44 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
49 QualType getType() const { return getCanonicalTypeInternal(); }
50 TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
52 void getAsStringInternal(std::string &Str,
53 const PrintingPolicy &Policy) const;
55 static bool classof(const Type *T) {
56 return T->getTypeClass() == (TypeClass)LocInfo;
60 } // end namespace clang
62 #endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H