aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-11 16:29:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-11 16:29:35 +0000
commit46faa67da1d7e9450e8fa363f6633e2c68e33ff1 (patch)
treeba7f8dbcd8358d07c15d1da6c2c2cc38f0febeb6
parent874094833caedbee43fd17cca164dec53d500bdc (diff)
downloadsrc-46faa67da1d7e9450e8fa363f6633e2c68e33ff1.tar.gz
src-46faa67da1d7e9450e8fa363f6633e2c68e33ff1.zip
Vendor import of clang release_70 branch r339355:vendor/clang/clang-release_70-r339355
Notes
Notes: svn path=/vendor/clang/dist-release_70/; revision=337633 svn path=/vendor/clang/clang-release_70-r339355/; revision=337634; tag=vendor/clang/clang-release_70-r339355
-rw-r--r--docs/AddressSanitizer.rst6
-rw-r--r--docs/MemorySanitizer.rst7
-rw-r--r--docs/ReleaseNotes.rst3
-rw-r--r--lib/CodeGen/CGBlocks.cpp28
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp38
-rw-r--r--lib/CodeGen/CodeGenAction.cpp1
-rw-r--r--lib/Headers/unwind.h4
-rw-r--r--lib/Sema/SemaExprCXX.cpp10
-rw-r--r--test/CodeGen/global-blocks-win32.c18
-rw-r--r--test/SemaCXX/constructor.cpp11
-rw-r--r--test/lit.cfg.py2
-rw-r--r--www/cxx_dr_status.html20
-rw-r--r--www/cxx_status.html6
-rwxr-xr-xwww/make_cxx_dr_status5
14 files changed, 105 insertions, 54 deletions
diff --git a/docs/AddressSanitizer.rst b/docs/AddressSanitizer.rst
index 7549159a39ab..3404b669e248 100644
--- a/docs/AddressSanitizer.rst
+++ b/docs/AddressSanitizer.rst
@@ -144,6 +144,12 @@ For more information on leak detector in AddressSanitizer, see
and can be enabled using ``ASAN_OPTIONS=detect_leaks=1`` on OS X;
however, it is not yet supported on other platforms.
+Writable/Executable paging detection
+------------------------------------
+
+The W^X detection is disabled by default and can be enabled using
+``ASAN_OPTIONS=detect_write_exec=1``.
+
Issue Suppression
=================
diff --git a/docs/MemorySanitizer.rst b/docs/MemorySanitizer.rst
index 4e033fa1941d..e979186be1ac 100644
--- a/docs/MemorySanitizer.rst
+++ b/docs/MemorySanitizer.rst
@@ -165,6 +165,13 @@ to:
#. Set environment variable `MSAN_OPTIONS=poison_in_dtor=1` before running
the program.
+Writable/Executable paging detection
+====================================
+
+You can eable writable-executable page detection in MemorySanitizer by
+setting the environment variable `MSAN_OPTIONS=detect_write_exec=1` before
+running the program.
+
Handling external code
======================
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 01702023c540..5f446d85dc8c 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -284,7 +284,8 @@ libclang
Static Analyzer
---------------
-- ...
+- The new `MmapWriteExec` checker had been introduced to detect attempts to map pages
+both writable and executable.
...
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 8269b5b229a2..906b98bfbafe 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -1213,9 +1213,13 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
auto fields = builder.beginStruct();
bool IsOpenCL = CGM.getLangOpts().OpenCL;
+ bool IsWindows = CGM.getTarget().getTriple().isOSWindows();
if (!IsOpenCL) {
// isa
- fields.add(CGM.getNSConcreteGlobalBlock());
+ if (IsWindows)
+ fields.addNullPointer(CGM.Int8PtrPtrTy);
+ else
+ fields.add(CGM.getNSConcreteGlobalBlock());
// __flags
BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE;
@@ -1250,7 +1254,27 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
llvm::Constant *literal = fields.finishAndCreateGlobal(
"__block_literal_global", blockInfo.BlockAlign,
- /*constant*/ true, llvm::GlobalVariable::InternalLinkage, AddrSpace);
+ /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, AddrSpace);
+
+ // Windows does not allow globals to be initialised to point to globals in
+ // different DLLs. Any such variables must run code to initialise them.
+ if (IsWindows) {
+ auto *Init = llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy,
+ {}), llvm::GlobalValue::InternalLinkage, ".block_isa_init",
+ &CGM.getModule());
+ llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry",
+ Init));
+ b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(),
+ b.CreateStructGEP(literal, 0), CGM.getPointerAlign().getQuantity());
+ b.CreateRetVoid();
+ // We can't use the normal LLVM global initialisation array, because we
+ // need to specify that this runs early in library initialisation.
+ auto *InitVar = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
+ /*isConstant*/true, llvm::GlobalValue::InternalLinkage,
+ Init, ".block_isa_init_ptr");
+ InitVar->setSection(".CRT$XCLa");
+ CGM.addUsedGlobal(InitVar);
+ }
// Return a constant of the appropriately-casted type.
llvm::Type *RequiredType =
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 3e994edc976b..915738b8b301 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -3812,40 +3812,10 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
// is. This allows code compiled with non-fragile ivars to work correctly
// when linked against code which isn't (most of the time).
llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name);
- if (!IvarOffsetPointer) {
- // This will cause a run-time crash if we accidentally use it. A value of
- // 0 would seem more sensible, but will silently overwrite the isa pointer
- // causing a great deal of confusion.
- uint64_t Offset = -1;
- // We can't call ComputeIvarBaseOffset() here if we have the
- // implementation, because it will create an invalid ASTRecordLayout object
- // that we are then stuck with forever, so we only initialize the ivar
- // offset variable with a guess if we only have the interface. The
- // initializer will be reset later anyway, when we are generating the class
- // description.
- if (!CGM.getContext().getObjCImplementation(
- const_cast<ObjCInterfaceDecl *>(ID)))
- Offset = ComputeIvarBaseOffset(CGM, ID, Ivar);
-
- llvm::ConstantInt *OffsetGuess = llvm::ConstantInt::get(Int32Ty, Offset,
- /*isSigned*/true);
- // Don't emit the guess in non-PIC code because the linker will not be able
- // to replace it with the real version for a library. In non-PIC code you
- // must compile with the fragile ABI if you want to use ivars from a
- // GCC-compiled class.
- if (CGM.getLangOpts().PICLevel) {
- llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
- Int32Ty, false,
- llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
- IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
- IvarOffsetGV->getType(), false, llvm::GlobalValue::LinkOnceAnyLinkage,
- IvarOffsetGV, Name);
- } else {
- IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
- llvm::Type::getInt32PtrTy(VMContext), false,
- llvm::GlobalValue::ExternalLinkage, nullptr, Name);
- }
- }
+ if (!IvarOffsetPointer)
+ IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
+ llvm::Type::getInt32PtrTy(VMContext), false,
+ llvm::GlobalValue::ExternalLinkage, nullptr, Name);
return IvarOffsetPointer;
}
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index d499364002f0..1a2b0616dc77 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -127,6 +127,7 @@ namespace clang {
CodeGenOpts, C, CoverageInfo)),
LinkModules(std::move(LinkModules)) {
FrontendTimesIsEnabled = TimePasses;
+ llvm::TimePassesIsEnabled = TimePasses;
}
llvm::Module *getModule() const { return Gen->GetModule(); }
std::unique_ptr<llvm::Module> takeModule() {
diff --git a/lib/Headers/unwind.h b/lib/Headers/unwind.h
index 345fa4d0c193..0e8317e5b9d9 100644
--- a/lib/Headers/unwind.h
+++ b/lib/Headers/unwind.h
@@ -154,8 +154,12 @@ struct _Unwind_Control_Block {
struct _Unwind_Exception {
_Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
+#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
+ _Unwind_Word private_[6];
+#else
_Unwind_Word private_1;
_Unwind_Word private_2;
+#endif
/* The Itanium ABI requires that _Unwind_Exception objects are "double-word
* aligned". GCC has interpreted this to mean "use the maximum useful
* alignment for the target"; so do we. */
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index a1168fa34d56..7a8f2d3f4702 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -113,9 +113,15 @@ ParsedType Sema::getConstructorName(IdentifierInfo &II,
break;
}
}
- if (!InjectedClassName && CurClass->isInvalidDecl())
+ if (!InjectedClassName) {
+ if (!CurClass->isInvalidDecl()) {
+ // FIXME: RequireCompleteDeclContext doesn't check dependent contexts
+ // properly. Work around it here for now.
+ Diag(SS.getLastQualifierNameLoc(),
+ diag::err_incomplete_nested_name_spec) << CurClass << SS.getRange();
+ }
return ParsedType();
- assert(InjectedClassName && "couldn't find injected class name");
+ }
QualType T = Context.getTypeDeclType(InjectedClassName);
DiagnoseUseOfDecl(InjectedClassName, NameLoc);
diff --git a/test/CodeGen/global-blocks-win32.c b/test/CodeGen/global-blocks-win32.c
new file mode 100644
index 000000000000..7a66c924b420
--- /dev/null
+++ b/test/CodeGen/global-blocks-win32.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fblocks -triple i386-pc-windows-msvc %s -emit-llvm -o - -fblocks | FileCheck %s
+
+
+int (^x)(void) = ^() { return 21; };
+
+
+// Check that the block literal is emitted with a null isa pointer
+// CHECK: @__block_literal_global = internal global { i8**, i32, i32, i8*, %struct.__block_descriptor* } { i8** null,
+
+// Check that _NSConcreteGlobalBlock has the correct dllimport specifier.
+// CHECK: @_NSConcreteGlobalBlock = external dllimport global i8*
+// Check that we create an initialiser pointer in the correct section (early library initialisation).
+// CHECK: @.block_isa_init_ptr = internal constant void ()* @.block_isa_init, section ".CRT$XCLa"
+
+// Check that we emit an initialiser for it.
+// CHECK: define internal void @.block_isa_init() {
+// CHECK: store i8** @_NSConcreteGlobalBlock, i8*** getelementptr inbounds ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }, { i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global, i32 0, i32 0), align 4
+
diff --git a/test/SemaCXX/constructor.cpp b/test/SemaCXX/constructor.cpp
index 105605c6e37b..33ea49663491 100644
--- a/test/SemaCXX/constructor.cpp
+++ b/test/SemaCXX/constructor.cpp
@@ -86,3 +86,14 @@ A::S::operator int() { return 1; }
A::S::~S() {}
+namespace PR38286 {
+ // FIXME: It'd be nice to give more consistent diagnostics for these cases
+ // (but they're all failing for somewhat different reasons...).
+ template<typename> struct A;
+ template<typename T> A<T>::A() {} // expected-error {{incomplete type 'A' named in nested name specifier}}
+ /*FIXME: needed to recover properly from previous error*/;
+ template<typename> struct B;
+ template<typename T> void B<T>::f() {} // expected-error {{out-of-line definition of 'f' from class 'B<type-parameter-0-0>'}}
+ template<typename> struct C;
+ template<typename T> C<T>::~C() {} // expected-error {{no type named 'C' in 'C<type-parameter-0-0>'}}
+}
diff --git a/test/lit.cfg.py b/test/lit.cfg.py
index ad30988c1796..c962b41723e5 100644
--- a/test/lit.cfg.py
+++ b/test/lit.cfg.py
@@ -71,7 +71,7 @@ llvm_config.add_tool_substitutions(tools, tool_dirs)
config.substitutions.append(
('%hmaptool', "'%s' %s" % (config.python_executable,
- os.path.join(config.llvm_tools_dir, 'hmaptool'))))
+ os.path.join(config.clang_tools_dir, 'hmaptool'))))
# Plugins (loadable modules)
# TODO: This should be supplied by Makefile or autoconf.
diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html
index cdeb451911dc..8362a52b76db 100644
--- a/www/cxx_dr_status.html
+++ b/www/cxx_dr_status.html
@@ -28,7 +28,7 @@
<!--*************************************************************************-->
<h1>C++ Defect Report Support in Clang</h1>
<!--*************************************************************************-->
-<p>Last updated: $Date: 2018-07-27 06:41:37 +0200 (Fri, 27 Jul 2018) $</p>
+<p>Last updated: $Date: 2018-08-06 12:32:02 +0200 (Mon, 06 Aug 2018) $</p>
<h2 id="cxxdr">C++ defect report implementation status</h2>
@@ -2021,7 +2021,7 @@ of class templates</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#330">330</a></td>
<td>CD4</td>
<td>Qualification conversions and pointers to arrays of pointers</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="331">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#331">331</a></td>
@@ -7093,7 +7093,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1213">1213</a></td>
<td>CD3</td>
<td>Array subscripting and xvalues</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="1214">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1214">1214</a></td>
@@ -9847,7 +9847,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1672">1672</a></td>
<td>CD4</td>
<td>Layout compatibility with multiple empty bases</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="1673">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1673">1673</a></td>
@@ -9937,7 +9937,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1687">1687</a></td>
<td>C++14</td>
<td>Conversions of operands of built-in operators</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="1688">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1688">1688</a></td>
@@ -9991,7 +9991,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1696">1696</a></td>
<td>CD4</td>
<td>Temporary lifetime and non-static data member initializers</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr class="open" id="1697">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1697">1697</a></td>
@@ -10693,7 +10693,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1813">1813</a></td>
<td>CD4</td>
<td>Direct vs indirect bases in standard-layout classes</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="1814">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1814">1814</a></td>
@@ -11101,7 +11101,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1881">1881</a></td>
<td>CD4</td>
<td>Standard-layout classes and unnamed bit-fields</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="1882">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1882">1882</a></td>
@@ -12535,7 +12535,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2120">2120</a></td>
<td>CD4</td>
<td>Array as first non-static data member in standard-layout class</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr class="open" id="2121">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2121">2121</a></td>
@@ -13189,7 +13189,7 @@ and <I>POD class</I></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2229">2229</a></td>
<td>tentatively ready</td>
<td>Volatile unnamed bit-fields</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr id="2230">
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#2230">2230</a></td>
diff --git a/www/cxx_status.html b/www/cxx_status.html
index 7318b0bab885..be65c6ed0480 100644
--- a/www/cxx_status.html
+++ b/www/cxx_status.html
@@ -26,7 +26,7 @@
<!--*************************************************************************-->
<h1>C++ Support in Clang</h1>
<!--*************************************************************************-->
-<p>Last updated: $Date: 2018-07-27 06:41:37 +0200 (Fri, 27 Jul 2018) $</p>
+<p>Last updated: $Date: 2018-08-06 12:32:02 +0200 (Mon, 06 Aug 2018) $</p>
<p>Clang fully implements all published ISO C++ standards (<a
href="#cxx98">C++98 / C++03</a>, <a
@@ -707,7 +707,7 @@ version 3.7.
<tr>
<!-- from Kona 2017 -->
<td><a href="http://wg21.link/p0620r1">P0620R0</a> (<a href="#dr">DR</a>)</td>
- <td class="svn" align="center">SVN</td>
+ <td class="svn" align="center">Clang 7</td>
</tr>
<tr>
<!-- from Toronto 2017 -->
@@ -1026,7 +1026,7 @@ and library features that are not part of standard C++.</p>
</tr>
<tr>
<td class="svn" align="center">
- SVN (<a href="http://wg21.link/p0096r5">P0096R5</a>)</a>
+ Clang 7 (<a href="http://wg21.link/p0096r5">P0096R5</a>)</a>
</td>
</tr>
<!-- FIXME: Implement latest recommendations.
diff --git a/www/make_cxx_dr_status b/www/make_cxx_dr_status
index 5b1991717d6b..af85c55af915 100755
--- a/www/make_cxx_dr_status
+++ b/www/make_cxx_dr_status
@@ -108,9 +108,12 @@ def availability(issue):
if status == 'unknown':
avail = 'Unknown'
avail_style = ' class="none"'
- elif status == '7':
+ elif status == '8':
avail = 'SVN'
avail_style = ' class="svn"'
+ elif status == '7':
+ avail = 'Clang 7'
+ avail_style = ' class="svn"'
elif re.match('^[0-9]+\.?[0-9]*', status):
avail = 'Clang %s' % status
avail_style = ' class="full"'