diff options
| author | Jason Henline <jhen@google.com> | 2016-09-13 19:25:43 +0000 |
|---|---|---|
| committer | Jason Henline <jhen@google.com> | 2016-09-13 19:25:43 +0000 |
| commit | fb621479491f353562ec745a3daa402123110615 (patch) | |
| tree | d056f6065c45f1d2ea316a6a3ebfe44b81d1e54a /parallel-libs/streamexecutor/lib | |
| parent | 6956d290341b3ceb7fb7599c9c772c08b0c2450a (diff) | |
| download | bcm5719-llvm-fb621479491f353562ec745a3daa402123110615.tar.gz bcm5719-llvm-fb621479491f353562ec745a3daa402123110615.zip | |
[SE] Add .clang-format
Summary:
The .clang-tidy file is copied from the top-level LLVM source directory.
Also fix warnings generated by clang-format:
* Moved SimpleHostPlatformDevice.h so its header include guard could
have the right format.
* Changed signatures of methods taking llvm::Twine by value to take it
by const ref instead.
* Add "noexcept" to some move constructors and assignment operators.
* Removed a bunch of places where single-statement loops and
conditionals were surrounded with braces. (This was not found by the
current clang-tidy, but with a local patch that I hope to upstream
soon.)
Reviewers: jlebar, jprice
Subscribers: parallel_libs-commits
Differential Revision: https://reviews.llvm.org/D24468
llvm-svn: 281374
Diffstat (limited to 'parallel-libs/streamexecutor/lib')
| -rw-r--r-- | parallel-libs/streamexecutor/lib/Device.cpp | 3 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/DeviceMemory.cpp | 3 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/Error.cpp | 5 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/HostMemory.cpp | 3 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/Kernel.cpp | 4 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/KernelSpec.cpp | 11 | ||||
| -rw-r--r-- | parallel-libs/streamexecutor/lib/Stream.cpp | 4 |
7 files changed, 13 insertions, 20 deletions
diff --git a/parallel-libs/streamexecutor/lib/Device.cpp b/parallel-libs/streamexecutor/lib/Device.cpp index 260c1ba17cd..2bed3e7be16 100644 --- a/parallel-libs/streamexecutor/lib/Device.cpp +++ b/parallel-libs/streamexecutor/lib/Device.cpp @@ -29,9 +29,8 @@ Device::~Device() = default; Expected<Stream> Device::createStream() { Expected<const void *> MaybePlatformStream = PDevice->createStream(); - if (!MaybePlatformStream) { + if (!MaybePlatformStream) return MaybePlatformStream.takeError(); - } return Stream(PDevice, *MaybePlatformStream); } diff --git a/parallel-libs/streamexecutor/lib/DeviceMemory.cpp b/parallel-libs/streamexecutor/lib/DeviceMemory.cpp index 62b702b8acf..8447a60b1ca 100644 --- a/parallel-libs/streamexecutor/lib/DeviceMemory.cpp +++ b/parallel-libs/streamexecutor/lib/DeviceMemory.cpp @@ -19,10 +19,9 @@ namespace streamexecutor { GlobalDeviceMemoryBase::~GlobalDeviceMemoryBase() { - if (Handle) { + if (Handle) // TODO(jhen): How to handle errors here. consumeError(TheDevice->freeDeviceMemory(*this)); - } } } // namespace streamexecutor diff --git a/parallel-libs/streamexecutor/lib/Error.cpp b/parallel-libs/streamexecutor/lib/Error.cpp index 1f9d4a7834d..0d728fab669 100644 --- a/parallel-libs/streamexecutor/lib/Error.cpp +++ b/parallel-libs/streamexecutor/lib/Error.cpp @@ -44,14 +44,13 @@ char StreamExecutorError::ID = 0; namespace streamexecutor { -Error make_error(Twine Message) { +Error make_error(const Twine &Message) { return llvm::make_error<StreamExecutorError>(Message.str()); } std::string consumeAndGetMessage(Error &&E) { - if (!E) { + if (!E) return "success"; - } std::string Message; llvm::handleAllErrors(std::move(E), [&Message](const StreamExecutorError &SEE) { diff --git a/parallel-libs/streamexecutor/lib/HostMemory.cpp b/parallel-libs/streamexecutor/lib/HostMemory.cpp index f7fbe044aa3..8eba7e6b563 100644 --- a/parallel-libs/streamexecutor/lib/HostMemory.cpp +++ b/parallel-libs/streamexecutor/lib/HostMemory.cpp @@ -20,9 +20,8 @@ namespace internal { void destroyRegisteredHostMemoryInternals(Device *TheDevice, void *Pointer) { // TODO(jhen): How to handle errors here? - if (Pointer) { + if (Pointer) consumeError(TheDevice->unregisterHostMemory(Pointer)); - } } } // namespace internal diff --git a/parallel-libs/streamexecutor/lib/Kernel.cpp b/parallel-libs/streamexecutor/lib/Kernel.cpp index 55a83514f48..911ac6656aa 100644 --- a/parallel-libs/streamexecutor/lib/Kernel.cpp +++ b/parallel-libs/streamexecutor/lib/Kernel.cpp @@ -33,7 +33,7 @@ KernelBase::KernelBase(PlatformDevice *D, const void *PlatformKernelHandle, "cannot construct a kernel object with a null platform kernel handle"); } -KernelBase::KernelBase(KernelBase &&Other) +KernelBase::KernelBase(KernelBase &&Other) noexcept : PDevice(Other.PDevice), PlatformKernelHandle(Other.PlatformKernelHandle), Name(std::move(Other.Name)), DemangledName(std::move(Other.DemangledName)) { @@ -41,7 +41,7 @@ KernelBase::KernelBase(KernelBase &&Other) Other.PlatformKernelHandle = nullptr; } -KernelBase &KernelBase::operator=(KernelBase &&Other) { +KernelBase &KernelBase::operator=(KernelBase &&Other) noexcept { PDevice = Other.PDevice; PlatformKernelHandle = Other.PlatformKernelHandle; Name = std::move(Other.Name); diff --git a/parallel-libs/streamexecutor/lib/KernelSpec.cpp b/parallel-libs/streamexecutor/lib/KernelSpec.cpp index d2715aa88a5..b5753a489d1 100644 --- a/parallel-libs/streamexecutor/lib/KernelSpec.cpp +++ b/parallel-libs/streamexecutor/lib/KernelSpec.cpp @@ -25,9 +25,8 @@ CUDAPTXInMemorySpec::CUDAPTXInMemorySpec( llvm::StringRef KernelName, const llvm::ArrayRef<CUDAPTXInMemorySpec::PTXSpec> SpecList) : KernelLoaderSpec(KernelName) { - for (const auto &Spec : SpecList) { + for (const auto &Spec : SpecList) PTXByComputeCapability.emplace(Spec.TheComputeCapability, Spec.PTXCode); - } } const char *CUDAPTXInMemorySpec::getCode(int ComputeCapabilityMajor, @@ -35,9 +34,8 @@ const char *CUDAPTXInMemorySpec::getCode(int ComputeCapabilityMajor, auto PTXIter = PTXByComputeCapability.find(CUDAPTXInMemorySpec::ComputeCapability{ ComputeCapabilityMajor, ComputeCapabilityMinor}); - if (PTXIter == PTXByComputeCapability.end()) { + if (PTXIter == PTXByComputeCapability.end()) return nullptr; - } return PTXIter->second; } @@ -50,12 +48,11 @@ OpenCLTextInMemorySpec::OpenCLTextInMemorySpec(llvm::StringRef KernelName, : KernelLoaderSpec(KernelName), Text(Text) {} void MultiKernelLoaderSpec::setKernelName(llvm::StringRef KernelName) { - if (TheKernelName) { + if (TheKernelName) assert(KernelName.equals(*TheKernelName) && "different kernel names in one MultiKernelLoaderSpec"); - } else { + else TheKernelName = llvm::make_unique<std::string>(KernelName); - } } MultiKernelLoaderSpec &MultiKernelLoaderSpec::addCUDAPTXInMemory( diff --git a/parallel-libs/streamexecutor/lib/Stream.cpp b/parallel-libs/streamexecutor/lib/Stream.cpp index 96aad044c9c..fe135b4d0af 100644 --- a/parallel-libs/streamexecutor/lib/Stream.cpp +++ b/parallel-libs/streamexecutor/lib/Stream.cpp @@ -27,7 +27,7 @@ Stream::Stream(PlatformDevice *D, const void *PlatformStreamHandle) "cannot construct a stream object with a null platform stream handle"); } -Stream::Stream(Stream &&Other) +Stream::Stream(Stream &&Other) noexcept : PDevice(Other.PDevice), PlatformStreamHandle(Other.PlatformStreamHandle), ErrorMessageMutex(std::move(Other.ErrorMessageMutex)), ErrorMessage(std::move(Other.ErrorMessage)) { @@ -35,7 +35,7 @@ Stream::Stream(Stream &&Other) Other.PlatformStreamHandle = nullptr; } -Stream &Stream::operator=(Stream &&Other) { +Stream &Stream::operator=(Stream &&Other) noexcept { PDevice = Other.PDevice; PlatformStreamHandle = Other.PlatformStreamHandle; ErrorMessageMutex = std::move(Other.ErrorMessageMutex); |

