components/llvm/patches/009-solaris-clang-libclangSema.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Thu, 28 Jul 2016 16:25:34 -0700
changeset 6512 92717ce71105
permissions -rw-r--r--
24326140 upgrade LLVM to 3.8.1 24326159 upgrade clang to 3.8.1 22902339 memory corruption caused by undefined behavior in LLVM IR Module 22777179 implement [ -mtune= -march= -mcpu= ] in clang SPARC 22778085 LLVM is using %icc when it should be using %xcc 22778089 the SPARCV9 IS implementation is incomplete 22778098 LLVM should emit proc identifiers in SPARC assembler (capabilities) 22778650 clang should support OpenMP because it can 22859423 llvm CodeGen on Intel emits a bogus .ctors section 22902355 clang CodeGen is affected by 22902339 23701635 clang produces amd64 opcodes, but calls 32-bit assembler by default 23593143 lli JIT bitcode parsing creates a main function with wrong argc/argv 21759660 clang packages should include the scan-view and scan-build utilities 23854357 clang should check for GNU ld 17867434 clang crashed in LEXER 24306550 clang crashes in llvm::Twine::toStringRef 24311726 clang's Perl and Python utilities should not use #!/usr/bin/env 24312028 llvm::Twine needs copy constructors and assignment operators 24312221 classes must be CopyConstructible, CopyAssignable, MoveConstructible ... 24314621 LLVM should build using the new CMake based build system 24314638 LLVM CommandLine subsystem is busted 24314687 static initialization of optimization passes doesn't work as intended 21870069 clang makes incorrect assumptions about anonymous namespace instantiation order 22643565 llvm's Google test harness needs some attention 24314745 clang should support PIE executables in Solaris

# 22902355 clang CodeGen is affected by 22902339
# 3.9.X upstream.
--- tools/clang/include/clang/Sema/AttributeList.h	2015-12-02 12:07:30.000000000 -0500
+++ tools/clang/include/clang/Sema/AttributeList.h	2016-05-08 23:19:20.555431312 -0400
@@ -475,6 +475,27 @@
   unsigned getSemanticSpelling() const;
 };
 
+static_assert(
+  llvm::AlignOf<AttributeList>::Alignment >=
+  llvm::AlignOf<ArgsUnion>::Alignment,
+  "Alignment is insufficient for objects appended to AttributeList");
+static_assert(
+  llvm::AlignOf<ArgsUnion>::Alignment >=
+  llvm::AlignOf<AvailabilityChange>::Alignment,
+  "Alignment is insufficient for objects appended to AttributeList");
+static_assert(
+  llvm::AlignOf<ArgsUnion>::Alignment >=
+  llvm::AlignOf<AttributeList::TypeTagForDatatypeData>::Alignment,
+  "Alignment is insufficient for objects appended to AttributeList");
+static_assert(
+  llvm::AlignOf<AttributeList>::Alignment >=
+  llvm::AlignOf<ParsedType>::Alignment,
+  "Alignment is insufficient for objects appended to AttributeList");
+static_assert(
+  llvm::AlignOf<AttributeList>::Alignment >=
+  llvm::AlignOf<AttributeList::PropertyData>::Alignment,
+  "Alignment is insufficient for objects appended to AttributeList");
+
 /// A factory, from which one makes pools, from which one creates
 /// individual attributes which are deallocated with the pool.
 ///
--- tools/clang/include/clang/Sema/CodeCompleteConsumer.h	2015-07-07 02:20:19.000000000 -0400
+++ tools/clang/include/clang/Sema/CodeCompleteConsumer.h	2016-05-08 23:19:20.555431312 -0400
@@ -494,6 +494,14 @@
   /// which is mainly useful for debugging.
   std::string getAsString() const;
 };
+static_assert(
+    llvm::AlignOf<CodeCompletionString>::Alignment >=
+        llvm::AlignOf<CodeCompletionString::Chunk>::Alignment,
+    "Alignment is insufficient for objects appended to CodeCompletionString");
+static_assert(
+    llvm::AlignOf<CodeCompletionString::Chunk>::Alignment >=
+        llvm::AlignOf<const char *>::Alignment,
+    "Alignment is insufficient for objects appended to CodeCompletionString");
 
 /// \brief An allocator used specifically for the purpose of code completion.
 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
