[PATCH] D38821: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38821#895527, @compnerd wrote:

> Don't you need a change to the intrinsics to actually map the builtin?


This seems to be automatically mapped via this piece of code in CGBuiltin.cpp:

  // See if we have a target specific intrinsic.
  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
  StringRef Prefix =
  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
  if (!Prefix.empty()) {
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
// NOTE we dont need to perform a compatibility flag check here since the
// intrinsics are declared in Builtins*.def via LANGBUILTIN which filter the
// MS builtins via ALL_MS_LANGUAGES and are filtered earlier.
if (IntrinsicID == Intrinsic::not_intrinsic)
  IntrinsicID = Intrinsic::getIntrinsicForMSBuiltin(Prefix.data(), Name);
  } 

And these target specific intrinsics are already hooked up on the LLVM side in 
SVN r310502.


https://reviews.llvm.org/D38821



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


r315567 - [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-12 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Oct 12 00:05:37 2017
New Revision: 315567

URL: http://llvm.org/viewvc/llvm-project?rev=315567&view=rev
Log:
[COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

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

Added:
cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/Basic/Targets/AArch64.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=315567&r1=315566&r2=315567&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Thu Oct 12 00:05:37 2017
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@ BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=315567&r1=315566&r2=315567&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Thu Oct 12 00:05:37 2017
@@ -27,6 +27,8 @@ const Builtin::Info AArch64TargetInfo::B
 
 #define BUILTIN(ID, TYPE, ATTRS)   
\
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) 
\
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 

Added: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c?rev=315567&view=auto
==
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c (added)
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c Thu Oct 12 00:05:37 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s 
\
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'


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


[PATCH] D38821: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315567: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb 
(authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D38821?vs=118689&id=118747#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38821

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c


Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN
Index: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s 
\
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   
\
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) 
\
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 


Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN
Index: cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
+++ cfe/trunk/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'
Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -27,6 +27,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   \
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, 

[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D38444#895403, @george.karpenkov wrote:

> @mgorny I've replied via email, but the message didn't seem to appear here.
>
> From my (maybe limited) understanding, running tests on standalone 
> compiler-rt builds was never something which was supported, as that required 
> a fresh compiler.
>  I've just tried running them, and for me even `check-*` targets don't exist.
>
> How do you create the standalone build? I've checked out `compiler-rt` 
> separately, and ran
>
>   cmake -GNinja 
> -DLLVM_CONFIG=/Users/george/code/llvm/release-build/bin/llvm-config  ../.
>


Our command-line is:

  cmake -C 
/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_common_config.cmake
 -G Ninja -DCMAKE_INSTALL_PREFIX=/usr 
-DCOMPILER_RT_INSTALL_PATH=/usr/lib/clang/6.0.0 
-DCOMPILER_RT_OUTPUT_DIR=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/clang/6.0.0
 -DCOMPILER_RT_INCLUDE_TESTS=yes -DCOMPILER_RT_BUILD_BUILTINS=OFF 
-DCOMPILER_RT_BUILD_LIBFUZZER=ON -DCOMPILER_RT_BUILD_SANITIZERS=ON 
-DCOMPILER_RT_BUILD_XRAY=ON 
-DLLVM_MAIN_SRC_DIR=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/llvm
 -DLLVM_EXTERNAL_LIT=/usr/bin/lit -DLLVM_LIT_ARGS=-vv 
-DCOMPILER_RT_TEST_COMPILER=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/llvm/6/bin/clang
 
-DCOMPILER_RT_TEST_CXX_COMPILER=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/llvm/6/bin/clang++
 -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_rules.cmake
 
-DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_toolchain.cmake
  
/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-



> but the resulting build directory does not have any `check-*` targets.

I think the `-DCOMPILER_RT_INCLUDE_TESTS=yes` may be relevant here.

> In the refactoring I did try to make the dependence conditional: all 
> compilation goes through `sanitizer_test_compile`,
>  but looking into the `sanitizer_test_compile` macro there is an obvious bug.
>  Would it be better to fix that instead?

Indeed there is. I'll check if fixing that solves the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


r315568 - Split the AlignTrailingComments on several lines. The comments were applied to the right columns

2017-10-12 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu Oct 12 01:07:53 2017
New Revision: 315568

URL: http://llvm.org/viewvc/llvm-project?rev=315568&view=rev
Log:
Split the AlignTrailingComments on several lines. The comments were applied to 
the right columns

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=315568&r1=315567&r2=315568&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Oct 12 01:07:53 2017
@@ -266,9 +266,13 @@ the configuration (without a prefix: ``A
 
   .. code-block:: c++
 
-true:   false:
-int a; // My comment a  vs. int a; // My comment a
-int b = 2; // comment  bint b = 2; // comment about b
+true:
+int a; // My comment a
+int b = 2; // comment  b
+
+false:
+int a; // My comment a
+int b = 2; // comment about b
 
 **AllowAllParametersOfDeclarationOnNextLine** (``bool``)
   If the function declaration doesn't fit on a line,


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


[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

2017-10-12 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

ping


https://reviews.llvm.org/D37695



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D35082#895312, @yaxunl wrote:

> Thanks. I will separate the implicit addr space flag to another patch.


Thanks, appreciated.




Comment at: include/clang/AST/Type.h:562
+  static const uint32_t IMask = 0x200;
+  static const uint32_t IShift = 9;
   static const uint32_t AddressSpaceMask =

yaxunl wrote:
> rjmccall wrote:
> > "I" is not an appropriate abbreviation for "AddressSpaceImplicit".
> Will change it to ImplictAddrSpace.
Sounds good.


https://reviews.llvm.org/D35082



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


[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

Ok, I think I've found a better solution. Will start submitting patches soonish.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


[PATCH] D38838: [compiler-rt] [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Fix typo in variable assignment inside sanitizer_test_compile() that
resulted in TEST_DEPS parameter not being included in the clang_compile()
call. Spotted by George Karpenkov in https://reviews.llvm.org/D38444.


https://reviews.llvm.org/D38838

Files:
  cmake/Modules/CompilerRTCompile.cmake


Index: cmake/Modules/CompilerRTCompile.cmake
===
--- cmake/Modules/CompilerRTCompile.cmake
+++ cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()


Index: cmake/Modules/CompilerRTCompile.cmake
===
--- cmake/Modules/CompilerRTCompile.cmake
+++ cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38452: Mark test as a long-test

2017-10-12 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315570: Mark test as a long-test (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D38452?vs=117317&id=118753#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38452

Files:
  
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp


Index: 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
===
--- 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
+++ 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
@@ -13,6 +13,8 @@
 // class basic_streambuf;
 
 // void pbump(int n);
+//
+// REQUIRES: long_tests
 
 #include 
 #include 


Index: libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
===
--- libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
+++ libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
@@ -13,6 +13,8 @@
 // class basic_streambuf;
 
 // void pbump(int n);
+//
+// REQUIRES: long_tests
 
 #include 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r315570 - Mark test as a long-test

2017-10-12 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Oct 12 01:46:05 2017
New Revision: 315570

URL: http://llvm.org/viewvc/llvm-project?rev=315570&view=rev
Log:
Mark test as a long-test

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


Modified:

libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp?rev=315570&r1=315569&r2=315570&view=diff
==
--- 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 Thu Oct 12 01:46:05 2017
@@ -13,6 +13,8 @@
 // class basic_streambuf;
 
 // void pbump(int n);
+//
+// REQUIRES: long_tests
 
 #include 
 #include 


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


[PATCH] D38839: [compiler-rt] [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Fix the gtest dependency to be included in DEPS only, rather than
in COMPILE_DEPS + DEPS. The former variable is apparently used to
provide unconditional dependencies, while the latter are only used
for non-standalone builds. Since they are concatenated, specifying gtest
in both is redundant. Furthermore, including it in COMPILE_DEPS causes
build failure for standalone builds where 'gtest' target is not present.


https://reviews.llvm.org/D38839

Files:
  lib/interception/tests/CMakeLists.txt


Index: lib/interception/tests/CMakeLists.txt
===
--- lib/interception/tests/CMakeLists.txt
+++ lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})


Index: lib/interception/tests/CMakeLists.txt
===
--- lib/interception/tests/CMakeLists.txt
+++ lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38840: [compiler-rt] [cmake] [asan] Reuse generate_asan_tests for dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added subscribers: dberris, kubamracek.

Unify the ASAN dynamic test logic to use generate_asan_tests() in both
MSVC and non-MSVC branch. It is unclear why this particular branch used
add_compiler_rt_test() directly. However, it skipped
the COMPILE_DEPS/DEPS logic which resulted in 'gtest' target being
included in standalone builds, causing build failures due to missing
target.


https://reviews.llvm.org/D38840

Files:
  lib/asan/tests/CMakeLists.txt


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -202,9 +202,9 @@
 else()
 
   # Otherwise, reuse ASAN_INST_TEST_OBJECTS.
-  add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
+  generate_asan_tests(ASAN_INST_TEST_OBJECTS
+AsanDynamicUnitTests "${dynamic_test_name}"
 SUBDIR "dynamic"
-OBJECTS ${ASAN_INST_TEST_OBJECTS}
 DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -202,9 +202,9 @@
 else()
 
   # Otherwise, reuse ASAN_INST_TEST_OBJECTS.
-  add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
+  generate_asan_tests(ASAN_INST_TEST_OBJECTS
+AsanDynamicUnitTests "${dynamic_test_name}"
 SUBDIR "dynamic"
-OBJECTS ${ASAN_INST_TEST_OBJECTS}
 DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

https://reviews.llvm.org/D38838 addresses the typo. Now that I know how it's 
supposed to work, https://reviews.llvm.org/D38839 and 
https://reviews.llvm.org/D38840 address the issues, and fix it for me.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ideas behind both hashing change and new testing mechanism look great to me.

I think it would be great to split them into two different patches, to be able 
to easily see how the change in the hashing affects the tests (and maybe revert 
easily if something goes wrong).




Comment at: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:88
+&ExprInspectionChecker::analyzerNumTimesReached)
+  .Case("clang_analyzer_hash_dump",
+&ExprInspectionChecker::analyzerDumpHash)

`clang_analyzer_hashDump` would be more consistent.


https://reviews.llvm.org/D38728



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


[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D38728#895669, @NoQ wrote:

> I think it would be great to split them into two different patches, to be 
> able to easily see how the change in the hashing affects the tests (and maybe 
> revert easily if something goes wrong).


So you would commit the hash change first and the test change on the top of it? 
Or the other way around?


https://reviews.llvm.org/D38728



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


[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The other way round, i guess. I like the test change, it's easier to 
understand, so it's better to have it before starting to understand :)


https://reviews.llvm.org/D38728



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


[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Looks good.




Comment at: lib/Basic/DiagnosticIDs.cpp:46
   unsigned WarnShowInSystemHeader : 1;
-  unsigned Category : 5;
+  unsigned Category : 6;
 

arphaman wrote:
> hokein wrote:
> > just curious: is this change needed?
> I get a build warning without this change as the bitfield becomes too narrow 
> with the new category, so yeah.
Thanks for explanation.


Repository:
  rL LLVM

https://reviews.llvm.org/D38772



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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-12 Thread Jonas Toth via cfe-commits

Hi,

I am not sure if could follow correctly, but the test for nested 
namespaces comments does not work correctly and is therefore currently 
disabled by fileextension?


When running the check from trunk i get the following issues:

$ clang-check google-readability-namespace-comments-cxx17.cpp -- -std=c++17
> error: invalid value 'c++17' in '-std=c++17'

In the clang-tidy check '-std=c++17' is used. I don't know if the c++17 
- flag is introduced in clang yet, but maybe this would be one issue.


Running clang-tidy from command line does not produce output (added 
fileextension for now):


$ clang-tidy -checks=-*,google-readability-namespace-comments 
google-readability-namespace-comments-cxx17.cpp -- -std=c++1z
$ clang-tidy -checks=-*,google-readability-namespace-comments 
google-readability-namespace-comments-cxx17.cpp -- -- -std=c++1z
> Error while processing 
/home/jonas/opt/llvm/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp.


Adding a 'std::cout << "Test if run" << std::endl' at the beginning of 
the `check` - Method works and generates output:


$ clang-tidy -checks=-*,google-readability-namespace-comments 
google-readability-namespace-comments-cxx17.cpp -- -std=c++1z

Test if run
Test if run
Test if run

So I think there is a regression in the Testingcode not catching the 
nested namespaces. Did it work before and what could have changed?
If it did work and the clang-tidy code is the same this could be a 
regression somewhere else.


All the Best, Jonas

Am 11.10.2017 um 21:36 schrieb Aaron Ballman:

On Wed, Oct 11, 2017 at 3:29 PM, Alexander Kornienko  wrote:

On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits
 wrote:

Author: aaronballman
Date: Fri Oct  6 06:27:59 2017
New Revision: 315060

URL: http://llvm.org/viewvc/llvm-project?rev=315060&view=rev
Log:
Renaming a test to start with the name of the check based on post-commit
review feedback; NFC.

Added:

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17


Sorry for not being clear. I didn't mean the `.cpp` extension should be
removed. This effectively disables the test, since lit only runs tests in
files with certain extensions (under clang-tools-extra/test these are '.c',
'.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
'.module-map-checker', '.test').

That's entirely my fault -- I should have recognized that. Sorry for
the trouble!


I've just renamed the file to *.cpp and the test fails for me:

[0/1] Running the Clang extra tools' regression tests
FAIL: Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)
 TEST 'Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED

Script:
--
/usr/bin/python2.7
/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
google-readability-namespace-comments
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
-- -- -std=c++17
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-tidy',
'/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'-fix', '--checks=-*,google-readability-namespace-comments', '--',
'-std=c++17', '-nostdinc++']...
 clang-tidy output ---

--
-- Fixes -

--
FileCheck failed:
/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp:13:17:
error: expected string not found in input
// CHECK-FIXES: }  // namespace n3
 ^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:1:1:
note: scanning from here
// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- --
-std=c++17
^
/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp:5:7:
note: possible intended match here
   // So that namespace is not empty.
   ^


--
Command Output (stderr):
--
Traceback (most recent call last):
   File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 140, in 
 main()
   File
"/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py",
line 121, in main
 stderr=subprocess.STDOUT)
   File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
 raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['FileCheck',
'-input-file=/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp.cpp',
'/src/tools/clang/tools/extra/test/clan

r315573 - Fix warnings. [-Wdocumentation]

2017-10-12 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Oct 12 02:42:14 2017
New Revision: 315573

URL: http://llvm.org/viewvc/llvm-project?rev=315573&view=rev
Log:
Fix warnings. [-Wdocumentation]

Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=315573&r1=315572&r2=315573&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Thu Oct 12 02:42:14 2017
@@ -847,9 +847,8 @@ static void updateConsecutiveMacroArgTok
 /// \brief Creates SLocEntries and updates the locations of macro argument
 /// tokens to their new expanded locations.
 ///
-/// \param ArgIdDefLoc the location of the macro argument id inside the macro
+/// \param ArgIdSpellLoc the location of the macro argument id inside the macro
 /// definition.
-/// \param Tokens the macro argument tokens to update.
 void TokenLexer::updateLocForMacroArgTokens(SourceLocation ArgIdSpellLoc,
 Token *begin_tokens,
 Token *end_tokens) {

Modified: cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp?rev=315573&r1=315572&r2=315573&view=diff
==
--- cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp (original)
+++ cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp Thu Oct 12 02:42:14 2017
@@ -19,8 +19,6 @@ using namespace clang;
 ///\brief Constructs a new multiplexing external sema source and appends the
 /// given element to it.
 ///
-///\param[in] source - An ExternalSemaSource.
-///
 MultiplexExternalSemaSource::MultiplexExternalSemaSource(ExternalSemaSource 
&s1,
 ExternalSemaSource 
&s2){
   Sources.push_back(&s1);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=315573&r1=315572&r2=315573&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 12 02:42:14 2017
@@ -5425,10 +5425,12 @@ PreprocessedEntity *ASTReader::ReadPrepr
   llvm_unreachable("Invalid PreprocessorDetailRecordTypes");
 }
 
-/// \brief \arg SLocMapI points at a chunk of a module that contains no
-/// preprocessed entities or the entities it contains are not the ones we are
-/// looking for. Find the next module that contains entities and return the ID
+/// \brief Find the next module that contains entities and return the ID
 /// of the first entry.
+///
+/// \param SLocMapI points at a chunk of a module that contains no
+/// preprocessed entities or the entities it contains are not the ones we are
+/// looking for.
 PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
GlobalSLocOffsetMapType::const_iterator SLocMapI) const 
{
   ++SLocMapI;


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


r315572 - SVal::getAsSymbol(bool IncludeBaseRegions): Follow clang/StaticAnalyzer/Core/PathSensitive/SVals.h, s/IncludeBaseRegion/IncludeBaseRegions/g [-Wdocumentation]

2017-10-12 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Oct 12 02:42:12 2017
New Revision: 315572

URL: http://llvm.org/viewvc/llvm-project?rev=315572&view=rev
Log:
SVal::getAsSymbol(bool IncludeBaseRegions): Follow 
clang/StaticAnalyzer/Core/PathSensitive/SVals.h, 
s/IncludeBaseRegion/IncludeBaseRegions/g [-Wdocumentation]

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=315572&r1=315571&r2=315572&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Thu Oct 12 02:42:12 2017
@@ -113,12 +113,12 @@ SymbolRef SVal::getLocSymbolInBase() con
 /// Casts are ignored during lookup.
 /// \param IncludeBaseRegions The boolean that controls whether the search
 /// should continue to the base regions if the region is not symbolic.
-SymbolRef SVal::getAsSymbol(bool IncludeBaseRegion) const {
+SymbolRef SVal::getAsSymbol(bool IncludeBaseRegions) const {
   // FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
   if (Optional X = getAs())
 return X->getSymbol();
 
-  return getAsLocSymbol(IncludeBaseRegion);
+  return getAsLocSymbol(IncludeBaseRegions);
 }
 
 /// getAsSymbolicExpression - If this Sval wraps a symbolic expression then


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


[PATCH] D33989: [OpenCL] Allow targets to select address space per type

2017-10-12 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.



Comment at: cfe/trunk/lib/Basic/TargetInfo.cpp:351
 
+LangAS::ID TargetInfo::getOpenCLTypeAddrSpace(const Type *T) const {
+  auto BT = dyn_cast(T);

Excuse me for old commit, I think it might be layering violation.
Could we avoid using AST/Type here?


Repository:
  rL LLVM

https://reviews.llvm.org/D33989



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


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

2017-10-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34512#890537, @r.stahl wrote:

> In https://reviews.llvm.org/D34512#877643, @xazax.hun wrote:
>
> > - Unittests now creates temporary files at the correct location
> > - Temporary files are also cleaned up when the process is terminated
> > - Absolute paths are handled correctly by the library
>
>
> I think there is an issue with this change.
>
> First, the function map generation writes absolute paths to the map file. Now 
> when the `parseCrossTUIndex` function parses it, it will no longer prepend 
> the paths with the CTUDir and therefore expect the precompiled AST files at 
> the exact path of the source file. This seems like a bad requirement, because 
> the user would have to overwrite his source files.
>
> If I understand your intention correctly, a fix would be to replace the 
> `is_absolute` check with a check for `CTUDir == ""` in the 
> `parseCrossTUIndex` function.


Good catch, that is right!


Repository:
  rL LLVM

https://reviews.llvm.org/D34512



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


[clang-tools-extra] r315574 - Fix the google-readability-namespace-comments-cxx17 test after r315060.

2017-10-12 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Oct 12 03:41:22 2017
New Revision: 315574

URL: http://llvm.org/viewvc/llvm-project?rev=315574&view=rev
Log:
Fix the google-readability-namespace-comments-cxx17 test after r315060.

Restore the file extension. Make the namespace longer than the
ShortNamespaceLines so that the check triggers.

Added:

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
Removed:

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17

Removed: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17?rev=315573&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17
 (removed)
@@ -1,15 +0,0 @@
-// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- -- 
-std=c++17
-
-namespace n1::n2 {
-namespace n3 {
-  // So that namespace is not empty.
-  void f();
-
-// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
-// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
-// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
-}}
-// CHECK-FIXES: }  // namespace n3
-// CHECK-FIXES: }  // namespace n1::n2
-

Added: 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp?rev=315574&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
 Thu Oct 12 03:41:22 2017
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- -- 
-std=c++17
+
+namespace n1::n2 {
+namespace n3 {
+  // So that namespace is not empty and has at least 10 lines.
+  // 1
+  // 2
+  // 3
+  // 3
+  // 4
+  // 5
+  // 6
+  // 7
+  // 8
+  void f();
+}}
+// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE-14]]:11: note: namespace 'n3' starts here
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: namespace 'n1::n2' not terminated 
with a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE-17]]:11: note: namespace 'n1::n2' starts here
+// CHECK-FIXES: }  // namespace n3
+// CHECK-FIXES: }  // namespace n1::n2
+


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


Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-12 Thread Alexander Kornienko via cfe-commits
On Thu, Oct 12, 2017 at 11:12 AM, Jonas Toth  wrote:

> Hi,
>
> I am not sure if could follow correctly, but the test for nested
> namespaces comments does not work correctly and is therefore currently
> disabled by fileextension?
>

No, the removal of the file extension was unintentional (likely
misunderstanding of my post-commit review comment).


>
> When running the check from trunk i get the following issues:
>
> $ clang-check google-readability-namespace-comments-cxx17.cpp --
> -std=c++17
> > error: invalid value 'c++17' in '-std=c++17'
>

I suppose, your clang-check is just old. Clang supports -std=c++17 these
days.


>
> In the clang-tidy check '-std=c++17' is used. I don't know if the c++17 -
> flag is introduced in clang yet, but maybe this would be one issue.
>
> Running clang-tidy from command line does not produce output (added
> fileextension for now):
>
> $ clang-tidy -checks=-*,google-readability-namespace-comments
> google-readability-namespace-comments-cxx17.cpp -- -std=c++1z
> $ clang-tidy -checks=-*,google-readability-namespace-comments
> google-readability-namespace-comments-cxx17.cpp -- -- -std=c++1z
> > Error while processing /home/jonas/opt/llvm/tools/cla
> ng/tools/extra/test/clang-tidy/google-readability-namespace-
> comments-cxx17.cpp.
>
> Adding a 'std::cout << "Test if run" << std::endl' at the beginning of the
> `check` - Method works and generates output:
>
> $ clang-tidy -checks=-*,google-readability-namespace-comments
> google-readability-namespace-comments-cxx17.cpp -- -std=c++1z
> Test if run
> Test if run
> Test if run
>
> So I think there is a regression in the Testingcode not catching the
> nested namespaces. Did it work before and what could have changed?
> If it did work and the clang-tidy code is the same this could be a
> regression somewhere else.
>

The problem was that the namespace was shorter than the default
ShortNamespaceLines option value, so the check didn't trigger. Fixed
in r315574 (but would be nice, if this kind of stuff was detected before
commit).

However, this is not the end of problems with this check. It started
causing assertion failures on some of our code after the recent changes
(r315057). I'll post an update on that revision once I have more details.


>
> All the Best, Jonas
>
>
> Am 11.10.2017 um 21:36 schrieb Aaron Ballman:
>
>> On Wed, Oct 11, 2017 at 3:29 PM, Alexander Kornienko 
>> wrote:
>>
>>> On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits
>>>  wrote:
>>>
 Author: aaronballman
 Date: Fri Oct  6 06:27:59 2017
 New Revision: 315060

 URL: http://llvm.org/viewvc/llvm-project?rev=315060&view=rev
 Log:
 Renaming a test to start with the name of the check based on post-commit
 review feedback; NFC.

 Added:

 clang-tools-extra/trunk/test/clang-tidy/google-readability-n
 amespace-comments-cxx17

>>>
>>> Sorry for not being clear. I didn't mean the `.cpp` extension should be
>>> removed. This effectively disables the test, since lit only runs tests in
>>> files with certain extensions (under clang-tools-extra/test these are
>>> '.c',
>>> '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize',
>>> '.module-map-checker', '.test').
>>>
>> That's entirely my fault -- I should have recognized that. Sorry for
>> the trouble!
>>
>> I've just renamed the file to *.cpp and the test fails for me:
>>>
>>> [0/1] Running the Clang extra tools' regression tests
>>> FAIL: Clang Tools ::
>>> clang-tidy/google-readability-namespace-comments-cxx17.cpp (102 of 674)
>>>  TEST 'Clang Tools ::
>>> clang-tidy/google-readability-namespace-comments-cxx17.cpp' FAILED
>>> 
>>> Script:
>>> --
>>> /usr/bin/python2.7
>>> /src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py
>>> /src/tools/clang/tools/extra/test/clang-tidy/google-readabil
>>> ity-namespace-comments-cxx17.cpp
>>> google-readability-namespace-comments
>>> /build/tools/clang/tools/extra/test/clang-tidy/Output/google
>>> -readability-namespace-comments-cxx17.cpp.tmp
>>> -- -- -std=c++17
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stdout):
>>> --
>>> Running ['clang-tidy',
>>> '/build/tools/clang/tools/extra/test/clang-tidy/Output/googl
>>> e-readability-namespace-comments-cxx17.cpp.tmp.cpp',
>>> '-fix', '--checks=-*,google-readability-namespace-comments', '--',
>>> '-std=c++17', '-nostdinc++']...
>>>  clang-tidy output ---
>>>
>>> --
>>> -- Fixes -
>>>
>>> --
>>> FileCheck failed:
>>> /src/tools/clang/tools/extra/test/clang-tidy/google-readabil
>>> ity-namespace-comments-cxx17.cpp:13:17:
>>> error: expected string not found in input
>>> // CHECK-FIXES: }  // namespace n3
>>>  ^
>>> /build/tools/clang/tools/extra/test/clang-

Re: [clang-tools-extra] r315060 - Renaming a test to start with the name of the check based on post-commit review feedback; NFC.

2017-10-12 Thread Jonas Toth via cfe-commits

Ok.

I subscribe to r315057. I can look at debugging the change as well if 
you guys want. Should have time today evening and tomorrow.



Am 12.10.2017 um 12:46 schrieb Alexander Kornienko:
On Thu, Oct 12, 2017 at 11:12 AM, Jonas Toth > wrote:


Hi,

I am not sure if could follow correctly, but the test for nested
namespaces comments does not work correctly and is therefore
currently disabled by fileextension?


No, the removal of the file extension was unintentional (likely 
misunderstanding of my post-commit review comment).



When running the check from trunk i get the following issues:

$ clang-check google-readability-namespace-comments-cxx17.cpp --
-std=c++17
> error: invalid value 'c++17' in '-std=c++17'


I suppose, your clang-check is just old. Clang supports -std=c++17 
these days.



In the clang-tidy check '-std=c++17' is used. I don't know if the
c++17 - flag is introduced in clang yet, but maybe this would be
one issue.

Running clang-tidy from command line does not produce output
(added fileextension for now):

$ clang-tidy -checks=-*,google-readability-namespace-comments
google-readability-namespace-comments-cxx17.cpp -- -std=c++1z
$ clang-tidy -checks=-*,google-readability-namespace-comments
google-readability-namespace-comments-cxx17.cpp -- -- -std=c++1z
> Error while processing

/home/jonas/opt/llvm/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp.

Adding a 'std::cout << "Test if run" << std::endl' at the
beginning of the `check` - Method works and generates output:

$ clang-tidy -checks=-*,google-readability-namespace-comments
google-readability-namespace-comments-cxx17.cpp -- -std=c++1z
Test if run
Test if run
Test if run

So I think there is a regression in the Testingcode not catching
the nested namespaces. Did it work before and what could have changed?
If it did work and the clang-tidy code is the same this could be a
regression somewhere else.


The problem was that the namespace was shorter than the default 
ShortNamespaceLines option value, so the check didn't trigger. Fixed 
in r315574 (but would be nice, if this kind of stuff was detected 
before commit).


However, this is not the end of problems with this check. It started 
causing assertion failures on some of our code after the recent 
changes (r315057). I'll post an update on that revision once I have 
more details.



All the Best, Jonas


Am 11.10.2017 um 21:36 schrieb Aaron Ballman:

On Wed, Oct 11, 2017 at 3:29 PM, Alexander Kornienko
mailto:ale...@google.com>> wrote:

On Fri, Oct 6, 2017 at 3:27 PM, Aaron Ballman via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: aaronballman
Date: Fri Oct  6 06:27:59 2017
New Revision: 315060

URL:
http://llvm.org/viewvc/llvm-project?rev=315060&view=rev

Log:
Renaming a test to start with the name of the check
based on post-commit
review feedback; NFC.

Added:


clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17


Sorry for not being clear. I didn't mean the `.cpp`
extension should be
removed. This effectively disables the test, since lit
only runs tests in
files with certain extensions (under
clang-tools-extra/test these are '.c',
'.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
'.modularize',
'.module-map-checker', '.test').

That's entirely my fault -- I should have recognized that.
Sorry for
the trouble!

I've just renamed the file to *.cpp and the test fails for me:

[0/1] Running the Clang extra tools' regression tests
FAIL: Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp
(102 of 674)
 TEST 'Clang Tools ::
clang-tidy/google-readability-namespace-comments-cxx17.cpp'
FAILED

Script:
--
/usr/bin/python2.7

/src/tools/clang/tools/extra/test/../test/clang-tidy/check_clang_tidy.py

/src/tools/clang/tools/extra/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
google-readability-namespace-comments

/build/tools/clang/tools/extra/test/clang-tidy/Output/google-readability-namespace-comments-cxx17.cpp.tmp
-- -- -std=c++17
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-ti

r315575 - [CodeGen] Generate TBAA info along with LValue base info

2017-10-12 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Thu Oct 12 04:29:46 2017
New Revision: 315575

URL: http://llvm.org/viewvc/llvm-project?rev=315575&view=rev
Log:
[CodeGen] Generate TBAA info along with LValue base info

This patch enables explicit generation of TBAA information in all
cases where LValue base info is propagated or constructed in
non-trivial ways. Eventually, we will consider each of these
cases to make sure the TBAA information is correct and not too
conservative. For now, we just fall back to generating TBAA info
from the access type.

This patch should not bring in any functional changes.

This is part of D38126 reworked to be a separate patch to
simplify review.

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315575&r1=315574&r2=315575&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 12 04:29:46 2017
@@ -2159,7 +2159,8 @@ LValue CodeGenFunction::EmitLoadOfRefere
   const ReferenceType *RefTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo);
-  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(RefTy->getPointeeType()));
 }
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
@@ -2175,7 +2176,8 @@ LValue CodeGenFunction::EmitLoadOfPointe
 const PointerType *PtrTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo);
-  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(PtrTy->getPointeeType()));
 }
 
 static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
@@ -2328,7 +2330,8 @@ LValue CodeGenFunction::EmitDeclRefLValu
 bool MayAlias = CapLVal.getBaseInfo().getMayAlias();
 return MakeAddrLValue(
 Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
-CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, 
MayAlias));
+CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias),
+CGM.getTBAAAccessInfo(CapLVal.getType()));
   }
 
   assert(isa(CurCodeDecl));
