|
|
|||
File indexing completed on 2026-05-10 08:36:40
0001 //===--- QualTypeNames.h - Generate Complete QualType Names ----*- 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 // \file 0010 // Functionality to generate the fully-qualified names of QualTypes, 0011 // including recursively expanding any subtypes and template 0012 // parameters. 0013 // 0014 // More precisely: Generates a name that can be used to name the same 0015 // type if used at the end of the current translation unit--with 0016 // certain limitations. See below. 0017 // 0018 // This code desugars names only very minimally, so in this code: 0019 // 0020 // namespace A { 0021 // struct X {}; 0022 // } 0023 // using A::X; 0024 // namespace B { 0025 // using std::tuple; 0026 // typedef tuple<X> TX; 0027 // TX t; 0028 // } 0029 // 0030 // B::t's type is reported as "B::TX", rather than std::tuple<A::X>. 0031 // 0032 // Also, this code replaces types found via using declarations with 0033 // their more qualified name, so for the code: 0034 // 0035 // using std::tuple; 0036 // tuple<int> TInt; 0037 // 0038 // TInt's type will be named, "std::tuple<int>". 0039 // 0040 // Limitations: 0041 // 0042 // Some types have ambiguous names at the end of a translation unit, 0043 // are not namable at all there, or are special cases in other ways. 0044 // 0045 // 1) Types with only local scope will have their local names: 0046 // 0047 // void foo() { 0048 // struct LocalType {} LocalVar; 0049 // } 0050 // 0051 // LocalVar's type will be named, "struct LocalType", without any 0052 // qualification. 0053 // 0054 // 2) Types that have been shadowed are reported normally, but a 0055 // client using that name at the end of the translation unit will be 0056 // referring to a different type. 0057 // 0058 // ===----------------------------------------------------------------------===// 0059 0060 #ifndef LLVM_CLANG_AST_QUALTYPENAMES_H 0061 #define LLVM_CLANG_AST_QUALTYPENAMES_H 0062 0063 #include "clang/AST/ASTContext.h" 0064 0065 namespace clang { 0066 namespace TypeName { 0067 /// Get the fully qualified name for a type. This includes full 0068 /// qualification of all template parameters etc. 0069 /// 0070 /// \param[in] QT - the type for which the fully qualified name will be 0071 /// returned. 0072 /// \param[in] Ctx - the ASTContext to be used. 0073 /// \param[in] WithGlobalNsPrefix - If true, then the global namespace 0074 /// specifier "::" will be prepended to the fully qualified name. 0075 std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, 0076 const PrintingPolicy &Policy, 0077 bool WithGlobalNsPrefix = false); 0078 0079 /// Generates a QualType that can be used to name the same type 0080 /// if used at the end of the current translation unit. This ignores 0081 /// issues such as type shadowing. 0082 /// 0083 /// \param[in] QT - the type for which the fully qualified type will be 0084 /// returned. 0085 /// \param[in] Ctx - the ASTContext to be used. 0086 /// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace 0087 /// specifier "::" should be prepended or not. 0088 QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, 0089 bool WithGlobalNsPrefix = false); 0090 } // end namespace TypeName 0091 } // end namespace clang 0092 #endif // LLVM_CLANG_AST_QUALTYPENAMES_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|