[PATCH] D45662: OpenBSD add C++ runtime in a driver's standpoint

2018-04-19 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330310: OpenBSD add C++ runtime in a driver's 
standpoint (authored by dberris, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45662?vs=142811&id=143049#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45662

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


Index: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
@@ -259,6 +259,14 @@
   getFilePaths().push_back("/usr/lib");
 }
 
+void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+  CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
+}
+
 Tool *OpenBSD::buildAssembler() const {
   return new tools::openbsd::Assembler(*this);
 }
Index: cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
===
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
@@ -58,6 +58,8 @@
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }
   bool isPIEDefault() const override { return true; }
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
 return 2;


Index: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
@@ -259,6 +259,14 @@
   getFilePaths().push_back("/usr/lib");
 }
 
+void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+  CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
+}
+
 Tool *OpenBSD::buildAssembler() const {
   return new tools::openbsd::Assembler(*this);
 }
Index: cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
===
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.h
@@ -58,6 +58,8 @@
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }
   bool isPIEDefault() const override { return true; }
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
 return 2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-04-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 143050.
zinovy.nis marked 4 inline comments as done.
zinovy.nis added a comment.

- Fixed issues pointed by Alexander.


https://reviews.llvm.org/D45776

Files:
  test/clang-tidy/check_clang_tidy.cpp
  test/clang-tidy/check_clang_tidy.py


Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,6 +42,7 @@
   parser.add_argument('-expect-clang-tidy-error', action='store_true')
   parser.add_argument('-resource-dir')
   parser.add_argument('-assume-filename')
+  parser.add_argument('-check-suffix', default='')
   parser.add_argument('input_file_name')
   parser.add_argument('check_name')
   parser.add_argument('temp_file_name')
@@ -70,6 +71,13 @@
   clang_tidy_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
+  if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix):
+sys.exit('Only A..Z, 0..9 and "-" are allowed in check suffix, but "%s" 
was given' % (args.check_suffix))
+
+  file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
+  check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
+  check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
   clang_tidy_extra_args.append('-nostdinc++')
@@ -80,17 +88,17 @@
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
 
-  has_check_fixes = input_text.find('CHECK-FIXES') >= 0
-  has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_fixes = check_fixes_prefix in input_text
+  has_check_messages = check_messages_prefix in input_text
 
   if not has_check_fixes and not has_check_messages:
-sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, 
check_messages_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
   # avoiding empty lines which could potentially trigger formatting-related
   # checks.
-  cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text)
+  cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
 
   write_file(temp_file_name, cleaned_test)
 
@@ -128,7 +136,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
-   '-check-prefix=CHECK-FIXES', '-strict-whitespace'],
+   '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
@@ -140,7 +148,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + messages_file, input_file_name,
-   '-check-prefix=CHECK-MESSAGES',
+   '-check-prefix=' + check_messages_prefix,
'-implicit-check-not={{warning|error}}:'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
Index: test/clang-tidy/check_clang_tidy.cpp
===
--- test/clang-tidy/check_clang_tidy.cpp
+++ test/clang-tidy/check_clang_tidy.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-A 
-- -DUSING_A
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-B 
-- -DUSING_B
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+namespace a {class A {}; class B {}; class C {}; }
+namespace b {
+#if defined(USING_A)
+using a::A;
+#elif  defined(USING_B)
+using a::B;
+#else
+using a::C;
+#endif
+}
+namespace c {}
+// CHECK-MESSAGES-USING-A: :[[@LINE-8]]:10: warning: using decl 'A' {{.*}}
+// CHECK-MESSAGES-USING-B: :[[@LINE-7]]:10: warning: using decl 'B' {{.*}}
+// CHECK-MESSAGES: :[[@LINE-6]]:10: warning: using decl 'C' {{.*}}
+// CHECK-FIXES-USING-A-NOT: using a::A;$
+// CHECK-FIXES-USING-B-NOT: using a::B;$
+// CHECK-FIXES-NOT: using a::C;$


Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,6 +42,7 @@
   parser.add_argument('-expect-clang-tidy-error', action='store_true')
   parser.add_argument('-resource-dir')
   parser.add_argument('-assume-filename')
+  parser.add_argument('-check-suffix', default='')
   parser.add_argument('input_file_name')
   parser.add_argument('check_name')
   parser.add_argument('temp_file_name')
@@ -70,6 +71,13 @@
   clang_tidy_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
+  if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix):
+sys

[PATCH] D45805: [libcxx] Remove redundant specializations in type_traits.

2018-04-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: cfe-commits, christof.

Repository:
  rCXX libc++

https://reviews.llvm.org/D45805

Files:
  include/type_traits


Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -553,9 +553,6 @@
 template <>
 struct __lazy_and_impl : true_type {};
 
-template 
-struct __lazy_and_impl : integral_constant {};
-
 template 
 struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, 
_Tp...> {};
 
@@ -591,25 +588,19 @@
 
 template struct __and_<_B0> : _B0 {};
 
-template
-struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
-
-template
-struct __and_<_B0, _B1, _B2, _Bn...> 
-: conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
+template
+struct __and_<_B0, _B1, _Bn...>
+: conditional<_B0::value, __and_<_B1, _Bn...>, _B0>::type {};
 
 // __or_
 template struct __or_;
 template<> struct __or_<> : false_type {};
 
 template struct __or_<_B0> : _B0 {};
 
-template
-struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
-
-template
-struct __or_<_B0, _B1, _B2, _Bn...> 
-: conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
+template
+struct __or_<_B0, _B1, _Bn...>
+: conditional<_B0::value, _B0, __or_<_B1, _Bn...> >::type {};
 
 // __not_
 template 


Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -553,9 +553,6 @@
 template <>
 struct __lazy_and_impl : true_type {};
 
-template 
-struct __lazy_and_impl : integral_constant {};
-
 template 
 struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {};
 
@@ -591,25 +588,19 @@
 
 template struct __and_<_B0> : _B0 {};
 
-template
-struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
-
-template
-struct __and_<_B0, _B1, _B2, _Bn...> 
-: conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
+template
+struct __and_<_B0, _B1, _Bn...>
+: conditional<_B0::value, __and_<_B1, _Bn...>, _B0>::type {};
 
 // __or_
 template struct __or_;
 template<> struct __or_<> : false_type {};
 
 template struct __or_<_B0> : _B0 {};
 
-template
-struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
-
-template
-struct __or_<_B0, _B1, _B2, _Bn...> 
-: conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
+template
+struct __or_<_B0, _B1, _Bn...>
+: conditional<_B0::value, _B0, __or_<_B1, _Bn...> >::type {};
 
 // __not_
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Henrik Gramner via cfe-commits
The force_align_arg_pointer attribute was using a hardcoded 16-byte
alignment value which in combination with -mstack-alignment=32 (or
larger) would produce a misaligned stack which could result in crashes
when accessing stack buffers using aligned AVX load/store
instructions.

The attached patch fixes the issue by using the "stackrealign"
function attribute instead of using a hardcoded 16-byte alignment.

Tested on 64-bit Linux and it works as far as I can see, unable to
test on anything else though.


force_align_arg_pointer.diff
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-04-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 143052.
zinovy.nis added a comment.

- Updated docs.


https://reviews.llvm.org/D45776

Files:
  docs/clang-tidy/index.rst
  test/clang-tidy/check_clang_tidy.cpp
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,6 +42,7 @@
   parser.add_argument('-expect-clang-tidy-error', action='store_true')
   parser.add_argument('-resource-dir')
   parser.add_argument('-assume-filename')
+  parser.add_argument('-check-suffix', default='')
   parser.add_argument('input_file_name')
   parser.add_argument('check_name')
   parser.add_argument('temp_file_name')
@@ -70,6 +71,13 @@
   clang_tidy_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
+  if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix):
+sys.exit('Only A..Z, 0..9 and "-" are allowed in check suffix, but "%s" was given' % (args.check_suffix))
+
+  file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
+  check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
+  check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
   clang_tidy_extra_args.append('-nostdinc++')
@@ -80,17 +88,17 @@
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
 
-  has_check_fixes = input_text.find('CHECK-FIXES') >= 0
-  has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_fixes = check_fixes_prefix in input_text
+  has_check_messages = check_messages_prefix in input_text
 
   if not has_check_fixes and not has_check_messages:
-sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
   # avoiding empty lines which could potentially trigger formatting-related
   # checks.
-  cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text)
+  cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
 
   write_file(temp_file_name, cleaned_test)
 
@@ -128,7 +136,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
-   '-check-prefix=CHECK-FIXES', '-strict-whitespace'],
+   '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
@@ -140,7 +148,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + messages_file, input_file_name,
-   '-check-prefix=CHECK-MESSAGES',
+   '-check-prefix=' + check_messages_prefix,
'-implicit-check-not={{warning|error}}:'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
Index: test/clang-tidy/check_clang_tidy.cpp
===
--- test/clang-tidy/check_clang_tidy.cpp
+++ test/clang-tidy/check_clang_tidy.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-A -- -DUSING_A
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-B -- -DUSING_B
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+namespace a {class A {}; class B {}; class C {}; }
+namespace b {
+#if defined(USING_A)
+using a::A;
+#elif  defined(USING_B)
+using a::B;
+#else
+using a::C;
+#endif
+}
+namespace c {}
+// CHECK-MESSAGES-USING-A: :[[@LINE-8]]:10: warning: using decl 'A' {{.*}}
+// CHECK-MESSAGES-USING-B: :[[@LINE-7]]:10: warning: using decl 'B' {{.*}}
+// CHECK-MESSAGES: :[[@LINE-6]]:10: warning: using decl 'C' {{.*}}
+// CHECK-FIXES-USING-A-NOT: using a::A;$
+// CHECK-FIXES-USING-B-NOT: using a::B;$
+// CHECK-FIXES-NOT: using a::C;$
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -673,6 +673,27 @@
 // CHECK-FIXES: int b = a;
   }
 
+To check more than one scenario in the same test file use 
+``-check-suffix=SUFFIX_NAME`` on ``check_clang_tidy.py`` command line.
+With ``-check-suffix=SUFFIX_NAME`` you need to replace your ``CHECK-*`` 
+directives with ``CHECK-MESSAGES-SUFFIX-NAME`` and ``CHECK-FIXES-SUFFIX-NAME``.
+
+Here's an example:
+
+.. code-block:: c++
+
+   // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-A -- -DUSING_A
+   // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-B -- -DUSING_B
+   // RUN: %check_clang_tidy %

[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-04-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 143053.
zinovy.nis added a comment.

- Removed exec attribute on file.


https://reviews.llvm.org/D45776

Files:
  docs/clang-tidy/index.rst
  test/clang-tidy/check_clang_tidy.cpp
  test/clang-tidy/check_clang_tidy.py

Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -42,6 +42,7 @@
   parser.add_argument('-expect-clang-tidy-error', action='store_true')
   parser.add_argument('-resource-dir')
   parser.add_argument('-assume-filename')
+  parser.add_argument('-check-suffix', default='')
   parser.add_argument('input_file_name')
   parser.add_argument('check_name')
   parser.add_argument('temp_file_name')
@@ -70,6 +71,13 @@
   clang_tidy_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
+  if args.check_suffix and not re.match('^[A-Z0-9\-]+$', args.check_suffix):
+sys.exit('Only A..Z, 0..9 and "-" are allowed in check suffix, but "%s" was given' % (args.check_suffix))
+
+  file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else ''
+  check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix
+  check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix
+
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
   clang_tidy_extra_args.append('-nostdinc++')
@@ -80,17 +88,17 @@
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
 
-  has_check_fixes = input_text.find('CHECK-FIXES') >= 0
-  has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_fixes = check_fixes_prefix in input_text
+  has_check_messages = check_messages_prefix in input_text
 
   if not has_check_fixes and not has_check_messages:
-sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) )
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
   # avoiding empty lines which could potentially trigger formatting-related
   # checks.
-  cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text)
+  cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
 
   write_file(temp_file_name, cleaned_test)
 
@@ -128,7 +136,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
-   '-check-prefix=CHECK-FIXES', '-strict-whitespace'],
+   '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
   print('FileCheck failed:\n' + e.output.decode())
