LocInfoType.h revision ba243b59a1074e0962f6abfa3bb9aa984eac1245
1//===--- LocInfoType.h - Parsed Type with Location Information---*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the LocInfoType class, which holds a type and its 11// source-location information. 12// 13//===----------------------------------------------------------------------===// 14#ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H 15#define LLVM_CLANG_SEMA_LOCINFOTYPE_H 16 17#include "clang/AST/Type.h" 18 19namespace clang { 20 21class TypeSourceInfo; 22 23/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator 24/// parsing. 25/// 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. 29class LocInfoType : public Type { 30 enum { 31 // The last number that can fit in Type's TC. 32 // Avoids conflict with an existing Type class. 33 LocInfo = Type::TypeLast + 1 34 }; 35 36 TypeSourceInfo *DeclInfo; 37 38 LocInfoType(QualType ty, TypeSourceInfo *TInfo) 39 : Type((TypeClass)LocInfo, ty, ty->isDependentType(), 40 ty->isInstantiationDependentType(), 41 ty->isVariablyModifiedType(), 42 ty->containsUnexpandedParameterPack()), 43 DeclInfo(TInfo) { 44 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); 45 } 46 friend class Sema; 47 48public: 49 QualType getType() const { return getCanonicalTypeInternal(); } 50 TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } 51 52 void getAsStringInternal(std::string &Str, 53 const PrintingPolicy &Policy) const; 54 55 static bool classof(const Type *T) { 56 return T->getTypeClass() == (TypeClass)LocInfo; 57 } 58 static bool classof(const LocInfoType *) { return true; } 59}; 60 61} // end namespace clang 62 63#endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H 64