Author: rsingh
Date: Wed Mar  1 05:42:01 2017
New Revision: 296612

URL: http://llvm.org/viewvc/llvm-project?rev=296612&view=rev
Log:
[libcxxabi] Clean up macro usage.

Convention in libcxxabi is to use !defined(FOO) not !FOO.

Differential Revision: https://reviews.llvm.org/D30459


Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/include/__cxxabi_config.h
    libcxxabi/trunk/include/cxxabi.h
    libcxxabi/trunk/src/abort_message.cpp
    libcxxabi/trunk/src/config.h
    libcxxabi/trunk/src/cxa_default_handlers.cpp
    libcxxabi/trunk/src/cxa_exception.cpp
    libcxxabi/trunk/src/cxa_exception.hpp
    libcxxabi/trunk/src/cxa_personality.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Mar  1 05:42:01 2017
@@ -157,6 +157,11 @@ set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CAC
 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
 
+option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
+# The default terminate handler attempts to demangle uncaught exceptions, which
+# causes extra I/O and demangling code to be pulled in.
+option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler 
default to a silent alternative" OFF)
+
 if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
   message(FATAL_ERROR "libc++abi must be built as either a shared or static 
library.")
 endif()
@@ -432,11 +437,15 @@ endif()
 
 # Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation.
 if (LIBCXXABI_USE_LLVM_UNWINDER)
-  add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1)
+  add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER)
 endif()
 
 if (LIBCXXABI_SILENT_TERMINATE)
-  add_definitions(-DLIBCXXABI_SILENT_TERMINATE=1)
+  add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
+endif()
+
+if (LIBCXXABI_BAREMETAL)
+    add_definitions(-DLIBCXXABI_BAREMETAL)
 endif()
 
 string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Wed Mar  1 05:42:01 2017
@@ -12,9 +12,7 @@
 
 #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) &&                 
\
     !defined(__ARM_DWARF_EH__)
-#define _LIBCXXABI_ARM_EHABI 1
-#else
-#define _LIBCXXABI_ARM_EHABI 0
+#define _LIBCXXABI_ARM_EHABI
 #endif
 
 #if !defined(__has_attribute)

Modified: libcxxabi/trunk/include/cxxabi.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Wed Mar  1 05:42:01 2017
@@ -55,7 +55,7 @@ __cxa_get_exception_ptr(void *exceptionO
 extern _LIBCXXABI_FUNC_VIS void *
 __cxa_begin_catch(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
 extern _LIBCXXABI_FUNC_VIS bool
 __cxa_begin_cleanup(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();

Modified: libcxxabi/trunk/src/abort_message.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Wed Mar  1 05:42:01 2017
@@ -32,7 +32,7 @@ extern "C" void android_set_abort_messag
 void abort_message(const char* format, ...)
 {
     // write message to stderr
-#if !defined(NDEBUG) || !LIBCXXABI_BAREMETAL
+#if !defined(NDEBUG) || !defined(LIBCXXABI_BAREMETAL)
 #ifdef __APPLE__
     fprintf(stderr, "libc++abi.dylib: ");
 #endif

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Wed Mar  1 05:42:01 2017
@@ -16,18 +16,4 @@
 
 #include <unistd.h>
 
-// Set this in the CXXFLAGS when you need it, because otherwise we'd have to
-// #if !defined(__linux__) && !defined(__APPLE__) && ...
-// and so-on for *every* platform.
-#ifndef LIBCXXABI_BAREMETAL
-#  define LIBCXXABI_BAREMETAL 0
-#endif
-
-// The default terminate handler attempts to demangle uncaught exceptions, 
which
-// causes extra I/O and demangling code to be pulled in.
-// Set this to make the terminate handler default to a silent alternative.
-#ifndef LIBCXXABI_SILENT_TERMINATE
-#  define LIBCXXABI_SILENT_TERMINATE 0
-#endif
-
 #endif // LIBCXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Wed Mar  1 05:42:01 2017
@@ -85,7 +85,7 @@ static void demangling_unexpected_handle
     std::terminate();
 }
 
-#if !LIBCXXABI_SILENT_TERMINATE
+#if !defined(LIBCXXABI_SILENT_TERMINATE)
 static std::terminate_handler default_terminate_handler = 
demangling_terminate_handler;
 static std::terminate_handler default_unexpected_handler = 
demangling_unexpected_handler;
 #else

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Mar  1 05:42:01 2017
@@ -234,7 +234,7 @@ The adjusted pointer is computed by the
   Requires:  exception is native
 */
 void *__cxa_get_exception_ptr(void *unwind_exception) throw() {
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
     return reinterpret_cast<void*>(
         
static_cast<_Unwind_Control_Block*>(unwind_exception)->barrier_cache.bitpattern[0]);
 #else
@@ -243,7 +243,7 @@ void *__cxa_get_exception_ptr(void *unwi
 #endif
 }
 
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
 /*
 The routine to be called before the cleanup.  This will save __cxa_exception in
 __cxa_eh_globals, so that __cxa_end_cleanup() can recover later.
@@ -325,7 +325,7 @@ asm (
     "  bl      abort\n"
     "  .popsection"
 );
-#endif  // _LIBCXXABI_ARM_EHABI
+#endif  // defined(_LIBCXXABI_ARM_EHABI)
     
 /*
 This routine can catch foreign or native exceptions.  If native, the exception
@@ -385,7 +385,7 @@ __cxa_begin_catch(void* unwind_arg) thro
             globals->caughtExceptions = exception_header;
         }
         globals->uncaughtExceptions -= 1;   // Not atomically, since globals 
are thread-local
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
         return 
reinterpret_cast<void*>(exception_header->unwindHeader.barrier_cache.bitpattern[0]);
 #else
         return exception_header->adjustedPtr;

Modified: libcxxabi/trunk/src/cxa_exception.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.hpp?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.hpp (original)
+++ libcxxabi/trunk/src/cxa_exception.hpp Wed Mar  1 05:42:01 2017
@@ -25,7 +25,7 @@ static const uint64_t kOurDependentExcep
 static const uint64_t get_vendor_and_language     = 0xFFFFFFFFFFFFFF00; // 
mask for CLNGC++
 
 struct _LIBCXXABI_HIDDEN __cxa_exception {
-#if defined(__LP64__) || _LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
     // This is a new field to support C++ 0x exception_ptr.
     // For binary compatibility it is at the start of this
     // struct which is prepended to the object thrown in
@@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception
 
     int handlerCount;
 
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
     __cxa_exception* nextPropagatingException;
     int propagationCount;
 #else
@@ -54,7 +54,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception
     void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !_LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI)
     // This is a new field to support C++ 0x exception_ptr.
     // For binary compatibility it is placed where the compiler
     // previously adding padded to 64-bit align unwindHeader.
@@ -68,7 +68,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception
 // The layout of this structure MUST match the layout of __cxa_exception, with
 // primaryException instead of referenceCount.
 struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
-#if defined(__LP64__) || _LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI)
     void* primaryException;
 #endif
 
@@ -81,7 +81,7 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent
 
     int handlerCount;
 
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
     __cxa_exception* nextPropagatingException;
     int propagationCount;
 #else
@@ -92,7 +92,7 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent
     void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !_LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI)
     void* primaryException;
 #endif
 
@@ -102,7 +102,7 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent
 struct _LIBCXXABI_HIDDEN __cxa_eh_globals {
     __cxa_exception *   caughtExceptions;
     unsigned int        uncaughtExceptions;
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
     __cxa_exception* propagatingExceptions;
 #endif
 };

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=296612&r1=296611&r2=296612&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Wed Mar  1 05:42:01 2017
@@ -317,7 +317,7 @@ call_terminate(bool native_exception, _U
     std::terminate();
 }
 
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
 static const void* read_target2_value(const void* ptr)
 {
     uintptr_t offset = *reinterpret_cast<const uintptr_t*>(ptr);
@@ -328,7 +328,7 @@ static const void* read_target2_value(co
     // deferred to the linker. For bare-metal they turn into absolute
     // relocations. For linux they turn into GOT-REL relocations."
     // https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00264.html
-#if LIBCXXABI_BAREMETAL
+#if defined(LIBCXXABI_BAREMETAL)
     return reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(ptr) +
                                          offset);
 #else
@@ -358,7 +358,7 @@ get_shim_type_info(uint64_t ttypeIndex,
     return reinterpret_cast<const __shim_type_info *>(
         read_target2_value(ttypePtr));
 }
-#else // !_LIBCXXABI_ARM_EHABI
+#else // !defined(_LIBCXXABI_ARM_EHABI)
 static
 const __shim_type_info*
 get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
@@ -394,7 +394,7 @@ get_shim_type_info(uint64_t ttypeIndex,
     classInfo -= ttypeIndex;
     return (const __shim_type_info*)readEncodedPointer(&classInfo, 
ttypeEncoding);
 }
-#endif // !_LIBCXXABI_ARM_EHABI
+#endif // !defined(_LIBCXXABI_ARM_EHABI)
 
 /*
     This is checking a thrown exception type, excpType, against a possibly 
empty
@@ -405,7 +405,7 @@ get_shim_type_info(uint64_t ttypeIndex,
     the list will catch a excpType.  If any catchType in the list can catch an
     excpType, then this exception spec does not catch the excpType.
 */
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
 static
 bool
 exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
@@ -934,7 +934,7 @@ _UA_CLEANUP_PHASE
         Else a cleanup is not found: return _URC_CONTINUE_UNWIND
 */
 
-#if !_LIBCXXABI_ARM_EHABI
+#if !defined(_LIBCXXABI_ARM_EHABI)
 _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
 #ifdef __USING_SJLJ_EXCEPTIONS__
 __gxx_personality_sj0
@@ -1194,7 +1194,7 @@ __cxa_call_unexpected(void* arg)
         u_handler = old_exception_header->unexpectedHandler;
         // If std::__unexpected(u_handler) rethrows the same exception,
         //   these values get overwritten by the rethrow.  So save them now:
-#if _LIBCXXABI_ARM_EHABI
+#if defined(_LIBCXXABI_ARM_EHABI)
         ttypeIndex = 
(int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];
         lsda = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];
 #else


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to