@@ -2440,7 +2443,7 @@ LValue CodeGenFunction::EmitUnaryOpLValu
 
 LValueBaseInfo BaseInfo;
 Address Addr = EmitPointerWithAlignment(E->getSubExpr(), &BaseInfo);
-LValue LV = MakeAddrLValue(Addr, T, BaseInfo);
+LValue LV = MakeAddrLValue(Addr, T, BaseInfo, CGM.getTBAAAccessInfo(T));
 LV.getQuals().setAddressSpace(ExprTy.getAddressSpace());
 
 // We should not generate __weak write barrier on indirect reference
@@ -2472,7 +2475,8 @@ LValue CodeGenFunction::EmitUnaryOpLValu
   (E->getOpcode() == UO_Real
  ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
  : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
-LValue ElemLV = MakeAddrLValue(Component, T, LV.getBaseInfo());
+LValue ElemLV = MakeAddrLValue(Component, T, LV.getBaseInfo(),
+   CGM.getTBAAAccessInfo(T));
 ElemLV.getQuals().addQualifiers(LV.getQuals());
 return ElemLV;
   }
@@ -3202,7 +3206,8 @@ LValue CodeGenFunction::EmitArraySubscri
 QualType EltType = LV.getType()->castAs()->getElementType();
 Addr = emitArraySubscriptGEP(*this, Addr, Idx, EltType, /*inbounds*/ true,
  SignedIndices, E->getExprLoc());
-return MakeAddrLValue(Addr, EltType, LV.getBaseInfo());
+return MakeAddrLValue(Addr, EltType, LV.getBaseInfo(),
+  CGM.getTBAAAccessInfo(EltType));
   }
 
   LValueBaseInfo BaseInfo;
@@ -3293,7 +3298,8 @@ LValue CodeGenFunction::EmitArraySubscri
  SignedIndices, E->getExprLoc());
   }
 
-  LValue LV = MakeAddrLValue(Addr, E->getType(), BaseInfo);
+  LValue LV = MakeAddrLValue(Addr, E->getType(), BaseInfo,
+ CGM.getTBAAAccessInfo(E->getType()));
 
   // TODO: Preserve/extend path TBAA metadata?
 
@@ -3493,7 +3499,8 @@ LValue CodeGenFunction::EmitOMPArraySect
/*SignedIndices=*/false, E->getExprLoc());
   }
 
-  return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo);
+  return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo,
+CGM.getTBAAAccessInfo(ResultExprTy));
 }
 
 LValue CodeGenFunction::
@@ -3508,7 +3515,8 @@ EmitExtVectorElementExpr(const ExtVector

[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

2017-10-12 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315575: [CodeGen] Generate TBAA info along with LValue base 
info (authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D38733?vs=118551&id=118771#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38733

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -980,7 +980,8 @@
   SharedLVal = CGF.MakeAddrLValue(
   CGF.Builder.CreateElementBitCast(SharedLVal.getAddress(),
CGF.ConvertTypeForMem(SharedType)),
-  SharedType, SharedAddresses[N].first.getBaseInfo());
+  SharedType, SharedAddresses[N].first.getBaseInfo(),
+  CGF.CGM.getTBAAAccessInfo(SharedType));
   if (isa(ClausesData[N].Ref) ||
   CGF.getContext().getAsArrayType(PrivateVD->getType())) {
 emitAggregateInitialization(CGF, N, PrivateAddr, SharedLVal, DRD);
@@ -1033,7 +1034,8 @@
   return CGF.MakeAddrLValue(
   CGF.Builder.CreateElementBitCast(BaseLV.getAddress(),
CGF.ConvertTypeForMem(ElTy)),
-  BaseLV.getType(), BaseLV.getBaseInfo());
+  BaseLV.getType(), BaseLV.getBaseInfo(),
+  CGF.CGM.getTBAAAccessInfo(BaseLV.getType()));
 }
 
 static Address castToBase(CodeGenFunction &CGF, QualType BaseTy, QualType ElTy,
@@ -4072,7 +4074,8 @@
 Address(SharedRefLValue.getPointer(), C.getDeclAlign(OriginalVD)),
 SharedRefLValue.getType(),
 LValueBaseInfo(AlignmentSource::Decl,
-   SharedRefLValue.getBaseInfo().getMayAlias()));
+   SharedRefLValue.getBaseInfo().getMayAlias()),
+CGF.CGM.getTBAAAccessInfo(SharedRefLValue.getType()));
 QualType Type = OriginalVD->getType();
 if (Type->isArrayType()) {
   // Initialize firstprivate array.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -180,7 +180,8 @@
 CodeGenFunction::MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T) {
   LValueBaseInfo BaseInfo;
   CharUnits Align = getNaturalTypeAlignment(T, &BaseInfo, /*pointee*/ true);
-  return MakeAddrLValue(Address(V, Align), T, BaseInfo);
+  return MakeAddrLValue(Address(V, Align), T, BaseInfo,
+CGM.getTBAAAccessInfo(T));
 }
 
 
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -2159,7 +2159,8 @@
   const ReferenceType *RefTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo);
-  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(RefTy->getPointeeType()));
 }
 
 Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
@@ -2175,7 +2176,8 @@
 const PointerType *PtrTy) {
   LValueBaseInfo BaseInfo;
   Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo);
-  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo);
+  return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo,
+CGM.getTBAAAccessInfo(PtrTy->getPointeeType()));
 }
 
 static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
@@ -2328,7 +2330,8 @@
 bool MayAlias = CapLVal.getBaseInfo().getMayAlias();
 return MakeAddrLValue(
 Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)),
-CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias));
+CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias),
+CGM.getTBAAAccessInfo(CapLVal.getType()));
   }
 
   assert(isa(CurCodeDecl));
@@ -2440,7 +2443,7 @@
 
 LValueBaseInfo BaseInfo;
 Address Addr = EmitPointerWithAlignment(E->getSubExpr(), &BaseInfo);
-LValue LV = MakeAddrLValue(Addr, T, BaseInfo);
+LValue LV = MakeAddrLValue(Addr, T, BaseInfo, CGM.getTBAAAccessInfo(T));
 LV.getQuals().setAddressSpace(ExprTy.getAddressSpace());
 
 // We should not generate __weak write barrier on indirect reference
@@ -2472,7 +2475,8 @@
   (E->getOpcode() == UO_Real
  ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
  : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
-LValue ElemLV = MakeAddrLValue(Component, T, LV.getBase

[PATCH] D38835: [refactor] selection: new CodeRangeASTSelection represents a set of selected consecutive statements

2017-10-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: include/clang/Tooling/Refactoring/ASTSelection.h:74
+/// An AST selection value that corresponds to a selection of a set of
+/// statements that belong to one body of code (like one function).
+///

I see all your tests are for function body,  does it support other body, i.e. 
"global namespace", "compound statement"? 

if yes, how about adding more test cases to cover it.

```
// variable in global namespace
int a; // select int.
``` 

```
void f() {
   {
   int a;  // select a.
   }
}
```



Comment at: include/clang/Tooling/Refactoring/ASTSelection.h:95
+/// \c SelectedASTNode tree and should not outlive it.
+struct CodeRangeASTSelection {
+  CodeRangeASTSelection(CodeRangeASTSelection &&) = default;

nit:  instead of a structure, this feels more like a `class`.



Comment at: lib/Tooling/Refactoring/ASTSelection.cpp:247
+namespace {
+
+struct SelectedNodeWithParents {

nit: remove the empty line.



Comment at: unittests/Tooling/ASTSelectionTest.cpp:685
+)";
+  // Empty range is an invalid code range.
+  findSelectedASTNodesWithRange(

I think "No selection range" is more precise -- you are passing `None` 
parameter to the function.

For `empty range`, it should be something like `FileRange{{2, 2}, {2, 2}}`, we 
can also add a test for it.



Comment at: unittests/Tooling/ASTSelectionTest.cpp:688
+  Source, {2, 2}, None,
+  [](SourceRange SelectionRange, Optional Node) {
+EXPECT_TRUE(Node);

I'm a bit confused here, if the selection range is none/empty,  shouldn't 
`SelectedASTNode` be empty?

If this behavior is intended, I'd suggest documenting it in 
`findSelectedASTNodesWithRange`.



Comment at: unittests/Tooling/ASTSelectionTest.cpp:718
+isa(Parents[0].get().Node.get()));
+EXPECT_TRUE(isa(Parents[1].get().Node.get()));
+EXPECT_TRUE(isa(Parents[2].get().Node.get()));

nit: would be clearer to add a comment indicating the corresponding code, the 
same below.

like

```
EXPECT_TRUE(...); // function f definition
EXPECT_TRUE(...); // function body of function f
```


Repository:
  rL LLVM

https://reviews.llvm.org/D38835



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


[PATCH] D38842: [CrossTU] Fix handling of Cross Translation Unit directory path

2017-10-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.

The function map generator tool always creates absolute path. The correct logic 
to determine whether a path should be handled as absolute depends on the value 
of the CrossTU directory. Added a unit test to avoid regressions.


https://reviews.llvm.org/D38842

Files:
  lib/CrossTU/CrossTranslationUnit.cpp
  unittests/CrossTU/CrossTranslationUnitTest.cpp


Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -109,9 +109,9 @@
 
 TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
   llvm::StringMap Index;
-  Index["a"] = "b";
-  Index["c"] = "d";
-  Index["e"] = "f";
+  Index["a"] = "/b/f1";
+  Index["c"] = "/d/f2";
+  Index["e"] = "/f/f3";
   std::string IndexText = createCrossTUIndexString(Index);
 
   int IndexFD;
@@ -134,5 +134,25 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
+TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
+  llvm::StringMap Index;
+  Index["a"] = "/b/c/d";
+  std::string IndexText = createCrossTUIndexString(Index);
+
+  int IndexFD;
+  llvm::SmallString<256> IndexFileName;
+  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
+  IndexFileName));
+  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
+  IndexFile.os() << IndexText;
+  IndexFile.os().flush();
+  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+  llvm::Expected> IndexOrErr =
+  parseCrossTUIndex(IndexFileName, "/ctudir");
+  EXPECT_TRUE((bool)IndexOrErr);
+  llvm::StringMap ParsedIndex = IndexOrErr.get();
+  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
+}
+
 } // end namespace cross_tu
 } // end namespace clang
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -93,7 +93,7 @@
 index_error_code::multiple_definitions, IndexPath.str(), LineNo);
   StringRef FileName = LineRef.substr(Pos + 1);
   SmallString<256> FilePath = CrossTUDir;
