diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index 207db6a..b85ff24 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -651,17 +651,24 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co position p(ts::ref(result.source), output.c_str()); std::size_t file_depth = 0u; - ts::flag in_string(false); + ts::flag in_string(false), in_char(false); while (p) { if (starts_with(p, "\\\"")) // starts with \" p.bump(2u); - else if (starts_with(p, "\"")) // starts with " + else if (starts_with(p, "\\'")) // starts with \' + p.bump(2u); + else if (in_char == false && starts_with(p, "\"")) // starts with " { p.bump(); in_string.toggle(); } - else if (in_string == true) + else if (in_string == false && starts_with(p, "'")) + { + p.bump(); + in_char.toggle(); + } + else if (in_string == true || in_char == true) p.bump(); else if (auto macro = parse_macro(p, result, file_depth == 0u)) { diff --git a/test/cpp_preprocessor.cpp b/test/cpp_preprocessor.cpp index 23f3644..8c8945d 100644 --- a/test/cpp_preprocessor.cpp +++ b/test/cpp_preprocessor.cpp @@ -145,7 +145,10 @@ struct a {}; /// u /** b * b */ -void b(int, float); +void b(int, float) +{ + auto c = '#'; +} /** u */ //! c