Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-05 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 70308.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24183

Files:
  CMakeLists.txt
  change-namespace/CMakeLists.txt
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/CMakeLists.txt
  change-namespace/tool/ClangChangeNamespace.cpp
  test/CMakeLists.txt
  test/change-namespace/simple-move.cpp
  unittests/CMakeLists.txt
  unittests/change-namespace/CMakeLists.txt
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- /dev/null
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -0,0 +1,234 @@
+//===-- ChangeNamespaceTests.cpp - Change namespace unit tests ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ChangeNamespace.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace change_namespace {
+namespace {
+
+class ChangeNamespaceTest : public ::testing::Test {
+public:
+  std::string runChangeNamespaceOnCode(llvm::StringRef Code) {
+clang::RewriterTestContext Context;
+clang::FileID ID = Context.createInMemoryFile(FileName, Code);
+
+std::map FileToReplacements;
+change_namespace::ChangeNamespaceTool NamespaceTool(
+OldNamespace, NewNamespace, FilePattern, &FileToReplacements);
+ast_matchers::MatchFinder Finder;
+NamespaceTool.registerMatchers(&Finder);
+std::unique_ptr Factory =
+tooling::newFrontendActionFactory(&Finder);
+tooling::runToolOnCodeWithArgs(Factory->create(), Code, {"-std=c++11"},
+   FileName);
+formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite);
+return format(Context.getRewrittenText(ID));
+  }
+
+  std::string format(llvm::StringRef Code) {
+tooling::Replacements Replaces = format::reformat(
+format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())});
+auto ChangedCode = tooling::applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(ChangedCode));
+if (!ChangedCode) {
+  llvm::errs() << llvm::toString(ChangedCode.takeError());
+  return "";
+}
+return *ChangedCode;
+  }
+
+protected:
+  std::string FileName = "input.cc";
+  std::string OldNamespace = "na::nb";
+  std::string NewNamespace = "x::y";
+  std::string FilePattern = "input.cc";
+};
+
+TEST_F(ChangeNamespaceTest, NoMatchingNamespace) {
+  std::string Code = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveWithoutTypeRefs) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "class A {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "} // names

Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-05 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: change-namespace/ChangeNamespace.cpp:22
@@ +21,3 @@
+  (void)NS.ltrim(':');
+  return NS.str();
+}

Yes, it is added to please  `LLVM_ATTRIBUTE_UNUSED_RESULT` of 
`llvm::StringRef::ltrim`.


Comment at: change-namespace/ChangeNamespace.cpp:30
@@ +29,3 @@
+  std::string Result = Namespaces.front();
+  for (auto I = Namespaces.begin() + 1, E = Namespaces.end(); I != E; ++I) {
+Result += ("::" + *I).str();

omtcyfz wrote:
> Braces around single-line statement inside control flow statement body is 
> occasionally not welcome in LLVM Codebase.
> 
> There are actually both many braces around single-line statement inside cfs 
> body here and many cfs's without braces around single-line body inside a 
> single file, which isn't good in terms of consistency at least inside the 
> project.
You are right! I missed those braces when converting the code from google style 
:P Thanks for the catch!


Comment at: change-namespace/ChangeNamespace.cpp:105
@@ +104,3 @@
+  llvm::StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
+  if (InvalidTemp)
+return SourceLocation();

omtcyfz wrote:
> Shouldn't this throw an error instead?
An empty `SourceLocation` is invalid and often used to indicate error. Added 
error handling at callers.


https://reviews.llvm.org/D24183



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


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-05 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: change-namespace/ChangeNamespace.cpp:480
@@ +479,3 @@
+Replaces = Replaces.merge(NewReplacements);
+format::FormatStyle Style = format::getStyle("file", FilePath, "google");
+// Clean up old namespaces if there is nothing in it after moving.

By the way, shouldn't this one be "LLVM"?


https://reviews.llvm.org/D24183



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


[clang-tools-extra] r280653 - [clang-rename] Add comment after namespace closing

2016-09-05 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep  5 04:42:02 2016
New Revision: 280653

URL: http://llvm.org/viewvc/llvm-project?rev=280653&view=rev
Log:
[clang-rename] Add comment after namespace closing

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.h

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.h?rev=280653&r1=280652&r2=280653&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h Mon Sep  5 04:42:02 
2016
@@ -41,7 +41,8 @@ private:
   std::map &FileToReplaces;
   bool PrintLocations;
 };
-}
-}
+
+} // namespace rename
+} // namespace clang
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_RENAMING_ACTION_H


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


Re: [PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-09-05 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 70318.

https://reviews.llvm.org/D21505

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -241,6 +241,21 @@
   _mm512_mask_store_pd(p, m, a);
 }
 
+void test_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_ss
+  // CHECK:  store float {{.*}}, float* {{.*}}
+  return _mm_mask_store_ss (__W, __U, __A);
+}
+
+void test_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_sd
+  // CHECK:  store double {{.*}}, double* {{.*}}
+  return _mm_mask_store_sd ( __W,  __U,  __A);
+}
+
+
 void test_mm512_mask_storeu_epi32(void *__P, __mmask16 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_storeu_epi32
   // CHECK: @llvm.masked.store.v16i32.p0v16i32(<16 x i32> %{{.*}}, <16 x i32>* %{{.*}}, i32 1, <16 x i1> %{{.*}})
@@ -371,6 +386,38 @@
   return _mm512_maskz_load_pd(__U, __P);
 }
 