@@ -140,7 +148,7 @@
 try:
   subprocess.check_output(
   ['FileCheck', '-input-file=' + messages_file, input_file_name,
-   '-check-prefix=CHECK-MESSAGES',
+   '-check-prefix=' + check_messages_prefix,
'-implicit-check-not={{warning|error}}:'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
Index: test/clang-tidy/check_clang_tidy.cpp
===
--- test/clang-tidy/check_clang_tidy.cpp
+++ test/clang-tidy/check_clang_tidy.cpp
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-A -- -DUSING_A
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-B -- -DUSING_B
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+namespace a {class A {}; class B {}; class C {}; }
+namespace b {
+#if defined(USING_A)
+using a::A;
+#elif  defined(USING_B)
+using a::B;
+#else
+using a::C;
+#endif
+}
+namespace c {}
+// CHECK-MESSAGES-USING-A: :[[@LINE-8]]:10: warning: using decl 'A' {{.*}}
+// CHECK-MESSAGES-USING-B: :[[@LINE-7]]:10: warning: using decl 'B' {{.*}}
+// CHECK-MESSAGES: :[[@LINE-6]]:10: warning: using decl 'C' {{.*}}
+// CHECK-FIXES-USING-A-NOT: using a::A;$
+// CHECK-FIXES-USING-B-NOT: using a::B;$
+// CHECK-FIXES-NOT: using a::C;$
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -673,6 +673,27 @@
 // CHECK-FIXES: int b = a;
   }
 
+To check more than one scenario in the same test file use 
+``-check-suffix=SUFFIX_NAME`` on ``check_clang_tidy.py`` command line.
+With ``-check-suffix=SUFFIX_NAME`` you need to replace your ``CHECK-*`` 
+directives with ``CHECK-MESSAGES-SUFFIX-NAME`` and ``CHECK-FIXES-SUFFIX-NAME``.
+
+Here's an example:
+
+.. code-block:: c++
+
+   // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-A -- -DUSING_A
+   // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check-suffix=USING-B -- -DUSING_B
+   // RUN: %

[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-04-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Done.


https://reviews.llvm.org/D45776



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


[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py

2018-04-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: test/clang-tidy/check_clang_tidy.py:77
+
+  check_fixes_prefix = 'CHECK-FIXES' + args.check_suffix
+  check_messages_prefix = 'CHECK-MESSAGES' + args.check_suffix

alexfh wrote:
> Maybe the script should add a dash when check_suffix is not empty, so that 
> one could use -check-suffix=FLAG instead of -check-suffix=-FLAG?
OK.


https://reviews.llvm.org/D45776



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


[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/XRefs.cpp:209
 
+  llvm::DenseSet QuerySyms;
+  llvm::DenseMap ResultCandidates;

the approach could some documentation - I find it hard to follow the code.

This function is probably too big by now and should be split up - but without 
understanding the goal I can't suggest how.



Comment at: clangd/XRefs.cpp:216
+  log("Could not creat location for Loc");
+  continue;
+}

this seems suspicious to me - if we can't find an AST based location for the 
symbol, why would that mean giving up without consulting the index?



Comment at: clangd/XRefs.cpp:224
+bool IsDef = GetDefinition(D) == D;
+// Query the index if there is no definition point in the local AST.
+if (!IsDef)

isn't the condition here something else - that there's at least one declaration 
that isn't a definition?



Comment at: clangd/XRefs.cpp:239
+  assert(it != ResultCandidates.end());
+  if (Sym.Definition) {
+auto Uri = URI::parse(Sym.Definition.FileURI);

why are we ignoring the index if it's not a definition (and therefore 
preferring the AST one?)



Comment at: clangd/XRefs.cpp:261
+
+  for (auto It : ResultCandidates)
+Result.push_back(It.second);

Here we're returning exactly one candidate per symbol we identified as a 
candidate. There are other choices - why this one?



Comment at: clangd/XRefs.h:26
+std::vector findDefinitions(ParsedAST &AST, Position Pos,
+  const SymbolIndex *const Index = 
nullptr);
 

nit: drop the second const here? we don't normally bother to mark by-value 
parameters as const (particularly not in declarations)



Comment at: unittests/clangd/XRefsTests.cpp:109
 
+TEST(GoToDefinition, WithIndex) {
+  MockFSProvider FS;

We have a findDefinitionsHelper to avoid all this boilerplate.
Can you extend/overload it it to work with index?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-19 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

Hi All,
Are there other issues related to this patch?
If NO could anyone give me LGTM? I need this patch committed to continue with 
recursive time counters.


https://reviews.llvm.org/D45619



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


Re: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Martin Storsjö via cfe-commits

Hej Henrik,

On Thu, 19 Apr 2018, Henrik Gramner via cfe-commits wrote:


The force_align_arg_pointer attribute was using a hardcoded 16-byte
alignment value which in combination with -mstack-alignment=32 (or
larger) would produce a misaligned stack which could result in crashes
when accessing stack buffers using aligned AVX load/store
instructions.

The attached patch fixes the issue by using the "stackrealign"
function attribute instead of using a hardcoded 16-byte alignment.

Tested on 64-bit Linux and it works as far as I can see, unable to
test on anything else though.


You need to update the corresponding tests as well, run "ninja 
check-clang" to see that this change alters the output from 
test/CodeGen/function-attributes.c, breaking that test. You at least need 
to update it with how this patch changes the behaviour of the existing 
tests, but ideally also add a new test case (either in this file or as a 
completely new file) for the specific usecase that you had in mind (32 
byte alignment).


For better visibility, I'd also recommend uploading the patch at 
https://reviews.llvm.org (even though the official guidelines say this is 
optional). I don't know off-hand who would be best to add as reviewer for 
it though (I'm not authoritative in this area)...


// Martin

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


[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/XRefs.cpp:209
 
+  llvm::DenseSet QuerySyms;
+  llvm::DenseMap ResultCandidates;

sammccall wrote:
> the approach could some documentation - I find it hard to follow the code.
> 
> This function is probably too big by now and should be split up - but without 
> understanding the goal I can't suggest how.
Having read the code in more detail, I'd suggest a structure like:
 - we identify the symbols being searched for
 - for each, we have a definition slot and a non-definition slot
 - initially we populate one of the slots with our preferred declaration from 
the AST (if location is available)
 - then we query the index and overwrite either/both slots with returned info
 - finally, we return populated slots for all symbols, definition first

(It's not clear how to order the returned symbols if there are multiple. When 
can this happen?)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717



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


[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.

2018-04-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: jkorous.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45442



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


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping


https://reviews.llvm.org/D45255



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-19 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

I tried my checker on 10 famous open source project, this is the outcome:

F5977628: curl_lib_transfer_c.html 
F5977629: ffmpeg_libavformat_sdp_c.html 
F5977631: openssl_apps_ca_c.html 
F5977633: postgresql_src_backend_libpq_auth_c.html 

F5977635: postgresql_src_backend_utils_adt_cash_c.html 

F5977636: postgresql_src_interfaces_ecpg_compatlib_informix_c.html 

F5977637: postgresql_src_interfaces_ecpg_pgtypeslib_datetime_c.html 



https://reviews.llvm.org/D45050



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


[PATCH] D45807: [libclang] Fix test LibclangReparseTest.FileName when TMPDIR is set to a symbolic link

2018-04-19 Thread Petr Pavlu via Phabricator via cfe-commits
petpav01 created this revision.
petpav01 added reviewers: MaskRay, jbcoe.
Herald added a subscriber: cfe-commits.

Commit r329515 
 recently 
added new test `LibclangReparseTest.FileName`. This test fails in an 
environment which has `TMPDIR` set to a symbolic link that points to an actual 
directory.

Example:

  build$ ln -s /tmp mytmp
  build$ TMPDIR=$PWD/mytmp ./tools/clang/unittests/libclang/libclangTests
  [...]
  [--] 5 tests from LibclangReparseTest
  [ RUN  ] LibclangReparseTest.FileName
  .../tools/clang/unittests/libclang/LibclangTest.cpp:497: Failure
  Value of: strstr(clang_getCString(cxname), CppName.c_str())
Actual: false
  Expected: true
  [  FAILED  ] LibclangReparseTest.FileName (10 ms)
  [...]

`CppName` is the original path in form `$tmpdir/libclang-test-xx/main.cpp`. 
Value `cxname` is obtained through `clang_File_tryGetRealPathName()` which 
gives the real path with the symlink resolved. The test fails because these two 
paths do not match.

The proposed patch addresses the problem by checking only that the value 
returned by `clang_File_tryGetRealPathName()` ends with "main.cpp".

Additionally, the patch makes the previous assertion in the test that checks 
result of `clang_getFileName()` stricter. It newly verifies that the name 
returned by the function is exactly same as what was given to 
`clang_parseTranslationUnit()`/`clang_getFile()`.


Repository:
  rC Clang

https://reviews.llvm.org/D45807

Files:
  unittests/libclang/LibclangTest.cpp


Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "clang-c/Index.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -490,11 +491,11 @@
   CXFile cxf = clang_getFile(ClangTU, CppName.c_str());
 
   CXString cxname = clang_getFileName(cxf);
-  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  ASSERT_STREQ(clang_getCString(cxname), CppName.c_str());
   clang_disposeString(cxname);
 
   cxname = clang_File_tryGetRealPathName(cxf);
-  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  ASSERT_TRUE(llvm::StringRef(clang_getCString(cxname)).endswith("main.cpp"));
   clang_disposeString(cxname);
 }
 


Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "clang-c/Index.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -490,11 +491,11 @@
   CXFile cxf = clang_getFile(ClangTU, CppName.c_str());
 
   CXString cxname = clang_getFileName(cxf);
-  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  ASSERT_STREQ(clang_getCString(cxname), CppName.c_str());
   clang_disposeString(cxname);
 
   cxname = clang_File_tryGetRealPathName(cxf);
-  ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str()));
+  ASSERT_TRUE(llvm::StringRef(clang_getCString(cxname)).endswith("main.cpp"));
   clang_disposeString(cxname);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Shouldn't it catch in curl also this code?

urllen = strlen(url_clone);
 
memcpy(newest, url_clone, urllen);


https://reviews.llvm.org/D45050



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


[PATCH] D45808: [OpenCL] Add 'denorms-are-zero' function attribute

2018-04-19 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb created this revision.
krisb added reviewers: Anastasia, yaxunl.
Herald added a subscriber: cfe-commits.

Generate attribute 'denorms-are-zero'='true' if '-cl-denorms-are-zero'
compile option was specified and 'denorms-are-zero'='false' otherwise.


Repository:
  rC Clang

https://reviews.llvm.org/D45808

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenOpenCL/denorms-are-zero.cl


Index: test/CodeGenOpenCL/denorms-are-zero.cl
===
--- test/CodeGenOpenCL/denorms-are-zero.cl
+++ test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,19 +1,20 @@
-// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s 
| FileCheck %s --check-prefix=CHECK-DENORM
-// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature 
-fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s 
| FileCheck %s --check-prefix=AMDGCN-DENORM
+// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature 
-fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck --check-prefix=AMDGCN-FEATURE %s
 
-// For non-amdgcn targets, this test just checks that the -cl-denorms-are-zero 
argument is accepted
-// by clang.  This option is currently a no-op, which is allowed by the
-// OpenCL specification.
+// For all targets 'denorms-are-zero' attribute is set to 'true'
+
+// CHECK-LABEL: define void @f()
+// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true"
 
 // For amdgcn target cpu fiji, fp32 should be flushed since fiji does not 
support fp32 denormals, unless +fp32-denormals is
 // explicitly set. amdgcn target always do not flush fp64 denormals. The 
control for fp64 and fp16 denormals is the same.
 
-// CHECK-DENORM-LABEL: define void @f()
-// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-LABEL: define void @f()
-// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-FEATURE-LABEL: define void @f()
-// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
+// AMDGCN-LABEL: define void @f()
+// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// AMDGCN-DENORM-LABEL: define void @f()
+// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// AMDGCN-FEATURE-LABEL: define void @f()
+// AMDGCN-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
 void f() {}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1745,6 +1745,10 @@
 "correctly-rounded-divide-sqrt-fp-math",
 llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt));
 
+if (getLangOpts().OpenCL)
+  FuncAttrs.addAttribute("denorms-are-zero",
+ llvm::toStringRef(CodeGenOpts.FlushDenorm));
+
 // TODO: Reciprocal estimate codegen options should apply to instructions?
 const std::vector &Recips = CodeGenOpts.Reciprocals;
 if (!Recips.empty())


Index: test/CodeGenOpenCL/denorms-are-zero.cl
===
--- test/CodeGenOpenCL/denorms-are-zero.cl
+++ test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,19 +1,20 @@
-// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM
-// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-c

[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.This required a couple of yaks to be shaved:1. MatchingOpeningBlockLineIndex was misused to also store the

2018-04-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Great patch!




Comment at: lib/Format/AffectedRangeManager.cpp:144
+  Line->First->is(tok::r_brace) &&
+  Line->MatchingOpeningBlockLineIndex != -1 &&
+  Lines[Line->MatchingOpeningBlockLineIndex]->Affected;

nit: replace `-1` with `UnwrappedLine::kInvalidIndex`



Comment at: lib/Format/UnwrappedLineParser.h:58
+
+  /// \brief The corresponding closing line to MatchingOpeningBlockLineIndex.
+  size_t MatchingClosingBlockLineIndex = kInvalidIndex;

This comment could be improved. I interpret it as: start with the line at 
`MatchingOpeningBlockLineIndex`, and store the closing block line index of it, 
which will result in just the index of the current line being stored here if it 
closes a block.


Repository:
  rC Clang

https://reviews.llvm.org/D45726



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


[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.

2018-04-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Another point: for the example in the summary about bailing-out early, is there 
a test for this already? If not, we should add one.


Repository:
  rC Clang

https://reviews.llvm.org/D45726



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Another idea if you want to implement it - check fopen.

FILE *f = fopen("file", "r"); // read only
fputs("str", f); // we are writing -> boom, sigsegv or something like that.


https://reviews.llvm.org/D45050



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


[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option

2018-04-19 Thread Simon Dardis via Phabricator via cfe-commits
sdardis requested changes to this revision.
sdardis added a comment.
This revision now requires changes to proceed.

A quick comment on the error message, inlined. It's about the quality of the 
diagnostics.




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:336-337
+def warn_drv_unsupported_pic : Warning<
+  "ignoring '-fno-pic' option as it cannot be used with "
+  "-mabicalls and the N64 ABI">,
   InGroup;

Can you fine tune this error message to say:

"ignoring '-fno-pic' option as it cannot be used with explicit use of 
-mabicalls and the N64 ABI" when -mabicalls is used on the commandline and:

"ignoring '-fno-pic' option as it cannot be used with implicit use of 
-mabicalls and the N64 ABI" when -mno-abicalls and -mabicalls are not present.

You should also report the precise pic/PIC/pie/PIE option used in the error 
message. You should be able to get it from the argument directly: 
http://llvm.org/doxygen/classllvm_1_1opt_1_1Arg.html


Repository:
  rC Clang

https://reviews.llvm.org/D44684



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


[PATCH] D45808: [OpenCL] Add 'denorms-are-zero' function attribute

2018-04-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/CodeGenOpenCL/denorms-are-zero.cl:9
+// CHECK-LABEL: define void @f()
+// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true"
 

Could we add a check for the false case too?



Comment at: test/CodeGenOpenCL/denorms-are-zero.cl:14
 
-// CHECK-DENORM-LABEL: define void @f()
-// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-LABEL: define void @f()
-// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-FEATURE-LABEL: define void @f()
-// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
+// AMDGCN-LABEL: define void @f()
+// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"

Should we check `denorms-are-zero` here as well?


Repository:
  rC Clang

https://reviews.llvm.org/D45808



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


[PATCH] D45764: [clangd][tests] Fix delimiter handling

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Oops, thanks! LG, optional suggestion




Comment at: JSONRPCDispatcher.cpp:281
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;

This trades one gotcha (empty lines delimit) for another ( looks valid, but 
isn't).
What about adding LineRef.startswith("-") to the original check?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45764



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


[PATCH] D45777: [UnitTests] NFC/build-perf: Break up nontrivial compile jobs

2018-04-19 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Ping. Any review feedback would be appreciated. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45777



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


[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

I can't see the bug/change related to "Comments should be allowed at the end of 
test files." can you elaborate?




Comment at: clangd/delimited-input-comment-at-the-end.test:7
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: Input message terminated by EOF

I'd actually lean towards dropping this test.
It's asserting that a magic string isn't present, and this patch removes the 
only occurrence of the magic string from the code. I like the drive to test 
every change, but it's hard to see this one ever failing :-)

(if you need a test with a trailing comment, maybe just throw one on the test 
from the other patch and call it `delimited.test`)?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45763



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-04-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 143068.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/bugprone/ExceptionEscapeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-exception-escape.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-exception-escape.cpp

Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -0,0 +1,256 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: bugprone-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: bugprone-exception-escape.EnabledFunctions, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  if (n) throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+if (n) throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1; 
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' th

[PATCH] D45095: [clang-tidy] Align usage of ClangTool interface with new VFS injection

2018-04-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:91
 public:
-  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
-llvm::IntrusiveRefCntPtr BaseFS)
-  : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
+  ErrorReporter(ClangTidyContext &Context, bool ApplyFixes, ClangTool &Tool)
+  : Files(FileSystemOptions(), Tool.getFiles().getVirtualFileSystem()),

whisperity wrote:
> ilya-biryukov wrote:
> > Why do we need to change the signature of `ErrorReporter` constructor?
> > Broadening the accepted interface does not seem right. It only needs the 
> > vfs and the clients could get vfs from `ClangTool` themselves.
> Is it okay interface-wise if the FS used by the `ErrorReporter` is **not** 
> the same as the one used by the module that produced the errors? It seems 
> like an undocumented consensus/convention that the same VFS should have been 
> passed here.
I find actually documenting that the vfs should be the same to be a better 
option. Or even sharing the `FileManager`, but that might be more involved.

The problem of passing `ClangTool` is that it's a much more powerful than what 
we need (e.g. it allows to rerun clang-tidy, which is certainly not something 
that `ErrorReporter` should do).



Comment at: clang-tidy/tool/CMakeLists.txt:19
   clangBasic
+  clangFrontend
   clangTidy

whisperity wrote:
> ilya-biryukov wrote:
> > Why do we need an extra dependency?
> In the current state of the patch, `clang-tidy/tool/ClangTidyMain.cpp` 
> constructs the `ClangTool` which constructor requires a 
> `std::shared_ptr`. `PCHContainerOperations`'s 
> definition and implementation is part of the `clangFrontend` library, and 
> without this dependency, there would be a symbol resolution error.
Thanks for clarification.
Does it mean that to use `ClangTool` one needs both a dependency on 
`clangTooling` and `clangFrontend`?
That's weird, given that `clangTooling` itself depends on `clangFrontend` and 
it would be nice if the buildsystem actually propagated those.


https://reviews.llvm.org/D45095



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


[PATCH] D45373: [clang-format] Don't remove empty lines before namespace endings

2018-04-19 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.




Comment at: lib/Format/NamespaceEndCommentsFixer.h:24
 
+// Finds the namespace token corresponding to a closing namespace `}`, if that
+// is to be formatted.

I don't understand the "if that is to be formatted part". What do you mean?


Repository:
  rC Clang

https://reviews.llvm.org/D45373



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


[PATCH] D45373: [clang-format] Don't remove empty lines before namespace endings

2018-04-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: lib/Format/NamespaceEndCommentsFixer.h:24
 
+// Finds the namespace token corresponding to a closing namespace `}`, if that
+// is to be formatted.

djasper wrote:
> I don't understand the "if that is to be formatted part". What do you mean?
I'm documenting the current behavior of the implementation, getting into more 
detail in the next paragraph of the comments: this returns `nullptr` if `Line` 
is not `Affected`, even if otherwise would have a namespace token.


Repository:
  rC Clang

https://reviews.llvm.org/D45373



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


[PATCH] D44786: Lowering x86 adds/addus/subs/subus intrinsics (clang)

2018-04-19 Thread Alexander Ivchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330323: Lowering x86 adds/addus/subs/subus intrinsics 
(clang) (authored by aivchenk, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44786

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/avx2-builtins.c
  cfe/trunk/test/CodeGen/avx512bw-builtins.c
  cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
  cfe/trunk/test/CodeGen/sse2-builtins.c

Index: cfe/trunk/test/CodeGen/avx2-builtins.c
===
--- cfe/trunk/test/CodeGen/avx2-builtins.c
+++ cfe/trunk/test/CodeGen/avx2-builtins.c
@@ -56,25 +56,53 @@
 
 __m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_adds_epi8
-  // CHECK: call <32 x i8> @llvm.x86.avx2.padds.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK-NOT: call <32 x i8> @llvm.x86.avx2.padds.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: add <32 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <32 x i16> %{{.*}}, 
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> 
+  // CHECK: icmp slt <32 x i16> %{{.*}}, 
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i16> , <32 x i16> %{{.*}}
+  // CHECK: trunc <32 x i16> %{{.*}} to <32 x i8>
   return _mm256_adds_epi8(a, b);
 }
 
 __m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_adds_epi16
-  // CHECK: call <16 x i16> @llvm.x86.avx2.padds.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK-NOT: call <16 x i16> @llvm.x86.avx2.padds.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK: sext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: sext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: add <16 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <16 x i32> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> 
+  // CHECK: icmp slt <16 x i32> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> , <16 x i32> %{{.*}}
+  // CHECK: trunc <16 x i32> %{{.*}} to <16 x i16>
   return _mm256_adds_epi16(a, b);
 }
 
 __m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_adds_epu8
-  // CHECK: call <32 x i8> @llvm.x86.avx2.paddus.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK-NOT: call <32 x i8> @llvm.x86.avx2.paddus.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK: zext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: zext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: add <32 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp ule <32 x i16> %{{.*}}, 
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> 
+  // CHECK: trunc <32 x i16> %{{.*}} to <32 x i8>
   return _mm256_adds_epu8(a, b);
 }
 
 __m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_adds_epu16
-  // CHECK: call <16 x i16> @llvm.x86.avx2.paddus.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK-NOT: call <16 x i16> @llvm.x86.avx2.paddus.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK: zext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: zext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: add <16 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp ule <16 x i32> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> 
+  // CHECK: trunc <16 x i32> %{{.*}} to <16 x i16>
   return _mm256_adds_epu16(a, b);
 }
 
@@ -1171,25 +1199,47 @@
 
 __m256i test_mm256_subs_epi8(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_subs_epi8
-  // CHECK: call <32 x i8> @llvm.x86.avx2.psubs.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK-NOT: call <32 x i8> @llvm.x86.avx2.psubs.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
+  // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
+  // CHECK: sub <32 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <32 x i16> %{{.*}}, 
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> 
+  // CHECK: icmp slt <32 x i16> %{{.*}}, 
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i16> , <32 x i16> %{{.*}}
+  // CHECK: trunc <32 x i16> %{{.*}} to <32 x i8>
   return _mm256_subs_epi8(a, b);
 }
 
 __m256i test_mm256_subs_epi16(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_subs_epi16
-  // CHECK: call <16 x i16> @llvm.x86.avx2.psubs.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK-NOT: call <16 x i16> @llvm.x86.avx2.psubs.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
+  // CHECK: sext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: sext <16 x i16> %{{.*}} to <16 x i32>
+  // CHECK: sub <16 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <16 x i32> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> 
+  // CHECK: icmp slt <16 x i32> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> , <16 x i32> %{{.*}}
+  // CHECK: trunc <16 x i32> %{{.*}} to <16 x i16>
   return _mm256_subs_epi16(a, b

[PATCH] D45808: [OpenCL] Add 'denorms-are-zero' function attribute

2018-04-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45808



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


[PATCH] D45808: [OpenCL] Add 'denorms-are-zero' function attribute

2018-04-19 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 143072.
krisb added a comment.

Applied the comments


Repository:
  rC Clang

https://reviews.llvm.org/D45808

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenOpenCL/denorms-are-zero.cl


Index: test/CodeGenOpenCL/denorms-are-zero.cl
===
--- test/CodeGenOpenCL/denorms-are-zero.cl
+++ test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,19 +1,25 @@
-// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s 
| FileCheck %s --check-prefix=CHECK-DENORM
-// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature 
-fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s 
--check-prefix=DENORM-ZERO
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s 
| FileCheck %s --check-prefix=AMDGCN-DENORM
+// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature 
-fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa 
-target-cpu fiji %s | FileCheck --check-prefix=AMDGCN-FEATURE %s
 
-// For non-amdgcn targets, this test just checks that the -cl-denorms-are-zero 
argument is accepted
-// by clang.  This option is currently a no-op, which is allowed by the
-// OpenCL specification.
+// For all targets 'denorms-are-zero' attribute is set to 'true'
+// if '-cl-denorms-are-zero' was specified and  to 'false' otherwise.
+
+// CHECK-LABEL: define void @f()
+// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false"
+//
+// DENORM-ZERO-LABEL: define void @f()
+// DENORM-ZERO: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true"
 
 // For amdgcn target cpu fiji, fp32 should be flushed since fiji does not 
support fp32 denormals, unless +fp32-denormals is
 // explicitly set. amdgcn target always do not flush fp64 denormals. The 
control for fp64 and fp16 denormals is the same.
 
-// CHECK-DENORM-LABEL: define void @f()
-// CHECK-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-LABEL: define void @f()
-// CHECK: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// CHECK-FEATURE-LABEL: define void @f()
-// CHECK-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} 
"target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
+// AMDGCN-LABEL: define void @f()
+// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" 
{{.*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// AMDGCN-DENORM-LABEL: define void @f()
+// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} 
"denorms-are-zero"="false" {{.*}} 
"target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// AMDGCN-FEATURE-LABEL: define void @f()
+// AMDGCN-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} 
"denorms-are-zero"="true" {{.*}} 
"target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
 void f() {}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1745,6 +1745,10 @@
 "correctly-rounded-divide-sqrt-fp-math",
 llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt));
 
+if (getLangOpts().OpenCL)
+  FuncAttrs.addAttribute("denorms-are-zero",
+ llvm::toStringRef(CodeGenOpts.FlushDenorm));
+
 // TODO: Reciprocal estimate codegen options should apply to instructions?
 const std::vector &Recips = CodeGenOpts.Reciprocals;
 if (!Recips.empty())


Index: test/CodeGenOpenCL/denorms-are-zero.cl
===
--- test/CodeGenOpenCL/denorms-are-zero.cl
+++ test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,19 +1,25 @@
-// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=CHECK-DENORM
-// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=CHECK-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %c

[PATCH] D45284: [RISCV] More validations on the input value of -march=

2018-04-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.
Herald added a subscriber: edward-jones.

This is looking great, the only remaining code comment I have is that 
getExtensionFeatures needs a comment describing it.

The remaining issue I have is more of a spec issue - do canonical ordering 
requirements apply to extension categories? e.g. is sfoo_xbar illegal because 
it should be ordered xbar_sfoo? From my reading of the note below table 22.1 in 
the spec I think it is illegal and ordering of non-standard user-level vs 
standard supervisor-level vs nons-standard supervisor-level should be checked. 
Do you agree with my interpretation?


https://reviews.llvm.org/D45284



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


[PATCH] D45478: [clangd] Merge symbols in global-sym-builder on the go

2018-04-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.
Herald added a subscriber: jkorous.

In https://reviews.llvm.org/D45478#1064027, @sammccall wrote:

> Is this patch still relevant after haojian's string deduplication?


Apparently it does. It has an advantage of distributing the work more evenly 
between the program runs.
Currently the tool reports progress based on the number of files it parsed. But 
then it takes a lot of time to actually merge all the symbols at the end and 
the progress is not reported during that time.

The perfect behavior would be to remove duplicates, not just intern them :-) 
That shouldn't be too hard and it probably even makes sense to have a 
ToolExecutor that does that.




Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:53
 
+/// Combines occurrences of the same symbols across translation units.
+class SymbolMerger {

sammccall wrote:
> Seems reasonably likely we would actually have contention here? merging 
> per-thread (combiner) and then globally at the end (reducer) might be the way 
> to go (might be significantly faster). But not sure how big the impact is.
I haven't seen any noticeable performance degradation after this patch.
There should be contention, but it doesn't seem to matter much, as parsing 
still takes way more time. 

Still makes sense to rewrite the code in order to avoid contention, will do 
that.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45478



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


[PATCH] D45478: [clangd] Merge symbols in global-sym-builder on the go

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D45478#1071983, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D45478#1064027, @sammccall wrote:
>
> > Is this patch still relevant after haojian's string deduplication?
>
>
> Apparently it does. It has an advantage of distributing the work more evenly 
> between the program runs.
>  Currently the tool reports progress based on the number of files it parsed. 
> But then it takes a lot of time to actually merge all the symbols at the end 
> and the progress is not reported during that time.
>
> The perfect behavior would be to remove duplicates, not just intern them :-) 
> That shouldn't be too hard and it probably even makes sense to have a 
> ToolExecutor that does that.


OK, can we sync up offline with @hokein and decide what to do here? I don't 
think it makes sense to have both these solutions to the same issue, but I 
don't have a strong opinion on exactly what we do.
(Other than clearly the right solution is to have a proper MR framework 
)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45478



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


[PATCH] D45478: [clangd] Merge symbols in global-sym-builder on the go

2018-04-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:53
 
+/// Combines occurrences of the same symbols across translation units.
+class SymbolMerger {

ilya-biryukov wrote:
> sammccall wrote:
> > Seems reasonably likely we would actually have contention here? merging 
> > per-thread (combiner) and then globally at the end (reducer) might be the 
> > way to go (might be significantly faster). But not sure how big the impact 
> > is.
> I haven't seen any noticeable performance degradation after this patch.
> There should be contention, but it doesn't seem to matter much, as parsing 
> still takes way more time. 
> 
> Still makes sense to rewrite the code in order to avoid contention, will do 
> that.
Looking at the traces, the threads spend ~6% of `mergeSymbols` time between 
`Lock(Mut)` and `for(const Sym...`.
Improving it might be a good idea, but from my point of view it's not too bad 
to commit it as is.

Doing it properly is a little complicated in the current setup, since we don't 
have knobs to create per-thread structs and merge them later.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45478



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


r330324 - [clang-format] Don't remove empty lines before namespace endings

2018-04-19 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Apr 19 06:02:15 2018
New Revision: 330324

URL: http://llvm.org/viewvc/llvm-project?rev=330324&view=rev
Log:
[clang-format] Don't remove empty lines before namespace endings

Summary: This implements an alternative to r327861, namely preserving empty 
lines before namespace endings.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=330324&r1=330323&r2=330324&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Thu Apr 19 06:02:15 2018
@@ -107,6 +107,7 @@ void updateEndComment(const FormatToken
  << llvm::toString(std::move(Err)) << "\n";
   }
 }
+} // namespace
 
 const FormatToken *
 getNamespaceToken(const AnnotatedLine *line,
@@ -131,7 +132,6 @@ getNamespaceToken(const AnnotatedLine *l
 return nullptr;
   return NamespaceTok;
 }
-} // namespace
 
 NamespaceEndCommentsFixer::NamespaceEndCommentsFixer(const Environment &Env,
  const FormatStyle &Style)

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h?rev=330324&r1=330323&r2=330324&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h Thu Apr 19 06:02:15 2018
@@ -21,6 +21,16 @@
 namespace clang {
 namespace format {
 
+// Finds the namespace token corresponding to a closing namespace `}`, if that
+// is to be formatted.
+// If \p Line contains the closing `}` of a namespace, is affected and is not 
in
+// a preprocessor directive, the result will be the matching namespace token.
+// Otherwise returns null.
+// \p AnnotatedLines is the sequence of lines from which \p Line is a member 
of.
+const FormatToken *
+getNamespaceToken(const AnnotatedLine *Line,
+  const SmallVectorImpl &AnnotatedLines);
+
 class NamespaceEndCommentsFixer : public TokenAnalyzer {
 public:
   NamespaceEndCommentsFixer(const Environment &Env, const FormatStyle &Style);

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=330324&r1=330323&r2=330324&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Thu Apr 19 06:02:15 2018
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+#include "NamespaceEndCommentsFixer.h"
 #include "UnwrappedLineFormatter.h"
 #include "WhitespaceManager.h"
 #include "llvm/Support/Debug.h"
@@ -1050,8 +1051,7 @@ UnwrappedLineFormatter::format(const Sma
 if (ShouldFormat && TheLine.Type != LT_Invalid) {
   if (!DryRun) {
 bool LastLine = Line->First->is(tok::eof);
-formatFirstToken(TheLine, PreviousLine,
- Indent,
+formatFirstToken(TheLine, PreviousLine, Lines, Indent,
  LastLine ? LastStartColumn : NextStartColumn + 
Indent);
   }
 
@@ -1095,7 +1095,7 @@ UnwrappedLineFormatter::format(const Sma
   TheLine.LeadingEmptyLinesAffected);
 // Format the first token.
 if (ReformatLeadingWhitespace)
-  formatFirstToken(TheLine, PreviousLine,
+  formatFirstToken(TheLine, PreviousLine, Lines,
TheLine.First->OriginalColumn,
TheLine.First->OriginalColumn);
 else
@@ -1117,10 +1117,10 @@ UnwrappedLineFormatter::format(const Sma
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(const AnnotatedLine &Line,
-  const AnnotatedLine 
*PreviousLine,
-  unsigned Indent,
-  unsigned NewlineIndent) {
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
   FormatToken &RootToken = *Line.First;
   if (RootToken.is(tok::eof)) {
 unsigned Newlines = std::min(RootToken.Newlines

[PATCH] D45373: [clang-format] Don't remove empty lines before namespace endings

2018-04-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
krasimir marked an inline comment as done.
Closed by commit rL330324: [clang-format] Don't remove empty lines before 
namespace endings (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45373?vs=141352&id=143081#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45373

Files:
  cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
  cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.h
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -107,6 +107,7 @@
  << llvm::toString(std::move(Err)) << "\n";
   }
 }
+} // namespace
 
 const FormatToken *
 getNamespaceToken(const AnnotatedLine *line,
@@ -131,7 +132,6 @@
 return nullptr;
   return NamespaceTok;
 }
-} // namespace
 
 NamespaceEndCommentsFixer::NamespaceEndCommentsFixer(const Environment &Env,
  const FormatStyle &Style)
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.h
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.h
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.h
@@ -49,8 +49,9 @@
   /// \brief Add a new line and the required indent before the first Token
   /// of the \c UnwrappedLine if there was no structural parsing error.
   void formatFirstToken(const AnnotatedLine &Line,
-const AnnotatedLine *PreviousLine, unsigned Indent,
-unsigned NewlineIndent);
+const AnnotatedLine *PreviousLine,
+const SmallVectorImpl &Lines,
+unsigned Indent, unsigned NewlineIndent);
 
   /// \brief Returns the column limit for a line, taking into account whether we
   /// need an escaped newline due to a continued preprocessor directive.
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "NamespaceEndCommentsFixer.h"
 #include "UnwrappedLineFormatter.h"
 #include "WhitespaceManager.h"
 #include "llvm/Support/Debug.h"
@@ -1050,8 +1051,7 @@
 if (ShouldFormat && TheLine.Type != LT_Invalid) {
   if (!DryRun) {
 bool LastLine = Line->First->is(tok::eof);
-formatFirstToken(TheLine, PreviousLine,
- Indent,
+formatFirstToken(TheLine, PreviousLine, Lines, Indent,
  LastLine ? LastStartColumn : NextStartColumn + Indent);
   }
 
@@ -1095,7 +1095,7 @@
   TheLine.LeadingEmptyLinesAffected);
 // Format the first token.
 if (ReformatLeadingWhitespace)
-  formatFirstToken(TheLine, PreviousLine,
+  formatFirstToken(TheLine, PreviousLine, Lines,
TheLine.First->OriginalColumn,
TheLine.First->OriginalColumn);
 else
@@ -1117,10 +1117,10 @@
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(const AnnotatedLine &Line,
-  const AnnotatedLine *PreviousLine,
-  unsigned Indent,
-  unsigned NewlineIndent) {
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
   FormatToken &RootToken = *Line.First;
   if (RootToken.is(tok::eof)) {
 unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
@@ -1134,7 +1134,9 @@
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)) &&
+  // Do not remove empty lines before namespace closing "}".
+  !getNamespaceToken(&Line, Lines))
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)
Index: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
===
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
@@ -21,6 +21,16 @@
 

[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input

2018-04-19 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 143079.
jkorous added a comment.

Include the correct test.


https://reviews.llvm.org/D45763

Files:
  JSONRPCDispatcher.cpp
  clangd/delimited-input-comment-at-the-end.test


Index: clangd/delimited-input-comment-at-the-end.test
===
--- /dev/null
+++ clangd/delimited-input-comment-at-the-end.test
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t 
< %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -277,21 +277,19 @@
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }


Index: clangd/delimited-input-comment-at-the-end.test
===
--- /dev/null
+++ clangd/delimited-input-comment-at-the-end.test
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -277,21 +277,19 @@
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Henrik Gramner via Phabricator via cfe-commits
Gramner created this revision.
Gramner added a reviewer: erichkeane.
Gramner added a project: clang.
Herald added a subscriber: javed.absar.

The force_align_arg_pointer attribute was using a hardcoded 16-byte
alignment value which in combination with -mstack-alignment=32 (or
larger) would produce a misaligned stack which could result in crashes
when accessing stack buffers using aligned AVX load/store instructions.

Fix the issue by using the "stackrealign" function attribute instead
of using a hardcoded 16-byte alignment.


Repository:
  rC Clang

https://reviews.llvm.org/D45812

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/function-attributes.c


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("stackrealign");
   }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
@@ -2431,13 +2421,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
-  auto *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (co

[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input

2018-04-19 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

By "Comments should be allowed at the end of test files." I meant that we 
shouldn't log it as an exceptional state. Should've worded that better.

I included a wrong test in the patch. I had realized the same thing as you and 
had written another test but messed up.


https://reviews.llvm.org/D45763



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


[PATCH] D45814: Fix an assertion when -print-prog-name= is invoked without parameter. Returns an empty string.

2018-04-19 Thread Christian Bruel via Phabricator via cfe-commits
chrib created this revision.
Herald added a subscriber: cfe-commits.

Fix an assertion when -print-prog-name=


Repository:
  rC Clang

https://reviews.llvm.org/D45814

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4053,6 +4053,11 @@
 }
 
 std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
+
+  // Null program name cannot have a path.
+  if (Name.empty())
+return Name.str();
+
   SmallVector TargetSpecificExecutables;
   generatePrefixedToolNames(Name, TC, TargetSpecificExecutables);
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4053,6 +4053,11 @@
 }
 
 std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
+
+  // Null program name cannot have a path.
+  if (Name.empty())
+return Name.str();
+
   SmallVector TargetSpecificExecutables;
   generatePrefixedToolNames(Name, TC, TargetSpecificExecutables);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Can you make sure that this doesn't cause stackrealign to happen 2x if using 
-mstackrealign?  Additionally, please provide the diff with full-context (see 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface).
  What is the commit before this?  The line numbers don't look right to me.

Barring any surprises from those two, this looks alright to me.


Repository:
  rC Clang

https://reviews.llvm.org/D45812



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


[PATCH] D45764: [clangd][tests] Fix delimiter handling

2018-04-19 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

[ultranit] Sorry, just to be sure - did you really mean any number of dashes

  if (LineRef.startswith("-") && LineRef.find_first_not_of('-') == 
llvm::StringRef::npos)

or at least three?

  if (LineRef.startswith("---") && LineRef.find_first_not_of('-') == 
llvm::StringRef::npos)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45764



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


[PATCH] D45319: [Atomics] warn about misaligned atomic accesses using libcalls

2018-04-19 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:883
   if (UseLibcall) {
+CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned);
+

compnerd wrote:
> It is kinda unfortunate that you need to look up 125 lines to get the context 
> that the call here is implied by a lack of alignment.  Perhaps we can rename 
> `UseLibcall` to `UnsuitableAligned` or something?
I'd be OK with that, or I could just move the diagnostic further up so it is 
next to the definition (or maybe just after to avoid the atomic_init case)?


Repository:
  rC Clang

https://reviews.llvm.org/D45319



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


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Henrik Gramner via Phabricator via cfe-commits
Gramner updated this revision to Diff 143083.
Gramner added a comment.

Full context.


https://reviews.llvm.org/D45812

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/function-attributes.c


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("stackrealign");
   }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
@@ -2431,13 +2421,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
-  auto *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("stackrealign");
   }
   if (FD->hasAttr()) {

r330323 - Lowering x86 adds/addus/subs/subus intrinsics (clang)

2018-04-19 Thread Alexander Ivchenko via cfe-commits
Author: aivchenk
Date: Thu Apr 19 05:15:11 2018
New Revision: 330323

URL: http://llvm.org/viewvc/llvm-project?rev=330323&view=rev
Log:
Lowering x86 adds/addus/subs/subus intrinsics (clang)

This is the patch that lowers x86 intrinsics to native IR
in order to enable optimizations.

Patch by tkrupa

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=330323&r1=330322&r2=330323&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Apr 19 05:15:11 2018
@@ -8449,6 +8449,76 @@ static Value *EmitX86SExtMask(CodeGenFun
   return CGF.Builder.CreateSExt(Mask, DstTy, "vpmovm2");
 }
 
+// Emit addition or subtraction with saturation.
+// Handles both signed and unsigned intrinsics.
+static Value *EmitX86AddSubSatExpr(CodeGenFunction &CGF, const CallExpr *E,
+   SmallVectorImpl &Ops,
+   bool IsAddition, bool Signed) {
+
+  // Collect vector elements and type data.
+  llvm::Type *ResultType = CGF.ConvertType(E->getType());
+  int NumElements = ResultType->getVectorNumElements();
+  Value *Res;
+  if (!IsAddition && !Signed) {
+Value *ICmp = CGF.Builder.CreateICmp(ICmpInst::ICMP_UGT, Ops[0], Ops[1]);
+Value *Select = CGF.Builder.CreateSelect(ICmp, Ops[0], Ops[1]);
+Res = CGF.Builder.CreateSub(Select, Ops[1]);
+  } else {
+unsigned EltSizeInBits = ResultType->getScalarSizeInBits();
+llvm::Type *ExtElementType = EltSizeInBits == 8 ?
+ CGF.Builder.getInt16Ty() :
+ CGF.Builder.getInt32Ty();
+
+// Extending vectors to next possible width to make space for possible
+// overflow.
+llvm::Type *ExtType = llvm::VectorType::get(ExtElementType, NumElements);
+Value *VecA = Signed ? CGF.Builder.CreateSExt(Ops[0], ExtType)
+ : CGF.Builder.CreateZExt(Ops[0], ExtType);
+Value *VecB = Signed ? CGF.Builder.CreateSExt(Ops[1], ExtType)
+ : CGF.Builder.CreateZExt(Ops[1], ExtType);
+
+llvm::Value *ExtProduct = IsAddition ? CGF.Builder.CreateAdd(VecA, VecB)
+ : CGF.Builder.CreateSub(VecA, VecB);
+
+// Create vector of the same type as expected result with max possible
+// values and extend it to the same type as the product of the addition.
+APInt SignedMaxValue =
+llvm::APInt::getSignedMaxValue(EltSizeInBits);
+Value *Max = Signed ? llvm::ConstantInt::get(ResultType, SignedMaxValue)
+: llvm::Constant::getAllOnesValue(ResultType);
+Value *ExtMaxVec = Signed ? CGF.Builder.CreateSExt(Max, ExtType)
+  : CGF.Builder.CreateZExt(Max, ExtType);
+// In Product, replace all overflowed values with max values of 
non-extended
+// type.
+ICmpInst::Predicate Pred = Signed ? ICmpInst::ICMP_SLE : 
ICmpInst::ICMP_ULE;
+Value *Cmp = CGF.Builder.CreateICmp(Pred, ExtProduct,
+ExtMaxVec); // 1 if no overflow.
+Value *SaturatedProduct = CGF.Builder.CreateSelect(
+Cmp, ExtProduct, ExtMaxVec); // If overflowed, copy from max values.
+
+if (Signed) {
+  APInt SignedMinValue =
+  llvm::APInt::getSignedMinValue(EltSizeInBits);
+  Value *Min = llvm::ConstantInt::get(ResultType, SignedMinValue);
+  Value *ExtMinVec = CGF.Builder.CreateSExt(Min, ExtType);
+  Value *IsNegative =
+CGF.Builder.CreateICmp(ICmpInst::ICMP_SLT, SaturatedProduct, 
ExtMinVec);
+  SaturatedProduct =
+CGF.Builder.CreateSelect(IsNegative, ExtMinVec, SaturatedProduct);
+}
+
+Res = CGF.Builder.CreateTrunc(SaturatedProduct,
+  ResultType); // Trunc to ResultType.
+  }
+  if (E->getNumArgs() == 4) { // For masked intrinsics.
+Value *VecSRC = Ops[2];
+Value *Mask = Ops[3];
+return EmitX86Select(CGF, Mask, Res, VecSRC);
+  }
+
+  return Res;
+}
+
 Value *CodeGenFunction::EmitX86CpuIs(const CallExpr *E) {
   const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts();
   StringRef CPUStr = cast(CPUExpr)->getString();
@@ -9516,10 +9586,37 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Load->setVolatile(true);
 return Load;
   }
+  case X86::BI__builtin_ia32_paddusb512_mask:
+  case X86::BI__builtin_ia32_paddusw512_mask:
+  case X86::BI__builtin_ia32_paddusb256:
+  case X86::BI__builtin_ia32_paddusw256:
+  case X86::BI__builtin_ia32_paddusb128:
+  case X86::BI__builtin_ia32_paddusw128:
+return EmitX86AddSubSatExpr(*th

[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Henrik Gramner via Phabricator via cfe-commits
Gramner added a comment.

In https://reviews.llvm.org/D45812#1072066, @erichkeane wrote:

> Can you make sure that this doesn't cause stackrealign to happen 2x if using 
> -mstackrealign?  Additionally, please provide the diff with full-context (see 
> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface).
>   What is the commit before this?  The line numbers don't look right to me.
>
> Barring any surprises from those two, this looks alright to me.


The commit before this one is git hash 4889058f23607ff086470afe013082ca4a278ddb

It does "the right thing" as far as I can see, e.g. no double stack realignment 
or anything weird, when tested on 64-bit Linux with various combinations (and 
lack of thereof) of -mstack-alignment=32, -mstack-alignment=64, -mstackrealign, 
-m32. Unable to test on other systems though.


https://reviews.llvm.org/D45812



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


[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location

2018-04-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Hi @spetrovic - I think Hal Finkel's earlier request to update the comments of 
IsBetterAsSingleFieldRun remains unaddressed. It looks like at least the 
comment string immediately before `auto IsBetterAsSingleFieldRun` needs to be 
updated to reflect the changed behaviour.

The documentation `-ffine-grained-bitfield-accesses` option may also need to be 
updated. Iit currently reads "Use separate accesses for bitfields with legal 
widths and alignments.". I think "Use separate accesses for consecutive 
bitfield runs with legal widths and alignments" might better reflect the 
behaviour after this patch. Do you agree?


https://reviews.llvm.org/D39053



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


[PATCH] D45764: [clangd][tests] Fix delimiter handling

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D45764#1072067, @jkorous wrote:

> [ultranit] Sorry, just to be sure - did you really mean any number of dashes
>
>   if (LineRef.startswith("-") && LineRef.find_first_not_of('-') == 
> llvm::StringRef::npos)
>
>
> or at least three?
>
>   if (LineRef.startswith("---") && LineRef.find_first_not_of('-') == 
> llvm::StringRef::npos)
>


I meant any number, but at-least-three is fine too! Up to you.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45764



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


[clang-tools-extra] r330327 - [clang-tidy] Fix unused-variable warning.

2018-04-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Apr 19 06:34:03 2018
New Revision: 330327

URL: http://llvm.org/viewvc/llvm-project?rev=330327&view=rev
Log:
[clang-tidy] Fix unused-variable warning.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=330327&r1=330326&r2=330327&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Thu Apr 19 06:34:03 
2018
@@ -230,7 +230,8 @@ FileOptionsProvider::getRawOptions(Strin
   assert(FS && "FS must be set.");
 
   llvm::SmallString<128> AbsoluteFilePath(FileName);
-  if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath))
+
+  if (FS->makeAbsolute(AbsoluteFilePath))
 return {};
 
   std::vector RawOptions =


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


Re: [clang-tools-extra] r330245 - [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.

2018-04-19 Thread Haojian Wu via cfe-commits
Thanks! I didn't see this warning when running check-clang-tools on my
machine. Fixed in r330327.

On Thu, Apr 19, 2018 at 7:39 AM, Mikael Holmén 
wrote:

> Hi,
>
>
> On 04/18/2018 10:54 AM, Haojian Wu via cfe-commits wrote:
>
>> Author: hokein
>> Date: Wed Apr 18 01:54:28 2018
>> New Revision: 330245
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=330245&view=rev
>> Log:
>> [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.
>>
>> Summary: Fix https://bugs.llvm.org/show_bug.cgi?id=34900.
>>
>> Reviewers: alexfh
>>
>> Reviewed By: alexfh
>>
>> Subscribers: JonasToth, klimek, xazax.hun, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D45697
>>
>> Added:
>>  clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp
>> Modified:
>>  clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
>>  clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
>>  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/ClangTidyOptions.cpp?rev=330245&r1=330244&r2=330245&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
>> +++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Wed Apr 18
>> 01:54:28 2018
>> @@ -204,9 +204,12 @@ ConfigOptionsProvider::getRawOptions(llv
>>   FileOptionsProvider::FileOptionsProvider(
>>   const ClangTidyGlobalOptions &GlobalOptions,
>>   const ClangTidyOptions &DefaultOptions,
>> -const ClangTidyOptions &OverrideOptions)
>> +const ClangTidyOptions &OverrideOptions,
>> +llvm::IntrusiveRefCntPtr VFS)
>>   : DefaultOptionsProvider(GlobalOptions, DefaultOptions),
>> -  OverrideOptions(OverrideOptions) {
>> +  OverrideOptions(OverrideOptions), FS(std::move(VFS)) {
>> +  if (!FS)
>> +FS = vfs::getRealFileSystem();
>> ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration);
>>   }
>>   @@ -224,14 +227,19 @@ FileOptionsProvider::FileOptionsProvider
>>   std::vector
>>   FileOptionsProvider::getRawOptions(StringRef FileName) {
>> DEBUG(llvm::dbgs() << "Getting options for file " << FileName <<
>> "...\n");
>> +  assert(FS && "FS must be set.");
>> +
>> +  llvm::SmallString<128> AbsoluteFilePath(FileName);
>> +  if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath))
>> +return {};
>>
>>
>
> This causes a compilation warning:
>
> ../tools/clang/tools/extra/clang-tidy/ClangTidyOptions.cpp:233:23: error:
> unused variable 'ec' [-Werror,-Wunused-variable]
>   if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath))
>   ^
> 1 error generated.
>
> Regards,
> Mikael
>
>
>
> std::vector RawOptions =
>> -  DefaultOptionsProvider::getRawOptions(FileName);
>> +  DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
>> OptionsSource CommandLineOptions(OverrideOptions,
>>  OptionsSourceTypeCheckCommandL
>> ineOption);
>> // Look for a suitable configuration file in all parent directories
>> of the
>> // file. Start with the immediate parent directory and move up.
>> -  StringRef Path = llvm::sys::path::parent_path(FileName);
>> +  StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str());
>> for (StringRef CurrentPath = Path; !CurrentPath.empty();
>>  CurrentPath = llvm::sys::path::parent_path(CurrentPath)) {
>>   llvm::Optional Result;
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/ClangTidyOptions.h?rev=330245&r1=330244&r2=330245&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h (original)
>> +++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h Wed Apr 18
>> 01:54:28 2018
>> @@ -13,7 +13,9 @@
>>   #include "llvm/ADT/Optional.h"
>>   #include "llvm/ADT/StringMap.h"
>>   #include "llvm/ADT/StringRef.h"
>> +#include "llvm/ADT/IntrusiveRefCntPtr.h"
>>   #include "llvm/Support/ErrorOr.h"
>> +#include "clang/Basic/VirtualFileSystem.h"
>>   #include 
>>   #include 
>>   #include 
>> @@ -221,7 +223,8 @@ public:
>> /// whatever options are read from the configuration file.
>> FileOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions,
>> const ClangTidyOptions &DefaultOptions,
>> -  const ClangTidyOptions &OverrideOptions);
>> +  const ClangTidyOptions &OverrideOptions,
>> +  llvm::IntrusiveRefCntPtr FS =
>> nullptr);
>>   /// \brief Initializes the \c FileOptionsProvider instance with a
>> custom set
>> /// of configuration file handlers.
>> @@ -255,6 +258,7 @@ protected:
>> llvm::StringMa

[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-19 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik created this revision.
Herald added subscribers: cfe-commits, kbarton, nemanjai, klimek.

As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new
options

  CXTranslationUnit_LimitSkipFunctionBodiesToPreamble
  CXTranslationUnit_LimitSkipFunctionBodiesToNonTemplates.

The first one constraints the skipping of functions bodies to the preamble.
The second one allows to exclude template function bodies from being skipped,
which is useful for diagnostics about wrong/incomplete template instantiations.

For the purpose of an IDE both options makes sense.


Repository:
  rC Clang

https://reviews.llvm.org/D45815

Files:
  include/clang-c/Index.h
  include/clang/Frontend/ASTUnit.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/Frontend/SkipFunctionBodies.h
  include/clang/Parse/ParseAST.h
  include/clang/Parse/Parser.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseAST.cpp
  lib/Parse/Parser.cpp
  test/Parser/skip-function-bodies.h
  test/Parser/skip-function-bodies.mm
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/Indexing.cpp
  unittests/CodeGen/BufferSourceTest.cpp
  unittests/CodeGen/CodeGenExternalTest.cpp
  unittests/CodeGen/IncrementalProcessingTest.cpp
  unittests/CodeGen/TBAAMetadataTest.cpp
  unittests/Frontend/PCHPreambleTest.cpp
  unittests/Lex/PPCallbacksTest.cpp
  unittests/Tooling/ToolingTest.cpp

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -250,7 +250,7 @@
 struct SkipBodyAction : public clang::ASTFrontendAction {
   std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
  StringRef) override {
-Compiler.getFrontendOpts().SkipFunctionBodies = true;
+Compiler.getFrontendOpts().SkipFunctionBodies = SkipFunctionBodies_All;
 return llvm::make_unique();
   }
 };
Index: unittests/Lex/PPCallbacksTest.cpp
===
--- unittests/Lex/PPCallbacksTest.cpp
+++ unittests/Lex/PPCallbacksTest.cpp
@@ -201,7 +201,7 @@
 
 ASTConsumer Consumer;
 Sema S(PP, Context, Consumer);
-Parser P(PP, S, false);
+Parser P(PP, S, SkipFunctionBodies_None);
 PragmaOpenCLExtensionCallbacks* Callbacks = new PragmaOpenCLExtensionCallbacks;
 PP.addPPCallbacks(std::unique_ptr(Callbacks));
 
Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -103,7 +103,9 @@
   }
 
   bool ReparseAST(const std::unique_ptr &AST) {
-bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), VFS);
+bool reparseFailed =
+AST->Reparse(PCHContainerOpts, GetRemappedFiles(),
+ ASTUnit::SkipFunctionBodiesOptions(), VFS);
 return !reparseFailed;
   }
 
Index: unittests/CodeGen/TBAAMetadataTest.cpp
===
--- unittests/CodeGen/TBAAMetadataTest.cpp
+++ unittests/CodeGen/TBAAMetadataTest.cpp
@@ -73,7 +73,7 @@
   }
 
   const BasicBlock *compile() {
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler.getSema(), false, clang::SkipFunctionBodies_None);
 M = CG->GetModule();
 
 // Do not expect more than one function definition.
Index: unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- unittests/CodeGen/IncrementalProcessingTest.cpp
+++ unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -143,7 +143,7 @@
 Sema& S = compiler.getSema();
 
 std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S,
-   /*SkipFunctionBodies*/ false));
+   SkipFunctionBodies_None));
 Parser &P = *ParseOP.get();
 
 std::array, 3> M;
Index: unittests/CodeGen/CodeGenExternalTest.cpp
===
--- unittests/CodeGen/CodeGenExternalTest.cpp
+++ unittests/CodeGen/CodeGenExternalTest.cpp
@@ -294,7 +294,7 @@
 sm.setMainFileID(sm.createFileID(
 llvm::MemoryBuffer::getMemBuffer(TestProgram), clang::SrcMgr::C_User));
 
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler.getSema(), false, clang::SkipFunctionBodies_None);
 
 ASSERT_TRUE(test_codegen_fns_ran);
 }
Index: unittests/CodeGen/BufferSourceTest.cpp
===
--- unittests/CodeGen/BufferSourceTest.cpp
+++ unittests/CodeGen/BufferSourceTest.cpp
@@ -74,7 +74,7 @@
 sm.setMainFileID(sm.createFileID(
 llvm::MemoryBuffer::getMemBuffer(TestProgram), clang::SrcMgr::C_User));
 
-clang::ParseAST(compiler.getSema(), false, false);
+clang::ParseAST(compiler

[PATCH] D45815: [libclang] Add options to limit skipping of function bodies

2018-04-19 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

@ilya: Using SkipFunctionBodies_AllExceptTemplates for the preamble might be 
also useful for clangd.


Repository:
  rC Clang

https://reviews.llvm.org/D45815



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


[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

2018-04-19 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Sorry for the delay, I think I'll come back to this one soon.


Repository:
  rC Clang

https://reviews.llvm.org/D41005



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


[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2018-04-19 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

This one still applies and tests pass.

Please review.


https://reviews.llvm.org/D40481



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


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

LGTM, Do you have commit access, or do you want me to commit it for you?


https://reviews.llvm.org/D45812



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


[PATCH] D45095: [clang-tidy] Align usage of ClangTool interface with new VFS injection

2018-04-19 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang-tidy/tool/CMakeLists.txt:19
   clangBasic
+  clangFrontend
   clangTidy

ilya-biryukov wrote:
> whisperity wrote:
> > ilya-biryukov wrote:
> > > Why do we need an extra dependency?
> > In the current state of the patch, `clang-tidy/tool/ClangTidyMain.cpp` 
> > constructs the `ClangTool` which constructor requires a 
> > `std::shared_ptr`. `PCHContainerOperations`'s 
> > definition and implementation is part of the `clangFrontend` library, and 
> > without this dependency, there would be a symbol resolution error.
> Thanks for clarification.
> Does it mean that to use `ClangTool` one needs both a dependency on 
> `clangTooling` and `clangFrontend`?
> That's weird, given that `clangTooling` itself depends on `clangFrontend` and 
> it would be nice if the buildsystem actually propagated those.
I'm not sure if you need to have both as a dependency just to use `ClangTool`. 
If you want to construct an empty `PCHContainerOperations` to pass as an 
argument, though, it seems you do.

One can wonder where the default argument's (which is a shared pointer to a 
default constructed object) expression's evaluation is in the object code or if 
passing `nullptr` breaks something.

You need the dependency because it's **your** code who wants to run the 
constructor of the PCH class.


https://reviews.llvm.org/D45095



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


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Henrik Gramner via Phabricator via cfe-commits
Gramner added a comment.

In https://reviews.llvm.org/D45812#1072128, @erichkeane wrote:

> LGTM, Do you have commit access, or do you want me to commit it for you?


I do not have commit access, so please do. Thanks for the review.


https://reviews.llvm.org/D45812



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


r330331 - Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Apr 19 07:27:05 2018
New Revision: 330331

URL: http://llvm.org/viewvc/llvm-project?rev=330331&view=rev
Log:
Fix __attribute__((force_align_arg_pointer)) misalignment bug

The force_align_arg_pointer attribute was using a hardcoded 16-byte
alignment value which in combination with -mstack-alignment=32 (or
larger) would produce a misaligned stack which could result in crashes
when accessing stack buffers using aligned AVX load/store instructions.

Fix the issue by using the "stackrealign" function attribute instead
of using a hardcoded 16-byte alignment.

Patch By: Gramner

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/function-attributes.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=330331&r1=330330&r2=330331&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Apr 19 07:27:05 2018
@@ -1941,13 +1941,8 @@ void X86_32TargetCodeGenInfo::setTargetA
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@ public:
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("stackrealign");
   }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
@@ -2431,13 +2421,8 @@ void WinX86_64TargetCodeGenInfo::setTarg
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
-  auto *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);

