clang API Documentation
00001 //===--- LocInfoType.h - Parsed Type with Location Information---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the LocInfoType class, which holds a type and its 00011 // source-location information. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 #ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H 00015 #define LLVM_CLANG_SEMA_LOCINFOTYPE_H 00016 00017 #include "clang/AST/Type.h" 00018 00019 namespace clang { 00020 00021 class TypeSourceInfo; 00022 00023 /// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator 00024 /// parsing. 00025 /// 00026 /// LocInfoType is a "transient" type, only needed for passing to/from Parser 00027 /// and Sema, when we want to preserve type source info for a parsed type. 00028 /// It will not participate in the type system semantics in any way. 00029 class LocInfoType : public Type { 00030 enum { 00031 // The last number that can fit in Type's TC. 00032 // Avoids conflict with an existing Type class. 00033 LocInfo = Type::TypeLast + 1 00034 }; 00035 00036 TypeSourceInfo *DeclInfo; 00037 00038 LocInfoType(QualType ty, TypeSourceInfo *TInfo) 00039 : Type((TypeClass)LocInfo, ty, ty->isDependentType(), 00040 ty->isInstantiationDependentType(), 00041 ty->isVariablyModifiedType(), 00042 ty->containsUnexpandedParameterPack()), 00043 DeclInfo(TInfo) { 00044 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); 00045 } 00046 friend class Sema; 00047 00048 public: 00049 QualType getType() const { return getCanonicalTypeInternal(); } 00050 TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } 00051 00052 void getAsStringInternal(std::string &Str, 00053 const PrintingPolicy &Policy) const; 00054 00055 static bool classof(const Type *T) { 00056 return T->getTypeClass() == (TypeClass)LocInfo; 00057 } 00058 }; 00059 00060 } // end namespace clang 00061 00062 #endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H