@@ -140,6 +140,25 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
140
140
cbor_encoder_close_container (encoder, &local);
141
141
}
142
142
143
+ DiagnosticBuilder getDiagBuilder (SourceLocation Loc,
144
+ DiagnosticsEngine::Level Lvl) {
145
+ auto &DiagEngine = Context->getDiagnostics ();
146
+ // Prefix warnings with `c2rust`, so the user can distinguish
147
+ // our warning messages from those generated by clang itself.
148
+ const auto ID = DiagEngine.getCustomDiagID (Lvl, " c2rust: %0" );
149
+ return DiagEngine.Report (Loc, ID);
150
+ }
151
+
152
+ void printWarning (std::string Message,
153
+ SourceLocation S,
154
+ SourceRange R = SourceRange()) {
155
+ auto DiagBuilder =
156
+ getDiagBuilder (S, DiagnosticsEngine::Warning);
157
+ DiagBuilder.AddString (Message);
158
+ DiagBuilder.AddSourceRange (
159
+ CharSourceRange::getCharRange (R));
160
+ }
161
+
143
162
public:
144
163
uintptr_t encodeQualType (QualType t) {
145
164
auto s = t.split ();
@@ -303,9 +322,36 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
303
322
TypeTag tag;
304
323
auto kind = T->getKind ();
305
324
325
+ #if CLANG_VERSION_MAJOR >= 11
326
+ // Handle built-in vector types as if they're normal vector types
327
+ if (kind >= BuiltinType::SveInt8 && kind <= BuiltinType::SveBool) {
328
+ auto Info = Context->getBuiltinVectorTypeInfo (T);
329
+ auto t = Info.ElementType ;
330
+ auto qt = encodeQualType (t);
331
+
332
+ encodeType (T, TagVectorType, [T, qt, Info](CborEncoder *local) {
333
+ cbor_encode_uint (local, qt);
334
+ cbor_encode_uint (local, Info.EC .getKnownMinValue () *
335
+ Info.NumVectors );
336
+ });
337
+
338
+ VisitQualType (t);
339
+ return ;
340
+ }
341
+ #endif
342
+
306
343
// clang-format off
307
344
switch (kind) {
308
- default : tag = TagTypeUnknown; break ;
345
+ default : {
346
+ auto pol = clang::PrintingPolicy (Context->getLangOpts ());
347
+ auto warning = std::string (" Encountered unsupported BuiltinType kind " ) +
348
+ std::to_string ((int )kind) + " for type " +
349
+ T->getName (pol).str ();
350
+ printWarning (warning, clang::FullSourceLoc ());
351
+ tag = TagTypeUnknown;
352
+ break ;
353
+ }
354
+
309
355
case BuiltinType::BuiltinFn: tag = TagBuiltinFn; break ;
310
356
case BuiltinType::UInt128: tag = TagUInt128; break ;
311
357
case BuiltinType::Int128: tag = TagInt128; break ;
0 commit comments