+__m128 test_mm_mask_load_ss (__m128 __W, __mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_load_ss ( __W,  __U,  __A);
+}
+
+__m128 test_mm_maskz_load_ss (__mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_load_ss (__U, __A);
+}
+
+__m128d test_mm_mask_load_sd (__m128 __W, __mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}} 
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_load_sd ( __W,  __U,  __A);
+}
+
+__m128d test_mm_maskz_load_sd (__mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_load_sd (__U, __A);
+}
+
 __m512d test_mm512_set1_pd(double d)
 {
   // CHECK-LABEL: @test_mm512_set1_pd
@@ -6199,6 +6246,38 @@
   return _mm512_maskz_mov_ps(__U, __A); 
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+ return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 void test_mm512_mask_compressstoreu_pd(void *__P, __mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_mask_compressstoreu_pd
   // CHECK: @llvm.x86.avx512.mask.compress.store.pd.512
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -4558,6 +4558,30 @@
   return *(__m512i *) __P;
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_load_ss (__m128 __W, __mmask8 __U, const float* __A)
+{
+  return (__U & 1) ?  _mm_load_ss(__A) :  (__m128) { __W[0], 0, 0, 0}; 
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_load_ss (__mmask8 __U, const float* __A)
+{
+  return (__U & 1) ?  _mm_load_ss(__A) :  (__m128) { 0, 0, 0, 0}; 
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_load_sd (__m128d __W, __mmask8 __U, const double* __A)
+{
+  return (__U & 1) ?  _mm_load_sd(__A) :(__m128d) { __W[0], 0};
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_load_sd (__mmask8 __U, const double* __A)
+{
+  return (__U & 1) ?  _mm_load_sd(__A) :(__m128d) { 0, 0};
+}
+
 /* SIMD store ops */
 
 static __inline void __DEFAULT_FN_ATTRS
@@ -4649,6 +4673,20 @@
   *(__m512i *) __P = __A;
 }
 
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __

Re: [PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-09-05 Thread michael zuckerman via cfe-commits
m_zuckerman marked an inline comment as done.
m_zuckerman added a comment.

https://reviews.llvm.org/D21505



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


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-05 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: change-namespace/ChangeNamespace.cpp:480
@@ +479,3 @@
+Replaces = Replaces.merge(NewReplacements);
+format::FormatStyle Style = format::getStyle("file", FilePath, "google");
+// Clean up old namespaces if there is nothing in it after moving.

omtcyfz wrote:
> By the way, shouldn't this one be "LLVM"?
Alternatively, it might be nice to provide an option to specify desired 
formatting style.


https://reviews.llvm.org/D24183



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


r280658 - Attempt to fix buildbots not targetting x86

2016-09-05 Thread James Molloy via cfe-commits
Author: jamesm
Date: Mon Sep  5 07:28:49 2016
New Revision: 280658

URL: http://llvm.org/viewvc/llvm-project?rev=280658&view=rev
Log:
Attempt to fix buildbots not targetting x86

r280613 introduced failures for all builds that don't target x86 by default. 
Add an explicit target to avoid a missing feature diagnostic.

Modified:
cfe/trunk/test/Modules/compiler_builtins_x86.c

Modified: cfe/trunk/test/Modules/compiler_builtins_x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/compiler_builtins_x86.c?rev=280658&r1=280657&r2=280658&view=diff
==
--- cfe/trunk/test/Modules/compiler_builtins_x86.c (original)
+++ cfe/trunk/test/Modules/compiler_builtins_x86.c Mon Sep  5 07:28:49 2016
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple x86 -fsyntax-only -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s -verify -ffreestanding
 // expected-no-diagnostics
 
 #include


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


Re: r280613 - [Modules] Add 'freestanding' to the 'requires-declaration' feature-list.

2016-09-05 Thread James Molloy via cfe-commits
Hi Elad,

This commit broke all buildbots that don't default to targetting x86. I've
committed a fix with r280658, but could you please double check it's
correct.

Cheers,

James

On Sun, 4 Sep 2016 at 07:09 Elad Cohen via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: eladcohen
> Date: Sun Sep  4 01:00:42 2016
> New Revision: 280613
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280613&view=rev
> Log:
> [Modules] Add 'freestanding' to the 'requires-declaration' feature-list.
>
> This adds support for modules that require (non-)freestanding
> environment, such as the compiler builtin mm_malloc submodule.
>
> Differential Revision: https://reviews.llvm.org/D23871
>
>
> Added:
> cfe/trunk/test/Modules/compiler_builtins_x86.c
> Modified:
> cfe/trunk/docs/Modules.rst
> cfe/trunk/lib/Basic/Module.cpp
> cfe/trunk/lib/Headers/module.modulemap
>
> Modified: cfe/trunk/docs/Modules.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=280613&r1=280612&r2=280613&view=diff
>
> ==
> --- cfe/trunk/docs/Modules.rst (original)
> +++ cfe/trunk/docs/Modules.rst Sun Sep  4 01:00:42 2016
> @@ -413,6 +413,9 @@ cplusplus
>  cplusplus11
>C++11 support is available.
>
> +freestanding
> +  A freestanding environment is available.
> +
>  gnuinlineasm
>GNU inline ASM is available.
>
>
> Modified: cfe/trunk/lib/Basic/Module.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=280613&r1=280612&r2=280613&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/Module.cpp (original)
> +++ cfe/trunk/lib/Basic/Module.cpp Sun Sep  4 01:00:42 2016
> @@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature
>  .Case("blocks", LangOpts.Blocks)
>  .Case("cplusplus", LangOpts.CPlusPlus)
>  .Case("cplusplus11", LangOpts.CPlusPlus11)
> +.Case("freestanding", LangOpts.Freestanding)
>  .Case("gnuinlineasm", LangOpts.GNUAsm)
>  .Case("objc", LangOpts.ObjC1)
>  .Case("objc_arc", LangOpts.ObjCAutoRefCount)
>
> Modified: cfe/trunk/lib/Headers/module.modulemap
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=280613&r1=280612&r2=280613&view=diff
>
> ==
> --- cfe/trunk/lib/Headers/module.modulemap (original)
> +++ cfe/trunk/lib/Headers/module.modulemap Sun Sep  4 01:00:42 2016
> @@ -63,6 +63,7 @@ module _Builtin_intrinsics [system] [ext
>  textual header "mwaitxintrin.h"
>
>  explicit module mm_malloc {
> +  requires !freestanding
>header "mm_malloc.h"
>export * // note: for  dependency
>  }
>
> Added: cfe/trunk/test/Modules/compiler_builtins_x86.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/compiler_builtins_x86.c?rev=280613&view=auto
>
> ==
> --- cfe/trunk/test/Modules/compiler_builtins_x86.c (added)
> +++ cfe/trunk/test/Modules/compiler_builtins_x86.c Sun Sep  4 01:00:42 2016
> @@ -0,0 +1,6 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps
> -fmodules-cache-path=%t %s -verify -ffreestanding
> +// expected-no-diagnostics
> +
> +#include
> +
>
>
> ___
> 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


Re: [PATCH] D23831: [libcxx] Fix gcc 4.9 -Wcast-qual warning.

2016-09-05 Thread Andrey Khalyavin via cfe-commits
halyavin added a comment.

False alarm. I figured out that only -Wattributes warnings ignore gcc 
system_header pragma. So this -Wcast-qual and other warnings doesn't block us.


https://reviews.llvm.org/D23831



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


r280659 - clang/test/Modules/compiler_builtins_x86.c: Fix r280658.

2016-09-05 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Sep  5 08:14:54 2016
New Revision: 280659

URL: http://llvm.org/viewvc/llvm-project?rev=280659&view=rev
Log:
clang/test/Modules/compiler_builtins_x86.c: Fix r280658.

Modified:
cfe/trunk/test/Modules/compiler_builtins_x86.c

Modified: cfe/trunk/test/Modules/compiler_builtins_x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/compiler_builtins_x86.c?rev=280659&r1=280658&r2=280659&view=diff
==
--- cfe/trunk/test/Modules/compiler_builtins_x86.c (original)
+++ cfe/trunk/test/Modules/compiler_builtins_x86.c Mon Sep  5 08:14:54 2016
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86 -fsyntax-only -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // expected-no-diagnostics
 
 #include


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


Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values

2016-09-05 Thread Vladimir Yakovlev via cfe-commits
I'll fix this.


Vladimir


---

From: *Akira Hatanaka* 
Date: Fri, Sep 2, 2016 at 3:00 AM
Subject: Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of
vector values
To: vladimi...@gmail.com, ulrich.weig...@de.ibm.com, amjad.ab...@intel.com,
guy.ben...@intel.com, aaron.ball...@gmail.com
Cc: ahata...@gmail.com, andreybokha...@gmail.com, anastasia.stul...@arm.com,
dmitry.poluk...@gmail.com, cfe-commits@lists.llvm.org


ahatanak added a subscriber: ahatanak.
ahatanak added a comment.

This patch causes clang to error out on the following code, which used to
compile fine:

$ cat f2.c

  typedef __attribute__((__ext_vector_type__(8))) unsigned short
vector_ushort8;

  vector_ushort8 foo1(void) {
return 1 << (vector_ushort8){7,6,5,4,3,2,1,0};
  }

$ clang f2.c -c

clang used to transform the scaler operand to a vector operand (similar to
the way gcc's vector is handled) when compiling for normal c/c++ (but
printed an error message when compiling for opencl), but this patch dropped
the check for LangOpts added in r230464 and changed that behavior. I don't
think this was intentional?


Repository:
  rL LLVM

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


Re: [PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-09-05 Thread Elena Demikhovsky via cfe-commits
delena added inline comments.


Comment at: lib/Headers/avx512fintrin.h:9337
@@ +9336,3 @@
+{
+  return (__m128) _mm_move_ss( __A, __builtin_ia32_selectps_128 ((__mmask8) 
__U,
+ (__v4sf) __B,

selectps should not be used here. It complicates IR.
You can write the following:
res = __A;
res[0] = (__U&1)? __B[0]:__W[0];


Comment at: test/CodeGen/avx512f-builtins.c:393
@@ +392,3 @@
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_load_ss ( __W,  __U,  __A);

you should not see any "load" here.


https://reviews.llvm.org/D21505



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


Re: [PATCH] D23503: [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.

2016-09-05 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

Ping!


https://reviews.llvm.org/D23503



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


Re: [PATCH] D22507: Clang-tidy - Enum misuse check

2016-09-05 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 70324.
szepet marked 4 inline comments as done.
szepet added a comment.

cast to dyn-cast change in order to fix a bug, changes based on comments


https://reviews.llvm.org/D22507

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/EnumMisuseCheck.cpp
  clang-tidy/misc/EnumMisuseCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-enum-misuse.rst
  test/clang-tidy/misc-enum-misuse-strict.cpp
  test/clang-tidy/misc-enum-misuse.cpp

Index: test/clang-tidy/misc-enum-misuse.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-enum-misuse.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s misc-enum-misuse %t -- -config="{CheckOptions: [{key: misc-enum-misuse.StrictMode, value: 0}]}" --
+
+enum Empty {
+};
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4
+};
+
+enum {
+  P = 2,
+  Q = 3,
+  R = 4,
+  S = 8,
+  T = 16
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types [misc-enum-misuse]
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+  unsigned p;
+  p = Q | P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: left hand side value is not power-of-2 unlike most other values in the enum type
+}
+
+int dont_trigger() {
+  if (A + G == E)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = T | Q;
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: test/clang-tidy/misc-enum-misuse-strict.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-enum-misuse-strict.cpp
@@ -0,0 +1,92 @@
+// RUN: %check_clang_tidy %s misc-enum-misuse %t -- -config="{CheckOptions: [{key: misc-enum-misuse.StrictMode, value: 1}]}" --
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4
+};
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: enum type seems like a bitmask but possibly contains misspelled number(s) [misc-enum-misuse]
+enum PP {
+  P = 2,
+  Q = 3,
+  R = 4,
+  S = 8,
+  T = 16,
+  U = 31
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+  if (P + Q == R)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: right hand side value is not power-of-2 unlike most other values in the enum type
+  else if ((Q | R) == T)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:13: warning: left hand side value is not power-of-2 unlike most other values in the enum type
+  else
+int k = T | Q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: right hand side value is not power-of-2 unlike most other values in the enum type
+  unsigned p = R;
+  PP pp = Q;
+  p |= pp;
+  // Line 65 triggers the LINE:17 warning
+  p = A | G;
+  return 0;
+}
+
+int dont_trigger() {
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+
+  unsigned bitflag;
+  enum A aa = B;
+  bitflag = aa | C;
+
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: docs/clang-tidy/checks/misc-enum-misuse.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-enum-misuse.rst
@@ -0,0 +1,67 @@
+.. title:: clang-tidy - misc-enum-misuse
+
+misc-enum-misuse
+
+
+The checker detects various cases when an enum is probably misused (as a bitmask).
+  
+1. When "ADD" or "bitwise OR" is used between two enum which come from different
+ types and these types value ranges are not disjoint.
+
+In the following cases you can choose either "Strict" or "Weak" option.
+In "Strict" mode we check if the used EnumConstantDecl type contains almost
+only pow-of-2 numbers. 
+We regard the enum as a bitmask if the two cond

[PATCH] D24235: [OpenCL] Improve double literal handling

2016-09-05 Thread Neil Hickey via cfe-commits
neil.hickey created this revision.
neil.hickey added a reviewer: Anastasia.
neil.hickey added a subscriber: cfe-commits.

Improve handling of floating point literals to only use double precision if it 
is supported.

https://reviews.llvm.org/D24235

Files:
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify 
-pedantic -fsyntax-only -DNOFP64
 
+#if __OPENCL_C_VERSION__ < 120
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 
extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires 
cl_khr_fp64}}
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
@@ -21,16 +24,22 @@
 #endif
 
   (void) 1.0;
+#ifdef FP64
+// expected-no-diagnostics
+#endif
+
 #ifdef NOFP64
-// expected-warning@-2{{double precision constant requires cl_khr_fp64, 
casting to single precision}}
+// expected-warning@-6{{double precision constant requires cl_khr_fp64, 
casting to single precision}}
 #endif
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
 #ifdef NOFP64
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#if __OPENCL_C_VERSION__ < 120
 void f3(void) {
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
 }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1413,7 +1413,8 @@
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
+!((S.getLangOpts().OpenCLVersion >= 120 
+   && S.Context.getTargetInfo().getSupportedOpenCLOpts().cl_khr_fp64) 
||
   S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -3406,8 +3406,14 @@
   if (getLangOpts().SinglePrecisionConstants) {
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   } else if (getLangOpts().OpenCL &&
- !((getLangOpts().OpenCLVersion >= 120) ||
+ !((getLangOpts().OpenCLVersion >= 120 &&
+Context.getTargetInfo()
+.getSupportedOpenCLOpts()
+.cl_khr_fp64) ||
getOpenCLOptions().cl_khr_fp64)) {
+// Impose single-precision float type when:
+//  - in CL 1.2 or above and cl_khr_fp64 is not supported, or
+//  - in CL 1.1 or below and cl_khr_fp64 is not enabled.
 Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   }


Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
 
+#if __OPENCL_C_VERSION__ < 120
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
@@ -21,16 +24,22 @@
 #endif
 
   (void) 1.0;
+#ifdef FP64
+// expected-no-diagnostics
+#endif
+
 #ifdef NOFP64
-// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
+// expected-warning@-6{{double precision constant requires cl_khr_fp64, casting to single precision}}
 #endif
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
 #ifdef NOFP64
 // expected-warning@-2{{unsupported Ope

Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.

2016-09-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:97
@@ +96,3 @@
+  return llvm::ConstantInt::get(Int32Ty,
+TypeSizeInBits / 8, // Size in bytes.
+false);

Perhaps it's safer to use getTypeSizeInChars instead? Even though most of 
architectures should have an 8-bit byte, it will allow us to avoid having 
hard-coded numbers.


https://reviews.llvm.org/D23992



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


Re: [PATCH] D24235: [OpenCL] Improve double literal handling

2016-09-05 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Could we add a CodeGen test as well to check that the constants generated are 
in the right precision format?


https://reviews.llvm.org/D24235



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


Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.

2016-09-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/CodeGenOpenCL/pipe_builtin.cl:64
@@ +63,3 @@
+void test8(read_only pipe int r, write_only pipe int w, global int *ptr) {
+  // verify that return type is correctly casted to i1 value
+  // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2

Could you please add similar test for the other two functions: 
get_pipe_*_packets?


https://reviews.llvm.org/D24136



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


Re: [PATCH] D23915: [OpenCL] Remove access qualifiers on images in arg info metadata.

2016-09-05 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


https://reviews.llvm.org/D23915



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


Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

2016-09-05 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Sure, I have no problems merging rename-all and rename-at, I added it as it 
looked like a good idea at that time.


https://reviews.llvm.org/D24224



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


Re: [PATCH] D22130: Link static PIE programs against rcrt0.o on OpenBSD

2016-09-05 Thread Stefan Kempf via cfe-commits
sisnkemp added a comment.

Ping?


https://reviews.llvm.org/D22130



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


[libunwind] r280669 - Add missing _US_ACTION_MASK constant to unwind.h

2016-09-05 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Mon Sep  5 13:01:13 2016
New Revision: 280669

URL: http://llvm.org/viewvc/llvm-project?rev=280669&view=rev
Log:
Add missing _US_ACTION_MASK constant to unwind.h

Summary:
During building of recent compiler-rt sources on FreeBSD for arm, I
noticed that our unwind.h (which originates in libunwind) was missing
the `_US_ACTION_MASK` constant:

compiler-rt/lib/builtins/gcc_personality_v0.c:187:18: error: use of 
undeclared identifier '_US_ACTION_MASK'
if ((state & _US_ACTION_MASK) != _US_UNWIND_FRAME_STARTING)
 ^

It appears that both clang's internal unwind.h, and libgcc's unwind.h
define this constant as 3, so let's add this to libunwind's version too.

Reviewers: logan, kledzik, davide, emaste

Subscribers: joerg, davide, aemerson, emaste, llvm-commits

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

Modified:
libunwind/trunk/include/unwind.h

Modified: libunwind/trunk/include/unwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/unwind.h?rev=280669&r1=280668&r2=280669&view=diff
==
--- libunwind/trunk/include/unwind.h (original)
+++ libunwind/trunk/include/unwind.h Mon Sep  5 13:01:13 2016
@@ -57,6 +57,7 @@ typedef uint32_t _Unwind_State;
 static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME   = 0;
 static const _Unwind_State _US_UNWIND_FRAME_STARTING  = 1;
 static const _Unwind_State _US_UNWIND_FRAME_RESUME= 2;
+static const _Unwind_State _US_ACTION_MASK= 3;
 /* Undocumented flag for force unwinding. */
 static const _Unwind_State _US_FORCE_UNWIND   = 8;
 


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


Re: [PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-09-05 Thread Anastasia Stulova via cfe-commits
Anastasia requested changes to this revision.
Anastasia added a comment.
This revision now requires changes to proceed.

Have you done any investigation regarding the compilation speed as this change 
adds expensive container lookups for all OpenCL declarations and function calls.

It would be nice to see some profiling information first before we go ahead 
with this solution...



Comment at: include/clang/Basic/DiagnosticParseKinds.td:957
@@ +956,3 @@
+  "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - 
ignoring">, InGroup;
+def warn_pragma_begin_end_mismatch : Warning<
+  "OpenCL extension end directive mismatches begin directive - ignoring">, 
InGroup;

Could you please add a test for this diagnostic too?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7998
@@ -7995,1 +7997,3 @@
   InGroup;
+ def err_decl_requires_extension : Error<
+  "use of declaration requires %0 extension to be enabled">;

Could we unify with err_type_requires_extension?


Comment at: include/clang/Basic/OpenCLImageTypes.def:20
@@ -17,4 +19,3 @@
 
-#define IMAGE_READ_TYPE(Type, Id) GENERIC_IMAGE_TYPE(Type, Id)
-#define IMAGE_WRITE_TYPE(Type, Id) 
-#define IMAGE_READ_WRITE_TYPE(Type, Id) 
+#define IMAGE_READ_TYPE(Type, Id, ...) GENERIC_IMAGE_TYPE(Type, Id)
+#define IMAGE_WRITE_TYPE(Type, Id, ...)

Any reason to use variadic macros here? Do we expect variable number of 
arguments?


Comment at: include/clang/Basic/OpenCLOptions.h:18
@@ -17,1 +17,3 @@
 
+#include 
+#include 

Are those two headers actually used here?


Comment at: include/clang/Sema/Sema.h:8006
@@ +8005,3 @@
+  /// \brief Check if declaration \p D used by expression \p E
+  /// is disabled due to required OpenCL extensions are disabled. If so,
+  /// emit diagnostics.

are disabled -> being disabled


Comment at: lib/Headers/opencl-c.h:15484
@@ +15483,3 @@
+#ifdef cl_khr_gl_msaa_sharing
+#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
+#endif //cl_khr_gl_msaa_sharing

Does this change belong here?


Comment at: lib/Parse/ParsePragma.cpp:461
@@ -459,1 +460,3 @@
+  };
+  typedef std::pair OpenCLExtData;
 }

Could we use PointerIntPair still but with 2 bits?


Comment at: lib/Sema/Sema.cpp:1558
@@ +1557,3 @@
+  if (Exts.empty())
+return;
+  auto CanT = T.getCanonicalType().getTypePtr();

Would this not be an error?


Comment at: lib/Sema/SemaDecl.cpp:4797
@@ +4796,3 @@
+  if (getLangOpts().OpenCL)
+setCurrentOpenCLExtensionForDecl(Dcl);
+

I am a  bit concerned about the compilation speed since we will be performing 
expensive container lookups for each declaration here.

Have you done any profiling in this direction?


Comment at: lib/Serialization/ASTReader.cpp:6937
@@ -6936,3 +6942,1 @@
 
-  // FIXME: What happens if these are changed by a module import?
-  if (!OpenCLExtensions.empty()) {

Is the comment no longer relevant?


https://reviews.llvm.org/D21698



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


Re: [PATCH] D19586: Misleading Indentation check

2016-09-05 Thread Pauer Gergely via cfe-commits
Pajesz marked 12 inline comments as done.
Pajesz added a comment.

so i have to submit K good to know



Comment at: test/clang-tidy/readability-misleading-indentation.cpp:48
@@ +47,3 @@
+   }
+  foo2();  // ok
+

nlewycky wrote:
> This is arguably misleading indentation, but I'm ok with not warning on it if 
> you think it will cause too many false positives.
Since brackets are used I don't think we should warn about it. It would indeed 
cause man false positives.


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:63
@@ +62,3 @@
+foo2();
+  }
+

alexfh wrote:
> alexfh wrote:
> > What about this comment?
> What about this comment?
The checker doesn't work for macro's I don't know why and how to fix it so I 
just ignored it.


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:16
@@ +15,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: wrong indentation, 
'else' belongs to 'if(cond2)' statement
+  // CHECK-FIXES: {{^}}  // comment1
+

alexfh wrote:
> Did you run the tests after changes? I don't think the `// comment1` line can 
> actually appear in the fixed code, when it's not there before the fix.
Could you please explain what check-fixes does and how? Im not sure about it.


https://reviews.llvm.org/D19586



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


r280672 - Add support for targeting armv6-unknown-cloudabi-eabihf.

2016-09-05 Thread Ed Schouten via cfe-commits
Author: ed
Date: Mon Sep  5 13:38:34 2016
New Revision: 280672

URL: http://llvm.org/viewvc/llvm-project?rev=280672&view=rev
Log:
Add support for targeting armv6-unknown-cloudabi-eabihf.

I'm in the progress of adding ARMv6 support to CloudABI. On the compiler
side, everything seems to work properly with this tiny change applied.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=280672&r1=280671&r2=280672&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Sep  5 13:38:34 2016
@@ -8261,6 +8261,8 @@ static TargetInfo *AllocateTarget(const
   return new DarwinARMTargetInfo(Triple, Opts);
 
 switch (os) {
+case llvm::Triple::CloudABI:
+  return new CloudABITargetInfo(Triple, Opts);
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=280672&r1=280671&r2=280672&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Sep  5 13:38:34 2016
@@ -1975,6 +1975,11 @@
 // ARMEABIHARDFP:#define __arm 1
 // ARMEABIHARDFP:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=armv6-unknown-cloudabi-eabihf 
< /dev/null | FileCheck -match-full-lines -check-prefix ARMV6-CLOUDABI %s
+//
+// ARMV6-CLOUDABI:#define __CloudABI__ 1
+// ARMV6-CLOUDABI:#define __arm__ 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-netbsd-eabi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NETBSD %s
 //
 // ARM-NETBSD-NOT:#define _LP64


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


Re: [PATCH] D23926: [libcxx] Don't use C99 math ops in -std=c++03 mode

2016-09-05 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D23926#531226, @rmaprath wrote:

> Simplified the patch a little bit more.
>
> Now, library vendors should be able to define 
> `_LIBCPP_STRICT_C99_COMPATIBILITY` and `libc++` will not use/test C99 math 
> functions in `C++03/98` modes. Currently it's only the math functions, we can 
> extend this approach to other affected areas if the approach is OK. Not 100% 
> sure about the namings, can change them as needed.
>
> @EricWF: Gentle ping.


Currently we rely on C++11, C99, BSD, XOPEN, and GNU extensions in all dialects 
in the headers. We have to do so to safely and correctly implement locales and 
IO. In order to support this clang++ and g++ explicitly enable the C99 standard 
library by defining `-D_GNU_SOURCE` in the driver (Heres a 10yo libstdc++ bug 
about it ).

"strict C95 compatibly" is not a feature for our C++ users. If your C library 
support C99 you should enable it, not make libc++ conforming. If we have to 
disable a couple of `` functions to make that work that's OK. However I 
view that as a defect not a feature.



Comment at: test/std/depr/depr.c.headers/math_h.pass.cpp:753
@@ -752,1 +752,3 @@
 
+#if _LIBCPP_USE_C99
+

Tests should be as portable as across standard libraries and not enabled by 
libc++ specific macros.
Disabling tests is OK though. ex `#ifndef _LIBCPP_HAS_NO_C99_MATH`.


https://reviews.llvm.org/D23926



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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-05 Thread Zoltán Dániel Török via cfe-commits
zdtorok removed rL LLVM as the repository for this revision.
zdtorok updated this revision to Diff 70345.
zdtorok marked an inline comment as done.
zdtorok added a comment.

Fixed based on the provided comments and feedbacks.

- added new inter-procedural tests
- minor styling fix (trailing whitespaces)
- fixed tests (missing verify option)
- fixed post, preCall checks


https://reviews.llvm.org/D21506

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  test/Analysis/block-in-critical-section.cpp

Index: test/Analysis/block-in-critical-section.cpp
===
--- /dev/null
+++ test/Analysis/block-in-critical-section.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.BlockInCriticalSection -std=c++11 -verify %s
+
+void sleep(int x) {}
+
+namespace std {
+struct mutex {
+  void lock() {}
+  void unlock() {}
+};
+}
+
+void testBlockInCriticalSection() {
+  std::mutex m;
+  m.lock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  m.unlock();
+}
+
+void testBlockInCriticalSectionWithNestedMutexes() {
+  std::mutex m, n, k;
+  m.lock();
+  n.lock();
+  k.lock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  k.unlock();
+  sleep(5); // expected-warning {{A blocking function %s is called inside a critical section}}
+  n.unlock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  m.unlock();
+  sleep(3); // no-warning
+}
+
+void f() {
+  sleep(1000); // expected-warning {{A blocking function %s is called inside a critical section}}
+}
+
+void testBlockInCriticalSectionInterProcedural() {
+  std::mutex m;
+  m.lock();
+  f();
+  m.unlock();
+}
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -9,6 +9,7 @@
   ArrayBoundChecker.cpp
   ArrayBoundCheckerV2.cpp
   BasicObjCFoundationChecks.cpp
+  BlockInCriticalSectionChecker.cpp
   BoolAssignmentChecker.cpp
   BuiltinFunctionChecker.cpp
   CStringChecker.cpp
Index: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -0,0 +1,109 @@
+//===-- BlockInCriticalSectionChecker.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a checker for blocks in critical sections. This checker should find
+// the calls to blocking functions (for example: sleep, getc, fgets, read,
+// recv etc.) inside a critical section. When sleep(x) is called while a mutex
+// is held, other threades cannot lock the same mutex. This might take some
+// time, leading to bad performance or even deadlock.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class BlockInCriticalSectionChecker : public Checker {
+
+  CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn;
+
+  std::unique_ptr BlockInCritSectionBugType;
+
+  void reportBlockInCritSection(SymbolRef FileDescSym,
+const CallEvent &call,
+CheckerContext &C) const;
+
+public:
+  BlockInCriticalSectionChecker();
+
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+
+  /// Process unlock.
+  /// Process lock.
+  /// Process blocking functions (sleep, getc, fgets, read, recv)
+  void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
+
+};
+
+} // end anonymous namespace
+
+REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCounter, unsigned)
+
+BlockInCriticalSectionChecker::BlockInCriticalSectionChecker()
+: LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"),
+  FgetsFn("fgets"), ReadFn("read"), RecvFn("recv") {
+  // Initialize the bug type.
+  BlockInCritSectionBugType.reset(
+  new BugType(this, "Call to blocking function in critical section",
+"Blocking Error"));
+}
+
+void BlockInCriticalSectionChecker::checkPreCall(const CallEvent &Call,
+ 

Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-05 Thread Zoltán Dániel Török via cfe-commits
zdtorok marked 8 inline comments as done.
zdtorok added a comment.

Thank you for both of your comments and feedbacks! Also please forgive me for 
my (really) late response. Please have a look at my fixes and the new attached 
diff. Thanks!



Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:85
@@ +84,3 @@
+
+void BlockInCriticalSectionChecker::checkPreCall(const CallEvent &Call,
+ CheckerContext &C) const {

zaks.anna wrote:
> Why is handling of unlock in preCall?
For some reason first I thought it's better for performance reasons - but now 
I've changed it to postCall.


Repository:
  rL LLVM

https://reviews.llvm.org/D21506



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


Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.

2016-09-05 Thread Renato Golin via cfe-commits
On 3 September 2016 at 20:19, Craig Topper via cfe-commits
 wrote:
> Author: ctopper
> Date: Sat Sep  3 14:19:49 2016
> New Revision: 280597
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280597&view=rev
> Log:
> [AVX-512] Remove masked integer mullo builtins and replace with native IR.
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/Headers/avx512bwintrin.h
> cfe/trunk/lib/Headers/avx512dqintrin.h
> cfe/trunk/lib/Headers/avx512fintrin.h
> cfe/trunk/lib/Headers/avx512vlbwintrin.h
> cfe/trunk/lib/Headers/avx512vldqintrin.h
> cfe/trunk/lib/Headers/avx512vlintrin.h
> cfe/trunk/test/CodeGen/avx512bw-builtins.c
> cfe/trunk/test/CodeGen/avx512dq-builtins.c
> cfe/trunk/test/CodeGen/avx512f-builtins.c
> cfe/trunk/test/CodeGen/avx512vl-builtins.c
> cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
> cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Hi Craig,

This caused a regression on our buildbot:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/14466

Unfortunately, our bots didn't detect because of a change in the
builder which made all bots not report any errors.

If you can't fix it quickly, please revert and we'll investigate that
later, as right now, we're dealing with a large number of concurrent
failures and we won't have time to investigate further.

Sorry.

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


Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.

2016-09-05 Thread Craig Topper via cfe-commits
This failure doesn't make sense. It's acting like the test was updated for
r280596, but not the intrinsic header or the clang binary. That's the only
way I can think that the output IR could contain
@llvm.x86.avx512.mask.padd.b.256.

/home/linaro/buildbot/clang-cmake-armv7-a15-full/llvm/tools/clang/test/CodeGen/avx512vlbw-builtins.c:740:11:
error: expected string not found in input
 //CHECK: add <32 x i8> %{{.*}}, %{{.*}}
  ^
:2847:43: note: scanning from here
define <4 x i64> @test_mm256_mask_add_epi8(<4 x i64> %__W, i32 %__U,
<4 x i64> %__A, <4 x i64> %__B) #0 {
  ^
:2876:80: note: possible intended match here
 %11 = call <32 x i8> @llvm.x86.avx512.mask.padd.b.256(<32 x i8> %5,
<32 x i8> %7, <32 x i8> %9, i32 %10) #4
   ^
/home/linaro/buildbot/clang-cmake-armv7-a15-full/llvm/tools/clang/test/CodeGen/avx512vlbw-builtins.c:747:11:
error: expected string not found in input
 //CHECK: add <32 x i8> %{{.*}}, %{{.*}}


~Craig

On Mon, Sep 5, 2016 at 3:53 PM, Renato Golin 
wrote:

> On 3 September 2016 at 20:19, Craig Topper via cfe-commits
>  wrote:
> > Author: ctopper
> > Date: Sat Sep  3 14:19:49 2016
> > New Revision: 280597
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=280597&view=rev
> > Log:
> > [AVX-512] Remove masked integer mullo builtins and replace with native
> IR.
> >
> > Modified:
> > cfe/trunk/include/clang/Basic/BuiltinsX86.def
> > cfe/trunk/lib/Headers/avx512bwintrin.h
> > cfe/trunk/lib/Headers/avx512dqintrin.h
> > cfe/trunk/lib/Headers/avx512fintrin.h
> > cfe/trunk/lib/Headers/avx512vlbwintrin.h
> > cfe/trunk/lib/Headers/avx512vldqintrin.h
> > cfe/trunk/lib/Headers/avx512vlintrin.h
> > cfe/trunk/test/CodeGen/avx512bw-builtins.c
> > cfe/trunk/test/CodeGen/avx512dq-builtins.c
> > cfe/trunk/test/CodeGen/avx512f-builtins.c
> > cfe/trunk/test/CodeGen/avx512vl-builtins.c
> > cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
> > cfe/trunk/test/CodeGen/avx512vldq-builtins.c
>
> Hi Craig,
>
> This caused a regression on our buildbot:
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/14466
>
> Unfortunately, our bots didn't detect because of a change in the
> builder which made all bots not report any errors.
>
> If you can't fix it quickly, please revert and we'll investigate that
> later, as right now, we're dealing with a large number of concurrent
> failures and we won't have time to investigate further.
>
> Sorry.
>
> --reanto
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23503: [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.

2016-09-05 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23503



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


Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.

2016-09-05 Thread Renato Golin via cfe-commits
On 6 September 2016 at 00:27, Craig Topper  wrote:
> This failure doesn't make sense. It's acting like the test was updated for
> r280596, but not the intrinsic header or the clang binary. That's the only
> way I can think that the output IR could contain
> @llvm.x86.avx512.mask.padd.b.256.

Hi Craig,

I don't know, but this is a fresh build with sources (hopefully) in sync:

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/15232

and still shows a lot of avx builtin problems...

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


Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.

2016-09-05 Thread Craig Topper via cfe-commits
This error makes even less sense. Nothing about __builtin_ia32_selectd_512
requires a constant integer.

/home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/bin/../lib/clang/4.0.0/include/avx512fintrin.h:223:19:
error: argument to '__builtin_ia32_selectd_512' must be a constant
integer
  return (__m512i)__builtin_ia32_selectd_512(__M,


~Craig

On Mon, Sep 5, 2016 at 4:49 PM, Renato Golin 
wrote:

> On 6 September 2016 at 00:27, Craig Topper  wrote:
> > This failure doesn't make sense. It's acting like the test was updated
> for
> > r280596, but not the intrinsic header or the clang binary. That's the
> only
> > way I can think that the output IR could contain
> > @llvm.x86.avx512.mask.padd.b.256.
>
> Hi Craig,
>
> I don't know, but this is a fresh build with sources (hopefully) in sync:
>
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/15232
>
> and still shows a lot of avx builtin problems...
>
> cheers,
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.

2016-09-05 Thread Nico Weber via cfe-commits
Renato, I remember you saying you worked around the bot problem by making
the build dir a symlink. Maybe stuff gets confused by that setup? Symlink
build dirs tend to cause trouble.

On Sep 5, 2016 8:11 PM, "Craig Topper via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> This error makes even less sense. Nothing about __builtin_ia32_selectd_512
> requires a constant integer.
>
> /home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/bin/../lib/clang/4.0.0/include/avx512fintrin.h:223:19:
>  error: argument to '__builtin_ia32_selectd_512' must be a constant integer
>   return (__m512i)__builtin_ia32_selectd_512(__M,
>
>
> ~Craig
>
> On Mon, Sep 5, 2016 at 4:49 PM, Renato Golin 
> wrote:
>
>> On 6 September 2016 at 00:27, Craig Topper 
>> wrote:
>> > This failure doesn't make sense. It's acting like the test was updated
>> for
>> > r280596, but not the intrinsic header or the clang binary. That's the
>> only
>> > way I can think that the output IR could contain
>> > @llvm.x86.avx512.mask.padd.b.256.
>>
>> Hi Craig,
>>
>> I don't know, but this is a fresh build with sources (hopefully) in sync:
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/15232
>>
>> and still shows a lot of avx builtin problems...
>>
>> cheers,
>> --renato
>>
>
>
> ___
> 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


Re: [PATCH] D23926: [libcxx] Don't use C99 math ops in -std=c++03 mode

2016-09-05 Thread Asiri Rathnayake via cfe-commits
Hi @EricWD, @mclow.lists,

Thanks for the comments.

I will discuss this downstream a bit and get back. What I don't want to do
is deviate too much from upstream in terms of expectations. We may have to
shed some of our old expectations with libc++, I wanted to first clarify
upstream position on this.

Would be good to get these points documented though. I will do a docs patch
once i have discussed this internally.

Cheers,

/ Asiri

PS: @mclow.lists: Ping on the thread api patch... ;)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits