|
| 1 | +From 6c941686f1a230d23685b2fcab104d88391f967a Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Wed, 8 Jun 2022 13:18:08 +0200 |
| 4 | +Subject: [PATCH] c2rust-exporter: Remove Atomics warnings |
| 5 | + |
| 6 | +As atomics are being implemented, these warnings are becoming wrong. Any |
| 7 | +operations on atomics that stay unimplmented will be caught more |
| 8 | +precisely at later translation stages. |
| 9 | +--- |
| 10 | + c2rust-ast-exporter/src/AstExporter.cpp | 54 ------------------------- |
| 11 | + 1 file changed, 54 deletions(-) |
| 12 | + |
| 13 | +diff --git a/c2rust-ast-exporter/src/AstExporter.cpp b/c2rust-ast-exporter/src/AstExporter.cpp |
| 14 | +index d5e9e7b68..56cce5c93 100644 |
| 15 | +--- a/c2rust-ast-exporter/src/AstExporter.cpp |
| 16 | ++++ b/c2rust-ast-exporter/src/AstExporter.cpp |
| 17 | +@@ -189,24 +189,6 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> { |
| 18 | + astEncoder(ast) {} |
| 19 | + |
| 20 | + void VisitQualType(const QualType &QT) { |
| 21 | +- if(isa<AtomicType>(QT)) { |
| 22 | +- // No printC11AtomicError available here and no location |
| 23 | +- // information either -- should better have been caught at the |
| 24 | +- // caller, but catching it here is still better than the |
| 25 | +- // nondescript error messages that would come later. |
| 26 | +- std::string msg = "C11 Atomics are not supported. No precise " |
| 27 | +- "location information available. Aborting."; |
| 28 | +- |
| 29 | +- auto &DiagEngine = Context->getDiagnostics(); |
| 30 | +- // Prefix warnings with `c2rust`, so the user can distinguish |
| 31 | +- // our warning messages from those generated by clang itself. |
| 32 | +- const auto ID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Error, |
| 33 | +- "c2rust: %0"); |
| 34 | +- DiagEngine.Report(SourceLocation::getFromRawEncoding(0), ID).AddString(msg); |
| 35 | +- |
| 36 | +- abort(); |
| 37 | +- } |
| 38 | +- |
| 39 | + if (!QT.isNull()) { |
| 40 | + auto s = QT.split(); |
| 41 | + |
| 42 | +@@ -1919,10 +1901,6 @@ class TranslateASTVisitor final |
| 43 | + // Use the type from the definition in case the extern was an incomplete |
| 44 | + // type |
| 45 | + auto T = def->getType(); |
| 46 | +- if(isa<AtomicType>(T)) { |
| 47 | +- printC11AtomicError(def); |
| 48 | +- abort(); |
| 49 | +- } |
| 50 | + |
| 51 | + auto loc = is_defn ? def->getLocation() : VD->getLocation(); |
| 52 | + |
| 53 | +@@ -2006,12 +1984,6 @@ class TranslateASTVisitor final |
| 54 | + auto recordAlignment = 0; |
| 55 | + auto byteSize = 0; |
| 56 | + |
| 57 | +- auto t = D->getTypeForDecl(); |
| 58 | +- if(isa<AtomicType>(t)) { |
| 59 | +- printC11AtomicError(D); |
| 60 | +- abort(); |
| 61 | +- } |
| 62 | +- |
| 63 | + auto loc = D->getLocation(); |
| 64 | + std::vector<void *> childIds; |
| 65 | + if (def) { |
| 66 | +@@ -2084,12 +2056,6 @@ class TranslateASTVisitor final |
| 67 | + // They are used in actual code and accepted by compilers, so we cannot |
| 68 | + // exit early via code like `if (!D->isCompleteDefinition()) return true;`. |
| 69 | + |
| 70 | +- auto t = D->getTypeForDecl(); |
| 71 | +- if(isa<AtomicType>(t)) { |
| 72 | +- printC11AtomicError(D); |
| 73 | +- abort(); |
| 74 | +- } |
| 75 | +- |
| 76 | + std::vector<void *> childIds; |
| 77 | + for (auto x : D->enumerators()) { |
| 78 | + childIds.push_back(x->getCanonicalDecl()); |
| 79 | +@@ -2148,10 +2114,6 @@ class TranslateASTVisitor final |
| 80 | + |
| 81 | + std::vector<void *> childIds; |
| 82 | + auto t = D->getType(); |
| 83 | +- if(isa<AtomicType>(t)) { |
| 84 | +- printC11AtomicError(D); |
| 85 | +- abort(); |
| 86 | +- } |
| 87 | + |
| 88 | + auto record = D->getParent(); |
| 89 | + const ASTRecordLayout &layout = |
| 90 | +@@ -2206,17 +2168,6 @@ class TranslateASTVisitor final |
| 91 | + cbor_encode_boolean(array, D->isImplicit()); |
| 92 | + }); |
| 93 | + |
| 94 | +- if(isa<AtomicType>(typeForDecl)) { |
| 95 | +- // This case is especially checked as that's what happens when |
| 96 | +- // clang's stdatomic.h is traversed. Other callers of VisitQualType |
| 97 | +- // could get the same check to preserve the location information |
| 98 | +- // available in Decl but not in Type, but those are more likely not |
| 99 | +- // to be hit, and can fall back to the less descriptive error from |
| 100 | +- // inside there. |
| 101 | +- printC11AtomicError(D); |
| 102 | +- abort(); |
| 103 | +- } |
| 104 | +- |
| 105 | + typeEncoder.VisitQualType(typeForDecl); |
| 106 | + |
| 107 | + return true; |
| 108 | +@@ -2373,11 +2324,6 @@ class TranslateASTVisitor final |
| 109 | + CharSourceRange::getCharRange(E->getSourceRange())); |
| 110 | + } |
| 111 | + |
| 112 | +- void printC11AtomicError(Decl *D) { |
| 113 | +- std::string msg = "C11 Atomics are not supported. Aborting."; |
| 114 | +- printError(msg, D); |
| 115 | +- } |
| 116 | +- |
| 117 | + void printError(std::string Message, Decl *D) { |
| 118 | + auto DiagBuilder = |
| 119 | + getDiagBuilder(D->getLocation(), DiagnosticsEngine::Error); |
0 commit comments