[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D104918#2870582 , @teemperor wrote:

> @v.g.vassilev For LLDB you need to change the 
> `TypeSystemClang::SetExternalSource` function to this (it just moves the 
> `setHasExternalLexicalStorage` one line up. You can just add that change and 
> the compilation fix to this commit.
>
>   void TypeSystemClang::SetExternalSource(
>   llvm::IntrusiveRefCntPtr _source_up) {
> ASTContext  = getASTContext();
> ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
> ast.setExternalSource(ast_source_up);
>   }
>
> The problem is that a few ASTs in LLDB change the ExternalSource that is 
> originally set, but the LazyGenerationalUpdatePtr remembers the initial 
> ExternalSource and tries to access it to complete the redecl chain (but the 
> original ExternalSource just got replaced and deleted). The better fix is to 
> not even create that original ExternalSource, but I can fix that in a follow 
> up as that seems out of scope for this patch.

Thanks @teemperor! I will add your suggestion and recommit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

@v.g.vassilev For LLDB you need to change the 
`TypeSystemClang::SetExternalSource` function to this (it just moves the 
`setHasExternalLexicalStorage` one line up. You can just add that change and 
the compilation fix to this commit.

  void TypeSystemClang::SetExternalSource(
  llvm::IntrusiveRefCntPtr _source_up) {
ASTContext  = getASTContext();
ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
ast.setExternalSource(ast_source_up);
  }

The problem is that a few ASTs in LLDB change the ExternalSource that is 
originally set, but the LazyGenerationalUpdatePtr remembers the initial 
ExternalSource and tries to access it to complete the redecl chain (but the 
original ExternalSource just got replaced and deleted). The better fix is to 
not even create that original ExternalSource, but I can fix that in a follow up 
as that seems out of scope for this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-11 Thread Vassil Vassilev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6775fc6ffa3c: [clang-repl] Implement partial translation 
units and error recovery. (authored by v.g.vassilev).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/PartialTranslationUnit.h
  clang/include/clang/Interpreter/Transaction.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/unittests/AST/ASTVectorTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -323,7 +323,7 @@
 // according to LangOptions, so we init Parser to register opencl
 // pragma handlers
 ASTContext Context(OpenCLLangOpts, SourceMgr, PP.getIdentifierTable(),
-   PP.getSelectorTable(), PP.getBuiltinInfo());
+   PP.getSelectorTable(), PP.getBuiltinInfo(), PP.TUKind);
 Context.InitBuiltinTypes(*Target);
 
 ASTConsumer Consumer;
Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -37,34 +37,41 @@
   return cantFail(clang::Interpreter::create(std::move(CI)));
 }
 
+static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
+  return std::distance(PTUDecl->decls().begin(), PTUDecl->decls().end());
+}
+
 TEST(InterpreterTest, Sanity) {
   std::unique_ptr Interp = createInterpreter();
-  Transaction (cantFail(Interp->Parse("void g(); void g() {}")));
-  EXPECT_EQ(2U, R1.Decls.size());
 
-  Transaction (cantFail(Interp->Parse("int i;")));
-  EXPECT_EQ(1U, R2.Decls.size());
+  using PTU = PartialTranslationUnit;
+
+  PTU (cantFail(Interp->Parse("void g(); void g() {}")));
+  EXPECT_EQ(2U, DeclsSize(R1.TUPart));
+
+  PTU (cantFail(Interp->Parse("int i;")));
+  EXPECT_EQ(1U, DeclsSize(R2.TUPart));
 }
 