-  if (llvm::sys::path::is_absolute(FileName))
+  if (CrossTUDir.empty())
 FilePath = FileName;
   else
 llvm::sys::path::append(FilePath, FileName);


Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -109,9 +109,9 @@
 
 TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
   llvm::StringMap Index;
-  Index["a"] = "b";
-  Index["c"] = "d";
-  Index["e"] = "f";
+  Index["a"] = "/b/f1";
+  Index["c"] = "/d/f2";
+  Index["e"] = "/f/f3";
   std::string IndexText = createCrossTUIndexString(Index);
 
   int IndexFD;
@@ -134,5 +134,25 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
+TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
+  llvm::StringMap Index;
+  Index["a"] = "/b/c/d";
+  std::string IndexText = createCrossTUIndexString(Index);
+
+  int IndexFD;
+  llvm::SmallString<256> IndexFileName;
+  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
+  IndexFileName));
+  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
+  IndexFile.os() << IndexText;
+  IndexFile.os().flush();
+  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+  llvm::Expected> IndexOrErr =
+  parseCrossTUIndex(IndexFileName, "/ctudir");
+  EXPECT_TRUE((bool)IndexOrErr);
+  llvm::StringMap ParsedIndex = IndexOrErr.get();
+  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
+}
+
 } // end namespace cross_tu
 } // end namespace clang
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -93,7 +93,7 @@
 index_error_code::multiple_definitions, IndexPath.str(), LineNo);
   StringRef FileName = LineRef.substr(Pos + 1);
   SmallString<256> FilePath = CrossTUDir;
