clang 20.0.0git
Public Member Functions | List of all members
clang::VariadicMacroScopeGuard Class Reference

An RAII class that tracks when the Preprocessor starts and stops lexing the definition of a (ISO C/C++) variadic macro. More...

#include "clang/Lex/VariadicMacroSupport.h"

Public Member Functions

 VariadicMacroScopeGuard (const Preprocessor &P)
 
void enterScope ()
 Client code should call this function just before the Preprocessor is about to Lex tokens from the definition of a variadic (ISO C/C++) macro.
 
void exitScope ()
 Client code should call this function as soon as the Preprocessor has either completed lexing the macro's definition tokens, or an error occurred and the context is being exited.
 
 ~VariadicMacroScopeGuard ()
 

Detailed Description

An RAII class that tracks when the Preprocessor starts and stops lexing the definition of a (ISO C/C++) variadic macro.

As an example, this is useful for unpoisoning and repoisoning certain identifiers (such as VA_ARGS) that are only allowed in this context. Also, being a friend of the Preprocessor class allows it to access PP's cached identifiers directly (as opposed to performing a lookup each time).

Definition at line 30 of file VariadicMacroSupport.h.

Constructor & Destructor Documentation

◆ VariadicMacroScopeGuard()

clang::VariadicMacroScopeGuard::VariadicMacroScopeGuard ( const Preprocessor P)
inline

Definition at line 36 of file VariadicMacroSupport.h.

References clang::IdentifierInfo::isPoisoned().

◆ ~VariadicMacroScopeGuard()

clang::VariadicMacroScopeGuard::~VariadicMacroScopeGuard ( )
inline

Definition at line 61 of file VariadicMacroSupport.h.

References exitScope().

Member Function Documentation

◆ enterScope()

void clang::VariadicMacroScopeGuard::enterScope ( )
inline

Client code should call this function just before the Preprocessor is about to Lex tokens from the definition of a variadic (ISO C/C++) macro.

Definition at line 47 of file VariadicMacroSupport.h.

References clang::IdentifierInfo::setIsPoisoned().

◆ exitScope()

void clang::VariadicMacroScopeGuard::exitScope ( )
inline

Client code should call this function as soon as the Preprocessor has either completed lexing the macro's definition tokens, or an error occurred and the context is being exited.

This function is idempotent (might be explicitly called, and then reinvoked via the destructor).

Definition at line 56 of file VariadicMacroSupport.h.

References clang::IdentifierInfo::setIsPoisoned().

Referenced by ~VariadicMacroScopeGuard().


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