Skip to content

Commit ff42c48

Browse files
committed
[next] Handle new BTFTagAttributedType
Introduced in llvm/llvm-project 3251ba2d0fcf5223fce3e270b91c54f548664b4e.
1 parent 59bc1c9 commit ff42c48

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

include/swift/ClangImporter/SwiftAbstractBasicReader.h

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class DataStreamBasicReader
8989
clang::QualType type = asImpl().readTypeRef();
9090
return getASTContext().getQualifiedType(type, quals);
9191
}
92+
93+
const clang::BTFTypeTagAttr *readBTFTypeTagAttr() {
94+
llvm::report_fatal_error("Read BTFTypeTagAttr that should never have been"
95+
" serialized");
96+
}
9297
};
9398

9499
}

include/swift/ClangImporter/SwiftAbstractBasicWriter.h

+15-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define SWIFT_CLANGIMPORTER_SWIFTABSTRACTBASICWRITER_H
2222

2323
#include "clang/AST/AbstractTypeWriter.h"
24+
#include "clang/AST/Type.h"
2425

2526
namespace swift {
2627

@@ -80,11 +81,24 @@ class DataStreamBasicWriter
8081
assert(!type.isNull());
8182

8283
auto split = type.split();
83-
asImpl().writeQualifiers(split.Quals);
84+
auto qualifiers = split.Quals;
8485

86+
// Unwrap BTFTagAttributeType and merge any of its qualifiers.
87+
while (auto btfType = dyn_cast<clang::BTFTagAttributedType>(split.Ty)) {
88+
split = btfType->getWrappedType().split();
89+
qualifiers.addQualifiers(split.Quals);
90+
}
91+
92+
asImpl().writeQualifiers(qualifiers);
8593
// Just recursively visit the given type.
8694
asImpl().writeTypeRef(split.Ty);
8795
}
96+
97+
void writeBTFTypeTagAttr(const clang::BTFTypeTagAttr *attr) {
98+
// BTFTagAttributeType is explicitly unwrapped above, so we should never
99+
// hit any of its attributes.
100+
llvm::report_fatal_error("Should never hit BTFTypeTagAttr serialization");
101+
}
88102
};
89103

90104
}

lib/ClangImporter/ImportType.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ namespace {
930930
SUGAR_TYPE(SubstTemplateTypeParm)
931931
SUGAR_TYPE(Elaborated)
932932
SUGAR_TYPE(Using)
933+
SUGAR_TYPE(BTFTagAttributed)
933934

934935
ImportResult VisitDecayedType(const clang::DecayedType *type) {
935936
clang::ASTContext &clangCtx = Impl.getClangASTContext();

0 commit comments

Comments
 (0)