--- tools/clang/include/clang/Sema/ParsedTemplate.h	2015-06-22 19:07:51.000000000 -0400
+++ tools/clang/include/clang/Sema/ParsedTemplate.h	2016-05-08 23:19:20.555431312 -0400
@@ -205,6 +205,10 @@
       free(this); 
     }
   };
+  static_assert(
+      llvm::AlignOf<TemplateIdAnnotation>::Alignment >=
+          llvm::AlignOf<ParsedTemplateArgument>::Alignment,
+      "Alignment is insufficient for objects appended to TemplateIdAnnotation");
 
   /// Retrieves the range of the given template parameter lists.
   SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params,
--- tools/clang/lib/Sema/SemaExceptionSpec.cpp	2015-12-18 16:45:41.000000000 -0500
+++ tools/clang/lib/Sema/SemaExceptionSpec.cpp	2016-05-08 23:19:20.576431823 -0400
@@ -998,9 +998,8 @@
   case Expr::LambdaExprClass: {
     const LambdaExpr *Lambda = cast<LambdaExpr>(E);
     CanThrowResult CT = CT_Cannot;
-    for (LambdaExpr::const_capture_init_iterator
-             Cap = Lambda->capture_init_begin(),
-             CapEnd = Lambda->capture_init_end();
+    for (LambdaExpr::const_capture_init_iterator Cap =
+         Lambda->capture_init_begin(), CapEnd = Lambda->capture_init_end();
          Cap != CapEnd; ++Cap)
       CT = mergeCanThrow(CT, canThrow(*Cap));
     return CT;
--- tools/clang/lib/Sema/TypeLocBuilder.cpp	2014-05-26 02:22:03.000000000 -0400
+++ tools/clang/lib/Sema/TypeLocBuilder.cpp	2016-05-08 23:19:20.576431823 -0400
@@ -13,6 +13,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "TypeLocBuilder.h"
+#include <cstring>
+#include <stdlib.h>
 
 using namespace clang;
 
@@ -46,14 +48,35 @@
   assert(NewCapacity > Capacity);
 
   // Allocate the new buffer and copy the old data into it.
-  char *NewBuffer = new char[NewCapacity];
+  char *NewBuffer;
+
+#if defined(_MSC_VER)
+  NewBuffer = _aligned_malloc(NewCapacity, (size_t) BufferMaxAlignment);
+  assert(NewBuffer && "_aligned_malloc failed!");
+  if (!NewBuffer) {
+    llvm::errs() << __PRETTY_FUNCTION__ << ": _aligned_malloc failed!\n";
+    abort();
+  }
+#else
+  int R = posix_memalign((void**) &NewBuffer,
+                         (size_t) BufferMaxAlignment, NewCapacity);
+  assert((R == 0) && "posix_memalign failed!");
+  assert(NewBuffer && "posix_memalign failed!");
+  if ((R != 0) || (!NewBuffer)) {
+    llvm::errs() << __PRETTY_FUNCTION__ << ": posix_memalign failed!\n";
+    abort();
+  }
+#endif
+
+  (void) std::memset(NewBuffer, 0, NewCapacity);
+
   unsigned NewIndex = Index + NewCapacity - Capacity;
-  memcpy(&NewBuffer[NewIndex],
-         &Buffer[Index],
-         Capacity - Index);
+  (void) std::memcpy(&NewBuffer[NewIndex],
+                     &Buffer[Index],
+                     Capacity - Index);
 
   if (Buffer != InlineBuffer.buffer)
-    delete[] Buffer;
+    std::free(Buffer);
 
   Buffer = NewBuffer;
   Capacity = NewCapacity;
--- tools/clang/lib/Sema/TypeLocBuilder.h	2015-06-22 19:07:51.000000000 -0400
+++ tools/clang/lib/Sema/TypeLocBuilder.h	2016-05-08 23:19:20.577431847 -0400
@@ -39,7 +39,7 @@
 #endif
     
   /// The inline buffer.
-  enum { BufferMaxAlignment = llvm::AlignOf<void*>::Alignment };
+  enum { BufferMaxAlignment = llvm::AlignOf<uint64_t>::Alignment };
   llvm::AlignedCharArray<BufferMaxAlignment, InlineCapacity> InlineBuffer;
   unsigned NumBytesAtAlign4, NumBytesAtAlign8;
 
@@ -52,7 +52,7 @@
 
   ~TypeLocBuilder() {
     if (Buffer != InlineBuffer.buffer)
-      delete[] Buffer;
+      std::free(Buffer);
   }
 
   /// Ensures that this buffer has at least as much capacity as described.