mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
clang_generator: Skip dependent types
PiperOrigin-RevId: 490508865 Change-Id: Ic1d49a4abfde4cd02f08dd24c3f7a20058ef4965
This commit is contained in:
parent
d7fe6cd334
commit
cded8655d3
|
@ -295,6 +295,26 @@ TEST_F(EmitterTest, TypedefTypeDependencies) {
|
|||
" int size; }"));
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, OmitDependentTypes) {
|
||||
EmitterForTesting emitter;
|
||||
EXPECT_THAT(
|
||||
RunFrontendAction(
|
||||
R"(template <typename T>
|
||||
struct Callback {
|
||||
typedef void (T::*MemberSignature)();
|
||||
MemberSignature pointer;
|
||||
};
|
||||
struct S : public Callback<S> {
|
||||
void Callable() {}
|
||||
};
|
||||
extern "C" void Invoke(S::MemberSignature* cb);)",
|
||||
std::make_unique<GeneratorAction>(emitter, GeneratorOptions())),
|
||||
IsOk());
|
||||
EXPECT_THAT(emitter.GetRenderedFunctions(), SizeIs(1));
|
||||
|
||||
EXPECT_THAT(UglifyAll(emitter.SpellingsForNS("")), IsEmpty());
|
||||
}
|
||||
|
||||
TEST(IncludeGuard, CreatesRandomizedGuardForEmptyFilename) {
|
||||
// Copybara will transform the string. This is intentional.
|
||||
constexpr absl::string_view kGeneratedHeaderPrefix =
|
||||
|
|
|
@ -147,6 +147,14 @@ std::vector<clang::TypeDecl*> TypeCollector::GetTypeDeclarations() {
|
|||
for (clang::TypeDecl* type_decl : ordered_decls_) {
|
||||
clang::QualType type_decl_type = context.getTypeDeclType(type_decl);
|
||||
|
||||
// Filter out problematic dependent types that we cannot emit properly.
|
||||
// CollectRelatedTypes() cannot skip those, as it runs before this
|
||||
// information is available.
|
||||
if (type_decl_type->isMemberFunctionPointerType() &&
|
||||
type_decl_type->isDependentType()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ideally, collected_.contains() on the underlying QualType of the TypeDecl
|
||||
// would work here. However, QualTypes obtained from a TypeDecl contain
|
||||
// different Type pointers, even when referring to one of the same types
|
||||
|
|
Loading…
Reference in New Issue
Block a user