Skip to content

Commit

Permalink
[clang-repl] Implement continuation for preprocessor directives. (#10…
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev authored Sep 20, 2024
1 parent 400b725 commit 96ae7c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions clang/test/Interpreter/multiline.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// REQUIRES: host-supports-jit
// UNSUPPORTED: system-aix
// RUN: cat %s | clang-repl | FileCheck %s
// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s

// expected-no-diagnostics

extern "C" int printf(const char*,...);
int i = \
Expand All @@ -17,8 +19,7 @@ void f(int x) \
f(i);
// CHECK: x=12

// FIXME: Support preprocessor directives.
// #if 0 \
// #error "Can't be!" \
// #endif
#if 0 \
#error "Can't be!" \
#endif

4 changes: 3 additions & 1 deletion clang/tools/clang-repl/ClangRepl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ int main(int argc, const char **argv) {
llvm::StringRef L = *Line;
L = L.trim();
if (L.ends_with("\\")) {
// FIXME: Support #ifdef X \ ...
Input += L.drop_back(1);
// If it is a preprocessor directive, new lines matter.
if (L.starts_with('#'))
Input += "\n";
LE.setPrompt("clang-repl... ");
continue;
}
Expand Down

0 comments on commit 96ae7c4

Please sign in to comment.