clang
3.9.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
llvm.src
tools
clang
include
clang
Tooling
Core
QualTypeNames.h
Go to the documentation of this file.
1
//===--- QualTypeNames.h - Generate Complete QualType Names ----*- C++ -*-===//
2
//
3
// This file is distributed under the University of Illinois Open Source
4
// License. See LICENSE.TXT for details.
5
//
6
// ===----------------------------------------------------------------------===//
7
//
8
// \file
9
// Functionality to generate the fully-qualified names of QualTypes,
10
// including recursively expanding any subtypes and template
11
// parameters.
12
//
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.
16
//
17
// This code desugars names only very minimally, so in this code:
18
//
19
// namespace A {
20
// struct X {};
21
// }
22
// using A::X;
23
// namespace B {
24
// using std::tuple;
25
// typedef tuple<X> TX;
26
// TX t;
27
// }
28
//
29
// B::t's type is reported as "B::TX", rather than std::tuple<A::X>.
30
//
31
// Also, this code replaces types found via using declarations with
32
// their more qualified name, so for the code:
33
//
34
// using std::tuple;
35
// tuple<int> TInt;
36
//
37
// TInt's type will be named, "std::tuple<int>".
38
//
39
// Limitations:
40
//
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.
43
//
44
// 1) Types with only local scope will have their local names:
45
//
46
// void foo() {
47
// struct LocalType {} LocalVar;
48
// }
49
//
50
// LocalVar's type will be named, "struct LocalType", without any
51
// qualification.
52
//
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.
56
//
57
// ===----------------------------------------------------------------------===//
58
59
#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
60
#define LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
61
62
#include "
clang/AST/ASTContext.h
"
63
64
namespace
clang {
65
namespace
TypeName {
66
/// \brief Get the fully qualified name for a type. This includes full
67
/// qualification of all template parameters etc.
68
///
69
/// \param[in] QT - the type for which the fully qualified name will be
70
/// returned.
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,
75
const
ASTContext
&Ctx,
76
bool
WithGlobalNsPrefix =
false
);
77
}
// end namespace TypeName
78
}
// end namespace clang
79
#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
ASTContext.h
Defines the clang::ASTContext interface.
clang::QualType
A (possibly-)qualified type.
Definition:
Type.h:598
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition:
ASTContext.h:92
clang::TypeName::getFullyQualifiedName
std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Get the fully qualified name for a type.
Definition:
QualTypeNames.cpp:466
Generated on Wed Aug 31 2016 16:58:10 for clang by
1.8.6