14#ifndef LLVM_CLANG_PARSE_RAIIOBJECTSFORPARSER_H
15#define LLVM_CLANG_PARSE_RAIIOBJECTSFORPARSER_H
53 : S(
P.getActions()), DiagnosticPool(nullptr) {
55 State = S.PushParsingDeclaration(DiagnosticPool);
62 : S(
Other.S), DiagnosticPool(
std::move(
Other.DiagnosticPool)),
69 assert(Active &&
"trying to end an inactive suppression");
70 S.PopParsingDeclaration(State,
nullptr);
75 assert(!Active &&
"redelaying without having ended first");
77 S.redelayDiagnostics(DiagnosticPool);
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) {}
208 ParsingRAII(
P, &DS.getDelayedDiagnosticPool()) {}
236 ParsingRAII(
P, &DS.getDelayedDiagnosticPool()) {}
278 :
P(p), OldVal(
P.ColonIsSacred) {
285 P.ColonIsSacred = OldVal;
301 :
P(
P), OldVal(
P.OpenMPDirectiveParsing) {
302 P.OpenMPDirectiveParsing =
Value;
307 void restore() {
P.OpenMPDirectiveParsing = OldVal; }
320 :
P(
P), OldVal(
P.OpenACCDirectiveParsing) {
321 P.OpenACCDirectiveParsing =
Value;
326 void restore() {
P.OpenACCDirectiveParsing = OldVal; }
334 bool &GreaterThanIsOperator;
335 bool OldGreaterThanIsOperator;
338 : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) {
339 GreaterThanIsOperator = Val;
343 GreaterThanIsOperator = OldGreaterThanIsOperator;
348 bool &InMessageExpression;
353 : InMessageExpression(
P.InMessageExpression),
354 OldValue(
P.InMessageExpression) {
355 InMessageExpression =
Value;
359 InMessageExpression = OldValue;
369 : OffsetOfState(
P.OffsetOfState), OldValue(
P.OffsetOfState) {
370 OffsetOfState =
Value;
380 unsigned short ParenCount, BracketCount, BraceCount;
383 :
P(p), ParenCount(p.ParenCount), BracketCount(p.BracketCount),
384 BraceCount(p.BraceCount) { }
387 P.AngleBrackets.clear(
P);
388 P.ParenCount = ParenCount;
389 P.BracketCount = BracketCount;
390 P.BraceCount = BraceCount;
406 : Ident_AbnormalTermination(
Self.Ident_AbnormalTermination, NewValue),
407 Ident_GetExceptionCode(
Self.Ident_GetExceptionCode, NewValue),
408 Ident_GetExceptionInfo(
Self.Ident_GetExceptionInfo, NewValue),
409 Ident__abnormal_termination(
Self.Ident__abnormal_termination, NewValue),
410 Ident__exception_code(
Self.Ident__exception_code, NewValue),
411 Ident__exception_info(
Self.Ident__exception_info, NewValue),
412 Ident___abnormal_termination(
Self.Ident___abnormal_termination, NewValue),
413 Ident___exception_code(
Self.Ident___exception_code, NewValue),
414 Ident___exception_info(
Self.Ident___exception_info, NewValue) {
426 unsigned short &getDepth() {
428 case tok::l_brace:
return P.BraceCount;
429 case tok::l_square:
return P.BracketCount;
430 case tok::l_paren:
return P.ParenCount;
431 default: llvm_unreachable(
"Wrong token kind");
435 bool diagnoseOverflow();
436 bool diagnoseMissingClose();
442 P(p), Kind(k), FinalToken(FinalToken)
445 default: llvm_unreachable(
"Unexpected balanced token");
447 Close = tok::r_brace;
448 Consumer = &Parser::ConsumeBrace;
451 Close = tok::r_paren;
452 Consumer = &Parser::ConsumeParen;
456 Close = tok::r_square;
457 Consumer = &Parser::ConsumeBracket;
470 if (getDepth() <
P.getLangOpts().BracketDepth) {
471 LOpen = (
P.*Consumer)();
475 return diagnoseOverflow();
479 const char *Msg =
"",
482 if (
P.Tok.is(Close)) {
483 LClose = (
P.*Consumer)();
485 }
else if (
P.Tok.is(tok::semi) &&
P.NextToken().is(Close)) {
487 P.Diag(SemiLoc, diag::err_unexpected_semi)
489 LClose = (
P.*Consumer)();
493 return diagnoseMissingClose();
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
SourceLocation getOpenLocation() const
SourceRange getRange() const
BalancedDelimiterTracker(Parser &p, tok::TokenKind k, tok::TokenKind FinalToken=tok::semi)
SourceLocation getCloseLocation() const
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
void restore()
restore - This can be used to restore the state early, before the dtor is run.
ColonProtectionRAIIObject(Parser &p, bool Value=true)
~ColonProtectionRAIIObject()
Captures information about "declaration specifiers".
Decl - This represents one declaration (or definition), e.g.
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
void clear()
Reset the contents of this Declarator.
Concrete class used by the front-end to report problems and issues.
void DecrementAllExtensionsSilenced()
void IncrementAllExtensionsSilenced()
Counter bumped when an extension block is/ encountered.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
ExtensionRAIIObject(DiagnosticsEngine &diags)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a templat...
~GreaterThanIsOperatorScope()
GreaterThanIsOperatorScope(bool >IO, bool Val)
InMessageExpressionRAIIObject(Parser &P, bool Value)
~InMessageExpressionRAIIObject()
OffsetOfStateRAIIObject(Parser &P, Sema::OffsetOfKind Value)
~OffsetOfStateRAIIObject()
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
~ParenBraceBracketBalancer()
ParenBraceBracketBalancer(Parser &p)
ParsedAttributes - A collection of parsed attributes.
Parser - This implements a parser for the C family of languages.
RAII object used to inform the actions that we're currently parsing a declaration.
ParsingDeclRAIIObject(Parser &P, ParsingDeclRAIIObject *other)
Creates a RAII object and, optionally, initialize its diagnostics pool by stealing the diagnostics fr...
ParsingDeclRAIIObject(Parser &P, const sema::DelayedDiagnosticPool *parentPool)
Creates a RAII object whose pool is optionally parented by another.
void abort()
Signals that the context was completed without an appropriate declaration being parsed.
void abortAndRemember()
Unregister this object from Sema, but remember all the diagnostics that were emitted into it.
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
sema::DelayedDiagnosticPool & getDelayedDiagnosticPool()
ParsingDeclRAIIObject(Parser &P, NoParent_t _)
void reset()
Resets the RAII object for a new declaration.
A class for parsing a DeclSpec.
ParsingDeclSpec(Parser &P)
ParsingDeclSpec(Parser &P, ParsingDeclRAIIObject *RAII)
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
A class for parsing a declarator.
ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, const ParsedAttributes &DeclarationAttrs, DeclaratorContext C)
const ParsingDeclSpec & getDeclSpec() const
ParsingDeclSpec & getMutableDeclSpec() const
A class for parsing a field declarator.
const ParsingDeclSpec & getDeclSpec() const
ParsingDeclSpec & getMutableDeclSpec() const
ParsingFieldDeclarator(Parser &P, const ParsingDeclSpec &DS, const ParsedAttributes &DeclarationAttrs)
Activates OpenACC parsing mode to preseve OpenACC specific annotation tokens.
void restore()
This can be used to restore the state early, before the dtor is run.
~ParsingOpenACCDirectiveRAII()
ParsingOpenACCDirectiveRAII(Parser &P, bool Value=true)
Activates OpenMP parsing mode to preseve OpenMP specific annotation tokens.
~ParsingOpenMPDirectiveRAII()
void restore()
This can be used to restore the state early, before the dtor is run.
ParsingOpenMPDirectiveRAII(Parser &P, bool Value=true)
An RAII object for [un]poisoning an identifier within a scope.
PoisonSEHIdentifiersRAIIObject(Parser &Self, bool NewValue)
Sema - This implements semantic analysis and AST building for C.
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Encodes a location in the source.
A trivial tuple used to represent a source range.
A RAII object used to temporarily suppress access-like checking.
void operator=(SuppressAccessChecks &&Other)=delete
SuppressAccessChecks(Parser &P, bool activate=true)
Begin suppressing access-like checks.
SuppressAccessChecks(SuppressAccessChecks &&Other)
A collection of diagnostics which were delayed.
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Other
Other implicit parameter.
This little struct is used to capture information about structure field declarators,...