Public Member Functions | Public Attributes | List of all members
clang::insights::ScopeHelper Struct Reference

Track the scope we are currently in to build a properly scoped variable. More...

#include "InsightsHelpers.h"

Inheritance diagram for clang::insights::ScopeHelper:
Inheritance graph
[legend]
Collaboration diagram for clang::insights::ScopeHelper:
Collaboration graph
[legend]

Public Member Functions

 ScopeHelper (const size_t len)
 

Public Attributes

const size_t mLength
 Length of the scope as it was before this declaration was appended. More...
 
- Public Attributes inherited from StackListEntry< ScopeHelper >
StackListEntrynext
 
StackListEntryprev
 

Detailed Description

Track the scope we are currently in to build a properly scoped variable.

The AST only knows about absolute scopes (namespace, struct, class), as once a declaration is parsed it is either in a scope or not. Each request to give me the namespace automatically leads to the entire scope the item is in. This makes it hard to have constructs like this:

struct One
{
static const int o{};
struct Two
{
static const int d = o;
};
static const int a = Two::d;
};

Here the initializer of a is in the scope One::Two::d. At this point the qualification Two::d is enought.

ScopeHelper tracks whether we are currently in a class or namespace and simply remove the path we already in from the scope.

Definition at line 247 of file InsightsHelpers.h.

Constructor & Destructor Documentation

◆ ScopeHelper()

clang::insights::ScopeHelper::ScopeHelper ( const size_t  len)
inline

Definition at line 249 of file InsightsHelpers.h.

Member Data Documentation

◆ mLength

const size_t clang::insights::ScopeHelper::mLength

Length of the scope as it was before this declaration was appended.

Definition at line 254 of file InsightsHelpers.h.


The documentation for this struct was generated from the following file: