Merge branch 'foonathan:main' into main
This commit is contained in:
commit
c125883083
6 changed files with 161 additions and 11 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace cppast
|
||||
{
|
||||
/// The C++ standard that should be used.
|
||||
/// The C/C++ standard that should be used.
|
||||
enum class cpp_standard
|
||||
{
|
||||
cpp_98,
|
||||
|
|
@ -26,8 +26,16 @@ enum class cpp_standard
|
|||
cpp_17,
|
||||
cpp_2a,
|
||||
cpp_20,
|
||||
cpp_2b,
|
||||
|
||||
c_89,
|
||||
c_99,
|
||||
c_11,
|
||||
c_17,
|
||||
c_2x,
|
||||
|
||||
cpp_latest = cpp_standard::cpp_14, //< The latest supported C++ standard.
|
||||
c_latest = cpp_standard::c_17, //< The latest supported C standard.
|
||||
};
|
||||
|
||||
/// \returns A human readable string representing the option,
|
||||
|
|
@ -52,12 +60,52 @@ inline const char* to_string(cpp_standard standard) noexcept
|
|||
return "c++2a";
|
||||
case cpp_standard::cpp_20:
|
||||
return "c++20";
|
||||
case cpp_standard::cpp_2b:
|
||||
return "c++2b";
|
||||
|
||||
case cpp_standard::c_89:
|
||||
return "c89";
|
||||
case cpp_standard::c_99:
|
||||
return "c99";
|
||||
case cpp_standard::c_11:
|
||||
return "c11";
|
||||
case cpp_standard::c_17:
|
||||
return "c17";
|
||||
case cpp_standard::c_2x:
|
||||
return "c2x";
|
||||
}
|
||||
|
||||
DEBUG_UNREACHABLE(detail::assert_handler{});
|
||||
return "ups";
|
||||
}
|
||||
|
||||
/// \returns whether the language standard is a C standard
|
||||
inline bool is_c_standard(cpp_standard standard) noexcept
|
||||
{
|
||||
switch (standard)
|
||||
{
|
||||
case cpp_standard::cpp_98:
|
||||
case cpp_standard::cpp_03:
|
||||
case cpp_standard::cpp_11:
|
||||
case cpp_standard::cpp_14:
|
||||
case cpp_standard::cpp_1z:
|
||||
case cpp_standard::cpp_17:
|
||||
case cpp_standard::cpp_2a:
|
||||
case cpp_standard::cpp_20:
|
||||
case cpp_standard::cpp_2b:
|
||||
return false;
|
||||
case cpp_standard::c_89:
|
||||
case cpp_standard::c_99:
|
||||
case cpp_standard::c_11:
|
||||
case cpp_standard::c_17:
|
||||
case cpp_standard::c_2x:
|
||||
return true;
|
||||
}
|
||||
|
||||
DEBUG_UNREACHABLE(detail::assert_handler{});
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Other special compilation flags.
|
||||
enum class compile_flag
|
||||
{
|
||||
|
|
@ -114,6 +162,12 @@ public:
|
|||
return do_get_name();
|
||||
}
|
||||
|
||||
/// \returns Whether to parse files as C rather than C++.
|
||||
bool use_c() const noexcept
|
||||
{
|
||||
return do_use_c();
|
||||
}
|
||||
|
||||
protected:
|
||||
compile_config(std::vector<std::string> def_flags) : flags_(std::move(def_flags)) {}
|
||||
|
||||
|
|
@ -157,6 +211,9 @@ private:
|
|||
/// \notes This allows detecting mismatches of configurations and parsers.
|
||||
virtual const char* do_get_name() const noexcept = 0;
|
||||
|
||||
/// \returns Whether to parse files as C rather than C++.
|
||||
virtual bool do_use_c() const noexcept = 0;
|
||||
|
||||
std::vector<std::string> flags_;
|
||||
};
|
||||
} // namespace cppast
|
||||
|
|
|
|||
|
|
@ -187,10 +187,13 @@ private:
|
|||
return "libclang";
|
||||
}
|
||||
|
||||
bool do_use_c() const noexcept override;
|
||||
|
||||
std::string clang_binary_;
|
||||
bool write_preprocessed_ : 1;
|
||||
bool fast_preprocessing_ : 1;
|
||||
bool remove_comments_in_macro_ : 1;
|
||||
bool use_c_ : 1;
|
||||
|
||||
friend detail::libclang_compile_config_access;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue