]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/LocInfoType.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / LocInfoType.h
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
19 namespace clang {
20
21 class TypeSourceInfo;
22
23 /// 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.
29 class 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(), ty->isVariablyModifiedType(),
41              ty->containsUnexpandedParameterPack()),
42         DeclInfo(TInfo) {
43     assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
44   }
45   friend class Sema;
46
47 public:
48   QualType getType() const { return getCanonicalTypeInternal(); }
49   TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
50
51   void getAsStringInternal(std::string &Str,
52                            const PrintingPolicy &Policy) const;
53
54   static bool classof(const Type *T) {
55     return T->getTypeClass() == (TypeClass)LocInfo;
56   }
57 };
58
59 } // end namespace clang
60
61 #endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H