https://github.com/vgvassilev created https://github.com/llvm/llvm-project/pull/107552
None >From 1947d04f969c53b75103cabf02a1f2c851d082e1 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev <v.g.vassi...@gmail.com> Date: Fri, 6 Sep 2024 09:05:15 +0000 Subject: [PATCH] [clang-repl] Implement continuation for preprocessor directives. --- clang/test/Interpreter/multiline.cpp | 11 ++++++----- clang/tools/clang-repl/ClangRepl.cpp | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/test/Interpreter/multiline.cpp b/clang/test/Interpreter/multiline.cpp index 054e61a7e3d62e..0f5ef48417f133 100644 --- a/clang/test/Interpreter/multiline.cpp +++ b/clang/test/Interpreter/multiline.cpp @@ -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 = \ @@ -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 diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index 9cfc70462893dd..08c54e6cafa901 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -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; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits