forked from llvm-mirror/clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tooling functionality to get a name for a QualType that can be us…
…ed to name that type from the global scope. Patch by Sterling Augustine, derived (with permission) from code from Cling by Vassil Vassilev and Philippe Canal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260278 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
5 changed files
with
676 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
//===--- QualTypeNames.h - Generate Complete QualType Names ----*- C++ -*-===// | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
// ===----------------------------------------------------------------------===// | ||
// | ||
// \file | ||
// Functionality to generate the fully-qualified names of QualTypes, | ||
// including recursively expanding any subtypes and template | ||
// parameters. | ||
// | ||
// More precisely: Generates a name that can be used to name the same | ||
// type if used at the end of the current translation unit--with | ||
// certain limitations. See below. | ||
// | ||
// This code desugars names only very minimally, so in this code: | ||
// | ||
// namespace A { | ||
// struct X {}; | ||
// } | ||
// using A::X; | ||
// namespace B { | ||
// using std::tuple; | ||
// typedef tuple<X> TX; | ||
// TX t; | ||
// } | ||
// | ||
// B::t's type is reported as "B::TX", rather than std::tuple<A::X>. | ||
// | ||
// Also, this code replaces types found via using declarations with | ||
// their more qualified name, so for the code: | ||
// | ||
// using std::tuple; | ||
// tuple<int> TInt; | ||
// | ||
// TInt's type will be named, "std::tuple<int>". | ||
// | ||
// Limitations: | ||
// | ||
// Some types have ambiguous names at the end of a translation unit, | ||
// are not namable at all there, or are special cases in other ways. | ||
// | ||
// 1) Types with only local scope will have their local names: | ||
// | ||
// void foo() { | ||
// struct LocalType {} LocalVar; | ||
// } | ||
// | ||
// LocalVar's type will be named, "struct LocalType", without any | ||
// qualification. | ||
// | ||
// 2) Types that have been shadowed are reported normally, but a | ||
// client using that name at the end of the translation unit will be | ||
// referring to a different type. | ||
// | ||
// ===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H | ||
#define LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H | ||
|
||
#include "clang/AST/ASTContext.h" | ||
|
||
namespace clang { | ||
namespace TypeName { | ||
/// \brief Get the fully qualified name for a type. This includes full | ||
/// qualification of all template parameters etc. | ||
/// | ||
/// \param[in] QT - the type for which the fully qualified name will be | ||
/// returned. | ||
/// \param[in] Ctx - the ASTContext to be used. | ||
std::string getFullyQualifiedName(QualType QT, | ||
const ASTContext &Ctx); | ||
} // end namespace TypeName | ||
} // end namespace clang | ||
#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.