-  if (llvm::sys::path::is_absolute(FileName))
+  if (CrossTUDir.empty())
 FilePath = FileName;
   else
 llvm::sys::path::append(FilePath, FileName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38843: [ASTImporter] Support importing CXXPseudoDestructorExpr

2017-10-12 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.

Adding VisitCXXPseudoDestructorExpr callback to the ASTImporter.

Note: This is based on: 
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7624
 .


https://reviews.llvm.org/D38843

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -535,5 +535,21 @@
  binaryOperator(has(cxxUnresolvedConstructExpr()));
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxPseudoDestructorExpr;
+
+TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("typedef int T;"
+ "void declToImport(int *p) {"
+ "p->T::~T();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(has(compoundStmt(has(
+ callExpr(has(cxxPseudoDestructorExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -278,6 +278,7 @@
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
+Expr *VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
 Expr *VisitMemberExpr(MemberExpr *E);
 Expr *VisitCallExpr(CallExpr *E);
 Expr *VisitInitListExpr(InitListExpr *E);
@@ -5540,6 +5541,38 @@
   E->isOverloaded(), ToDecls.begin(), ToDecls.end());
 }
 
+
+Expr *ASTNodeImporter::VisitCXXPseudoDestructorExpr(
+CXXPseudoDestructorExpr *E) {
+
+  Expr *BaseE = Importer.Import(E->getBase());
+  if (!BaseE)
+return nullptr;
+
+  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
+
+  PseudoDestructorTypeStorage Storage;
+  if (IdentifierInfo *FromII = E->getDestroyedTypeIdentifier()) {
+IdentifierInfo *ToII = Importer.Import(FromII);
+if (!ToII)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(
+  ToII, Importer.Import(E->getDestroyedTypeLoc()));
+  } else {
+TypeSourceInfo *TI = Importer.Import(E->getDestroyedTypeInfo());
+if (!TI)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(TI);
+  }
+
+  return new (Importer.getToContext()) CXXPseudoDestructorExpr(
+Importer.getToContext(), BaseE, E->isArrow(),
+Importer.Import(E->getOperatorLoc()),
+Importer.Import(E->getQualifierLoc()),
+ScopeInfo, Importer.Import(E->getColonColonLoc()),
+Importer.Import(E->getTildeLoc()), Storage);
+}
+
 Expr *ASTNodeImporter::VisitCallExpr(CallExpr *E) {
   QualType T = Importer.Import(E->getType());
   if (T.isNull())


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -535,5 +535,21 @@
  binaryOperator(has(cxxUnresolvedConstructExpr()));
 }
 
+const internal::VariadicDynCastAllOfMatcher
+cxxPseudoDestructorExpr;
+
+TEST(ImportExpr, ImportCXXPseudoDestructorExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("typedef int T;"
+ "void declToImport(int *p) {"
+ "p->T::~T();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(has(compoundStmt(has(
+ callExpr(has(cxxPseudoDestructorExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -278,6 +278,7 @@
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
+Expr *VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
 Expr *VisitMemberExpr(MemberExpr *E);
 Expr *VisitCallExpr(CallExpr *E);
 Expr *VisitInitListExpr(InitListExpr *E);
@@ -5540,6 +5541,38 @@
   E->isOverloaded(), ToDecls.begin(), ToDecls.end());
 }
 
+
+Expr *ASTNodeImporter::VisitCXXPseudoDestructorExpr(
+CXXPseudoDestructorExpr *E) {
+
+  Expr *BaseE = Importer.Import(E->getBase());
+  if (!BaseE)
+return nullptr;
+
+  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
+
+  PseudoDestructorTypeStorage Storage;
+  if (IdentifierInfo *FromII = E->getDestroyedTypeIdentifier()) {
+IdentifierInfo *ToII = Importer.Import(FromII);
+if (!ToII)
+  return nullptr;
+Storage = PseudoDestructorTypeStorage(
+  ToII, Importer.Import(E->getDestroyedTypeLoc()));
+  } else {
+   

[PATCH] D38464: [clangd] less boilerplate in RPC dispatch

2017-10-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 118782.
sammccall added a comment.

Rebase


https://reviews.llvm.org/D38464

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/did-change-watch-files.test
  test/clangd/fixits.test

Index: test/clangd/fixits.test
===
--- test/clangd/fixits.test
+++ test/clangd/fixits.test
@@ -15,13 +15,13 @@
 
  {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
 #
-# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
 #
 Content-Length: 771
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"code":"1","source":"foo","message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
 # Make sure unused "code" and "source" fields ignored gracefully
-# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
 #
 Content-Length: 44
 
Index: test/clangd/did-change-watch-files.test

[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2017-10-12 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.

The visit callback implementations for the 3 C++ AST Node added to the 
ASTImporter.

Note: Based on: 
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp


https://reviews.llvm.org/D38845

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -551,5 +551,68 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher
+unresolvedMemberExpr;
+TEST(ImportExpr, ImportUnresolvedMemberExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("struct S { template  void mem(); };"
+ "template  void declToImport() {"
+ "S s;"
+ "s.mem();"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(
+ has(callExpr(has(unresolvedMemberExpr()));
+}
+
+const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr;
+TEST(ImportExpr, ImportDependentScopeDeclRefExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("template  struct S;"
+ "template  void declToImport() {"
+ "S::foo;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(
+ has(dependentScopeDeclRefExpr();
+
+  EXPECT_TRUE(testImport("template  struct S;"
+ "template  void declToImport() {"
+ "S::template foo;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(
+ has(dependentScopeDeclRefExpr();
+
+  EXPECT_TRUE(testImport("template  struct S;"
+ "template  void declToImport() {"
+ "S::template foo<>;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(
+ has(dependentScopeDeclRefExpr();
+
+  EXPECT_TRUE(testImport("template  struct S;"
+ "template  void declToImport() {"
+ "S::template foo;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(
+ has(dependentScopeDeclRefExpr();
+}
+
+const internal::VariadicDynCastAllOfMatcher
+dependentNameType;
+TEST(ImportExpr, DependentNameType) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("template  struct declToImport {"
+ "typedef typename T::type dependent_name;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(typedefDecl(has(dependentNameType();
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -76,7 +76,7 @@
 QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T);
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
-// FIXME: DependentNameType
+QualType VisitDependentNameType(const DependentNameType *T);
 // FIXME: DependentTemplateSpecializationType
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 QualType VisitObjCObjectType(const ObjCObjectType *T);
@@ -273,8 +273,10 @@
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
 Expr *VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
 Expr *VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+Expr *VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
 Expr *VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *CE);
 Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
+Expr *VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
@@ -774,6 +776,25 @@
ToQualifier, ToNamedType);
 }
 
+QualType ASTNodeImporter::VisitDependentNameType(const DependentNameType *T) {
+  NestedNameSpecifier *NNS = Importer.Import(T

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-12 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 118784.
arichardson added a comment.

Removed the additional namespace


https://reviews.llvm.org/D38816

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypeCache.h
  lib/CodeGen/ConstantEmitter.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -398,12 +398,8 @@
 
 unsigned clang_getAddressSpace(CXType CT) {
   QualType T = GetQualType(CT);
-
-  // For non language-specific address space, use separate helper function.
-  if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
-return T.getQualifiers().getAddressSpaceAttributePrintValue();
-  }
-  return T.getAddressSpace();
+  ASTContext &Ctx = cxtu::getASTUnit(GetTU(CT))->getASTContext();
+  return Ctx.getTargetAddressSpace(T);
 }
 
 CXString clang_getTypedefName(CXType CT) {
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5632,7 +5632,7 @@
 // If this type is already address space qualified, reject it.
 // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified
 // by qualifiers for two or more different address spaces."
-if (T.getAddressSpace()) {
+if (T.getAddressSpace() != LangAS::Default) {
   Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers);
   return QualType();
 }
@@ -5656,15 +5656,16 @@
 }
 
 llvm::APSInt max(addrSpace.getBitWidth());
-max = Qualifiers::MaxAddressSpace - LangAS::FirstTargetAddressSpace;
+max =
+Qualifiers::MaxAddressSpace - (unsigned)LangAS::FirstTargetAddressSpace;
 if (addrSpace > max) {
   Diag(AttrLoc, diag::err_attribute_address_space_too_high)
   << (unsigned)max.getZExtValue() << AddrSpace->getSourceRange();
   return QualType();
 }
 
-unsigned ASIdx = static_cast(addrSpace.getZExtValue()) +
- LangAS::FirstTargetAddressSpace;
+LangAS ASIdx =
+LangASFromTargetAS(static_cast(addrSpace.getZExtValue()));
 
 return Context.getAddrSpaceQualType(T, ASIdx);
   }
@@ -5690,7 +5691,7 @@
   // If this type is already address space qualified, reject it.
   // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified by
   // qualifiers for two or more different address spaces."
-  if (Type.getAddressSpace()) {
+  if (Type.getAddressSpace() != LangAS::Default) {
 S.Diag(Attr.getLoc(), diag::err_attribute_address_multiple_qualifiers);
 Attr.setInvalid();
 return;
@@ -5704,7 +5705,7 @@
 return;
   }
 
-  unsigned ASIdx;
+  LangAS ASIdx;
   if (Attr.getKind() == AttributeList::AT_AddressSpace) {
 
 // Check the attribute arguments.
@@ -5754,7 +5755,8 @@
   ASIdx = LangAS::opencl_generic; break;
 default:
   assert(Attr.getKind() == AttributeList::AT_OpenCLPrivateAddressSpace);
-  ASIdx = 0; break;
+  ASIdx = LangAS::Default;
+  break;
 }
 
 Type = S.Context.getAddrSpaceQualType(Type, ASIdx);
@@ -7167,7 +7169,7 @@
   // Pointers that are declared without pointing to a named address space point
   // to the generic address space.
   if (state.getSema().getLangOpts().OpenCLVersion >= 200 &&
-  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == LangAS::Default &&
   (TAL == TAL_DeclSpec || TAL == TAL_DeclChunk)) {
 Declarator &D = state.getDeclarator();
 if (state.getCurrentChunkIndex() > 0 &&
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1870,11 +1870,10 @@
 Deduced);
   }
 
-  if (Arg.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
+  if (isTargetAddressSpace(Arg.getAddressSpace())) {
 llvm::APSInt ArgAddressSpace(S.Context.getTypeSize(S.Context.IntTy),
  false);
-ArgAddressSpace =
-(Arg.getAddressS

Re: [PATCH] D38464: [clangd] less boilerplate in RPC dispatch

2017-10-12 Thread Sam McCall via cfe-commits
Interesting - this is pretty primitive, and still fairly tightly coupled to
JSON-RPC.
I can't easily tell from the code how the ORC RPC functionality - would it
be easy to use with JSON-RPC, does it make sense to use serialization only,
does it have opinions about threading models? And really, what would we
expect to gain vs using the current more naive code (it looks more
complicated, probably having more complex requirements).

On Mon, Oct 9, 2017 at 11:16 PM, David Blaikie  wrote:

> hey Lang (& folks here) any chance there's some overlap between the RPC
> functionality here and the RPC functionality in ORC that could be
> deduplicated/refactored?
>
> On Fri, Oct 6, 2017 at 5:30 AM Ilya Biryukov via Phabricator via
> cfe-commits  wrote:
>
>> ilya-biryukov accepted this revision.
>> ilya-biryukov added a comment.
>> This revision is now accepted and ready to land.
>>
>> LGTM.
>> Note there's a new LSP method handler added upstream
>> (`textDocument/signatureHelp`), we should add it to this change before
>> submitting.
>>
>>
>>
>> 
>> Comment at: clangd/ClangdLSPServer.h:47
>>// Implement ProtocolCallbacks.
>> -  void onInitialize(StringRef ID, InitializeParams IP,
>> -JSONOutput &Out) override;
>> -  void onShutdown(JSONOutput &Out) override;
>> -  void onDocumentDidOpen(DidOpenTextDocumentParams Params,
>> - JSONOutput &Out) override;
>> -  void onDocumentDidChange(DidChangeTextDocumentParams Params,
>> -   JSONOutput &Out) override;
>> -  void onDocumentDidClose(DidCloseTextDocumentParams Params,
>> -  JSONOutput &Out) override;
>> -  void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params,
>> -  StringRef ID, JSONOutput &Out)
>> override;
>> -  void onDocumentRangeFormatting(DocumentRangeFormattingParams Params,
>> - StringRef ID, JSONOutput &Out) override;
>> -  void onDocumentFormatting(DocumentFormattingParams Params, StringRef
>> ID,
>> -JSONOutput &Out) override;
>> -  void onCodeAction(CodeActionParams Params, StringRef ID,
>> -JSONOutput &Out) override;
>> -  void onCompletion(TextDocumentPositionParams Params, StringRef ID,
>> -JSONOutput &Out) override;
>> -  void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
>> -JSONOutput &Out) override;
>> -  void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
>> -JSONOutput &Out) override;
>> +  void onInitialize(Ctx &C, InitializeParams &Params) override;
>> +  void onShutdown(Ctx &C, NoParams &Params) override;
>> 
>> sammccall wrote:
>> > ilya-biryukov wrote:
>> > > ilya-biryukov wrote:
>> > > > Maybe there's a way to have a typed return value instead of `Ctx`?
>> > > > This would give an interface that's harder to misuse: one can't
>> forget to call `reply` or call it twice.
>> > > >
>> > > > Here's on design that comes to mind.
>> > > > Notification handlers could have `void` return, normal requests can
>> return `Optional` or `Optional` (with result json).
>> > > > `Optional` is be used to indicate whether error occurred while
>> processing the request.
>> > > >
>> > > After putting more thought into it, `Ctx`-based API seems to have an
>> advantage: it will allow us to easily implement async responses.
>> > > E.g., we can run code completion on a background thread and continue
>> processing other requests. When completion is ready, we will simply call
>> `Ctx.reply` to return results to the language client.
>> > >
>> > > To make that possible, can we allow moving `RequestContext` and pass
>> it by-value instead of by-ref?
>> > Yeah I thought about returning a value... it certainly reads more
>> nicely, but I don't think we're ready to do a good job in this patch:
>> >  - return value should be an object ready to be serialized (rather than
>> a JSON string) - I don't want to bring that in scope here, but it might
>> affect the details of the API
>> >  - there's several cases we know about (return object, no reply, error
>> reply) and some we're not sure about (async as you mention - any multiple
>> responses)? I think this needs some design, and I don't yet know the
>> project well enough to drive it.
>> >
>> > I've switched to passing Ctx by value as you suggest (though it's
>> certainly cheap enough to copy, too).
>> Yeah, copy is also fine there performance-wise.
>>
>> I do think move-only interface fits slightly better. We can check a whole
>> bunch of invariants if `Ctx` is move-only (i.e., that request wasn't
>> dropped without response or `reply` was not called twice).
>>
>>
>> 
>> Comment at: clangd/ClangdLSPServer.h:48
>> +  void onInitialize(Ctx &C, InitializeParams &Params) override;
>> +  void onShutdown(Ctx &C, NoParams &Params) override;
>> +  void onDocumentDid

[clang-tools-extra] r315577 - [clangd] less boilerplate in RPC dispatch

2017-10-12 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Oct 12 06:29:58 2017
New Revision: 315577

URL: http://llvm.org/viewvc/llvm-project?rev=315577&view=rev
Log:
[clangd] less boilerplate in RPC dispatch

Summary:
Make the ProtocolHandlers glue between JSONRPCDispatcher and
ClangdLSPServer generic.
Eliminate small differences between methods, de-emphasize the unimportant
distinction between notifications and methods.

ClangdLSPServer is no longer responsible for producing a complete
JSON-RPC response, just the JSON of the result object. (In future, we
should move that JSON serialization out, too).
Handler methods now take a context object that we may hang more
functionality off in the future.

Added documentation to ProtocolHandlers.

Reviewers: ilya-biryukov, bkramer

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/test/clangd/did-change-watch-files.test
clang-tools-extra/trunk/test/clangd/fixits.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=315577&r1=315576&r2=315577&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Oct 12 06:29:58 2017
@@ -37,11 +37,9 @@ replacementsToEdits(StringRef Code,
 
 } // namespace
 
-void ClangdLSPServer::onInitialize(StringRef ID, InitializeParams IP,
-   JSONOutput &Out) {
-  Out.writeMessage(
-  R"({"jsonrpc":"2.0","id":)" + ID +
-  R"(,"result":{"capabilities":{
+void ClangdLSPServer::onInitialize(Ctx C, InitializeParams &Params) {
+  C.reply(
+  R"({"capabilities":{
   "textDocumentSync": 1,
   "documentFormattingProvider": true,
   "documentRangeFormattingProvider": true,
@@ -50,73 +48,68 @@ void ClangdLSPServer::onInitialize(Strin
   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
   "definitionProvider": true
-}}})");
-  if (IP.rootUri && !IP.rootUri->file.empty())
-Server.setRootPath(IP.rootUri->file);
-  else if (IP.rootPath && !IP.rootPath->empty())
-Server.setRootPath(*IP.rootPath);
+}})");
+  if (Params.rootUri && !Params.rootUri->file.empty())
+Server.setRootPath(Params.rootUri->file);
+  else if (Params.rootPath && !Params.rootPath->empty())
+Server.setRootPath(*Params.rootPath);
 }
 
-void ClangdLSPServer::onShutdown(JSONOutput &Out) { IsDone = true; }
+void ClangdLSPServer::onShutdown(Ctx C, ShutdownParams &Params) {
+  IsDone = true;
+}
 
-void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams Params,
-JSONOutput &Out) {
+void ClangdLSPServer::onDocumentDidOpen(Ctx C,
+DidOpenTextDocumentParams &Params) {
   if (Params.metadata && !Params.metadata->extraFlags.empty())
 CDB.setExtraFlagsForFile(Params.textDocument.uri.file,
  std::move(Params.metadata->extraFlags));
   Server.addDocument(Params.textDocument.uri.file, Params.textDocument.text);
 }
 
-void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams Params,
-  JSONOutput &Out) {
+void ClangdLSPServer::onDocumentDidChange(Ctx C,
+  DidChangeTextDocumentParams &Params) 
{
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file,
  Params.contentChanges[0].text);
 }
 
-void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams &Params) {
+void ClangdLSPServer::onFileEvent(Ctx C, DidChangeWatchedFilesParams &Params) {
   Server.onFileEvent(Params);
 }
 
-void ClangdLSPServer::onDocumentDidClose(DidCloseTextDocumentParams Params,
- JSONOutput &Out) {
+void ClangdLSPServer::onDocumentDidClose(Ctx C,
+ DidCloseTextDocumentParams &Params) {
   Server.removeDocument(Params.textDocument.uri.file);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
-DocumentOnTypeFormattingParams Params, StringRef ID, JSONOutput &Out) {
+Ctx C, DocumentOnTypeFormattingParams &Params) {
   auto File = Params.textDocument.uri.file;
   std::string Code = Server.getDocument(

[PATCH] D38464: [clangd] less boilerplate in RPC dispatch

2017-10-12 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315577: [clangd] less boilerplate in RPC dispatch (authored 
by sammccall).

Repository:
  rL LLVM

https://reviews.llvm.org/D38464

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/clangd/ProtocolHandlers.h
  clang-tools-extra/trunk/test/clangd/did-change-watch-files.test
  clang-tools-extra/trunk/test/clangd/fixits.test

Index: clang-tools-extra/trunk/test/clangd/fixits.test
===
--- clang-tools-extra/trunk/test/clangd/fixits.test
+++ clang-tools-extra/trunk/test/clangd/fixits.test
@@ -15,13 +15,13 @@
 
  {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
 #
-# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
 #
 Content-Length: 771
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":2,"code":"1","source":"foo","message":"using the result of an assignment as a condition without parentheses"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"place parentheses around the assignment to silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end": {"line": 0, "character": 35}},"severity":3,"message":"use '==' to turn this assignment into an equality comparison"}]}}}
 # Make sure unused "code" and "source" fields ignored gracefully
-# CHECK: {"jsonrpc":"2.0","id":2, "result": [{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText": ")"}]]},{"title":"Apply FixIt 'use '==' to turn this assignment into an equality comparison'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}}, "newText": "=="}]]}]
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[{"title":"Apply FixIt 'place parentheses around the assignment to silence this warning'", "command": "clangd.applyFix", "arguments": ["file:///foo.c", [{"range": {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end": {"line": 0, "charact

[PATCH] D33989: [OpenCL] Allow targets to select address space per type

2017-10-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: cfe/trunk/lib/Basic/TargetInfo.cpp:351
 
+LangAS::ID TargetInfo::getOpenCLTypeAddrSpace(const Type *T) const {
+  auto BT = dyn_cast(T);

chapuni wrote:
> Excuse me for old commit, I think it might be layering violation.
> Could we avoid using AST/Type here?
One of the problems is that even if we could write another layer of enums to 
map OpenCL specific AST types into the TargetInfo representation it doesn't 
really help creating a layered structure between AST and Basic libs.  They seem 
to have a large logical dependence despite not including the library headers 
physically. So modification in AST would require modifications in Basic anyway 
resulting in overhead of changing 2 places instead of 1. So I am wondering if 
there is any better approach here e.g. revisiting the library dependencies or 
what classes they should contain?


Repository:
  rL LLVM

https://reviews.llvm.org/D33989



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


r315578 - [OPENMP] Fix PR34925: Fix getting thread_id lvalue for inlined regions

2017-10-12 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 12 06:51:32 2017
New Revision: 315578

URL: http://llvm.org/viewvc/llvm-project?rev=315578&view=rev
Log:
[OPENMP] Fix PR34925: Fix getting thread_id lvalue for inlined regions
in C.

If we try to get the lvalue for thread_id variables in inlined regions,
we did not use the correct version of function. Fixed this bug by adding
overrided version of the function getThreadIDVariableLValue for inlined
regions.

Added:
cfe/trunk/test/OpenMP/task_codegen.c
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315578&r1=315577&r2=315578&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 12 06:51:32 2017
@@ -265,6 +265,13 @@ public:
 return nullptr;
   }
 
+  /// \brief Get an LValue for the current ThreadID variable.
+  LValue getThreadIDVariableLValue(CodeGenFunction &CGF) override {
+if (OuterRegionInfo)
+  return OuterRegionInfo->getThreadIDVariableLValue(CGF);
+llvm_unreachable("No LValue for inlined OpenMP construct");
+  }
+
   /// \brief Get the name of the capture helper.
   StringRef getHelperName() const override {
 if (auto *OuterRegionInfo = getOldCSI())

Added: cfe/trunk/test/OpenMP/task_codegen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_codegen.c?rev=315578&view=auto
==
--- cfe/trunk/test/OpenMP/task_codegen.c (added)
+++ cfe/trunk/test/OpenMP/task_codegen.c Thu Oct 12 06:51:32 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t 
%s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void foo();
+
+// CHECK-LABEL: @main
+int main() {
+  // CHECK: call i32 @__kmpc_global_thread_num(
+  // CHECK: call i8* @__kmpc_omp_task_alloc(
+  // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+  {
+#pragma omp taskgroup
+{
+#pragma omp task
+  foo();
+}
+  }
+  // CHECK: ret i32 0
+  return 0;
+}
+// CHECK: call void @__kmpc_taskgroup(
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
+// CHECK: call void @__kmpc_end_taskgroup(
+#endif


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


Re: [clang-tools-extra] r315057 - Fix nested namespaces in google-readability-nested-namespace-comments.

2017-10-12 Thread Alexander Kornienko via cfe-commits
On Fri, Oct 6, 2017 at 2:57 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Fri Oct  6 05:57:28 2017
> New Revision: 315057
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315057&view=rev
> Log:
> Fix nested namespaces in google-readability-nested-namespace-comments.
>
> Fixes PR34701.
>
> Patch by Alexandru Octavian Buțiu.
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.cpp
> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h
>
> Modified: clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=
> 315057&r1=315056&r2=315057&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
> Fri Oct  6 05:57:28 2017
> @@ -23,7 +23,7 @@ NamespaceCommentCheck::NamespaceCommentC
>   ClangTidyContext *Context)
>  : ClangTidyCheck(Name, Context),
>NamespaceCommentPattern("^/[/*] *(end (of )?)?
> *(anonymous|unnamed)? *"
> -  "namespace( +([a-zA-Z0-9_]+))?\\.?
> *(\\*/)?$",
> +  "namespace( +([a-zA-Z0-9_:]+))?\\.?
> *(\\*/)?$",
>llvm::Regex::IgnoreCase),
>ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
>SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
> @@ -56,6 +56,15 @@ static std::string getNamespaceComment(c
>return Fix;
>  }
>
> +static std::string getNamespaceComment(const std::string &NameSpaceName,
> +   bool InsertLineBreak) {
> +  std::string Fix = "// namespace ";
> +  Fix.append(NameSpaceName);
> +  if (InsertLineBreak)
> +Fix.append("\n");
> +  return Fix;
> +}
> +
>  void NamespaceCommentCheck::check(const MatchFinder::MatchResult
> &Result) {
>const auto *ND = Result.Nodes.getNodeAs("namespace");
>const SourceManager &Sources = *Result.SourceManager;
> @@ -74,11 +83,38 @@ void NamespaceCommentCheck::check(const
>SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
>SourceLocation Loc = AfterRBrace;
>Token Tok;
> +  SourceLocation LBracketLocation = ND->getLocation();
> +  SourceLocation NestedNamespaceBegin = LBracketLocation;
> +
> +  // Currently for nested namepsace (n1::n2::...) the AST matcher will
> match foo
> +  // then bar instead of a single match. So if we got a nested namespace
> we have
> +  // to skip the next ones.
> +  for (const auto &EndOfNameLocation : Ends) {
> +if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
> +  EndOfNameLocation))
> +  return;
> +  }
> +  while (Lexer::getRawToken(LBracketLocation, Tok, Sources,
> getLangOpts()) ||
> + !Tok.is(tok::l_brace)) {
>

Now another issue with this revision: the check started triggering an
assertion failure and incredible slowness (infinite loops?) on some real
files. I've not yet come up with an isolated test case, but all this seems
to be happening around this loop.

I'm going to revert this revision.


> +LBracketLocation = LBracketLocation.getLocWithOffset(1);
> +  }
> +
> +  auto TextRange =
> +  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin,
> LBracketLocation),
> +Sources, getLangOpts());
> +  auto NestedNamespaceName =
> +  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
> +  bool IsNested = NestedNamespaceName.contains(':');
> +
> +  if (IsNested)
> +Ends.push_back(LBracketLocation);
> +
>// Skip whitespace until we find the next token.
>while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
>   Tok.is(tok::semi)) {
>  Loc = Loc.getLocWithOffset(1);
>}
> +
>if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
>  return;
>
> @@ -98,10 +134,14 @@ void NamespaceCommentCheck::check(const
>StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] :
> "";
>StringRef Anonymous = Groups.size() > 3 ? Groups[3] : "";
>
> -  // Check if the namespace in the comment is the same.
> -  if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty())
> ||
> -  (ND->getNameAsString() == NamespaceNameInComment &&
> -   Anonymous.empty())) {
> +  if (IsNested && NestedNamespaceName == NamespaceNameInComment) {
> +// C++17 nested namespace.
> +return;
> +  } else if ((ND->isAnonymousNamespace() &&
> +  NamespaceNameInComment.empty()) ||
> +

Re: [clang-tools-extra] r315057 - Fix nested namespaces in google-readability-nested-namespace-comments.

2017-10-12 Thread Aaron Ballman via cfe-commits
On Thu, Oct 12, 2017 at 10:01 AM, Alexander Kornienko  wrote:
>
> On Fri, Oct 6, 2017 at 2:57 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Fri Oct  6 05:57:28 2017
>> New Revision: 315057
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315057&view=rev
>> Log:
>> Fix nested namespaces in google-readability-nested-namespace-comments.
>>
>> Fixes PR34701.
>>
>> Patch by Alexandru Octavian Buțiu.
>>
>> Added:
>>
>> clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=315057&r1=315056&r2=315057&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp Fri
>> Oct  6 05:57:28 2017
>> @@ -23,7 +23,7 @@ NamespaceCommentCheck::NamespaceCommentC
>>   ClangTidyContext *Context)
>>  : ClangTidyCheck(Name, Context),
>>NamespaceCommentPattern("^/[/*] *(end (of )?)?
>> *(anonymous|unnamed)? *"
>> -  "namespace( +([a-zA-Z0-9_]+))?\\.?
>> *(\\*/)?$",
>> +  "namespace( +([a-zA-Z0-9_:]+))?\\.?
>> *(\\*/)?$",
>>llvm::Regex::IgnoreCase),
>>ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
>>SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
>> @@ -56,6 +56,15 @@ static std::string getNamespaceComment(c
>>return Fix;
>>  }
>>
>> +static std::string getNamespaceComment(const std::string &NameSpaceName,
>> +   bool InsertLineBreak) {
>> +  std::string Fix = "// namespace ";
>> +  Fix.append(NameSpaceName);
>> +  if (InsertLineBreak)
>> +Fix.append("\n");
>> +  return Fix;
>> +}
>> +
>>  void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result)
>> {
>>const auto *ND = Result.Nodes.getNodeAs("namespace");
>>const SourceManager &Sources = *Result.SourceManager;
>> @@ -74,11 +83,38 @@ void NamespaceCommentCheck::check(const
>>SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
>>SourceLocation Loc = AfterRBrace;
>>Token Tok;
>> +  SourceLocation LBracketLocation = ND->getLocation();
>> +  SourceLocation NestedNamespaceBegin = LBracketLocation;
>> +
>> +  // Currently for nested namepsace (n1::n2::...) the AST matcher will
>> match foo
>> +  // then bar instead of a single match. So if we got a nested namespace
>> we have
>> +  // to skip the next ones.
>> +  for (const auto &EndOfNameLocation : Ends) {
>> +if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
>> +  EndOfNameLocation))
>> +  return;
>> +  }
>> +  while (Lexer::getRawToken(LBracketLocation, Tok, Sources,
>> getLangOpts()) ||
>> + !Tok.is(tok::l_brace)) {
>
>
> Now another issue with this revision: the check started triggering an
> assertion failure and incredible slowness (infinite loops?) on some real
> files. I've not yet come up with an isolated test case, but all this seems
> to be happening around this loop.
>
> I'm going to revert this revision.

I think that's the right call. The original review thread is
https://reviews.llvm.org/D38284 if you want to alert the author.

~Aaron

>
>>
>> +LBracketLocation = LBracketLocation.getLocWithOffset(1);
>> +  }
>> +
>> +  auto TextRange =
>> +  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin,
>> LBracketLocation),
>> +Sources, getLangOpts());
>> +  auto NestedNamespaceName =
>> +  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
>> +  bool IsNested = NestedNamespaceName.contains(':');
>> +
>> +  if (IsNested)
>> +Ends.push_back(LBracketLocation);
>> +
>>// Skip whitespace until we find the next token.
>>while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
>>   Tok.is(tok::semi)) {
>>  Loc = Loc.getLocWithOffset(1);
>>}
>> +
>>if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
>>  return;
>>
>> @@ -98,10 +134,14 @@ void NamespaceCommentCheck::check(const
>>StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] :
>> "";
>>StringRef Anonymous = Groups.size() > 3 ? Groups[3] : "";
>>
>> -  // Check if the namespace in the comment is the same.
>> -  if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty())
>> ||
>> -  (ND->getNameAsString() == NamespaceNameInCom

[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces

2017-10-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:97
+  }
+  while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
+ !Tok.is(tok::l_brace)) {

The check started triggering an assertion failure and incredible slowness 
(infinite loops?) on some real files. I've not yet come up with an isolated 
test case, but all this seems to be happening around this loop.

I'm going to revert this revision. A bug report (and hopefully a test case ;) 
will follow.



https://reviews.llvm.org/D38284



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


[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

2017-10-12 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

looks good.


https://reviews.llvm.org/D37695



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


[clang-tools-extra] r315580 - Revert "Fix nested namespaces in google-readability-nested-namespace-comments."

2017-10-12 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Oct 12 07:25:16 2017
New Revision: 315580

URL: http://llvm.org/viewvc/llvm-project?rev=315580&view=rev
Log:
Revert "Fix nested namespaces in google-readability-nested-namespace-comments."

This reverts r315057. The revision introduces assertion failures:
assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in
const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion()
const: isExpansion() && "Not a macro expansion SLocEntry!"
Stack trace:
__assert_fail
clang::SrcMgr::SLocEntry::getExpansion()
clang::SourceManager::getExpansionLocSlowCase()
clang::SourceManager::getExpansionLoc()
clang::Lexer::getRawToken()
clang::tidy::readability::NamespaceCommentCheck::check()
clang::ast_matchers::internal::(anonymous 
namespace)::MatchASTVisitor::MatchVisitor::visitMatch()
clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches()
clang::ast_matchers::internal::(anonymous 
namespace)::MatchASTVisitor::matchWithFilter()
clang::ast_matchers::internal::(anonymous 
namespace)::MatchASTVisitor::matchDispatch()
clang::ast_matchers::internal::(anonymous 
namespace)::MatchASTVisitor::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::ast_matchers::MatchFinder::matchAST()
clang::MultiplexConsumer::HandleTranslationUnit()
clang::ParseAST()
clang::FrontendAction::Execute()
clang::CompilerInstance::ExecuteAction()
clang::tooling::FrontendActionFactory::runInvocation()
clang::tooling::ToolInvocation::runInvocation()
clang::tooling::ToolInvocation::run()

Still working on an isolated test case.

Removed:

clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments-cxx17.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=315580&r1=315579&r2=315580&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp 
Thu Oct 12 07:25:16 2017
@@ -23,7 +23,7 @@ NamespaceCommentCheck::NamespaceCommentC
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "namespace( +([a-zA-Z0-9_:]+))?\\.? *(\\*/)?$",
+  "namespace( +([a-zA-Z0-9_]+))?\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase),
   ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
   SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
@@ -56,15 +56,6 @@ static std::string getNamespaceComment(c
   return Fix;
 }
 
-static std::string getNamespaceComment(const std::string &NameSpaceName,
-   bool InsertLineBreak) {
-  std::string Fix = "// namespace ";
-  Fix.append(NameSpaceName);
-  if (InsertLineBreak)
-Fix.append("\n");
-  return Fix;
-}
-
 void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ND = Result.Nodes.getNodeAs("namespace");
   const SourceManager &Sources = *Result.SourceManager;
@@ -83,38 +74,11 @@ void NamespaceCommentCheck::check(const
   SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
   SourceLocation Loc = AfterRBrace;
   Token Tok;
-  SourceLocation LBracketLocation = ND->getLocation();
-  SourceLocation NestedNamespaceBegin = LBracketLocation;
-
-  // Currently for nested namepsace (n1::n2::...) the AST matcher will match 
foo
-  // then bar instead of a single match. So if we got a nested namespace we 
have
-  // to skip the next ones.
-  for (const auto &EndOfNameLocation : Ends) {
-if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
-  EndOfNameLocation))
-  return;
-  }
-  while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
- !Tok.is(tok::l_brace)) {
-LBracketLocation = LBracketLocation.getLocWithOffset(1);
-  }
-
-  auto TextRange =
-  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin, 
LBracketLocation),
-Sources, getLangOpts());
-  auto NestedNamespaceName =
-  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rt

Re: [clang-tools-extra] r315057 - Fix nested namespaces in google-readability-nested-namespace-comments.

2017-10-12 Thread Alexander Kornienko via cfe-commits
Reverted in r315580.

On Thu, Oct 12, 2017 at 4:03 PM, Aaron Ballman 
wrote:

> On Thu, Oct 12, 2017 at 10:01 AM, Alexander Kornienko 
> wrote:
> >
> > On Fri, Oct 6, 2017 at 2:57 PM, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Fri Oct  6 05:57:28 2017
> >> New Revision: 315057
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=315057&view=rev
> >> Log:
> >> Fix nested namespaces in google-readability-nested-namespace-comments.
> >>
> >> Fixes PR34701.
> >>
> >> Patch by Alexandru Octavian Buțiu.
> >>
> >> Added:
> >>
> >> clang-tools-extra/trunk/test/clang-tidy/google-readability-
> nested-namespace-comments.cpp
> >> Modified:
> >>
> >> clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.cpp
> >> clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.h
> >>
> >> Modified:
> >> clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/readability/NamespaceCommentCheck.cpp?rev=
> 315057&r1=315056&r2=315057&view=diff
> >>
> >> 
> ==
> >> ---
> >> clang-tools-extra/trunk/clang-tidy/readability/
> NamespaceCommentCheck.cpp
> >> (original)
> >> +++
> >> clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
> Fri
> >> Oct  6 05:57:28 2017
> >> @@ -23,7 +23,7 @@ NamespaceCommentCheck::NamespaceCommentC
> >>   ClangTidyContext *Context)
> >>  : ClangTidyCheck(Name, Context),
> >>NamespaceCommentPattern("^/[/*] *(end (of )?)?
> >> *(anonymous|unnamed)? *"
> >> -  "namespace( +([a-zA-Z0-9_]+))?\\.?
> >> *(\\*/)?$",
> >> +  "namespace( +([a-zA-Z0-9_:]+))?\\.?
> >> *(\\*/)?$",
> >>llvm::Regex::IgnoreCase),
> >>ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
> >>SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
> >> @@ -56,6 +56,15 @@ static std::string getNamespaceComment(c
> >>return Fix;
> >>  }
> >>
> >> +static std::string getNamespaceComment(const std::string
> &NameSpaceName,
> >> +   bool InsertLineBreak) {
> >> +  std::string Fix = "// namespace ";
> >> +  Fix.append(NameSpaceName);
> >> +  if (InsertLineBreak)
> >> +Fix.append("\n");
> >> +  return Fix;
> >> +}
> >> +
> >>  void NamespaceCommentCheck::check(const MatchFinder::MatchResult
> &Result)
> >> {
> >>const auto *ND = Result.Nodes.getNodeAs("namespace");
> >>const SourceManager &Sources = *Result.SourceManager;
> >> @@ -74,11 +83,38 @@ void NamespaceCommentCheck::check(const
> >>SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
> >>SourceLocation Loc = AfterRBrace;
> >>Token Tok;
> >> +  SourceLocation LBracketLocation = ND->getLocation();
> >> +  SourceLocation NestedNamespaceBegin = LBracketLocation;
> >> +
> >> +  // Currently for nested namepsace (n1::n2::...) the AST matcher will
> >> match foo
> >> +  // then bar instead of a single match. So if we got a nested
> namespace
> >> we have
> >> +  // to skip the next ones.
> >> +  for (const auto &EndOfNameLocation : Ends) {
> >> +if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin,
> >> +  EndOfNameLocation))
> >> +  return;
> >> +  }
> >> +  while (Lexer::getRawToken(LBracketLocation, Tok, Sources,
> >> getLangOpts()) ||
> >> + !Tok.is(tok::l_brace)) {
> >
> >
> > Now another issue with this revision: the check started triggering an
> > assertion failure and incredible slowness (infinite loops?) on some real
> > files. I've not yet come up with an isolated test case, but all this
> seems
> > to be happening around this loop.
> >
> > I'm going to revert this revision.
>
> I think that's the right call. The original review thread is
> https://reviews.llvm.org/D38284 if you want to alert the author.
>
> ~Aaron
>
> >
> >>
> >> +LBracketLocation = LBracketLocation.getLocWithOffset(1);
> >> +  }
> >> +
> >> +  auto TextRange =
> >> +  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin,
> >> LBracketLocation),
> >> +Sources, getLangOpts());
> >> +  auto NestedNamespaceName =
> >> +  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
> >> +  bool IsNested = NestedNamespaceName.contains(':');
> >> +
> >> +  if (IsNested)
> >> +Ends.push_back(LBracketLocation);
> >> +
> >>// Skip whitespace until we find the next token.
> >>while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
> >>   Tok.is(tok::semi)) {
> >>  Loc = Loc.getLocWithOffset(1);
> >>}
> >> +
> >>if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
> >>  return;
> >>
> >> @@ -98,10 +134,14 @@ void NamespaceCommentCheck::check(con

[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces

2017-10-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/NamespaceCommentCheck.cpp:97
+  }
+  while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
+ !Tok.is(tok::l_brace)) {

alexfh wrote:
> The check started triggering an assertion failure and incredible slowness 
> (infinite loops?) on some real files. I've not yet come up with an isolated 
> test case, but all this seems to be happening around this loop.
> 
> I'm going to revert this revision. A bug report (and hopefully a test case ;) 
> will follow.
> 
Reverted in r315580.


https://reviews.llvm.org/D38284



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


[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 118788.
xazax.hun added a comment.

- Rebase based on the dependent revision and minor cleanups


https://reviews.llvm.org/D38728

Files:
  lib/StaticAnalyzer/Core/IssueHash.cpp
  test/Analysis/bug_hash_test.cpp
  test/Analysis/edges-new.mm


Index: test/Analysis/edges-new.mm
===
--- test/Analysis/edges-new.mm
+++ test/Analysis/edges-new.mm
@@ -20288,7 +20288,7 @@
 // CHECK-NEXT:typeBad deallocator
 // CHECK-NEXT:
check_nameunix.MismatchedDeallocator
 // CHECK-NEXT:
-// CHECK-NEXT:
issue_hash_content_of_line_in_contextd9dbbf68db41ab74e2158f4b131abe34
+// CHECK-NEXT:
issue_hash_content_of_line_in_context046c88d1c91ff46d6506dff5ff880756
 // CHECK-NEXT:   issue_hash_function_offset0
 // CHECK-NEXT:   location
 // CHECK-NEXT:   
Index: test/Analysis/bug_hash_test.cpp
===
--- test/Analysis/bug_hash_test.cpp
+++ test/Analysis/bug_hash_test.cpp
@@ -71,15 +71,13 @@
 
 template 
 void f(T) {
-  clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void 
f(double)$27$clang_analyzer_hashDump(5);$Category}}
-   // 
expected-warning@-1{{debug.ExprInspection$void 
f(int)$27$clang_analyzer_hashDump(5);$Category}}
+  clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void 
f(T)$27$clang_analyzer_hashDump(5);$Category}}
 }
 
 template 
 struct TX {
   void f(T) {
-clang_analyzer_hashDump(5); // expected-warning 
{{debug.ExprInspection$void 
TX::f(double)$29$clang_analyzer_hashDump(5);$Category}}
- // 
expected-warning@-1{{debug.ExprInspection$void 
TX::f(int)$29$clang_analyzer_hashDump(5);$Category}}
+clang_analyzer_hashDump(5); // expected-warning 
{{debug.ExprInspection$void TX::f(T)$29$clang_analyzer_hashDump(5);$Category}}
   }
 };
 
@@ -99,11 +97,17 @@
 struct TTX {
   template
   void f(T, S) {
-clang_analyzer_hashDump(5); // expected-warning 
{{debug.ExprInspection$void TTX::f(int, 
int)$29$clang_analyzer_hashDump(5);$Category}}
+clang_analyzer_hashDump(5); // expected-warning 
{{debug.ExprInspection$void TTX::f(T, 
S)$29$clang_analyzer_hashDump(5);$Category}}
   }
 };
 
 void g() {
+  // TX and TX is instantiated from the same code with the same
+  // source locations. The same error happining in both of the instantiations
+  // should share the common hash. This means we should not include the
+  // template argument for these types in the function signature.
+  // Note that, we still want the hash to be different for explicit
+  // specializations.
   TX x;
   TX y;
   TX xl;
Index: lib/StaticAnalyzer/Core/IssueHash.cpp
===
--- lib/StaticAnalyzer/Core/IssueHash.cpp
+++ lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -33,6 +33,13 @@
 return "";
   std::string Signature;
 
+  // When a flow sensitive bug happens in templated code we should not generate
+  // distinct hash value for every instantiation. Use the signature from the
+  // primary template.
+  if (const FunctionDecl *InstantiatedFrom =
+  Target->getTemplateInstantiationPattern())
+Target = InstantiatedFrom;
+
   if (!isa(Target) && !isa(Target) &&
   !isa(Target))
 Signature.append(Target->getReturnType().getAsString()).append(" ");


Index: test/Analysis/edges-new.mm
===
--- test/Analysis/edges-new.mm
+++ test/Analysis/edges-new.mm
@@ -20288,7 +20288,7 @@
 // CHECK-NEXT:typeBad deallocator
 // CHECK-NEXT:check_nameunix.MismatchedDeallocator
 // CHECK-NEXT:
-// CHECK-NEXT:issue_hash_content_of_line_in_contextd9dbbf68db41ab74e2158f4b131abe34
+// CHECK-NEXT:issue_hash_content_of_line_in_context046c88d1c91ff46d6506dff5ff880756
 // CHECK-NEXT:   issue_hash_function_offset0
 // CHECK-NEXT:   location
 // CHECK-NEXT:   
Index: test/Analysis/bug_hash_test.cpp
===
--- test/Analysis/bug_hash_test.cpp
+++ test/Analysis/bug_hash_test.cpp
@@ -71,15 +71,13 @@
 
 template 
 void f(T) {
-  clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void f(double)$27$clang_analyzer_hashDump(5);$Category}}
-   // expected-warning@-1{{debug.ExprInspection$void f(int)$27$clang_analyzer_hashDump(5);$Category}}
+  clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void f(T)$27$clang_analyzer_hashDump(5);$Category}}
 }
 
 template 
 struct TX {
   void f(T) {
-clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void TX::f(double)$29$clang_analyzer_hashDump(5);$Category}}
- // expected-warning@-1{{debug.ExprInspection$void TX::f(int)$29$clang_analyzer_hashDump(5);$Category}}
+clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInsp

[libcxx] r315582 - More fuzzing infastructre - regex

2017-10-12 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Oct 12 07:48:09 2017
New Revision: 315582

URL: http://llvm.org/viewvc/llvm-project?rev=315582&view=rev
Log:
More fuzzing infastructre - regex

Added:
libcxx/trunk/test/libcxx/fuzzing/regex_ECMAScript.cpp
libcxx/trunk/test/libcxx/fuzzing/regex_POSIX.cpp
libcxx/trunk/test/libcxx/fuzzing/regex_awk.cpp
libcxx/trunk/test/libcxx/fuzzing/regex_egrep.cpp
libcxx/trunk/test/libcxx/fuzzing/regex_extended.cpp
libcxx/trunk/test/libcxx/fuzzing/regex_grep.cpp
Modified:
libcxx/trunk/fuzzing/fuzzing.cpp
libcxx/trunk/fuzzing/fuzzing.h

Modified: libcxx/trunk/fuzzing/fuzzing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/fuzzing/fuzzing.cpp?rev=315582&r1=315581&r2=315582&view=diff
==
--- libcxx/trunk/fuzzing/fuzzing.cpp (original)
+++ libcxx/trunk/fuzzing/fuzzing.cpp Thu Oct 12 07:48:09 2017
@@ -26,8 +26,7 @@
 #include "fuzzing.h"
 #include 
 #include 
-
-#include 
+#include 
 
 // If we had C++14, we could use the four iterator version of 
is_permutation
 
@@ -219,4 +218,59 @@ int partial_sort (const uint8_t *data, s
return 0;
 }
 
+
+// --  regex fuzzers
+
+static int regex_helper(const uint8_t *data, size_t size, 
std::regex::flag_type flag)
+{
+   if (size > 0)
+   {
+   try
+   {
+   std::string s((const char *)data, size);
+   std::regex re(s, flag);
+   return std::regex_match(s, re) ? 1 : 0;
+   } 
+   catch (std::regex_error &ex) {} 
+   }
+   return 0;   
+}
+
+
+int regex_ECMAScript (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::ECMAScript);
+   return 0;
+}
+
+int regex_POSIX (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::basic);
+   return 0;
+}
+
+int regex_extended (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::extended);
+   return 0;
+}
+
+int regex_awk (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::awk);
+   return 0;
+}
+
+int regex_grep (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::grep);
+   return 0;
+}
+
+int regex_egrep (const uint8_t *data, size_t size)
+{
+   (void) regex_helper(data, size, std::regex_constants::egrep);
+   return 0;
+}
+
 } // namespace fuzzing

