@@ -17,32 +17,32 @@ using namespace llvm;
17
17
using namespace llvm ::object;
18
18
19
19
struct RustArchiveMember {
20
- const char *filename ;
21
- const char *name ;
22
- Archive::Child child ;
20
+ const char *Filename ;
21
+ const char *Name ;
22
+ Archive::Child Child ;
23
23
24
24
RustArchiveMember ()
25
- : filename (nullptr ), name (nullptr ),
25
+ : Filename (nullptr ), Name (nullptr ),
26
26
#if LLVM_VERSION_GE(3, 8)
27
- child (nullptr , nullptr , nullptr )
27
+ Child (nullptr , nullptr , nullptr )
28
28
#else
29
- child (nullptr , nullptr )
29
+ Child (nullptr , nullptr )
30
30
#endif
31
31
{
32
32
}
33
33
~RustArchiveMember () {}
34
34
};
35
35
36
36
struct RustArchiveIterator {
37
- bool first ;
38
- Archive::child_iterator cur ;
39
- Archive::child_iterator end ;
37
+ bool First ;
38
+ Archive::child_iterator Cur ;
39
+ Archive::child_iterator End ;
40
40
#if LLVM_VERSION_GE(3, 9)
41
- Error err ;
41
+ Error Err ;
42
42
43
- RustArchiveIterator () : first (true ), err (Error::success()) {}
43
+ RustArchiveIterator () : First (true ), Err (Error::success()) {}
44
44
#else
45
- RustArchiveIterator () : first (true ) {}
45
+ RustArchiveIterator () : First (true ) {}
46
46
#endif
47
47
};
48
48
@@ -54,8 +54,8 @@ enum class LLVMRustArchiveKind {
54
54
COFF,
55
55
};
56
56
57
- static Archive::Kind from_rust (LLVMRustArchiveKind kind ) {
58
- switch (kind ) {
57
+ static Archive::Kind fromRust (LLVMRustArchiveKind Kind ) {
58
+ switch (Kind ) {
59
59
case LLVMRustArchiveKind::GNU:
60
60
return Archive::K_GNU;
61
61
case LLVMRustArchiveKind::MIPS64:
@@ -75,59 +75,61 @@ typedef Archive::Child *LLVMRustArchiveChildRef;
75
75
typedef Archive::Child const *LLVMRustArchiveChildConstRef;
76
76
typedef RustArchiveIterator *LLVMRustArchiveIteratorRef;
77
77
78
- extern " C" LLVMRustArchiveRef LLVMRustOpenArchive (char *path ) {
79
- ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or =
80
- MemoryBuffer::getFile (path , -1 , false );
81
- if (!buf_or ) {
82
- LLVMRustSetLastError (buf_or .getError ().message ().c_str ());
78
+ extern " C" LLVMRustArchiveRef LLVMRustOpenArchive (char *Path ) {
79
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufOr =
80
+ MemoryBuffer::getFile (Path , -1 , false );
81
+ if (!BufOr ) {
82
+ LLVMRustSetLastError (BufOr .getError ().message ().c_str ());
83
83
return nullptr ;
84
84
}
85
85
86
86
#if LLVM_VERSION_LE(3, 8)
87
- ErrorOr<std::unique_ptr<Archive>> archive_or =
87
+ ErrorOr<std::unique_ptr<Archive>> ArchiveOr =
88
88
#else
89
- Expected<std::unique_ptr<Archive>> archive_or =
89
+ Expected<std::unique_ptr<Archive>> ArchiveOr =
90
90
#endif
91
- Archive::create (buf_or .get ()->getMemBufferRef ());
91
+ Archive::create (BufOr .get ()->getMemBufferRef ());
92
92
93
- if (!archive_or ) {
93
+ if (!ArchiveOr ) {
94
94
#if LLVM_VERSION_LE(3, 8)
95
- LLVMRustSetLastError (archive_or .getError ().message ().c_str ());
95
+ LLVMRustSetLastError (ArchiveOr .getError ().message ().c_str ());
96
96
#else
97
- LLVMRustSetLastError (toString (archive_or .takeError ()).c_str ());
97
+ LLVMRustSetLastError (toString (ArchiveOr .takeError ()).c_str ());
98
98
#endif
99
99
return nullptr ;
100
100
}
101
101
102
- OwningBinary<Archive> *ret = new OwningBinary<Archive>(
103
- std::move (archive_or .get ()), std::move (buf_or .get ()));
102
+ OwningBinary<Archive> *Ret = new OwningBinary<Archive>(
103
+ std::move (ArchiveOr .get ()), std::move (BufOr .get ()));
104
104
105
- return ret ;
105
+ return Ret ;
106
106
}
107
107
108
- extern " C" void LLVMRustDestroyArchive (LLVMRustArchiveRef ar) { delete ar; }
108
+ extern " C" void LLVMRustDestroyArchive (LLVMRustArchiveRef RustArchive) {
109
+ delete RustArchive;
110
+ }
109
111
110
112
extern " C" LLVMRustArchiveIteratorRef
111
- LLVMRustArchiveIteratorNew (LLVMRustArchiveRef ra ) {
112
- Archive *ar = ra ->getBinary ();
113
- RustArchiveIterator *rai = new RustArchiveIterator ();
113
+ LLVMRustArchiveIteratorNew (LLVMRustArchiveRef RustArchive ) {
114
+ Archive *Archive = RustArchive ->getBinary ();
115
+ RustArchiveIterator *RAI = new RustArchiveIterator ();
114
116
#if LLVM_VERSION_LE(3, 8)
115
- rai-> cur = ar ->child_begin ();
117
+ RAI-> Cur = Archive ->child_begin ();
116
118
#else
117
- rai-> cur = ar ->child_begin (rai-> err );
118
- if (rai-> err ) {
119
- LLVMRustSetLastError (toString (std::move (rai-> err )).c_str ());
120
- delete rai ;
119
+ RAI-> Cur = Archive ->child_begin (RAI-> Err );
120
+ if (RAI-> Err ) {
121
+ LLVMRustSetLastError (toString (std::move (RAI-> Err )).c_str ());
122
+ delete RAI ;
121
123
return nullptr ;
122
124
}
123
125
#endif
124
- rai-> end = ar ->child_end ();
125
- return rai ;
126
+ RAI-> End = Archive ->child_end ();
127
+ return RAI ;
126
128
}
127
129
128
130
extern " C" LLVMRustArchiveChildConstRef
129
- LLVMRustArchiveIteratorNext (LLVMRustArchiveIteratorRef rai ) {
130
- if (rai-> cur == rai-> end )
131
+ LLVMRustArchiveIteratorNext (LLVMRustArchiveIteratorRef RAI ) {
132
+ if (RAI-> Cur == RAI-> End )
131
133
return nullptr ;
132
134
133
135
// Advancing the iterator validates the next child, and this can
@@ -136,94 +138,94 @@ LLVMRustArchiveIteratorNext(LLVMRustArchiveIteratorRef rai) {
136
138
// the next child.
137
139
// This means we must not advance the iterator in the *first* call,
138
140
// but instead advance it *before* fetching the child in all later calls.
139
- if (!rai-> first ) {
140
- ++rai-> cur ;
141
+ if (!RAI-> First ) {
142
+ ++RAI-> Cur ;
141
143
#if LLVM_VERSION_GE(3, 9)
142
- if (rai-> err ) {
143
- LLVMRustSetLastError (toString (std::move (rai-> err )).c_str ());
144
+ if (RAI-> Err ) {
145
+ LLVMRustSetLastError (toString (std::move (RAI-> Err )).c_str ());
144
146
return nullptr ;
145
147
}
146
148
#endif
147
149
} else {
148
- rai-> first = false ;
150
+ RAI-> First = false ;
149
151
}
150
152
151
- if (rai-> cur == rai-> end )
153
+ if (RAI-> Cur == RAI-> End )
152
154
return nullptr ;
153
155
154
156
#if LLVM_VERSION_EQ(3, 8)
155
- const ErrorOr<Archive::Child> *cur = rai-> cur .operator ->();
156
- if (!*cur ) {
157
- LLVMRustSetLastError (cur ->getError ().message ().c_str ());
157
+ const ErrorOr<Archive::Child> *Cur = RAI-> Cur .operator ->();
158
+ if (!*Cur ) {
159
+ LLVMRustSetLastError (Cur ->getError ().message ().c_str ());
158
160
return nullptr ;
159
161
}
160
- const Archive::Child &child = cur ->get ();
162
+ const Archive::Child &Child = Cur ->get ();
161
163
#else
162
- const Archive::Child &child = *rai-> cur .operator ->();
164
+ const Archive::Child &Child = *RAI-> Cur .operator ->();
163
165
#endif
164
- Archive::Child *ret = new Archive::Child (child );
166
+ Archive::Child *Ret = new Archive::Child (Child );
165
167
166
- return ret ;
168
+ return Ret ;
167
169
}
168
170
169
- extern " C" void LLVMRustArchiveChildFree (LLVMRustArchiveChildRef child ) {
170
- delete child ;
171
+ extern " C" void LLVMRustArchiveChildFree (LLVMRustArchiveChildRef Child ) {
172
+ delete Child ;
171
173
}
172
174
173
- extern " C" void LLVMRustArchiveIteratorFree (LLVMRustArchiveIteratorRef rai ) {
174
- delete rai ;
175
+ extern " C" void LLVMRustArchiveIteratorFree (LLVMRustArchiveIteratorRef RAI ) {
176
+ delete RAI ;
175
177
}
176
178
177
179
extern " C" const char *
178
- LLVMRustArchiveChildName (LLVMRustArchiveChildConstRef child , size_t *size ) {
180
+ LLVMRustArchiveChildName (LLVMRustArchiveChildConstRef Child , size_t *Size ) {
179
181
#if LLVM_VERSION_GE(4, 0)
180
- Expected<StringRef> name_or_err = child ->getName ();
181
- if (!name_or_err ) {
182
- // rustc_llvm currently doesn't use this error string, but it might be useful
183
- // in the future, and in the mean time this tells LLVM that the error was
184
- // not ignored and that it shouldn't abort the process.
185
- LLVMRustSetLastError (toString (name_or_err .takeError ()).c_str ());
182
+ Expected<StringRef> NameOrErr = Child ->getName ();
183
+ if (!NameOrErr ) {
184
+ // rustc_llvm currently doesn't use this error string, but it might be
185
+ // useful in the future, and in the mean time this tells LLVM that the
186
+ // error was not ignored and that it shouldn't abort the process.
187
+ LLVMRustSetLastError (toString (NameOrErr .takeError ()).c_str ());
186
188
return nullptr ;
187
189
}
188
190
#else
189
- ErrorOr<StringRef> name_or_err = child ->getName ();
190
- if (name_or_err .getError ())
191
+ ErrorOr<StringRef> NameOrErr = Child ->getName ();
192
+ if (NameOrErr .getError ())
191
193
return nullptr ;
192
194
#endif
193
- StringRef name = name_or_err .get ();
194
- *size = name .size ();
195
- return name .data ();
195
+ StringRef Name = NameOrErr .get ();
196
+ *Size = Name .size ();
197
+ return Name .data ();
196
198
}
197
199
198
- extern " C" const char *LLVMRustArchiveChildData (LLVMRustArchiveChildRef child ,
199
- size_t *size ) {
200
- StringRef buf ;
200
+ extern " C" const char *LLVMRustArchiveChildData (LLVMRustArchiveChildRef Child ,
201
+ size_t *Size ) {
202
+ StringRef Buf ;
201
203
#if LLVM_VERSION_GE(4, 0)
202
- Expected<StringRef> buf_or_err = child ->getBuffer ();
203
- if (!buf_or_err ) {
204
- LLVMRustSetLastError (toString (buf_or_err .takeError ()).c_str ());
204
+ Expected<StringRef> BufOrErr = Child ->getBuffer ();
205
+ if (!BufOrErr ) {
206
+ LLVMRustSetLastError (toString (BufOrErr .takeError ()).c_str ());
205
207
return nullptr ;
206
208
}
207
209
#else
208
- ErrorOr<StringRef> buf_or_err = child ->getBuffer ();
209
- if (buf_or_err .getError ()) {
210
- LLVMRustSetLastError (buf_or_err .getError ().message ().c_str ());
210
+ ErrorOr<StringRef> BufOrErr = Child ->getBuffer ();
211
+ if (BufOrErr .getError ()) {
212
+ LLVMRustSetLastError (BufOrErr .getError ().message ().c_str ());
211
213
return nullptr ;
212
214
}
213
215
#endif
214
- buf = buf_or_err .get ();
215
- *size = buf .size ();
216
- return buf .data ();
216
+ Buf = BufOrErr .get ();
217
+ *Size = Buf .size ();
218
+ return Buf .data ();
217
219
}
218
220
219
221
extern " C" LLVMRustArchiveMemberRef
220
222
LLVMRustArchiveMemberNew (char *Filename, char *Name,
221
- LLVMRustArchiveChildRef child ) {
223
+ LLVMRustArchiveChildRef Child ) {
222
224
RustArchiveMember *Member = new RustArchiveMember;
223
- Member->filename = Filename;
224
- Member->name = Name;
225
- if (child )
226
- Member->child = *child ;
225
+ Member->Filename = Filename;
226
+ Member->Name = Name;
227
+ if (Child )
228
+ Member->Child = *Child ;
227
229
return Member;
228
230
}
229
231
@@ -234,38 +236,38 @@ extern "C" void LLVMRustArchiveMemberFree(LLVMRustArchiveMemberRef Member) {
234
236
extern " C" LLVMRustResult
235
237
LLVMRustWriteArchive (char *Dst, size_t NumMembers,
236
238
const LLVMRustArchiveMemberRef *NewMembers,
237
- bool WriteSymbtab, LLVMRustArchiveKind rust_kind ) {
239
+ bool WriteSymbtab, LLVMRustArchiveKind RustKind ) {
238
240
239
241
#if LLVM_VERSION_LE(3, 8)
240
242
std::vector<NewArchiveIterator> Members;
241
243
#else
242
244
std::vector<NewArchiveMember> Members;
243
245
#endif
244
- auto Kind = from_rust (rust_kind );
246
+ auto Kind = fromRust (RustKind );
245
247
246
- for (size_t i = 0 ; i < NumMembers; i ++) {
247
- auto Member = NewMembers[i ];
248
- assert (Member->name );
249
- if (Member->filename ) {
248
+ for (size_t I = 0 ; I < NumMembers; I ++) {
249
+ auto Member = NewMembers[I ];
250
+ assert (Member->Name );
251
+ if (Member->Filename ) {
250
252
#if LLVM_VERSION_GE(3, 9)
251
253
Expected<NewArchiveMember> MOrErr =
252
- NewArchiveMember::getFile (Member->filename , true );
254
+ NewArchiveMember::getFile (Member->Filename , true );
253
255
if (!MOrErr) {
254
256
LLVMRustSetLastError (toString (MOrErr.takeError ()).c_str ());
255
257
return LLVMRustResult::Failure;
256
258
}
257
259
Members.push_back (std::move (*MOrErr));
258
260
#elif LLVM_VERSION_EQ(3, 8)
259
- Members.push_back (NewArchiveIterator (Member->filename ));
261
+ Members.push_back (NewArchiveIterator (Member->Filename ));
260
262
#else
261
- Members.push_back (NewArchiveIterator (Member->filename , Member->name ));
263
+ Members.push_back (NewArchiveIterator (Member->Filename , Member->Name ));
262
264
#endif
263
265
} else {
264
266
#if LLVM_VERSION_LE(3, 8)
265
- Members.push_back (NewArchiveIterator (Member->child , Member->name ));
267
+ Members.push_back (NewArchiveIterator (Member->Child , Member->Name ));
266
268
#else
267
269
Expected<NewArchiveMember> MOrErr =
268
- NewArchiveMember::getOldMember (Member->child , true );
270
+ NewArchiveMember::getOldMember (Member->Child , true );
269
271
if (!MOrErr) {
270
272
LLVMRustSetLastError (toString (MOrErr.takeError ()).c_str ());
271
273
return LLVMRustResult::Failure;
@@ -275,12 +277,12 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
275
277
}
276
278
}
277
279
#if LLVM_VERSION_GE(3, 8)
278
- auto pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true , false );
280
+ auto Pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true , false );
279
281
#else
280
- auto pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true );
282
+ auto Pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true );
281
283
#endif
282
- if (!pair .second )
284
+ if (!Pair .second )
283
285
return LLVMRustResult::Success;
284
- LLVMRustSetLastError (pair .second .message ().c_str ());
286
+ LLVMRustSetLastError (Pair .second .message ().c_str ());
285
287
return LLVMRustResult::Failure;
286
288
}
0 commit comments