1 //===--- QualTypeNames.h - Generate Complete QualType Names ----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 // ===----------------------------------------------------------------------===//
10 // Functionality to generate the fully-qualified names of QualTypes,
11 // including recursively expanding any subtypes and template
14 // More precisely: Generates a name that can be used to name the same
15 // type if used at the end of the current translation unit--with
16 // certain limitations. See below.
18 // This code desugars names only very minimally, so in this code:
26 // typedef tuple<X> TX;
30 // B::t's type is reported as "B::TX", rather than std::tuple<A::X>.
32 // Also, this code replaces types found via using declarations with
33 // their more qualified name, so for the code:
38 // TInt's type will be named, "std::tuple<int>".
42 // Some types have ambiguous names at the end of a translation unit,
43 // are not namable at all there, or are special cases in other ways.
45 // 1) Types with only local scope will have their local names:
48 // struct LocalType {} LocalVar;
51 // LocalVar's type will be named, "struct LocalType", without any
54 // 2) Types that have been shadowed are reported normally, but a
55 // client using that name at the end of the translation unit will be
56 // referring to a different type.
58 // ===----------------------------------------------------------------------===//
60 #ifndef LLVM_CLANG_AST_QUALTYPENAMES_H
61 #define LLVM_CLANG_AST_QUALTYPENAMES_H
63 #include "clang/AST/ASTContext.h"
67 /// Get the fully qualified name for a type. This includes full
68 /// qualification of all template parameters etc.
70 /// \param[in] QT - the type for which the fully qualified name will be
72 /// \param[in] Ctx - the ASTContext to be used.
73 /// \param[in] WithGlobalNsPrefix - If true, then the global namespace
74 /// specifier "::" will be prepended to the fully qualified name.
75 std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx,
76 const PrintingPolicy &Policy,
77 bool WithGlobalNsPrefix = false);
79 /// Generates a QualType that can be used to name the same type
80 /// if used at the end of the current translation unit. This ignores
81 /// issues such as type shadowing.
83 /// \param[in] QT - the type for which the fully qualified type will be
85 /// \param[in] Ctx - the ASTContext to be used.
86 /// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace
87 /// specifier "::" should be prepended or not.
88 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
89 bool WithGlobalNsPrefix = false);
90 } // end namespace TypeName
91 } // end namespace clang
92 #endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H