-static std::string DeclToString(DeclGroupRef DGR) {
-  return llvm::cast(DGR.getSingleDecl())->getQualifiedNameAsString();
+static std::string DeclToString(Decl *D) {
+  return llvm::cast(D)->getQualifiedNameAsString();
 }
 
 TEST(InterpreterTest, IncrementalInputTopLevelDecls) {
   std::unique_ptr Interp = createInterpreter();
-  auto R1OrErr = Interp->Parse("int var1 = 42; int f() { return var1; }");
+  auto R1 = Interp->Parse("int var1 = 42; int f() { return var1; }");
   // gtest doesn't expand into explicit bool conversions.
-  EXPECT_TRUE(!!R1OrErr);
-  auto R1 = R1OrErr->Decls;
-  EXPECT_EQ(2U, R1.size());
-  EXPECT_EQ("var1", DeclToString(R1[0]));
-  EXPECT_EQ("f", DeclToString(R1[1]));
-
-  auto R2OrErr = Interp->Parse("int var2 = f();");
-  EXPECT_TRUE(!!R2OrErr);
-  auto R2 = R2OrErr->Decls;
-  EXPECT_EQ(1U, R2.size());
-  EXPECT_EQ("var2", DeclToString(R2[0]));
+  EXPECT_TRUE(!!R1);
+  auto R1DeclRange = R1->TUPart->decls();
+  EXPECT_EQ(2U, DeclsSize(R1->TUPart));
+  EXPECT_EQ("var1", DeclToString(*R1DeclRange.begin()));
+  EXPECT_EQ("f", DeclToString(*(++R1DeclRange.begin(;
+
+  auto R2 = Interp->Parse("int var2 = f();");
+  EXPECT_TRUE(!!R2);
+  auto R2DeclRange = R2->TUPart->decls();
+  EXPECT_EQ(1U, DeclsSize(R2->TUPart));
+  EXPECT_EQ("var2", DeclToString(*R2DeclRange.begin()));
 }
 
 TEST(InterpreterTest, Errors) {
@@ -83,9 +90,8 @@
   HasSubstr("error: unknown type name 'intentional_error'"));
   EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
 
-#ifdef GTEST_HAS_DEATH_TEST
-  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
-#endif
+  auto RecoverErr = Interp->Parse("int var1 = 42;");
+  EXPECT_TRUE(!!RecoverErr);
 }
 
 // Here we test whether the user can mix declarations and statements. The
@@ -101,21 +107,21 @@
   DiagnosticsOS, new DiagnosticOptions());
 
   auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
-  auto R1OrErr = Interp->Parse(
+  auto R1 = Interp->Parse(
   "int var1 = 

[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:690-691
+
+  /// The translation unit is a partial translation unit, growing 
incrementally.
+  TU_Partial
 };

rsmith wrote:
> I don't think this is clear enough about the difference between `TU_Prefix` 
> and `TU_Partial`. I think the difference is:
> 
> * `TU_Prefix` is an incomplete prefix of a translation unit. Because it's not 
> complete, we don't perform (most) finalization steps (eg, template 
> instantiation) at the end.
> * `TU_Partial` is a complete translation unit that we might nonetheless 
> incrementally extend later. Because it is complete (and we might want to 
> generate code for it), we do perform template instantiation, but because it 
> might be extended later, we don't warn if it declares or uses undefined 
> internal-linkage symbols.
> 
> I wonder if `TU_Incremental` would be a better name than `TU_Partial`.
Good point. Fixed.



Comment at: clang/include/clang/Interpreter/Interpreter.h:63
+if (auto Err = ErrOrPTU.takeError())
   return Err;
+if (ErrOrPTU->TheModule)

sgraenitz wrote:
> `ErrorOr` has different semantics and is still in use, so the name could 
> be confusing. Idiomatic usage for `Expected` would rather be like:
> ```
> auto PTU = Parse(Code);
> if (!PTU)
>   return PTU.takeError();
> ```
> 
> The patch didn't introduce it, but it might be a good chance for improvement.
Ha, that made the code much nicer looking! Thanks!!



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:178
+TranslationUnitDecl *PreviousTU = MostRecentTU->getPreviousDecl();
+assert(PreviousTU);
+TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();

sgraenitz wrote:
> Where does it point, if the very first TU fails? Maybe worth noting in the 
> assert and/or adding a test case?
The very first TU contains the compiler builtins and it is created when the 
ASTContext is created. Not having a PreviousTU would mean that we did not 
initialize the CompilerInstance properly. 

Added some description in the assert.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-07-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 356015.
v.g.vassilev marked 4 inline comments as done.
v.g.vassilev added a comment.

Address review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/PartialTranslationUnit.h
  clang/include/clang/Interpreter/Transaction.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/unittests/AST/ASTVectorTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -279,7 +279,7 @@
 // according to LangOptions, so we init Parser to register opencl
 // pragma handlers
 ASTContext Context(OpenCLLangOpts, SourceMgr, PP.getIdentifierTable(),
-   PP.getSelectorTable(), PP.getBuiltinInfo());
+   PP.getSelectorTable(), PP.getBuiltinInfo(), PP.TUKind);
 Context.InitBuiltinTypes(*Target);
 
 ASTConsumer Consumer;
Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -37,34 +37,41 @@
   return cantFail(clang::Interpreter::create(std::move(CI)));
 }
 
+static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
+  return std::distance(PTUDecl->decls().begin(), PTUDecl->decls().end());
+}
+
 TEST(InterpreterTest, Sanity) {
   std::unique_ptr Interp = createInterpreter();
-  Transaction (cantFail(Interp->Parse("void g(); void g() {}")));
-  EXPECT_EQ(2U, R1.Decls.size());
 
-  Transaction (cantFail(Interp->Parse("int i;")));
-  EXPECT_EQ(1U, R2.Decls.size());
+  using PTU = PartialTranslationUnit;
+
+  PTU (cantFail(Interp->Parse("void g(); void g() {}")));
+  EXPECT_EQ(2U, DeclsSize(R1.TUPart));
+
+  PTU (cantFail(Interp->Parse("int i;")));
+  EXPECT_EQ(1U, DeclsSize(R2.TUPart));
 }
 
-static std::string DeclToString(DeclGroupRef DGR) {
-  return llvm::cast(DGR.getSingleDecl())->getQualifiedNameAsString();
+static std::string DeclToString(Decl *D) {
+  return llvm::cast(D)->getQualifiedNameAsString();
 }
 
 TEST(InterpreterTest, IncrementalInputTopLevelDecls) {
   std::unique_ptr Interp = createInterpreter();
-  auto R1OrErr = Interp->Parse("int var1 = 42; int f() { return var1; }");
+  auto R1 = Interp->Parse("int var1 = 42; int f() { return var1; }");
   // gtest doesn't expand into explicit bool conversions.
-  EXPECT_TRUE(!!R1OrErr);
-  auto R1 = R1OrErr->Decls;
-  EXPECT_EQ(2U, R1.size());
-  EXPECT_EQ("var1", DeclToString(R1[0]));
-  EXPECT_EQ("f", DeclToString(R1[1]));
-
-  auto R2OrErr = Interp->Parse("int var2 = f();");
-  EXPECT_TRUE(!!R2OrErr);
-  auto R2 = R2OrErr->Decls;
-  EXPECT_EQ(1U, R2.size());
-  EXPECT_EQ("var2", DeclToString(R2[0]));
+  EXPECT_TRUE(!!R1);
+  auto R1DeclRange = R1->TUPart->decls();
+  EXPECT_EQ(2U, DeclsSize(R1->TUPart));
+  EXPECT_EQ("var1", DeclToString(*R1DeclRange.begin()));
+  EXPECT_EQ("f", DeclToString(*(++R1DeclRange.begin(;
+
+  auto R2 = Interp->Parse("int var2 = f();");
+  EXPECT_TRUE(!!R2);
+  auto R2DeclRange = R2->TUPart->decls();
+  EXPECT_EQ(1U, DeclsSize(R2->TUPart));
+  EXPECT_EQ("var2", DeclToString(*R2DeclRange.begin()));
 }
 
 TEST(InterpreterTest, Errors) {
@@ -83,9 +90,8 @@
   HasSubstr("error: unknown type name 'intentional_error'"));
   EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
 
-#ifdef GTEST_HAS_DEATH_TEST
-  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
-#endif
+  auto RecoverErr = Interp->Parse("int var1 = 42;");
+  EXPECT_TRUE(!!RecoverErr);
 }
 
 // Here we test whether the user can mix declarations and statements. The
@@ -101,21 +107,21 @@
   DiagnosticsOS, new DiagnosticOptions());
 
   auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
-  auto R1OrErr = Interp->Parse(
+  auto R1 = Interp->Parse(
   "int var1 = 42; extern \"C\" int printf(const char*, ...);");
   // gtest doesn't expand into explicit bool conversions.
-  EXPECT_TRUE(!!R1OrErr);
+  EXPECT_TRUE(!!R1);
 
-  auto R1 = 

[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-06-30 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

A few minor notes




Comment at: clang/include/clang/Interpreter/Interpreter.h:63
+if (auto Err = ErrOrPTU.takeError())
   return Err;
+if (ErrOrPTU->TheModule)

`ErrorOr` has different semantics and is still in use, so the name could be 
confusing. Idiomatic usage for `Expected` would rather be like:
```
auto PTU = Parse(Code);
if (!PTU)
  return PTU.takeError();
```

The patch didn't introduce it, but it might be a good chance for improvement.



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:178
+TranslationUnitDecl *PreviousTU = MostRecentTU->getPreviousDecl();
+assert(PreviousTU);
+TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();

Where does it point, if the very first TU fails? Maybe worth noting in the 
assert and/or adding a test case?



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:263
+  if (auto Err = ErrOrPTU.takeError())
 return std::move(Err);
 

```
auto PTU = ParseOrWrapTopLevelDecl();
if (!PTU)
  return PTU.takeError();
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-06-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I'm (happily) surprised this required so few changes!




Comment at: clang/include/clang/Basic/LangOptions.h:690-691
+
+  /// The translation unit is a partial translation unit, growing 
incrementally.
+  TU_Partial
 };

I don't think this is clear enough about the difference between `TU_Prefix` and 
`TU_Partial`. I think the difference is:

* `TU_Prefix` is an incomplete prefix of a translation unit. Because it's not 
complete, we don't perform (most) finalization steps (eg, template 
instantiation) at the end.
* `TU_Partial` is a complete translation unit that we might nonetheless 
incrementally extend later. Because it is complete (and we might want to 
generate code for it), we do perform template instantiation, but because it 
might be extended later, we don't warn if it declares or uses undefined 
internal-linkage symbols.

I wonder if `TU_Incremental` would be a better name than `TU_Partial`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104918/new/

https://reviews.llvm.org/D104918

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


[PATCH] D104918: [clang-repl] Implement partial translation units and error recovery.

2021-06-25 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, rjmccall, lhames, teemperor, aprantl, 
sgraenitz, hfinkel.
Herald added subscribers: dexonsmith, kbarton, nemanjai.
v.g.vassilev requested review of this revision.

https://reviews.llvm.org/D96033 contained a discussion regarding efficient 
modeling of error recovery. @rjmccall has outlined the key ideas:

Conceptually, we can split the translation unit into a sequence of partial 
translation units (PTUs). Every declaration will be associated with a unique 
PTU that owns it.

  

The first key insight here is that the owning PTU isn't always the "active" 
(most recent) PTU, and it isn't always the PTU that the declaration "comes 
from". A new declaration (that isn't a redeclaration or specialization of 
anything) does belong to the active PTU. A template specialization, however, 
belongs to the most recent PTU of all the declarations in its signature - 
mostly that means that it can be pulled into a more recent PTU by its template 
arguments.

The second key insight is that processing a PTU might extend an earlier PTU. 
Rolling back the later PTU shouldn't throw that extension away. For example, if 
the second PTU defines a template, and the third PTU requires that template to 
be instantiated at float, that template specialization is still part of the 
second PTU. Similarly, if the fifth PTU uses an inline function belonging to 
the fourth, that definition still belongs to the fourth. When we go to emit 
code in a new PTU, we map each declaration we have to emit back to its owning 
PTU and emit it in a new module for just the extensions to that PTU. We keep 
track of all the modules we've emitted for a PTU so that we can unload them all 
if we decide to roll it back.

  

Most declarations/definitions will only refer to entities from the same or 
earlier PTUs. However, it is possible (primarily by defining a 
previously-declared entity, but also through templates or ADL) for an entity 
that belongs to one PTU to refer to something from a later PTU. We will have to 
keep track of this and prevent unwinding to later PTU when we recognize it.

Fortunately, this should be very rare; and crucially, we don't have to do the 
bookkeeping for this if we've only got one PTU, e.g. in normal compilation. 
Otherwise, PTUs after the first just need to record enough metadata to be able 
to revert any changes they've made to declarations belonging to earlier PTUs, 
e.g. to redeclaration chains or template specialization lists.

It should even eventually be possible for PTUs to provide their own slab 
allocators which can be thrown away as part of rolling back the PTU. We can 
maintain a notion of the active allocator and allocate things like Stmt/Expr 
nodes in it, temporarily changing it to the appropriate PTU whenever we go to 
do something like instantiate a function template. More care will be required 
when allocating declarations and types, though.

We would want the PTU to be efficiently recoverable from a Decl; I'm not sure 
how best to do that. An easy option that would cover most declarations would be 
to make multiple TranslationUnitDecls and parent the declarations 
appropriately, but I don't think that's good enough for things like member 
function templates, since an instantiation of that would still be parented by 
its original class. Maybe we can work this into the DC chain somehow, like how 
lexical DCs are.

  

This patch teaches clang-repl how to recover from errors by disconnecting the 
most recent PTU and update the primary PTU lookup tables. For instance:

  ./clang-repl
  clang-repl> int i = 12; error;
  In file included from <<< inputs >>>:1:
  input_line_0:1:13: error: C++ requires a type specifier for all declarations
  int i = 12; error;
   ^
  error: Parsing failed.
  clang-repl> int i = 13; extern "C" int printf(const char*,...);
  clang-repl> auto r1 = printf("i=%d\n", i);
  i=13
  clang-repl> quit


Repository:
  rC Clang

https://reviews.llvm.org/D104918

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/PartialTranslationUnit.h
  clang/include/clang/Interpreter/Transaction.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/unittests/AST/ASTVectorTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp