Skip to content

Commit 6e37cef

Browse files
committed
Check if CLING_RUNTIME_PRINT_VALUE_H defined before including RuntimePrintValue.h.
1 parent e3a1b11 commit 6e37cef

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

lib/Interpreter/ValuePrinter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,18 @@ namespace cling {
869869
// But user can undo past the transaction that invoked this, so whether
870870
// we are first or not is known by the interpreter.
871871
//
872-
// Additionally add any transactions that occur in this scope as
873-
// children to the transaction that invoked us
872+
// When printing has already occured once or RuntimePrintValue.h was
873+
// explicitly included, then Transaction merging has to occur here.
874+
//
875+
// Additionally the user could have included RuntimePrintValue.h before
876+
// this code is run, so if there is no print transaction, check if
877+
// CLING_RUNTIME_PRINT_VALUE_H is defined.
878+
// FIXME: Relying on this macro isn't the best, but what's another way?
874879

875880
Interpreter* Interp = V.getInterpreter();
876881
Interpreter::TransactionMerge M(Interp, true);
877882
const Transaction*& T = Interp->printValueTransaction();
878-
if (!T) {
883+
if (!T && !Interp->getMacro("CLING_RUNTIME_PRINT_VALUE_H")) {
879884
// DiagnosticErrorTrap Trap(Interp->getSema().getDiagnostics());
880885
Interp->declare("#include \"cling/Interpreter/RuntimePrintValue.h\"",
881886
const_cast<Transaction**>(&T));
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//------------------------------------------------------------------------------
2+
// CLING - the C++ LLVM-based InterpreterG :)
3+
//
4+
// This file is dual-licensed: you can choose to license it under the University
5+
// of Illinois Open Source License or the GNU Lesser General Public License. See
6+
// LICENSE.TXT for details.
7+
8+
//------------------------------------------------------------------------------
9+
10+
// RUN: cat %s | %cling -Xclang -verify 2>&1 | FileCheck %s
11+
12+
#include "cling/Interpreter/RuntimePrintValue.h"
13+
14+
struct Trigger { } trgr
15+
// CHECK: (struct Trigger &) @0x{{.*}}
16+
.undo
17+
18+
struct Trigger2 { } trgr
19+
// CHECK-NEXT: (struct Trigger2 &) @0x{{.*}}
20+
.undo
21+
22+
.undo // #include "cling/Interpreter/RuntimePrintValue.h"
23+
24+
struct Trigger3 { } trgr
25+
// CHECK-NEXT: (struct Trigger3 &) @0x{{.*}}
26+
27+
// expected-no-diagnostics
28+
.q

0 commit comments

Comments
 (0)