MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / BuildNamespace

Function BuildNamespace

InsightsHelpers.cpp:166–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165namespace details {
166static void
167BuildNamespace(std::string& fullNamespace, const NestedNameSpecifier* stmt, const IgnoreNamespace ignoreNamespace)
168{
169 RETURN_IF(not stmt);
170
171 if(const auto* prefix = stmt->getPrefix()) {
172 BuildNamespace(fullNamespace, prefix, ignoreNamespace);
173 }
174
175 switch(stmt->getKind()) {
176 case NestedNameSpecifier::Identifier: fullNamespace.append(stmt->getAsIdentifier()->getName()); break;
177
178 case NestedNameSpecifier::Namespace:
179 RETURN_IF((IgnoreNamespace::Yes == ignoreNamespace) or (stmt->getAsNamespace()->isAnonymousNamespace()));
180
181 fullNamespace.append(stmt->getAsNamespace()->getName());
182 break;
183
184 case NestedNameSpecifier::NamespaceAlias: fullNamespace.append(stmt->getAsNamespaceAlias()->getName()); break;
185#if IS_CLANG_NEWER_THAN(20)
186#else
187 case NestedNameSpecifier::TypeSpecWithTemplate:
188 if(auto* dependentSpecType = stmt->getAsType()->getAs<DependentTemplateSpecializationType>()) {
189 fullNamespace.append(GetElaboratedTypeKeyword(dependentSpecType->getKeyword()));
190 }
191
192 [[fallthrough]];
193#endif
194 case NestedNameSpecifier::TypeSpec:
195 fullNamespace.append(GetUnqualifiedScopelessName(stmt->getAsType(), InsightsSuppressScope::Yes));
196 // The template parameters are already contained in the type we inserted above.
197 break;
198
199 default: break;
200 }
201
202 fullNamespace.append("::"sv);
203}
204//-----------------------------------------------------------------------------
205} // namespace details
206

Callers 1

GetNestedNameFunction · 0.85

Calls 3

GetElaboratedTypeKeywordFunction · 0.85
getNameMethod · 0.80

Tested by

no test coverage detected