;
32 autoGetNextNamedNamespace = [](
const DeclContext*Context) {
34 while(Context && (!isa<NamespaceDecl>(Context) ||
35cast<NamespaceDecl>(Context)->isAnonymousNamespace()))
36Context = Context->getParent();
39 for(Context = GetNextNamedNamespace(Context); Context !=
nullptr;
40Context = GetNextNamedNamespace(Context->getParent()))
41Namespaces.push_back(cast<NamespaceDecl>(Context));
62 if(UseNamespaces.size() < FromNamespaces.size())
64 unsignedDiff = UseNamespaces.size() - FromNamespaces.size();
65 autoFromIter = FromNamespaces.begin();
69 autoUseIter = UseNamespaces.begin() + Diff;
70 for(; FromIter != FromNamespaces.end() && UseIter != UseNamespaces.end();
71++FromIter, ++UseIter) {
73 if(*FromIter == *UseIter)
77 if(cast<NamespaceDecl>(*FromIter)->getDeclName() ==
78cast<NamespaceDecl>(*UseIter)->getDeclName())
81assert(FromIter == FromNamespaces.end() && UseIter == UseNamespaces.end());
87 boolHadLeadingColonColon) {
89 while(DeclA && !isa<NamespaceDecl>(DeclA))
94 returnHadLeadingColonColon ? NewName : NewName.substr(2);
100 "::"+ cast<NamespaceDecl>(DeclA)->getQualifiedNameAsString() +
"::";
101 if(NewName.consume_front(NS))
131assert(QName.starts_with(
"::"));
132assert(QName.ends_with(Spelling));
133 if(Spelling.starts_with(
"::"))
134 returnstd::string(Spelling);
136 autoUnspelledSpecifier = QName.drop_back(Spelling.size());
138UnspelledSpecifier.split(UnspelledScopes,
"::",
-1,
144StringRef TrimmedQName = QName.substr(2);
146UseLoc =
SM.getSpellingLoc(UseLoc);
148 autoIsAmbiguousSpelling = [&](
constllvm::StringRef CurSpelling) {
149 if(CurSpelling.starts_with(
"::"))
154StringRef Head = CurSpelling.split(
"::").first;
155 for(
const auto*NS : EnclosingNamespaces) {
157 if(!LookupRes.empty()) {
163 if(!TrimmedQName.starts_with(Res->getQualifiedNameAsString()) &&
164 SM.isBeforeInTranslationUnit(
165 SM.getSpellingLoc(Res->getLocation()), UseLoc))
173std::string Disambiguated = std::string(Spelling);
174 while(IsAmbiguousSpelling(Disambiguated)) {
175 if(UnspelledScopes.empty()) {
176Disambiguated =
"::"+ Disambiguated;
178Disambiguated = (UnspelledScopes.back() +
"::"+ Disambiguated).str();
179UnspelledScopes.pop_back();
182 returnDisambiguated;
189StringRef ReplacementString) {
190assert(ReplacementString.starts_with(
"::") &&
191 "Expected fully-qualified name!");
201 const boolclass_name_only = !Use;
202 const boolin_global_namespace =
204 const boolis_class_forward_decl =
206!cast<CXXRecordDecl>(
FromDecl)->isCompleteDefinition();
207 if(class_name_only && !in_global_namespace && !is_class_forward_decl &&
210 autoPos = ReplacementString.rfind(
"::");
211 returnstd::string(Pos != StringRef::npos
212? ReplacementString.substr(Pos + 2)
213: ReplacementString);
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static llvm::SmallVector< const NamespaceDecl *, 4 > getAllNamedNamespaces(const DeclContext *Context)
static bool usingFromDifferentCanonicalNamespace(const DeclContext *FromContext, const DeclContext *UseContext)
static StringRef getBestNamespaceSubstr(const DeclContext *DeclA, StringRef NewName, bool HadLeadingColonColon)
static std::string disambiguateSpellingInScope(StringRef Spelling, StringRef QName, const DeclContext &UseContext, SourceLocation UseLoc)
static bool isFullyQualified(const NestedNameSpecifier *NNS)
Check if the name specifier begins with a written "::".
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
const NamedDecl * FromDecl
SourceManager & getSourceManager()
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ASTContext & getParentASTContext() const
DeclContext * getDeclContext()
The name of a declaration.
This represents a decl that may have a name.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
@ Global
The global specifier '::'. There is no stored value.
Encodes a location in the source.
The JSON file list parser is used to communicate input to InstallAPI.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4