[PATCH] D31190: Publish RAIIObjectsForParser.h for external usage

2017-03-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r298606.


Repository:
  rL LLVM

https://reviews.llvm.org/D31190



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31190: Publish RAIIObjectsForParser.h for external usage

2017-03-21 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

In the context of cling, we need to recover the parser from errors. This patch 
is essential for us and we would like to move it from our fork to clang proper.


Repository:
  rL LLVM

https://reviews.llvm.org/D31190

Files:
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseInit.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Parse/Parser.cpp
  lib/Parse/RAIIObjectsForParser.h

Index: lib/Parse/RAIIObjectsForParser.h
===
--- lib/Parse/RAIIObjectsForParser.h
+++ /dev/null
@@ -1,447 +0,0 @@
-//===--- RAIIObjectsForParser.h - RAII helpers for the parser ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines and implements the some simple RAII objects that are used
-// by the parser to manage bits in recursion.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_LIB_PARSE_RAIIOBJECTSFORPARSER_H
-#define LLVM_CLANG_LIB_PARSE_RAIIOBJECTSFORPARSER_H
-
-#include "clang/Parse/ParseDiagnostic.h"
-#include "clang/Parse/Parser.h"
-#include "clang/Sema/DelayedDiagnostic.h"
-#include "clang/Sema/Sema.h"
-
-namespace clang {
-  // TODO: move ParsingClassDefinition here.
-  // TODO: move TentativeParsingAction here.
-
-  /// \brief 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
-  /// might be the entirety of an explicit instantiation:
-  ///   template <> class std::vector;
-  /// or just an elaborated type specifier:
-  ///   template <> class std::vector make_vector<>();
-  /// Therefore this class collects all the diagnostics and permits
-  /// them to be re-delayed in a new context.
-  class SuppressAccessChecks {
-Sema 
-sema::DelayedDiagnosticPool DiagnosticPool;
-Sema::ParsingDeclState State;
-bool Active;
-
-  public:
-/// Begin suppressing access-like checks 
-SuppressAccessChecks(Parser , bool activate = true)
-: S(P.getActions()), DiagnosticPool(nullptr) {
-  if (activate) {
-State = S.PushParsingDeclaration(DiagnosticPool);
-Active = true;
-  } else {
-Active = false;
-  }
-}
-SuppressAccessChecks(SuppressAccessChecks &)
-  : S(Other.S), DiagnosticPool(std::move(Other.DiagnosticPool)),
-State(Other.State), Active(Other.Active) {
-  Other.Active = false;
-}
-void operator=(SuppressAccessChecks &) = delete;
-
-void done() {
-  assert(Active && "trying to end an inactive suppression");
-  S.PopParsingDeclaration(State, nullptr);
-  Active = false;
-}
-
-void redelay() {
-  assert(!Active && "redelaying without having ended first");
-  if (!DiagnosticPool.pool_empty())
-S.redelayDiagnostics(DiagnosticPool);
-  assert(DiagnosticPool.pool_empty());
-}
-
-~SuppressAccessChecks() {
-  if (Active) done();
-}
-  };
-
-  /// \brief 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 {
-Sema 
-sema::DelayedDiagnosticPool DiagnosticPool;
-Sema::ParsingDeclState State;
-bool Popped;
-
-ParsingDeclRAIIObject(const ParsingDeclRAIIObject &) = delete;
-void operator=(const ParsingDeclRAIIObject &) = delete;
-
-  public:
-enum NoParent_t { NoParent };
-ParsingDeclRAIIObject(Parser , NoParent_t _)
-: Actions(P.getActions()), DiagnosticPool(nullptr) {
-  push();
-}
-
-/// Creates a RAII object whose pool is optionally parented by another.
-ParsingDeclRAIIObject(Parser ,
-  const sema::DelayedDiagnosticPool *parentPool)
-: Actions(P.getActions()), DiagnosticPool(parentPool) {
-  push();
-}
-
-/// Creates a RAII object and,