Skip character literals when preprocessing

This commit is contained in:
Jonathan Müller 2017-04-21 11:52:30 +02:00
commit bc9b8433c8
2 changed files with 14 additions and 4 deletions

View file

@ -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))
{

View file

@ -145,7 +145,10 @@ struct a {};
/// u
/** b
* b */
void b(int, float);
void b(int, float)
{
auto c = '#';
}
/** u */
//! c