Fix out-of-class destructor definition
This commit is contained in:
parent
e6271f4c0d
commit
b5a5e42955
2 changed files with 16 additions and 6 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <cppast/cpp_function.hpp>
|
#include <cppast/cpp_function.hpp>
|
||||||
#include <cppast/cpp_member_function.hpp>
|
#include <cppast/cpp_member_function.hpp>
|
||||||
|
#include <clang-c/Index.h>
|
||||||
|
|
||||||
#include "libclang_visitor.hpp"
|
#include "libclang_visitor.hpp"
|
||||||
#include "parse_functions.hpp"
|
#include "parse_functions.hpp"
|
||||||
|
|
@ -657,13 +658,15 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_destructor(const detail::parse_con
|
||||||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||||
detail::token_stream stream(tokenizer, cur);
|
detail::token_stream stream(tokenizer, cur);
|
||||||
|
|
||||||
auto is_virtual = detail::skip_if(stream, "virtual");
|
auto prefix_info = parse_prefix_info(stream, "~", false);
|
||||||
detail::skip(stream, "~");
|
DEBUG_ASSERT(!prefix_info.is_constexpr && !prefix_info.is_explicit, detail::assert_handler{});
|
||||||
|
|
||||||
auto name = std::string("~") + stream.get().c_str();
|
auto name = std::string("~") + stream.get().c_str();
|
||||||
cpp_destructor::builder builder(std::move(name));
|
cpp_destructor::builder builder(std::move(name));
|
||||||
context.comments.match(builder.get(), cur);
|
context.comments.match(builder.get(), cur);
|
||||||
|
|
||||||
detail::skip(stream, "(");
|
detail::skip(stream, "(");
|
||||||
detail::skip(stream, ")");
|
detail::skip(stream, ")");
|
||||||
return handle_suffix(context, cur, builder, stream, is_virtual, type_safe::nullopt);
|
return handle_suffix(context, cur, builder, stream, prefix_info.is_virtual,
|
||||||
|
std::move(prefix_info.semantic_parent));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,10 @@ struct d : c
|
||||||
/// virtual ~d() override final;
|
/// virtual ~d() override final;
|
||||||
~d() final;
|
~d() final;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// virtual d::~d() override;
|
||||||
|
d::~d() {}
|
||||||
|
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto file = parse({}, "cpp_destructor.cpp", code);
|
auto file = parse({}, "cpp_destructor.cpp", code);
|
||||||
|
|
@ -364,12 +368,15 @@ struct d : c
|
||||||
else if (dtor.name() == "~d")
|
else if (dtor.name() == "~d")
|
||||||
{
|
{
|
||||||
REQUIRE(dtor.virtual_info());
|
REQUIRE(dtor.virtual_info());
|
||||||
REQUIRE(dtor.virtual_info().value()
|
if (dtor.is_declaration())
|
||||||
== (cpp_virtual_flags::override | cpp_virtual_flags::final));
|
REQUIRE(dtor.virtual_info().value()
|
||||||
|
== (cpp_virtual_flags::override | cpp_virtual_flags::final));
|
||||||
|
else
|
||||||
|
REQUIRE(dtor.virtual_info().value() == cpp_virtual_flags::override);
|
||||||
REQUIRE(!dtor.noexcept_condition());
|
REQUIRE(!dtor.noexcept_condition());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
REQUIRE(false);
|
REQUIRE(false);
|
||||||
});
|
});
|
||||||
REQUIRE(count == 4u);
|
REQUIRE(count == 5u);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue