15 #ifndef LLVM_CLANG_LIB_PARSE_RAIIOBJECTSFORPARSER_H
16 #define LLVM_CLANG_LIB_PARSE_RAIIOBJECTSFORPARSER_H
53 : S(P.getActions()), DiagnosticPool(nullptr) {
62 : S(Other.S), DiagnosticPool(std::move(Other.DiagnosticPool)),
63 State(Other.State), Active(Other.Active) {
69 assert(Active &&
"trying to end an inactive suppression");
75 assert(!Active &&
"redelaying without having ended first");
102 : Actions(P.getActions()), DiagnosticPool(nullptr) {
109 : Actions(P.getActions()), DiagnosticPool(parentPool) {
117 : Actions(P.getActions()),
118 DiagnosticPool(other ? other->DiagnosticPool.getParent() : nullptr) {
120 DiagnosticPool.
steal(other->DiagnosticPool);
131 return DiagnosticPool;
134 return DiagnosticPool;
150 assert(!Popped &&
"ParsingDeclaration has already been popped!");
184 ParsingRAII(P, RAII) {}
205 :
Declarator(DS, C), ParsingRAII(P, &DS.getDelayedDiagnosticPool()) {
232 :
FieldDeclarator(DS), ParsingRAII(P, &DS.getDelayedDiagnosticPool()) {
275 : P(p), OldVal(P.ColonIsSacred) {
276 P.ColonIsSacred =
Value;
282 P.ColonIsSacred = OldVal;
293 bool &GreaterThanIsOperator;
294 bool OldGreaterThanIsOperator;
297 : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) {
298 GreaterThanIsOperator = Val;
302 GreaterThanIsOperator = OldGreaterThanIsOperator;
307 bool &InMessageExpression;
312 : InMessageExpression(P.InMessageExpression),
313 OldValue(P.InMessageExpression) {
314 InMessageExpression =
Value;
318 InMessageExpression = OldValue;
326 unsigned short ParenCount, BracketCount, BraceCount;
329 : P(p), ParenCount(p.ParenCount), BracketCount(p.BracketCount),
330 BraceCount(p.BraceCount) { }
333 P.ParenCount = ParenCount;
334 P.BracketCount = BracketCount;
335 P.BraceCount = BraceCount;
351 : Ident_AbnormalTermination(Self.Ident_AbnormalTermination, NewValue),
352 Ident_GetExceptionCode(Self.Ident_GetExceptionCode, NewValue),
353 Ident_GetExceptionInfo(Self.Ident_GetExceptionInfo, NewValue),
354 Ident__abnormal_termination(Self.Ident__abnormal_termination, NewValue),
355 Ident__exception_code(Self.Ident__exception_code, NewValue),
356 Ident__exception_info(Self.Ident__exception_info, NewValue),
357 Ident___abnormal_termination(Self.Ident___abnormal_termination, NewValue),
358 Ident___exception_code(Self.Ident___exception_code, NewValue),
359 Ident___exception_info(Self.Ident___exception_info, NewValue) {
371 unsigned short &getDepth() {
373 case tok::l_brace:
return P.BraceCount;
374 case tok::l_square:
return P.BracketCount;
375 case tok::l_paren:
return P.ParenCount;
376 default: llvm_unreachable(
"Wrong token kind");
380 enum { MaxDepth = 256 };
382 bool diagnoseOverflow();
383 bool diagnoseMissingClose();
389 P(p),
Kind(k), FinalToken(FinalToken)
392 default: llvm_unreachable(
"Unexpected balanced token");
394 Close = tok::r_brace;
395 Consumer = &Parser::ConsumeBrace;
398 Close = tok::r_paren;
399 Consumer = &Parser::ConsumeParen;
403 Close = tok::r_square;
404 Consumer = &Parser::ConsumeBracket;
418 LOpen = (P.*Consumer)();
422 return diagnoseOverflow();
426 const char *Msg =
"",
429 if (P.Tok.
is(Close)) {
430 LClose = (P.*Consumer)();
434 P.
Diag(SemiLoc, diag::err_unexpected_semi)
436 LClose = (P.*Consumer)();
440 return diagnoseMissingClose();
SourceLocation getCloseLocation() const
void clear()
Reset the contents of this Declarator.
SuppressAccessChecks(SuppressAccessChecks &&Other)
const LangOptions & getLangOpts() const
ColonProtectionRAIIObject(Parser &p, bool Value=true)
RAII object used to inform the actions that we're currently parsing a declaration. This is active when parsing a variable's initializer, but not when parsing the body of a class or function definition.
A RAII object used to temporarily suppress access-like checking. Access-like checks are those associa...
Information about one declarator, including the parsed type information and the identifier.
ExtensionRAIIObject(DiagnosticsEngine &diags)
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
const ParsingDeclSpec & getDeclSpec() const
const Token & NextToken()
void operator=(SuppressAccessChecks &&Other)=delete
ParenBraceBracketBalancer(Parser &p)
~GreaterThanIsOperatorScope()
void IncrementAllExtensionsSilenced()
Counter bumped when an extension block is/ encountered.
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ParsingFieldDeclarator(Parser &P, const ParsingDeclSpec &DS)
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
SourceRange getRange() const
void reset()
Resets the RAII object for a new declaration.
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
Concrete class used by the front-end to report problems and issues.
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
GreaterThanIsOperatorScope(bool >IO, bool Val)
Sema - This implements semantic analysis and AST building for C.
A class for parsing a declarator.
ParsingDeclSpec(Parser &P, ParsingDeclRAIIObject *RAII)
ParsingDeclRAIIObject(Parser &P, const sema::DelayedDiagnosticPool *parentPool)
Creates a RAII object whose pool is optionally parented by another.
const ParsingDeclSpec & getDeclSpec() const
ParsingDeclRAIIObject(Parser &P, NoParent_t _)
~ColonProtectionRAIIObject()
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
ParsingDeclRAIIObject(Parser &P, ParsingDeclRAIIObject *other)
SuppressAccessChecks(Parser &P, bool activate=true)
Begin suppressing access-like checks.
A class for parsing a field declarator.
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a temp...
A class for parsing a DeclSpec.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
ParsingDeclSpec(Parser &P)
~ParenBraceBracketBalancer()
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
InMessageExpressionRAIIObject(Parser &P, bool Value)
bool is(tok::TokenKind K) const
ParsingDeclSpec & getMutableDeclSpec() const
SourceLocation getOpenLocation() const
ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, TheContext C)
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
static __inline__ uint32_t volatile uint32_t * p
BalancedDelimiterTracker(Parser &p, tok::TokenKind k, tok::TokenKind FinalToken=tok::semi)
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ParsingDeclSpec & getMutableDeclSpec() const
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
sema::DelayedDiagnosticPool & getDelayedDiagnosticPool()
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
~InMessageExpressionRAIIObject()
void DecrementAllExtensionsSilenced()
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
PoisonSEHIdentifiersRAIIObject(Parser &Self, bool NewValue)
A collection of diagnostics which were delayed.
A trivial tuple used to represent a source range.
An RAII object for [un]poisoning an identifier within a scope.
const DeclSpec & getDeclSpec() const