//===--- RAIIObjectsForParser.h - RAII helpers for the parser ---*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines and implements the some simple RAII objects that are used // by the parser to manage bits in recursion. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_PARSE_RAIIOBJECTSFORPARSER_H #define LLVM_CLANG_PARSE_RAIIOBJECTSFORPARSER_H #include "clang/Parse/ParseDiagnostic.h" #include "clang/Parse/Parser.h" #include "clang/Sema/DelayedDiagnostic.h" #include "clang/Sema/ParsedTemplate.h" #include "clang/Sema/Sema.h" namespace clang { // TODO: move ParsingClassDefinition here. // TODO: move TentativeParsingAction here. /// A RAII object used to temporarily suppress access-like /// checking. Access-like checks are those associated with /// controlling the use of a declaration, like C++ access control /// errors and deprecation warnings. They are contextually /// dependent, in that they can only be resolved with full /// information about what's being declared. They are also /// suppressed in certain contexts, like the template arguments of /// an explicit instantiation. However, those suppression contexts /// cannot necessarily be fully determined in advance; for /// example, something starting like this: /// template <> class std::vector<A::PrivateType> /// might be the entirety of an explicit instantiation: /// template <> class std::vector<A::PrivateType>; /// or just an elaborated type specifier: /// template <> class std::vector<A::PrivateType> make_vector<>(); /// Therefore this class collects all the diagnostics and permits /// them to be re-delayed in a new context. class SuppressAccessChecks { … }; /// 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. class ParsingDeclRAIIObject { … }; /// A class for parsing a DeclSpec. class ParsingDeclSpec : public DeclSpec { … }; /// A class for parsing a declarator. class ParsingDeclarator : public Declarator { … }; /// A class for parsing a field declarator. class ParsingFieldDeclarator : public FieldDeclarator { … }; /// ExtensionRAIIObject - This saves the state of extension warnings when /// constructed and disables them. When destructed, it restores them back to /// the way they used to be. This is used to handle __extension__ in the /// parser. class ExtensionRAIIObject { … }; /// ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and /// restores it when destroyed. This says that "foo:" should not be /// considered a possible typo for "foo::" for error recovery purposes. class ColonProtectionRAIIObject { … }; /// Activates OpenMP parsing mode to preseve OpenMP specific annotation /// tokens. class ParsingOpenMPDirectiveRAII { … }; /// Activates OpenACC parsing mode to preseve OpenACC specific annotation /// tokens. class ParsingOpenACCDirectiveRAII { … }; /// RAII object that makes '>' behave either as an operator /// or as the closing angle bracket for a template argument list. class GreaterThanIsOperatorScope { … }; class InMessageExpressionRAIIObject { … }; class OffsetOfStateRAIIObject { … }; /// RAII object that makes sure paren/bracket/brace count is correct /// after declaration/statement parsing, even when there's a parsing error. class ParenBraceBracketBalancer { … }; class PoisonSEHIdentifiersRAIIObject { … }; /// RAII class that helps handle the parsing of an open/close delimiter /// pair, such as braces { ... } or parentheses ( ... ). class BalancedDelimiterTracker : public GreaterThanIsOperatorScope { … }; } // end namespace clang #endif