@@ -17,32 +17,32 @@ using namespace llvm;
1717using namespace llvm ::object;
1818
1919struct 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 ;
2323
2424 RustArchiveMember ()
25- : filename (nullptr ), name (nullptr ),
25+ : Filename (nullptr ), Name (nullptr ),
2626#if LLVM_VERSION_GE(3, 8)
27- child (nullptr , nullptr , nullptr )
27+ Child (nullptr , nullptr , nullptr )
2828#else
29- child (nullptr , nullptr )
29+ Child (nullptr , nullptr )
3030#endif
3131 {
3232 }
3333 ~RustArchiveMember () {}
3434};
3535
3636struct 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 ;
4040#if LLVM_VERSION_GE(3, 9)
41- Error err ;
41+ Error Err ;
4242
43- RustArchiveIterator () : first (true ), err (Error::success()) {}
43+ RustArchiveIterator () : First (true ), Err (Error::success()) {}
4444#else
45- RustArchiveIterator () : first (true ) {}
45+ RustArchiveIterator () : First (true ) {}
4646#endif
4747};
4848
@@ -54,8 +54,8 @@ enum class LLVMRustArchiveKind {
5454 COFF,
5555};
5656
57- static Archive::Kind from_rust (LLVMRustArchiveKind kind ) {
58- switch (kind ) {
57+ static Archive::Kind fromRust (LLVMRustArchiveKind Kind ) {
58+ switch (Kind ) {
5959 case LLVMRustArchiveKind::GNU:
6060 return Archive::K_GNU;
6161 case LLVMRustArchiveKind::MIPS64:
@@ -75,59 +75,61 @@ typedef Archive::Child *LLVMRustArchiveChildRef;
7575typedef Archive::Child const *LLVMRustArchiveChildConstRef;
7676typedef RustArchiveIterator *LLVMRustArchiveIteratorRef;
7777
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 ());
8383 return nullptr ;
8484 }
8585
8686#if LLVM_VERSION_LE(3, 8)
87- ErrorOr<std::unique_ptr<Archive>> archive_or =
87+ ErrorOr<std::unique_ptr<Archive>> ArchiveOr =
8888#else
89- Expected<std::unique_ptr<Archive>> archive_or =
89+ Expected<std::unique_ptr<Archive>> ArchiveOr =
9090#endif
91- Archive::create (buf_or .get ()->getMemBufferRef ());
91+ Archive::create (BufOr .get ()->getMemBufferRef ());
9292
93- if (!archive_or ) {
93+ if (!ArchiveOr ) {
9494#if LLVM_VERSION_LE(3, 8)
95- LLVMRustSetLastError (archive_or .getError ().message ().c_str ());
95+ LLVMRustSetLastError (ArchiveOr .getError ().message ().c_str ());
9696#else
97- LLVMRustSetLastError (toString (archive_or .takeError ()).c_str ());
97+ LLVMRustSetLastError (toString (ArchiveOr .takeError ()).c_str ());
9898#endif
9999 return nullptr ;
100100 }
101101
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 ()));
104104
105- return ret ;
105+ return Ret ;
106106}
107107
108- extern " C" void LLVMRustDestroyArchive (LLVMRustArchiveRef ar) { delete ar; }
108+ extern " C" void LLVMRustDestroyArchive (LLVMRustArchiveRef RustArchive) {
109+ delete RustArchive;
110+ }
109111
110112extern " 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 ();
114116#if LLVM_VERSION_LE(3, 8)
115- rai-> cur = ar ->child_begin ();
117+ RAI-> Cur = Archive ->child_begin ();
116118#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 ;
121123 return nullptr ;
122124 }
123125#endif
124- rai-> end = ar ->child_end ();
125- return rai ;
126+ RAI-> End = Archive ->child_end ();
127+ return RAI ;
126128}
127129
128130extern " C" LLVMRustArchiveChildConstRef
129- LLVMRustArchiveIteratorNext (LLVMRustArchiveIteratorRef rai ) {
130- if (rai-> cur == rai-> end )
131+ LLVMRustArchiveIteratorNext (LLVMRustArchiveIteratorRef RAI ) {
132+ if (RAI-> Cur == RAI-> End )
131133 return nullptr ;
132134
133135 // Advancing the iterator validates the next child, and this can
@@ -136,94 +138,94 @@ LLVMRustArchiveIteratorNext(LLVMRustArchiveIteratorRef rai) {
136138 // the next child.
137139 // This means we must not advance the iterator in the *first* call,
138140 // 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 ;
141143#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 ());
144146 return nullptr ;
145147 }
146148#endif
147149 } else {
148- rai-> first = false ;
150+ RAI-> First = false ;
149151 }
150152
151- if (rai-> cur == rai-> end )
153+ if (RAI-> Cur == RAI-> End )
152154 return nullptr ;
153155
154156#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 ());
158160 return nullptr ;
159161 }
160- const Archive::Child &child = cur ->get ();
162+ const Archive::Child &Child = Cur ->get ();
161163#else
162- const Archive::Child &child = *rai-> cur .operator ->();
164+ const Archive::Child &Child = *RAI-> Cur .operator ->();
163165#endif
164- Archive::Child *ret = new Archive::Child (child );
166+ Archive::Child *Ret = new Archive::Child (Child );
165167
166- return ret ;
168+ return Ret ;
167169}
168170
169- extern " C" void LLVMRustArchiveChildFree (LLVMRustArchiveChildRef child ) {
170- delete child ;
171+ extern " C" void LLVMRustArchiveChildFree (LLVMRustArchiveChildRef Child ) {
172+ delete Child ;
171173}
172174
173- extern " C" void LLVMRustArchiveIteratorFree (LLVMRustArchiveIteratorRef rai ) {
174- delete rai ;
175+ extern " C" void LLVMRustArchiveIteratorFree (LLVMRustArchiveIteratorRef RAI ) {
176+ delete RAI ;
175177}
176178
177179extern " C" const char *
178- LLVMRustArchiveChildName (LLVMRustArchiveChildConstRef child , size_t *size ) {
180+ LLVMRustArchiveChildName (LLVMRustArchiveChildConstRef Child , size_t *Size ) {
179181#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 ());
186188 return nullptr ;
187189 }
188190#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 ())
191193 return nullptr ;
192194#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 ();
196198}
197199
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 ;
201203#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 ());
205207 return nullptr ;
206208 }
207209#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 ());
211213 return nullptr ;
212214 }
213215#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 ();
217219}
218220
219221extern " C" LLVMRustArchiveMemberRef
220222LLVMRustArchiveMemberNew (char *Filename, char *Name,
221- LLVMRustArchiveChildRef child ) {
223+ LLVMRustArchiveChildRef Child ) {
222224 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 ;
227229 return Member;
228230}
229231
@@ -234,38 +236,38 @@ extern "C" void LLVMRustArchiveMemberFree(LLVMRustArchiveMemberRef Member) {
234236extern " C" LLVMRustResult
235237LLVMRustWriteArchive (char *Dst, size_t NumMembers,
236238 const LLVMRustArchiveMemberRef *NewMembers,
237- bool WriteSymbtab, LLVMRustArchiveKind rust_kind ) {
239+ bool WriteSymbtab, LLVMRustArchiveKind RustKind ) {
238240
239241#if LLVM_VERSION_LE(3, 8)
240242 std::vector<NewArchiveIterator> Members;
241243#else
242244 std::vector<NewArchiveMember> Members;
243245#endif
244- auto Kind = from_rust (rust_kind );
246+ auto Kind = fromRust (RustKind );
245247
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 ) {
250252#if LLVM_VERSION_GE(3, 9)
251253 Expected<NewArchiveMember> MOrErr =
252- NewArchiveMember::getFile (Member->filename , true );
254+ NewArchiveMember::getFile (Member->Filename , true );
253255 if (!MOrErr) {
254256 LLVMRustSetLastError (toString (MOrErr.takeError ()).c_str ());
255257 return LLVMRustResult::Failure;
256258 }
257259 Members.push_back (std::move (*MOrErr));
258260#elif LLVM_VERSION_EQ(3, 8)
259- Members.push_back (NewArchiveIterator (Member->filename ));
261+ Members.push_back (NewArchiveIterator (Member->Filename ));
260262#else
261- Members.push_back (NewArchiveIterator (Member->filename , Member->name ));
263+ Members.push_back (NewArchiveIterator (Member->Filename , Member->Name ));
262264#endif
263265 } else {
264266#if LLVM_VERSION_LE(3, 8)
265- Members.push_back (NewArchiveIterator (Member->child , Member->name ));
267+ Members.push_back (NewArchiveIterator (Member->Child , Member->Name ));
266268#else
267269 Expected<NewArchiveMember> MOrErr =
268- NewArchiveMember::getOldMember (Member->child , true );
270+ NewArchiveMember::getOldMember (Member->Child , true );
269271 if (!MOrErr) {
270272 LLVMRustSetLastError (toString (MOrErr.takeError ()).c_str ());
271273 return LLVMRustResult::Failure;
@@ -275,12 +277,12 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
275277 }
276278 }
277279#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 );
279281#else
280- auto pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true );
282+ auto Pair = writeArchive (Dst, Members, WriteSymbtab, Kind, true );
281283#endif
282- if (!pair .second )
284+ if (!Pair .second )
283285 return LLVMRustResult::Success;
284- LLVMRustSetLastError (pair .second .message ().c_str ());
286+ LLVMRustSetLastError (Pair .second .message ().c_str ());
285287 return LLVMRustResult::Failure;
286288}
0 commit comments