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

Function GetScope

InsightsHelpers.cpp:413–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411//-----------------------------------------------------------------------------
412
413static std::string GetScope(const DeclContext* declCtx,
414 const RemoveCurrentScope removeCurrentScope = RemoveCurrentScope::Yes)
415{
416 std::string name{};
417
418 if(not declCtx->isTranslationUnit() and not declCtx->isFunctionOrMethod()) {
419 while(declCtx->isInlineNamespace()) {
420 declCtx = declCtx->getParent();
421 }
422
423 if(not declCtx->isTranslationUnit() and (declCtx->isNamespace() or declCtx->getParent()->isTranslationUnit())) {
424 if(const auto* namedDecl = dyn_cast_or_null<NamedDecl>(declCtx)) {
425 name = GetQualifiedName(*namedDecl, removeCurrentScope);
426 name.append("::"sv);
427 }
428 }
429 }
430
431 return name;
432}
433//-----------------------------------------------------------------------------
434
435/// \brief SimpleTypePrinter a partially substitution of Clang's TypePrinter.

Callers 2

HandleTypeMethod · 0.85
GetNameFunction · 0.85

Calls 1

GetQualifiedNameFunction · 0.85

Tested by

no test coverage detected