r285054 - [X86][AVX512][Clang][Intrinsics][reduce] Adding missing reduce (Operators: +, *, &&, ||) intrinsics to Clang

2016-10-25 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Oct 25 02:56:04 2016
New Revision: 285054

URL: http://llvm.org/viewvc/llvm-project?rev=285054&view=rev
Log:
[X86][AVX512][Clang][Intrinsics][reduce] Adding missing reduce (Operators: 
+,*,&&,||) intrinsics to Clang
 
Committed after LGTM and check-all

 
Vector-reduction arithmetic accepts vectors as inputs and produces scalars as 
outputs.
This class of vector operation forms the basis of many scientific computations.
In vector-reduction arithmetic, the evaluation off is independent of the order 
of the input elements of V.
 
Used bisection method. At each step, we partition the vector with previous
step in half, and the operation is performed on its two halves.
This takes log2(n) steps where n is the number of elements in the vector.
 
Reviwer: 1. igorb
 2. craig.topper
Differential Revision: https://reviews.llvm.org/D25527



Added:
cfe/trunk/test/CodeGen/avx512-reduceIntrin.c
Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=285054&r1=285053&r2=285054&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Oct 25 02:56:04 2016
@@ -9658,6 +9658,243 @@ _mm512_mask_abs_pd(__m512d __W, __mmask8
   return (__m512d)_mm512_mask_and_epi64((__v8di)__W, __K, 
_mm512_set1_epi64(0x7FFF),(__v8di)__A);
 }
 
+// Vector-reduction arithmetic accepts vectors as inputs and produces scalars 
as
+// outputs. This class of vector operation forms the basis of many scientific
+// computations. In vector-reduction arithmetic, the evaluation off is
+// independent of the order of the input elements of V.
+
+// Used bisection method. At each step, we partition the vector with previous
+// step in half, and the operation is performed on its two halves.
+// This takes log2(n) steps where n is the number of elements in the vector.
+
+// Vec512 - Vector with size 512.
+// Operator - Can be one of following: +,*,&&,||
+// T2  - Can get 'i' for int and 'f' for float.
+// T1 - Can get 'i' for int and 'd' for double.
+
+#define _mm512_reduce_operator_64bit(Vec512, Operator, T2, T1) \
+  __extension__({  \
+__m256##T1 Vec256 = __builtin_shufflevector(   \
+(__v8d##T2)Vec512, \
+(__v8d##T2)Vec512, \
+0, 1, 2, 3)\
+Operator   \
+__builtin_shufflevector(   \
+(__v8d##T2)Vec512, \
+(__v8d##T2)Vec512, \
+4, 5, 6, 7);   \
+__m128##T1 Vec128 = __builtin_shufflevector(   \
+(__v4d##T2)Vec256, \
+(__v4d##T2)Vec256, \
+0, 1)  \
+Operator   \
+__builtin_shufflevector(   \
+(__v4d##T2)Vec256, \
+(__v4d##T2)Vec256, \
+2, 3); \
+Vec128 = __builtin_shufflevector((__v2d##T2)Vec128,\
+ (__v2d##T2)Vec128, 0, -1) \
+ Operator  \
+ __builtin_shufflevector((__v2d##T2)Vec128,\
+ (__v2d##T2)Vec128, 1, -1);\
+return Vec128[0];  \
+  })
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_add_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, +, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_mul_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, *, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_and_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, &, i, i);
+}
+
+static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_or_epi64(__m512i 
__W) {
+  _mm512_reduce_operator_64bit(__W, |, i, i);
+}
+
+static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_add_pd(__m512d __W) {
+  _mm512_reduce_operator_64bit(__W, +, f, d);
+}
+
+static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_mul_pd(__m512d __W) {
+  _mm512_reduce_operator_64bit(__W, *, f, d);
+}

[PATCH] D25928: [cfi] Enable cfi-icall on ARM and AArch64.

2016-10-25 Thread Stephen Hines via cfe-commits
srhines accepted this revision.
srhines added a reviewer: srhines.
srhines added a comment.
This revision is now accepted and ready to land.

Looks good for the Android side.


Repository:
  rL LLVM

https://reviews.llvm.org/D25928



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


[PATCH] D25888: Add support for __builtin_os_log_format[_buffer_size]

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

CodeGen depending on Analysis is fine with me. Any clang tool that builds an 
AST will have Analysis linked in anyways so there's virtually no cost to it.


Repository:
  rL LLVM

https://reviews.llvm.org/D25888



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


[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

Very nice.




Comment at: unittests/Driver/ToolChainsTest.cpp:15
+// FIXME: I presume this is not the correct way of doing this
+#include "../lib/Driver/ToolChains.h"
+#include "clang/Basic/VirtualFileSystem.h"

Yeah. It's better to hoist the enum + the decl for detectDistro into a public 
header under include/clang/Driver and include it from here.


https://reviews.llvm.org/D25869



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


[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.



Comment at: lib/Driver/ToolChains.cpp:1438
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (const StringRef& CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr> File =

drop the const&. Using StringRef by value is fine.



Comment at: lib/Driver/ToolChains.cpp:1445
+File.get()->getBuffer().split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  // CURRENT=triple-version

drop ref



Comment at: lib/Driver/ToolChains.cpp:1447
+  // CURRENT=triple-version
+  if (Line.startswith("CURRENT=")) {
+const std::pair ActiveVersion =

We have StringRef::consume_front now to make this more convenient.


https://reviews.llvm.org/D25661



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


[PATCH] D25658: Load clang-include-fixer.el from the unit test suite so that the unit tests can run in batch mode

2016-10-25 Thread Jens Massberg via cfe-commits
massberg accepted this revision.
massberg added a comment.
This revision is now accepted and ready to land.

looks good to me


https://reviews.llvm.org/D25658



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


[PATCH] D25657: include-fixer: Don't overwrite buffer changes

2016-10-25 Thread Jens Massberg via cfe-commits
massberg accepted this revision.
massberg added a comment.
This revision is now accepted and ready to land.

looks good to me


https://reviews.llvm.org/D25657



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


r285056 - Fix 'unknown documentation command' warning ranges

2016-10-25 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Tue Oct 25 05:06:11 2016
New Revision: 285056

URL: http://llvm.org/viewvc/llvm-project?rev=285056&view=rev
Log:
Fix 'unknown documentation command' warning ranges

Warnings generated by -Wdocumentation-unknown-command did only have a
start location, not a full source range. This resulted in only the
"carret" being show in messages, and IDEs highlighting only the single
initial character.


Modified:
cfe/trunk/lib/AST/CommentLexer.cpp
cfe/trunk/test/Sema/warn-documentation-unknown-command.cpp

Modified: cfe/trunk/lib/AST/CommentLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentLexer.cpp?rev=285056&r1=285055&r2=285056&view=diff
==
--- cfe/trunk/lib/AST/CommentLexer.cpp (original)
+++ cfe/trunk/lib/AST/CommentLexer.cpp Tue Oct 25 05:06:11 2016
@@ -378,15 +378,17 @@ void Lexer::lexCommentText(Token &T) {
   if ((Info = Traits.getTypoCorrectCommandInfo(CommandName))) {
 StringRef CorrectedName = Info->Name;
 SourceLocation Loc = getSourceLocation(BufferPtr);
-SourceRange CommandRange(Loc.getLocWithOffset(1),
- getSourceLocation(TokenPtr));
+SourceLocation EndLoc = getSourceLocation(TokenPtr);
+SourceRange FullRange = SourceRange(Loc, EndLoc);
+SourceRange CommandRange(Loc.getLocWithOffset(1), EndLoc);
 Diag(Loc, diag::warn_correct_comment_command_name)
-  << CommandName << CorrectedName
+  << FullRange << CommandName << CorrectedName
   << FixItHint::CreateReplacement(CommandRange, CorrectedName);
   } else {
 formTokenWithChars(T, TokenPtr, tok::unknown_command);
 T.setUnknownCommandName(CommandName);
-Diag(T.getLocation(), diag::warn_unknown_comment_command_name);
+Diag(T.getLocation(), diag::warn_unknown_comment_command_name)
+<< SourceRange(T.getLocation(), T.getEndLocation());
 return;
   }
 }

Modified: cfe/trunk/test/Sema/warn-documentation-unknown-command.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation-unknown-command.cpp?rev=285056&r1=285055&r2=285056&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation-unknown-command.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation-unknown-command.cpp Tue Oct 25 
05:06:11 2016
@@ -9,3 +9,7 @@ int test_unknown_comand_1;
 /// \retur aaa
 int test_unknown_comand_2();
 
+// RUN: c-index-test -test-load-source all -Wdocumentation-unknown-command %s 
> /dev/null 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
+// CHECK-RANGE: warn-documentation-unknown-command.cpp:5:9:{5:9-5:17}: 
warning: unknown command tag name
+// CHECK-RANGE: warn-documentation-unknown-command.cpp:9:5:{9:5-9:11}: 
warning: unknown command tag name 'retur'; did you mean 'return'?


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


[PATCH] D21737: [PATCH] [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.

2016-10-25 Thread Marcin Kościelnicki via cfe-commits
koriakin added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:422
   // Set up the per-function pass manager.
+  FPM.add(new TargetLibraryInfoWrapperPass(*TLII));
   if (CodeGenOpts.VerifyModule)

mehdi_amini wrote:
> This seems unnecessary?
This ensures FPM passes get the right TLI as well - since I'm removing the 
PMBuilder.LIbraryInfo assignment, they would otherwise get the 
default-constructed ones.  Or should I keep the assignment instead, and only 
special-case MPM?


Repository:
  rL LLVM

https://reviews.llvm.org/D21737



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


r285057 - Include full filename range for missing includes

2016-10-25 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Tue Oct 25 05:13:10 2016
New Revision: 285057

URL: http://llvm.org/viewvc/llvm-project?rev=285057&view=rev
Log:
Include full filename range for missing includes

For the purpose of highlighting in an IDE.

Added:
cfe/trunk/test/Preprocessor/missing-include-range-check.h
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=285057&r1=285056&r2=285057&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Oct 25 05:13:10 2016
@@ -1847,7 +1847,8 @@ void Preprocessor::HandleIncludeDirectiv
 
   // If the file is still not found, just go with the vanilla diagnostic
   if (!File)
-Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
+Diag(FilenameTok, diag::err_pp_file_not_found) << Filename
+   << FilenameRange;
 }
   }
 

Added: cfe/trunk/test/Preprocessor/missing-include-range-check.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/missing-include-range-check.h?rev=285057&view=auto
==
--- cfe/trunk/test/Preprocessor/missing-include-range-check.h (added)
+++ cfe/trunk/test/Preprocessor/missing-include-range-check.h Tue Oct 25 
05:13:10 2016
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -test-load-source all %s > 
/dev/null 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
+
+#include 
+#include "moozegnarf.h"
+
+// CHECK-RANGE: rewrite-includes-missing.c:4:10:{4:10-4:19}: fatal error: 
'foobar.h' file not found
+// CHECK-RANGE: rewrite-includes-missing.c:5:10:{5:10-5:24}: fatal error: 
'moozegnarf.h' file not found


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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-25 Thread Alexey Bader via cfe-commits
bader added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

Anastasia wrote:
> bader wrote:
> > AlexeySotkin wrote:
> > > Anastasia wrote:
> > > > Why this change?
> > > Without this change, global variables with unnamed address space are 
> > > translated to SPIR-V as variables with "Function" storage class, which is 
> > > wrong.
> > > This should fix this issue: 
> > > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
> > There is inconsistency with how Clang maps initializers to OpenCL memory 
> > model.
> > Consider example from the test case:
> > ```
> > __private int arr[] = {1, 2, 3};
> > ```
> > This code allocates a global constant for initializer {1, 2, 3} and later 
> > copies values from this global constant to the private array using memcpy 
> > intrinsic. The global constant must be allocated in constant address space, 
> > but old code do assign any address space, which is considered to be a 
> > private memory region.
> > This patch puts global constant objects to constant address space.
> Yes, this is perfectly fine. I was specifically asking about setting 
> llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has to 
> be done or is it because we now assign concrete address space and private was 
> treated as no address space at all?
This attribute has nothing to do with address spaces.
See http://llvm.org/docs/LangRef.html#global-variables for local_unnamed_addr 
and unnamed_addr attributes description.
My understanding is that llvm::GlobalValue::UnnamedAddr::Global should be fine 
here.


https://reviews.llvm.org/D25305



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


[PATCH] D25902: [AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

2016-10-25 Thread Elena Demikhovsky via cfe-commits
delena accepted this revision.
delena added a comment.
This revision is now accepted and ready to land.

LGTM. Agree, one-by-one.


https://reviews.llvm.org/D25902



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


[PATCH] D25935: [OpenCL] Diagnose variadic arguments

2016-10-25 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: yaxunl.
Anastasia added a subscriber: cfe-commits.

OpenCL disallows using variadic arguments (s6.9.e and s6.12.5 OpenCL v2.0) 
apart from some exceptions:

- printf
- enqueue_kernel

This change adds error diagnostic for variadic functions but accepts printf and 
any compiler internal function (which should cover __enqueue_kernel_XXX cases). 
It also unifies diagnostic with block prototype and adds missing uncaught cases 
for blocks.

Note that this implementation checks against printf name. Alternative approach 
would be to enable printf as Clang builtin and diagnose using custom Sema 
checks. Though it 's not clear whether this brings any  benefit.


https://reviews.llvm.org/D25935

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/builtin.cl
  test/SemaOpenCL/func.cl
  test/SemaOpenCL/func_ptr.cl
  test/SemaOpenCL/invalid-block.cl

Index: test/SemaOpenCL/invalid-block.cl
===
--- test/SemaOpenCL/invalid-block.cl
+++ test/SemaOpenCL/invalid-block.cl
@@ -31,23 +31,30 @@
 }
 
 // A block with variadic argument is not allowed.
-int (^bl)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}}
+int (^bl)(int, ...) = ^int(int I, ...) { // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
   return 0;
 };
+typedef int (^bl1_t)(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
 
 // A block can't be used to declare an array
-typedef int (^bl1_t)(int);
+typedef int (^bl2_t)(int);
 void f5(int i) {
-  bl1_t bl1 = ^(int i) {return 1;};
-  bl1_t bl2 = ^(int i) {return 2;};
-  bl1_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl1_t' (aka 'int (^const)(int)') type is invalid in OpenCL}}
+  bl2_t bl1 = ^(int i) {
+return 1;
+  };
+  bl2_t bl2 = ^(int i) {
+return 2;
+  };
+  bl2_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl2_t' (aka 'int (^const)(int)') type is invalid in OpenCL}}
   int tmp = i ? bl1(i)  // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
   : bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
 }
 // A block pointer type and all pointer operations are disallowed
-void f6(bl1_t * bl_ptr) { // expected-error{{pointer to type '__generic bl1_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}}
-  bl1_t bl = ^(int i) {return 1;};
-  bl1_t *p; // expected-error {{pointer to type '__generic bl1_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}}
-  *bl;  // expected-error {{invalid argument type 'bl1_t' (aka 'int (^const)(int)') to unary expression}}
-  &bl; // expected-error {{invalid argument type 'bl1_t' (aka 'int (^const)(int)') to unary expression}}
+void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}}
+  bl2_t bl = ^(int i) {
+return 1;
+  };
+  bl2_t *p; // expected-error {{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}}
+  *bl;  // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}}
+  &bl;  // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}}
 }
Index: test/SemaOpenCL/func_ptr.cl
===
--- test/SemaOpenCL/func_ptr.cl
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-
-void foo(void*);
-
-void bar()
-{
-  // declaring a function pointer is an error
-  void (*fptr)(int); // expected-error{{pointers to functions are not allowed}}
-
-  // taking the address of a function is an error
-  foo((void*)foo); // expected-error{{taking address of function is not allowed}}
-  foo(&foo); // expected-error{{taking address of function is not allowed}}
-
-  // initializing an array with the address of functions is an error
-  void* vptrarr[2] = {foo, &foo}; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}}
-
-  // just calling a function is correct
-  foo(0);
-}
Index: test/SemaOpenCL/func.cl
===
--- /dev/null
+++ test/SemaOpenCL/func.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+// Variadic functions
+void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
+void __vararg_f(int, ...);
+typedef void (*vararg_fptr_t)(int, ...);// expected-error {{invalid prototype, variadic arguments ar

[clang-tools-extra] r285059 - Load clang-include-fixer.el from the unit test suite so that the unit tests can run in batch mode.

2016-10-25 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct 25 06:30:28 2016
New Revision: 285059

URL: http://llvm.org/viewvc/llvm-project?rev=285059&view=rev
Log:
Load clang-include-fixer.el from the unit test suite so that the unit tests can 
run in batch mode.

Patch by Philipp Stephani.

Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el?rev=285059&r1=285058&r2=285059&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el 
(original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el Tue 
Oct 25 06:30:28 2016
@@ -6,6 +6,8 @@
 
 ;;; Code:
 
+(require 'clang-include-fixer)
+
 (require 'cc-mode)
 (require 'ert)
 


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


[clang-tools-extra] r285060 - include-fixer: Don't overwrite buffer changes

2016-10-25 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct 25 06:31:22 2016
New Revision: 285060

URL: http://llvm.org/viewvc/llvm-project?rev=285060&view=rev
Log:
include-fixer: Don't overwrite buffer changes

Raise a signal if the buffer has been modified before replacing it, to
avoid overwriting users' changes.

Patch by Philipp Stephani.

Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=285060&r1=285059&r2=285060&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Tue Oct 
25 06:31:22 2016
@@ -244,7 +244,13 @@ clang-include-fixer to insert the select
 (clang-include-fixer--select-header context)
 ;; Call clang-include-fixer again to insert the selected header.
 (clang-include-fixer--start
- #'clang-include-fixer--replace-buffer
+ (let ((old-tick (buffer-chars-modified-tick)))
+   (lambda (stdout)
+ (when (/= old-tick (buffer-chars-modified-tick))
+   ;; Replacing the buffer now would undo the user’s changes.
+   (user-error (concat "The buffer has been changed "
+   "before the header could be inserted")))
+ (clang-include-fixer--replace-buffer stdout)))
  (format "-insert-header=%s"
  (clang-include-fixer--encode-json context)))
   nil)


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


[PATCH] D25936: Fix format string for err_os_log_argument_to_big (currently unused)

2016-10-25 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

Good catch! How did you find this?
We need a test though.
(I can take over if you want, as I introduced the issue in the first place)


https://reviews.llvm.org/D25936



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


[PATCH] D25936: Fix format string for err_os_log_argument_to_big (currently unused)

2016-10-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285065: Fix diagnostic format string for 
err_os_log_argument_to_big (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D25936?vs=75685&id=75687#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25936

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/test/SemaObjC/format-strings-oslog.m


Index: cfe/trunk/test/SemaObjC/format-strings-oslog.m
===
--- cfe/trunk/test/SemaObjC/format-strings-oslog.m
+++ cfe/trunk/test/SemaObjC/format-strings-oslog.m
@@ -36,6 +36,9 @@
   wchar_t wcs[] = {'a', 0};
   __builtin_os_log_format(buf, "%S", wcs);
   printf("%S", wcs);
+
+  struct { char data[0x100]; } toobig;
+  __builtin_os_log_format(buf, "%s", toobig); // expected-error {{os_log() 
argument 2 is too big (256 bytes, max 255)}}
 }
 
 // Test os_log_format primitive with ObjC string literal format argument.
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7570,7 +7570,7 @@
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 


Index: cfe/trunk/test/SemaObjC/format-strings-oslog.m
===
--- cfe/trunk/test/SemaObjC/format-strings-oslog.m
+++ cfe/trunk/test/SemaObjC/format-strings-oslog.m
@@ -36,6 +36,9 @@
   wchar_t wcs[] = {'a', 0};
   __builtin_os_log_format(buf, "%S", wcs);
   printf("%S", wcs);
+
+  struct { char data[0x100]; } toobig;
+  __builtin_os_log_format(buf, "%s", toobig); // expected-error {{os_log() argument 2 is too big (256 bytes, max 255)}}
 }
 
 // Test os_log_format primitive with ObjC string literal format argument.
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7570,7 +7570,7 @@
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285065 - Fix diagnostic format string for err_os_log_argument_to_big

2016-10-25 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Oct 25 07:39:28 2016
New Revision: 285065

URL: http://llvm.org/viewvc/llvm-project?rev=285065&view=rev
Log:
Fix diagnostic format string for err_os_log_argument_to_big

Patch by Sam McCall, test case by me.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaObjC/format-strings-oslog.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285065&r1=285064&r2=285065&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 25 07:39:28 
2016
@@ -7570,7 +7570,7 @@ def warn_cfstring_truncated : Warning<
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 

Modified: cfe/trunk/test/SemaObjC/format-strings-oslog.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-oslog.m?rev=285065&r1=285064&r2=285065&view=diff
==
--- cfe/trunk/test/SemaObjC/format-strings-oslog.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-oslog.m Tue Oct 25 07:39:28 2016
@@ -36,6 +36,9 @@ void test_os_log_format(const char *pc,
   wchar_t wcs[] = {'a', 0};
   __builtin_os_log_format(buf, "%S", wcs);
   printf("%S", wcs);
+
+  struct { char data[0x100]; } toobig;
+  __builtin_os_log_format(buf, "%s", toobig); // expected-error {{os_log() 
argument 2 is too big (256 bytes, max 255)}}
 }
 
 // Test os_log_format primitive with ObjC string literal format argument.


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


Re: r285065 - Fix diagnostic format string for err_os_log_argument_to_big

2016-10-25 Thread Mehdi Amini via cfe-commits
Thanks!

> On Oct 25, 2016, at 5:39 AM, Benjamin Kramer via cfe-commits 
>  wrote:
> 
> Author: d0k
> Date: Tue Oct 25 07:39:28 2016
> New Revision: 285065
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285065&view=rev
> Log:
> Fix diagnostic format string for err_os_log_argument_to_big
> 
> Patch by Sam McCall, test case by me.
> 
> Differential Revision: https://reviews.llvm.org/D25936
> 
> Modified:
>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>cfe/trunk/test/SemaObjC/format-strings-oslog.m
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285065&r1=285064&r2=285065&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 25 07:39:28 
> 2016
> @@ -7570,7 +7570,7 @@ def warn_cfstring_truncated : Warning<
> def err_os_log_format_not_string_constant : Error<
>   "os_log() format argument is not a string constant">;
> def err_os_log_argument_too_big : Error<
> -  "os_log() argument %d is too big (%d bytes, max %d)">;
> +  "os_log() argument %0 is too big (%1 bytes, max %2)">;
> def warn_os_log_format_narg : Error<
>  "os_log() '%%n' format specifier is not allowed">, DefaultError;
> 
> 
> Modified: cfe/trunk/test/SemaObjC/format-strings-oslog.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-oslog.m?rev=285065&r1=285064&r2=285065&view=diff
> ==
> --- cfe/trunk/test/SemaObjC/format-strings-oslog.m (original)
> +++ cfe/trunk/test/SemaObjC/format-strings-oslog.m Tue Oct 25 07:39:28 2016
> @@ -36,6 +36,9 @@ void test_os_log_format(const char *pc,
>   wchar_t wcs[] = {'a', 0};
>   __builtin_os_log_format(buf, "%S", wcs);
>   printf("%S", wcs);
> +
> +  struct { char data[0x100]; } toobig;
> +  __builtin_os_log_format(buf, "%s", toobig); // expected-error {{os_log() 
> argument 2 is too big (256 bytes, max 255)}}
> }
> 
> // Test os_log_format primitive with ObjC string literal format argument.
> 
> 
> ___
> 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


r285067 - Fix MSVC unused variable warning.

2016-10-25 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Oct 25 07:59:15 2016
New Revision: 285067

URL: http://llvm.org/viewvc/llvm-project?rev=285067&view=rev
Log:
Fix MSVC unused variable warning.

LLVM_ATTRIBUTE_UNUSED doesn't work for non-gcc style compilers.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=285067&r1=285066&r2=285067&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Tue 
Oct 25 07:59:15 2016
@@ -464,10 +464,11 @@ void StdLibraryFunctionsChecker::initFun
   QualType SSizeTy = ACtx.getIntTypeForBitwidth(ACtx.getTypeSize(SizeTy), 
true);
 
   // Don't worry about truncation here, it'd be cast back to SIZE_MAX when 
used.
-  LLVM_ATTRIBUTE_UNUSED int64_t SizeMax =
+  int64_t SizeMax =
   BVF.getMaxValue(SizeTy).getLimitedValue();
   int64_t SSizeMax =
 BVF.getMaxValue(SSizeTy).getLimitedValue();
+  (void)SizeMax;
 
   // We are finally ready to define specifications for all supported functions.
   //


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


[PATCH] D25937: [Sema] -Wunused-variable warning for variables with array types should behave similarly to variables with scalar types

2016-10-25 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: rjmccall, thakis.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch makes the `-Wunused-variable` warning behaviour more consistent: Now 
clang won't warn on variables with constant array types where it doesn't warn 
on variables with scalar types.


Repository:
  rL LLVM

https://reviews.llvm.org/D25937

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-unused-variables.cpp


Index: test/SemaCXX/warn-unused-variables.cpp
===
--- test/SemaCXX/warn-unused-variables.cpp
+++ test/SemaCXX/warn-unused-variables.cpp
@@ -150,3 +150,50 @@
 }
 
 #include "Inputs/warn-unused-variables.h"
+
+namespace arrayRecords {
+
+int total = 0;
+
+class Adder {
+public:
+  Adder(int x); // out of line below
+  ~Adder() {}
+};
+
+Adder::Adder(int x) {
+  total += x;
+}
+
+struct Foo {
+  int x;
+  Foo(int x) : x(x) {}
+};
+
+struct S1 {
+  S1();
+};
+
+void foo() {
+  S1 y; // no warning
+  S1 yarray[2]; // no warning
+
+  Adder scalerInFuncScope = 134; // no warning
+  Adder arrayInFuncScope[] = { 135, 136 };  // no warning
+
+  Foo fooScalar = 1; // expected-warning {{unused variable 'fooScalar'}}
+  Foo fooArray[] = {1,2}; // expected-warning {{unused variable 'fooArray'}}
+}
+
+template
+void bar() {
+  Adder scaler = 123; // no warning
+  Adder array[N] = {1,2}; // no warning
+}
+
+void test() {
+  foo();
+  bar<2>();
+}
+
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1535,6 +1535,11 @@
 if (Ty->isIncompleteType() || Ty->isDependentType())
   return false;
 
+// Look at the element type when the type is a constant array to ensure
+// that the warning behaviour is consistent for both scalars and arrays.
+if (Ty->isConstantArrayType())
+  Ty = Ty->getAsArrayTypeUnsafe()->getElementType();
+
 if (const TagType *TT = Ty->getAs()) {
   const TagDecl *Tag = TT->getDecl();
   if (Tag->hasAttr())


Index: test/SemaCXX/warn-unused-variables.cpp
===
--- test/SemaCXX/warn-unused-variables.cpp
+++ test/SemaCXX/warn-unused-variables.cpp
@@ -150,3 +150,50 @@
 }
 
 #include "Inputs/warn-unused-variables.h"
+
+namespace arrayRecords {
+
+int total = 0;
+
+class Adder {
+public:
+  Adder(int x); // out of line below
+  ~Adder() {}
+};
+
+Adder::Adder(int x) {
+  total += x;
+}
+
+struct Foo {
+  int x;
+  Foo(int x) : x(x) {}
+};
+
+struct S1 {
+  S1();
+};
+
+void foo() {
+  S1 y; // no warning
+  S1 yarray[2]; // no warning
+
+  Adder scalerInFuncScope = 134; // no warning
+  Adder arrayInFuncScope[] = { 135, 136 };  // no warning
+
+  Foo fooScalar = 1; // expected-warning {{unused variable 'fooScalar'}}
+  Foo fooArray[] = {1,2}; // expected-warning {{unused variable 'fooArray'}}
+}
+
+template
+void bar() {
+  Adder scaler = 123; // no warning
+  Adder array[N] = {1,2}; // no warning
+}
+
+void test() {
+  foo();
+  bar<2>();
+}
+
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1535,6 +1535,11 @@
 if (Ty->isIncompleteType() || Ty->isDependentType())
   return false;
 
+// Look at the element type when the type is a constant array to ensure
+// that the warning behaviour is consistent for both scalars and arrays.
+if (Ty->isConstantArrayType())
+  Ty = Ty->getAsArrayTypeUnsafe()->getElementType();
+
 if (const TagType *TT = Ty->getAs()) {
   const TagDecl *Tag = TT->getDecl();
   if (Tag->hasAttr())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25871: Include full filename range for missing includes

2016-10-25 Thread Erik Verbruggen via cfe-commits
erikjv closed this revision.
erikjv added a comment.

r285057


https://reviews.llvm.org/D25871



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


[PATCH] D25870: Fix 'unknown documentation command' warning ranges

2016-10-25 Thread Erik Verbruggen via cfe-commits
erikjv closed this revision.
erikjv added a comment.

r285056


https://reviews.llvm.org/D25870



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


[PATCH] D25938: PP: Remove unused parameters from methods

2016-10-25 Thread Erik Verbruggen via cfe-commits
erikjv created this revision.
erikjv added a reviewer: bkramer.
erikjv added a subscriber: cfe-commits.

NFC


https://reviews.llvm.org/D25938

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPDirectives.cpp


Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1014,11 +1014,11 @@
 case tok::pp_define:
   return HandleDefineDirective(Result, ImmediatelyAfterTopLevelIfndef);
 case tok::pp_undef:
-  return HandleUndefDirective(Result);
+  return HandleUndefDirective();
 
 // C99 6.10.4 - Line Control.
 case tok::pp_line:
-  return HandleLineDirective(Result);
+  return HandleLineDirective();
 
 // C99 6.10.5 - Error Directive.
 case tok::pp_error:
@@ -1055,7 +1055,7 @@
 
 case tok::pp___private_macro:
   if (getLangOpts().Modules)
-return HandleMacroPrivateDirective(Result);
+return HandleMacroPrivateDirective();
   break;
 }
 break;
@@ -1153,7 +1153,7 @@
 ///   # line digit-sequence
 ///   # line digit-sequence "s-char-sequence"
 /// \endverbatim
-void Preprocessor::HandleLineDirective(Token &Tok) {
+void Preprocessor::HandleLineDirective() {
   // Read the line # and string argument.  Per C99 6.10.4p5, these tokens are
   // expanded.
   Token DigitTok;
@@ -1458,7 +1458,7 @@
 }
 
 /// \brief Handle a #private directive.
-void Preprocessor::HandleMacroPrivateDirective(Token &Tok) {
+void Preprocessor::HandleMacroPrivateDirective() {
   Token MacroNameTok;
   ReadMacroName(MacroNameTok, MU_Undef);
 
@@ -2553,7 +2553,7 @@
 
 /// HandleUndefDirective - Implements \#undef.
 ///
-void Preprocessor::HandleUndefDirective(Token &UndefTok) {
+void Preprocessor::HandleUndefDirective() {
   ++NumUndefined;
 
   Token MacroNameTok;
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -1928,12 +1928,12 @@
   /// Handle*Directive - implement the various preprocessor directives.  These
   /// should side-effect the current preprocessor object so that the next call
   /// to Lex() will return the appropriate token next.
-  void HandleLineDirective(Token &Tok);
+  void HandleLineDirective();
   void HandleDigitDirective(Token &Tok);
   void HandleUserDiagnosticDirective(Token &Tok, bool isWarning);
   void HandleIdentSCCSDirective(Token &Tok);
   void HandleMacroPublicDirective(Token &Tok);
-  void HandleMacroPrivateDirective(Token &Tok);
+  void HandleMacroPrivateDirective();
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc,
@@ -1995,7 +1995,7 @@
 private:
   // Macro handling.
   void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef);
-  void HandleUndefDirective(Token &Tok);
+  void HandleUndefDirective();
 
   // Conditional Inclusion.
   void HandleIfdefDirective(Token &Tok, bool isIfndef,


Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1014,11 +1014,11 @@
 case tok::pp_define:
   return HandleDefineDirective(Result, ImmediatelyAfterTopLevelIfndef);
 case tok::pp_undef:
-  return HandleUndefDirective(Result);
+  return HandleUndefDirective();
 
 // C99 6.10.4 - Line Control.
 case tok::pp_line:
-  return HandleLineDirective(Result);
+  return HandleLineDirective();
 
 // C99 6.10.5 - Error Directive.
 case tok::pp_error:
@@ -1055,7 +1055,7 @@
 
 case tok::pp___private_macro:
   if (getLangOpts().Modules)
-return HandleMacroPrivateDirective(Result);
+return HandleMacroPrivateDirective();
   break;
 }
 break;
@@ -1153,7 +1153,7 @@
 ///   # line digit-sequence
 ///   # line digit-sequence "s-char-sequence"
 /// \endverbatim
-void Preprocessor::HandleLineDirective(Token &Tok) {
+void Preprocessor::HandleLineDirective() {
   // Read the line # and string argument.  Per C99 6.10.4p5, these tokens are
   // expanded.
   Token DigitTok;
@@ -1458,7 +1458,7 @@
 }
 
 /// \brief Handle a #private directive.
-void Preprocessor::HandleMacroPrivateDirective(Token &Tok) {
+void Preprocessor::HandleMacroPrivateDirective() {
   Token MacroNameTok;
   ReadMacroName(MacroNameTok, MU_Undef);
 
@@ -2553,7 +2553,7 @@
 
 /// HandleUndefDirective - Implements \#undef.
 ///
-void Preprocessor::HandleUndefDirective(Token &UndefTok) {
+void Preprocessor::HandleUndefDirective() {
   ++NumUndefined;
 
   Token MacroNameTok;
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -1928,12 +1928,12 @@
   /// Handle*Directive - implement the various preprocessor directives.  These
   /// should side-effect the current preprocessor object so that the next call
   

[PATCH] D25938: PP: Remove unused parameters from methods

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D25938



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


[PATCH] D25939: PP: Replace some uses of unsigned with size_t

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:804
 if (LangOpts.MSVCCompat && !isAngled) {
-  for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
 IncludeStackInfo &ISEntry = IncludeMacroStack[e - i - 1];

While there you could turn this into a for-range loop 
```
for (IncludeStackInfo &ISEntry : llvm::reverse(IncludeMacroStack))
```



Comment at: lib/Lex/PPDirectives.cpp:868
 
-  for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
 IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];

Looks like another candidate for for-range.


https://reviews.llvm.org/D25939



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


[PATCH] D25940: [analyzer] LibraryFunctions: Fix errors due to different integral types and typedefs on different architectures.

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin, a.sidorin, xazax.hun.
NoQ added a subscriber: cfe-commits.

The mechanism for filtering out wrong functions with the same name was too 
aggressive to filter out eg. `int` vs. `long`, when sizes of both are equal. 
Such issues were detected by several buildbots.

In fact, our function summaries are not precise enough to deal with such 
differences, and they do not need to be. This patch fixes the issue by only 
taking size and signedness into account. Also minor cleanups.


https://reviews.llvm.org/D25940

Files:
  lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -1,4 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple armv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple thumbv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -22,7 +26,6 @@
   clang_analyzer_eval(fgetc(fp) >= 0); // expected-warning{{UNKNOWN}}
 }
 
-
 typedef unsigned long size_t;
 typedef signed long ssize_t;
 ssize_t read(int, void *, size_t);
Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -79,11 +79,13 @@
   /// impose a constraint that involves other argument or return value symbols.
   enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
 
+  typedef uint64_t RangeIntTy;
+
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVectorTy;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
@@ -185,9 +187,11 @@
   return T;
 }
 
+static bool typesAreEqual(QualType Lhs, QualType Rhs, ASTContext &ACtx);
+
 /// Try our best to figure out if the call expression is the call of
 /// *the* library function to which this specification applies.
-bool matchesCall(const CallExpr *CE) const;
+bool matchesCall(const CallExpr *CE, ASTContext &ACtx) const;
   };
 
   // The map of all functions supported by the checker. It is initialized
@@ -386,31 +390,53 @@
   llvm_unreachable("Unknown invalidation kind!");
 }
 
+bool StdLibraryFunctionsChecker::FunctionSummaryTy::typesAreEqual(
+QualType Lhs, QualType Rhs, ASTContext &ACtx) {
+  // Lhs comes from the FunctionSummary, Rhs comes from the call expression.
+  // Hence lack of symmetry.
+  if (Lhs.isNull()) // "Irrelevant" types.
+return true;
+
+  assertTypeSuitableForSummary(Lhs);
+  assert(!Rhs.isNull());
+  assert(Lhs.isCanonical());
+  Rhs = Rhs.getCanonicalType();
+
+  // We're only requiring integral types to match by size and signedness,
+  // not be completely identical. Currently the only reason for that is
+  // our inability to guess ssize_t correctly from the AST context.
+  // FIXME: Maybe the proper solution would be to scan through typedefs.
+  if (!Lhs->isIntegralOrEnumerationType())
+return Lhs == Rhs;
+  if (!Rhs->isIntegralOrEnumerationType())
+return false;
+
+  if (Lhs->isSignedIntegerOrEnumerationType() !=
+  Rhs->isSignedIntegerOrEnumerationType())
+return false;
+
+  return ACtx.getTypeSize(Lhs) == ACtx.getTypeSize(Rhs);
+}
+
 bool StdLibraryFunctionsChecker::FunctionSummaryTy::matchesCall(
-const CallExpr *CE) const {
+const CallExpr *CE, ASTContext &ACtx) const {
   // Check number of arguments:
   if (CE->getNumArgs() != ArgTypes.size())
 return false;
 
   // Check return type if relevant:
-  if (!RetType.isNull() && RetType != CE->getType().getCanonicalType())
+  if (!typesAreEqual(RetType, CE->getType().getCanonicalType(), ACtx))
 return false;
 
   // Check argument types when relevant:
   for (size_t I = 0, E = ArgTypes.size(); I != E; ++I) {
 QualType FormalT = ArgTypes[I];
 // Null type marks irrelevant arguments.
-if (FormalT.isNull())
-  continue;
-
-assertTypeSuitableForSummary

[PATCH] D25936: Fix format string for err_os_log_argument_to_big (currently unused)

2016-10-25 Thread Sam McCall via cfe-commits
sammccall created this revision.
sammccall added a reviewer: bkramer.
sammccall added subscribers: cfe-commits, mehdi_amini.

https://reviews.llvm.org/D25936

Files:
  include/clang/Basic/DiagnosticSemaKinds.td


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7570,7 +7570,7 @@
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7570,7 +7570,7 @@
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23528: [OpenMP] Sema and parsing for 'teams distribute simd' pragma

2016-10-25 Thread Kelvin Li via cfe-commits
The failure cannot be reproduced.  I re-apply r279045.  Committed revision
285066.

Thanks,
Kelvin

On Thu, Aug 18, 2016 at 5:46 AM, Diana Picus  wrote:

> Hi,
>
> I had to revert this (r279045) because it breaks some of our buildbots
> (e.g.
> clang-cmake-aarch64-quick, clang-x86_64-linux-selfhost-modules).
>
> The error is in OpenMP/teams_distribute_simd_ast_print.cpp:
> clang: /home/buildslave/buildslave/clang-cmake-aarch64-quick/llvm/
> include/llvm/ADT/DenseMap.h:527:
> bool llvm::DenseMapBase BucketT>::LookupBucketFor(const LookupKeyT&, const BucketT*&) const
> [with LookupKeyT = clang::Stmt*; DerivedT = llvm::DenseMap long unsigned int>;
> KeyT = clang::Stmt*; ValueT = long unsigned int;
> KeyInfoT = llvm::DenseMapInfo;
> BucketT = llvm::detail::DenseMapPair int>]:
>
> Assertion `!KeyInfoT::isEqual(Val, EmptyKey) && !KeyInfoT::isEqual(Val,
> TombstoneKey) &&
> "Empty/Tombstone value shouldn't be inserted into map!"' failed.
>
> On 18 August 2016 at 02:21, Phabricator via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL279003: [OpenMP] Sema and parsing for 'teams
>> distribute simd’ pragma (authored by kli).
>>
>> Changed prior to commit:
>>   https://reviews.llvm.org/D23528?vs=68216&id=68448#toc
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D23528
>>
>> Files:
>>   cfe/trunk/include/clang-c/Index.h
>>   cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>>   cfe/trunk/include/clang/AST/StmtOpenMP.h
>>   cfe/trunk/include/clang/Basic/OpenMPKinds.def
>>   cfe/trunk/include/clang/Basic/StmtNodes.td
>>   cfe/trunk/include/clang/Sema/Sema.h
>>   cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>   cfe/trunk/lib/AST/StmtOpenMP.cpp
>>   cfe/trunk/lib/AST/StmtPrinter.cpp
>>   cfe/trunk/lib/AST/StmtProfile.cpp
>>   cfe/trunk/lib/Basic/OpenMPKinds.cpp
>>   cfe/trunk/lib/CodeGen/CGStmt.cpp
>>   cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>>   cfe/trunk/lib/CodeGen/CodeGenFunction.h
>>   cfe/trunk/lib/Parse/ParseOpenMP.cpp
>>   cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>   cfe/trunk/lib/Sema/TreeTransform.h
>>   cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
>>   cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>>   cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
>>   cfe/trunk/test/OpenMP/nesting_of_regions.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_default_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_dist_schedule_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_lastprivate_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_num_teams_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_private_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_reduction_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_safelen_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_shared_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_simdlen_messages.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_simd_thread_limit_messages.cpp
>>   cfe/trunk/tools/libclang/CIndex.cpp
>>   cfe/trunk/tools/libclang/CXCursor.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] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType

2016-10-25 Thread Łukasz Anforowicz via cfe-commits
lukasza updated the summary for this revision.
lukasza updated this revision to Diff 75661.
lukasza added a comment.

Reverted changes in the patch that are not related to the issue of 
hasDeclaration not matching *anything* in some cases.


https://reviews.llvm.org/D24361

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2106,5 +2106,36 @@
functionDecl(hasName("bar"));
 }
 
+TEST(HasDeclaration, ElaboratedTypeAndTemplateSpecializationType) {
+  std::string input =
+  "namespace Namespace {\n"
+  "template\n"
+  "class Template {\n"
+  " public:\n"
+  "  void Method() {}\n"
+  "};\n"
+  "}  // namespace Namespace\n"
+  "template \n"
+  "void Function(Namespace::Template param) {\n"
+  "  param.Method();\n"
+  "};\n";
+
+  // Matcher for ::Namespace::Template template decl.
+  auto param_type_decl_matcher = classTemplateDecl(
+  hasName("Template"),
+  hasParent(namespaceDecl(hasName("Namespace"))),
+  has(templateTypeParmDecl(hasName("T";
+
+  // hasDeclaration / qualType-flavour.
+  EXPECT_TRUE(matches(input, parmVarDecl(
+  hasName("param"),
+  hasType(qualType(hasDeclaration(decl(param_type_decl_matcher)));
+
+  // hasDeclaration / elaboratedType-flavour.
+  EXPECT_TRUE(matches(input, parmVarDecl(
+  hasName("param"),
+  
hasType(elaboratedType(hasDeclaration(decl(param_type_decl_matcher)));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -748,6 +748,10 @@
   return matchesDecl(TD, Finder, Builder);
 else if (auto *TT = Node->getAs())
   return matchesDecl(TT->getDecl(), Finder, Builder);
+else if (auto *ET = Node->getAs())
+  return matchesSpecialized(ET->getNamedType(), Finder, Builder);
+else if (auto *TST = Node->getAs())
+  return matchesSpecialized(*TST, Finder, Builder);
 // Do not use getAs instead of the direct dyn_cast.
 // Calling getAs will return the canonical type, but that type does not
 // store a TemplateTypeParmDecl. We *need* the uncanonical type, if it is
@@ -763,6 +767,14 @@
 return false;
   }
 
+  /// \brief Gets the QualType from ElaboratedType
+  /// and returns whether the inner matches on it.
+  bool matchesSpecialized(const ElaboratedType &Node,
+  ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder) const {
+return matchesSpecialized(Node.getNamedType(), Finder, Builder);
+  }
+
   /// \brief Gets the TemplateDecl from a TemplateSpecializationType
   /// and returns whether the inner matches on it.
   bool matchesSpecialized(const TemplateSpecializationType &Node,
@@ -1007,10 +1019,10 @@
  TypeLoc, QualType> AdaptativeDefaultToTypes;
 
 /// \brief All types that are supported by HasDeclarationMatcher above.
-typedef TypeList HasDeclarationSupportedTypes;
 
 /// \brief Converts a \c Matcher to a matcher of desired type \c To by
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2454,7 +2454,8 @@
 /// function. e.g. various subtypes of clang::Type and various expressions.
 ///
 /// Usable as: Matcher, Matcher,
-///   Matcher, Matcher, Matcher,
+///   Matcher, Matcher, Matcher,
+///   Matcher,
 ///   Matcher, Matcher, Matcher,
 ///   Matcher, Matcher, Matcher,
 ///   Matcher, Matcher,


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2106,5 +2106,36 @@
functionDecl(hasName("bar"));
 }
 
+TEST(HasDeclaration, ElaboratedTypeAndTemplateSpecializationType) {
+  std::string input =
+  "namespace Namespace {\n"
+  "template\n"
+  "class Template {\n"
+  " public:\n"
+  "  void Method() {}\n"
+  "};\n"
+  "}  // namespace Namespace\n"
+  "template \n"
+  "void Function(Namespace::Template param) {\n"
+  "  param.Method();\n"
+  "};\n";
+
+  // Matcher for ::Namespace::Template template decl.
+  auto param_type_decl_matcher = classTemplateDecl(
+  hasName("Template"),
+  hasParent(namespaceDecl(hasName("Namespace"))),
+  has(template

[PATCH] D25936: Fix format string for err_os_log_argument_to_big (currently unused)

2016-10-25 Thread Sam McCall via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D25936#578341, @mehdi_amini wrote:

> Good catch! How did you find this?


We've got a library that parses diagnostics that consumes 
DiagnosticSemaKinds.inc, and it failed to parse this message format.

> We need a test though.
>  (I can take over if you want, as I introduced the issue in the first place)

Thanks! I'm pretty new to llvm and wasn't sure how to test this.
Looks like bkramer came up with one though.


Repository:
  rL LLVM

https://reviews.llvm.org/D25936



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


[PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!

In https://reviews.llvm.org/D21840#555719, @hfinkel wrote:

> The naming here is a bit hard to follow, we have 'dependent action', 
> 'dependency action', 'depending action', and I think they're all supposed to 
> mean the same thing. Only 'dependent action' sounds right to me, can we use 
> that universally (i.e. in all comments and names of functions and variables)?


I agree the Depending/Dependence stuff can be confusing. However, I tried to 
use Depending and Dependence to indicate different things:

- Depending action -> an action that depends on the current one
- Dependence action ->  an action that is a dependence to the current one

Of course they all are dependent actions, so your suggestion definitely makes 
sense. So, in the last diff I indicate:

- Depending action -> Next Dependent action
- Dependence action -> Prev(ious) Dependent action

I hope this helps clarifying things. Let me know you thoughts.

Thanks again!
Samuel




Comment at: lib/Driver/Driver.cpp:2394
+Action *CurAction = *Inputs.begin();
+if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed)
+  return nullptr;

hfinkel wrote:
> As a micro-optimization, check CanBeCollapsed first, then call the function:
> 
>   if (CanBeCollapsed && !CurAction->isCollapsingWithDependingActionLegal())
> 
Ok, makes sense. Fixed this in the last diff.



Comment at: lib/Driver/Driver.cpp:2444
+  /// collapsed with it.
+  struct JobActionInfoTy final {
+/// The action this info refers to.

hfinkel wrote:
> Putting "Ty" on the end of a type name seems unusual for our code base (we 
> generally use that for typedefs or for variables that represent types of 
> other entities). Just JobActionInfo should be fine.
Ok, fixed that in the last diff.



Comment at: lib/Driver/Driver.cpp:2474
+  const Tool *
+  attemptCombineAssembleBackendCompile(ArrayRef ActionInfo,
+   const ActionList *&Inputs,

hfinkel wrote:
> I don't think we need 'attempt' in the name here, just make this:
> 
>   combineAssembleBackendCompile
Ok, fixed in last diff.



Comment at: lib/Driver/Driver.cpp:2632
+
+if (!T)
+  T = attemptCombineAssembleBackendCompile(ActionChain, Inputs,

hfinkel wrote:
> I don't think the syntactic regularity here is helpful enough to justify this 
> extra if. Just do:
> 
>   const Tool *T = combineAssembleBackendCompile(ActionChain, Inputs,
> CollapsedOffloadAction);
> 
Ok, fixed in last diff.


https://reviews.llvm.org/D21840



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


[PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75698.
sfantao marked 10 inline comments as done.
sfantao added a comment.

- Address Hal Finkel suggestions - rename functions/reorder code/fix comments.


https://reviews.llvm.org/D21840

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

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1930,7 +1930,7 @@
 
 // Create the offload action with all dependences. When an offload action
 // is created the kinds are propagated to the host action, so we don't have
-// to do that explicitely here.
+// to do that explicitly here.
 OffloadAction::HostDependence HDep(
 *HostAction, *C.getSingleOffloadToolChain(),
 /*BoundArch*/ nullptr, ActiveOffloadKinds);
@@ -2368,142 +2368,288 @@
 }
   }
 }
-/// Collapse an offloading action looking for a job of the given type. The input
-/// action is changed to the input of the collapsed sequence. If we effectively
-/// had a collapse return the corresponding offloading action, otherwise return
-/// null.
-template 
-static OffloadAction *collapseOffloadingAction(Action *&CurAction) {
-  if (!CurAction)
-return nullptr;
-  if (auto *OA = dyn_cast(CurAction)) {
-if (OA->hasHostDependence())
-  if (auto *HDep = dyn_cast(OA->getHostDependence())) {
-CurAction = HDep;
-return OA;
-  }
-if (OA->hasSingleDeviceDependence())
-  if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) {
-CurAction = DDep;
-return OA;
+
+namespace {
+/// Utility class to control the collapse of dependent actions and select the
+/// tools accordingly.
+class ToolSelector final {
+  /// The tool chain this selector refers to.
+  const ToolChain &TC;
+
+  /// The compilation this selector refers to.
+  const Compilation &C;
+
+  /// The base action this selector refers to.
+  const JobAction *BaseAction;
+
+  /// Set to true if the current toolchain refers to host actions.
+  bool IsHostSelector;
+
+  /// Set to true if save-temps and embed-bitcode functionalities are active.
+  bool SaveTemps;
+  bool EmbedBitcode;
+
+  /// Get previous dependent action or null if that does not exist. If
+  /// \a CanBeCollapsed is false, that action must be legal to collapse or
+  /// null will be returned.
+  const JobAction *getPrevDependentAction(const ActionList &Inputs,
+  ActionList &SavedOffloadAction,
+  bool CanBeCollapsed = true) {
+// An option can be collapsed only if it has a single input.
+if (Inputs.size() != 1)
+  return nullptr;
+
+Action *CurAction = *Inputs.begin();
+if (CanBeCollapsed &&
+!CurAction->isCollapsingWithNextDependentActionLegal())
+  return nullptr;
+
+// If the input action is an offload action. Look through it and save any
+// offload action that can be dropped in the event of a collapse.
+if (auto *OA = dyn_cast(CurAction)) {
+  // If the dependent action is a device action, we will attempt to collapse
+  // only with other device actions. Otherwise, we would do the same but
+  // with host actions only.
+  if (!IsHostSelector) {
+if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) {
+  CurAction =
+  OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true);
+  if (CanBeCollapsed &&
+  !CurAction->isCollapsingWithNextDependentActionLegal())
+return nullptr;
+  SavedOffloadAction.push_back(OA);
+  return dyn_cast(CurAction);
+}
+  } else if (OA->hasHostDependence()) {
+CurAction = OA->getHostDependence();
+if (CanBeCollapsed &&
+!CurAction->isCollapsingWithNextDependentActionLegal())
+  return nullptr;
+SavedOffloadAction.push_back(OA);
+return dyn_cast(CurAction);
   }
+  return nullptr;
+}
+
+return dyn_cast(CurAction);
   }
-  return nullptr;
-}
-// Returns a Tool for a given JobAction.  In case the action and its
-// predecessors can be combined, updates Inputs with the inputs of the
-// first combined action. If one of the collapsed actions is a
-// CudaHostAction, updates CollapsedCHA with the pointer to it so the
-// caller can deal with extra handling such action requires.
-static const Tool *selectToolForJob(Compilation &C, bool SaveTemps,
-bool EmbedBitcode, const ToolChain *TC,
-const JobAction *JA,
-const ActionList *&Inputs,
-ActionList &CollapsedOffloadAction) {
-  const Tool *ToolForJob = nullptr;
-  CollapsedOffloadAction.clear();
-
-  // See if we should look for a compiler with an integrated assembler. We match
-  // bottom up, so what we are actually looking for 

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-25 Thread Alexey Sotkin via cfe-commits
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > AlexeySotkin wrote:
> > > > Anastasia wrote:
> > > > > Why this change?
> > > > Without this change, global variables with unnamed address space are 
> > > > translated to SPIR-V as variables with "Function" storage class, which 
> > > > is wrong.
> > > > This should fix this issue: 
> > > > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
> > > There is inconsistency with how Clang maps initializers to OpenCL memory 
> > > model.
> > > Consider example from the test case:
> > > ```
> > > __private int arr[] = {1, 2, 3};
> > > ```
> > > This code allocates a global constant for initializer {1, 2, 3} and later 
> > > copies values from this global constant to the private array using memcpy 
> > > intrinsic. The global constant must be allocated in constant address 
> > > space, but old code do assign any address space, which is considered to 
> > > be a private memory region.
> > > This patch puts global constant objects to constant address space.
> > Yes, this is perfectly fine. I was specifically asking about setting 
> > llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has to 
> > be done or is it because we now assign concrete address space and private 
> > was treated as no address space at all?
> This attribute has nothing to do with address spaces.
> See http://llvm.org/docs/LangRef.html#global-variables for local_unnamed_addr 
> and unnamed_addr attributes description.
> My understanding is that llvm::GlobalValue::UnnamedAddr::Global should be 
> fine here.
llvm::GlobalValue::UnnamedAddr::None is default value of UnnamedAddr for 
GlobalValue. This line can be removed, but extra "if" statement must be added 
before GV->setUnnamedAddr(UA);


https://reviews.llvm.org/D25305



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


[PATCH] D25942: Fix crash in implicit default constructor creation for a template record specialization that has a field declaration with an initializer expression

2016-10-25 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: rjmccall, rsmith.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes a NULL pointer crash that happens when clang is trying to 
create an implicit default constructor for a specialization of a record 
template which is defined in a specialization of a parent record template and 
has a field declaration with an initializer expression.

The following piece of code reproduces this problem:

  template
  class A {
  public:
template 
struct Inner;
  };
  
  template<>
  template
  struct A::Inner {
int member = 42;
  };
  
  int main(void) {
return A::Inner<0>().member;
  }

The crash happens because `CXXRecordDecl::getTemplateInstantiationPattern` 
returns nil when instantiating `A::Inner<0>`, because it tries to get the 
instantiation pattern from the declaration of `Inner` (which has no definition 
and thus no instantiation pattern), rather than the specialized definition of 
`Inner`. This patch fixes this by making sure that the instantiation pattern 
comes from the definition rather than the declaration of the record template.


Repository:
  rL LLVM

https://reviews.llvm.org/D25942

Files:
  lib/AST/DeclCXX.cpp
  test/CodeGenCXX/cxx11-crashes.cpp


Index: test/CodeGenCXX/cxx11-crashes.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx11-crashes.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 %s -o - | 
FileCheck %s
+
+namespace rd28886662 {
+
+template
+class A {
+public:
+  template
+  struct Inner;
+};
+
+template<>
+template
+struct A::Inner {
+  int member = 42; // should be ok
+};
+
+int foo(void) {
+  return A::Inner<0>().member;
+}
+
+// CHECK: _ZN10rd288866621AIiE5InnerILi0EEC2Ev
+// CHECK: store i32 42, i32* %member
+
+}
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1347,7 +1347,8 @@
 auto From = TD->getInstantiatedFrom();
 if (auto *CTD = From.dyn_cast()) {
   while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
-if (NewCTD->isMemberSpecialization())
+if (NewCTD->isMemberSpecialization() ||
+!NewCTD->isThisDeclarationADefinition())
   break;
 CTD = NewCTD;
   }


Index: test/CodeGenCXX/cxx11-crashes.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx11-crashes.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 %s -o - | FileCheck %s
+
+namespace rd28886662 {
+
+template
+class A {
+public:
+  template
+  struct Inner;
+};
+
+template<>
+template
+struct A::Inner {
+  int member = 42; // should be ok
+};
+
+int foo(void) {
+  return A::Inner<0>().member;
+}
+
+// CHECK: _ZN10rd288866621AIiE5InnerILi0EEC2Ev
+// CHECK: store i32 42, i32* %member
+
+}
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1347,7 +1347,8 @@
 auto From = TD->getInstantiatedFrom();
 if (auto *CTD = From.dyn_cast()) {
   while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
-if (NewCTD->isMemberSpecialization())
+if (NewCTD->isMemberSpecialization() ||
+!NewCTD->isThisDeclarationADefinition())
   break;
 CTD = NewCTD;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25935: [OpenCL] Diagnose variadic arguments

2016-10-25 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D25935



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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75704.
mgorny added a comment.

Updated to perform `.startswith()` check before splitting.


https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75705.
sfantao marked an inline comment as done.
sfantao added a comment.

- Address Hal Finkel comments - make diagnostic message more informative.


https://reviews.llvm.org/D21843

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- /dev/null
+++ test/Driver/openmp-offload.c
@@ -0,0 +1,37 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -fopenmp-targets
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
+
+/// ###
+
+/// Check error for no -fopenmp option
+// RUN:   %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// RUN:   %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.
+
+/// ###
+
+/// Check warning for duplicate offloading targets.
+// RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
+// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3009,72 +3009,23 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-namespace {
-enum OpenMPRuntimeKind {
-  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
-  /// without knowing what runtime to target.
-  OMPRT_Unknown,
-
-  /// The LLVM OpenMP runtime. When completed and integrated, this will become
-  /// the default for Clang.
-  OMPRT_OMP,
-
-  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
-  /// this runtime but can swallow the pragmas, and find and link against the
-  /// runtime library itself.
-  OMPRT_GOMP,
-
-  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
-  /// OpenMP runtime. We support this mode for users with existing dependencies
-  /// on this runtime library name.
-  OMPRT_IOMP5
-};
-}
-
-/// Compute the desired OpenMP runtime from the flag provided.
-static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain &TC,
-  const ArgList &Args) {
-  StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
-
-  const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
-  if (A)
-RuntimeName = A->getValue();
-
-  auto RT = llvm::StringSwitch(RuntimeName)
-.Case("libomp", OMPRT_OMP)
-.Case("libgomp", OMPRT_GOMP)
-.Case("libiomp5", OMPRT_IOMP5)
-.Default(OMPRT_Unknown);
-
-  if (RT == OMPRT_Unknown) {
-if (A)
-  TC.getDriver().Diag(diag::err_drv_unsupported_option_argument)
-  << A->getOption().getName() << A->getValue();
-else
-  // FIXME: We could use a nicer diagnostic here.
-  TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
-  }
-
-  return RT;
-}
-
 static void addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
   const ArgList &Args) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
 options::OPT_fno_openmp, false))
 return;
 
-  switch (getOpenMPRuntime(TC, Args)) {
-  case OMPRT_OMP:
+  switch (TC.getDriver().getOpenMPRuntime(Args

[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added inline comments.



Comment at: unittests/Driver/ToolChainsTest.cpp:15
+// FIXME: I presume this is not the correct way of doing this
+#include "../lib/Driver/ToolChains.h"
+#include "clang/Basic/VirtualFileSystem.h"

bkramer wrote:
> Yeah. It's better to hoist the enum + the decl for detectDistro into a public 
> header under include/clang/Driver and include it from here.
Ok. Then I'll probably refactor the whole thing into a nicer API anyway ;-).


https://reviews.llvm.org/D25869



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


r285073 - CodeGen: mark protocols as common data

2016-10-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Oct 25 09:50:44 2016
New Revision: 285073

URL: http://llvm.org/viewvc/llvm-project?rev=285073&view=rev
Log:
CodeGen: mark protocols as common data

This allows for the coalescing of the protocol declarations.  When the protocols
are declared in headers, multiple definitions of the protocol would be emitted.
Marking them as common data indicates that any one can be selected.

Added:
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285073&r1=285072&r2=285073&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Oct 25 09:50:44 2016
@@ -6562,15 +6562,20 @@ llvm::Constant *CGObjCNonFragileABIMac::
   const ObjCProtocolDecl *PD) {
   llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()];
 
-  if (!Entry)
+  if (!Entry) {
 // We use the initializer as a marker of whether this is a forward
 // reference or not. At module finalization we add the empty
 // contents for protocols which were referenced but never defined.
-Entry =
-new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
- false, llvm::GlobalValue::ExternalLinkage,
- nullptr,
- "\01l_OBJC_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+llvm::SmallString<64> Protocol;
+llvm::raw_svector_ostream(Protocol) << "\01l_OBJC_PROTOCOL_$_"
+<< PD->getObjCRuntimeNameAsString();
+
+Entry = new llvm::GlobalVariable(CGM.getModule(), 
ObjCTypes.ProtocolnfABITy,
+ false, llvm::GlobalValue::ExternalLinkage,
+ nullptr, Protocol);
+if (!CGM.getTriple().isOSBinFormatMachO())
+  Entry->setComdat(CGM.getModule().getOrInsertComdat(Protocol));
+  }
 
   return Entry;
 }
@@ -6688,10 +6693,16 @@ llvm::Constant *CGObjCNonFragileABIMac::
 Entry->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
 Entry->setInitializer(Init);
   } else {
-Entry =
-  new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
-   false, llvm::GlobalValue::WeakAnyLinkage, Init,
-   "\01l_OBJC_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+llvm::SmallString<64> Protocol;
+llvm::raw_svector_ostream(Protocol) << "\01l_OBJC_PROTOCOL_$_"
+<< PD->getObjCRuntimeNameAsString();
+
+Entry = new llvm::GlobalVariable(CGM.getModule(), 
ObjCTypes.ProtocolnfABITy,
+ false, llvm::GlobalValue::WeakAnyLinkage,
+ Init, Protocol);
+if (!CGM.getTriple().isOSBinFormatMachO())
+  Entry->setComdat(CGM.getModule().getOrInsertComdat(Protocol));
+
 Entry->setAlignment(
   CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABITy));
 
@@ -6702,13 +6713,20 @@ llvm::Constant *CGObjCNonFragileABIMac::
 
   // Use this protocol meta-data to build protocol list table in section
   // __DATA, __objc_protolist
+  llvm::SmallString<64> ProtocolRef;
+  llvm::raw_svector_ostream(ProtocolRef) << "\01l_OBJC_LABEL_PROTOCOL_$_"
+ << PD->getObjCRuntimeNameAsString();
+
   llvm::GlobalVariable *PTGV =
 new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy,
  false, llvm::GlobalValue::WeakAnyLinkage, Entry,
- "\01l_OBJC_LABEL_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+ ProtocolRef);
+  if (!CGM.getTriple().isOSBinFormatMachO())
+PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef));
   PTGV->setAlignment(
 CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
-  PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
+  if (CGM.getTriple().isOSBinFormatMachO())
+PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
   PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   CGM.addCompilerUsedGlobal(PTGV);
   return Entry;

Added: cfe/trunk/test/CodeGenObjC/protocol-comdat.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/protocol-comdat.m?rev=285073&view=auto
==
--- cfe/trunk/test/CodeGenObjC/protocol-comdat.m (added)
+++ cfe/trunk/test/CodeGenObjC/protocol-comdat.m Tue Oct 25 09:50:44 2016
@@ -0,0 +1,20 @@
+// RUN: %clang -cc1 -triple thumbv7--windows-itanium -fobjc-runtime=ios 
-emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
+
+@protocol P
+- (void) method;
+@end
+
+@interface I
+@en

[PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:163
+def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
+  "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading.">;
+def warn_drv_omp_offload_target_duplicate : Warning<

hfinkel wrote:
> This message does not tell the user how they might make their -fopenmp option 
> "compatible with offloading." Please make sure the message does, or is has an 
> associated hint message which does.
> 
Ok, the message is now: `The option -fopenmp-targets must be used in 
conjunction with a -fopenmp option compatible with offloading, please use 
-fopenmp=libomp or -fopenmp=libiomp5.`


https://reviews.llvm.org/D21843



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


[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75707.
mgorny marked 3 inline comments as done.
mgorny added a comment.

Thanks for the review. Implemented all three suggestions.


https://reviews.llvm.org/D25661

Files:
  lib/Driver/ToolChains.cpp
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  test/Driver/linux-header-search.cpp


Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -301,6 +301,15 @@
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for Gentoo's gcc-config -- clang should prefer the older
+// (4.9.3) version over the newer (5.4.0) due to preference specified
+// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
Index: test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
===
--- /dev/null
+++ test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
@@ -0,0 +1 @@
+Gentoo Base System release 2.3
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1430,6 +1430,43 @@
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr> File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTriple.str());
+  if (File) {
+SmallVector Lines;
+File.get()->getBuffer().split(Lines, "\n");
+for (StringRef Line : Lines) {
+  // CURRENT=triple-version
+  if (Line.consume_front("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
+// contain anything new or especially useful to us.
+const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
+   ActiveVersion.fir

[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285074: [Driver] Support obtaining active toolchain from 
gcc-config on Gentoo (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25661?vs=75707&id=75710#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25661

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  cfe/trunk/test/Driver/linux-header-search.cpp


Index: cfe/trunk/test/Driver/linux-header-search.cpp
===
--- cfe/trunk/test/Driver/linux-header-search.cpp
+++ cfe/trunk/test/Driver/linux-header-search.cpp
@@ -301,6 +301,15 @@
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for Gentoo's gcc-config -- clang should prefer the older
+// (4.9.3) version over the newer (5.4.0) due to preference specified
+// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
@@ -0,0 +1 @@
+Gentoo Base System release 2.3
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1438,6 +1438,43 @@
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr> File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTriple.str());
+  

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-10-25 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 75708.
sdardis marked an inline comment as done.
sdardis added a comment.

Extra testing for cases where the operand on the left of an operation is a 
vector.
Removed two spurious checks for vector types.


https://reviews.llvm.org/D25866

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-scalar-implict-conv.c
  test/Sema/zvector.c

Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-scalar-implict-conv.c
===
--- /dev/null
+++ test/Sema/vector-scalar-implict-conv.c
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+
+typedef long long v2i64 __attribute__((vector_size(16)));
+typedef long long v2i64 __attribute__((vector_size(16)));
+
+typedef int v2i32 __attribute__((vector_size(8)));
+typedef int v2i32 __attribute__((vector_size(8)));
+
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+
+typedef float v4f32 __attribute__((vector_size(16)));
+typedef double v4f64 __attribute__((vector_size(32)));
+
+void test (void);
+
+void test (void){
+
+  v2i64 v2i64_a = (v2i64) {0, 1};
+  v2i64 v2i64_r;
+
+  v2i32 v2i32_a = (v2i32) {0 , 1};
+
+  v2u64 v2u64_a = (v2u64) {0, 1};
+
+  v4f32 v4f32_a = (v4f32) {0.1f, 0.2f, 0.3f, 0.4f};
+
+  v4f64 v4f64_r = v4f32_a; // expected-error {{initializing 'v4f64' (vector of 4 'double' values) with an expression of incompatible type 'v4f32' (vector of 4 'float' values)}}
+
+  v4f64_r = v4f32_a;
+
+  // FIXME: this should warn about truncation.
+  v4f32_a = v4f64_r;
+
+  v2i64_r = v2i32_a; // expected-error {{assigning to 'v2i64' (vector of 2 'long long' values) from incompatible type 'v2i32' (vector of 2 'int' values)}}
+
+  v2i64_r = v2u64_a; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'v2u64' (vector of 2 'unsigned long long' values)}}
+
+  v2i64_r = v2i64_a + 1;
+  v2i64_r = v2i64_a - 1;
+  v2i64_r = v2i64_a * 1;
+  v2i64_r = v2i64_a / 1;
+  v2i64_r = v2i64_a % 1;
+
+  v2i64_r = 1 + v2i64_a;
+  v2i64_r = 1 - v2i64_a;
+  v2i64_r = 1 * v2i64_a;
+  v2i64_r = 1 / v2i64_a;
+  v2i64_r = 1 % v2i64_a;
+
+
+  v2i64_a += 1;
+  v2i64_a -= 1;
+  v2i64_a *= 1;
+  v2i64_a /= 1;
+  v2i64_a %= 1;
+
+  v2i64_r = v2i64_a == 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long __attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}}
+  v2i64_r = v2i64_a != 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long __attribute__((ext_v

[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

ship it.


https://reviews.llvm.org/D25661



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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D24954



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


[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

This is great!




Comment at: unittests/Driver/ToolChainsTest.cpp:154
+   
"BUG_REPORT_URL=\"https://bugs.debian.org/\"\n";));
+  ASSERT_EQ(DebianStretch, DetectDistro(DebianStretchSidFileSystem));
+}

Can you add the tests for /etc/SuSE-release here as well? 


https://reviews.llvm.org/D25869



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


Re: [PATCH] D25932: Unconditionally pass `-lto_library` to the linker on Darwin

2016-10-25 Thread Duncan P. N. Exon Smith via cfe-commits
> On 2016-Oct-24, at 21:43, Mehdi AMINI  wrote:
> 
> mehdi_amini created this revision.
> mehdi_amini added a reviewer: dexonsmith.
> mehdi_amini added a subscriber: cfe-commits.
> 
> We're only doing it with -flto currently, however it never "hurt"
> to pass it, and users that are linking without -flto can get in
> trouble if one of the dependency (a static library for instance)
> contains bitcode.

Seems reasonable.  LGTM.

> 
> 
> https://reviews.llvm.org/D25932
> 
> Files:
>  clang/lib/Driver/Tools.cpp
>  clang/test/Driver/darwin-ld-lto.c
> 
> 
> Index: clang/test/Driver/darwin-ld-lto.c
> ===
> --- clang/test/Driver/darwin-ld-lto.c
> +++ clang/test/Driver/darwin-ld-lto.c
> @@ -6,20 +6,20 @@
> // RUN: mkdir -p %T/lib
> // RUN: touch %T/lib/libLTO.dylib
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %T/bin -mlinker-version=133 -flto 2> %t.log
> +// RUN:   -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH: {{ld(.exe)?"}}
> // LINK_LTOLIB_PATH: "-lto_library"
> 
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -flto 2> 
> %t.log
> +// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed 
> dir not found; using 'ld' default search path instead
> 
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 
> -flto 2> %t.log
> +// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 
> 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH_NOWRN-NOT: warning: libLTO.dylib relative to clang 
> installed dir not found; using 'ld' default search path instead
> Index: clang/lib/Driver/Tools.cpp
> ===
> --- clang/lib/Driver/Tools.cpp
> +++ clang/lib/Driver/Tools.cpp
> @@ -7944,22 +7944,22 @@
>   CmdArgs.push_back("-object_path_lto");
>   CmdArgs.push_back(TmpPath);
> }
> +  }
> 
> -// Use -lto_library option to specify the libLTO.dylib path. Try to find
> -// it in clang installed libraries. If not found, the option is not used
> -// and 'ld' will use its default mechanism to search for libLTO.dylib.
> -if (Version[0] >= 133) {
> -  // Search for libLTO in /../lib/libLTO.dylib
> -  StringRef P = llvm::sys::path::parent_path(D.getInstalledDir());
> -  SmallString<128> LibLTOPath(P);
> -  llvm::sys::path::append(LibLTOPath, "lib");
> -  llvm::sys::path::append(LibLTOPath, "libLTO.dylib");
> -  if (llvm::sys::fs::exists(LibLTOPath)) {
> -CmdArgs.push_back("-lto_library");
> -CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
> -  } else {
> -D.Diag(diag::warn_drv_lto_libpath);
> -  }
> +  // Use -lto_library option to specify the libLTO.dylib path. Try to find
> +  // it in clang installed libraries. If not found, the option is not used
> +  // and 'ld' will use its default mechanism to search for libLTO.dylib.
> +  if (Version[0] >= 133) {
> +// Search for libLTO in /../lib/libLTO.dylib
> +StringRef P = llvm::sys::path::parent_path(D.getInstalledDir());
> +SmallString<128> LibLTOPath(P);
> +llvm::sys::path::append(LibLTOPath, "lib");
> +llvm::sys::path::append(LibLTOPath, "libLTO.dylib");
> +if (llvm::sys::fs::exists(LibLTOPath)) {
> +  CmdArgs.push_back("-lto_library");
> +  CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
> +} else {
> +  D.Diag(diag::warn_drv_lto_libpath);
> }
>   }
> 
> 
> 
> 

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


r285074 - [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 25 10:07:41 2016
New Revision: 285074

URL: http://llvm.org/viewvc/llvm-project?rev=285074&view=rev
Log:
[Driver] Support obtaining active toolchain from gcc-config on Gentoo

Support using gcc-config to determine the correct GCC toolchain location
on Gentoo. In order to do that, attempt to read gcc-config configuration
form [[sysroot]]/etc/env.d/gcc, if no custom toolchain location is
provided.

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

Added:
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285074&r1=285073&r2=285074&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 25 10:07:41 2016
@@ -1438,6 +1438,43 @@ void Generic_GCC::GCCInstallationDetecto
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr> File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTriple.str());
+  if (File) {
+SmallVector Lines;
+File.get()->getBuffer().split(Lines, "\n");
+for (StringRef Line : Lines) {
+  // CURRENT=triple-version
+  if (Line.consume_front("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
+// contain anything new or especially useful to us.
+const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
+   ActiveVersion.first.str() + "/" +
+   ActiveVersion.second.str();
+if (D.getVFS().exists(GentooPath + 

[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285076: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 
and older (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24954?vs=75704&id=75713#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24954

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3968,8 +3968,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3968,8 +3968,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-25 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 75712.
arphaman added a comment.

The updated patch addresses Richard's comment by making sure the fixit isn't 
emitted when the destructor call is invalid.


Repository:
  rL LLVM

https://reviews.llvm.org/D25817

Files:
  lib/Sema/SemaExprCXX.cpp
  test/CXX/special/class.dtor/p10-0x.cpp
  test/FixIt/fixit.cpp
  test/FixIt/no-fixit.cpp
  test/SemaCXX/pseudo-destructors.cpp

Index: test/SemaCXX/pseudo-destructors.cpp
===
--- test/SemaCXX/pseudo-destructors.cpp
+++ test/SemaCXX/pseudo-destructors.cpp
@@ -89,3 +89,26 @@
 void AliasTemplate(int *p) {
   p->~Id();
 }
+
+namespace dotPointerAccess {
+struct Base {
+  virtual ~Base() {}
+};
+
+struct Derived : Base {
+  ~Derived() {}
+};
+
+void test() {
+  Derived d;
+  static_cast(&d).~Base(); // expected-error {{member reference type 'dotPointerAccess::Base *' is a pointer; did you mean to use '->'}}
+  d->~Derived(); // expected-error {{member reference type 'dotPointerAccess::Derived' is not a pointer; did you mean to use '.'}}
+}
+
+typedef Derived *Foo;
+
+void test2(Foo d) {
+  d.~Foo(); // This is ok
+  d.~Derived(); // expected-error {{member reference type 'Foo' (aka 'dotPointerAccess::Derived *') is a pointer; did you mean to use '->'}}
+}
+}
Index: test/FixIt/no-fixit.cpp
===
--- test/FixIt/no-fixit.cpp
+++ test/FixIt/no-fixit.cpp
@@ -11,3 +11,15 @@
 (void)&i;
   }
 } x;
+
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar() = delete;
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // no fixit
+}
+
+}
Index: test/FixIt/fixit.cpp
===
--- test/FixIt/fixit.cpp
+++ test/FixIt/fixit.cpp
@@ -395,3 +395,14 @@
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"{}"
 int use_czi = czi.a;
 
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar();
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // expected-error {{member reference type 'dotPointerDestructor::Bar *' is a pointer; did you mean to use '->'}}
+}  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:5}:"->"
+
+}
Index: test/CXX/special/class.dtor/p10-0x.cpp
===
--- test/CXX/special/class.dtor/p10-0x.cpp
+++ test/CXX/special/class.dtor/p10-0x.cpp
@@ -33,7 +33,7 @@
  expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   pi->~decltype(int())();
-  pi.~decltype(int())(); // expected-error{{the type of object expression ('int *') does not match the type being destroyed ('decltype(int())' (aka 'int')) in pseudo-destructor expression}}
+  pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a pointer; did you mean to use '->'?}}
   pi.~decltype(intp())();
   pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6375,6 +6375,23 @@
   return false;
 }
 
+/// \brief Check if it's ok to try and recover dot pseudo destructor calls on
+/// pointer objects.
+static bool
+canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema &SemaRef,
+   QualType DestructedType) {
+  // If this is a record type, check if its destructor is callable.
+  if (auto *RD = DestructedType->getAsCXXRecordDecl()) {
+if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
+  return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
+return false;
+  }
+
+  // Otherwise, check if it's a type for which it's valid to use a pseudo-dtor.
+  return DestructedType->isDependentType() || DestructedType->isScalarType() ||
+ DestructedType->isVectorType();
+}
+
 ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -6409,15 +6426,36 @@
   = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin();
 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) {
   if (!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
-Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
-  << ObjectType << DestructedType << Base->getSourceRange()
-  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
-
-// Recover by settin

r285076 - [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 25 10:33:32 2016
New Revision: 285076

URL: http://llvm.org/viewvc/llvm-project?rev=285076&view=rev
Log:
[Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

Disable the OpenSUSE rules for OpenSUSE versions older than 11 as they
are incompatible with the old binutils on that distribution.

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285076&r1=285075&r2=285076&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 25 10:33:32 2016
@@ -3968,8 +3968,25 @@ static Distro DetectDistro(vfs::FileSyst
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


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


[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: unittests/Driver/ToolChainsTest.cpp:154
+   
"BUG_REPORT_URL=\"https://bugs.debian.org/\"\n";));
+  ASSERT_EQ(DebianStretch, DetectDistro(DebianStretchSidFileSystem));
+}

bruno wrote:
> Can you add the tests for /etc/SuSE-release here as well? 
Yes, that is a goal. I didn't add all distros yet because I wanted to see if 
I'm doing it right first ;-).


https://reviews.llvm.org/D25869



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Hi,

Nice, thanks for working on this!




Comment at: lib/Sema/SemaExpr.cpp:8051
+  if (!LHSVecType) {
+assert(RHSVecType && "RHSVecType is not a vector!");
 if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS),

`tryVectorConvertAndSplat` does more than plain scalar splat; it supports a 
more general type of CK_IntegralCast, see the comment on one of your changes to 
the tests below.

I suggest that instead of reusing this function, you should create another one 
that only handles the cases we actually want to support for non-ext vectors 
(i.e. for GCC compat). 



Comment at: test/Sema/vector-cast.c:57
+  // FIXME: This lacks a diagnostic: should complain that 'double' to vector 
'float2' involves truncation
+  f2 += d;
+  d += f2; // expected-error {{assigning to 'double' from incompatible type 
'float2' (vector of 2 'float' values)}}

This is not right. The fact that we don't have the appropriate diagnostics here 
doesn't mean we should accept this. For instance, this is what we get with GCC:

error: conversion of scalar 'double' to vector 'float2 {aka __vector(2) float}' 
involves truncation



Comment at: test/Sema/vector-scalar-implict-conv.c:2
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+
+typedef long long v2i64 __attribute__((vector_size(16)));

Can you rename this to vector-gcc-compat.c? It would also be nice to split 
functionality being tested within their own function, e.g.: arithmetic, logic, 
vector comparisons.


https://reviews.llvm.org/D25866



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


[PATCH] D25937: [Sema] -Wunused-variable warning for variables with array types should behave similarly to variables with scalar types

2016-10-25 Thread John McCall via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

There's no reason for this to only consider constant-sized arrays, and you 
should use getBaseElementTypeUnsafe() so you look through nested array types.  
That method is a no-op on non-array types, so you can just call it 
unconditionally here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25937



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


[PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review! Fixed the typos in the new diff.




Comment at: lib/Driver/Driver.cpp:1949
+SpecializedBuilders.push_back(new OpenMPActionBuilder(C, Args, Inputs));
+
 //

hfinkel wrote:
> Since we can have both OpenMP offloading and CUDA, please add a test that the 
> phases work correctly for that case (or that we produce an error if that 
> can't currently work correctly).
Added new test for that. The phases generation should work well if CUDA and 
OpenMP offloading are used on the same file. 

However, the bindings for these phases cannot be generated given that the NVPTX 
toolchain support for OpenMP is not implemented yet and the CUDA implementation 
interprets actions differently, e.g. in CUDA linking is the combination of 
binaries of different devices (GPUs) whereas for OpenMP actual linking takes 
place, i.e. symbols are resolved by looking into other compilation units.



https://reviews.llvm.org/D21845



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


[PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75722.
sfantao marked 7 inline comments as done.
sfantao added a comment.

- Fix typos and add test tht checks phases when OpenMP and CUDA are used 
simultaneously.


https://reviews.llvm.org/D21845

Files:
  lib/Driver/Driver.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -2,6 +2,11 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
 /// ###
 
 /// Check whether an invalid OpenMP target is specified:
@@ -35,3 +40,136 @@
 // RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
 // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
+
+/// ###
+
+/// Check the phases graph when using a single target, different from the host.
+/// We should have an offload action joining the host compile and device
+/// preprocessor and another one joining the device linking outputs to the host
+/// action.
+// RUN:   %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES %s
+// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp)
+// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp)
+// CHK-PHASES: 4: assembler, {3}, object, (host-openmp)
+// CHK-PHASES: 5: linker, {4}, image, (host-openmp)
+// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp)
+// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp)
+// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp)
+// CHK-PHASES: 11: assembler, {10}, object, (device-openmp)
+// CHK-PHASES: 12: linker, {11}, image, (device-openmp)
+// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image
+
+/// ###
+
+/// Check the phases when using multiple targets. Here we also add a library to
+/// make sure it is treated as input by the device.
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-LIB %s
+// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp)
+// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp)
+// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp)
+// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp)
+// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp)
+// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir
+// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp)
+// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp)
+// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp)
+// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir
+// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp)
+// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp)
+// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image
+
+
+/// ###
+
+/// Check the phases when using 

[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-10-25 Thread Pavel Labath via cfe-commits
labath created this revision.
labath added reviewers: benlangmuir, zturner.
labath added a subscriber: cfe-commits.

NFCI


https://reviews.llvm.org/D25948

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/FileSystemStatCache.cpp
  lib/Basic/VirtualFileSystem.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Serialization/ModuleManager.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -115,20 +115,23 @@
   }
 
   void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  1024, sys::fs::file_type::regular_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 1024,
+  sys::fs::file_type::regular_file, Perms);
 addEntry(Path, S);
   }
 
   void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::directory_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::directory_file, Perms);
 addEntry(Path, S);
   }
 
   void addSymlink(StringRef Path) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::symlink_file, sys::fs::all_all);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::symlink_file, sys::fs::all_all);
 addEntry(Path, S);
   }
 };
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -102,7 +102,7 @@
   // A cached stat value would be fine as well.
   if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
 ModuleEntry->InputFilesValidationTimestamp =
-Status.getLastModificationTime().toEpochTime();
+llvm::sys::toTimeT(Status.getLastModificationTime());
 }
 
 // Load the contents of the module
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1392,7 +1392,8 @@
 }
 
 OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
-Status.getSize(), Status.getLastModificationTime().toEpochTime());
+Status.getSize(),
+llvm::sys::toTimeT(Status.getLastModificationTime()));
   }
 
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
@@ -1433,8 +1434,8 @@
 
 // The file was not remapped; check whether it has changed on disk.
 if (Status.getSize() != uint64_t(F->second.Size) ||
-Status.getLastModificationTime().toEpochTime() !=
-uint64_t(F->second.ModTime))
+llvm::sys::toTimeT(Status.getLastModificationTime()) !=
+F->second.ModTime)
   AnyFileChanged = true;
   }
   
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -47,7 +47,7 @@
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
+llvm::sys::toTimePoint(ModificationTime), 0, 0,
   

[PATCH] D25949: [Driver] Refactor distro detection & classification as a separate API

2016-10-25 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: bruno, bkramer.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: modocache, beanz.

Refactor the Distro enum along with helper functions into a full-fledged
Distro class, inspired by llvm::Triple, and make it a public API.
The new class wraps the enum with necessary comparison operators, adding
the convenience Is*() methods and a constructor performing
the detection. The public API is needed to run the unit tests 
(https://reviews.llvm.org/D25869).


https://reviews.llvm.org/D25949

Files:
  include/clang/Driver/Distro.h
  lib/Driver/CMakeLists.txt
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/Distro.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -3834,169 +3835,6 @@
   }
 }
 
-/// Distribution (very bare-bones at the moment).
-
-enum Distro {
-  // NB: Releases of a particular Linux distro should be kept together
-  // in this enum, because some tests are done by integer comparison against
-  // the first and last known member in the family, e.g. IsRedHat().
-  ArchLinux,
-  DebianLenny,
-  DebianSqueeze,
-  DebianWheezy,
-  DebianJessie,
-  DebianStretch,
-  Exherbo,
-  RHEL5,
-  RHEL6,
-  RHEL7,
-  Fedora,
-  OpenSUSE,
-  UbuntuHardy,
-  UbuntuIntrepid,
-  UbuntuJaunty,
-  UbuntuKarmic,
-  UbuntuLucid,
-  UbuntuMaverick,
-  UbuntuNatty,
-  UbuntuOneiric,
-  UbuntuPrecise,
-  UbuntuQuantal,
-  UbuntuRaring,
-  UbuntuSaucy,
-  UbuntuTrusty,
-  UbuntuUtopic,
-  UbuntuVivid,
-  UbuntuWily,
-  UbuntuXenial,
-  UbuntuYakkety,
-  UnknownDistro
-};
-
-static bool IsRedhat(enum Distro Distro) {
-  return Distro == Fedora || (Distro >= RHEL5 && Distro <= RHEL7);
-}
-
-static bool IsOpenSUSE(enum Distro Distro) { return Distro == OpenSUSE; }
-
-static bool IsDebian(enum Distro Distro) {
-  return Distro >= DebianLenny && Distro <= DebianStretch;
-}
-
-static bool IsUbuntu(enum Distro Distro) {
-  return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
-}
-
-static Distro DetectDistro(vfs::FileSystem &VFS) {
-  llvm::ErrorOr> File =
-  VFS.getBufferForFile("/etc/lsb-release");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-SmallVector Lines;
-Data.split(Lines, "\n");
-Distro Version = UnknownDistro;
-for (StringRef Line : Lines)
-  if (Version == UnknownDistro && Line.startswith("DISTRIB_CODENAME="))
-Version = llvm::StringSwitch(Line.substr(17))
-  .Case("hardy", UbuntuHardy)
-  .Case("intrepid", UbuntuIntrepid)
-  .Case("jaunty", UbuntuJaunty)
-  .Case("karmic", UbuntuKarmic)
-  .Case("lucid", UbuntuLucid)
-  .Case("maverick", UbuntuMaverick)
-  .Case("natty", UbuntuNatty)
-  .Case("oneiric", UbuntuOneiric)
-  .Case("precise", UbuntuPrecise)
-  .Case("quantal", UbuntuQuantal)
-  .Case("raring", UbuntuRaring)
-  .Case("saucy", UbuntuSaucy)
-  .Case("trusty", UbuntuTrusty)
-  .Case("utopic", UbuntuUtopic)
-  .Case("vivid", UbuntuVivid)
-  .Case("wily", UbuntuWily)
-  .Case("xenial", UbuntuXenial)
-  .Case("yakkety", UbuntuYakkety)
-  .Default(UnknownDistro);
-if (Version != UnknownDistro)
-  return Version;
-  }
-
-  File = VFS.getBufferForFile("/etc/redhat-release");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-if (Data.startswith("Fedora release"))
-  return Fedora;
-if (Data.startswith("Red Hat Enterprise Linux") ||
-Data.startswith("CentOS") ||
-Data.startswith("Scientific Linux")) {
-  if (Data.find("release 7") != StringRef::npos)
-return RHEL7;
-  else if (Data.find("release 6") != StringRef::npos)
-return RHEL6;
-  else if (Data.find("release 5") != StringRef::npos)
-return RHEL5;
-}
-return UnknownDistro;
-  }
-
-  File = VFS.getBufferForFile("/etc/debian_version");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-// Contents: < major.minor > or < codename/sid >
-int MajorVersion;
-if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
-  switch (MajorVersion) {
-  case 5:
-return DebianLenny;
-  case 6:
-return DebianSqueeze;
-  case 7:
-return DebianWheezy;
-  case 8:
-return DebianJessie;
-  case 9:
-retur

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-25 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

AlexeySotkin wrote:
> bader wrote:
> > Anastasia wrote:
> > > bader wrote:
> > > > AlexeySotkin wrote:
> > > > > Anastasia wrote:
> > > > > > Why this change?
> > > > > Without this change, global variables with unnamed address space are 
> > > > > translated to SPIR-V as variables with "Function" storage class, 
> > > > > which is wrong.
> > > > > This should fix this issue: 
> > > > > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
> > > > There is inconsistency with how Clang maps initializers to OpenCL 
> > > > memory model.
> > > > Consider example from the test case:
> > > > ```
> > > > __private int arr[] = {1, 2, 3};
> > > > ```
> > > > This code allocates a global constant for initializer {1, 2, 3} and 
> > > > later copies values from this global constant to the private array 
> > > > using memcpy intrinsic. The global constant must be allocated in 
> > > > constant address space, but old code do assign any address space, which 
> > > > is considered to be a private memory region.
> > > > This patch puts global constant objects to constant address space.
> > > Yes, this is perfectly fine. I was specifically asking about setting 
> > > llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has 
> > > to be done or is it because we now assign concrete address space and 
> > > private was treated as no address space at all?
> > This attribute has nothing to do with address spaces.
> > See http://llvm.org/docs/LangRef.html#global-variables for 
> > local_unnamed_addr and unnamed_addr attributes description.
> > My understanding is that llvm::GlobalValue::UnnamedAddr::Global should be 
> > fine here.
> llvm::GlobalValue::UnnamedAddr::None is default value of UnnamedAddr for 
> GlobalValue. This line can be removed, but extra "if" statement must be added 
> before GV->setUnnamedAddr(UA);
Yes, I also think that leaving global should be fine here. So could we just 
undo the change to line 1274?


https://reviews.llvm.org/D25305



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


[PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75730.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Address Hal Finkel comments - fix comments/fix linker script comment.


https://reviews.llvm.org/D21847

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -173,3 +173,104 @@
 // CHK-PHASES-WITH-CUDA: 20: assembler, {19}, object, (device-openmp)
 // CHK-PHASES-WITH-CUDA: 21: linker, {20}, image, (device-openmp)
 // CHK-PHASES-WITH-CUDA: 22: offload, "host-cuda-openmp (powerpc64le-ibm-linux-gnu)" {14}, "device-openmp (nvptx64-nvidia-cuda)" {21}, image
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+/// We use -fopenmp-dump-offload-linker-script to dump the linker script and
+/// check its contents.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS -check-prefix=CHK-LKS -check-prefix=CHK-LKS-REG %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST -check-prefix=CHK-LKS -check-prefix=CHK-LKS-ST %s
+
+// Make sure we are not dumping the script unless the user requested it.
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+
+//
+// Check the linker script contains what we expect.
+//
+// CHK-LKS: /*
+// CHK-LKS:   OpenMP Offload Linker Script
+// CHK-LKS: *** Automatically generated by clang ***
+// CHK-LKS-NODUMP-NOT:  OpenMP Offload Linker Script.
+// CHK-LKS: */
+// CHK-LKS: TARGET(binary)
+// CHK-LKS-REG: INPUT([[T1BIN:.+\.out]])
+// CHK-LKS-REG: INPUT([[T2BIN:.+\.out]])
+// CHK-LKS-ST: INPUT([[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]])
+// CHK-LKS-ST: INPUT([[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]])
+// CHK-LKS: SECTIONS
+// CHK-LKS: {
+// CHK-LKS:   .omp_offloading :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   {
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: [[T1BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .);
+// CHK-LKS: [[T2BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .);
+// CHK-LKS:   }
+// CHK-LKS:   .omp_offloading.entries :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   SUBALIGN(0x01)
+// CHK-LKS:   {
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_begin = .);
+// CHK-LKS: *(.omp_offloading.entries)
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_end = .);
+// CHK-LKS:   }
+// CHK-LKS: }
+// CHK-LKS: INSERT BEFORE .data
+
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenm

[PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review! Comments inlined.




Comment at: lib/Driver/Tools.cpp:334
+  LksStream << "  OpenMP Offload Linker Script.\n";
+  LksStream << "*/\n";
+  LksStream << "TARGET(binary)\n";

hfinkel wrote:
> We should also say 'autogenerated' somewhere in this comment.
Ok, makes sense. The comment is now:
```
   OpenMP Offload Linker Script.
 *** Automatically generated by clang ***
```



Comment at: lib/Driver/Tools.cpp:386
+  // Dump the contents of the linker script if the user requested that.
+  if (C.getArgs().hasArg(options::OPT_fopenmp_dump_offload_linker_script))
+llvm::errs() << LksBuffer;

hfinkel wrote:
> I don't see why this is needed if we have -save-temps - I think we should 
> remove this option entirely.
The reason for adding this option is that the test is done when the driver is 
in dry-run mode (`-###`) so I'm not supposed to generate any files. If we don't 
run in dry-run mode, we need to allow linking to actually happen, therefore the 
machine where the tests runs needs to have a gcc-based toolchain and ld. 

Is there a way to request that in the required features set in llvm-lit config 
file? Should I add a new feature?


https://reviews.llvm.org/D21847



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


[PATCH] D23752: cmake: Supporting overriding runtime libdir via CLANG_LIBDIR_SUFFIX

2016-10-25 Thread Chris Bieneman via cfe-commits
beanz added a comment.

I think doing just the suffix is the right starting point.


https://reviews.llvm.org/D23752



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


[PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75732.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Fix typos and check -dynamic when it comes to translating arguments for 
offloading gcc toolchains.


https://reviews.llvm.org/D21848

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/ToolChain.h
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -247,24 +247,24 @@
 //
 // Compile for the powerpc device.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS: ld" {{.*}}"-o" "[[T1BIN]]" {{.*}}"[[T1OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1PP:.+\.i]]" "-x" "c" "[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1BC:.+\.bc]]" "-x" "cpp-output" "[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1ASM:.+\.s]]" "-x" "ir" "[[T1BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "[[T1ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T1BIN]]" {{.*}}[[T1OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" {{.*}}"-o" "[[T1BIN]]" {{.*}}[[T1OBJ]]
 
 //
 // Compile for the x86 device.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj"  {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp"  {{.*}}"-o" "[[T2OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS: ld" {{.*}}"-o" "[[T2BIN]]" {{.*}}"[[T2OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2PP:.+\.i]]" "-x" "c" "[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2BC:.+\.bc]]" "-x" "cpp-output" "[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "[[T2ASM:.+\.s]]" "-x" "ir" "[[T2BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "[[T2OBJ:.+\.o]]" "[[T2ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-o" "[[T2BIN]]" {{.*}}[[T2OBJ]]
+// CHK-COMMANDS-ST: ld" {{.*}}"-shared" {{.*}}"-o" "[[T2BIN]]" {{.*}}[[T2OBJ]]
 
 //
 // Generate host object from the BC file and link using the linker script.
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -222,6 +222,9 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
   bool IsIntegratedAssemblerDefault() const override;
+  llvm::opt::DerivedArgList *
+  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
 
 protected:
   Tool *getTool(Action::ActionClass AC) const override;
@@ -317,8 +320,8 @@
   bool HasNativeLLVMSupport() const override;
 
   llvm::opt::DerivedArgList *
-  TranslateArgs(const llvm::opt::DerivedArgList &Args,
-StringRef BoundArch) const override;
+  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
+Action::OffloadKind DeviceOffloadKind) const override;
 
   bool IsBlocksDefault() const override {
 // Always all

[PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!




Comment at: lib/Driver/ToolChains.cpp:2854
+  case options::OPT_shared:
+  case options::OPT_static:
+  case options::OPT_fPIC:

hfinkel wrote:
> And also?
> 
>   case options::OPT_dynamic:
Oh, yes, that one too! Thanks!


https://reviews.llvm.org/D21848



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


[PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao marked 7 inline comments as done.
sfantao added a comment.

Hi Hal,

Thanks for the review! Comments inlined.




Comment at: include/clang/Driver/Action.h:504
+  /// unbundling action.
+  struct DependingActionInfoTy final {
+/// \brief The tool chain of the depending action.

hfinkel wrote:
> Don't need 'Ty' in the name of this struct.
Ok, using `DependentActionInfo` now.



Comment at: lib/Driver/Driver.cpp:2091
+InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
+!types::isSrcFile(HostAction->getType())) {
+  auto UnbundlingHostAction =

hfinkel wrote:
> hfinkel wrote:
> > This checks that the file needs to be preprocessed. What does preprocessing 
> > have to do with this? I don't imagine that providing a preprocessed source 
> > file as input should invoke the unbundler   .
> On second thought, this is okay. It does not make sense to have a non-bundled 
> preprocessed source for the input there, as the host and device compilation 
> don't share a common preprocessor state.
> 
> We do need to be careful, perhaps, about .s files (which don't need 
> preprocessing as .S files do) -- we should probably assume that all 
> non-bundled .s files are host assembly code.
Yes, that is what we do. If the bundler tool detects that the input is not a 
bundle, it assumes it is host code/bits. In either case, we still generate the 
unbundling tool as the driver doesn't check the contents of the files.



Comment at: test/Driver/openmp-offload.c:274
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target 
powerpc64le-linux 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \

hfinkel wrote:
> hfinkel wrote:
> > Oh, are you using .i to indicate a bundle instead of a preprocessed file? 
> > Don't do that. Please use a different suffix -- the bundler has its own 
> > file format.
> Never mind; this is okay too.
Ok, there is no particular suffix to indicate a file is a bundle. The 
(un)bundler, however, has the machinery to detect if a given file is a bundle, 
it just uses the extension to understand if it is a human readable file, 
bitcode file, or object file, because the bundle format is different in those 
three cases.


https://reviews.llvm.org/D21853



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/dispatch-once.m:13
+
+void test_stack() {
+  dispatch_once_t once;

dcoughlin wrote:
> Should the tests for dispatch_once in unix-fns.c be moved here?
In fact we need to de-duplicate code with unix.API's pthread_once check, which 
is an exact copy-paste for this checker. Not sure how to achieve that, maybe 
split both into a single *-once checker (and remove this checker because it 
becomes empty). Maybe then we'd deal with tests as well.


https://reviews.llvm.org/D25909



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 75739.
NoQ marked 2 inline comments as done.
NoQ added a comment.

Consider a lot more dispatch_once_t regions: improve diagnostics for local 
structs containing predicates, find ivar structs with predicates.

Address a couple of review comments, discuss the rest.


https://reviews.llvm.org/D25909

Files:
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  test/Analysis/dispatch-once.m

Index: test/Analysis/dispatch-once.m
===
--- /dev/null
+++ test/Analysis/dispatch-once.m
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value.  Using such transient memory for the predicate is potentially dangerous.  Perhaps you intended to declare the variable as 'static'?}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(&once, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  // Use regexps to check that we're NOT suggesting to make this static.
+  dispatch_once(once, ^{}); // expected-warning-re^Call to 'dispatch_once' uses heap-allocated memory for the predicate value.  Using such transient memory for the predicate is potentially dangerous$
+}
+
+void test_external_pointer(dispatch_once_t *once) {
+  // External pointer does not necessarily point to the heap.
+  dispatch_once(once, ^{}); // no-warning
+}
+
+typedef struct {
+  dispatch_once_t once;
+} Struct;
+
+void test_local_struct() {
+  Struct s;
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 's' for the predicate value.  Using such transient memory for the predicate is potentially dangerous.  Perhaps you intended to declare the variable as 'static'?}}
+}
+
+void test_heap_struct() {
+  Struct *s = calloc(1, sizeof(Struct));
+  dispatch_once(&s->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses heap-allocated memory for the predicate value.}}
+}
+
+@interface Object : NSObject {
+@public
+  dispatch_once_t once;
+  Struct s;
+}
+- (void)test_ivar_from_inside;
+- (void)test_ivar_struct_from_inside;
+@end
+
+@implementation Object
+- (void)test_ivar_from_inside {
+  dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
+@end
+
+void test_ivar_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+void test_ivar_struct_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(&o->s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
+
+void test_ivar_from_external_obj(Object *o) {
+  // ObjC object pointer always points to the heap.
+  dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+
+void test_ivar_struct_from_external_obj(Object *o) {
+  dispatch_once(&o->s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -33,6 +33,8 @@
 class MacOSXAPIChecker : public Checker< check::PreStmt > {
   mutable std::unique_ptr BT_dispatchOnce;
 
+  static const ObjCIvarRegion *getParentIvarRegion(const MemRegion *R);
+
 public:
   void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
 
@@ -49,20 +51,35 @@
 // dispatch_once and dispatch_once_f
 //===--===//
 
+const ObjCIvarRegion *
+MacOSXAPIChecker::getParentIvarRegion(const MemRegion *R) {
+  const SubRegion *SR = dyn_cast(R);
+  while (SR) {
+if (const ObjCIvarRegion *IR = dyn_cast(SR))
+  return IR;
+SR = dyn_cast(SR->getSuperRegion());
+  }
+  return nullptr;
+}
+
 void MacOSXAPIChecker::CheckDispatchOnce

[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
yaxunl added subscribers: cfe-commits, b-sumner.

https://reviews.llvm.org/D25954

Files:
  lib/Headers/opencl-c.h


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75741.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Fix typos and use StringRef() instead of const char * to follow what the 
Driver does today when it comes to specify the bound architectures.


https://reviews.llvm.org/D21853

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Types.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Types.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -302,3 +302,56 @@
 // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp)
 // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp)
 // CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBACTIONS %s
+
+// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp)
+// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp)
+// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp)
+// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp)
+// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp)
+// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir
+// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp)
+// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir
+// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp)
+// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp)
+// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp)
+// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling/bundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBUACTIONS %s
+
+// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp)
+// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir
+// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp)
+// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object
+// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object
+// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp)
+// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
+// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
+
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -170,6 +170,10 @@
   }
 }
 
+bool types::isSrcFile(ID Id) {
+  return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID;
+}
+
 types::ID types::lookupTypeForExtension(llvm::StringRef Ext) {
   return llvm::StringSwitch(Ext)
.Case("c", TY_C)
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -265,6 +265,7 @@
 retu

[PATCH] D25850: [WIP] Accept nullability annotations (_Nullable) on array parameters

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2493-2499
   case Type::Adjusted:
-  case Type::Decayed:
+  case Type::Decayed: {
 // Decayed and adjusted types use the adjusted type in LLVM and DWARF.
-return CreateType(
-cast(cast(Ty)->getAdjustedType()), Unit);
+QualType Adjusted = cast(Ty)->getAdjustedType();
+(void)AttributedType::stripOuterNullability(Adjusted);
+return CreateType(cast(Adjusted), Unit);
+  }

rsmith wrote:
> I think this should be handled by `UnwrapTypeForDebugInfo` instead of here; 
> this is after all just a type sugar node.
Getting back to this today. I'm inclined to say we should just drop the 
AdjustedType node altogether in UnwrapTypeForDebugInfo. What do you think? 
(also for @aprantl)


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[PATCH] D25876: [analyzer] Report CFNumberGetValue API misuse

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/CFNumber.c:39
+  unsigned char scalar = 0;
+  CFNumberGetValue(x, kCFNumberSInt16Type, &scalar);  // expected-warning{{A 
CFNumber object that represents a 16-bit integer is used to initialize an 8-bit 
integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
+  return scalar;

We're not sure from this code if the `CFNumber` object `x` actually represents 
a 16-bit integer, or somebody just misplaced the `kCFNumberSInt16Type` thing. I 
think the warning message could be made more precise in this sence, but i'm not 
good at coming up with warning messages.

Hmm, there could actually be a separate check for detecting inconsistent type 
specifiers used for accessing the same CFNumber object.


https://reviews.llvm.org/D25876



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


r285098 - Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"

2016-10-25 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Oct 25 14:05:50 2016
New Revision: 285098

URL: http://llvm.org/viewvc/llvm-project?rev=285098&view=rev
Log:
Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"

The problem with the original commit was that some of Apple's headers depended
on an incorrect behaviour, this commit adds a temporary workaround until those
headers are fixed.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=285098&r1=285097&r2=285098&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 25 14:05:50 2016
@@ -9909,23 +9909,16 @@ public:
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
-  AvailabilityResult getCurContextAvailability() const;
-
-  /// \brief Get the verison that this context implies.
-  /// For instance, a method in an interface that is annotated with an
-  /// availability attribuite effectively has the availability of the 
interface.
-  VersionTuple getVersionForDecl(const Decl *Ctx) const;
-
   /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
   ///
   /// \param D The declaration to check. Note that this may be altered to point
   /// to another declaration that \c D gets it's availability from. i.e., we
   /// walk the list of typedefs to find an availability attribute.
   ///
-  /// \param ContextVersion The version to compare availability against.
-  AvailabilityResult
-  ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, VersionTuple ContextVersion,
-   std::string *Message);
+  /// \param Message If non-null, this will be populated with the message from
+  /// the availability attribute that is selected.
+  AvailabilityResult ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D,
+  std::string *Message);
 
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=285098&r1=285097&r2=285098&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 25 14:05:50 2016
@@ -15627,29 +15627,3 @@ void Sema::ActOnPragmaWeakAlias(Identifi
 Decl *Sema::getObjCDeclContext() const {
   return (dyn_cast_or_null(CurContext));
 }
-
-AvailabilityResult Sema::getCurContextAvailability() const {
-  const Decl *D = cast_or_null(getCurObjCLexicalContext());
-  if (!D)
-return AR_Available;
-
-  // If we are within an Objective-C method, we should consult
-  // both the availability of the method as well as the
-  // enclosing class.  If the class is (say) deprecated,
-  // the entire method is considered deprecated from the
-  // purpose of checking if the current context is deprecated.
-  if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-AvailabilityResult R = MD->getAvailability();
-if (R != AR_Available)
-  return R;
-D = MD->getClassInterface();
-  }
-  // If we are within an Objective-c @implementation, it
-  // gets the same availability context as the @interface.
-  else if (const ObjCImplementationDecl *ID =
-dyn_cast(D)) {
-D = ID->getClassInterface();
-  }
-  // Recover from user error.
-  return D ? D->getAvailability() : AR_Available;
-}

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=285098&r1=285097&r2=285098&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Oct 25 14:05:50 2016
@@ -6328,30 +6328,6 @@ static void handleDelayedForbiddenType(S
   diag.Triggered = true;
 }
 
-static bool isDeclDeprecated(Decl *D) {
-  do {
-if (D->isDeprecated())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interface->isDeprecated();
-  } while ((D = cast_or_null(D->getDeclContext(;
-  return false;
-}
-
-static bool isDeclUnavailable(Decl *D) {
-  do {
-if (D->isUnavailable())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return 

[PATCH] D25958: [libc++] Silence "unused parameter" warnings in test/support/archetypes.hpp

2016-10-25 Thread Casey Carter via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: EricWF, mclow.lists.
CaseyCarter added a subscriber: cfe-commits.

Fairly straightforward: simply removes the parameter names from the unused 
parameters.


https://reviews.llvm.org/D25958

Files:
  test/support/archetypes.hpp


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -68,12 +68,12 @@
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept
+explicit TestBase(std::initializer_list& il, int = 0) noexcept
   : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept : 
value(il.size()) {
+explicit TestBase(std::initializer_list& il, int = 0) noexcept : 
value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 TestBase& operator=(int xvalue) noexcept {
@@ -135,9 +135,9 @@
 template ::type = true>
 constexpr ValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr ValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {}
+explicit constexpr ValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {}
 template ::type = true>
-constexpr ValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {}
+constexpr ValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {}
 TEST_CONSTEXPR_CXX14 ValueBase& operator=(int xvalue) noexcept {
 value = xvalue;
 return *this;
@@ -193,9 +193,9 @@
 template ::type = true>
 constexpr TrivialValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr TrivialValueBase(std::initializer_list& il, int y 
= 0) : value(il.size()) {}
+explicit constexpr TrivialValueBase(std::initializer_list& il, int = 
0) : value(il.size()) {}
 template ::type = true>
-constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {};
+constexpr TrivialValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {};
 int value;
 protected:
 constexpr TrivialValueBase() noexcept : value(0) {}


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -68,12 +68,12 @@
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept
+explicit TestBase(std::initializer_list& il, int = 0) noexcept
   : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept : value(il.size()) {
+explicit TestBase(std::initializer_list& il, int = 0) noexcept : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 TestBase& operator=(int xvalue) noexcept {
@@ -135,9 +135,9 @@
 template ::type = true>
 constexpr ValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr ValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+explicit constexpr ValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 template ::type = true>
-constexpr ValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+constexpr ValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 TEST_CONSTEXPR_CXX14 ValueBase& operator=(int xvalue) noexcept {
 value = xvalue;
 return *this;
@@ -193,9 +193,9 @@
 template ::type = true>
 constexpr TrivialValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+explicit constexpr TrivialValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 template ::type = true>
-constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {};
+constexpr TrivialValueBase(std::initializer_list& il, int = 0) : value(il.size()) {};
 int value;
 protected:
 constexpr TrivialValueBase() noexcept : value(0) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285100 - [libc++] Fix modules build - Rework __refstring definition

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:33:14 2016
New Revision: 285100

URL: http://llvm.org/viewvc/llvm-project?rev=285100&view=rev
Log:
[libc++] Fix modules build - Rework __refstring definition 

Summary:
`__libcpp_refstring` currently has two different definitions. First there is 
the complete definition in `<__refstring>` but there is also a second in  
``.  The historical reason for this split is because both libc++ and 
libc++abi need to see the inline definitions of __libcpp_refstrings methods, 
but the `` header doesn't.  However this is an ODR violation and 
breaks the modules build.

This patch fixes the issue by creating a single class definition in 
`` and changing `<__refstring>` to contain only the inline method 
definitions. This way both `libcxx/src/stdexcept.cpp` and 
`libcxxabi/src/stdexcept.cpp` see the same declaration in `` and 
definitions in `<__refstring>`

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/__refstring
libcxx/trunk/include/stdexcept
libcxx/trunk/src/stdexcept.cpp

Modified: libcxx/trunk/include/__refstring
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__refstring?rev=285100&r1=285099&r2=285100&view=diff
==
--- libcxx/trunk/include/__refstring (original)
+++ libcxx/trunk/include/__refstring Tue Oct 25 14:33:14 2016
@@ -11,6 +11,7 @@
 #define _LIBCPP___REFSTRING
 
 #include <__config>
+#include 
 #include 
 #include 
 #ifdef __APPLE__
@@ -20,119 +21,106 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-class _LIBCPP_HIDDEN __libcpp_refstring
-{
-private:
-const char* str_;
-
-typedef int count_t;
-
-struct _Rep_base
-{
-std::size_t len;
-std::size_t cap;
-count_t count;
-};
-
-static
-_Rep_base*
-rep_from_data(const char *data_) _NOEXCEPT
-{
-char *data = const_cast(data_);
-return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-}
-static
-char *
-data_from_rep(_Rep_base *rep) _NOEXCEPT
-{
-char *data = reinterpret_cast(rep);
-return data + sizeof(*rep);
-}
+namespace __refstring_imp { namespace {
+typedef int count_t;
 
-#ifdef __APPLE__
-static
-const char*
-compute_gcc_empty_string_storage() _NOEXCEPT
-{
-void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-if (handle == nullptr)
-return nullptr;
-void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
-if (sym == nullptr)
-return nullptr;
-return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-}
-
-static
-const char*
-get_gcc_empty_string_storage() _NOEXCEPT
-{
-static const char* p = compute_gcc_empty_string_storage();
-return p;
-}
+struct _Rep_base {
+std::size_t len;
+std::size_t cap;
+count_t count;
+};
 
-bool
-uses_refcount() const
-{
-return str_ != get_gcc_empty_string_storage();
-}
-#else
-bool
-uses_refcount() const
-{
-return true;
-}
+inline _Rep_base* rep_from_data(const char *data_) noexcept {
+char *data = const_cast(data_);
+return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+}
+
+inline char * data_from_rep(_Rep_base *rep) noexcept {
+char *data = reinterpret_cast(rep);
+return data + sizeof(*rep);
+}
+
+#if defined(__APPLE__)
+inline
+const char* compute_gcc_empty_string_storage() _NOEXCEPT
+{
+void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+if (handle == nullptr)
+return nullptr;
+void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+if (sym == nullptr)
+return nullptr;
+return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
+}
+
+inline
+const char*
+get_gcc_empty_string_storage() _NOEXCEPT
+{
+static const char* p = compute_gcc_empty_string_storage();
+return p;
+}
 #endif
 
-public:
-explicit __libcpp_refstring(const char* msg) {
-std::size_t len = strlen(msg);
-_Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) 
+ len + 1));
-rep->len = len;
-rep->cap = len;
-rep->count = 0;
-char *data = data_from_rep(rep);
-std::memcpy(data, msg, len + 1);
-str_ = data;
-}
+}} // namespace __refstring_imp
 
-__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_)
-{
-if (uses_refcount())
-__sync_add_and_fetch(&rep_from_data(str_)->count, 1);
-}
+using namespace __refstring_imp;
 
-__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT
+inline
+__libcpp_refstring::__libcpp_refstring(const char* msg) {
+std::size_t len = strlen(msg);
+_Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + 
len + 1));
+rep-

[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 75770.
EricWF added a comment.

- Address review comments by adding better documentation in the CHANGELOG.TXT.


https://reviews.llvm.org/D25593

Files:
  CMakeLists.txt
  lib/abi/CHANGELOG.TXT
  lib/abi/x86_64-linux-gnu.abilist

Index: lib/abi/x86_64-linux-gnu.abilist
===
--- lib/abi/x86_64-linux-gnu.abilist
+++ lib/abi/x86_64-linux-gnu.abilist
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD2Ev'}
@@ -893,9 +891,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvEaSERKS1_'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__get_const_dbEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE'}
 {'type': 'OBJECT', 'name': '_ZNSt3__114__num_get_base5__srcE', 'size': 33}
@@ -943,12 +938,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb1EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__get_classnameEPKcb'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIdEET_PKcS3_Rj'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIeEET_PKcS3_Rj'}
@@ -1080,9 +1069,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state4waitEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9__executeEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9set_valueEv'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED2Ev'}
@@ -1122,8 +1108,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutex8try_lockEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base11lock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base13unlock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base15try_lock_sharedEv'}
@@ -1144,9 +1128,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__119__thread_local_dataEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119declare_no_pointersEPcm'}
 {'type': 'OBJECT', 'name': '_ZNSt3__119piecewise_constructE', 'size': 1}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__get_collation_nameEPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__throw_system_errorEiPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE16__at_thread_exitEPv'}
Index: lib/abi/CHANGELOG.TXT
===
--- lib/abi/CHANGELOG.TXT
+++ lib/abi/CHANGELOG.TXT
@@ -16,6 +16,41 @@
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experime

[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285101: [libcxx] Build with -fvisibility-inlines-hidden -- 
Remove 20 inline definitions… (authored by EricWF).

Changed prior to commit:
  https://reviews.llvm.org/D25593?vs=75770&id=75772#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25593

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/lib/abi/CHANGELOG.TXT
  libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist

Index: libcxx/trunk/lib/abi/CHANGELOG.TXT
===
--- libcxx/trunk/lib/abi/CHANGELOG.TXT
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT
@@ -16,6 +16,41 @@
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IwED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD2Ev
+  SYMBOL REMOVED: _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+
+  x86_64-apple-darwin16.0
+  ---
+  No Changes - inline symbols are already hidden
+
+
 * r284206 - Implement C++17 aligned allocation in 
 
   x86_64-linux-gnu
Index: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
===
--- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
+++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD2Ev'}
@@ -893,9 +891,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvEaSERKS1_'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__get_const_dbEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE'}
 {'type': 'OBJECT', 'name': '_ZNSt3__114__num_get_base5__srcE', 'size': 33}
@@ -943,12 +938,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb1EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__get_classnameEPKcb'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIdEET_PKcS3_Rj'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIeEET_PKcS3_Rj'}
@@ -1080,9 +1069,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state4waitEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9__executeEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9set_valueEv'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__libcpp_sscanf_lEPKcP15__l

[libcxx] r285102 - Update revision number in CHANGELOG.TXT

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:44:38 2016
New Revision: 285102

URL: http://llvm.org/viewvc/llvm-project?rev=285102&view=rev
Log:
Update revision number in CHANGELOG.TXT

Modified:
libcxx/trunk/lib/abi/CHANGELOG.TXT

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285102&r1=285101&r2=285102&view=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Tue Oct 25 14:44:38 2016
@@ -17,7 +17,7 @@ Version 4.0
 ---
 
 
-* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+* r285101 - Add -fvisibility-inlines-hidden when building libc++.
 
   Although this change removes symbols, it should still be non-ABI breaking
   since all of the definitions removed are inline functions. For this reason


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


[libcxx] r285101 - [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:43:44 2016
New Revision: 285101

URL: http://llvm.org/viewvc/llvm-project?rev=285101&view=rev
Log:
[libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions 
from the dylib

Summary:
This patch turns on `-fvisibility-inlines-hidden` when building  the dylib. 
This is important so that libc++.dylib doesn't accidentally export 
inline-functions which are ODR used somewhere in the dylib.

On OS X this change has no effect on the current ABI of the dylib. 
Unfortunately on Linux there are already ~20 inline functions which are 
unintentionally exported by the dylib. Almost all of these are implicitly 
generated destructors. I believe removing these function definitions is safe 
because every "linkage unit" which uses these functions has its own definition, 
and therefore shouldn't be dependent on libc++.dylib to provide them.

Also could a FreeBSD maintainer comment on the ABI compatibility of this patch?



Reviewers: mclow.lists, emaste, dexonsmith, joker-eph-DISABLED, jroelofs, 
danalbert, mehdi_amini, compnerd, dim

Subscribers: beanz, mgorny, cfe-commits, modocache

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=285101&r1=285100&r2=285101&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Oct 25 14:43:44 2016
@@ -342,6 +342,11 @@ endif()
 # headers
 add_compile_flags_if_supported(-nostdinc++)
 
+# Hide all inline function definitions which have not explicitly been marked
+# visible. This prevents new definitions for inline functions from appearing in
+# the dylib when get ODR used by another function.
+add_compile_flags_if_supported(-fvisibility-inlines-hidden)
+
 # Let the library headers know they are currently being used to build the
 # library.
 add_definitions(-D_LIBCPP_BUILDING_LIBRARY)

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285101&r1=285100&r2=285101&view=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Tue Oct 25 14:43:44 2016
@@ -16,6 +16,41 @@ New entries should be added directly bel
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IwED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD2Ev
+  SYMBOL REMOVED: _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+
+  x86_64-apple-darwin16.0
+  ---
+  No Changes - inline symbols are already hidden
+
+
 * r284206 - Implement C++17 aligned allocation in 
 
   x86_64-linux-gnu

Modified: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist?rev=285101&r1=285100&r2=285101&view=diff
==
--- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist (original)
+++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist Tue Oct 25 14:43:44 2016
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': 
'_ZNSt12experimental15fundamentals_v1

[PATCH] D25850: [WIP] Accept nullability annotations (_Nullable) on array parameters

2016-10-25 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2493-2499
   case Type::Adjusted:
-  case Type::Decayed:
+  case Type::Decayed: {
 // Decayed and adjusted types use the adjusted type in LLVM and DWARF.
-return CreateType(
-cast(cast(Ty)->getAdjustedType()), Unit);
+QualType Adjusted = cast(Ty)->getAdjustedType();
+(void)AttributedType::stripOuterNullability(Adjusted);
+return CreateType(cast(Adjusted), Unit);
+  }

jordan_rose wrote:
> rsmith wrote:
> > I think this should be handled by `UnwrapTypeForDebugInfo` instead of here; 
> > this is after all just a type sugar node.
> Getting back to this today. I'm inclined to say we should just drop the 
> AdjustedType node altogether in UnwrapTypeForDebugInfo. What do you think? 
> (also for @aprantl)
Assuming that we don't want to support nullability attributes in the debug info 
that seems fine. At least at this point I don;t think there is a need to encode 
this in DWARF.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[libcxxabi] r285107 - Get libc++abi building with LLVM_ENABLE_MODULES

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 15:07:49 2016
New Revision: 285107

URL: http://llvm.org/viewvc/llvm-project?rev=285107&view=rev
Log:
Get libc++abi building with LLVM_ENABLE_MODULES

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=285107&r1=285106&r2=285107&view=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Tue Oct 25 15:07:49 2016
@@ -95,6 +95,12 @@ string(REPLACE ";" " " LIBCXXABI_COMPILE
 string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}")
 string(REPLACE ";" " " LIBCXXABI_SHARED_LINK_FLAGS 
"${LIBCXXABI_SHARED_LINK_FLAGS}")
 
+# FIXME: libc++abi.so will not link when modules are enabled because it depends
+# on symbols defined in libc++.so which has not yet been built.
+if (LLVM_ENABLE_MODULES)
+  string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS 
"${CMAKE_SHARED_LINKER_FLAGS}")
+endif()
+
 # Add a object library that contains the compiled source files.
 add_library(cxxabi_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
 


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


[PATCH] D23754: cmake: Add CLANG_GOLD_LIBDIR_SUFFIX to specify loc of LLVMgold.so

2016-10-25 Thread Michał Górny via cfe-commits
mgorny added a reviewer: beanz.
mgorny added a subscriber: beanz.
mgorny added a comment.

@beanz, could you also look at this one? I'd like to replace 
CLANG_LIBDIR_SUFFIX with the runtimes suffix, and for this I'd have to get rid 
of this CLANG_LIBDIR_SUFFIX occurrence as well. However, I don't think 
LLVMgold.so really counts as a 'runtime', so I guess a default of 
LLVM_LIBDIR_SUFFIX with possible explicit override would work here.


https://reviews.llvm.org/D23754



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


[libcxx] r285117 - Fix nullptr tests

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 15:45:17 2016
New Revision: 285117

URL: http://llvm.org/viewvc/llvm-project?rev=285117&view=rev
Log:
Fix nullptr tests

Modified:
libcxx/trunk/include/__nullptr
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp

Modified: libcxx/trunk/include/__nullptr
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__nullptr?rev=285117&r1=285116&r2=285117&view=diff
==
--- libcxx/trunk/include/__nullptr (original)
+++ libcxx/trunk/include/__nullptr Tue Oct 25 15:45:17 2016
@@ -42,10 +42,6 @@ struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
 
 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, 
nullptr_t) {return true;}
 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, 
nullptr_t) {return true;}
 };
 
 inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() 
{return nullptr_t(0);}

Modified: 
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp?rev=285117&r1=285116&r2=285117&view=diff
==
--- libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp Tue 
Oct 25 15:45:17 2016
@@ -11,6 +11,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 // typedef decltype(nullptr) nullptr_t;
 
 struct A
@@ -34,22 +36,20 @@ void test_conversions()
 }
 }
 
+template  struct Voider { typedef void type; };
+template  struct has_less : std::false_type {};
+
+template  struct has_less() < nullptr)>::type> : 
std::true_type {};
+
 template 
 void test_comparisons()
 {
 T p = nullptr;
 assert(p == nullptr);
-assert(p <= nullptr);
-assert(p >= nullptr);
 assert(!(p != nullptr));
-assert(!(p < nullptr));
-assert(!(p > nullptr));
 assert(nullptr == p);
-assert(nullptr <= p);
-assert(nullptr >= p);
 assert(!(nullptr != p));
-assert(!(nullptr < p));
-assert(!(nullptr > p));
 }
 
 #if defined(__clang__)
@@ -89,6 +89,15 @@ int main()
 test_conversions();
 }
 {
+#ifdef _LIBCPP_HAS_NO_NULLPTR
+static_assert(!has_less::value, "");
+// FIXME: our c++03 nullptr emulation still allows for comparisons
+// with other pointer types by way of the conversion operator.
+//static_assert(!has_less::value, "");
+#else
+// TODO Enable this assertion when all compilers implement core DR 583.
+// static_assert(!has_less::value, "");
+#endif
 test_comparisons();
 test_comparisons();
 test_comparisons();


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


Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
> wrote:
> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
> >  wrote:
> >>
> >> > Sure, go ahead.
> >>
> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
> >> I've found: the changes for the builtins affecting non submodule local
> >> visibility broke current users of plain "-fmodules" against our
> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
> >> work around that for the time being: make the new behavior dependent
> >> on local vis. Can you take a look?
> >
> >
> > What's the nature of the breakage? Generally I'd be fine with your patch,
> > but I wonder if there's something better we could do here.
>
> I haven't entirely isolated the problem, but they are all related to
> definitions from stdint.h. In one example below, uint32_t doesn't
> leak, requiring an explicit "#include " to make it work.
>
> -- example.m
> #import 
> --
> $ clang -arch x86_64 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>
> While building module 'IOKit' imported from example.m:1:
> In file included from :2:
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/
> Library/Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
> error: de
>   'Darwin.POSIX._types._uint32_t' before it is required
> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
> uint32_t *dataSize);
>   ^
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/
> include/_types/_uint32_t.h:31:22:
> note: previous declaration is here
> typedef unsigned int uint32_t;
>  ^
> bot.m:1:9: fatal error: could not build module 'IOKit'
> #import 
>  ~~~^


This change also broke local submodule visibility builds with modular glibc
(see PR30778 for details). I have an idea for how to fix this; running it
through bootstrap now.

>> > Hmm. Ideally, we should try to pick something that captures the spirit
> >> > of
> >> > "only non-modular headers and headers from used modules". Something
> like
> >> > "ignore_modules_not_declared_used", but less wordy?
> >>
> >> Right. It's gonna be hard to shrink this to a meaningful short name.
> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
> >
> >
> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
> > specified on a use-declaration:
> >
> >   use [exhaustive] a, b, c
>
> I don't understand, the 'Darwin' module map doesn't use the 'use'
> keyword in any of its modules, how do you suggest we would use that to
> express the 'ignore_modules_not_declared_used' idea?


Hah, right, this would only work if your module has dependencies. Maybe an
[exhaustive_uses] attribute on the module itself then?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285120 - [index] Fixes for locations and relations in Objective C categories and getters/setters

2016-10-25 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Oct 25 16:11:22 2016
New Revision: 285120

URL: http://llvm.org/viewvc/llvm-project?rev=285120&view=rev
Log:
[index] Fixes for locations and relations in Objective C categories and 
getters/setters

- Add entries for protocols on categories
- Add relation between categories and class they extend
- Add relation between getters/setters and their corresponding property
- Use category name location as the location of category decls/defs if it has 
one

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.m
cfe/trunk/test/Index/Core/index-subkinds.m

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=285120&r1=285119&r2=285120&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Tue Oct 25 16:11:22 2016
@@ -88,8 +88,10 @@ enum class SymbolRole : uint16_t {
   RelationOverrideOf  = 1 << 11,
   RelationReceivedBy  = 1 << 12,
   RelationCalledBy= 1 << 13,
+  RelationExtendedBy  = 1 << 14,
+  RelationAccessorOf  = 1 << 15,
 };
-static const unsigned SymbolRoleBitNum = 14;
+static const unsigned SymbolRoleBitNum = 16;
 typedef unsigned SymbolRoleSet;
 
 /// Represents a relation to another symbol for a symbol occurrence.

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=285120&r1=285119&r2=285120&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Oct 25 16:11:22 2016
@@ -75,8 +75,21 @@ public:
 }
   }
 
-  bool handleObjCMethod(const ObjCMethodDecl *D) {
-if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic))
+  bool handleObjCMethod(const ObjCMethodDecl *D,
+const ObjCPropertyDecl *AssociatedProp = nullptr) {
+SmallVector Relations;
+SmallVector Overriden;
+
+D->getOverriddenMethods(Overriden);
+for(auto overridden: Overriden) {
+  Relations.emplace_back((unsigned) SymbolRole::RelationOverrideOf,
+ overridden);
+}
+if (AssociatedProp)
+  Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
+ AssociatedProp);
+
+if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
   return false;
 IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
 for (const auto *I : D->parameters())
@@ -269,9 +282,18 @@ public:
   }
 
   bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
-if (!IndexCtx.handleDecl(D))
-  return false;
-IndexCtx.indexDeclContext(D);
+const ObjCInterfaceDecl *C = D->getClassInterface();
+if (C)
+  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
+  SymbolRoleSet(), SymbolRelation{
+(unsigned)SymbolRole::RelationExtendedBy, D
+  }));
+SourceLocation CategoryLoc = D->getCategoryNameLoc();
+if (!CategoryLoc.isValid())
+  CategoryLoc = D->getLocation();
+TRY_TO(IndexCtx.handleDecl(D, CategoryLoc));
+TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D));
+TRY_TO(IndexCtx.indexDeclContext(D));
 return true;
   }
 
@@ -279,8 +301,14 @@ public:
 const ObjCCategoryDecl *Cat = D->getCategoryDecl();
 if (!Cat)
   return true;
-
-if (!IndexCtx.handleDecl(D))
+const ObjCInterfaceDecl *C = D->getClassInterface();
+if (C)
+  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
+  SymbolRoleSet()));
+SourceLocation CategoryLoc = D->getCategoryNameLoc();
+if (!CategoryLoc.isValid())
+  CategoryLoc = D->getLocation();
+if (!IndexCtx.handleDecl(D, CategoryLoc))
   return false;
 IndexCtx.indexDeclContext(D);
 return true;
@@ -299,10 +327,10 @@ public:
   bool VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
 if (ObjCMethodDecl *MD = D->getGetterMethodDecl())
   if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
-handleObjCMethod(MD);
+handleObjCMethod(MD, D);
 if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
   if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
-handleObjCMethod(MD);
+handleObjCMethod(MD, D);
 if (!IndexCtx.handleDecl(D))
   return false;
 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=285120&r1=285119&r2=285120&view=diff
==

[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D25954



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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:94
+  else if (isa(RS)) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.

NoQ wrote:
> dcoughlin wrote:
> > It is not clear to me that this FIXME is a good idea. I would remove it so 
> > someone doesn't spend a lot of time trying to address it.
> > 
> > Objective-C objects don't have the strong dis-aliasing guarantee that the 
> > analyzer assumes for heap base regions. In other words, two calls to [[Foo 
> > alloc] init] may yield exactly the same instance.  This is because, unlike 
> > malloc() and C++ global new, ObjC initializers can (and frequently do) 
> > return instances other than the passed-in, freshly-allocated self.
> Hmm, that seems to be exactly the thing i'm looking for: heap-based regions 
> that may alias.
> 
> The property of a region's staying on the heap has little to do with the 
> property of being able to alias.
> 
> I've a feeling that we should have avoided using C++ inheritance in the 
> memregion hierarchy, and instead went for a bunch of constraints. Eg., memory 
> space is essentially a constraint (it may be unknown or get known later 
> through exploring aliasing), region's value type is essentially a constraint 
> (as seen during dynamic type propagation, it may be unknown, it may be 
> partially known, we may get to know it better during the analysis by 
> observing successful dynamic casts), extent is essentially a constraint (that 
> we currently impose on SymbolExtent), offset of a symbolic region inside its 
> true parent region is a constraint, and so on.
> 
> But that's too vague. I've no well-defined idea how to make this better at 
> the moment.
If you feel strongly about this, I would suggest putting the FIXME in the core, 
perhaps in SimpleSValBuilder where the dis-aliasing assumption is introduced or 
perhaps in the declaration of HeapSpaceRegion. This will make it clear to 
future maintainers that it is not a defect in the checker.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:70
 
   // Check if the first argument is stack allocated.  If so, issue a warning
   // because that's likely to be bad news.

I guess this comment needs to be updated.



Comment at: test/Analysis/dispatch-once.m:26
+  // Use regexps to check that we're NOT suggesting to make this static.
+  dispatch_once(once, ^{}); // expected-warning-re^Call to 'dispatch_once' 
uses heap-allocated memory for the predicate value.  Using such transient 
memory for the predicate is potentially dangerous$
+}

Clever.



Comment at: test/Analysis/dispatch-once.m:62
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 's' for the predicate value.}}
+}

Interesting. Have you seen this pattern in the wild?

I think this diagnostic is a little bit confusing since the ivar itself isn't 
being used for the predicate value.

Maybe "... uses a subfield of the instance variable 's' for the predicate 
value"? 






https://reviews.llvm.org/D25909



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


r285125 - [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct 25 16:37:05 2016
New Revision: 285125

URL: http://llvm.org/viewvc/llvm-project?rev=285125&view=rev
Log:
[OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

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

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=285125&r1=285124&r2=285125&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Tue Oct 25 16:37:05 2016
@@ -14616,6 +14616,13 @@ int __ovld atom_xor(volatile __local int
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


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


[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285125: [OpenCL] Add missing atom_xor for 64 bit to 
opencl-c.h (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D25954?vs=75740&id=75797#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25954

Files:
  cfe/trunk/lib/Headers/opencl-c.h


Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285126 - CodeGen: be more conservative about setting section

2016-10-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Oct 25 16:43:28 2016
New Revision: 285126

URL: http://llvm.org/viewvc/llvm-project?rev=285126&view=rev
Log:
CodeGen: be more conservative about setting section

The section names currently are MachO specific.  Only set the section on the
variables if the file format is MachO.

Added:
cfe/trunk/test/CodeGenObjC/section-name.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285126&r1=285125&r2=285126&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Oct 25 16:43:28 2016
@@ -2919,10 +2919,13 @@ CGObjCMac::EmitProtocolList(Twine Name,
   ProtocolRefs.size()),
  ProtocolRefs);
 
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO())
+Section = "__OBJC,__cat_cls_meth,regular,no_dead_strip";
+
   llvm::Constant *Init = llvm::ConstantStruct::getAnon(Values);
   llvm::GlobalVariable *GV =
-CreateMetadataVar(Name, Init, 
"__OBJC,__cat_cls_meth,regular,no_dead_strip",
-  CGM.getPointerAlign(), false);
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), false);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListPtrTy);
 }
 
@@ -3028,12 +3031,13 @@ llvm::Constant *CGObjCCommonMac::EmitPro
   Values[2] = llvm::ConstantArray::get(AT, Properties);
   llvm::Constant *Init = llvm::ConstantStruct::getAnon(Values);
 
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO())
+Section = (ObjCABI == 2) ? "__DATA, __objc_const"
+ : "__OBJC,__property,regular,no_dead_strip";
+
   llvm::GlobalVariable *GV =
-CreateMetadataVar(Name, Init,
-  (ObjCABI == 2) ? "__DATA, __objc_const" :
-  "__OBJC,__property,regular,no_dead_strip",
-  CGM.getPointerAlign(),
-  true);
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), true);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.PropertyListPtrTy);
 }
 
@@ -3049,9 +3053,12 @@ CGObjCCommonMac::EmitProtocolMethodTypes
  MethodTypes.size());
   llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes);
 
-  llvm::GlobalVariable *GV = CreateMetadataVar(
-  Name, Init, (ObjCABI == 2) ? "__DATA, __objc_const" : StringRef(),
-  CGM.getPointerAlign(), true);
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO() && ObjCABI == 2)
+Section = "__DATA, __objc_const";
+
+  llvm::GlobalVariable *GV =
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), true);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.Int8PtrPtrTy);
 }
 
@@ -5959,18 +5966,21 @@ llvm::GlobalVariable * CGObjCNonFragileA
   }
   llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassRonfABITy,
Values);
+
+  llvm::SmallString<64> ROLabel;
+  llvm::raw_svector_ostream(ROLabel)
+  << ((flags & NonFragileABI_Class_Meta) ? "\01l_OBJC_METACLASS_RO_$_"
+ : "\01l_OBJC_CLASS_RO_$_")
+  << ClassName;
+
   llvm::GlobalVariable *CLASS_RO_GV =
-new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassRonfABITy, false,
- llvm::GlobalValue::PrivateLinkage,
- Init,
- (flags & NonFragileABI_Class_Meta) ?
- 
std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName :
- std::string("\01l_OBJC_CLASS_RO_$_")+ClassName);
+  new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassRonfABITy, 
false,
+   llvm::GlobalValue::PrivateLinkage, Init, 
ROLabel);
   CLASS_RO_GV->setAlignment(
 CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassRonfABITy));
