[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Organizationally, this seems fine. Carry on :)




Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:229-231
+def err_fnmap_parsing : Error<
+  "error parsing CrossTU index file: '%0' line: %1 'USR filename' format "
+  "expected">;

Please add a new `DiagnosticCrossTUKinds.td` file for the new subdirectory.



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:13-14
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_CROSSTRANSLATIONUNIT_H
+#define LLVM_CLANG_TOOLING_CROSSTRANSLATIONUNIT_H
+

This should be updated to match the new directory.



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:30
+
+namespace crossTU {
+

This doesn't follow either of our normal conventions for namespace names within 
Clang and LLVM (`CamelCase` and `snake_case`, with the latter being more 
common). Maybe `cross_tu`?


https://reviews.llvm.org/D34512



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


[PATCH] D36184: [clang-diff] Filter AST nodes

2017-08-02 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

In https://reviews.llvm.org/D36184#828866, @klimek wrote:

> Why? Also, missing tests.


implicit nodes are noisy / they generally don't add information; I guess one 
could also keep them.

I excluded nodes outside of the main file are because the visualisation only 
works with single files for now.
That will change, same as with macros.


https://reviews.llvm.org/D36184



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


[PATCH] D35922: [Driver] Enable AddressSanitizer for Fuchsia targets

2017-08-02 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr updated this revision to Diff 109428.
mcgrathr added a comment.

Added tests.


https://reviews.llvm.org/D35922

Files:
  cmake/caches/Fuchsia-stage2.cmake
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/fuchsia.c

Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -44,3 +44,27 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: -fsanitize=address 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-ASAN-X86
+// CHECK-ASAN-X86: "-fsanitize=address"
+// CHECK-ASAN-X86: "-fsanitize-address-globals-dead-stripping"
+// CHECK-ASAN-X86: /libclang_rt.asan-x86_64.so
+// CHECK-ASAN-X86: /libclang_rt.asan-preinit-x86_64.a
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=address 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64
+// CHECK-ASAN-AARCH64: "-fsanitize=address"
+// CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping"
+// CHECK-ASAN-AARCH64: /libclang_rt.asan-aarch64.so
+// CHECK-ASAN-AARCH64: /libclang_rt.asan-preinit-aarch64.a
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: -fsanitize=address -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-ASAN-SHARED
+// CHECK-ASAN-SHARED: "-fsanitize=address"
+// CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
+// CHECK-ASAN-SHARED: /libclang_rt.asan-x86_64.so
+// CHECK-ASAN-SHARED-NOT: /libclang_rt.asan-preinit-x86_64.a
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
 
@@ -68,22 +69,21 @@
   else
 CmdArgs.push_back("--build-id");
 
-  if (!Args.hasArg(options::OPT_static))
-CmdArgs.push_back("--eh-frame-hdr");
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-Bstatic");
   else if (Args.hasArg(options::OPT_shared))
 CmdArgs.push_back("-shared");
 
-  if (!Args.hasArg(options::OPT_static)) {
-if (Args.hasArg(options::OPT_rdynamic))
-  CmdArgs.push_back("-export-dynamic");
-
-if (!Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back(Args.MakeArgString(D.DyldPrefix + "ld.so.1"));
-}
+  if (!Args.hasArg(options::OPT_shared)) {
+std::string Dyld = D.DyldPrefix;
+if (ToolChain.getSanitizerArgs().needsAsanRt() &&
+ToolChain.getSanitizerArgs().needsSharedAsanRt())
+  Dyld += "asan/";
+Dyld += "ld.so.1";
+CmdArgs.push_back("-dynamic-linker");
+CmdArgs.push_back(Args.MakeArgString(Dyld));
   }
 
   CmdArgs.push_back("-o");
@@ -100,6 +100,8 @@
 
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -277,5 +279,6 @@
 SanitizerMask Fuchsia::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
+  Res |= SanitizerKind::Address;
   return Res;
 }
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -171,7 +171,7 @@
   return ((Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
   CoverageFeatures) &&
  !Sanitizers.has(Address) && !Sanitizers.has(Memory) &&
- !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) && 
+ !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) &&
  !Sanitizers.has(Leak) && !CfiCrossDso;
 }
 
