14 #ifndef LLVM_CLANG_LIB_PARSE_RAIIOBJECTSFORPARSER_H 15 #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;
298 : P(P), OldVal(P.OpenMPDirectiveParsing) {
299 P.OpenMPDirectiveParsing =
true;
304 void restore() { P.OpenMPDirectiveParsing = OldVal; }
312 bool &GreaterThanIsOperator;
313 bool OldGreaterThanIsOperator;
316 : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) {
317 GreaterThanIsOperator = Val;
321 GreaterThanIsOperator = OldGreaterThanIsOperator;
326 bool &InMessageExpression;
331 : InMessageExpression(P.InMessageExpression),
332 OldValue(P.InMessageExpression) {
333 InMessageExpression =
Value;
337 InMessageExpression = OldValue;
345 unsigned short ParenCount, BracketCount, BraceCount;
348 : P(p), ParenCount(p.ParenCount), BracketCount(p.BracketCount),
349 BraceCount(p.BraceCount) { }
352 P.AngleBrackets.clear(P);
353 P.ParenCount = ParenCount;
354 P.BracketCount = BracketCount;
355 P.BraceCount = BraceCount;
371 : Ident_AbnormalTermination(Self.Ident_AbnormalTermination, NewValue),
372 Ident_GetExceptionCode(Self.Ident_GetExceptionCode, NewValue),
373 Ident_GetExceptionInfo(Self.Ident_GetExceptionInfo, NewValue),
374 Ident__abnormal_termination(Self.Ident__abnormal_termination, NewValue),
375 Ident__exception_code(Self.Ident__exception_code, NewValue),
376 Ident__exception_info(Self.Ident__exception_info, NewValue),
377 Ident___abnormal_termination(Self.Ident___abnormal_termination, NewValue),
378 Ident___exception_code(Self.Ident___exception_code, NewValue),
379 Ident___exception_info(Self.Ident___exception_info, NewValue) {
391 unsigned short &getDepth() {
393 case tok::l_brace:
return P.BraceCount;
394 case tok::l_square:
return P.BracketCount;
395 case tok::l_paren:
return P.ParenCount;
396 default: llvm_unreachable(
"Wrong token kind");
400 bool diagnoseOverflow();
401 bool diagnoseMissingClose();
407 P(p), Kind(k), FinalToken(FinalToken)
410 default: llvm_unreachable(
"Unexpected balanced token");
412 Close = tok::r_brace;
413 Consumer = &Parser::ConsumeBrace;
416 Close = tok::r_paren;
417 Consumer = &Parser::ConsumeParen;
421 Close = tok::r_square;
422 Consumer = &Parser::ConsumeBracket;
436 LOpen = (P.*Consumer)();
440 return diagnoseOverflow();
443 bool expectAndConsume(
unsigned DiagID = diag::err_expected,
444 const char *Msg =
"",
447 if (P.Tok.
is(Close)) {
448 LClose = (P.*Consumer)();
452 P.
Diag(SemiLoc, diag::err_unexpected_semi)
454 LClose = (P.*Consumer)();
458 return diagnoseMissingClose();
471 : Container(Container) {}
DestroyTemplateIdAnnotationsRAIIObj(SmallVectorImpl< TemplateIdAnnotation *> &Container)
void restore()
restore - This can be used to restore the state early, before the dtor is run.
void clear()
Reset the contents of this Declarator.
ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, DeclaratorContext C)
SuppressAccessChecks(SuppressAccessChecks &&Other)
ColonProtectionRAIIObject(Parser &p, bool Value=true)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
A RAII object used to temporarily suppress access-like checking.
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
SourceLocation getCloseLocation() const
Parser - This implements a parser for the C family of languages.
Information about one declarator, including the parsed type information and the identifier.
RAIIObject to destroy the contents of a SmallVector of TemplateIdAnnotation pointers and clear the ve...
ExtensionRAIIObject(DiagnosticsEngine &diags)
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
void operator=(SuppressAccessChecks &&Other)=delete
ParenBraceBracketBalancer(Parser &p)
~GreaterThanIsOperatorScope()
void IncrementAllExtensionsSilenced()
Counter bumped when an extension block is/ encountered.
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
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)
~ParsingOpenMPDirectiveRAII()
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
void reset()
Resets the RAII object for a new declaration.
void abortAndRemember()
Unregister this object from Sema, but remember all the diagnostics that were emitted into it...
SourceRange getRange() const
Concrete class used by the front-end to report problems and issues.
ParsingDeclSpec & getMutableDeclSpec() const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
const ParsingDeclSpec & getDeclSpec() const
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.
ParsingDeclRAIIObject(Parser &P, NoParent_t _)
~ColonProtectionRAIIObject()
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
ParsingDeclRAIIObject(Parser &P, ParsingDeclRAIIObject *other)
Creates a RAII object and, optionally, initialize its diagnostics pool by stealing the diagnostics fr...
SuppressAccessChecks(Parser &P, bool activate=true)
Begin suppressing access-like checks.
A class for parsing a field declarator.
SourceLocation getOpenLocation() const
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a templat...
const LangOptions & getLangOpts() const
A class for parsing a DeclSpec.
Encodes a location in the source.
const ParsingDeclSpec & getDeclSpec() const
ParsingDeclSpec(Parser &P)
void restore()
This can be used to restore the state early, before the dtor is run.
~ParenBraceBracketBalancer()
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
InMessageExpressionRAIIObject(Parser &P, bool Value)
Dataflow Directional Tag Classes.
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
BalancedDelimiterTracker(Parser &p, tok::TokenKind k, tok::TokenKind FinalToken=tok::semi)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const sema::DelayedDiagnosticPool & getDelayedDiagnosticPool() const
~DestroyTemplateIdAnnotationsRAIIObj()
sema::DelayedDiagnosticPool & getDelayedDiagnosticPool()
void abort()
Signals that the context was completed without an appropriate declaration being parsed.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ParsingDeclSpec & getMutableDeclSpec() const
~InMessageExpressionRAIIObject()
void DecrementAllExtensionsSilenced()
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
PoisonSEHIdentifiersRAIIObject(Parser &Self, bool NewValue)
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Activates OpenMP parsing mode to preseve OpenMP specific annotation tokens.
A collection of diagnostics which were delayed.
ParsingOpenMPDirectiveRAII(Parser &P)
A trivial tuple used to represent a source range.
An RAII object for [un]poisoning an identifier within a scope.