Modified: libcxx/trunk/fuzzing/fuzzing.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/fuzzing/fuzzing.h?rev=315582&r1=315581&r2=315582&view=diff
==
--- libcxx/trunk/fuzzing/fuzzing.h (original)
+++ libcxx/trunk/fuzzing/fuzzing.h Thu Oct 12 07:48:09 2017
@@ -27,7 +27,15 @@ namespace fuzzing {
 
int nth_element  (const uint8_t *data, size_t size);
int partial_sort (const uint8_t *data, size_t size);
-   
+
+// Various flavors of regex
+   int regex_ECMAScript (const uint8_t *data, size_t size);
+   int regex_POSIX  (const uint8_t *data, size_t size);
+   int regex_extended   (const uint8_t *data, size_t size);
+   int regex_awk(const uint8_t *data, size_t size);
+   int regex_grep   (const uint8_t *data, size_t size);
+   int regex_egrep  (const uint8_t *data, size_t size);
+
 } // namespace fuzzing
 
 #endif // _LIBCPP_FUZZING

Added: libcxx/trunk/test/libcxx/fuzzing/regex_ECMAScript.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/fuzzing/regex_ECMAScript.cpp?rev=315582&view=auto
==
--- libcxx/trunk/test/libcxx/fuzzing/regex_ECMAScript.cpp (added)
+++ libcxx/trunk/test/libcxx/fuzzing/regex_ECMAScript.cpp Thu Oct 12 07:48:09 
2017
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===- regex_ECMAScript.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// XFAIL
+
+#include "fuzzing.h"
+#include 
+#include  // for strlen
+
+const char * test_cases[] = {
+   "",
+   "s",
+   "b*c",
+   "ba?sf"
+   "lka*ea",
+   "adsf*kas;lnc441[0-9]1r34525234"
+   };
+
+const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
+
+int main ()
+{
+   for (size_t i = 0; i < k_num_tests; ++i)
+   {
+   const size_t   size = std::strlen(test_cases[i]);
+   const uint8_t *data = (const uint8_t *) test_cases[i];
+   assert(0 == fuzzing::regex_ECMAScript(data, size));
+

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I think it would be good to add a block test to CodeGenOpenCL where we would 
just call the block without any enqueue and check that the invoke function is 
generated but the kernel wrapper isn't.




Comment at: lib/CodeGen/CGBuiltin.cpp:2846
+  PtrToSizeArray};
+  std::vector ArgTys = {QueueTy,
+  IntTy,

Formatting seems inconsistent from above.



Comment at: lib/CodeGen/CodeGenFunction.h:2921
 private:
-  /// Helpers for blocks
-  llvm::Value *EmitBlockLiteral(const CGBlockInfo &Info);
+  /// Helpers for blocks. Returns invoke function by \p InvokeF if it is not
+  /// nullptr.

It will be nullptr in case block is not enqueued? May be it's worth explaining 
it in the comment.



Comment at: lib/CodeGen/TargetInfo.h:290
   }
+  /// Create an OpenCL kernel for an enqueued block.
+  virtual llvm::Function *

Can we also explain the wrapper kernel here?


https://reviews.llvm.org/D38134



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/AST/TypePrinter.cpp:1323
 OS << "address_space(";
-OS << T->getEquivalentType().getAddressSpace();
+OS << T->getEquivalentType()
+  .getQualifiers()

Why do we need this change?


https://reviews.llvm.org/D38816



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


r315586 - [OPENMP] Fix PR34926: Fix handling of the array sections passed as

2017-10-12 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 12 08:18:41 2017
New Revision: 315586

URL: http://llvm.org/viewvc/llvm-project?rev=315586&view=rev
Log:
[OPENMP] Fix PR34926: Fix handling of the array sections passed as
function params.

Codegen could crash if the array section base expression is the
function parameter.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315586&r1=315585&r2=315586&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 12 08:18:41 2017
@@ -3349,12 +3349,7 @@ static Address emitOMPArraySectionBase(C
 
 LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
 bool IsLowerBound) {
-  QualType BaseTy;
-  if (auto *ASE =
-  dyn_cast(E->getBase()->IgnoreParenImpCasts()))
-BaseTy = OMPArraySectionExpr::getBaseOriginalType(ASE);
-  else
-BaseTy = E->getBase()->getType();
+  QualType BaseTy = OMPArraySectionExpr::getBaseOriginalType(E->getBase());
   QualType ResultExprTy;
   if (auto *AT = getContext().getAsArrayType(BaseTy))
 ResultExprTy = AT->getElementType();

Modified: cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp?rev=315586&r1=315585&r2=315586&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp Thu Oct 12 08:18:41 
2017
@@ -80,6 +80,14 @@ struct SST {
 // CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { 
i32 0, i32 18, i32 0, i32 0, i8*
 // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
 
+//CHECK: foo_array_sect
+//CHECK: call void {{.+}}@__kmpc_fork_call(
+//CHECK: ret void
+void foo_array_sect(short x[1]) {
+#pragma omp parallel reduction(+ : x[:])
+  {}
+}
+
 template 
 T tmain() {
   T t;


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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-12 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

I have tested this on one of my machines after removing the checks for soft 
float (my debian install doesn't have the necessary headers for soft-float). 
With the patch you've pointed out and my inline comments addressed (bar the HI 
/ LO register comments), it passes the supplied test suite.

Can you change the checks for ABI from '_MIPS_SIM == $ABI' to 'defined($ABI)'? 
I mistakenly assumed they were always defined and that _MIPS_SIM was defined to 
be one of them but they are only defined when that particular ABI is being used.




Comment at: include/libunwind.h:584
+  UNW_MIPS_R31 = 31,
+};
+

Requires HI / LO registers.



Comment at: src/Registers.hpp:2014
+uint32_t __pc;
+  };
+

This appears to be missing the HI / LO registers.



Comment at: src/Registers.hpp:2039
+return true;
+  // FIXME: Hard float
+  return false;

FIXME: Hard float, DSP accumulator registers, MSA registers



Comment at: src/UnwindRegistersSave.S:120-122
+  jr   $31
+  # fp (in delay slot)
+  sw$30, (4 * 30)($4)

Move the last store out of the delay slot and put 'or $2, $zero, $zero' in the 
delay slot to return UNW_ESUCCESS.



Comment at: src/UnwindRegistersSave.S:155-157
+  jr   $31
+  # fp (in delay slot)
+  sd$30, (8 * 30)($4)

Move the last store out of the delay slot and put 'or $2, $zero, $zero' in the 
delay slot to return UNW_ESUCCESS.


https://reviews.llvm.org/D38110



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


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 118793.
lebedev.ri marked 4 inline comments as done.
lebedev.ri added a comment.

@rsmith, thank you for the review!

Rebased, address review notes, simplified all the things even further.

Testing:

- `$ ninja check-clang-sema check-clang-semacxx`
- Stage 2 build (still good, no issues/warnings)


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,47 +1,370 @@
 // RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
 
-unsigned value(void);
+unsigned uvalue(void);
+signed int svalue(void);
 
-int main() {
-  unsigned un = value();
+#define macro(val) val
+
+#ifdef __cplusplus
+template
+void TFunc() {
+  // Make sure that we do warn for normal variables in template functions !
+  unsigned char c = svalue();
+#ifdef TEST
+  if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return;
+#else
+  if (c < 0)
+  return;
+#endif
+
+  if (c < macro(0))
+  return;
+
+  T v = svalue();
+  if (v < 0)
+  return;
+}
+#endif
+
+int main()
+{
+#ifdef __cplusplus
+  TFunc();
+  TFunc();
+#endif
+
+  unsigned un = uvalue();
 
 #ifdef TEST
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
+  return 0;
   if (0 > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
-  if (un < 0U) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
-  if (un >= 0U) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
-  if (0U <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
-  if (0U > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+  return 0;
+  if (0UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+  return 0;
+  if (0UL >= un)
+  return 0;
 #else
 // expected-no-diagnostics
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0)
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0)
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un)
-return 0;
+  return 0;
   if (0 > un)
-return 0;
-  if (un < 0U)
-return 0;
-  if (un >= 0U)
-return 0;
-  if (0U <= un)
-return 0;
-  if (0U > un)
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL)
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL)
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un)
+  return 0;
+  if (0UL > un)
+  return 0;
+  if (0UL >= un)
+  return 0;
 #endif
 
+
+  signed int a = svalue();
+
+#ifdef TEST
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
+  if (a < 0)
+  retu

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8667-8679
+  bool Result; // The result of the comparison
+  if ((Op == BO_GT && ValueType == LimitType::Max && ConstOnRight) ||
+  (Op == BO_GT && ValueType == LimitType::Min && !ConstOnRight) ||
+  (Op == BO_LT && ValueType == LimitType::Max && !ConstOnRight) ||
+  (Op == BO_LT && ValueType == LimitType::Min && ConstOnRight)) {
+Result = false;
+  } else if ((Op == BO_GE && ValueType == LimitType::Max && !ConstOnRight) ||

rsmith wrote:
> The exhaustive case analysis is a little hard to verify. Perhaps something 
> like this would be clearer:
> 
> ```
> bool ConstIsLowerBound = (Op == BO_LT || Op == BO_LE) ^ ConstOnRight;
> bool ResultWhenConstEqualsOther = (Op == BO_LE || Op == BO_GE);
> bool ResultWhenConstNeOther = ConstIsLowerBound ^ ValueType == LimitType::Max;
> if (ResultWhenConstEqualsOther != ResultWhenConstNeOther)
>   return false;
> ```
Oh, that looks better indeed :)
I did consider doing something like that, but my variant ended up looking worse 
than even the current `if()`'s



Comment at: lib/Sema/SemaChecking.cpp:8940
+  } else if (!T->hasUnsignedIntegerRepresentation())
+IsComparisonConstant = E->isIntegerConstantExpr(S.Context);
+

rsmith wrote:
> It seems suboptimal to evaluate both sides of the comparison and then 
> evaluate the entire comparison again in this case. Presumably the point is to 
> catch comparisons whose operands are not of integral type (eg, floating 
> point), but we could get that benefit and also catch more integral cases by 
> switching from `isIntegerConstantExpr` to the more appropriate 
> `EvaluateAsRValue`.
> 
> I'm fine with a cleanup to avoid the repeated evaluation here being deferred 
> to a later patch.
If we look at this code closely, if `hasUnsignedIntegerRepresentation() == 
false`, we always do `return AnalyzeImpConvsInComparison(S, E);`, regardless of 
`E->isIntegerConstantExpr(S.Context)`.
So if i move more stuff into `if (T->isIntegralType(S.Context))`, then ` 
E->isIntegerConstantExpr(S.Context);` is simply gone.
At least the current tests say so.



Comment at: lib/Sema/SemaChecking.cpp:8949
+  if (T->isIntegralType(S.Context)) {
+if (CheckTautologicalComparison(S, E))
+  return AnalyzeImpConvsInComparison(S, E);

rsmith wrote:
> Pass `LHSValue` and `RHSValue` in here rather than recomputing them.
We can even go one step further, and pass the `bool IsConstLiteralOnRHS`


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



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


Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

2017-10-12 Thread Anastasia Stulova via cfe-commits

I think this bit is a bit confusing to us. Some of our original OpenCL checks 
were removed in some places because in some cases OpenCL semantic was adopted 
elsewhere. But I think this should indeed go under OpenCL check.

Thanks,
Anastasia


From: Bruno Cardoso Lopes 
Sent: 11 October 2017 00:27
To: Egor Churaev
Cc: cfe-commits; Anastasia Stulova
Subject: Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

Hi Egor,

On Tue, Mar 21, 2017 at 6:20 AM, Egor Churaev via cfe-commits
 wrote:
> Author: echuraev
> Date: Tue Mar 21 08:20:57 2017
> New Revision: 298369
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298369&view=rev
> Log:
> [OpenCL] Added diagnostic for checking length of vector
>
> Reviewers: Anastasia, cfe-commits
>
> Reviewed By: Anastasia
>
> Subscribers: bader, yaxunl
>
> Differential Revision: https://reviews.llvm.org/D30937
>
> Added:
> cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprMember.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298369&r1=298368&r2=298369&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 21 08:20:57 
> 2017
> @@ -8236,6 +8236,8 @@ def err_opencl_ptrptr_kernel_param : Err
>  def err_kernel_arg_address_space : Error<
>"pointer arguments to kernel functions must reside in '__global', "
>"'__constant' or '__local' address space">;
> +def err_opencl_ext_vector_component_invalid_length : Error<
> +  "vector component access has invalid length %0.  Supported: 
> 1,2,3,4,8,16.">;
>  def err_opencl_function_variable : Error<
>"%select{non-kernel function|function scope}0 variable cannot be declared 
> in %1 address space">;
>  def err_static_function_scope : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=298369&r1=298368&r2=298369&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 21 08:20:57 2017
> @@ -284,6 +284,14 @@ IsRGBA(char c) {
>}
>  }
>
> +// OpenCL v1.1, s6.1.7
> +// The component swizzle length must be in accordance with the acceptable
> +// vector sizes.
> +static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
> +{
> +  return (len >= 1 && len <= 4) || len == 8 || len == 16;
> +}
> +
>  /// Check an ext-vector component access expression.
>  ///
>  /// VK should be set in advance to the value kind of the base
> @@ -376,6 +384,19 @@ CheckExtVectorComponent(Sema &S, QualTyp
>  }
>}
>
> +  if (!HalvingSwizzle) {
> +unsigned SwizzleLength = CompName->getLength();
> +
> +if (HexSwizzle)
> +  SwizzleLength--;
> +
> +if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) {
> +  S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)
> +<< SwizzleLength << SourceRange(CompLoc);
> +  return QualType();
> +}
> +  }
> +
>// The component accessor looks fine - now we need to compute the actual 
> type.
>// The vector type is implied by the component accessor. For example,
>// vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
>
> Added: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=298369&view=auto
> ==
> --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Mar 21 08:20:57 
> 2017
> @@ -0,0 +1,10 @@
> +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> +
> +typedef float float8 __attribute__((ext_vector_type(8)));
> +
> +void foo() {
> +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0);
> +
> +f2.s01234; // expected-error {{vector component access has invalid 
> length 5.  Supported: 1,2,3,4,8,16}}
> +f2.xyzxy; // expected-error {{vector component access has invalid length 
> 5.  Supported: 1,2,3,4,8,16}}
> +}