-  CLASS_RO_GV->setSection("__DATA, __objc_const");
+  if (CGM.getTriple().isOSBinFormatMachO())
+CLASS_RO_GV->setSection("__DATA, __objc_const");
   return CLASS_RO_GV;
-
 }
 
 /// BuildClassMetaData - This routine defines that to-level meta-data
@@ -6002,9 +6012,10 @@ llvm::GlobalVariable *CGObjCNonFragileAB
Values);
   llvm::GlobalVariable *GV = GetClassGlobal(ClassName, Weak);
   GV->setInitializer(Init);
-  GV->setSection("__DATA, __objc_data");
+  if (CGM.getTriple().isOSBinFormatMachO())
+GV->setSection("__DATA, __objc_data");
   GV->setAlignment(
-CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
   if (!CGM.getTriple().isOSBinFormatCOFF())
 if (HiddenVisibility)
   GV->setVisibility(llvm:

r285127 - Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Oct 25 16:44:35 2016
New Revision: 285127

URL: http://llvm.org/viewvc/llvm-project?rev=285127&view=rev
Log:
Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

Summary:
This is only forced on if there is no non-Cortex-A53 CPU specified as
well. Android's platform and NDK builds need to assume that the code can
be run on Cortex-A53 devices, so we always enable the fix unless we know
specifically that the code is only running on a different kind of CPU.

Reviewers: cfe-commits

Subscribers: aemerson, rengolin, tberghammer, pirama, danalbert

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

Added:
cfe/trunk/test/Driver/android-aarch64-link.cpp
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285127&r1=285126&r2=285127&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 25 16:44:35 2016
@@ -9712,6 +9712,14 @@ void gnutools::Linker::ConstructJob(Comp
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 

Added: cfe/trunk/test/Driver/android-aarch64-link.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-aarch64-link.cpp?rev=285127&view=auto
==
--- cfe/trunk/test/Driver/android-aarch64-link.cpp (added)
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp Tue Oct 25 16:44:35 2016
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419


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


[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285127: Use linker flag --fix-cortex-a53-843419 on Android 
ARM64 compilation. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D25761?vs=75174&id=75801#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25761

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/android-aarch64-link.cpp


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
This was a thinko on my part: clang's builtin headers include_next the
system headers, not the other way around, so the system headers should be
implicitly textual, not clang's headers. This patch fixes the problem for
me with glibc. Does this help for Darwin too?

On Tue, Oct 25, 2016 at 2:01 PM, Richard Smith 
wrote:

> On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
>> wrote:
>> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
>> >  wrote:
>> >>
>> >> > Sure, go ahead.
>> >>
>> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
>> >> I've found: the changes for the builtins affecting non submodule local
>> >> visibility broke current users of plain "-fmodules" against our
>> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
>> >> work around that for the time being: make the new behavior dependent
>> >> on local vis. Can you take a look?
>> >
>> >
>> > What's the nature of the breakage? Generally I'd be fine with your
>> patch,
>> > but I wonder if there's something better we could do here.
>>
>> I haven't entirely isolated the problem, but they are all related to
>> definitions from stdint.h. In one example below, uint32_t doesn't
>> leak, requiring an explicit "#include " to make it work.
>>
>> -- example.m
>> #import 
>> --
>> $ clang -arch x86_64 -isysroot
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk
>> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>>
>> While building module 'IOKit' imported from example.m:1:
>> In file included from :2:
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk/System/Library
>> /Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
>> error: de
>>   'Darwin.POSIX._types._uint32_t' before it is required
>> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
>> uint32_t *dataSize);
>>   ^
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_
>> types/_uint32_t.h:31:22:
>> note: previous declaration is here
>> typedef unsigned int uint32_t;
>>  ^
>> bot.m:1:9: fatal error: could not build module 'IOKit'
>> #import 
>>  ~~~^
>
>
> This change also broke local submodule visibility builds with modular
> glibc (see PR30778 for details). I have an idea for how to fix this;
> running it through bootstrap now.
>
> >> > Hmm. Ideally, we should try to pick something that captures the spirit
>> >> > of
>> >> > "only non-modular headers and headers from used modules". Something
>> like
>> >> > "ignore_modules_not_declared_used", but less wordy?
>> >>
>> >> Right. It's gonna be hard to shrink this to a meaningful short name.
>> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
>> >
>> >
>> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
>> > specified on a use-declaration:
>> >
>> >   use [exhaustive] a, b, c
>>
>> I don't understand, the 'Darwin' module map doesn't use the 'use'
>> keyword in any of its modules, how do you suggest we would use that to
>> express the 'ignore_modules_not_declared_used' idea?
>
>
> Hah, right, this would only work if your module has dependencies. Maybe an
> [exhaustive_uses] attribute on the module itself then?
>
Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp   (revision 285117)
+++ lib/Lex/ModuleMap.cpp   (working copy)
@@ -1881,16 +1881,20 @@
   Module::Header H = {RelativePathName.str(), File};
   Map.excludeHeader(ActiveModule, H);
 } else {
-  // If there is a builtin counterpart to this file, add it now as a 
textual
-  // header, so it can be #include_next'd by the wrapper header, and can
-  // receive macros from the wrapper header.
+  // If there is a builtin counterpart to this file, add it now so it can
+  // wrap the system header.
   if (BuiltinFile) {
 // FIXME: Taking the name from the FileEntry is unstable and can give
 // different results depending on how we've previously named that file
 // in this build.
 Module::Header H = { BuiltinFile->getName(), BuiltinFile };
-Map.addHeader(ActiveModule, H, ModuleMap::ModuleHeaderRole(
-   Role | ModuleMap::TextualHeader));
+Map.addHeader(ActiveModule, H, Role);
+
+// If we have both a builtin and system version of the file, the
+// builtin version may want to inject macros into the system header, so
+// force the system header to be treated as a textual header in this
+// case.
+Role = ModuleMap::ModuleHeaderRole(Role | ModuleMap::

Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
Missed one change from the test suite:

Index: test/Modules/cstd.m
===
--- test/Modules/cstd.m (revision 285117)
+++ test/Modules/cstd.m (working copy)
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include
-ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t
-D__need_wint_t -Werror=implicit-function-declaration %s
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem
%S/Inputs/System/usr/include -fmodules -fimplicit-module-maps
-fmodules-cache-path=%t -D__need_wint_t
-Werror=implicit-function-declaration %s

 @import uses_other_constants;
 const double other_value = DBL_MAX;


On Tue, Oct 25, 2016 at 2:56 PM, Richard Smith 
wrote:

> This was a thinko on my part: clang's builtin headers include_next the
> system headers, not the other way around, so the system headers should be
> implicitly textual, not clang's headers. This patch fixes the problem for
> me with glibc. Does this help for Darwin too?
>
> On Tue, Oct 25, 2016 at 2:01 PM, Richard Smith 
> wrote:
>
>> On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
>>> wrote:
>>> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
>>> >  wrote:
>>> >>
>>> >> > Sure, go ahead.
>>> >>
>>> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
>>> >> I've found: the changes for the builtins affecting non submodule local
>>> >> visibility broke current users of plain "-fmodules" against our
>>> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
>>> >> work around that for the time being: make the new behavior dependent
>>> >> on local vis. Can you take a look?
>>> >
>>> >
>>> > What's the nature of the breakage? Generally I'd be fine with your
>>> patch,
>>> > but I wonder if there's something better we could do here.
>>>
>>> I haven't entirely isolated the problem, but they are all related to
>>> definitions from stdint.h. In one example below, uint32_t doesn't
>>> leak, requiring an explicit "#include " to make it work.
>>>
>>> -- example.m
>>> #import 
>>> --
>>> $ clang -arch x86_64 -isysroot
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk
>>> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>>>
>>> While building module 'IOKit' imported from example.m:1:
>>> In file included from :2:
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/
>>> Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
>>> error: de
>>>   'Darwin.POSIX._types._uint32_t' before it is required
>>> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
>>> uint32_t *dataSize);
>>>   ^
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_types/_
>>> uint32_t.h:31:22:
>>> note: previous declaration is here
>>> typedef unsigned int uint32_t;
>>>  ^
>>> bot.m:1:9: fatal error: could not build module 'IOKit'
>>> #import 
>>>  ~~~^
>>
>>
>> This change also broke local submodule visibility builds with modular
>> glibc (see PR30778 for details). I have an idea for how to fix this;
>> running it through bootstrap now.
>>
>> >> > Hmm. Ideally, we should try to pick something that captures the
>>> spirit
>>> >> > of
>>> >> > "only non-modular headers and headers from used modules". Something
>>> like
>>> >> > "ignore_modules_not_declared_used", but less wordy?
>>> >>
>>> >> Right. It's gonna be hard to shrink this to a meaningful short name.
>>> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
>>> >
>>> >
>>> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
>>> > specified on a use-declaration:
>>> >
>>> >   use [exhaustive] a, b, c
>>>
>>> I don't understand, the 'Darwin' module map doesn't use the 'use'
>>> keyword in any of its modules, how do you suggest we would use that to
>>> express the 'ignore_modules_not_declared_used' idea?
>>
>>
>> Hah, right, this would only work if your module has dependencies. Maybe
>> an [exhaustive_uses] attribute on the module itself then?
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-25 Thread Ettore Speziale via cfe-commits
Hello,

> As far as I understand the whole problem is that the optimized functions are 
> marked by __attribute__((pure)). If the attribute is removed from your 
> example, we get LLVM dump preserving correctness:
> 
> define i32 @bar(i32 %x) local_unnamed_addr #0 {
> entry:
>  %call = tail call i32 @foo() #2
>  %tobool = icmp eq i32 %x, 0
>  %.call = select i1 %tobool, i32 0, i32 %call
>  ret i32 %.call
> }

I’ve used __attribute__((pure)) only to force LLVM applying the transformation 
and show you an example of incorrect behavior.

This is another example:

void foo();
int baz();

int bar(int x) {
  int y;
  if (x) 
y = baz();
  foo();
  if (x) 
y = baz();
  return y;
} 

Which gets lowered into:

define i32 @bar(i32) #0 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %3, label %4

; :3   ; preds = %1
  tail call void (...) @foo() #2
  br label %7

; :4   ; preds = %1
  %5 = tail call i32 (...) @baz() #2
  tail call void (...) @foo() #2
  %6 = tail call i32 (...) @baz() #2
  br label %7

; :7   ; preds = %3, %4
  %8 = phi i32 [ %6, %4 ], [ undef, %3 ]
  ret i32 %8
}

As you can see the call sites of foo in the optimized IR are not 
control-equivalent to the only call site of foo in the unoptimized IR. Now 
imaging foo is implemented in another module and contains a call to a 
convergent function — e.f. barrier(). You are going to generate incorrect code.

Bye

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Akira Hatanaka via cfe-commits
ahatanak added reviewers: bruno, erik.pilkington, majnemer.
ahatanak added a comment.

Add more reviewers.


https://reviews.llvm.org/D25206



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:951
   Init = ParseInitializer();
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 

ahatanak wrote:
> mehdi_amini wrote:
> > What happens when there is no typo correction to apply?
> If there are no typos, it just returns the same Expr. If there are typos but 
> no corrections can be applied, it returns ExprError.
If `ParseInitializer` returned `ExprError()`, this will incorrectly convert it 
into `ExprResult()` (that is, it'll clear the 'invalid' flag). You should skip 
this step if the initializer expression is not valid.


https://reviews.llvm.org/D25206



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:951
   Init = ParseInitializer();
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 

rsmith wrote:
> ahatanak wrote:
> > mehdi_amini wrote:
> > > What happens when there is no typo correction to apply?
> > If there are no typos, it just returns the same Expr. If there are typos 
> > but no corrections can be applied, it returns ExprError.
> If `ParseInitializer` returned `ExprError()`, this will incorrectly convert 
> it into `ExprResult()` (that is, it'll clear the 'invalid' flag). You should 
> skip this step if the initializer expression is not valid.
I suggest having a test that exercise this code path.


https://reviews.llvm.org/D25206



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


[PATCH] D25876: [analyzer] Report CFNumberGetValue API misuse

2016-10-25 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.



Comment at: test/Analysis/CFNumber.c:39
+  unsigned char scalar = 0;
+  CFNumberGetValue(x, kCFNumberSInt16Type, &scalar);  // expected-warning{{A 
CFNumber object that represents a 16-bit integer is used to initialize an 8-bit 
integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
+  return scalar;

NoQ wrote:
> We're not sure from this code if the `CFNumber` object `x` actually 
> represents a 16-bit integer, or somebody just misplaced the 
> `kCFNumberSInt16Type` thing. I think the warning message could be made more 
> precise in this sence, but i'm not good at coming up with warning messages.
> 
> Hmm, there could actually be a separate check for detecting inconsistent type 
> specifiers used for accessing the same CFNumber object.
I see your point. Looks like we'd need to modify both first part of the 
sentence and the second to address this concern. We could do something like "A 
CFNumber object treated as if it represents a 16-bit integer is used to 
initialize an 8-bit integer; 8 bits of the CFNumber value or the adjacent 
storage will overwrite adjacent storage of the integer".

Though this is more correct, I do not think it's worth the new language 
complexity. Also, the warning message is already quite long.


https://reviews.llvm.org/D25876



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


[PATCH] D25850: [WIP] Accept nullability annotations (_Nullable) on array parameters

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose added a comment.

> `_Nonnull` in this position seems very similar to `static` (which typically 
> also implies non-nullness).

I wasn't actually sure if it was okay to assume this, but the standard does 
seem pretty clear:

> If the keyword `static` also appears within the `[` and `]` of the array type 
> derivation, then for each call to the function, the value of the 
> corresponding actual argument shall provide access to the first element of an 
> array with at least as many elements as specified by the size expression. 
> (C11 6.7.6.3p7)

We can pick this up on the Swift side.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


  1   2   >