Modified: cfe/trunk/test/CodeGen/function-attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=330331&r1=330330&r2=330331&view=diff
==
--- cfe/trunk/test/CodeGen/function-attributes.c (original)
+++ cfe/trunk/test/CodeGen/function-attributes.c Thu Apr 19 07:27:05 2018
@@ -71,7 +71,7 @@ void f15(void) {
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@ void f20(void) {
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }


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


[PATCH] D45812: Fix __attribute__((force_align_arg_pointer)) misalignment bug

2018-04-19 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330331: Fix __attribute__((force_align_arg_pointer)) 
misalignment bug (authored by erichkeane, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45812

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/function-attributes.c


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("stackrealign");
   }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
@@ -2431,13 +2421,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
-  auto *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -71,7 +71,7 @@
 
 // PR5254
 // CHECK-LABEL: define void @f16
-// CHECK: [[ALIGN:#[0-9]+]]
+// CHECK: [[SR:#[0-9]+]]
 // CHECK: {
 void __attribute__((force_align_arg_pointer)) f16(void) {
 }
@@ -112,7 +112,7 @@
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
-// CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
+// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1941,13 +1941,8 @@
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
-  // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
-
-  // Now add the 'alignstack' attribute with a value of 16.
-  llvm::AttrBuilder B;
-  B.addStackAlignmentAttr(16);
-  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  Fn->addFnAttr("stackrealign");
 }
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
@@ -2299,13 +2294,8 @@
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
   if (FD->hasAttr()) {
-// Get the LLVM function.
-auto *Fn = cast(GV);
-
-// Now add the 'alignstack' attribute with a value of 16.
-llvm::AttrBuilder B;
-B.addStackAlignmentAttr(16);
-Fn->addAttributes(llvm::AttributeList::Fu

[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-19 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: test/CodeGen/no-ident-version.c:1
+// RUN: %clang_cc1 -Qn -emit-llvm -debug-info-kind=limited -o - %s | FileCheck 
%s
+

Please test both -Qy and -Qn as well as the default case. 


https://reviews.llvm.org/D45255



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


[PATCH] D45771: [Driver] Support for -save-stats in AddGoldPlugin.

2018-04-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM with comment nit




Comment at: lib/Driver/ToolChains/CommonArgs.h:107
llvm::opt::OptSpecifier Group);
+SmallString<128> getStatsFileName(const InputInfo &Output,
+  const InputInfo &Input,

doxygen comment (looks like there aren't many to start with in this file, but 
good to add)


Repository:
  rC Clang

https://reviews.llvm.org/D45771



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-04-19 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Please run your changes through clang format before checking this in; otherwise 
LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D45045



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


r330336 - [NEON] Define vfma_n_f32() and vfmaq_n_f32() intrinsics in AArch32 mode

2018-04-19 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Thu Apr 19 08:27:28 2018
New Revision: 330336

URL: http://llvm.org/viewvc/llvm-project?rev=330336&view=rev
Log:
[NEON] Define vfma_n_f32() and vfmaq_n_f32() intrinsics in AArch32 mode

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/arm-neon-fma.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330336&r1=330335&r2=330336&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Thu Apr 19 08:27:28 2018
@@ -531,6 +531,7 @@ def VREINTERPRET
 let ArchGuard = "defined(__ARM_FEATURE_FMA)" in {
   def VFMA : SInst<"vfma", "", "fQf">;
   def VFMS : SOpInst<"vfms", "", "fQf", OP_FMLS>;
+  def FMLA_N_F32 : SOpInst<"vfma_n", "ddds", "fQf", OP_FMLA_N>;
 }
 
 

@@ -621,7 +622,7 @@ def FMLS : SOpInst<"vfms", "", "dQd"
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "dQd", OP_FMLA_N>;
 def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;

Modified: cfe/trunk/test/CodeGen/arm-neon-fma.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-neon-fma.c?rev=330336&r1=330335&r2=330336&view=diff
==
--- cfe/trunk/test/CodeGen/arm-neon-fma.c (original)
+++ cfe/trunk/test/CodeGen/arm-neon-fma.c Thu Apr 19 08:27:28 2018
@@ -20,3 +20,27 @@ float32x2_t test_fma_order(float32x2_t a
 float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t 
rhs) {
   return vfmaq_f32(accum, lhs, rhs);
 }
+
+// CHECK-LABEL: define <2 x float> @test_vfma_n_f32(<2 x float> %a, <2 x 
float> %b, float %n) #0 {
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <2 x float> undef, float %n, i32 0
+// CHECK:   [[VECINIT1_I:%.*]] = insertelement <2 x float> [[VECINIT_I]], 
float %n, i32 1
+// CHECK:   [[TMP1:%.*]] = bitcast <2 x float> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <2 x float> [[VECINIT1_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> %b, <2 
x float> [[VECINIT1_I]], <2 x float> %a)
+// CHECK:   ret <2 x float> [[TMP3]]
+float32x2_t test_vfma_n_f32(float32x2_t a, float32x2_t b, float32_t n) {
+  return vfma_n_f32(a, b, n);
+}
+
+// CHECK-LABEL: define <4 x float> @test_vfmaq_n_f32(<4 x float> %a, <4 x 
float> %b, float %n) #0 {
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
+// CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
+// CHECK:   [[VECINIT2_I:%.*]] = insertelement <4 x float> [[VECINIT1_I]], 
float %n, i32 2
+// CHECK:   [[VECINIT3_I:%.*]] = insertelement <4 x float> [[VECINIT2_I]], 
float %n, i32 3
+// CHECK:   [[TMP1:%.*]] = bitcast <4 x float> %b to <16 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <4 x float> [[VECINIT3_I]] to <16 x i8>
+// CHECK:   [[TMP3:%.*]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %b, <4 
x float> [[VECINIT3_I]], <4 x float> %a)
+// CHECK:   ret <4 x float> [[TMP3]]
+float32x4_t test_vfmaq_n_f32(float32x4_t a, float32x4_t b, float32_t n) {
+  return vfmaq_n_f32(a, b, n);
+}


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


