16 using namespace clang;
17 using namespace clang::tooling;
23 while (DeclA && !isa<NamespaceDecl>(DeclA))
27 while (DeclB && !isa<NamespaceDecl>(DeclB))
40 if (cast<NamespaceDecl>(DeclA)->getDeclName() ==
41 cast<NamespaceDecl>(DeclB)->getDeclName())
51 bool HadLeadingColonColon) {
53 while (DeclA && !isa<NamespaceDecl>(DeclA))
58 return HadLeadingColonColon ? NewName : NewName.substr(2);
64 "::" + cast<NamespaceDecl>(DeclA)->getQualifiedNameAsString() +
"::";
65 if (NewName.startswith(NS))
66 return NewName.substr(NS.size());
88 StringRef ReplacementString) {
89 assert(ReplacementString.startswith(
"::") &&
90 "Expected fully-qualified name!");
97 const bool class_name_only = !Use;
98 const bool in_global_namespace =
99 isa<TranslationUnitDecl>(FromDecl->getDeclContext());
100 if (class_name_only && !in_global_namespace &&
103 auto Pos = ReplacementString.rfind(
"::");
104 return Pos != StringRef::npos ? ReplacementString.substr(Pos + 2)
static bool isFullyQualified(const NestedNameSpecifier *NNS)
Check if the name specifier begins with a written "::".
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
static StringRef getBestNamespaceSubstr(const DeclContext *DeclA, StringRef NewName, bool HadLeadingColonColon)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool isInsideDifferentNamespaceWithSameName(const DeclContext *DeclA, const DeclContext *DeclB)
NamedDecl - This represents a decl with a name.
The global specifier '::'. There is no stored value.