@@ -557,8 +557,9 @@
 
   if (AllAddedKinds & Address) {
 AsanSharedRuntime =
-Args.hasArg(options::OPT_shared_libasan) || TC.getTriple().isAndroid();
-NeedPIE |= TC.getTriple().isAndroid();
+Args.hasArg(options::OPT_shared_libasan) ||
+TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia();
+NeedPIE |= TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia();
 if (Arg *A =
 Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
 StringRef S = A->getValue();
@@ -592,7 +593,7 @@
 // globals in ASan is disabled by default on ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
 AsanGlobalsDeadStripping =
-!TC.getTriple().isOSBinFormatELF() ||
+!TC.getTriple().isOSBinFormat

[PATCH] D36185: [clang-diff] Fix similarity computation

2017-08-02 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: test/Tooling/clang-diff-bottomup.cpp:3
+// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
+// RUN: clang-diff -m -no-compilation-database -s=0 %t.src.cpp %t.dst.cpp | 
FileCheck %s
+//

klimek wrote:
> Instead of using -no-compilation-database most tools support adding -- (args) 
> for using a fixed compilation database. Any specific reason to deviate from 
> that for clang-diff?
ah I actually wasn't aware of that, done


https://reviews.llvm.org/D36185



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-02 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: lib/CodeGen/CGCXXABI.cpp:43
   if (RD->hasNonTrivialDestructor())
 return false;
 

rjmccall wrote:
> Does canPassInRegisters() not subsume all of these earlier checks?
No, if I remove them here I get a lot of test failures. I cannot move them 
(yet?) in Sema, because I need to call `Sema::CheckCompletedCXXClass` in 
`Sema::ActOnFields` to compute the triviality of the decl. Only then it would 
be safe move these checks in `CanPassInRegisters`.


https://reviews.llvm.org/D35056



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


[PATCH] D36186: [clang-diff] Improve and test getNodeValue

2017-08-02 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: test/Tooling/clang-diff-ast.cpp:32
+
+// CHECK: TypedefDecl: nat;unsigned int;(
+typedef unsigned nat;

klimek wrote:
> For my curiosity: why are there semicolons here? Is the format documented 
> somewhere?
To avoid collisions (the value should be unique per TypedefDecl in this 
example), the second one is unnecessary I guess. It is not documented, If it 
works out I want to move to StmtDataCollector for node comparison and keep 
these just for visualisation / debugging.


https://reviews.llvm.org/D36186



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


r309888 - Remove unused diagnostic. NFC.

2017-08-02 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Aug  2 14:16:50 2017
New Revision: 309888

URL: http://llvm.org/viewvc/llvm-project?rev=309888&view=rev
Log:
Remove unused diagnostic. NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=309888&r1=309887&r2=309888&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Aug  2 14:16:50 
2017
@@ -893,8 +893,6 @@ def err_pragma_expected_clang_section_na
   "expected one of [bss|data|rodata|text] section kind in '#pragma %0'">;
 def err_pragma_clang_section_expected_equal : Error<
   "expected '=' following '#pragma clang section 
%select{invalid|bss|data|rodata|text}0'">;
-def err_pragma_clang_section_expected_name_or_clear : Error<
-  "expected section name or '\"\"' following '#pragma clang section 
%select{invalid|bss|data|rodata|text}0'">;
 def warn_pragma_expected_section_name : Warning<
   "expected a string literal for the section name in '#pragma %0' - ignored">,
   InGroup;


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


Re: [libcxx] r309881 - Rename a couple variables to eliminate a shadow warning. No functionality change

2017-08-02 Thread Blitz Rakete via cfe-commits
Instead of creating two variables, wouldn't it be better to just remove the
second definition and clear m_ec? You don't need to use both error codes
side by side, as the second usage of m_ec occurs after the first one is
finished. So you could remove the second definition and call clear() on it,
to reset it. I think that way is clearer then introducing one new variable,
no?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34848: Driver: Don't mix system tools with devtoolset tools on RHEL

2017-08-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Ping.u1


https://reviews.llvm.org/D34848



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


[PATCH] D34212: docs: Document binary compatibility issue due to bug in gcc

2017-08-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 109438.
tstellar added a comment.

Add links to index.rst and UsersManual.rst, and fix link to bug.


https://reviews.llvm.org/D34212

Files:
  docs/BinaryCompatibilityWithOtherCompilers.rst
  docs/UsersManual.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -40,6 +40,7 @@
Modules
MSVCCompatibility
ThinLTO
+   BinaryCompatibilityWithOtherCompilers
CommandGuide/index
FAQ
 
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2013,6 +2013,9 @@
 
 .. _objc:
 
+:doc:`BinaryCompatibilityWithOtherCompilers`
+
+
 Objective-C Language Features
 =
 
Index: docs/BinaryCompatibilityWithOtherCompilers.rst
===
--- /dev/null
+++ docs/BinaryCompatibilityWithOtherCompilers.rst
@@ -0,0 +1,39 @@
+=
+Binary compatibility with other compilers
+=
+
+Introduction
+
+
+This document describes some of the known binary compatibility problems
+when mixing object files built by clang with object files built by
+other compilers.
+
+If you run into a compatibility issue, please file a bug at bugs.llvm.org.
+
+gcc C++ ABI bug with variadic templates
+===
+
+Older versions of gcc incorrectly mangle variadic class/function templates,
+which can lead to undefined symbol errors when linking gcc built objects
+with clang built objects.
+
+gcc does emit the correct symbol name as an alias for the incorrect one,
+so libraries built by gcc are not affected by this bug.  You can only
+hit this bug if you have a library built by clang and you try to link
+against it with a gcc built object that uses a variadic class/function
+template from the library.
+
+workarounds:
+^^^
+
+* Use gcc 5.1.0 or newer.
+* Pass the -fabi-version=6 option to gcc when using versions < 5.1.0.
+
+gcc bug report:
+^^^
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51322
+
+llvm bug report:
+
+https://bugs.llvm.org/show_bug.cgi?id=33161


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -40,6 +40,7 @@
Modules
MSVCCompatibility
ThinLTO
+   BinaryCompatibilityWithOtherCompilers
CommandGuide/index
FAQ
 
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2013,6 +2013,9 @@
 
 .. _objc:
 
+:doc:`BinaryCompatibilityWithOtherCompilers`
+
+
 Objective-C Language Features
 =
 
Index: docs/BinaryCompatibilityWithOtherCompilers.rst
===
--- /dev/null
+++ docs/BinaryCompatibilityWithOtherCompilers.rst
@@ -0,0 +1,39 @@
+=
+Binary compatibility with other compilers
+=
+
+Introduction
+
+
+This document describes some of the known binary compatibility problems
+when mixing object files built by clang with object files built by
+other compilers.
+
+If you run into a compatibility issue, please file a bug at bugs.llvm.org.
+
+gcc C++ ABI bug with variadic templates
+===
+
+Older versions of gcc incorrectly mangle variadic class/function templates,
+which can lead to undefined symbol errors when linking gcc built objects
+with clang built objects.
+
+gcc does emit the correct symbol name as an alias for the incorrect one,
+so libraries built by gcc are not affected by this bug.  You can only
+hit this bug if you have a library built by clang and you try to link
+against it with a gcc built object that uses a variadic class/function
+template from the library.
+
+workarounds:
+^^^
+
+* Use gcc 5.1.0 or newer.
+* Pass the -fabi-version=6 option to gcc when using versions < 5.1.0.
+
+gcc bug report:
+^^^
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51322
+
+llvm bug report:
+
+https://bugs.llvm.org/show_bug.cgi?id=33161
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r308996 - [coroutines] Add serialization/deserialization of coroutines

2017-08-02 Thread Richard Smith via cfe-commits
On 31 July 2017 at 09:11, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Richard, Gor asked for this to be merged to 5.0. What do you think?


Sounds good to me.

On Tue, Jul 25, 2017 at 11:01 AM, Gor Nishanov via cfe-commits
>  wrote:
> > Author: gornishanov
> > Date: Tue Jul 25 11:01:49 2017
> > New Revision: 308996
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=308996&view=rev
> > Log:
> > [coroutines] Add serialization/deserialization of coroutines
> >
> > Reviewers: rsmith
> >
> > Reviewed By: rsmith
> >
> > Subscribers: EricWF, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D35383
> >
> > Added:
> > cfe/trunk/test/PCH/coroutines.cpp
> > Modified:
> > cfe/trunk/include/clang/AST/StmtCXX.h
> > cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> > cfe/trunk/lib/AST/StmtCXX.cpp
> > cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> > cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35388: [libc++] Give extern templates default visibility on gcc

2017-08-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

Hmm. So the documentation is wrong, but not "fully wrong". If you simply try 
applying this patch and compiling with GCC you'll still encounter a bunch of 
instances of `warning: type attributes ignored after type is already defined 
[-Wattributes]`.

The warning occurs when the class template specialization named in the extern 
template declaration has already been defined (possibly by an implicit 
instantiation). Ex. https://godbolt.org/g/DLgxhe

  #define VIS(Str) __attribute__((__visibility__(Str)))
  template  class VIS("hidden") T { void foo(); };
  T t; // cause definition of T. 
  template <> void T::foo() {} // causes definition?
  extern template class VIS("default") T; // OK not defined yet.
  extern template class VIS("default") T: // Not OK, T is already 
defined 

This case occurs multiple times in `` where the extern template 
declaration occurs after we declare an explicit specialization of a member 
function. It appears we need to do more to fix this than simply enable the 
visibility macro with GCC.
Likely either by ensuring the extern template decl occurs before anything that 
causes an implicit instantiation (but I'm not sure if that's allow, maybe 
member specializations have to occur first?), or by adding yet another macro to 
specially handle the `` case et al. with GCC.


https://reviews.llvm.org/D35388



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


[PATCH] D36249: Mark tests that need intel 80-bit floats as x86-only

2017-08-02 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.

These tests assume intel-80 bit floats, as noted in their comments. Rather than 
having each target discover the incompatibility and disable them ad-hoc, mark 
them as requiring x86.


Repository:
  rL LLVM

https://reviews.llvm.org/D36249

Files:
  compiler-rt/test/builtins/Unit/fixunsxfti_test.c
  compiler-rt/test/builtins/Unit/fixxfti_test.c
  compiler-rt/test/builtins/Unit/floattixf_test.c
  compiler-rt/test/builtins/Unit/floatuntixf_test.c


Index: compiler-rt/test/builtins/Unit/floatuntixf_test.c
===
--- compiler-rt/test/builtins/Unit/floatuntixf_test.c
+++ compiler-rt/test/builtins/Unit/floatuntixf_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- floatuntixf.c - Test __floatuntixf 
===//
 //
Index: compiler-rt/test/builtins/Unit/floattixf_test.c
===
--- compiler-rt/test/builtins/Unit/floattixf_test.c
+++ compiler-rt/test/builtins/Unit/floattixf_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- floattixf.c - Test __floattixf 
===//
 //
Index: compiler-rt/test/builtins/Unit/fixxfti_test.c
===
--- compiler-rt/test/builtins/Unit/fixxfti_test.c
+++ compiler-rt/test/builtins/Unit/fixxfti_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- fixxfti_test.c - Test __fixxfti 
---===//
 //
Index: compiler-rt/test/builtins/Unit/fixunsxfti_test.c
===
--- compiler-rt/test/builtins/Unit/fixunsxfti_test.c
+++ compiler-rt/test/builtins/Unit/fixunsxfti_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- fixunsxfti_test.c - Test __fixunsxfti 
-===//
 //


Index: compiler-rt/test/builtins/Unit/floatuntixf_test.c
===
--- compiler-rt/test/builtins/Unit/floatuntixf_test.c
+++ compiler-rt/test/builtins/Unit/floatuntixf_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- floatuntixf.c - Test __floatuntixf ===//
 //
Index: compiler-rt/test/builtins/Unit/floattixf_test.c
===
--- compiler-rt/test/builtins/Unit/floattixf_test.c
+++ compiler-rt/test/builtins/Unit/floattixf_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- floattixf.c - Test __floattixf ===//
 //
Index: compiler-rt/test/builtins/Unit/fixxfti_test.c
===
--- compiler-rt/test/builtins/Unit/fixxfti_test.c
+++ compiler-rt/test/builtins/Unit/fixxfti_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- fixxfti_test.c - Test __fixxfti ---===//
 //
Index: compiler-rt/test/builtins/Unit/fixunsxfti_test.c
===
--- compiler-rt/test/builtins/Unit/fixunsxfti_test.c
+++ compiler-rt/test/builtins/Unit/fixunsxfti_test.c
@@ -1,8 +1,5 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// XFAIL: aarch64
-// test fails for aarch64 (see pr32260)
-
-// UNSUPPORTED: mips
+// REQUIRES: x86-target-arch
 
 //===-- fixunsxfti_test.c - Test __fixunsxfti -===//
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34801: [coverage] Make smaller regions for the first case of a switch.

2017-08-02 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309901: [coverage] Make smaller regions for the first case 
of a switch. (authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D34801?vs=104581&id=109456#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34801

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/switch.cpp


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -704,6 +704,8 @@
 assert(!BreakContinueStack.empty() && "break not in a loop or switch!");
 BreakContinueStack.back().BreakCount = addCounters(
 BreakContinueStack.back().BreakCount, getRegion().getCounter());
+// FIXME: a break in a switch should terminate regions for all preceding
+// case statements, not just the most recent one.
 terminateRegion(S);
   }
 
@@ -845,15 +847,20 @@
 extendRegion(Body);
 if (const auto *CS = dyn_cast(Body)) {
   if (!CS->body_empty()) {
-// The body of the switch needs a zero region so that fallthrough 
counts
-// behave correctly, but it would be misleading to include the braces 
of
-// the compound statement in the zeroed area, so we need to handle this
-// specially.
+// Make a region for the body of the switch.  If the body starts with
+// a case, that case will reuse this region; otherwise, this covers
+// the unreachable code at the beginning of the switch body.
 size_t Index =
-pushRegion(Counter::getZero(), getStart(CS->body_front()),
-   getEnd(CS->body_back()));
+pushRegion(Counter::getZero(), getStart(CS->body_front()));
 for (const auto *Child : CS->children())
   Visit(Child);
+
+// Set the end for the body of the switch, if it isn't already set.
+for (size_t i = RegionStack.size(); i != Index; --i) {
+  if (!RegionStack[i - 1].hasEndLoc())
+RegionStack[i - 1].setEndLoc(getEnd(CS->body_back()));
+}
+
 popRegions(Index);
   }
 } else
Index: cfe/trunk/test/CoverageMapping/switch.cpp
===
--- cfe/trunk/test/CoverageMapping/switch.cpp
+++ cfe/trunk/test/CoverageMapping/switch.cpp
@@ -3,7 +3,7 @@
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
   switch(i) {
-  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
+  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
@@ -48,7 +48,7 @@
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
   switch(i) {
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
+  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2
 i = 1;
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #3
@@ -58,7 +58,7 @@
 break;
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
+  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6
 i = 1;
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
@@ -81,3 +81,19 @@
   baz();
   return 0;
 }
+
+// FIXME: End location for "case 1" shouldn't point at the end of the switch.
+ // CHECK: fallthrough
+int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 
= #0
+  switch(i) {
+  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
+i = 23;
+  case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 
+ #3)
+i = 11;
+break;
+  case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #4
+  case 4:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#4 
+ #5)
+i = 99;
+break;
+  }
+}


Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -704,6 +704,8 @@
 assert(!BreakContinueStack.empty() && "break not in a loop or switch!");
 BreakContinueStack.back().BreakCount = addCounters(
 BreakContinueStack.back().BreakCount, getRegion().getCounter());
+// FIXME: a break in a switch should terminate regions for all preceding
+// case statements, not just the most recent one.
 terminateRegion(S);
   }
 
@@ -845,15 +847,20 @@
 extendRegion(Body);

r309901 - [coverage] Make smaller regions for the first case of a switch.

2017-08-02 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Aug  2 16:22:50 2017
New Revision: 309901

URL: http://llvm.org/viewvc/llvm-project?rev=309901&view=rev
Log:
[coverage] Make smaller regions for the first case of a switch.

We never overwrite the end location of a region, so we would end up with
an overly large region when we reused the switch's region.

It's possible this code will be substantially rewritten in the near
future to deal with fallthrough more accurately, but this seems like
an improvement on its own for now.

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


Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/switch.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=309901&r1=309900&r2=309901&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Wed Aug  2 16:22:50 2017
@@ -704,6 +704,8 @@ struct CounterCoverageMappingBuilder
 assert(!BreakContinueStack.empty() && "break not in a loop or switch!");
 BreakContinueStack.back().BreakCount = addCounters(
 BreakContinueStack.back().BreakCount, getRegion().getCounter());
+// FIXME: a break in a switch should terminate regions for all preceding
+// case statements, not just the most recent one.
 terminateRegion(S);
   }
 