[PATCH] D45670: [NEON] Define vfma_n_f32() and vfmaq_n_f32() intrinsics in AArch32 mode

2018-04-19 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330336: [NEON] Define vfma_n_f32() and vfmaq_n_f32() 
intrinsics in AArch32 mode (authored by kosarev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45670?vs=142784&id=143099#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45670

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/arm-neon-fma.c


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -531,6 +531,7 @@
 let ArchGuard = "defined(__ARM_FEATURE_FMA)" in {
   def VFMA : SInst<"vfma", "", "fQf">;
   def VFMS : SOpInst<"vfms", "", "fQf", OP_FMLS>;
+  def FMLA_N_F32 : SOpInst<"vfma_n", "ddds", "fQf", OP_FMLA_N>;
 }
 
 

@@ -621,7 +622,7 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "dQd", OP_FMLA_N>;
 def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
Index: cfe/trunk/test/CodeGen/arm-neon-fma.c
===
--- cfe/trunk/test/CodeGen/arm-neon-fma.c
+++ cfe/trunk/test/CodeGen/arm-neon-fma.c
@@ -20,3 +20,27 @@
 float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t 
rhs) {
   return vfmaq_f32(accum, lhs, rhs);
 }
+
+// CHECK-LABEL: define <2 x float> @test_vfma_n_f32(<2 x float> %a, <2 x 
float> %b, float %n) #0 {
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <2 x float> undef, float %n, i32 0
+// CHECK:   [[VECINIT1_I:%.*]] = insertelement <2 x float> [[VECINIT_I]], 
float %n, i32 1
+// CHECK:   [[TMP1:%.*]] = bitcast <2 x float> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <2 x float> [[VECINIT1_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> %b, <2 
x float> [[VECINIT1_I]], <2 x float> %a)
+// CHECK:   ret <2 x float> [[TMP3]]
+float32x2_t test_vfma_n_f32(float32x2_t a, float32x2_t b, float32_t n) {
+  return vfma_n_f32(a, b, n);
+}
+
+// CHECK-LABEL: define <4 x float> @test_vfmaq_n_f32(<4 x float> %a, <4 x 
float> %b, float %n) #0 {
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
+// CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
+// CHECK:   [[VECINIT2_I:%.*]] = insertelement <4 x float> [[VECINIT1_I]], 
float %n, i32 2
+// CHECK:   [[VECINIT3_I:%.*]] = insertelement <4 x float> [[VECINIT2_I]], 
float %n, i32 3
+// CHECK:   [[TMP1:%.*]] = bitcast <4 x float> %b to <16 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <4 x float> [[VECINIT3_I]] to <16 x i8>
+// CHECK:   [[TMP3:%.*]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %b, <4 
x float> [[VECINIT3_I]], <4 x float> %a)
+// CHECK:   ret <4 x float> [[TMP3]]
+float32x4_t test_vfmaq_n_f32(float32x4_t a, float32x4_t b, float32_t n) {
+  return vfmaq_n_f32(a, b, n);
+}


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -531,6 +531,7 @@
 let ArchGuard = "defined(__ARM_FEATURE_FMA)" in {
   def VFMA : SInst<"vfma", "", "fQf">;
   def VFMS : SOpInst<"vfms", "", "fQf", OP_FMLS>;
+  def FMLA_N_F32 : SOpInst<"vfma_n", "ddds", "fQf", OP_FMLA_N>;
 }
 
 
