diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-07 00:57:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-07 00:57:40 +0100 |
| commit | 869529a13085da190f9870d544fd9018bda2e487 (patch) | |
| tree | 33b1c2221e663435e98e2aacbe4e2742cf4b9526 /compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp | |
| parent | 8dc49e1b8ef4f6e67db9b5c97546df6b8319e398 (diff) | |
| parent | 23623a08d6a181864a7b8609682eee27534b12f4 (diff) | |
| download | rust-869529a13085da190f9870d544fd9018bda2e487.tar.gz rust-869529a13085da190f9870d544fd9018bda2e487.zip | |
Rollup merge of #122062 - workingjubilee:initialize-my-fist, r=cuviper
Explicitly assign constructed C++ classes C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors[^0] that do not perform any complicated logic in their constructor. I contend that all constructors that the `rustc_llvm` code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision. The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs. [^0]: e.g. https://abseil.io/tips/88
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp index 91f84692df8..ee8239ef8e7 100644 --- a/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Object/ObjectFile.h" +#include <llvm/Support/raw_ostream.h> using namespace llvm; using namespace llvm::sys; @@ -42,7 +43,7 @@ extern "C" void *LLVMRustGetSymbols( MemoryBuffer::getMemBuffer(StringRef(BufPtr, BufLen), StringRef("LLVMRustGetSymbolsObject"), false); SmallString<0> SymNameBuf; - raw_svector_ostream SymName(SymNameBuf); + auto SymName = raw_svector_ostream(SymNameBuf); // In the scenario when LLVMContext is populated SymbolicFile will contain a // reference to it, thus SymbolicFile should be destroyed first. @@ -60,7 +61,7 @@ extern "C" void *LLVMRustGetSymbols( if (!ObjOrErr) { Error E = ObjOrErr.takeError(); SmallString<0> ErrorBuf; - raw_svector_ostream Error(ErrorBuf); + auto Error = raw_svector_ostream(ErrorBuf); Error << E << '\0'; return ErrorCallback(Error.str().data()); } @@ -70,7 +71,7 @@ extern "C" void *LLVMRustGetSymbols( if (!ObjOrErr) { Error E = ObjOrErr.takeError(); SmallString<0> ErrorBuf; - raw_svector_ostream Error(ErrorBuf); + auto Error = raw_svector_ostream(ErrorBuf); Error << E << '\0'; return ErrorCallback(Error.str().data()); } @@ -83,7 +84,7 @@ extern "C" void *LLVMRustGetSymbols( continue; if (Error E = S.printName(SymName)) { SmallString<0> ErrorBuf; - raw_svector_ostream Error(ErrorBuf); + auto Error = raw_svector_ostream(ErrorBuf); Error << E << '\0'; return ErrorCallback(Error.str().data()); } |
