Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:38

0001 //===--- LocInfoType.h - Parsed Type with Location Information---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the LocInfoType class, which holds a type and its
0010 // source-location information.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 #ifndef LLVM_CLANG_AST_LOCINFOTYPE_H
0014 #define LLVM_CLANG_AST_LOCINFOTYPE_H
0015 
0016 #include "clang/AST/Type.h"
0017 
0018 namespace clang {
0019 
0020 class TypeSourceInfo;
0021 
0022 /// Holds a QualType and a TypeSourceInfo* that came out of a declarator
0023 /// parsing.
0024 ///
0025 /// LocInfoType is a "transient" type, only needed for passing to/from Parser
0026 /// and Sema, when we want to preserve type source info for a parsed type.
0027 /// It will not participate in the type system semantics in any way.
0028 class LocInfoType : public Type {
0029   enum {
0030     // The last number that can fit in Type's TC.
0031     // Avoids conflict with an existing Type class.
0032     LocInfo = Type::TypeLast + 1
0033   };
0034 
0035   TypeSourceInfo *DeclInfo;
0036 
0037   LocInfoType(QualType ty, TypeSourceInfo *TInfo)
0038       : Type((TypeClass)LocInfo, ty, ty->getDependence()), DeclInfo(TInfo) {
0039     assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
0040   }
0041   friend class Sema;
0042 
0043 public:
0044   QualType getType() const { return getCanonicalTypeInternal(); }
0045   TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
0046 
0047   void getAsStringInternal(std::string &Str,
0048                            const PrintingPolicy &Policy) const;
0049 
0050   static bool classof(const Type *T) {
0051     return T->getTypeClass() == (TypeClass)LocInfo;
0052   }
0053 };
0054 
0055 } // end namespace clang
0056 
0057 #endif // LLVM_CLANG_AST_LOCINFOTYPE_H