Add support for C++17 parsing with cpp_1z option

Note: It is currently experimental.
This commit is contained in:
Jonathan Müller 2017-04-25 17:30:07 +02:00
commit 2af22083a6
3 changed files with 14 additions and 2 deletions

View file

@ -23,7 +23,9 @@ namespace cppast
cpp_11,
cpp_14,
cpp_latest = cpp_standard::cpp_14,
cpp_1z, //< Upcoming C++17 (experimental).
cpp_latest = cpp_standard::cpp_14, //< The latest supported C++ standard.
};
/// \returns A human readable string representing the option,
@ -40,6 +42,8 @@ namespace cppast
return "c++11";
case cpp_standard::cpp_14:
return "c++14";
case cpp_standard::cpp_1z:
return "c++1z";
}
DEBUG_UNREACHABLE(detail::assert_handler{});

View file

@ -86,6 +86,12 @@ void libclang_compile_config::do_set_flags(cpp_standard standard, compile_flags
else
add_flag("-std=c++14");
break;
case cpp_standard::cpp_1z:
if (flags & compile_flag::gnu_extensions)
add_flag("-std=gnu++1z");
else
add_flag("-std=c++1z");
break;
}
if (flags & compile_flag::ms_compatibility)

View file

@ -210,7 +210,7 @@ int main(int argc, char* argv[])
("file", "the file that is being parsed (last positional argument)",
cxxopts::value<std::string>());
options.add_options("compilation")
("std", "set the C++ standard (c++98, c++03, c++11, c++14)",
("std", "set the C++ standard (c++98, c++03, c++11, c++14, c++1z (experimental))",
cxxopts::value<std::string>()->default_value(cppast::to_string(cppast::cpp_standard::cpp_latest)))
("I,include_directory", "add directory to include search path",
cxxopts::value<std::vector<std::string>>())
@ -276,6 +276,8 @@ int main(int argc, char* argv[])
config.set_flags(cppast::cpp_standard::cpp_11, flags);
else if (options["std"].as<std::string>() == "c++14")
config.set_flags(cppast::cpp_standard::cpp_14, flags);
else if (options["std"].as<std::string>() == "c++1z")
config.set_flags(cppast::cpp_standard::cpp_1z, flags);
else
{
print_error("invalid value '" + options["std"].as<std::string>() + "' for std flag");