Sorry for the necromancy here, but I wonder if we should only make
this if LangOpts.OpenCL in on. Is there an initial intent for not to?

The rationale is that we have given users support for ext_vector_type
without OpenCL mode with arbitrary vectors lengths not defined in
"6.1.2 Built-In Vector Data Types", that said it makes sense to
support the component notation for those. I'm happy to fix it, I just
need to know if this covers some background I'm not aware of.

Thanks,

--
Bruno Cardoso Lo

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 118795.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D38134

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -6,10 +6,30 @@
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 
-// N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
+
+// For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
+// COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+
+// For anonymous blocks without captures, emit block literals as global variable.
+// COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG2:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG3:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG4:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG5:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG6:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG7:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG8:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVG8:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG9:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INVG9:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG10:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG11:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { 

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D38134#895848, @Anastasia wrote:

> I think it would be good to add a block test to CodeGenOpenCL where we would 
> just call the block without any enqueue and check that the invoke function is 
> generated but the kernel wrapper isn't.


we have test/CodeGenOpenCL/blocks.cl which only calls a block. I can add check 
to make sure no kernels generated.




Comment at: lib/CodeGen/CGBuiltin.cpp:2846
+  PtrToSizeArray};
+  std::vector ArgTys = {QueueTy,
+  IntTy,

Anastasia wrote:
> Formatting seems inconsistent from above.
Will fix.



Comment at: lib/CodeGen/CodeGenFunction.h:2921
 private:
-  /// Helpers for blocks
-  llvm::Value *EmitBlockLiteral(const CGBlockInfo &Info);
+  /// Helpers for blocks. Returns invoke function by \p InvokeF if it is not
+  /// nullptr.

Anastasia wrote:
> It will be nullptr in case block is not enqueued? May be it's worth 
> explaining it in the comment.
Will do.



Comment at: lib/CodeGen/TargetInfo.h:290
   }
+  /// Create an OpenCL kernel for an enqueued block.
+  virtual llvm::Function *

Anastasia wrote:
> Can we also explain the wrapper kernel here?
Will do.


https://reviews.llvm.org/D38134



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


