Skip to content

Commit e3a1b11

Browse files
committed
Use DiagnosticsEngine to report error when RuntimePrintValue.h cannot be loaded.
1 parent 1647088 commit e3a1b11

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

lib/Interpreter/ValuePrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,14 @@ namespace cling {
881881
const_cast<Transaction**>(&T));
882882
if (!T) {
883883
// Should also check T->getIssuedDiags() == Transaction::kErrors)?
884-
884+
885885
// It's redundant, but nicer to see the error at the bottom.
886886
// if (!Trap.hasErrorOccurred())
887-
cling::errs() << "RuntimePrintValue.h could not be loaded.\n";
887+
clang::DiagnosticsEngine& Diag = Interp->getDiagnostics();
888+
const unsigned ID = Diag.getCustomDiagID(
889+
clang::DiagnosticsEngine::Level::Error,
890+
"RuntimePrintValue.h could not be loaded");
891+
Diag.Report(Interp->getSourceLocation(), ID);
888892
return kUndefined;
889893
}
890894
}

test/ErrorRecovery/ABI.C

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,30 @@
66
// LICENSE.TXT for details.
77
//------------------------------------------------------------------------------
88

9-
// RUN: %cling -C -E -P %s | %cling -nostdinc++ -Xclang -verify 2>&1 | FileCheck %s
10-
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR %s | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
11-
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR2 %s | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
12-
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR3 %s | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
9+
// RUN: %cling -C -E -P %s > %t
10+
// RUN: cat %t | %cling -nostdinc++ -Xclang -verify 2>&1 | FileCheck %t
1311

12+
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR %s > %t
13+
// RUN: cat %t | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %t
14+
15+
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR2 %s > %t
16+
// RUN: cat %t | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %t
17+
18+
// RUN: %cling -C -E -P -DCLING_VALEXTRACT_ERR3 %s > %t
19+
// RUN: cat %t | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %t
20+
21+
// RUN: %cling -C -E -P -DCLING_RTIME_PRNT_ERR %s > %t
22+
// RUN: cat %t | %cling -I%S/ABI -Xclang -verify 2>&1 | FileCheck %t
23+
24+
#ifndef CLING_RTIME_PRNT_ERR
1425
// expected-error@input_line_1:1 {{'new' file not found}}
1526

1627
// CHECK: Warning in cling::IncrementalParser::CheckABICompatibility():
1728
// CHECK-NEXT: Possible C++ standard library mismatch, compiled with {{.*$}}
18-
29+
#endif
1930

2031
#if defined(CLING_VALEXTRACT_ERR) || defined(CLING_VALEXTRACT_ERR2) || \
21-
defined(CLING_VALEXTRACT_ERR3)
32+
defined(CLING_VALEXTRACT_ERR3) || defined(CLING_RTIME_PRNT_ERR)
2233

2334
struct Trigger {} Tr;
2435

@@ -38,4 +49,9 @@ Tr // expected-error@2 {{ValueExtractionSynthesizer could not find: 'cling::runt
3849

3950
#endif
4051

52+
#ifdef CLING_RTIME_PRNT_ERR
53+
Tr // expected-error@cling/Interpreter/RuntimePrintValue.h:2 {{C++ requires a type specifier for all declarations}} expected-error@2 {{RuntimePrintValue.h could not be loaded}}
54+
// CHECK: (struct Trigger &) <undefined>
55+
#endif
56+
4157
.q
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
ERROR;

0 commit comments

Comments
 (0)