1 //===--- QualTypeNames.h - Generate Complete QualType Names ----*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 // ===----------------------------------------------------------------------===//
9 // Functionality to generate the fully-qualified names of QualTypes,
10 // including recursively expanding any subtypes and template
13 // More precisely: Generates a name that can be used to name the same
14 // type if used at the end of the current translation unit--with
15 // certain limitations. See below.
17 // This code desugars names only very minimally, so in this code:
25 // typedef tuple<X> TX;
29 // B::t's type is reported as "B::TX", rather than std::tuple<A::X>.
31 // Also, this code replaces types found via using declarations with
32 // their more qualified name, so for the code:
37 // TInt's type will be named, "std::tuple<int>".
41 // Some types have ambiguous names at the end of a translation unit,
42 // are not namable at all there, or are special cases in other ways.
44 // 1) Types with only local scope will have their local names:
47 // struct LocalType {} LocalVar;
50 // LocalVar's type will be named, "struct LocalType", without any
53 // 2) Types that have been shadowed are reported normally, but a
54 // client using that name at the end of the translation unit will be
55 // referring to a different type.
57 // ===----------------------------------------------------------------------===//
59 #ifndef LLVM_CLANG_AST_QUALTYPENAMES_H
60 #define LLVM_CLANG_AST_QUALTYPENAMES_H
62 #include "clang/AST/ASTContext.h"
66 /// Get the fully qualified name for a type. This includes full
67 /// qualification of all template parameters etc.
69 /// \param[in] QT - the type for which the fully qualified name will be
71 /// \param[in] Ctx - the ASTContext to be used.
72 /// \param[in] WithGlobalNsPrefix - If true, then the global namespace
73 /// specifier "::" will be prepended to the fully qualified name.
74 std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx,
75 const PrintingPolicy &Policy,
76 bool WithGlobalNsPrefix = false);
78 /// Generates a QualType that can be used to name the same type
79 /// if used at the end of the current translation unit. This ignores
80 /// issues such as type shadowing.
82 /// \param[in] QT - the type for which the fully qualified type will be
84 /// \param[in] Ctx - the ASTContext to be used.
85 /// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace
86 /// specifier "::" should be prepended or not.
87 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
88 bool WithGlobalNsPrefix = false);
89 } // end namespace TypeName
90 } // end namespace clang
91 #endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H