[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-10-12 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:123
+  // Is variable changed anywhere in TU?
+  for (const Decl *D : AMgr.getASTContext().getTranslationUnitDecl()->decls()) 
{
+if (isChanged(D, VD))

dcoughlin wrote:
> Since you are calling `getInitialStateForGlobalStaticVar()` in 
> `getInitialState()` for each static variable declaration and 
> `getInitialState()` is called for each top-level function, you are doing an 
> n^3 operation in the size of the translation unit, which is going to be very, 
> very expensive for large translation units.
> 
> Have you considered doing the analysis for static variables that are never 
> changed during call-graph construction? This should be a linear operation and 
> doing it during call-graph construction would avoid an extra walk of the 
> entire translation unit.
hmm... could you tell me where the call-graph construction is that I can tweak?


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D36836#889375, @aaron.ballman wrote:

> Adding @dberlin for licensing discussion questions.


Ping.

Yes, i agree that what i have added is not a directory, and not a proper 
license.
That is more of a template to hopefully stat moving things in the right 
direction.

To clarify, my problem with this Differential is that i'we yet to see any 
opinion on
the proposed check from the people who will actually have the final say whether
it will be accepted or not. It will be *really* sad if we go through all this 
trouble 
with the legal matters, and then it will be NACK'ed...


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D38781: [X86] Add CLWB intrinsic. clang part

2017-10-12 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Headers/clwbintrin.h:34
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clwb(void const *__m) {

Worth adding the doxygen description? You can probably just copy+paste+modify 
the _mm_clflush documentation.



Comment at: test/CodeGen/builtin-clwb.c:4
+
+#include 
+void test_mm_clwb(const void *__m) {

Match what is done in the other files: use -ffreestanding instead of defining 
__MM_MALLOC_H and include the "top header":


https://reviews.llvm.org/D38781



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


[PATCH] D38700: [Sema][Crash] Correctly handle an non-dependent noexcept expr in function template

2017-10-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Bump!  I realize the two of you are super busy, but if anyone else on 
cfe-commits wants to take a look, I'd apprecate it!
-Erich


https://reviews.llvm.org/D38700



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-12 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: lib/AST/TypePrinter.cpp:1323
 OS << "address_space(";
-OS << T->getEquivalentType().getAddressSpace();
+OS << T->getEquivalentType()
+  .getQualifiers()

Anastasia wrote:
> Why do we need this change?
`__attribute__((address_space(n)))` is a target address space and not a 
language address space like `LangAS::opencl_generic`. Isn't 
`Qualifiers::getAddressSpaceAttributePrintValue()` meant exactly for this use 
case?


https://reviews.llvm.org/D38816



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


[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-10-12 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:123
+  // Is variable changed anywhere in TU?
+  for (const Decl *D : AMgr.getASTContext().getTranslationUnitDecl()->decls()) 
{
+if (isChanged(D, VD))

danielmarjamaki wrote:
> dcoughlin wrote:
> > Since you are calling `getInitialStateForGlobalStaticVar()` in 
> > `getInitialState()` for each static variable declaration and 
> > `getInitialState()` is called for each top-level function, you are doing an 
> > n^3 operation in the size of the translation unit, which is going to be 
> > very, very expensive for large translation units.
> > 
> > Have you considered doing the analysis for static variables that are never 
> > changed during call-graph construction? This should be a linear operation 
> > and doing it during call-graph construction would avoid an extra walk of 
> > the entire translation unit.
> hmm... could you tell me where the call-graph construction is that I can 
> tweak?
I think I found it: `clang/lib/Analysis/CallGraph.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


[PATCH] D38852: [Hexagon] Handling of new HVX flags and target-features

2017-10-12 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa created this revision.
Herald added a subscriber: eraman.

This patch has the following changes

1. A new flag "-mhvx-length={64B|128B}" is introduced to specify the

length of the vector. Previously we have used "-mhvx-double" for 128 Bytes.
This adds the target-feature "+hvx-length{64|128}b"

2. The "-mhvx" flag must be provided on command line to enable HVX for Hexagon.

If no -mhvx-length flag is specified, a default length is picked from the arch
mentioned in this priority order from either -mhvx=vxx or -mcpu. For v60 and 
v62 
the default length is 64 Byte. For unknown versions, the length is 128 Byte.
The -mhvx flag adds the target-feature "+hvxv{hvx_version}"

3. The 64 Byte mode is soon going to be deprecated. A warning is emitted if 64 
Byte

is enabled. A warning is still emitted for the default 64 Byte as well. This 
warning
can be suppressed with a -Wno flag.

4. The "-mhvx-double" and "-mno-hvx-double" flags are deprecated. A warning is

emitted if the driver sees them on commandline. "-mhvx-double" is an alias to
"-mhvx-length=128B"

5. The compilation will error out if -mhvx-length is specified with out an

-mhvx/-mhvx= flag

6. The macro __HVX_LENGTH__ is defined and is set to the length of the

vector.
Eg: #define __HVX_LENGTH__ 64

7. The macro __HVX_ARCH__ is defined and is set to the version of the HVX.

Eg: #define __HVX_ARCH__ 62


Repository:
  rL LLVM

https://reviews.llvm.org/D38852

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  lib/Basic/Targets/Hexagon.cpp
  lib/Basic/Targets/Hexagon.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Hexagon.cpp
  lib/Driver/ToolChains/Hexagon.h
  test/CodeGen/hexagon-inline-asm.c
  test/Driver/hexagon-hvx.c
  test/Preprocessor/hexagon-predefines.c

Index: test/Preprocessor/hexagon-predefines.c
===
--- test/Preprocessor/hexagon-predefines.c
+++ test/Preprocessor/hexagon-predefines.c
@@ -1,32 +1,43 @@
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv5 %s | FileCheck %s -check-prefix CHECK-V5
-
 // CHECK-V5: #define __HEXAGON_ARCH__ 5
 // CHECK-V5: #define __HEXAGON_V5__ 1
+// CHECK-V5-NOT: #define __HVX_LENGTH__
+// CHECK-V5-NOT: #define __HVX__ 1
 // CHECK-V5: #define __hexagon__ 1
 
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv55 %s | FileCheck %s -check-prefix CHECK-V55
-
 // CHECK-V55: #define __HEXAGON_ARCH__ 55
 // CHECK-V55: #define __HEXAGON_V55__ 1
+// CHECK-V55-NOT: #define __HVX_LENGTH__
+// CHECK-V55-NOT: #define __HVX__ 1
 // CHECK-V55: #define __hexagon__ 1
 
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 %s | FileCheck %s -check-prefix CHECK-V60
-
 // CHECK-V60: #define __HEXAGON_ARCH__ 60
 // CHECK-V60: #define __HEXAGON_V60__ 1
+// CHECK-V60-NOT: #define __HVX_LENGTH__
+// CHECK-V60-NOT: #define __HVX__ 1
 // CHECK-V60: #define __hexagon__ 1
 
-// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 -target-feature +hvx %s | FileCheck %s -check-prefix CHECK-V60HVX
-
-// CHECK-V60HVX: #define __HEXAGON_ARCH__ 60
-// CHECK-V60HVX: #define __HEXAGON_V60__ 1
-// CHECK-V60HVX: #define __HVX__ 1
-
-// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 -target-feature +hvx-double  %s | FileCheck %s -check-prefix CHECK-V60HVXD
-
-// CHECK-V60HVXD: #define __HEXAGON_ARCH__ 60
-// CHECK-V60HVXD: #define __HEXAGON_V60__ 1
-// CHECK-V60HVXD: #define __HVXDBL__ 1
-// CHECK-V60HVXD: #define __HVX__ 1
-// CHECK-V60HVXD: #define __hexagon__ 1
-
+// The HVX flags are explicitly defined by the driver.
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 \
+// RUN: -target-feature +hvxv60 -target-feature +hvx-length64b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-V60HVX-64B
+// CHECK-V60HVX-64B: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVX-64B: #define __HEXAGON_V60__ 1
+// CHECK-V60HVX-64B-NOT: #define __HVXDBL__ 1
+// CHECK-V60HVX-64B: #define __HVX_ARCH__ 60
+// CHECK-V60HVX-64B: #define __HVX_LENGTH__ 64
+// CHECK-V60HVX-64B: #define __HVX__ 1
+// CHECK-V60HVX-64B: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 \
+// RUN: -target-feature +hvxv60 -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-V60HVX-128B
+// CHECK-V60HVX-128B: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVX-128B: #define __HEXAGON_V60__ 1
+// CHECK-V60HVX-128B: #define __HVXDBL__ 1
+// CHECK-V60HVX-128B: #define __HVX_ARCH__ 60
+// CHECK-V60HVX-128B: #define __HVX_LENGTH__ 128
+// CHECK-V60HVX-128B: #define __HVX__ 1
+// CHECK-V60HVX-128B: #define __hexagon__ 1
Index: test/Driver/hexagon-hvx.c
===
--- /dev/null
+++ test/Driver/hexagon-hvx.c
@@ -0,0 +1,90 @@
+// -
+// Tests for

[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-10-12 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: include/clang/Frontend/CodeGenOptions.def:182
 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
+CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable finegrained bitfield 
accesses.
 CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum 
definition.

finegrained -> fine-grained

(I suppose we're not sticking to 80 cols in this file anyway)



Repository:
  rL LLVM

https://reviews.llvm.org/D36562



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


Re: [PATCH] D38464: [clangd] less boilerplate in RPC dispatch

2017-10-12 Thread David Blaikie via cfe-commits
I mention it only out of interest of deduplication of functionality/code
within the LLVM project as a whole. Be nice not to maintain two things if
one would suffice.

On Thu, Oct 12, 2017 at 6:21 AM Sam McCall  wrote:

> Interesting - this is pretty primitive, and still fairly tightly coupled
> to JSON-RPC.
> I can't easily tell from the code how the ORC RPC functionality - would it
> be easy to use with JSON-RPC, does it make sense to use serialization only,
> does it have opinions about threading models? And really, what would we
> expect to gain vs using the current more naive code (it looks more
> complicated, probably having more complex requirements).
>
> On Mon, Oct 9, 2017 at 11:16 PM, David Blaikie  wrote:
>
>> hey Lang (& folks here) any chance there's some overlap between the RPC
>> functionality here and the RPC functionality in ORC that could be
>> deduplicated/refactored?
>>
>> On Fri, Oct 6, 2017 at 5:30 AM Ilya Biryukov via Phabricator via
>> cfe-commits  wrote:
>>
>>> ilya-biryukov accepted this revision.
>>> ilya-biryukov added a comment.
>>> This revision is now accepted and ready to land.
>>>
>>> LGTM.
>>> Note there's a new LSP method handler added upstream
>>> (`textDocument/signatureHelp`), we should add it to this change before
>>> submitting.
>>>
>>>
>>>
>>> 
>>> Comment at: clangd/ClangdLSPServer.h:47
>>>// Implement ProtocolCallbacks.
>>> -  void onInitialize(StringRef ID, InitializeParams IP,
>>> -JSONOutput &Out) override;
>>> -  void onShutdown(JSONOutput &Out) override;
>>> -  void onDocumentDidOpen(DidOpenTextDocumentParams Params,
>>> - JSONOutput &Out) override;
>>> -  void onDocumentDidChange(DidChangeTextDocumentParams Params,
>>> -   JSONOutput &Out) override;
>>> -  void onDocumentDidClose(DidCloseTextDocumentParams Params,
>>> -  JSONOutput &Out) override;
>>> -  void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params,
>>> -  StringRef ID, JSONOutput &Out)
>>> override;
>>> -  void onDocumentRangeFormatting(DocumentRangeFormattingParams Params,
>>> - StringRef ID, JSONOutput &Out)
>>> override;
>>> -  void onDocumentFormatting(DocumentFormattingParams Params, StringRef
>>> ID,
>>> -JSONOutput &Out) override;
>>> -  void onCodeAction(CodeActionParams Params, StringRef ID,
>>> -JSONOutput &Out) override;
>>> -  void onCompletion(TextDocumentPositionParams Params, StringRef ID,
>>> -JSONOutput &Out) override;
>>> -  void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
>>> -JSONOutput &Out) override;
>>> -  void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
>>> -JSONOutput &Out) override;
>>> +  void onInitialize(Ctx &C, InitializeParams &Params) override;
>>> +  void onShutdown(Ctx &C, NoParams &Params) override;
>>> 
>>> sammccall wrote:
>>> > ilya-biryukov wrote:
>>> > > ilya-biryukov wrote:
>>> > > > Maybe there's a way to have a typed return value instead of `Ctx`?
>>> > > > This would give an interface that's harder to misuse: one can't
>>> forget to call `reply` or call it twice.
>>> > > >
>>> > > > Here's on design that comes to mind.
>>> > > > Notification handlers could have `void` return, normal requests
>>> can return `Optional` or `Optional` (with result json).
>>> > > > `Optional` is be used to indicate whether error occurred while
>>> processing the request.
>>> > > >
>>> > > After putting more thought into it, `Ctx`-based API seems to have an
>>> advantage: it will allow us to easily implement async responses.
>>> > > E.g., we can run code completion on a background thread and continue
>>> processing other requests. When completion is ready, we will simply call
>>> `Ctx.reply` to return results to the language client.
>>> > >
>>> > > To make that possible, can we allow moving `RequestContext` and pass
>>> it by-value instead of by-ref?
>>> > Yeah I thought about returning a value... it certainly reads more
>>> nicely, but I don't think we're ready to do a good job in this patch:
>>> >  - return value should be an object ready to be serialized (rather
>>> than a JSON string) - I don't want to bring that in scope here, but it
>>> might affect the details of the API
>>> >  - there's several cases we know about (return object, no reply, error
>>> reply) and some we're not sure about (async as you mention - any multiple
>>> responses)? I think this needs some design, and I don't yet know the
>>> project well enough to drive it.
>>> >
>>> > I've switched to passing Ctx by value as you suggest (though it's
>>> certainly cheap enough to copy, too).
>>> Yeah, copy is also fine there performance-wise.
>>>
>>> I do think move-only interface fits slightly better. We can check a
>>> whole bunch of invariants if 

[PATCH] D38839: [compiler-rt] [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS

2017-10-12 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Yep, thanks! This was probably the root cause of the failure.


https://reviews.llvm.org/D38839



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


[PATCH] D38838: [compiler-rt] [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()

2017-10-12 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Yep, thanks! Good to go provided tests run.
Looks like we haven't spotted it due to other bug you have fixed cancelling 
this one out.


https://reviews.llvm.org/D38838



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


[PATCH] D38840: [compiler-rt] [cmake] [asan] Reuse generate_asan_tests for dynamic tests

2017-10-12 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

@mgorny so this one actually changes semantics.
The previous one reused generated object files, and with the change it will 
start recompiling all the tests again.
(and actually being able to export object files has added quite a bit of 
complexity to all these compiler-rt macros).

The current code also looks weird, because it depends on 
`ASAN_INST_TEST_OBJECTS`, but will actually recompile and export them.

I think a better fix would be to change `add_compiler_rt_test` to accept two 
kinds of dependencies (probably again `DEPS` and `COMPILE_DEPS`? I know the 
name is not very descriptive, but I've kept it from the previous version).
It already checks that variable to conditionally add `clang` to dependencies.


https://reviews.llvm.org/D38840



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


[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

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

@arichardson, great work! Thanks a lot!


https://reviews.llvm.org/D38816



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


r315594 - [X86] Use -ffreestanding instead of using the mm_malloc.h include guard hack on more of the builtin tests.

2017-10-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 12 10:21:01 2017
New Revision: 315594

URL: http://llvm.org/viewvc/llvm-project?rev=315594&view=rev
Log:
[X86] Use -ffreestanding instead of using the mm_malloc.h include guard hack on 
more of the builtin tests.

Modified:
cfe/trunk/test/CodeGen/adc-builtins.c
cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c
cfe/trunk/test/CodeGen/builtin-clflushopt.c
cfe/trunk/test/CodeGen/builtin-clzero.c

Modified: cfe/trunk/test/CodeGen/adc-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/adc-builtins.c?rev=315594&r1=315593&r2=315594&view=diff
==
--- cfe/trunk/test/CodeGen/adc-builtins.c (original)
+++ cfe/trunk/test/CodeGen/adc-builtins.c Thu Oct 12 10:21:01 2017
@@ -1,6 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
-
-#define __MM_MALLOC_H
+// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -o 
- %s | FileCheck %s
 
 #include 
 

Modified: cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c?rev=315594&r1=315593&r2=315594&view=diff
==
--- cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c Thu Oct 12 10:21:01 2017
@@ -1,6 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx512ifma 
-target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
-
-#define __MM_MALLOC_H
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-apple-darwin 
-target-feature +avx512ifma -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
 
 #include 
 

Modified: cfe/trunk/test/CodeGen/builtin-clflushopt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-clflushopt.c?rev=315594&r1=315593&r2=315594&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-clflushopt.c (original)
+++ cfe/trunk/test/CodeGen/builtin-clflushopt.c Thu Oct 12 10:21:01 2017
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +clflushopt  
-emit-llvm -o - -Wall -Werror | FileCheck %s
-#define __MM_MALLOC_H
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-apple-darwin 
-target-feature +clflushopt  -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
 
-#include 
 void test_mm_clflushopt(char * __m) {
   //CHECK-LABEL: @test_mm_clflushopt
   //CHECK: @llvm.x86.clflushopt

Modified: cfe/trunk/test/CodeGen/builtin-clzero.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-clzero.c?rev=315594&r1=315593&r2=315594&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-clzero.c (original)
+++ cfe/trunk/test/CodeGen/builtin-clzero.c Thu Oct 12 10:21:01 2017
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +clzero  
-emit-llvm -o - -Wall -Werror | FileCheck %s
-#define __MM_MALLOC_H
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-apple-darwin 
-target-feature +clzero  -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 #include 
+
 void test_mm_clzero(void * __m) {
   //CHECK-LABEL: @test_mm_clzero
   //CHECK: @llvm.x86.clzero


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


[PATCH] D38853: [clang-format] Allow building fuzzer with OSS-Fuzz flags.

2017-10-12 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D38853

Files:
  clang/tools/clang-format/CMakeLists.txt
  clang/tools/clang-format/fuzzer/CMakeLists.txt


Index: clang/tools/clang-format/fuzzer/CMakeLists.txt
===
--- clang/tools/clang-format/fuzzer/CMakeLists.txt
+++ clang/tools/clang-format/fuzzer/CMakeLists.txt
@@ -1,11 +1,15 @@
 set(LLVM_LINK_COMPONENTS support)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+if(LLVM_USE_SANITIZE_COVERAGE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+endif()
 
 add_clang_executable(clang-format-fuzzer
   EXCLUDE_FROM_ALL
   ClangFormatFuzzer.cpp
   )
 
 target_link_libraries(clang-format-fuzzer
-  ${CLANG_FORMAT_LIB_DEPS})
+  ${CLANG_FORMAT_LIB_DEPS}
+  ${LIB_FUZZING_ENGINE}
+  )
Index: clang/tools/clang-format/CMakeLists.txt
===
--- clang/tools/clang-format/CMakeLists.txt
+++ clang/tools/clang-format/CMakeLists.txt
@@ -15,7 +15,7 @@
   ${CLANG_FORMAT_LIB_DEPS}
   )
 
-if( LLVM_USE_SANITIZE_COVERAGE )
+if( LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
 


Index: clang/tools/clang-format/fuzzer/CMakeLists.txt
===
--- clang/tools/clang-format/fuzzer/CMakeLists.txt
+++ clang/tools/clang-format/fuzzer/CMakeLists.txt
@@ -1,11 +1,15 @@
 set(LLVM_LINK_COMPONENTS support)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+if(LLVM_USE_SANITIZE_COVERAGE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+endif()
 
 add_clang_executable(clang-format-fuzzer
   EXCLUDE_FROM_ALL
   ClangFormatFuzzer.cpp
   )
 
 target_link_libraries(clang-format-fuzzer
-  ${CLANG_FORMAT_LIB_DEPS})
+  ${CLANG_FORMAT_LIB_DEPS}
+  ${LIB_FUZZING_ENGINE}
+  )
Index: clang/tools/clang-format/CMakeLists.txt
===
--- clang/tools/clang-format/CMakeLists.txt
+++ clang/tools/clang-format/CMakeLists.txt
@@ -15,7 +15,7 @@
   ${CLANG_FORMAT_LIB_DEPS}
   )
 
-if( LLVM_USE_SANITIZE_COVERAGE )
+if( LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38853: [clang-format] Allow building fuzzer with OSS-Fuzz flags.

2017-10-12 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a reviewer: bogner.
kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM

+Justin FYI

Please also take a look at llvm-isel-fuzzer, which I've just added to oss-fuzz


https://reviews.llvm.org/D38853



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


[PATCH] D38781: [X86] Add CLWB intrinsic. clang part

2017-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 118816.
craig.topper added a comment.

Address review feedback


https://reviews.llvm.org/D38781

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/CMakeLists.txt
  lib/Headers/clwbintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/builtin-clwb.c

Index: test/CodeGen/builtin-clwb.c
===
--- /dev/null
+++ test/CodeGen/builtin-clwb.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-apple-darwin -target-feature +clwb  -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm_clwb(const void *__m) {
+  //CHECK-LABEL: @test_mm_clwb
+  //CHECK: @llvm.x86.clwb
+  _mm_clwb(__m);
+}
Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -58,6 +58,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLWB__)
+#include 
+#endif
+
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)
 #include 
 #endif
Index: lib/Headers/clwbintrin.h
===
--- /dev/null
+++ lib/Headers/clwbintrin.h
@@ -0,0 +1,52 @@
+/*=== clwbintrin.h - CLWB intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __CLWBINTRIN_H
+#define __CLWBINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("clwb")))
+
+/// \brief Writes back to memory the cache line (if modified) that contains the
+/// linear address specified in \a __m from any level of the cache hierarchy in
+/// the cache coherence domain
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLWB  instruction.
+///
+/// \param __p
+///A pointer to the memory location used to identify the cache line to be
+///written back.
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clwb(void const *__m) {
+  __builtin_ia32_clwb(__m);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -33,6 +33,7 @@
   clzerointrin.h
   cpuid.h
   clflushoptintrin.h
+  clwbintrin.h
   emmintrin.h
   f16cintrin.h
   float.h
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -641,6 +641,9 @@
 //CLFLUSHOPT
 TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 
+//CLWB
+TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 118813.
yaxunl marked 7 inline comments as done.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Separate implicit addr space flag to another patch as John suggested.

This patch only introduces the private addr space but does not print it.


https://reviews.llvm.org/D35082

Files:
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/NVPTX.h
  lib/Basic/Targets/SPIR.h
  lib/Basic/Targets/TCE.h
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-spaces-mangling.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/extern.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl
  test/SemaTemplate/address_space-dependent.cpp

Index: test/SemaTemplate/address_space-dependent.cpp
===
--- test/SemaTemplate/address_space-dependent.cpp
+++ test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388599)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388598)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x77>();
+  correct<0x76>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,6 +5,20 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
+static float g_implicit_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static constant float g_constant_static_var = 0;
+static global float g_global_static_var = 0;   // expected-error {{program scope variable must reside in constant address space}}
+static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
+static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
+
+extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern constant float g_constant_extern_var;
+extern global float g_global_extern_var;   // expected-error {{extern variable must reside in constant address space}}
+extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
+extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
+
 void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
@@ -45,10 +59,17 @@
 __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
   }
 
+  static float l_implicit_static_var = 0;  // expected-error {{variables in function scope cannot be declared static}}
+  static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
+  static global float l_global_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
+  static local float l_local_static_var = 0;   // expected-error {{variables in function scope cannot be declared static}}
+  static private float l_private_static_var = 0;   // expected-error {{variables in function scope cannot be declared static}}
+  static generic float l_

r315603 - [clang-format] Allow building fuzzer with OSS-Fuzz flags.

2017-10-12 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Thu Oct 12 11:39:10 2017
New Revision: 315603

URL: http://llvm.org/viewvc/llvm-project?rev=315603&view=rev
Log:
[clang-format] Allow building fuzzer with OSS-Fuzz flags.

Reviewers: kcc, bogner

Reviewed By: kcc

Subscribers: cfe-commits, mgorny

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

Modified:
cfe/trunk/tools/clang-format/CMakeLists.txt
cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt

Modified: cfe/trunk/tools/clang-format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/CMakeLists.txt?rev=315603&r1=315602&r2=315603&view=diff
==
--- cfe/trunk/tools/clang-format/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format/CMakeLists.txt Thu Oct 12 11:39:10 2017
@@ -15,7 +15,7 @@ target_link_libraries(clang-format
   ${CLANG_FORMAT_LIB_DEPS}
   )
 
-if( LLVM_USE_SANITIZE_COVERAGE )
+if( LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
 

Modified: cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt?rev=315603&r1=315602&r2=315603&view=diff
==
--- cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt Thu Oct 12 11:39:10 2017
@@ -1,6 +1,8 @@
 set(LLVM_LINK_COMPONENTS support)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+if(LLVM_USE_SANITIZE_COVERAGE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+endif()
 
 add_clang_executable(clang-format-fuzzer
   EXCLUDE_FROM_ALL
@@ -8,4 +10,6 @@ add_clang_executable(clang-format-fuzzer
   )
 
 target_link_libraries(clang-format-fuzzer
-  ${CLANG_FORMAT_LIB_DEPS})
+  ${CLANG_FORMAT_LIB_DEPS}
+  ${LIB_FUZZING_ENGINE}
+  )


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


[PATCH] D38853: [clang-format] Allow building fuzzer with OSS-Fuzz flags.

2017-10-12 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315603: [clang-format] Allow building fuzzer with OSS-Fuzz 
flags. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38853?vs=118805&id=118819#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38853

Files:
  cfe/trunk/tools/clang-format/CMakeLists.txt
  cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt


Index: cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
@@ -1,11 +1,15 @@
 set(LLVM_LINK_COMPONENTS support)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+if(LLVM_USE_SANITIZE_COVERAGE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+endif()
 
 add_clang_executable(clang-format-fuzzer
   EXCLUDE_FROM_ALL
   ClangFormatFuzzer.cpp
   )
 
 target_link_libraries(clang-format-fuzzer
-  ${CLANG_FORMAT_LIB_DEPS})
+  ${CLANG_FORMAT_LIB_DEPS}
+  ${LIB_FUZZING_ENGINE}
+  )
Index: cfe/trunk/tools/clang-format/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format/CMakeLists.txt
+++ cfe/trunk/tools/clang-format/CMakeLists.txt
@@ -15,7 +15,7 @@
   ${CLANG_FORMAT_LIB_DEPS}
   )
 
-if( LLVM_USE_SANITIZE_COVERAGE )
+if( LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
 


Index: cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-format/fuzzer/CMakeLists.txt
@@ -1,11 +1,15 @@
 set(LLVM_LINK_COMPONENTS support)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+if(LLVM_USE_SANITIZE_COVERAGE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+endif()
 
 add_clang_executable(clang-format-fuzzer
   EXCLUDE_FROM_ALL
   ClangFormatFuzzer.cpp
   )
 
 target_link_libraries(clang-format-fuzzer
-  ${CLANG_FORMAT_LIB_DEPS})
+  ${CLANG_FORMAT_LIB_DEPS}
+  ${LIB_FUZZING_ENGINE}
+  )
Index: cfe/trunk/tools/clang-format/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format/CMakeLists.txt
+++ cfe/trunk/tools/clang-format/CMakeLists.txt
@@ -15,7 +15,7 @@
   ${CLANG_FORMAT_LIB_DEPS}
   )
 
-if( LLVM_USE_SANITIZE_COVERAGE )
+if( LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
   add_subdirectory(fuzzer)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38781: [X86] Add CLWB intrinsic. clang part

2017-10-12 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - one minor




Comment at: lib/Headers/clwbintrin.h:42
+///
+/// \param __p
+///A pointer to the memory location used to identify the cache line to be

\param __m


https://reviews.llvm.org/D38781



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


[PATCH] D38857: [OpenCL] Improve printing and semantic check related to implicit addr space

2017-10-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.

There are two issues:

1. only (void*)0 should be treated as nullptr

2. only explicit addr space should be printed

This patch introduces a flag in Qualifier to indicating a non-default address 
space qualifier is deduced by context. Only
non-implicit address space qualifier will be print out when printing AST. It is 
also used to identify nullptr.

However this review does not rule out alternative approaches, e.g. using 
AttributedType. We will explore alternative approaches.


https://reviews.llvm.org/D38857

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/atomic-ops.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/null_literal.cl
  test/SemaOpenCL/vector_conv_invalid.cl
  test/SemaTemplate/address_space-dependent.cpp

Index: test/SemaTemplate/address_space-dependent.cpp
===
--- test/SemaTemplate/address_space-dependent.cpp
+++ test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388598)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (4194294)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x76>();
+  correct<0x36>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: test/SemaOpenCL/vector_conv_invalid.cl
===
--- test/SemaOpenCL/vector_conv_invalid.cl
+++ test/SemaOpenCL/vector_conv_invalid.cl
@@ -16,7 +16,7 @@
   e = (constant int4)i;
   e = (private int4)i;
 
-  private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const int4 *' changes address space of pointer}}
+  private int4 *private_ptr = (const private int4 *)const_global_ptr; // expected-error{{casting 'const __global int4 *' to type 'const __private int4 *' changes address space of pointer}}
   global int4 *global_ptr = const_global_ptr; // expected-warning {{initializing '__global int4 *' with an expression of type 'const __global int4 *' discards qualifiers}}
   global_ptr = (global int4 *)const_global_ptr;
 }
Index: test/SemaOpenCL/null_literal.cl
===
--- test/SemaOpenCL/null_literal.cl
+++ test/SemaOpenCL/null_literal.cl
@@ -1,29 +1,68 @@
 // RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -verify %s
 
 #define NULL ((void*)0)
 
 void foo(){
+  global int *g1 = NULL;
+  global int *g2 = (global void *)0;
+  global int *g3 = (constant void *)0; // expected-error{{initializing '__global int *' with an expression of type '__constant void *' changes address space of pointer}}
+  global int *g4 = (local void *)0; // expected-error{{initializing '__global int *' with an expression of type '__local void *' changes address space of pointer}}
+  global int *g5 = (private void *)0; // expected-error{{initializing '__global int *' with an expression of type '__private void *' changes address space of pointer}}
 
-global int* ptr1 = NULL;
+  constant int *c1 = NULL;
+  constant int *c2 = (global void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}}
+  constant int *c3 = (constant void *)0;
+  constant int *c4 = (local void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__local void *' changes address space of pointer}}
+  constant int *c5 = (private void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__private void *' changes address space of pointer}}
 
-global int* ptr2 = (global void*)0;
+  local int *l1 = NULL;
+  local int *l2 = (global void *)0; // expected-error{{initializing '__local int *' with an expression of type '__global void *' changes address space of pointer}}
+  local int *l3 = (constant void *)0; // expected-error{{initializing '__local int *' with an expression of type '__constant void *' changes address space of pointer}}
+  local int *l4 = (local void *)0;
+  local int *l5 = (private void *)0; // 

[PATCH] D38838: [compiler-rt] [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315604: [cmake] Fix skipping DEPS (typo) in 
sanitizer_test_compile() (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38838?vs=118752&id=118820#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38838

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake


Index: compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()


Index: compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38839: [compiler-rt] [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315605: [cmake] [interception] Remove duplicate gtest from 
test COMPILE_DEPS (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38839?vs=118754&id=118821#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38839

Files:
  compiler-rt/trunk/lib/interception/tests/CMakeLists.txt


Index: compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})


Index: compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315607 - [X86] Add CLWB intrinsic. clang part

2017-10-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Oct 12 11:57:15 2017
New Revision: 315607

URL: http://llvm.org/viewvc/llvm-project?rev=315607&view=rev
Log:
[X86] Add CLWB intrinsic. clang part

Reviewers: RKSimon, zvi, igorb

Reviewed By: RKSimon

Subscribers: cfe-commits

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

Added:
cfe/trunk/lib/Headers/clwbintrin.h
cfe/trunk/test/CodeGen/builtin-clwb.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=315607&r1=315606&r2=315607&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Oct 12 11:57:15 2017
@@ -641,6 +641,9 @@ TARGET_BUILTIN(__builtin_ia32_xsaves, "v
 //CLFLUSHOPT
 TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 
+//CLWB
+TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=315607&r1=315606&r2=315607&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Oct 12 11:57:15 2017
@@ -33,6 +33,7 @@ set(files
   clzerointrin.h
   cpuid.h
   clflushoptintrin.h
+  clwbintrin.h
   emmintrin.h
   f16cintrin.h
   float.h

Added: cfe/trunk/lib/Headers/clwbintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/clwbintrin.h?rev=315607&view=auto
==
--- cfe/trunk/lib/Headers/clwbintrin.h (added)
+++ cfe/trunk/lib/Headers/clwbintrin.h Thu Oct 12 11:57:15 2017
@@ -0,0 +1,52 @@
+/*=== clwbintrin.h - CLWB intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __CLWBINTRIN_H
+#define __CLWBINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("clwb")))
+
+/// \brief Writes back to memory the cache line (if modified) that contains the
+/// linear address specified in \a __p from any level of the cache hierarchy in
+/// the cache coherence domain
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLWB  instruction.
+///
+/// \param __p
+///A pointer to the memory location used to identify the cache line to be
+///written back.
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clwb(void const *__p) {
+  __builtin_ia32_clwb(__p);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=315607&r1=315606&r2=315607&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Thu Oct 12 11:57:15 2017
@@ -58,6 +58,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLWB__)
+#include 
+#endif
+
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)
 #include 
 #endif

Added: cfe/trunk/test/CodeGen/builtin-clwb.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-clwb.c?rev=315607&view=auto
===

[PATCH] D38781: [X86] Add CLWB intrinsic. clang part

2017-10-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315607: [X86] Add CLWB intrinsic. clang part (authored by 
ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D38781?vs=118816&id=118822#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38781

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/clwbintrin.h
  cfe/trunk/lib/Headers/immintrin.h
  cfe/trunk/test/CodeGen/builtin-clwb.c

Index: cfe/trunk/lib/Headers/clwbintrin.h
===
--- cfe/trunk/lib/Headers/clwbintrin.h
+++ cfe/trunk/lib/Headers/clwbintrin.h
@@ -0,0 +1,52 @@
+/*=== clwbintrin.h - CLWB intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __CLWBINTRIN_H
+#define __CLWBINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("clwb")))
+
+/// \brief Writes back to memory the cache line (if modified) that contains the
+/// linear address specified in \a __p from any level of the cache hierarchy in
+/// the cache coherence domain
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLWB  instruction.
+///
+/// \param __p
+///A pointer to the memory location used to identify the cache line to be
+///written back.
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_clwb(void const *__p) {
+  __builtin_ia32_clwb(__p);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -33,6 +33,7 @@
   clzerointrin.h
   cpuid.h
   clflushoptintrin.h
+  clwbintrin.h
   emmintrin.h
   f16cintrin.h
   float.h
Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/lib/Headers/immintrin.h
@@ -58,6 +58,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLWB__)
+#include 
+#endif
+
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)
 #include 
 #endif
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -641,6 +641,9 @@
 //CLFLUSHOPT
 TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 
+//CLWB
+TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
Index: cfe/trunk/test/CodeGen/builtin-clwb.c
===
--- cfe/trunk/test/CodeGen/builtin-clwb.c
+++ cfe/trunk/test/CodeGen/builtin-clwb.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-apple-darwin -target-feature +clwb  -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm_clwb(const void *__m) {
+  //CHECK-LABEL: @test_mm_clwb
+  //CHECK: @llvm.x86.clwb
+  _mm_clwb(__m);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, this looks great.




Comment at: lib/Sema/SemaChecking.cpp:8940
+  } else if (!T->hasUnsignedIntegerRepresentation())
+IsComparisonConstant = E->isIntegerConstantExpr(S.Context);
+

lebedev.ri wrote:
> rsmith wrote:
> > It seems suboptimal to evaluate both sides of the comparison and then 
> > evaluate the entire comparison again in this case. Presumably the point is 
> > to catch comparisons whose operands are not of integral type (eg, floating 
> > point), but we could get that benefit and also catch more integral cases by 
> > switching from `isIntegerConstantExpr` to the more appropriate 
> > `EvaluateAsRValue`.
> > 
> > I'm fine with a cleanup to avoid the repeated evaluation here being 
> > deferred to a later patch.
> If we look at this code closely, if `hasUnsignedIntegerRepresentation() == 
> false`, we always do `return AnalyzeImpConvsInComparison(S, E);`, regardless 
> of `E->isIntegerConstantExpr(S.Context)`.
> So if i move more stuff into `if (T->isIntegralType(S.Context))`, then ` 
> E->isIntegerConstantExpr(S.Context);` is simply gone.
> At least the current tests say so.
It looks like the old behavior was to suppress the 
`CheckTautologicalComparisonWithZero` diagnostics when:

* the comparison has a constant value, and
* the types being compared are not integral types, and
* the types being compared do not have an unsigned integer representation

However, `CheckTautologicalComparisonWithZero` only emits diagnostics for 
comparisons with integral types. So I think you're right that the old codepath 
that evaluated `E->isIntegerConstantExpr(S.Context)` was pointless.



Comment at: lib/Sema/SemaChecking.cpp:8924
 
-  // If this is a tautological comparison, suppress -Wsign-compare.
-  if (CheckTautologicalComparisonWithZero(S, E))
-return AnalyzeImpConvsInComparison(S, E);
+bool IsComparisonConstant = (IsRHSIntegralLiteral && IsLHSIntegralLiteral);
+// We don't care about expressions whose result is a constant.

I don't think this variable pulls its weight any more, especially given the 
adjacent comment. Inline its initializer into the `if` condition, maybe?



Comment at: lib/Sema/SemaChecking.cpp:8930
+// We only care about expressions where just one side is literal
+if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
+  // Is the constant on the RHS or LHS?

It would probably be more obvious to use `||` here, since you already returned 
in the case where both sides are constant.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



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


[PATCH] D38840: [compiler-rt] [cmake] [asan] Remove unnecessary gtest dep from dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 118826.
mgorny retitled this revision from "[compiler-rt] [cmake] [asan] Reuse 
generate_asan_tests for dynamic tests" to "[compiler-rt] [cmake] [asan] Remove 
unnecessary gtest dep from dynamic tests".
mgorny edited the summary of this revision.
mgorny added a comment.

Ok, here's another idea. Since the objects have been compiled already (and they 
explicitly depend on gtest via their own deps), let's just remove the 
extraneous gtest dep.


https://reviews.llvm.org/D38840

Files:
  lib/asan/tests/CMakeLists.txt


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 118829.
lebedev.ri marked an inline comment as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,47 +1,370 @@
 // RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
 
-unsigned value(void);
+unsigned uvalue(void);
+signed int svalue(void);
 
-int main() {
-  unsigned un = value();
+#define macro(val) val
+
+#ifdef __cplusplus
+template
+void TFunc() {
+  // Make sure that we do warn for normal variables in template functions !
+  unsigned char c = svalue();
+#ifdef TEST
+  if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return;
+#else
+  if (c < 0)
+  return;
+#endif
+
+  if (c < macro(0))
+  return;
+
+  T v = svalue();
+  if (v < 0)
+  return;
+}
+#endif
+
+int main()
+{
+#ifdef __cplusplus
+  TFunc();
+  TFunc();
+#endif
+
+  unsigned un = uvalue();
 
 #ifdef TEST
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
+  return 0;
   if (0 > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
-  if (un < 0U) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
-  if (un >= 0U) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
-  if (0U <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
-  if (0U > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+  return 0;
+  if (0UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+  return 0;
+  if (0UL >= un)
+  return 0;
 #else
 // expected-no-diagnostics
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0)
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0)
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un)
-return 0;
+  return 0;
   if (0 > un)
-return 0;
-  if (un < 0U)
-return 0;
-  if (un >= 0U)
-return 0;
-  if (0U <= un)
-return 0;
-  if (0U > un)
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL)
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL)
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un)
+  return 0;
+  if (0UL > un)
+  return 0;
+  if (0UL >= un)
+  return 0;
 #endif
 
+
+  signed int a = svalue();
+
+#ifdef TEST
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
+  if (a < 0)
+  return 0;
+  if (a <= 0)
+  return 0;
+  if (a > 0)
+  return 0;
+  if (a >= 0)
+  return 0;
+
+  if (0 == a)
+  return 0;
+  if (0 != a)
+  return 0;
+  if (0 < a)
+  return 0;
+  if (0 <= a)
+  return 0;
+  if (0 > a)
+ 

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8930
+// We only care about expressions where just one side is literal
+if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) {
+  // Is the constant on the RHS or LHS?

rsmith wrote:
> It would probably be more obvious to use `||` here, since you already 
> returned in the case where both sides are constant.
And what if neither of them is constant?
I *think* we could reach this point in that case.
At least it is not immediately obvious to me why it can't happen.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



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


[PATCH] D38859: [clang] Enable clang build with LLVM_BUILD_INSTRUMENTED without setting LLVM_PROFTDATA

2017-10-12 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
Herald added a subscriber: mgorny.

At the moment if LLVM_BUILD_INSTRUMENTED is set to True 
one has to set LLVM_PROFTDATA even if it's not necessary (because of 
message(FATAL_ERROR ...)). 
Building instrumented Clang is useful even if one doesn't plan to use the 
target generate-profdata
(currently that target would use only 
llvm/tools/clang/utils/perf-training/cxx/hello_world.cpp as a source).
For example, one can run the instrumented version of Clang via a separate build 
system against a different codebase, 
collect the profiles and merge them by lllvm-profdata later.


Repository:
  rL LLVM

https://reviews.llvm.org/D38859

Files:
  utils/perf-training/CMakeLists.txt


Index: utils/perf-training/CMakeLists.txt
===
--- utils/perf-training/CMakeLists.txt
+++ utils/perf-training/CMakeLists.txt
@@ -30,13 +30,18 @@
   endif()
 
   if(NOT LLVM_PROFDATA)
-message(FATAL_ERROR "Must set LLVM_PROFDATA to point to llvm-profdata to 
use for merging PGO data")
+set(LLVM_PROFDATA ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
+message(STATUS "LLVM_PROFDATA is set to point to llvm-profdata built from 
the sources")
+set(GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA TRUE)
   endif()
-
+  
   add_custom_target(generate-profdata
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata 
${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Merging profdata"
 DEPENDS generate-profraw)
+  if (GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA)
+add_dependencies(generate-profdata llvm-profdata)
+  endif()
 endif()
 
 find_program(DTRACE dtrace)


Index: utils/perf-training/CMakeLists.txt
===
--- utils/perf-training/CMakeLists.txt
+++ utils/perf-training/CMakeLists.txt
@@ -30,13 +30,18 @@
   endif()
 
   if(NOT LLVM_PROFDATA)
-message(FATAL_ERROR "Must set LLVM_PROFDATA to point to llvm-profdata to use for merging PGO data")
+set(LLVM_PROFDATA ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
+message(STATUS "LLVM_PROFDATA is set to point to llvm-profdata built from the sources")
+set(GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA TRUE)
   endif()
-
+  
   add_custom_target(generate-profdata
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Merging profdata"
 DEPENDS generate-profraw)
+  if (GENERATE_PROFDATA_DEPENDS_ON_LLVM_PROFTDATA)
+add_dependencies(generate-profdata llvm-profdata)
+  endif()
 endif()
 
 find_program(DTRACE dtrace)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315611 - [OPENMP] Fix PR34927: Emit initializer for reduction array with declare

2017-10-12 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 12 13:03:39 2017
New Revision: 315611

URL: http://llvm.org/viewvc/llvm-project?rev=315611&view=rev
Log:
[OPENMP] Fix PR34927: Emit initializer for reduction array with declare
reduction.

If the reduction is an array or an array section and reduction operation
is declare reduction without initializer, it may lead to crash.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315611&r1=315610&r2=315611&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 12 13:03:39 2017
@@ -786,7 +786,8 @@ static void emitInitWithReductionInitial
 /// \param Init Initial expression of array.
 /// \param SrcAddr Address of the original array.
 static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr,
- QualType Type, const Expr *Init,
+ QualType Type, bool EmitDeclareReductionInit,
+ const Expr *Init,
  const OMPDeclareReductionDecl *DRD,
  Address SrcAddr = Address::invalid()) {
   // Perform element-by-element initialization.
@@ -840,7 +841,7 @@ static void EmitOMPAggregateInit(CodeGen
   // Emit copy.
   {
 CodeGenFunction::RunCleanupsScope InitScope(CGF);
-if (DRD && (DRD->getInitializer() || !Init)) {
+if (EmitDeclareReductionInit) {
   emitInitWithReductionInitializer(CGF, DRD, Init, DestElementCurrent,
SrcElementCurrent, ElementTy);
 } else
@@ -887,8 +888,12 @@ void ReductionCodeGen::emitAggregateInit
   // captured region.
   auto *PrivateVD =
   cast(cast(ClausesData[N].Private)->getDecl());
+  bool EmitDeclareReductionInit =
+  DRD && (DRD->getInitializer() || !PrivateVD->hasInit());
   EmitOMPAggregateInit(CGF, PrivateAddr, PrivateVD->getType(),
-   DRD ? ClausesData[N].ReductionOp : PrivateVD->getInit(),
+   EmitDeclareReductionInit,
+   EmitDeclareReductionInit ? ClausesData[N].ReductionOp
+: PrivateVD->getInit(),
DRD, SharedLVal.getAddress());
 }
 

Modified: cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp?rev=315611&r1=315610&r2=315611&view=diff
==
--- cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp Thu Oct 12 13:03:39 2017
@@ -9,6 +9,26 @@
 // CHECK: [[SSS_INT:.+]] = type { i32 }
 // CHECK-LOAD: [[SSS_INT:.+]] = type { i32 }
 
+// CHECK: add
+void add(short &out, short &in) {}
+
+#pragma omp declare reduction(my_add : short : add(omp_out, omp_in))
+
+// CHECK: define internal void @.
+// CHECK: call void @{{.+}}add{{.+}}(
+// CHECK: ret void
+
+// CHECK: foo_reduction_array
+void foo_reduction_array() {
+  short y[1];
+  // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(
+#pragma omp parallel for reduction(my_add : y)
+  for (int i = 0; i < 1; i++) {
+  }
+}
+
+// CHECK: define internal void @
+
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: define internal {{.*}}void @{{[^(]+}}(i32* noalias, i32* noalias)
 // CHECK: [[MUL:%.+]] = mul nsw i32


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


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 118833.
lebedev.ri added a comment.

Getting really weird problems when trying to use arc patch, maybe re-updating 
the differential helps


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,47 +1,370 @@
 // RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
 
-unsigned value(void);
+unsigned uvalue(void);
+signed int svalue(void);
 
-int main() {
-  unsigned un = value();
+#define macro(val) val
+
+#ifdef __cplusplus
+template
+void TFunc() {
+  // Make sure that we do warn for normal variables in template functions !
+  unsigned char c = svalue();
+#ifdef TEST
+  if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return;
+#else
+  if (c < 0)
+  return;
+#endif
+
+  if (c < macro(0))
+  return;
+
+  T v = svalue();
+  if (v < 0)
+  return;
+}
+#endif
+
+int main()
+{
+#ifdef __cplusplus
+  TFunc();
+  TFunc();
+#endif
+
+  unsigned un = uvalue();
 
 #ifdef TEST
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
+  return 0;
   if (0 > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
-  if (un < 0U) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
-  if (un >= 0U) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
-  if (0U <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
-  if (0U > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+  return 0;
+  if (0UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+  return 0;
+  if (0UL >= un)
+  return 0;
 #else
 // expected-no-diagnostics
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0)
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0)
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un)
-return 0;
+  return 0;
   if (0 > un)
-return 0;
-  if (un < 0U)
-return 0;
-  if (un >= 0U)
-return 0;
-  if (0U <= un)
-return 0;
-  if (0U > un)
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL)
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL)
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un)
+  return 0;
+  if (0UL > un)
+  return 0;
+  if (0UL >= un)
+  return 0;
 #endif
 
+
+  signed int a = svalue();
+
+#ifdef TEST
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
+  if (a < 0)
+  return 0;
+  if (a <= 0)
+  return 0;
+  if (a > 0)
+  return 0;
+  if (a >= 0)
+  return 0;
+
+  if (0 == a)
+  return 0;
+  if (0 != a)
+  re

r315614 - [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 13:16:51 2017
New Revision: 315614

URL: http://llvm.org/viewvc/llvm-project?rev=315614&view=rev
Log:
[Sema] Diagnose tautological comparison with type's min/max values

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/tautological-constant-compare.c
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/outof-range-constant-compare.c
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 12 13:16:51 2017
@@ -78,6 +78,10 @@ Improvements to Clang's diagnostics
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wtautological-constant-compare`` is a new warning that warns on
+  tautological comparisons between integer variable of the type ``T`` and the
+  largest/smallest possible integer constant of that same type.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Oct 12 13:16:51 2017
@@ -432,13 +432,15 @@ def StrncatSize : DiagGroup<"strncat-siz
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ 
TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315614&r1=315613&r2=315614&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 12 13:16:51 
2017
@@ -5938,18 +5938,18 @@ def note_typecheck_assign_const : Note<
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned expression}0 %2 "
+  "%select{unsigned expression|%3}0 is always %select{false|true}4">,
   InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: include/clang/Basic/AddressSpaces.h:66
 
+inline LangAS LangASFromTargetAS(unsigned TargetAS) {
+  return static_cast((TargetAS) +

how about `getLangASFromTargetAS` ? It is preferred to start with small letters.



Comment at: tools/libclang/CXType.cpp:402
+  ASTContext &Ctx = cxtu::getASTUnit(GetTU(CT))->getASTContext();
+  return Ctx.getTargetAddressSpace(T);
 }

Is this function suppose to return AST address space or target address space?

Some targets e.g. x86 maps all AST address spaces to 0. Returning target 
address space will not let the client unable to differentiate different address 
spaces in the source language.


https://reviews.llvm.org/D38816



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


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315614: [Sema] Diagnose tautological comparison with type's 
min/max values (authored by lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D38101?vs=118833&id=118835#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/outof-range-constant-compare.c
  cfe/trunk/test/Sema/tautological-constant-compare.c
  cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c

Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -78,6 +78,10 @@
   when the signed integer is coerced to an unsigned type for the comparison.
   ``-Wsign-compare`` was adjusted not to warn in this case.
 
+- ``-Wtautological-constant-compare`` is a new warning that warns on
+  tautological comparisons between integer variable of the type ``T`` and the
+  largest/smallest possible integer constant of that same type.
+
 - ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
   on a null pointer. Such pointer arithmetic has an undefined behavior if the
   offset is nonzero. It also now warns about arithmetic on a null pointer
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5938,18 +5938,18 @@
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned expression %0 is always %select{false|true}1">,
+def warn_unsigned_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned expression}0 %2 "
+  "%select{unsigned expression|%3}0 is always %select{false|true}4">,
   InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %0 unsigned expression is always %select{false|true}1">,
-  InGroup;
-def warn_lunsigned_enum_always_true_comparison : Warning<
-  "comparison of unsigned enum expression %0 is always %select{false|true}1">,
-  InGroup;
-def warn_runsigned_enum_always_true_comparison : Warning<
-  "comparison of %0 unsigned enum expression is always %select{false|true}1">,
+def warn_unsigned_enum_always_true_comparison : Warning<
+  "comparison of %select{%3|unsigned enum expression}0 %2 "
+  "%select{unsigned enum expression|%3}0 is always %select{false|true}4">,
   InGroup;
+def warn_tautological_constant_compare : Warning<
+  "comparison %select{%3|%1}0 %2 "
+  "%select{%1|%3}0 is always %select{false|true}4">,
+  InGroup;
 
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -432,13 +432,15 @@
 def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
+def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
+[TautologicalUnsignedZeroCompare,
+ TautologicalUnsignedEnumZeroCompare,
+ TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
- TautologicalOutOfRangeCompare,
+[TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
  TautologicalUndefinedCompare]>;
Index: cfe/trunk/test/Sema/outof-range-constant-compare.c
===
--- cfe/trunk/test/Sema/outof-range-constant-compare.c
+++ cfe/trunk/test/Sema/outof-range-constant-compare.c
@@ -7,58 +7,6 @@
 {
 int a = value();
 
-if (a == 

[PATCH] D38840: [compiler-rt] [cmake] [asan] Remove unnecessary gtest dep from dynamic tests

2017-10-12 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

LGTM, provided tests pass both in standalone and "normal" modes.


https://reviews.llvm.org/D38840



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


r315615 - [Analysis] Silence -Wtautological-constant-compare in two tests

2017-10-12 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Oct 12 13:27:41 2017
New Revision: 315615

URL: http://llvm.org/viewvc/llvm-project?rev=315615&view=rev
Log:
[Analysis] Silence -Wtautological-constant-compare in two tests

Yes, did not check that. Need to do better :(
I do not believe it makes sense to do expect that warning here.

Modified:
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/test/Analysis/conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/conversion.c?rev=315615&r1=315614&r2=315615&view=diff
==
--- cfe/trunk/test/Analysis/conversion.c (original)
+++ cfe/trunk/test/Analysis/conversion.c Thu Oct 12 13:27:41 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -Wno-conversion 
-analyzer-checker=core,alpha.core.Conversion -verify %s
+// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare 
-analyzer-checker=core,alpha.core.Conversion -verify %s
 
 unsigned char U8;
 signed char S8;

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=315615&r1=315614&r2=315615&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Thu Oct 12 13:27:41 2017
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-analyzer-purge=none -verify %s -Wno-error=return-type
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region 
-verify %s -Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s 
-Wno-error=return-type
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 
-Wno-tautological-constant-compare -analyzer-checker=core,deadcode,alpha.core 
-std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type
 
 typedef unsigned uintptr_t;
 


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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-12 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 118838.
Nebiroth marked an inline comment as done.
Nebiroth added a comment.

Addressed review comments.
Fixed some tests not having updated providers.
Removed TargetDeclarationFinder for less code reuse.
DocumentHighlight struct is now unparsed correctly.


https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -5,18 +5,21 @@
 Content-Length: 143
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -5,16 +5,17 @@
 Content-Length: 142
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":"","rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+# CHECK: Content-Length: 580
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
+# CHECK:   "codeActionProvider": true,
+# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
+# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
+# CHECK: }}}
+#
+
+Content-Length: 455
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "kind": 1},{"range": {"start": {"line": 17, "character": 0}, "end": {"line": 17, "c

[PATCH] D38840: [compiler-rt] [cmake] [asan] Remove unnecessary gtest dep from dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315620: [cmake] [asan] Remove unnecessary gtest dep from 
dynamic tests (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38840?vs=118826&id=118842#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38840

Files:
  compiler-rt/trunk/lib/asan/tests/CMakeLists.txt


Index: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()


Index: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm




Comment at: src/libunwind.cpp:188
+  co->getInfo(&info);
+  pint_t orgArgSize = (pint_t)info.gp;
+  uint64_t orgFuncStart = info.start_ip;

mstorsjo wrote:
> rnk wrote:
> > I think it makes sense to have this here: the contract is that if the 
> > personality sets the IP when the cursor pointed to a PC with a non-zero arg 
> > size, we should adjust SP for the personality.
> > 
> > However, it's not clear to me that we don't need the same adjustment when 
> > stepping across frames that use arg size without a frame pointer.
> When stepping across frames, the gnu args size is already included in, as 
> part of the CFA offset, so with the current code, it steps too far.
OK, yes, now I see the code that does that. :)


https://reviews.llvm.org/D38680



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


r315621 - [SemaChecking] Suppress a GCC warning. NFCI.

2017-10-12 Thread Davide Italiano via cfe-commits
Author: davide
Date: Thu Oct 12 14:08:29 2017
New Revision: 315621

URL: http://llvm.org/viewvc/llvm-project?rev=315621&view=rev
Log:
[SemaChecking] Suppress a GCC warning. NFCI.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=315621&r1=315620&r2=315621&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Oct 12 14:08:29 2017
@@ -8652,7 +8652,8 @@ bool CheckTautologicalComparison(Sema &S
 
   bool ConstIsLowerBound = (Op == BO_LT || Op == BO_LE) ^ RhsConstant;
   bool ResultWhenConstEqualsOther = (Op == BO_LE || Op == BO_GE);
-  bool ResultWhenConstNeOther = ConstIsLowerBound ^ ValueType == 
LimitType::Max;
+  bool ResultWhenConstNeOther =
+  ConstIsLowerBound ^ (ValueType == LimitType::Max);
   if (ResultWhenConstEqualsOther != ResultWhenConstNeOther)
 return false; // The comparison is not tautological.
 


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


[PATCH] D36111: [COFF, ARM64] Add MS builtins __dmb, __dsb, __isb

2017-10-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This one can be abandoned now.


https://reviews.llvm.org/D36111



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


  1   2   >