From db20190fe449d5e44cae9f8e5ec2fd96b4b9e6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Wed, 12 Apr 2017 14:52:28 +0200 Subject: [PATCH] Workaround clang bug with #undef output --- src/libclang/preprocessor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index e5ffd29..1a0b766 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -475,7 +475,11 @@ namespace ts::optional parse_undef(position& p) { // format (at new line): #undef - if (!p.was_newl() || !starts_with(p, "#undef")) + // due to a clang bug (http://bugs.llvm.org/show_bug.cgi?id=32631) I'll also an undef in the middle of the line + // the only issue is with string literals containing `#undef`. + // those will be stripped and evaluated + // however, this kind of usage should be rareā„¢ + if (/*!p.was_newl() ||*/ !starts_with(p, "#undef")) return ts::nullopt; p.skip(std::strlen("#undef"));