Add forward declarations (#116)

This commit is contained in:
Julian Rüth 2022-01-31 09:19:12 -05:00 committed by GitHub
commit 5069f2f167
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 163 additions and 40 deletions

View file

@ -44,6 +44,7 @@ set(header
../include/cppast/cpp_variable_template.hpp
../include/cppast/diagnostic.hpp
../include/cppast/diagnostic_logger.hpp
../include/cppast/cppast_fwd.hpp
../include/cppast/libclang_parser.hpp
../include/cppast/parser.hpp
../include/cppast/visitor.hpp)

View file

@ -494,6 +494,7 @@ namespace
std::vector<const char*> get_arguments(const libclang_compile_config& config)
{
std::vector<const char*> args
// TODO: Why? and Why?
= {"-x", "c++", "-I."}; // force C++ and enable current directory for include search
for (auto& flag : detail::libclang_compile_config_access::flags(config))
args.push_back(flag.c_str());

View file

@ -99,6 +99,25 @@ bool need_to_remove_scope(const CXCursor& cur, const CXType& type)
std::string get_type_spelling(const CXCursor& cur, const CXType& type)
{
// TODO: There are two interesting things we should keep track of here:
// * The canonical name of a type (easy, clang has a shortcut for that)
// * The type definition of this type, say for:
// std::vector<int, default_alloator...> this should be the type (we
// should ignore specialization here!) vector<T, S> whose parent is a
// namespace in this case but could again be a concrete type as well (to
// handle nested type specializations correctly.)
/*
auto ns_name = [](const CXCursor& cur) {
auto parent = clang_getCursorSemanticParent(cur);
if (clang_getCursorKind(parent) == CXCursor_TranslationUnit)
return "";
if (clang_getCursorKind(parent) == CXCursor_Namespace)
return spelling of cursor ...
};
*/
// auto canonical = detail::cxstring(clang_getTypeSpelling(clang_getCanonicalType(type))).std_str();
// auto declaration = detail::cxstring(clang_getCursorSpelling(clang_getTypeDeclaration(type))).std_str();
auto spelling = detail::cxstring(clang_getTypeSpelling(type)).std_str();
if (need_to_remove_scope(cur, type))
{