From b2881f1fbef62b8a9ba38af2f763a54e24ef5022 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 6 Sep 2016 19:39:56 +0000 Subject: [PATCH] Fix ItaniumDemangle.cpp build with MSVC 2013 llvm-svn: 280740 --- llvm/lib/Demangle/ItaniumDemangle.cpp | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Demangle/ItaniumDemangle.cpp b/llvm/lib/Demangle/ItaniumDemangle.cpp index ff533f6..d261aa0 100644 --- a/llvm/lib/Demangle/ItaniumDemangle.cpp +++ b/llvm/lib/Demangle/ItaniumDemangle.cpp @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// -#include +#include "llvm/Demangle/Demangle.h" +#include "llvm/Support/Compiler.h" // This file exports a single function: llvm::itanium_demangle. // It also has no dependencies on the rest of llvm. It is implemented this way @@ -4211,27 +4212,27 @@ static void demangle(const char *first, const char *last, C &db, int &status) { namespace { template class arena { static const std::size_t alignment = 16; - alignas(alignment) char buf_[N]; + LLVM_ALIGNAS(16) char buf_[N]; char *ptr_; - std::size_t align_up(std::size_t n) noexcept { + std::size_t align_up(std::size_t n) LLVM_NOEXCEPT { return (n + (alignment - 1)) & ~(alignment - 1); } - bool pointer_in_buffer(char *p) noexcept { + bool pointer_in_buffer(char *p) LLVM_NOEXCEPT { return buf_ <= p && p <= buf_ + N; } public: - arena() noexcept : ptr_(buf_) {} + arena() LLVM_NOEXCEPT : ptr_(buf_) {} ~arena() { ptr_ = nullptr; } arena(const arena &) = delete; arena &operator=(const arena &) = delete; char *allocate(std::size_t n); - void deallocate(char *p, std::size_t n) noexcept; + void deallocate(char *p, std::size_t n) LLVM_NOEXCEPT; - static constexpr std::size_t size() { return N; } + static LLVM_CONSTEXPR std::size_t size() { return N; } std::size_t used() const { return static_cast(ptr_ - buf_); } void reset() { ptr_ = buf_; } }; @@ -4247,7 +4248,7 @@ template char *arena::allocate(std::size_t n) { } template -void arena::deallocate(char *p, std::size_t n) noexcept { +void arena::deallocate(char *p, std::size_t n) LLVM_NOEXCEPT { if (pointer_in_buffer(p)) { n = align_up(n); if (p + n == ptr_) @@ -4265,35 +4266,35 @@ public: public: template struct rebind { typedef short_alloc<_Up, N> other; }; - short_alloc(arena &a) noexcept : a_(a) {} + short_alloc(arena &a) LLVM_NOEXCEPT : a_(a) {} template - short_alloc(const short_alloc &a) noexcept : a_(a.a_) {} + short_alloc(const short_alloc &a) LLVM_NOEXCEPT : a_(a.a_) {} short_alloc(const short_alloc &) = default; short_alloc &operator=(const short_alloc &) = delete; T *allocate(std::size_t n) { return reinterpret_cast(a_.allocate(n * sizeof(T))); } - void deallocate(T *p, std::size_t n) noexcept { + void deallocate(T *p, std::size_t n) LLVM_NOEXCEPT { a_.deallocate(reinterpret_cast(p), n * sizeof(T)); } template friend bool operator==(const short_alloc &x, - const short_alloc &y) noexcept; + const short_alloc &y) LLVM_NOEXCEPT; template friend class short_alloc; }; template inline bool operator==(const short_alloc &x, - const short_alloc &y) noexcept { + const short_alloc &y) LLVM_NOEXCEPT { return N == M && &x.a_ == &y.a_; } template inline bool operator!=(const short_alloc &x, - const short_alloc &y) noexcept { + const short_alloc &y) LLVM_NOEXCEPT { return !(x == y); } @@ -4308,12 +4309,12 @@ public: typedef std::ptrdiff_t difference_type; malloc_alloc() = default; - template malloc_alloc(const malloc_alloc &) noexcept {} + template malloc_alloc(const malloc_alloc &) LLVM_NOEXCEPT {} T *allocate(std::size_t n) { return static_cast(std::malloc(n * sizeof(T))); } - void deallocate(T *p, std::size_t) noexcept { std::free(p); } + void deallocate(T *p, std::size_t) LLVM_NOEXCEPT { std::free(p); } template struct rebind { using other = malloc_alloc; }; template void construct(U *p, Args &&... args) { @@ -4324,13 +4325,13 @@ public: template inline bool operator==(const malloc_alloc &, - const malloc_alloc &) noexcept { + const malloc_alloc &) LLVM_NOEXCEPT { return true; } template inline bool operator!=(const malloc_alloc &x, - const malloc_alloc &y) noexcept { + const malloc_alloc &y) LLVM_NOEXCEPT { return !(x == y); } -- 2.7.4