@@ -845,15 +847,20 @@ struct CounterCoverageMappingBuilder
 extendRegion(Body);
 if (const auto *CS = dyn_cast(Body)) {
   if (!CS->body_empty()) {
-// The body of the switch needs a zero region so that fallthrough 
counts
-// behave correctly, but it would be misleading to include the braces 
of
-// the compound statement in the zeroed area, so we need to handle this
-// specially.
+// Make a region for the body of the switch.  If the body starts with
+// a case, that case will reuse this region; otherwise, this covers
+// the unreachable code at the beginning of the switch body.
 size_t Index =
-pushRegion(Counter::getZero(), getStart(CS->body_front()),
-   getEnd(CS->body_back()));
+pushRegion(Counter::getZero(), getStart(CS->body_front()));
 for (const auto *Child : CS->children())
   Visit(Child);
+
+// Set the end for the body of the switch, if it isn't already set.
+for (size_t i = RegionStack.size(); i != Index; --i) {
+  if (!RegionStack[i - 1].hasEndLoc())
+RegionStack[i - 1].setEndLoc(getEnd(CS->body_back()));
+}
+
 popRegions(Index);
   }
 } else

Modified: cfe/trunk/test/CoverageMapping/switch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/switch.cpp?rev=309901&r1=309900&r2=309901&view=diff
==
--- cfe/trunk/test/CoverageMapping/switch.cpp (original)
+++ cfe/trunk/test/CoverageMapping/switch.cpp Wed Aug  2 16:22:50 2017
@@ -3,7 +3,7 @@
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
   switch(i) {
-  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #2
+  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
 break;
@@ -48,7 +48,7 @@ void baz() {// CHECK-NEXT: File
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
   switch(i) {
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
+  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2
 i = 1;
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #3
@@ -58,7 +58,7 @@ int main() {// CHECK-NEXT: File
 break;
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
+  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6
 i = 1;
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
@@ -81,3 +81,19 @@ int main() {// CHECK-NEXT: File
   baz();
   return 0;
 }
+
+// FIXME: End location for "case 1" shouldn't point at the end of the switch.
+ // CHECK: fallthrough
+int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 
= #0
+  switch(i) {
+  case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
+i = 23;
+  case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 
+ #3)
+i = 11;
+break;
+  case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #

[PATCH] D35863: Use the allocator's pointers for deallocation in `std::list`

2017-08-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

First, this patch would need tests before continuing, Could you please them? 
The list tests live under `test/std/containers/sequences/list`.  Let me know if 
you have any questions or need any help writing tests.

That being said. I'm not sure this patch is viable (or currently correct). 
First, LWG 2260  was 
resolved at the Toronto meeting by requiring `::pointer_to(r)` to be valid on 
allocator pointers, so I'm not sure your point about "not returning a 
deallocatable pointer" is valid anymore. In fact this seems to suggest that 
implementations should store raw pointers (since fancy-pointers don't require 
base <--> derived conversions), and then use `pointer_to` to generate the 
fancy-pointer for deallocation.

I understand the above behavior is quite limiting for fancy-pointers, since as 
you say, fancy-pointers often depend on information stored in the allocator in 
order to be constructed. However this point would have to be addressed to the 
committee in order for anything to be done about it.

Even if your point were valid, I'm not sure it's possible to correctly remove 
our dependency on `pointer_to` (though you're free to try). Leaving even one 
call to `pointer_to` within list seems like the manifestation of a bug.

Another problem to addressing this issue is that the pointer types used in 
`list`, `map`, `unordered_map`, ect are different in ABI v1 and ABI v2,  and 
correctly converting between them is overly complicated and easy to get wrong.


https://reviews.llvm.org/D35863



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


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.

The code after a noreturn call doesn't execute.

The pattern in the testcase is pretty common in LLVM (a switch with a default 
case that calls llvm_unreachable).


Repository:
  rL LLVM

https://reviews.llvm.org/D36250

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/switch.cpp


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,18 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+extendRegion(E);
+for (const Stmt *Child : E->children())
+  this->Visit(Child);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 


Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -97,3 +97,16 @@
 break;
   }
 }
+
+void abort(void) __attribute((noreturn));
+   // CHECK: noret
+int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
+  switch (x) {
+  default: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12
+abort();
+  case 1: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13
+return 5;
+  case 2: // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14
+return 10;
+  }
+}
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -716,6 +716,18 @@
 terminateRegion(S);
   }
 
+  void VisitCallExpr(const CallExpr *E) {
+extendRegion(E);
+for (const Stmt *Child : E->children())
+  this->Visit(Child);
+
+// Terminate the region when we hit a noreturn function.
+// (This is helpful dealing with switch statements.)
+QualType CalleeType = E->getCallee()->getType();
+if (getFunctionExtInfo(*CalleeType).getNoReturn())
+  terminateRegion(E);
+  }
+
   void VisitWhileStmt(const WhileStmt *S) {
 extendRegion(S);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-08-02 Thread Haowei Wu via Phabricator via cfe-commits
haowei created this revision.
Herald added a subscriber: xazax.hun.

This patch will suppress handle leak warnings if the path of a bug reported by 
MagentaHandleChecker will reach a no return function or will reach the end of 
main function. As these two scenarios mean program crash and the leaked handle 
will be recycled by OS, there is no point to report these bugs.


https://reviews.llvm.org/D36251

Files:
  lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
  test/Analysis/mxhandle.c


Index: test/Analysis/mxhandle.c
===
--- test/Analysis/mxhandle.c
+++ test/Analysis/mxhandle.c
@@ -58,7 +58,20 @@
 void useHandle02(
 MX_SYSCALL_PARAM_ATTR(handle_use) mx_handle_t *handle);
 
+void noReturnFunc() __attribute__((__noreturn__));
+
+int leakingFunc(int argc, char* argv[]) {
+  mx_handle_t sa, sb;
+  mx_channel_create(0, &sa, &sb);
+  return 1;
+}
+
 // End of declaration
+int main(int argc, char* argv[]) {
+  if (argc == 2)
+return leakingFunc(argc, argv); // Should not report any bugs here
+  return 0;
+}
 
 void checkNoLeak01() {
   mx_handle_t sa, sb;
@@ -207,6 +220,14 @@
   mx_handle_close(sb);
 }
 
+void checkNoLeak16() {
+  mx_handle_t sa, sb;
+  if (mx_channel_create(0, &sa, &sb) < 0) {
+return;
+  }
+  noReturnFunc(); // Should not report any bugs here
+}
+
 void checkLeak01() {
   mx_handle_t sa, sb;
   mx_channel_create(0, &sa, &sb);
Index: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
@@ -239,7 +239,7 @@
 
 class MagentaHandleChecker
 : public Checker {
+ check::PostCall, check::PreStmt> {
   std::unique_ptr LeakBugType;
   std::unique_ptr DoubleReleaseBugType;
   std::unique_ptr UseAfterFreeBugType;
@@ -255,6 +255,7 @@
   void checkPostCall(const CallEvent &Call, CheckerContext &Ctx) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &Ctx) const;
   bool evalCall(const CallExpr *CE, CheckerContext &Ctx) const;
+  void checkPreStmt(const ReturnStmt *RS, CheckerContext &Ctx) const;
   ProgramStateRef checkPointerEscape(ProgramStateRef State,
  const InvalidatedSymbols &Escaped,
  const CallEvent *Call,
@@ -402,6 +403,7 @@
   // Initialize the bug types.
   LeakBugType.reset(
   new BugType(this, "MX handle leak", "Magenta Handle Error"));
+  LeakBugType->setSuppressOnSink(true);
   DoubleReleaseBugType.reset(
   new BugType(this, "MX handle double release", "Magenta Handle Error"));
   UseAfterFreeBugType.reset(
@@ -478,6 +480,23 @@
   }
 }
 
+void MagentaHandleChecker::checkPreStmt(const ReturnStmt *RS,
+CheckerContext &Ctx) const {
+  ProgramStateRef State = Ctx.getState();
+  const StackFrameContext *SFCtx = Ctx.getStackFrame();
+  if (!SFCtx || !SFCtx->inTopFrame())
+return;
+  const FunctionDecl *FD = dyn_cast_or_null(SFCtx->getDecl());
+  if (!FD)
+return;
+  const IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+return;
+
+  if (II->isStr("main"))
+Ctx.generateSink(State, Ctx.getPredecessor());
+}
+
 ProgramStateRef MagentaHandleChecker::checkPointerEscape(
 ProgramStateRef State, const InvalidatedSymbols &Escaped,
 const CallEvent *Call, PointerEscapeKind Kind) const {


Index: test/Analysis/mxhandle.c
===
--- test/Analysis/mxhandle.c
+++ test/Analysis/mxhandle.c
@@ -58,7 +58,20 @@
 void useHandle02(
 MX_SYSCALL_PARAM_ATTR(handle_use) mx_handle_t *handle);
 
+void noReturnFunc() __attribute__((__noreturn__));
+
+int leakingFunc(int argc, char* argv[]) {
+  mx_handle_t sa, sb;
+  mx_channel_create(0, &sa, &sb);
+  return 1;
+}
+
 // End of declaration
+int main(int argc, char* argv[]) {
+  if (argc == 2)
+return leakingFunc(argc, argv); // Should not report any bugs here
+  return 0;
+}
 
 void checkNoLeak01() {
   mx_handle_t sa, sb;
@@ -207,6 +220,14 @@
   mx_handle_close(sb);
 }
 
+void checkNoLeak16() {
+  mx_handle_t sa, sb;
+  if (mx_channel_create(0, &sa, &sb) < 0) {
+return;
+  }
+  noReturnFunc(); // Should not report any bugs here
+}
+
 void checkLeak01() {
   mx_handle_t sa, sb;
   mx_channel_create(0, &sa, &sb);
Index: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
@@ -239,7 +239,7 @@
 
 class MagentaHandleChecker
 : public Checker {
+ check::PostCall, check::PreStmt> {
   std::unique_ptr LeakBugType;
   std::unique_ptr DoubleReleaseBugType;
   std::unique_ptr UseAfterFreeBugType;
@@ -255,6 +255,7 @@
   void checkPostCall(const CallEvent &Call, Checke

[PATCH] D36253: [Sema] Add a comment on an identified bug on default arguments.

2017-08-02 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
Herald added a subscriber: sanjoy.

The mis-compile is triggered by internal code, but I haven't reduced it to a 
small piece of code. Add a FIXME here, since a decent fix doesn't seem to be 
trivial.

The decent fix can be changing Decl::Init to PointerUnion, and make setUninstantiatedDefaultArg take a ParamVarDecl *, 
which contains the Expr * as the default argument. This way, 
getTemplateInstantiationArgs can take that ParamVarDecl and do the right thing.


https://reviews.llvm.org/D36253

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4477,6 +4477,22 @@
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4477,6 +4477,22 @@
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36254: [Driver][Fuchsia] Pass --hash-style=gnu to the linker

2017-08-02 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.

The .gnu_hash format is superior, and all versions of the Fuchsia
dynamic linker support it.


Repository:
  rL LLVM

https://reviews.llvm.org/D36254

Files:
  lib/Driver/ToolChains/Fuchsia.cpp


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -65,8 +65,10 @@
 
   if (Args.hasArg(options::OPT_r))
 CmdArgs.push_back("-r");
-  else
+  else {
 CmdArgs.push_back("--build-id");
+CmdArgs.push_back("--hash-style=gnu");
+  }
 
   if (!Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--eh-frame-hdr");


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -65,8 +65,10 @@
 
   if (Args.hasArg(options::OPT_r))
 CmdArgs.push_back("-r");
-  else
+  else {
 CmdArgs.push_back("--build-id");
+CmdArgs.push_back("--hash-style=gnu");
+  }
 
   if (!Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--eh-frame-hdr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309908 - [Sema] Add a comment on an identified bug on default arguments.

2017-08-02 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed Aug  2 17:18:11 2017
New Revision: 309908

URL: http://llvm.org/viewvc/llvm-project?rev=309908&view=rev
Log:
[Sema] Add a comment on an identified bug on default arguments.

Summary:
The mis-compile is triggered by internal code, but I haven't reduced it to a 
small piece of code. Add a FIXME here, since a decent fix doesn't seem to be 
trivial.

The decent fix can be changing Decl::Init to PointerUnion, and make setUninstantiatedDefaultArg take a ParamVarDecl *, 
which contains the Expr * as the default argument. This way, 
getTemplateInstantiationArgs can take that ParamVarDecl and do the right thing.

Reviewers: rsmith

Subscribers: sanjoy, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=309908&r1=309907&r2=309908&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug  2 17:18:11 2017
@@ -4477,6 +4477,22 @@ bool Sema::CheckCXXDefaultArgExpr(Source
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 


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


[PATCH] D36253: [Sema] Add a comment on an identified bug on default arguments.

2017-08-02 Thread Tim Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309908: [Sema] Add a comment on an identified bug on default 
arguments. (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D36253?vs=109461&id=109464#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36253

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -4477,6 +4477,22 @@
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -4477,6 +4477,22 @@
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36250: [coverage] Special-case calls to noreturn functions.

2017-08-02 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, lgtm.


Repository:
  rL LLVM

https://reviews.llvm.org/D36250



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


[PATCH] D36252: [diagtool] Add ability to get name from id

2017-08-02 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 109472.
hintonda added a comment.

- Use cat|xargs which should work on window -- used in other tests.


https://reviews.llvm.org/D36252

Files:
  test/Misc/find-diagnostic-id.c
  tools/diagtool/FindDiagnosticID.cpp


Index: tools/diagtool/FindDiagnosticID.cpp
===
--- tools/diagtool/FindDiagnosticID.cpp
+++ tools/diagtool/FindDiagnosticID.cpp
@@ -18,6 +18,15 @@
 using namespace clang;
 using namespace diagtool;
 
+static StringRef getNameFromID(StringRef Name) {
+  int DiagID;
+  if(!Name.getAsInteger(0, DiagID)) {
+const DiagnosticRecord &Diag = getDiagnosticForID(DiagID);
+return Diag.getName();
+  }
+  return StringRef();
+}
+
 static Optional
 findDiagnostic(ArrayRef Diagnostics, StringRef Name) {
   for (const auto &Diag : Diagnostics) {
@@ -38,7 +47,7 @@
   llvm::cl::Required, llvm::cl::cat(FindDiagnosticIDOptions));
 
   std::vector Args;
-  Args.push_back("find-diagnostic-id");
+  Args.push_back("diagtool find-diagnostic-id");
   for (const char *A : llvm::makeArrayRef(argv, argc))
 Args.push_back(A);
 
@@ -50,6 +59,13 @@
   Optional Diag =
   findDiagnostic(AllDiagnostics, DiagnosticName);
   if (!Diag) {
+// Name to id failed, so try id to name.
+auto Name = getNameFromID(DiagnosticName);
+if (!Name.empty()) {
+  OS << Name << '\n';
+  return 0;
+}
+
 llvm::errs() << "error: invalid diagnostic '" << DiagnosticName << "'\n";
 return 1;
   }
Index: test/Misc/find-diagnostic-id.c
===
--- test/Misc/find-diagnostic-id.c
+++ test/Misc/find-diagnostic-id.c
@@ -1,5 +1,7 @@
-// RUN: diagtool find-diagnostic-id warn_unused_variable | FileCheck %s
+// RUN: diagtool find-diagnostic-id warn_unused_variable > %t; FileCheck %s < 
%t
+// RUN: cat %t | xargs diagtool find-diagnostic-id | FileCheck %s 
--check-prefix=INVERSE
 // RUN: not diagtool find-diagnostic-id warn_unused_vars 2>&1 | FileCheck 
--check-prefix=ERROR %s
 
 // CHECK: {{^[0-9]+$}}
+// INVERSE: warn_unused_variable
 // ERROR: error: invalid diagnostic 'warn_unused_vars'


Index: tools/diagtool/FindDiagnosticID.cpp
===
--- tools/diagtool/FindDiagnosticID.cpp
+++ tools/diagtool/FindDiagnosticID.cpp
@@ -18,6 +18,15 @@
 using namespace clang;
 using namespace diagtool;
 
+static StringRef getNameFromID(StringRef Name) {
+  int DiagID;
+  if(!Name.getAsInteger(0, DiagID)) {
+const DiagnosticRecord &Diag = getDiagnosticForID(DiagID);
+return Diag.getName();
+  }
+  return StringRef();
+}
+
 static Optional
 findDiagnostic(ArrayRef Diagnostics, StringRef Name) {
   for (const auto &Diag : Diagnostics) {
@@ -38,7 +47,7 @@
   llvm::cl::Required, llvm::cl::cat(FindDiagnosticIDOptions));
 
   std::vector Args;
-  Args.push_back("find-diagnostic-id");
+  Args.push_back("diagtool find-diagnostic-id");
   for (const char *A : llvm::makeArrayRef(argv, argc))
 Args.push_back(A);
 
@@ -50,6 +59,13 @@
   Optional Diag =
   findDiagnostic(AllDiagnostics, DiagnosticName);
   if (!Diag) {
+// Name to id failed, so try id to name.
+auto Name = getNameFromID(DiagnosticName);
+if (!Name.empty()) {
+  OS << Name << '\n';
+  return 0;
+}
+
 llvm::errs() << "error: invalid diagnostic '" << DiagnosticName << "'\n";
 return 1;
   }
Index: test/Misc/find-diagnostic-id.c
===
--- test/Misc/find-diagnostic-id.c
+++ test/Misc/find-diagnostic-id.c
@@ -1,5 +1,7 @@
-// RUN: diagtool find-diagnostic-id warn_unused_variable | FileCheck %s
+// RUN: diagtool find-diagnostic-id warn_unused_variable > %t; FileCheck %s < %t
+// RUN: cat %t | xargs diagtool find-diagnostic-id | FileCheck %s --check-prefix=INVERSE
 // RUN: not diagtool find-diagnostic-id warn_unused_vars 2>&1 | FileCheck --check-prefix=ERROR %s
 
 // CHECK: {{^[0-9]+$}}
+// INVERSE: warn_unused_variable
 // ERROR: error: invalid diagnostic 'warn_unused_vars'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35922: [Driver] Enable AddressSanitizer for Fuchsia targets

2017-08-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


https://reviews.llvm.org/D35922



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


r309912 - Update for llvm change.

2017-08-02 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Aug  2 19:16:28 2017
New Revision: 309912

URL: http://llvm.org/viewvc/llvm-project?rev=309912&view=rev
Log:
Update for llvm change.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=309912&r1=309911&r2=309912&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Aug  2 19:16:28 2017
@@ -335,16 +335,18 @@ static CodeGenOpt::Level getCGOptLevel(c
   }
 }
 
-static llvm::CodeModel::Model getCodeModel(const CodeGenOptions &CodeGenOpts) {
-  unsigned CodeModel =
-  llvm::StringSwitch(CodeGenOpts.CodeModel)
-  .Case("small", llvm::CodeModel::Small)
-  .Case("kernel", llvm::CodeModel::Kernel)
-  .Case("medium", llvm::CodeModel::Medium)
-  .Case("large", llvm::CodeModel::Large)
-  .Case("default", llvm::CodeModel::Default)
-  .Default(~0u);
+static Optional
+getCodeModel(const CodeGenOptions &CodeGenOpts) {
+  unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel)
+   .Case("small", llvm::CodeModel::Small)
+   .Case("kernel", llvm::CodeModel::Kernel)
+   .Case("medium", llvm::CodeModel::Medium)
+   .Case("large", llvm::CodeModel::Large)
+   .Case("default", ~1u)
+   .Default(~0u);
   assert(CodeModel != ~0u && "invalid code model!");
+  if (CodeModel == ~1u)
+return None;
   return static_cast(CodeModel);
 }
 
@@ -658,7 +660,7 @@ void EmitAssemblyHelper::CreateTargetMac
 return;
   }
 
-  llvm::CodeModel::Model CM  = getCodeModel(CodeGenOpts);
+  Optional CM = getCodeModel(CodeGenOpts);
   std::string FeaturesStr =
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
   llvm::Reloc::Model RM = getRelocModel(CodeGenOpts);


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


[libcxx] r309917 - Add system header pragma to BSD locale fallback headers.

2017-08-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Aug  2 19:50:43 2017
New Revision: 309917

URL: http://llvm.org/viewvc/llvm-project?rev=309917&view=rev
Log:
Add system header pragma to BSD locale fallback headers.

This prevent leaking warnings to the user about use of C++11
extensions in C++03.

Modified:
libcxx/trunk/include/__bsd_locale_defaults.h
libcxx/trunk/include/__bsd_locale_fallbacks.h

Modified: libcxx/trunk/include/__bsd_locale_defaults.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bsd_locale_defaults.h?rev=309917&r1=309916&r2=309917&view=diff
==
--- libcxx/trunk/include/__bsd_locale_defaults.h (original)
+++ libcxx/trunk/include/__bsd_locale_defaults.h Wed Aug  2 19:50:43 2017
@@ -15,6 +15,10 @@
 #ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
 #define _LIBCPP_BSD_LOCALE_DEFAULTS_H
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #define __libcpp_mb_cur_max_l(loc)  MB_CUR_MAX_L(loc)
 #define __libcpp_btowc_l(ch, loc)   btowc_l(ch, loc)
 #define __libcpp_wctob_l(wch, loc)  wctob_l(wch, loc)

Modified: libcxx/trunk/include/__bsd_locale_fallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bsd_locale_fallbacks.h?rev=309917&r1=309916&r2=309917&view=diff
==
--- libcxx/trunk/include/__bsd_locale_fallbacks.h (original)
+++ libcxx/trunk/include/__bsd_locale_fallbacks.h Wed Aug  2 19:50:43 2017
@@ -18,6 +18,10 @@
 #include 
 #include 
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 inline _LIBCPP_ALWAYS_INLINE


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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-02 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: include/clang/Basic/SyncScope.h:23
+enum class SyncScope {
+  OpenCLWorkItem = 0,
+  OpenCLWorkGroup = 1,

The OpenCL workitem scope is only used for image fences and does not apply to 
atomic operations so not sure that it should be in this enumeration which is 
used only for memory atomics.



Comment at: lib/CodeGen/TargetInfo.cpp:7554-7555
+  switch (S) {
+  case SyncScope::OpenCLWorkItem:
+Name = "singlethread";
+break;

OpenCL only uses workitem for image fences which are not the same as atomic 
memory fences.

For image fences I don't think it would map to singlethread which is intended 
for signal handler support to ensure a signal handler has visibility of the 
updates done by a thread which is more of an optimization barrier. In contrast 
an image fence may need to flush caches to make the image and vector access 
paths coherent in a single thread.

Since this patch does not support fences probably want to leave workitem scope 
out. Current AMDGPU targets do not need to do anything for an OpenCL image 
fence, but other targets may need to generate an intrinsic since there is no 
LLVMIR instruction for this.



Comment at: lib/Headers/opencl-c.h:13145-13150
   memory_scope_work_item,
   memory_scope_work_group,
   memory_scope_device,
   memory_scope_all_svm_devices,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
   memory_scope_sub_group

Do these have to have the same values as the SycnScope enumeration? Should that 
be ensured in a similar way to the memory_order enumeration?



Comment at: lib/Sema/SemaChecking.cpp:3103
+Diag(Scope->getLocStart(),
+ diag::err_atomic_op_has_non_constant_synch_scope)
+<< Scope->getSourceRange();

IIRC OpenCL allows the scope to be a runtime value. So will doing this will 
likely cause failures in conformance?


https://reviews.llvm.org/D28691



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


Buildmaster restart

2017-08-02 Thread Victor Leschuk via cfe-commits
Hello everyone,
LLVM buildmaster will be updated and restarted approximately at 08:00 AM
PDT 4th August.

-- 
Best Regards,

Victor Leschuk | Software Engineer |Access Softek

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


[libcxx] r309920 - Fix libcxx build with glibc 2.26+ by removing xlocale.h include.

2017-08-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Aug  2 21:28:10 2017
New Revision: 309920

URL: http://llvm.org/viewvc/llvm-project?rev=309920&view=rev
Log:
Fix libcxx build with glibc 2.26+ by removing xlocale.h include.

Patch by Khem Raj. Reviewed as D35697. Also see PR33729.


Modified:
libcxx/trunk/include/__locale

Modified: libcxx/trunk/include/__locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=309920&r1=309919&r2=309920&view=diff
==
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Wed Aug  2 21:28:10 2017
@@ -34,7 +34,7 @@
 # include 
 #elif defined(_NEWLIB_VERSION)
 # include 
-#elif (defined(__GLIBC__) || defined(__APPLE__)  || defined(__FreeBSD__) \
+#elif (defined(__APPLE__)  || defined(__FreeBSD__) \
 || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include 
 #elif defined(__Fuchsia__)


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


[PATCH] D35820: [Driver] Search compiler-rt paths in -print-file-name=

2017-08-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 109485.

Repository:
  rL LLVM

https://reviews.llvm.org/D35820

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -308,6 +308,13 @@
   return TC.getArchName();
 }
 
+std::string ToolChain::getCompilerRTPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName);
+  return Path.str();
+}
+
 std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
  bool Shared) const {
   const llvm::Triple &TT = getTriple();
@@ -320,9 +327,7 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -3680,7 +3680,12 @@
   return P.str();
   }
 
-  SmallString<128> P(ResourceDir);
+  SmallString<128> R(ResourceDir);
+  llvm::sys::path::append(R, Name);
+  if (llvm::sys::fs::exists(Twine(R)))
+return R.str();
+
+  SmallString<128> P(TC.getCompilerRTPath());
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -298,6 +298,8 @@
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual std::string getCompilerRTPath() const;
+
   virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
 StringRef Component,
 bool Shared = false) const;


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -308,6 +308,13 @@
   return TC.getArchName();
 }
 
+std::string ToolChain::getCompilerRTPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName);
+  return Path.str();
+}
+
 std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
  bool Shared) const {
   const llvm::Triple &TT = getTriple();
@@ -320,9 +327,7 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  SmallString<128> Path(getDriver().ResourceDir);
-  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
-  llvm::sys::path::append(Path, "lib", OSLibName);
+  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -3680,7 +3680,12 @@
   return P.str();
   }
 
-  SmallString<128> P(ResourceDir);
+  SmallString<128> R(ResourceDir);
+  llvm::sys::path::append(R, Name);
+  if (llvm::sys::fs::exists(Twine(R)))
+return R.str();
+
+  SmallString<128> P(TC.getCompilerRTPath());
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
 return P.str();
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -298,6 +298,8 @@
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual std::string getCompilerRTPath() const;
+
   virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
 StringRef Component,
 bool Shared = false) const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36259: [OpenCL] Remove extra select functions from opencl-c.h

2017-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.

OpenCL spec v2.0 s6.13.6:

gentype select (gentype a,
gentype b,
igentype c)

gentype select (gentype a,
gentype b,
ugentype c)

igentype and ugentype must have the same number
of elements and bits as gentype.


https://reviews.llvm.org/D36259

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -11381,6 +11381,8 @@
  * For each component of a vector type,
  * result[i] = if MSB of c[i] is set ? b[i] : a[i].
  * For a scalar type, result = c ? b : a.
+ * b and a must have the same type.
+ * c must have the same number of elements and bits as a.
  */
 char __ovld __cnfn select(char a, char b, char c);
 uchar __ovld __cnfn select(uchar a, uchar b, char c);
@@ -11394,60 +11396,7 @@
 uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, char8 c);
 char16 __ovld __cnfn select(char16 a, char16 b, char16 c);
 uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, char16 c);
-short __ovld __cnfn select(short a, short b, char c);
-ushort __ovld __cnfn select(ushort a, ushort b, char c);
-short2 __ovld __cnfn select(short2 a, short2 b, char2 c);
-ushort2 __ovld __cnfn select(ushort2 a, ushort2 b, char2 c);
-short3 __ovld __cnfn select(short3 a, short3 b, char3 c);
-ushort3 __ovld __cnfn select(ushort3 a, ushort3 b, char3 c);
-short4 __ovld __cnfn select(short4 a, short4 b, char4 c);
-ushort4 __ovld __cnfn select(ushort4 a, ushort4 b, char4 c);
-short8 __ovld __cnfn select(short8 a, short8 b, char8 c);
-ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, char8 c);
-short16 __ovld __cnfn select(short16 a, short16 b, char16 c);
-ushort16 __ovld __cnfn select(ushort16 a, ushort16 b, char16 c);
-int __ovld __cnfn select(int a, int b, char c);
-uint __ovld __cnfn select(uint a, uint b, char c);
-int2 __ovld __cnfn select(int2 a, int2 b, char2 c);
-uint2 __ovld __cnfn select(uint2 a, uint2 b, char2 c);
-int3 __ovld __cnfn select(int3 a, int3 b, char3 c);
-uint3 __ovld __cnfn select(uint3 a, uint3 b, char3 c);
-int4 __ovld __cnfn select(int4 a, int4 b, char4 c);
-uint4 __ovld __cnfn select(uint4 a, uint4 b, char4 c);
-int8 __ovld __cnfn select(int8 a, int8 b, char8 c);
-uint8 __ovld __cnfn select(uint8 a, uint8 b, char8 c);
-int16 __ovld __cnfn select(int16 a, int16 b, char16 c);
-uint16 __ovld __cnfn select(uint16 a, uint16 b, char16 c);
-long __ovld __cnfn select(long a, long b, char c);
-ulong __ovld __cnfn select(ulong a, ulong b, char c);
-long2 __ovld __cnfn select(long2 a, long2 b, char2 c);
-ulong2 __ovld __cnfn select(ulong2 a, ulong2 b, char2 c);
-long3 __ovld __cnfn select(long3 a, long3 b, char3 c);
-ulong3 __ovld __cnfn select(ulong3 a, ulong3 b, char3 c);
-long4 __ovld __cnfn select(long4 a, long4 b, char4 c);
-ulong4 __ovld __cnfn select(ulong4 a, ulong4 b, char4 c);
-long8 __ovld __cnfn select(long8 a, long8 b, char8 c);
-ulong8 __ovld __cnfn select(ulong8 a, ulong8 b, char8 c);
-long16 __ovld __cnfn select(long16 a, long16 b, char16 c);
-ulong16 __ovld __cnfn select(ulong16 a, ulong16 b, char16 c);
-float __ovld __cnfn select(float a, float b, char c);
-float2 __ovld __cnfn select(float2 a, float2 b, char2 c);
-float3 __ovld __cnfn select(float3 a, float3 b, char3 c);
-float4 __ovld __cnfn select(float4 a, float4 b, char4 c);
-float8 __ovld __cnfn select(float8 a, float8 b, char8 c);
-float16 __ovld __cnfn select(float16 a, float16 b, char16 c);
-char __ovld __cnfn select(char a, char b, short c);
-uchar __ovld __cnfn select(uchar a, uchar b, short c);
-char2 __ovld __cnfn select(char2 a, char2 b, short2 c);
-uchar2 __ovld __cnfn select(uchar2 a, uchar2 b, short2 c);
-char3 __ovld __cnfn select(char3 a, char3 b, short3 c);
-uchar3 __ovld __cnfn select(uchar3 a, uchar3 b, short3 c);
-char4 __ovld __cnfn select(char4 a, char4 b, short4 c);
-uchar4 __ovld __cnfn select(uchar4 a, uchar4 b, short4 c);
-char8 __ovld __cnfn select(char8 a, char8 b, short8 c);
-uchar8 __ovld __cnfn select(uchar8 a, uchar8 b, short8 c);
-char16 __ovld __cnfn select(char16 a, char16 b, short16 c);
-uchar16 __ovld __cnfn select(uchar16 a, uchar16 b, short16 c);
+
 short __ovld __cnfn select(short a, short b, short c);
 ushort __ovld __cnfn select(ushort a, ushort b, short c);
 short2 __ovld __cnfn select(short2 a, short2 b, short2 c);
@@ -11460,60 +11409,7 @@
 ushort8 __ovld __cnfn select(ushort8 a, ushort8 b, short8 c);
 short16 __ovld __cnfn select(short16 a, short16 b, short16 c);
 ushort16 __ovld __cnfn select(ushort16 a, ushort16 b, short16 c);
-int __ovld __cnfn select(int a, int b, short c);
-uint __ovld __cnfn select(uint a, uint b, short c);
-int2 __ovld __cnfn select(int2 a, int2 b, short2 c);
-uint2 __ovld __cnfn select(uint2 a, uint2 b, short2 c);
-int3 __ovld __cnfn select(int3 a, int3 b, short3 c);
-uint3 __ovld __cnfn select(uint3 a, uint3 b, short3 c);
-int4 __ovld __cnfn select(int4 a, int4 b, short4 c);
-uint4 __ovld __cnfn select(uint4 a, uint4 b, short4 c);
-int

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-08-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The patch generally looks good, but if you need to handle non-constant scopes, 
you should submit a new patch to address that.




Comment at: lib/CodeGen/CGAtomic.cpp:896
+return V;
+  auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic);
+  auto T = V->getType();

You can sink this line and the next.



Comment at: lib/Sema/SemaChecking.cpp:3103
+Diag(Scope->getLocStart(),
+ diag::err_atomic_op_has_non_constant_synch_scope)
+<< Scope->getSourceRange();

t-tye wrote:
> IIRC OpenCL allows the scope to be a runtime value. So will doing this will 
> likely cause failures in conformance?
Ah, if that's true, you'll need to emit a switch in IRGen, the same way we 
handle non-constant memory orders.


https://reviews.llvm.org/D28691



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCXXABI.cpp:43
   if (RD->hasNonTrivialDestructor())
 return false;
 

v.g.vassilev wrote:
> rjmccall wrote:
> > Does canPassInRegisters() not subsume all of these earlier checks?
> No, if I remove them here I get a lot of test failures. I cannot move them 
> (yet?) in Sema, because I need to call `Sema::CheckCompletedCXXClass` in 
> `Sema::ActOnFields` to compute the triviality of the decl. Only then it would 
> be safe move these checks in `CanPassInRegisters`.
I feel it's pretty unfortunate to name a property "canPassInRegisters" when it 
actually means something quite different.  People will expect this to mean what 
it says.


https://reviews.llvm.org/D35056



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


[PATCH] D36249: Mark tests that need intel 80-bit floats as x86-only

2017-08-02 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz added a comment.

I tried to address it via checking pre-defined macros:
https://reviews.llvm.org/D31573

As long as the macros are defined correctly by clang, we don't need to worry 
about the specific target machine. How do you think about it?


Repository:
  rL LLVM

https://reviews.llvm.org/D36249



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


[PATCH] D36259: [OpenCL] Remove extra select functions from opencl-c.h

2017-08-02 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

Out of curiosity: how did you detect this?
Can we use the same approach for writing tests?


https://reviews.llvm.org/D36259



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


[PATCH] D36208: [mips] Enable target-specific attributes for MIPS64

2017-08-02 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:5979-5981
+if (S.Context.getTargetInfo().getABI() != "o32")
+  S.Diag(Attr.getLoc(), diag::err_attribute_supported_by_o32)
+  << Attr.getName() << D->getLocation();

aaron.ballman wrote:
> Please do not put logic into the switch statement, but instead sink it into a 
> helper function. We hope to remove the boilerplate switch someday, so keeping 
> with the `handleFooAttr()` pattern is preferred. Same below.
> 
> Further, why is this not handled by a TargetSpecificAttr in Attr.td? See 
> `TargetMicrosoftCXXABI` and `MSNoVTable` for an example.
> Further, why is this not handled by a TargetSpecificAttr in Attr.td? See 
> TargetMicrosoftCXXABI and MSNoVTable for an example.

I thought about this, but in that case compiler will show "unknown attribute 
'mips16' ignored" warning in case of using `mips16` on MIPS64 targets. As to me 
this warning is not quite correct in that case because `mips16`, `micromips`, 
`interrupt` all are known MIPS-specific attributes, but not applicable on 
MIPS64 by various reasons.


Repository:
  rL LLVM

https://reviews.llvm.org/D36208



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


<    1   2