1555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor//===--- LocInfoType.h - Parsed Type with Location Information---*- C++ -*-===// 2555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// 3555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// The LLVM Compiler Infrastructure 4555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// 5555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// This file is distributed under the University of Illinois Open Source 6555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// License. See LICENSE.TXT for details. 7555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// 8555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor//===----------------------------------------------------------------------===// 9555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// 10555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// This file defines the LocInfoType class, which holds a type and its 11555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// source-location information. 12555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor// 13555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor//===----------------------------------------------------------------------===// 14555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor#ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H 15555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor#define LLVM_CLANG_SEMA_LOCINFOTYPE_H 16555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 17555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor#include "clang/AST/Type.h" 18555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 19555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregornamespace clang { 20555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 21555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregorclass TypeSourceInfo; 22555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 23555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator 24555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// parsing. 25555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// 26555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// LocInfoType is a "transient" type, only needed for passing to/from Parser 27555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// and Sema, when we want to preserve type source info for a parsed type. 28555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor/// It will not participate in the type system semantics in any way. 29555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregorclass LocInfoType : public Type { 30555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor enum { 31555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor // The last number that can fit in Type's TC. 32555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor // Avoids conflict with an existing Type class. 33555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor LocInfo = Type::TypeLast + 1 34555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor }; 35555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 36555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor TypeSourceInfo *DeclInfo; 37555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 38555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor LocInfoType(QualType ty, TypeSourceInfo *TInfo) 39ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : Type((TypeClass)LocInfo, ty, ty->isDependentType(), 40561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor ty->isInstantiationDependentType(), 41555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor ty->isVariablyModifiedType(), 42ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ty->containsUnexpandedParameterPack()), 43ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie DeclInfo(TInfo) { 44ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); 45ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie } 46555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor friend class Sema; 47555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 48ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikiepublic: 49555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor QualType getType() const { return getCanonicalTypeInternal(); } 50555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } 51555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 52555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor void getAsStringInternal(std::string &Str, 53555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor const PrintingPolicy &Policy) const; 54555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 55555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor static bool classof(const Type *T) { 56555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor return T->getTypeClass() == (TypeClass)LocInfo; 57555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor } 58555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor}; 59555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 60555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor} // end namespace clang 61555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor 62555f57e3549fb5cc963a2ce38180c4f3643a6f95Douglas Gregor#endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H 63