@@ -621,7 +622,7 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "dQd", OP_FMLA_N>;
 def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
Index: cfe/trunk/test/CodeGen/arm-neon-fma.c
===
--- cfe/trunk/test/CodeGen/arm-neon-fma.c
+++ cfe/trunk/test/CodeGen/arm-neon-fma.c
@@ -20,3 +20,27 @@
 float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) {
   return vfmaq_f32(accum, lhs, rhs);
 }
+
+// CHECK-LABEL: define <2 x float> @test_vfma_n_f32(<2 x float> %a, <2 x float> %b, float %n) #0 {
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <2 x float> undef, float %n, i32 0
+// CHECK:   [[VECINIT1_I:%.*]] = insertelement <2 x float> [[VECINIT_I]], float %n, i32 1
+// CHECK:   [[TMP1:%.*]] = bitcast <2 x float> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <2 x float> [[VECINIT1_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] 

[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Does gcc's Qy/Qn option also affect the generated debug information? Clang is 
embedding the version number also into the DICompileUnit's producer string; I 
wonder if that should be affected by this option, too.


https://reviews.llvm.org/D45255



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


[PATCH] D45478: [clangd] Merge symbols in global-sym-builder on the go

2018-04-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I think this implementation will have problems in a "real" multi-machine MR 
framework. The lifetime of the Merger is the whole program, with output only 
coming at the end.
With N workers, each will store >1/N of the symbols (more because of overlap), 
and the streaming nature of a MR is important to its scaling.

As you know, we rely on this code in such a framework :-)
I would be much happier if we could express these constraints/patterns in the 
open-source code, I think the most promising approach would be to define a more 
complete clang mapreduce API in Tooling.
But that's way out of scope in this patch. I'm not really sure what to suggest 
here, happy to talk through it more tomorrow.




Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:56
+public:
+  void mergeSymbols(const SymbolSlab &Symbols) {
+std::lock_guard Lock(Mut);

consider calling this `consume`, and the member in SymbolIndexActionFactory etc 
`Sink`, to emphasize the data flow


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45478



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


r330338 - [CXX] Templates specialization visibility can be wrong

2018-04-19 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Thu Apr 19 08:46:43 2018
New Revision: 330338

URL: http://llvm.org/viewvc/llvm-project?rev=330338&view=rev
Log:
[CXX] Templates specialization visibility can be wrong

Summary:
Under some conditions, LinkageComputer can get the visibility for
ClassTemplateSpecializationDecl wrong because it failed to find the Decl
that has the explicit visibility.

This fixes:
llvm.org/bugs/pr36810
rdar://problem/38080953

Reviewers: rsmith, arphaman, doug.gregor

Reviewed By: doug.gregor

Subscribers: doug.gregor, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=330338&r1=330337&r2=330338&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Apr 19 08:46:43 2018
@@ -1092,9 +1092,18 @@ getExplicitVisibilityAux(const NamedDecl
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+// Walk all the template decl till this point to see if there are
+// explicit visibility attributes.
+const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl();
+while (TD != nullptr) {
+  auto Vis = getVisibilityOf(TD, kind);
+  if (Vis != None)
+return Vis;
+  TD = TD->getPreviousDecl();
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {

Added: cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp?rev=330338&view=auto
==
--- cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp Thu Apr 19 08:46:43 2018
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden 
-emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 
-fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}


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


[PATCH] D44670: [CXX] Templates specialization visibility can be wrong

2018-04-19 Thread Steven Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330338: [CXX] Templates specialization visibility can be 
wrong (authored by steven_wu, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44670

Files:
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp


Index: cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
===
--- cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
+++ cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden 
-emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 
-fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -1092,9 +1092,18 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+// Walk all the template decl till this point to see if there are
+// explicit visibility attributes.
+const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl();
+while (TD != nullptr) {
+  auto Vis = getVisibilityOf(TD, kind);
+  if (Vis != None)
+return Vis;
+  TD = TD->getPreviousDecl();
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {


Index: cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
===
--- cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
+++ cfe/trunk/test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -1092,9 +1092,18 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+// Walk all the template decl till this point to see if there are
+// explicit visibility attributes.
+const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl();
+while (TD != nullptr) {
+  auto Vis = getVisibilityOf(TD, kind);
+  if (Vis != None)
+return Vis;
+  TD = TD->getPreviousDecl();
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44670: [CXX] Templates specialization visibility can be wrong

2018-04-19 Thread Steven Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330338: [CXX] Templates specialization visibility can be 
wrong (authored by steven_wu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44670?vs=142961&id=143103#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44670

Files:
  lib/AST/Decl.cpp
  test/CodeGenCXX/visibility-pr36810.cpp


Index: test/CodeGenCXX/visibility-pr36810.cpp
===
--- test/CodeGenCXX/visibility-pr36810.cpp
+++ test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden 
-emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 
-fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1092,9 +1092,18 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+// Walk all the template decl till this point to see if there are
+// explicit visibility attributes.
+const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl();
+while (TD != nullptr) {
+  auto Vis = getVisibilityOf(TD, kind);
+  if (Vis != None)
+return Vis;
+  TD = TD->getPreviousDecl();
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {


Index: test/CodeGenCXX/visibility-pr36810.cpp
===
--- test/CodeGenCXX/visibility-pr36810.cpp
+++ test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1092,9 +1092,18 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+// Walk all the template decl till this point to see if there are
+// explicit visibility attributes.
+const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl();
+while (TD != nullptr) {
+  auto Vis = getVisibilityOf(TD, kind);
+  if (Vis != None)
+return Vis;
+  TD = TD->getPreviousDecl();
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In https://reviews.llvm.org/D45255#1072200, @aprantl wrote:

> Does gcc's Qy/Qn option also affect the generated debug information?


No, it does not. Do you think it would be better to leave debug information 
unchanged as well?


https://reviews.llvm.org/D45255



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


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I'm not sure. Compatibility with GCC and getting identical output for debugging 
purposes seem to be at odds here. I personally lean slightly towards stripping 
it from the debug info as well.


https://reviews.llvm.org/D45255



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


[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:283-285
+  llvm::FunctionType *RegisterGlobalsFnTy;
+  llvm::FunctionType *RegisterLinkedBinaryFnTy;
+  llvm::Function *DummyCallback;

Instead of tracking these through the conditionals of pretty long function, 
could we make these pointers class fields and init them in the constructor and 
make accessors return them and, possibly, assert that they are used if RDC is 
enabled?



Comment at: test/CodeGenCUDA/device-stub.cu:3-7
+// RUN:   | FileCheck %s --check-prefixes=CHECK,DEFAULT
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s 
-fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-rdc 
-fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,RDC

Labels could be a bit more descriptive:
CHECK -> ALL
DEFAULT -> NORDC

Long RUN lines could use some re-wrapping.


https://reviews.llvm.org/D42922



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


[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name

2018-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Could you please resubmit your patch with complete context? 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


https://reviews.llvm.org/D44435



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


[PATCH] D45777: [UnitTests] NFC/build-perf: Break up nontrivial compile jobs

2018-04-19 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Makes sense to me.


Repository:
  rC Clang

https://reviews.llvm.org/D45777



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


[PATCH] D45827: [CUDA] Enable CUDA compilation with CUDA-9.2

2018-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added a subscriber: sanjoy.

https://reviews.llvm.org/D45827

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9010
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
 #error "Unsupported CUDA version!"
 #endif
 
@@ -199,6 +199,11 @@
 #endif
 
 #if CUDA_VERSION >= 9000
+// CUDA-9.2 needs host-side memcpy for some host functions in
+// device_functions.hpp
+#if CUDA_VERSION >= 9020
+#include 
+#endif
 #include "crt/math_functions.hpp"
 #else
 #include "math_functions.hpp"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -57,6 +57,8 @@
 return CudaVersion::CUDA_90;
   if (Major == 9 && Minor == 1)
 return CudaVersion::CUDA_91;
+  if (Major == 9 && Minor == 2)
+return CudaVersion::CUDA_92;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -20,6 +20,8 @@
 return "9.0";
   case CudaVersion::CUDA_91:
 return "9.1";
+  case CudaVersion::CUDA_92:
+return "9.2";
   }
   llvm_unreachable("invalid enum");
 }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -23,7 +23,8 @@
   CUDA_80,
   CUDA_90,
   CUDA_91,
-  LATEST = CUDA_91,
+  CUDA_92,
+  LATEST = CUDA_92,
 };
 const char *CudaVersionToString(CudaVersion V);
 


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9010
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
 #error "Unsupported CUDA version!"
 #endif
 
@@ -199,6 +199,11 @@
 #endif
 
 #if CUDA_VERSION >= 9000
+// CUDA-9.2 needs host-side memcpy for some host functions in
+// device_functions.hpp
+#if CUDA_VERSION >= 9020
+#include 
+#endif
 #include "crt/math_functions.hpp"
 #else
 #include "math_functions.hpp"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -57,6 +57,8 @@
 return CudaVersion::CUDA_90;
   if (Major == 9 && Minor == 1)
 return CudaVersion::CUDA_91;
+  if (Major == 9 && Minor == 2)
+return CudaVersion::CUDA_92;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -20,6 +20,8 @@
 return "9.0";
   case CudaVersion::CUDA_91:
 return "9.1";
+  case CudaVersion::CUDA_92:
+return "9.2";
   }
   llvm_unreachable("invalid enum");
 }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -23,7 +23,8 @@
   CUDA_80,
   CUDA_90,
   CUDA_91,
-  LATEST = CUDA_91,
+  CUDA_92,
+  LATEST = CUDA_92,
 };
 const char *CudaVersionToString(CudaVersion V);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45601: Warn on bool* to bool conversion

2018-04-19 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

The bug which motivated this warning is: 
https://github.com/jemalloc/jemalloc/commit/4df483f0fd76a64e116b1c4f316f8b941078114d#diff-7b26b977303fe92c093a2245b0eaf255


https://reviews.llvm.org/D45601



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


[PATCH] D37475: Make MultiplexASTDeserializationListener part of the API [NFC]

2018-04-19 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D37475



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


r330353 - [UnitTests] NFC/build-perf: Break up nontrivial compile jobs

2018-04-19 Thread David Zarzycki via cfe-commits
Author: davezarzycki
Date: Thu Apr 19 11:19:02 2018
New Revision: 330353

URL: http://llvm.org/viewvc/llvm-project?rev=330353&view=rev
Log:
[UnitTests] NFC/build-perf: Break up nontrivial compile jobs

RecursiveASTVisitorTest.cpp is one of the longest compile jobs and a
build bottleneck on many-core machines. This patch breaks that file and
some peer files up into smaller files to increase build concurrency and
overall rebuild performance.

Added:
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/CXXMemberCall.cpp
  - copied, changed from r330338, 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestCallVisitor.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/Class.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/ConstructExpr.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/ImplicitCtor.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPostOrder.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/IntegerLiteral.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/ParenExpr.cpp

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
Removed:
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestCallVisitor.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
Modified:
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=330353&r1=330352&r2=330353&view=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Thu Apr 19 11:19:02 2018
@@ -21,10 +21,25 @@ add_clang_unittest(ToolingTests
   LexicallyOrderedRecursiveASTVisitorTest.cpp
   LookupTest.cpp
   QualTypeNamesTest.cpp
-  RecursiveASTVisitorTest.cpp
-  RecursiveASTVisitorTestCallVisitor.cpp
+  RecursiveASTVisitorTests/Attr.cpp
+  RecursiveASTVisitorTests/Class.cpp
+  RecursiveASTVisitorTests/ConstructExpr.cpp
+  RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
+  RecursiveASTVisitorTests/CXXMemberCall.cpp
+  RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp
+  RecursiveASTVisitorTests/DeclRefExpr.cpp
+  RecursiveASTVisitorTests/ImplicitCtor.cpp
+  RecursiveASTVisitorTests/InitListExprPostOrder.cpp
+  RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp
+  RecursiveASTVisitorTests/InitListExprPreOrder.cpp
+  RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp
+  RecursiveASTVisitorTests/IntegerLiteral.cpp
+  RecursiveASTVisitorTests/LambdaDefaultCapture.cpp
+  RecursiveASTVisitorTests/LambdaExpr.cpp
+  RecursiveASTVisitorTests/NestedNameSpecifiers.cpp
+  RecursiveASTVisitorTests/ParenExpr.cpp
+  RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
   RecursiveASTVisitorTestDeclVisitor.cpp
-  RecursiveASTVisitorTestExprVisitor.cpp
   RecursiveASTVisitorTestPostOrderVisitor.cpp
   RecursiveASTVisitorTestTypeLocVisitor.cpp
   RefactoringActionRulesTest.cpp

Removed: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=330352&view=auto
==
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (removed)
@@ -1,305 +0,0 @@
-//===- unittest/Tooling/RecursiveASTVisitorTest.cpp 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "TestVisitor.h"
-#include 
-
-using namespace clang;
-
-namespace {
-
-class LambdaExprVisitor : public ExpectedLocationVisitor {
-public:
-  bool VisitLambdaExpr(LambdaExpr *Lambda) {
-Pendin

[PATCH] D45777: [UnitTests] NFC/build-perf: Break up nontrivial compile jobs

2018-04-19 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki closed this revision.
davezarzycki added a comment.

Thanks @thakis!

Committed as r330353


Repository:
  rC Clang

https://reviews.llvm.org/D45777



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


[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-19 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 143136.
Hahnfeld marked 2 inline comments as done.
Hahnfeld added a comment.

Move `FunctionType`s to methods and change test prefixes.


https://reviews.llvm.org/D42922

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,33 +1,40 @@
 // RUN: echo "GPU binary would be here" > %t
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
 #ifndef NOGLOBALS
-// CHECK-DAG: @device_var = internal global i32
+// ALL-DAG: @device_var = internal global i32
 __device__ int device_var;
 
-// CHECK-DAG: @constant_var = internal global i32
+// ALL-DAG: @constant_var = internal global i32
 __constant__ int constant_var;
 
-// CHECK-DAG: @shared_var = internal global i32
+// ALL-DAG: @shared_var = internal global i32
 __shared__ int shared_var;
 
 // Make sure host globals don't get internalized...
-// CHECK-DAG: @host_var = global i32
+// ALL-DAG: @host_var = global i32
 int host_var;
 // ... and that extern vars remain external.
-// CHECK-DAG: @ext_host_var = external global i32
+// ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
 // Shadows for external device-side variables are *definitions* of
 // those variables.
-// CHECK-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = internal global i32
 extern __device__ int ext_device_var;
-// CHECK-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = internal global i32
 extern __constant__ int ext_constant_var;
 
 void use_pointers() {
@@ -43,59 +50,73 @@
 
 // Make sure that all parts of GPU code init/cleanup are there:
 // * constant unnamed string with the kernel name
-// CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
+// ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// CHECK-SAME: section ".nv_fatbin", align 8
+// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
+// NORDC-SAME: section ".nv_fatbin", align 8
+// RDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
-// CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
-// CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
-// CHECK-SAME: section ".nvFatBinSegment"
+// ALL: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
+// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// ALL-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
-// CHECK: @__cuda_gpubin_handle = internal global i8** null
-// * Make sure our constructor/destructor was added to global ctor/dtor list.
-// CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
-// CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// NORDC: @__cuda_gpubin_handle = internal global i8** null
+// * constant unnamed string with NVModuleID
+// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
+// RDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
+// * Make sure our constructor was added to global ctor list.
+// ALL: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
+// * In separate mode we also register a destructor.
+// NORDC: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// * Alias to global symbol containing the NVModuleID.
+// RDC: @__fatbinwrap[[MODULE_ID]] = alias { i32, i32, i8*, i8* }
+// RDC-SAME: { i32, i32, i8*, i8* }* @__cuda_fatbin_wrapper
 
 // Test that we build the correct number of calls to cudaSetupArgument followed
 // by a call to cudaLaunch.
 
-// CHECK: define{{.*}}kernelfunc
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaLaunch
+// ALL: define{{.*}}kernelfunc
+/

[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-19 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:283-285
+  llvm::FunctionType *RegisterGlobalsFnTy;
+  llvm::FunctionType *RegisterLinkedBinaryFnTy;
+  llvm::Function *DummyCallback;

tra wrote:
> Instead of tracking these through the conditionals of pretty long function, 
> could we make these pointers class fields and init them in the constructor 
> and make accessors return them and, possibly, assert that they are used if 
> RDC is enabled?
I've removed the caching entirely because that's already done by 
`llvm::FunctionType::get()`. These are now called in new methods to avoid 
duplication.


https://reviews.llvm.org/D42922



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Frontend/FrontendTiming.cpp:14
+
+#include "llvm/Support/Timer.h"
+

This should include clang/Frontend/Utils.h .



Comment at: test/Frontend/ftime-report-template-decl.cpp:2
+// RUN: %clang %s -S -o - -ftime-report  2>&1 | FileCheck %s
+// RUN: %clang %s -S -o - -fdelayed-template-parsing 
-DDELAYED_TEMPLATE_PARSING -ftime-report  2>&1 | FileCheck %s
+

What is this test supposed to be testing?  If you're just checking that we 
output the timers, this doesn't need to be so complicated.

We generally prefer to use %clang_cc1 for tests like this.

Please use -emit-llvm instead of -S if you don't actually need assembly.


https://reviews.llvm.org/D45619



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


[PATCH] D45829: Remove impossible _MSC_VER check

2018-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: EricWF.
Herald added a subscriber: christof.

It is immediately preceded by this check:

  #if _MSC_VER < 1900
  #error "MSVC versions prior to Visual Studio 2015 are not supported"
  #endif


https://reviews.llvm.org/D45829

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -586,9 +586,6 @@
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -586,9 +586,6 @@
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name

2018-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:287
+CtorSuffix.append("_");
+CtorSuffix.append(ModuleName);
+  }

There is a general problem with this approach. File name can contain the 
characters that PTX does not allow.
We currently only deal with '.' and '@', but that's not enough here.
You may want to either mangle the name somehow to avoid/convert illegal 
characters or use some other way to provide unique suffix. Hex-encoded hash of 
the file name would avoid this problem, for example.





https://reviews.llvm.org/D44435



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


[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:364-377
+  llvm::Constant *NVModuleIDConstant;
+  SmallString<64> NVModuleID;
+  if (RelocatableDeviceCode) {
+// Generate a unique module ID.
+llvm::raw_svector_ostream OS(NVModuleID);
+OS << "__nv_" << llvm::format("%x", FatbinWrapper->getGUID());
+NVModuleIDConstant =

This can all be folded into the 'else' branch of the 'if' below.


https://reviews.llvm.org/D42922



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


[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-19 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 143145.
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.

Move module ID to corresponding `else` branch.


https://reviews.llvm.org/D42922

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,33 +1,40 @@
 // RUN: echo "GPU binary would be here" > %t
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
 #ifndef NOGLOBALS
-// CHECK-DAG: @device_var = internal global i32
+// ALL-DAG: @device_var = internal global i32
 __device__ int device_var;
 
-// CHECK-DAG: @constant_var = internal global i32
+// ALL-DAG: @constant_var = internal global i32
 __constant__ int constant_var;
 
-// CHECK-DAG: @shared_var = internal global i32
+// ALL-DAG: @shared_var = internal global i32
 __shared__ int shared_var;
 
 // Make sure host globals don't get internalized...
-// CHECK-DAG: @host_var = global i32
+// ALL-DAG: @host_var = global i32
 int host_var;
 // ... and that extern vars remain external.
-// CHECK-DAG: @ext_host_var = external global i32
+// ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
 // Shadows for external device-side variables are *definitions* of
 // those variables.
-// CHECK-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = internal global i32
 extern __device__ int ext_device_var;
-// CHECK-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = internal global i32
 extern __constant__ int ext_constant_var;
 
 void use_pointers() {
@@ -43,59 +50,73 @@
 
 // Make sure that all parts of GPU code init/cleanup are there:
 // * constant unnamed string with the kernel name
-// CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
+// ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// CHECK-SAME: section ".nv_fatbin", align 8
+// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
+// NORDC-SAME: section ".nv_fatbin", align 8
+// RDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
-// CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
-// CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
-// CHECK-SAME: section ".nvFatBinSegment"
+// ALL: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
+// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// ALL-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
-// CHECK: @__cuda_gpubin_handle = internal global i8** null
-// * Make sure our constructor/destructor was added to global ctor/dtor list.
-// CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
-// CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// NORDC: @__cuda_gpubin_handle = internal global i8** null
+// * constant unnamed string with NVModuleID
+// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
+// RDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
+// * Make sure our constructor was added to global ctor list.
+// ALL: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
+// * In separate mode we also register a destructor.
+// NORDC: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// * Alias to global symbol containing the NVModuleID.
+// RDC: @__fatbinwrap[[MODULE_ID]] = alias { i32, i32, i8*, i8* }
+// RDC-SAME: { i32, i32, i8*, i8* }* @__cuda_fatbin_wrapper
 
 // Test that we build the correct number of calls to cudaSetupArgument followed
 // by a call to cudaLaunch.
 
-// CHECK: define{{.*}}kernelfunc
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaSetupArgument
-// CHECK: call{{.*}}cudaLaunch
+// ALL: define{{.*}}kernelfunc
+// ALL: call

[PATCH] D45835: Add new driver mode for dumping compiler options

2018-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
Herald added a subscriber: cryptoad.

There are situations where an out-of-tree user may need to know information 
about what compiler options are used and what features/extensions may be 
available for a given invocation of the compiler. For instance, a tool may want 
to interrogate Clang so that it can emulate settings specific to the 
compilation without having to reverse engineer the Clang command line options 
or keep a custom mapping of language modes to features or extensions available 
in that mode.

This patch adds the ability to dump compiler option-related information to a 
JSON file. Specifically, it dumps the language options, codegen options, 
diagnostic options, and features/extensions lists -- however, this output could 
be extended to other information should it be useful (like target options, 
available attributes, etc). In order to support features and extensions, I 
moved them into a .def file so that we could build the various lists we care 
about from them without a significant increase in maintenance burden.

I selected JSON as the output because the data being output is serialized (as 
opposed to something human-writable like a config file), it's what our tool 
already groks, and it was simple to output to. If/when we get a JSON support 
library, I expect this code to be converted over to use that.

Our expectation is that the list of features and extensions will only ever be 
added to (because these are user-facing and removing one could break code), but 
that the other options may be added to, renamed, or removed between major 
releases (as opposed to point releases).


https://reviews.llvm.org/D45835

Files:
  include/clang/Basic/Features.def
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/Frontend/compiler-options-dump.cpp

Index: test/Frontend/compiler-options-dump.cpp
===
--- test/Frontend/compiler-options-dump.cpp
+++ test/Frontend/compiler-options-dump.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -compiler-options-dump -std=c++03 %s -o - | FileCheck %s --check-prefix=CXX03
+// RUN: %clang_cc1 -compiler-options-dump -std=c++17 %s -o - | FileCheck %s --check-prefix=CXX17
+// RUN: %clang_cc1 -compiler-options-dump -std=c99 -ffast-math -x c %s -o - | FileCheck %s --check-prefix=C99
+
+// CXX03: "language options"
+// CXX03: "C99" : 0
+// CXX03: "CPlusPlus" : 1
+// CXX03: "CPlusPlus11" : 0
+// CXX03: "CPlusPlus14" : 0
+// CXX03: "CPlusPlus17" : 0
+// CXX03: "Bool" : 1
+// CXX03: "HexFloats" : 0
+// CXX03: "FastMath" : 0
+// CXX03: "codegen options"
+// CXX03: "diagnostic options"
+// CXX03: "features"
+// CXX03: "cxx_auto_type" : false
+// CXX03: "cxx_range_for" : false
+// CXX03: "extensions"
+// CXX03: "cxx_range_for" : true
+
+// CXX17: "language options"
+// CXX17: "C99" : 0
+// CXX17: "CPlusPlus" : 1
+// CXX17: "CPlusPlus11" : 1
+// CXX17: "CPlusPlus14" : 1
+// CXX17: "CPlusPlus17" : 1
+// CXX17: "Bool" : 1
+// CXX17: "HexFloats" : 1
+// CXX17: "FastMath" : 0
+// CXX17: "codegen options"
+// CXX17: "diagnostic options"
+// CXX17: "features"
+// CXX17: "cxx_auto_type" : true
+// CXX17: "cxx_range_for" : true
+// CXX17: "extensions"
+// CXX17: "cxx_range_for" : true
+
+// C99: "language options"
+// C99: "C99" : 1
+// C99: "CPlusPlus" : 0
+// C99: "CPlusPlus11" : 0
+// C99: "CPlusPlus14" : 0
+// C99: "CPlusPlus17" : 0
+// C99: "Bool" : 0
+// C99: "HexFloats" : 1
+// C99: "FastMath" : 1
+// C99: "codegen options"
+// C99: "diagnostic options"
+// C99: "features"
+// C99: "c_alignas" : false
+// C99: "c_atomic" : false
+// C99: "cxx_auto_type" : false
+// C99: "cxx_range_for" : false
+// C99: "extensions"
+// C99: "c_alignas" : true
+// C99: "c_atomic" : true
+// C99: "cxx_range_for" : false
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1100,187 +1100,11 @@
   if (Feature.startswith("__") && Feature.endswith("__") && Feature.size() >= 4)
 Feature = Feature.substr(2, Feature.size() - 4);
 
+#define FEATURE(Name, Predicate) .Case(#Name, Predicate)
   return llvm::StringSwitch(Feature)
-  .Case("address_sanitizer",
-LangOpts.Sanitize.hasOneOf(SanitizerKind::Address |
-   SanitizerKind::KernelAddress))
-  .Case("hwaddress_sanitizer",
-LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
-   SanitizerKind::KernelHWAddress))
-  .Case("assume_nonnull", true)
-  .Case("attribute_analyzer_noreturn", true)
-  .Case("attribute_availability", true)
-  .Case("attribute_availabil

[PATCH] D45829: Remove impossible _MSC_VER check

2018-04-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

LGTM. I'd tried to clean all stale `_MSC_VER` conditionals in the past, but I 
must have missed some.


https://reviews.llvm.org/D45829



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


[libcxx] r330360 - Remove impossible _MSC_VER check

2018-04-19 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 19 12:40:12 2018
New Revision: 330360

URL: http://llvm.org/viewvc/llvm-project?rev=330360&view=rev
Log:
Remove impossible _MSC_VER check

Summary:
It is immediately preceded by this check:
  #if _MSC_VER < 1900
  #error "MSVC versions prior to Visual Studio 2015 are not supported"
  #endif

Reviewers: EricWF

Subscribers: christof, cfe-commits

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=330360&r1=330359&r2=330360&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Apr 19 12:40:12 2018
@@ -586,9 +586,6 @@ namespace std {
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)


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


[PATCH] D45835: Add new driver mode for dumping compiler options

2018-04-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The list of features/extensions seems okay; it's information which is already 
available through a stable interface (specifically, clang -E).  JSON also seems 
fine as a representation.

Including the language/codegen/etc. options as-is doesn't make sense; we can, 
and often do, change the internal representation of the option structs.  If the 
information is useful, we should provide a stable interface.


https://reviews.llvm.org/D45835



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


[PATCH] D45829: Remove impossible _MSC_VER check

2018-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330360: Remove impossible _MSC_VER check (authored by rnk, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45829?vs=143137&id=143151#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45829

Files:
  libcxx/trunk/include/__config


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -586,9 +586,6 @@
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -586,9 +586,6 @@
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#if _MSC_VER <= 1800
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#endif
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45835: Add new driver mode for dumping compiler options

2018-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D45835#1072557, @efriedma wrote:

> The list of features/extensions seems okay; it's information which is already 
> available through a stable interface (specifically, clang -E).  JSON also 
> seems fine as a representation.
>
> Including the language/codegen/etc. options as-is doesn't make sense; we can, 
> and often do, change the internal representation of the option structs.  If 
> the information is useful, we should provide a stable interface.


For our needs, the features/extensions is the most important information. I'd 
be happy to split this patch into two parts: one for the features/extensions 
dump and another for extended information if the compiler options part remains 
contentious.

Our tool already has to parse the Clang command line to get much of this 
information, and that effectively is the stable interface to compiler options. 
However, every once in a while, some piece of configuration information is 
calculated from the command line and getting Clang's exact answer is useful. If 
any of those options we care about wind up being changed, there's a good chance 
we may need to change something on our end anyway, so breaking us is actually 
useful. Given the benefits of having implementation freedom for the options 
interfaces, I'd prefer to keep them unstable for this feature.


https://reviews.llvm.org/D45835



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


[PATCH] D45807: [libclang] Fix test LibclangReparseTest.FileName when TMPDIR is set to a symbolic link

2018-04-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45807



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


[PATCH] D45836: Don't do aligned allocations on MSVCRT before 19.12 (update 15.3)

2018-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: EricWF, pcc.
Herald added a subscriber: christof.

https://reviews.llvm.org/D45836

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -944,6 +944,12 @@
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+// If we are getting operator new from the MSVC CRT, then allocation overloads
+// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
+#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
 #if defined(__APPLE__)
 #  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
   defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -944,6 +944,12 @@
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+// If we are getting operator new from the MSVC CRT, then allocation overloads
+// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
+#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
 #if defined(__APPLE__)
 #  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
   defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs, baloghadamsoftware.

Since recently, WebKit uses a peculiar build system that compiles multiple 
translation units at once by automatically joining them into a bigger file via 
`#include`. Because none of the functions end up in the main file, we disable 
all our path-sensitive checks on such unified sources. Try to work around that.


Repository:
  rC Clang

https://reviews.llvm.org/D45839

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/unified-sources/UnifiedSource-1.cpp
  test/Analysis/unified-sources/source1.cpp
  test/Analysis/unified-sources/source2.cpp

Index: test/Analysis/unified-sources/source2.cpp
===
--- /dev/null
+++ test/Analysis/unified-sources/source2.cpp
@@ -0,0 +1,6 @@
+// RUN: true
+
+int bar() {
+  int *x = 0;
+  return *x; // expected-warning{{}}
+}
Index: test/Analysis/unified-sources/source1.cpp
===
--- /dev/null
+++ test/Analysis/unified-sources/source1.cpp
@@ -0,0 +1,6 @@
+// RUN: true
+
+int foo(int x) {
+  if (x) {}
+  return 1 / x; // expected-warning{{}}
+}
Index: test/Analysis/unified-sources/UnifiedSource-1.cpp
===
--- /dev/null
+++ test/Analysis/unified-sources/UnifiedSource-1.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// There should still be diagnostics within included files.
+#include "source1.cpp"
+#include "source2.cpp"
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -678,7 +678,7 @@
   SourceLocation SL = Body ? Body->getLocStart() : D->getLocation();
   SL = SM.getExpansionLoc(SL);
 
-  if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) {
+  if (!Opts->AnalyzeAll && !Mgr->isInCodeFile(SL)) {
 if (SL.isInvalid() || SM.isInSystemHeader(SL))
   return AM_None;
 return Mode & ~AM_Path;
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -148,11 +149,11 @@
   if (CallLoc.isMacroID())
 return nullptr;
 
-  assert(SMgr.isInMainFile(CallLoc) &&
+  assert(AnalysisManager::isInCodeFile(CallLoc, SMgr) &&
  "The call piece should be in the main file.");
 
   // Check if CP represents a path through a function outside of the main file.
-  if (!SMgr.isInMainFile(CP->callEnterWithin.asLocation()))
+  if (!AnalysisManager::isInCodeFile(CP->callEnterWithin.asLocation(), SMgr))
 return CP;
 
   const PathPieces &Path = CP->path;
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -806,8 +806,9 @@
 /// This checks static properties of the function, such as its signature and
 /// CFG, to determine whether the analyzer should ever consider inlining it,
 /// in any context.
-static bool mayInlineDecl(AnalysisDeclContext *CalleeADC,
-  AnalyzerOptions &Opts) {
+static bool mayInlineDecl(AnalysisManager &AMgr,
+  AnalysisDeclContext *CalleeADC) {
+  AnalyzerOptions &Opts = AMgr.getAnalyzerOptions();
   // FIXME: Do not inline variadic calls.
   if (CallEvent::isVariadic(CalleeADC->getDecl()))
 return false;
@@ -830,7 +831,7 @@
   // Conditionally control the inlining of methods on objects that look
   // like C++ containers.
   if (!Opts.mayInlineCXXContainerMethods())
-if (!Ctx.getSourceManager().isInMainFile(FD->getLocation()))
+if (!AMgr.isInCodeFile(FD->getLocation()))
   if (isContainerMethod(Ctx, FD))
 return false;
 
@@ -891,7 +892,7 @@
   } else {
 // We haven't actually checked the static properties of this function yet.
 // Do that now, and record our decision in the function summaries.
-if (mayInlineDecl(CalleeADC, Opts)) {
+if (mayInlineDecl(g

[libcxx] r330372 - Don't do aligned allocations on MSVCRT before 19.12 (update 15.3)

2018-04-19 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 19 15:12:10 2018
New Revision: 330372

URL: http://llvm.org/viewvc/llvm-project?rev=330372&view=rev
Log:
Don't do aligned allocations on MSVCRT before 19.12 (update 15.3)

Reviewers: EricWF, pcc

Subscribers: christof, cfe-commits

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=330372&r1=330371&r2=330372&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Apr 19 15:12:10 2018
@@ -944,6 +944,12 @@ template  struct __static_asse
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
 
+// If we are getting operator new from the MSVC CRT, then allocation overloads
+// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
+#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
 #if defined(__APPLE__)
 #  if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
   defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)


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


[PATCH] D41357: WIP: Fix Diagnostic layering, moving diagnostics out of Basic

2018-04-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I've pushed this further - it builds now & has no fallback in libBasic to the 
old behavior/table.

One remaining thing I'm unsure about is the table of DIAG_START_* values. Do 
you think this is OK/good to leave hardcoded in diagnostics? Should I somehow 
remove the need for that global knowledge (dynamically allocating the start 
ranges of each grouping?)? Or go the other way & decide this global information 
renders this direction questionable and just sink all the diagnostics into 
Basic explicitly/properly?


Repository:
  rC Clang

https://reviews.llvm.org/D41357



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


  1   2   >