[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323179: [ReleaseNotes] Mention OpenMP Tools Interface in 
runtime library (authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42352?vs=131004=131006#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42352

Files:
  cfe/branches/release_60/docs/ReleaseNotes.rst


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -231,6 +231,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS. If you 
observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with 
`-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message 
to the
+  `OpenMP development list 
`_.
+
 Internal API Changes
 
 


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -231,6 +231,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface (OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS. If you observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with `-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message to the
+  `OpenMP development list `_.
+
 Internal API Changes
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Olga Malysheva via Phabricator via cfe-commits
omalyshe accepted this revision.
omalyshe added a comment.

LGTM


https://reviews.llvm.org/D42352



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


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 131004.
Hahnfeld marked 3 inline comments as done.
Hahnfeld added a comment.

Fix `macOS`.


https://reviews.llvm.org/D42352

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -222,6 +222,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS. If you 
observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with 
`-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message 
to the
+  `OpenMP development list 
`_.
+
 Internal API Changes
 
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -222,6 +222,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface (OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS. If you observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with `-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message to the
+  `OpenMP development list `_.
+
 Internal API Changes
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Olga Malysheva via Phabricator via cfe-commits
omalyshe added inline comments.



Comment at: docs/ReleaseNotes.rst:226
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. If you 
observe
+  a measurable performance impact on one of your applications without a tool

Hahnfeld wrote:
> omalyshe wrote:
> > Linux*, Windows* and macOS*
> That's done nowhere else in Clang's documentation so I'm strongly opposed to 
> doing it here unless you have a very good legal reason that nobody else knows 
> about.
I'm OK with omitting "*" but "macOS" should be definitely fixed ;)


https://reviews.llvm.org/D42352



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


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: docs/ReleaseNotes.rst:226
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. If you 
observe
+  a measurable performance impact on one of your applications without a tool

omalyshe wrote:
> Linux*, Windows* and macOS*
That's done nowhere else in Clang's documentation so I'm strongly opposed to 
doing it here unless you have a very good legal reason that nobody else knows 
about.


https://reviews.llvm.org/D42352



___
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-01-22 Thread Wei Mi via Phabricator via cfe-commits
wmi added a comment.

Thanks for the size evaluation. I regarded the change as a natural and limited 
extension to the current fine-grain bitfield access mode, so I feel ok with the 
change. Hal, what do you think?


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] D41977: [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.

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

Looks good, thanks!

Maybe the assertion message could be clearer about why this is a problem 
though? ("binds to a temporary whose lifetime has ended" maybe?)


https://reviews.llvm.org/D41977



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


[PATCH] D42408: [clang-format] Align preprocessor comments with #

2018-01-22 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw created this revision.
mzeren-vmw added reviewers: krasimir, klimek, djasper.

r312125, which introduced preprocessor indentation, shipped with a known
issue where "indentation of comments immediately before indented
preprocessor lines is toggled on each run". For example these two forms
toggle:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  // comment
  #   define A 0
  #endif
  #endif
  
  #ifndef HEADER_H
  #define HEADER_H
  #if 1
 // comment
  #   define A 0
  #endif
  #endif

This happens because we check vertical alignment against the '#' yet
indent to the level of the 'define'. This patch resolves this issue by
aligning against the '#'.


Repository:
  rC Clang

https://reviews.llvm.org/D42408

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2610,21 +2610,85 @@
"code();\n"
"#endif",
Style));
-  // FIXME: The comment indent corrector in TokenAnnotator gets thrown off by
-  // preprocessor indentation.
-  EXPECT_EQ("#if 1\n"
-"  // comment\n"
-"#  define A 0\n"
-"// comment\n"
-"#  define B 0\n"
-"#endif",
-format("#if 1\n"
-   "// comment\n"
-   "#  define A 0\n"
-   "   // comment\n"
-   "#  define B 0\n"
-   "#endif",
-   Style));
+  // Keep comments aligned with #, otherwise indnet comments normally. These
+  // tests cannot use verifyFormat because messUp manipulates leading
+  // whitespace.
+  {
+const char *Expected = ""
+   "void f() {\n"
+   "#if 1\n"
+   "// Preprocessor aligned.\n"
+   "#  define A 0\n"
+   "  // Code. Separated by blank line.\n"
+   "\n"
+   "#  define B 0\n"
+   "  // Code. Not aligned with #\n"
+   "#  define C 0\n"
+   "#endif";
+const char *ToFormat = ""
+   "void f() {\n"
+   "#if 1\n"
+   "// Preprocessor aligned.\n"
+   "#  define A 0\n"
+   "// Code. Separated by blank line.\n"
+   "\n"
+   "#  define B 0\n"
+   "   // Code. Not aligned with #\n"
+   "#  define C 0\n"
+   "#endif";
+EXPECT_EQ(Expected, format(ToFormat, Style));
+EXPECT_EQ(Expected, format(Expected, Style));
+  }
+  // Keep block quotes aligned.
+  {
+const char *Expected = ""
+   "void f() {\n"
+   "#if 1\n"
+   "/* Preprocessor aligned. */\n"
+   "#  define A 0\n"
+   "  /* Code. Separated by blank line. */\n"
+   "\n"
+   "#  define B 0\n"
+   "  /* Code. Not aligned with # */\n"
+   "#  define C 0\n"
+   "#endif";
+const char *ToFormat = ""
+   "void f() {\n"
+   "#if 1\n"
+   "/* Preprocessor aligned. */\n"
+   "#  define A 0\n"
+   "/* Code. Separated by blank line. */\n"
+   "\n"
+   "#  define B 0\n"
+   "   /* Code. Not aligned with # */\n"
+   "#  define C 0\n"
+   "#endif";
+EXPECT_EQ(Expected, format(ToFormat, Style));
+EXPECT_EQ(Expected, format(Expected, Style));
+  }
+  // Keep comments aligned with un-indented directives.
+  {
+const char *Expected = ""
+   "void f() {\n"
+   "// Preprocessor aligned.\n"
+   "#define A 0\n"
+   "  // Code. Separated by blank line.\n"
+   "\n"
+   "#define B 0\n"
+   "  // Code. Not aligned with #\n"
+   "#define C 0\n";
+const char *ToFormat = ""
+   "void f() {\n"
+   "// Preprocessor aligned.\n"
+   "#define A 0\n"
+   "// Code. Separated by blank line.\n"
+   "\n"
+   "#define B 0\n"
+   "   // Code. Not aligned with #\n"
+   "#define C 0\n";

[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Olga Malysheva via Phabricator via cfe-commits
omalyshe added inline comments.



Comment at: docs/ReleaseNotes.rst:226
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. If you 
observe
+  a measurable performance impact on one of your applications without a tool

Linux*, Windows* and macOS*


https://reviews.llvm.org/D42352



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


r323177 - [NFC] fix trivial typos in comments

2018-01-22 Thread Hiroshi Inoue via cfe-commits
Author: inouehrs
Date: Mon Jan 22 21:50:06 2018
New Revision: 323177

URL: http://llvm.org/viewvc/llvm-project?rev=323177=rev
Log:
[NFC] fix trivial typos in comments

"the the" -> "the"


Modified:
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=323177=323176=323177=diff
==
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Mon Jan 22 21:50:06 2018
@@ -24,7 +24,7 @@ namespace clang {
 /// of QualType.
 ///
 enum class LangAS : unsigned {
-  // The default value 0 is the value used in QualType for the the situation
+  // The default value 0 is the value used in QualType for the situation
   // where there is no address space qualifier.
   Default = 0,
 

Modified: cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h?rev=323177=323176=323177=diff
==
--- cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ConstantInitBuilder.h Mon Jan 22 21:50:06 
2018
@@ -295,7 +295,7 @@ public:
 slot = value;
   }
 
-  /// Produce an address which will eventually point to the the next
+  /// Produce an address which will eventually point to the next
   /// position to be filled.  This is computed with an indexed
   /// getelementptr rather than by computing offsets.
   ///

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=323177=323176=323177=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jan 22 
21:50:06 2018
@@ -86,7 +86,7 @@ def LLVM : Package<"llvm">;
 
 // The APIModeling package is for checkers that model APIs and don't perform
 // any diagnostics. These checkers are always turned on; this package is
-// intended for API modeling that is not controlled by the the target triple.
+// intended for API modeling that is not controlled by the target triple.
 def APIModeling : Package<"apiModeling">, Hidden;
 def GoogleAPIModeling : Package<"google">, InPackage;
 

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h?rev=323177=323176=323177=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h Mon Jan 
22 21:50:06 2018
@@ -82,7 +82,7 @@ private:
   Expected
   createSourceReplacements(RefactoringRuleContext ) override;
 
-  // A NamedDecl which indentifies the the symbol being renamed.
+  // A NamedDecl which indentifies the symbol being renamed.
   const NamedDecl *ND;
   // The new qualified name to change the symbol to.
   std::string NewQualifiedName;


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


[PATCH] D42019: [Driver] Set default sysroot for Fuchsia if none is specified

2018-01-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: lib/Driver/ToolChains/Fuchsia.cpp:152
+  llvm::sys::path::append(P, normalizeTriple(Triple));
+  return P.str();
+}

mcgrathr wrote:
> The GCC behavior (if --with-sysroot is given to configure) is 
> tooldir/sys-root, not tooldir itself.
That's fine with me, although I'm not very fond of the `sys-root` since it's 
typically spelled as `sysroot` everywhere else, but I could be convinced if we 
want to be consistent with GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D42019



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


[libcxx] r323171 - [cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.

2018-01-22 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Jan 22 19:30:23 2018
New Revision: 323171

URL: http://llvm.org/viewvc/llvm-project?rev=323171=rev
Log:
[cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional 
ones.

* Previously part of https://reviews.llvm.org/D41622.

Modified:
libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake

Modified: libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake?rev=323171=323170=323171=diff
==
--- libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake (original)
+++ libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake Mon Jan 22 19:30:23 2018
@@ -9,7 +9,7 @@ INCLUDE(CheckCXXSourceCompiles)
 
 function(check_cxx_atomics varname)
   set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
-  set(CMAKE_REQUIRED_FLAGS "-nodefaultlibs -std=c++11 -nostdinc++ -isystem 
${LIBCXX_SOURCE_DIR}/include")
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs -std=c++11 
-nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
   if (${LIBCXX_GCC_TOOLCHAIN})
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} 
--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
   endif()


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


[PATCH] D42170: Fixit for 'typedef' instead of 'typename' typo

2018-01-22 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: Parse/ParseTemplate.cpp:492
+  // Is there just a typo in the input code? ('typedef' instead of 'typename')
+  if (Tok.is(tok::kw_typedef)) {
+Diag(Tok.getLocation(), diag::err_expected_template_parameter);

How does it work when you have `typedef` for the first template parameter?



Comment at: Parser/typedef-instead-of-typename-typo.hpp:3
+
+template  struct Foo {
+  a

Maybe put this test in clang/test/FixIt ?

Also please check what file extensions are used for testing templates. .hpp 
reflects real-life usage but  most tests are .cpp. Or maybe I wasn't paying 
attention.



Comment at: Parser/typedef-instead-of-typename-typo.hpp:5
+  a
+}; // CHECK: expected-error{{expected template parameter}} \
+// CHECK: expected-note{{Did you mean to use 'typename'?}} \

It is a little bit confusing to what lines the messages would be attributed to. 
Need to check locally because not sure I interpret all those backslashes the 
same way lit does.

Also idea for the test. To check that the fix-it was applied properly you can 
add a member like `B b;` and it shouldn't trigger any errors.



Comment at: clang/Basic/DiagnosticParseKinds.td:1167
+def note_meant_to_use_typename : Note<
+  "Did you mean to use 'typename'?">;
 }

Looks like other diagnostic messages "did you mean to use …" have lowercase "d" 
in "did". Though I haven't checked how it looks in various situations.


https://reviews.llvm.org/D42170



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


[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2018-01-22 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX323170: libcxx: Provide overloads for 
basic_filebuf::open() et al that take wchar_t*… (authored by pcc, committed by 
).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42225?vs=130747=130995#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D42225

Files:
  include/__config
  include/fstream
  
test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
  
test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
  test/libcxx/input.output/file.streams/fstreams/ifstream.cons/test.dat
  
test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp
  
test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
  test/libcxx/input.output/file.streams/fstreams/ifstream.members/test.dat
  
test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
  
test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
  test/support/platform_support.h

Index: include/fstream
===
--- include/fstream
+++ include/fstream
@@ -212,6 +212,9 @@
 bool is_open() const;
 #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
+#endif
 _LIBCPP_INLINE_VISIBILITY
 basic_filebuf* open(const string& __s, ios_base::openmode __mode);
 #endif
@@ -551,6 +554,90 @@
 return __rt;
 }
 
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+// This is basically the same as the char* overload except that it uses _wfopen
+// and long mode strings.
+template 
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
+{
+basic_filebuf<_CharT, _Traits>* __rt = 0;
+if (__file_ == 0)
+{
+__rt = this;
+const wchar_t* __mdstr;
+switch (__mode & ~ios_base::ate)
+{
+case ios_base::out:
+case ios_base::out | ios_base::trunc:
+__mdstr = L"w";
+break;
+case ios_base::out | ios_base::app:
+case ios_base::app:
+__mdstr = L"a";
+break;
+case ios_base::in:
+__mdstr = L"r";
+break;
+case ios_base::in | ios_base::out:
+__mdstr = L"r+";
+break;
+case ios_base::in | ios_base::out | ios_base::trunc:
+__mdstr = L"w+";
+break;
+case ios_base::in | ios_base::out | ios_base::app:
+case ios_base::in | ios_base::app:
+__mdstr = L"a+";
+break;
+case ios_base::out | ios_base::binary:
+case ios_base::out | ios_base::trunc | ios_base::binary:
+__mdstr = L"wb";
+break;
+case ios_base::out | ios_base::app | ios_base::binary:
+case ios_base::app | ios_base::binary:
+__mdstr = L"ab";
+break;
+case ios_base::in | ios_base::binary:
+__mdstr = L"rb";
+break;
+case ios_base::in | ios_base::out | ios_base::binary:
+__mdstr = L"r+b";
+break;
+case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+__mdstr = L"w+b";
+break;
+case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+case ios_base::in | ios_base::app | ios_base::binary:
+__mdstr = L"a+b";
+break;
+default:
+__rt = 0;
+break;
+}
+if (__rt)
+{
+__file_ = _wfopen(__s, __mdstr);
+if (__file_)
+{
+__om_ = __mode;
+if (__mode & ios_base::ate)
+{
+if (fseek(__file_, 0, SEEK_END))
+{
+fclose(__file_);
+__file_ = 0;
+__rt = 0;
+}
+}
+}
+else
+__rt = 0;
+}
+}
+return __rt;
+}
+#endif
+
 template 
 inline
 basic_filebuf<_CharT, _Traits>*
@@ -1017,6 +1104,10 @@
 #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 _LIBCPP_INLINE_VISIBILITY
 explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+_LIBCPP_INLINE_VISIBILITY
+explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
+#endif
 _LIBCPP_INLINE_VISIBILITY
 explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
 #endif
@@ -1036,6 +1127,9 @@
 bool is_open() const;
 #ifndef 

[libcxx] r323170 - libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2018-01-22 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Jan 22 18:07:27 2018
New Revision: 323170

URL: http://llvm.org/viewvc/llvm-project?rev=323170=rev
Log:
libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* 
filenames on Windows.

This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.

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

Added:
libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/fstream.cons/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/fstream.members/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/test.dat

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.members/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ifstream.members/test.dat
libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ofstream.members/

libcxx/trunk/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/fstream
libcxx/trunk/test/support/platform_support.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=323170=323169=323170=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan 22 18:07:27 2018
@@ -247,6 +247,7 @@
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))
 #define _LIBCPP_HAS_BITSCAN64
 #  endif
+#  define _LIBCPP_HAS_OPEN_WITH_WCHAR
 # if defined(_LIBCPP_MSVCRT)
 #   define _LIBCPP_HAS_QUICK_EXIT
 # endif

Modified: libcxx/trunk/include/fstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=323170=323169=323170=diff
==
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Mon Jan 22 18:07:27 2018
@@ -212,6 +212,9 @@ public:
 bool is_open() const;
 #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
 basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
+#endif
 _LIBCPP_INLINE_VISIBILITY
 basic_filebuf* open(const string& __s, ios_base::openmode __mode);
 #endif
@@ -551,6 +554,90 @@ basic_filebuf<_CharT, _Traits>::open(con
 return __rt;
 }
 
+#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+// This is basically the same as the char* overload except that it uses _wfopen
+// and long mode strings.
+template 
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode 
__mode)
+{
+basic_filebuf<_CharT, _Traits>* __rt = 0;
+if (__file_ == 0)
+{
+__rt = this;
+const wchar_t* __mdstr;
+switch (__mode & ~ios_base::ate)
+{
+case ios_base::out:
+case ios_base::out | ios_base::trunc:
+__mdstr = L"w";
+break;
+case ios_base::out | ios_base::app:
+case ios_base::app:
+__mdstr = L"a";
+break;
+case ios_base::in:
+__mdstr = L"r";
+break;
+case ios_base::in | ios_base::out:
+__mdstr = L"r+";
+break;
+case ios_base::in | ios_base::out | ios_base::trunc:
+__mdstr = L"w+";
+break;
+case ios_base::in | ios_base::out | ios_base::app:
+case ios_base::in | ios_base::app:
+__mdstr = L"a+";
+break;
+case ios_base::out | ios_base::binary:
+case ios_base::out | ios_base::trunc | ios_base::binary:
+__mdstr = L"wb";
+break;
+case ios_base::out | ios_base::app | ios_base::binary:
+case ios_base::app | ios_base::binary:
+__mdstr = L"ab";
+break;
+case ios_base::in | ios_base::binary:
+__mdstr = L"rb";
+break;
+case ios_base::in | ios_base::out | ios_base::binary:
+__mdstr = L"r+b";
+break;
+case ios_base::in | 

[libcxx] r323169 - libcxx: Move Windows threading support into a .cpp file.

2018-01-22 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon Jan 22 17:59:43 2018
New Revision: 323169

URL: http://llvm.org/viewvc/llvm-project?rev=323169=rev
Log:
libcxx: Move Windows threading support into a .cpp file.

This allows us to avoid polluting the namespace of users of 
with the definitions in windows.h.

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

Added:
libcxx/trunk/src/support/win32/thread_win32.cpp
Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=323169=323168=323169=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Mon Jan 22 17:59:43 2018
@@ -26,23 +26,11 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
-#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
-#include 
-#include 
-#include 
 #endif
 
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
 
-
-#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
-defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
-#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
-#else
-#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
-#endif
-
 #if defined(__FreeBSD__) && defined(__clang__) && 
__has_attribute(no_thread_safety_analysis)
 #define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
__attribute__((no_thread_safety_analysis))
 #else
@@ -51,7 +39,15 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
+
+#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
+
+#elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+
+#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
+
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -79,32 +75,41 @@ typedef pthread_key_t __libcpp_tls_key;
 
 #define _LIBCPP_TLS_DESTRUCTOR_CC
 #else
+
+#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
+
 // Mutex
-typedef SRWLOCK __libcpp_mutex_t;
-#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+typedef void* __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER 0
 
-typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || 
defined(__arm__)
+typedef void* __libcpp_recursive_mutex_t[6];
+#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || 
defined(__aarch64__)
+typedef void* __libcpp_recursive_mutex_t[5];
+#else
+# error Unsupported architecture
+#endif
 
 // Condition Variable
-typedef CONDITION_VARIABLE __libcpp_condvar_t;
-#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+typedef void* __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER 0
 
 // Execute Once
-typedef INIT_ONCE __libcpp_exec_once_flag;
-#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+typedef void* __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
 
 // Thread ID
-typedef DWORD __libcpp_thread_id;
+typedef long __libcpp_thread_id;
 
 // Thread
 #define _LIBCPP_NULL_THREAD 0U
 
-typedef HANDLE __libcpp_thread_t;
+typedef void* __libcpp_thread_t;
 
 // Thread Local Storage
-typedef DWORD __libcpp_tls_key;
+typedef long __libcpp_tls_key;
 
-#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
+#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
 #endif
 
 // Mutex
@@ -201,10 +206,9 @@ void *__libcpp_tls_get(__libcpp_tls_key
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
-defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
-
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
+defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
@@ -390,244 +394,6 @@ int __libcpp_tls_set(__libcpp_tls_key __
 return pthread_setspecific(__key, __p);
 }
 
-#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
-
-// Mutex
-int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
-{
-  InitializeCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
-{
-  EnterCriticalSection(__m);
-  return 0;
-}
-
-bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
-{
-  return TryEnterCriticalSection(__m) != 0;
-}
-
-int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
-{
-  LeaveCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
-{
-  DeleteCriticalSection(__m);
-  return 0;
-}
-
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
-{
-  AcquireSRWLockExclusive(__m);
-  return 0;
-}
-
-bool 

[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2018-01-22 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 130991.
mclow.lists added a comment.

Update macro checks.


https://reviews.llvm.org/D35472

Files:
  include/type_traits
  test/std/utilities/meta/meta.type.synop/endian.pass.cpp


Index: test/std/utilities/meta/meta.type.synop/endian.pass.cpp
===
--- test/std/utilities/meta/meta.type.synop/endian.pass.cpp
+++ test/std/utilities/meta/meta.type.synop/endian.pass.cpp
@@ -0,0 +1,47 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++1z
+
+// enum class endian;
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+typedef std::endian E;
+static_assert(std::is_enum::value, "");
+
+// Check that E is a scoped enum by checking for conversions.
+typedef std::underlying_type::type UT;
+static_assert(!std::is_convertible::value, "");
+
+// test that the enumeration values exist
+static_assert( std::endian::little == std::endian::little );
+static_assert( std::endian::big== std::endian::big );
+static_assert( std::endian::native == std::endian::native );
+static_assert( std::endian::little != std::endian::big );
+
+//  Technically not required, but true on all existing machines
+static_assert( std::endian::native == std::endian::little || 
+   std::endian::native == std::endian::big );
+
+//  Try to check at runtime
+{
+uint32_t i = 0x01020304;
+char c[4];
+static_assert(sizeof(i) == sizeof(c));
+std::memcpy(c, , sizeof(c));
+
+assert ((c[0] == 1) == (std::endian::native == std::endian::big));
+}
+}
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -4941,6 +4941,21 @@
 
 #endif
 
+#if _LIBCPP_STD_VER > 17
+enum class endian
+{
+little = 0xDEAD,
+big= 0xFACE,
+#if defined(_LIBCPP_LITTLE_ENDIAN)
+native = little
+#elif defined(_LIBCPP_BIG_ENDIAN)
+native = big
+#else
+native = 0xCAFE
+#endif
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 14


Index: test/std/utilities/meta/meta.type.synop/endian.pass.cpp
===
--- test/std/utilities/meta/meta.type.synop/endian.pass.cpp
+++ test/std/utilities/meta/meta.type.synop/endian.pass.cpp
@@ -0,0 +1,47 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++1z
+
+// enum class endian;
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+typedef std::endian E;
+static_assert(std::is_enum::value, "");
+
+// Check that E is a scoped enum by checking for conversions.
+typedef std::underlying_type::type UT;
+static_assert(!std::is_convertible::value, "");
+
+// test that the enumeration values exist
+static_assert( std::endian::little == std::endian::little );
+static_assert( std::endian::big== std::endian::big );
+static_assert( std::endian::native == std::endian::native );
+static_assert( std::endian::little != std::endian::big );
+
+//  Technically not required, but true on all existing machines
+static_assert( std::endian::native == std::endian::little || 
+   std::endian::native == std::endian::big );
+
+//  Try to check at runtime
+{
+uint32_t i = 0x01020304;
+char c[4];
+static_assert(sizeof(i) == sizeof(c));
+std::memcpy(c, , sizeof(c));
+
+assert ((c[0] == 1) == (std::endian::native == std::endian::big));
+}
+}
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -4941,6 +4941,21 @@
 
 #endif
 
+#if _LIBCPP_STD_VER > 17
+enum class endian
+{
+little = 0xDEAD,
+big= 0xFACE,
+#if defined(_LIBCPP_LITTLE_ENDIAN)
+native = little
+#elif defined(_LIBCPP_BIG_ENDIAN)
+native = big
+#else
+native = 0xCAFE
+#endif
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 14
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42154: Don't generate inline atomics for i386/i486

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Well, my point is that the example in the linked bug is asking for 486 
code-generation, which is apparently unsupported by LLVM.

Anyway, it's not a good reason to hold up this patch, since the way to support 
things is to gradually fix the bugs with them.  LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D42154



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


r323167 - NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.

2018-01-22 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Jan 22 17:25:24 2018
New Revision: 323167

URL: http://llvm.org/viewvc/llvm-project?rev=323167=rev
Log:
NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.

Using a new extension point in the new PM, register GCOV at the start of
the pipeline rather than the end.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/code-coverage.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=323167=323166=323167=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jan 22 17:25:24 2018
@@ -909,6 +909,9 @@ void EmitAssemblyHelper::EmitAssemblyWit
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  if (Optional Options = getGCOVOptions(CodeGenOpts))
+MPM.addPass(GCOVProfilerPass(*Options));
+
   // Build a minimal pipeline based on the semantics required by Clang,
   // which is just that always inlining occurs.
   MPM.addPass(AlwaysInlinerPass());
@@ -932,6 +935,10 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
+  if (Optional Options = getGCOVOptions(CodeGenOpts))
+PB.registerPipelineStartEPCallback([Options](ModulePassManager ) {
+  MPM.addPass(GCOVProfilerPass(*Options));
+});
 
   if (IsThinLTO) {
 MPM = PB.buildThinLTOPreLinkDefaultPipeline(
@@ -945,9 +952,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
CodeGenOpts.DebugPassManager);
   }
 }
-if (Optional Options = getGCOVOptions(CodeGenOpts)) {
-  MPM.addPass(GCOVProfilerPass(*Options));
-}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Modified: cfe/trunk/test/CodeGen/code-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/code-coverage.c?rev=323167=323166=323167=diff
==
--- cfe/trunk/test/CodeGen/code-coverage.c (original)
+++ cfe/trunk/test/CodeGen/code-coverage.c Mon Jan 22 17:25:24 2018
@@ -3,9 +3,15 @@
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data 
-coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -dwarf-column-info 
-debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix 
GCOV_FILE_INFO
 
 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager 
-fdebug-pass-manager -femit-coverage-data %s 2>&1 | FileCheck 
--check-prefix=NEWPM %s
+// RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager 
-fdebug-pass-manager -femit-coverage-data -O3 %s 2>&1 | FileCheck 
--check-prefix=NEWPM-O3 %s
 
+// NEWPM-NOT: Running pass
 // NEWPM: Running pass: GCOVProfilerPass
 
+// NEWPM-O3-NOT: Running pass
+// NEWPM-O3: Running pass: ForceFunctionAttrsPass
+// NEWPM-O3: Running pass: GCOVProfilerPass
+
 
 int test1(int a) {
   switch (a % 2) {


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


[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-22 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added a comment.

In https://reviews.llvm.org/D42036#984401, @djasper wrote:

> To me, aligning with the define seems fundamentally wrong.


we definitely have code that does that internally. It can also be seen in the 
wild e.g.:
https://github.com/boostorg/config/blob/develop/include/boost/config/detail/posix_features.hpp
However, it seems reasonable that clang-format's "default" be alignment with #. 
That will be a simpler patch, and it will resolve the toggling behavior. Let me 
work that up in a separate review.


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


[PATCH] D42319: [CUDA] CUDA has no device-side library builtins.

2018-01-22 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Got it, thanks for the explanation.


https://reviews.llvm.org/D42319



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


[PATCH] D42376: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

2018-01-22 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1579
 (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) 
{
+  unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+   ? 0

I think a comment might help here. Specifically, it should mention that this is 
required for the special case where there is an unbreakable tail only if 
certain other formatting decisions have been taken. The UnbreakableTailLength 
is an overapproximation in that case and we need to be correct here.

Thinking about this some more, there might actually be cases where this is 
still not correct as the unbreakable tail is neither 0 nor the precomputed 
value.

E.g. can we construct a case where there is a trailing comma in a braced list? 
Maybe this:

vector x = {"aa",};

In this case, I think the comma will always be part of the string literal, but 
the "};" only get part of the tail if we don't wrap after the "{".


Repository:
  rC Clang

https://reviews.llvm.org/D42376



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


[PATCH] D42396: [analyzer] Do not attempt to get the pointee of void* .

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 130979.

Repository:
  rL LLVM

https://reviews.llvm.org/D42396

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/malloc.c


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void **ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,9 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if ((*I)->getType()->isVoidPointerType())
+continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void **ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,9 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if ((*I)->getType()->isVoidPointerType())
+continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42354: Fix libcxx MSVC C++17 redefinition of 'align_val_t'

2018-01-22 Thread Force.Charlie-I via Phabricator via cfe-commits
fcharlie added a comment.

In https://reviews.llvm.org/D42354#984067, @STL_MSFT wrote:

> Seems reasonable to me.


Thanks


Repository:
  rCXX libc++

https://reviews.llvm.org/D42354



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


[PATCH] D42396: [analyzer] Do not attempt to get the pointee of void* .

2018-01-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, the original code seems quite quick-and-dirty. It, indeed, tries to 
blindly dereference something that's accidentally "some pointer".

Could you change the type check to consider AST types instead, i.e. check that 
`(*I)->getType()` is a double-pointer type? And then pass its single-pointee 
type into `getSVal` as the second optional argument, so that it knew what to 
expect. This would be the correct way to express what the author was trying to 
say.

Because your code ignores possible layers of sub-regions contained within 
`Reg`, and i'm afraid we may loose notes because of that.

(in any case there are many more ways in which a pointer can be passed into a 
function that this visitor doesn't pattern-match, but that's not super 
problematic)


Repository:
  rL LLVM

https://reviews.llvm.org/D42396



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


[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-22 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

While I agree that there is probably a bug to fix, I don't (yet) agree with 
what is proposed in this patch. I think a comment in between preprocessor 
directives should always either:

- Be considered part of the code in between the #-lines
- Be considered to be commenting on the subsequent #-line

In the former case, we need to indent with the regular IndentWidth, completely 
irrespective of anything inside the preprocessor lines. In the latter case, we 
should align with the # in column 0. To me, aligning with the define seems 
fundamentally wrong.


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


[libcxx] r323160 - Update cxx2a status

2018-01-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 22 15:17:20 2018
New Revision: 323160

URL: http://llvm.org/viewvc/llvm-project?rev=323160=rev
Log:
Update cxx2a status

Modified:
libcxx/trunk/www/cxx2a_status.html

Modified: libcxx/trunk/www/cxx2a_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=323160=323159=323160=diff
==
--- libcxx/trunk/www/cxx2a_status.html (original)
+++ libcxx/trunk/www/cxx2a_status.html Mon Jan 22 15:17:20 2018
@@ -54,14 +54,14 @@
 
-   https://wg21.link/P0463R1;>P0463R1LWGEndian just 
EndianTorontoIn progress
+   https://wg21.link/P0463R1;>P0463R1LWGEndian just 
EndianTorontoIn progress7.0
https://wg21.link/P0674R1;>P0674R1LWGExtending 
make_shared to Support ArraysToronto
 

https://wg21.link/P0020R6;>P0020R6LWGFloating Point 
AtomicAlbuquerque
https://wg21.link/P0053R7;>P0053R7LWGC++ 
Synchronized Buffered OstreamAlbuquerque
https://wg21.link/P0202R3;>P0202R3LWGAdd constexpr 
modifiers to functions in algorithm and utility 
HeadersAlbuquerqueIn Progress7.0
-   https://wg21.link/P0415R1;>P0415R1LWGConstexpr for 
std::complexAlbuquerque
+   https://wg21.link/P0415R1;>P0415R1LWGConstexpr for 
std::complexAlbuquerqueIn 
Progress7.0
https://wg21.link/P0439R0;>P0439R0LWGMake 
std::memory_order a scoped 
enumerationAlbuquerque
https://wg21.link/P0457R2;>P0457R2LWGString Prefix 
and Suffix CheckingAlbuquerqueComplete6.0
https://wg21.link/P0550R2;>P0550R2LWGTransformation 
Trait 
remove_cvrefAlbuquerqueComplete6.0
@@ -78,7 +78,10 @@
 
 [ Note: "Nothing to do" means that no library changes were needed to 
implement this change -- end note]
 
-The missing bits in P0600 are in [mem.res.class], 
[mem.poly.allocator.class], and [container.node.overview]
+The missing bits in P0600 are in [mem.res.class], 
[mem.poly.allocator.class], and [container.node.overview]
+
+The missing bits in P0202 are in copy, copy_backwards, 
move, and move_backwards (and the ones that call them: 
copy_n, rotate_copy, merge, set_union, 
set_difference, and set_symmetric_difference). This is 
because the first four algorithms have specializations that call 
memmove which is not constexpr. See https://bugs.llvm.org/show_bug.cgi?id=25165;>Bug 25165
+
 
   Library Working group Issues Status
 
@@ -115,7 +118,7 @@
https://wg21.link/LWG2958;>2958Moves 
improperly defined as deletedAlbuquerque
https://wg21.link/LWG2964;>2964Apparently 
redundant requirement for 
dynamic_pointer_castAlbuquerque
https://wg21.link/LWG2965;>2965Non-existing 
path::native_string() in filesystem_error::what() 
specificationAlbuquerque
-   https://wg21.link/LWG2972;>2972What is 
is_trivially_destructible_v?AlbuquerqueComplete
+   https://wg21.link/LWG2972;>2972What is 
is_trivially_destructible_vint?AlbuquerqueComplete
https://wg21.link/LWG2976;>2976Dangling 
uses_allocator specialization for 
packaged_taskAlbuquerqueComplete
https://wg21.link/LWG2977;>2977unordered_meow::merge() has 
incorrect Throws: clauseAlbuquerque
https://wg21.link/LWG2978;>2978Hash 
support for pmr::string and friendsAlbuquerque
@@ -132,7 +135,7 @@
 
   
 
-  Last Updated: 15-Jan-2018
+  Last Updated: 22-Jan-2018
 
 
 


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


[PATCH] D42395: [clang-format] Fix bug where -dump-config failed on ObjC header

2018-01-22 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 130970.
benhamilton added a comment.

- Support AssumeFileName with stdin.


Repository:
  rC Clang

https://reviews.llvm.org/D42395

Files:
  test/Format/dump-config-cxx.h
  test/Format/dump-config-objc.h
  test/Format/lit.local.cfg
  tools/clang-format/ClangFormat.cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -357,10 +357,27 @@
   }
 
   if (DumpConfig) {
+StringRef FileName;
+std::unique_ptr Code;
+if (FileNames.empty()) {
+  // We can't read the code to detect the language if there's no
+  // file name, so leave Code empty here.
+  FileName = AssumeFileName;
+} else {
+  // Read in the code in case the filename alone isn't enough to
+  // detect the language.
+  ErrorOr CodeOrErr =
+  MemoryBuffer::getFileOrSTDIN(FileNames[0]);
+  if (std::error_code EC = CodeOrErr.getError()) {
+llvm::errs() << EC.message() << "\n";
+return 1;
+  }
+  FileName = (FileNames[0] == "-") ? AssumeFileName : FileNames[0];
+  Code = std::move(CodeOrErr.get());
+}
 llvm::Expected FormatStyle =
-clang::format::getStyle(
-Style, FileNames.empty() ? AssumeFileName : FileNames[0],
-FallbackStyle);
+clang::format::getStyle(Style, FileName, FallbackStyle,
+Code ? Code->getBuffer() : "");
 if (!FormatStyle) {
   llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
   return 1;
Index: test/Format/lit.local.cfg
===
--- /dev/null
+++ test/Format/lit.local.cfg
@@ -0,0 +1,3 @@
+# Suffixes supported by clang-format.
+config.suffixes = ['.cpp', '.h', '.m', '.mm', '.java', '.js', '.ts', '.proto',
+   '.protodevel', '.pb.txt', '.textproto', '.asciipb', '.td']
Index: test/Format/dump-config-objc.h
===
--- /dev/null
+++ test/Format/dump-config-objc.h
@@ -0,0 +1,5 @@
+// RUN: clang-format -dump-config %s | FileCheck %s
+
+// CHECK: Language: ObjC
+@interface Foo
+@end
Index: test/Format/dump-config-cxx.h
===
--- /dev/null
+++ test/Format/dump-config-cxx.h
@@ -0,0 +1,3 @@
+// RUN: clang-format -dump-config %s | FileCheck %s
+
+// CHECK: Language: Cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -357,10 +357,27 @@
   }
 
   if (DumpConfig) {
+StringRef FileName;
+std::unique_ptr Code;
+if (FileNames.empty()) {
+  // We can't read the code to detect the language if there's no
+  // file name, so leave Code empty here.
+  FileName = AssumeFileName;
+} else {
+  // Read in the code in case the filename alone isn't enough to
+  // detect the language.
+  ErrorOr CodeOrErr =
+  MemoryBuffer::getFileOrSTDIN(FileNames[0]);
+  if (std::error_code EC = CodeOrErr.getError()) {
+llvm::errs() << EC.message() << "\n";
+return 1;
+  }
+  FileName = (FileNames[0] == "-") ? AssumeFileName : FileNames[0];
+  Code = std::move(CodeOrErr.get());
+}
 llvm::Expected FormatStyle =
-clang::format::getStyle(
-Style, FileNames.empty() ? AssumeFileName : FileNames[0],
-FallbackStyle);
+clang::format::getStyle(Style, FileName, FallbackStyle,
+Code ? Code->getBuffer() : "");
 if (!FormatStyle) {
   llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
   return 1;
Index: test/Format/lit.local.cfg
===
--- /dev/null
+++ test/Format/lit.local.cfg
@@ -0,0 +1,3 @@
+# Suffixes supported by clang-format.
+config.suffixes = ['.cpp', '.h', '.m', '.mm', '.java', '.js', '.ts', '.proto',
+   '.protodevel', '.pb.txt', '.textproto', '.asciipb', '.td']
Index: test/Format/dump-config-objc.h
===
--- /dev/null
+++ test/Format/dump-config-objc.h
@@ -0,0 +1,5 @@
+// RUN: clang-format -dump-config %s | FileCheck %s
+
+// CHECK: Language: ObjC
+@interface Foo
+@end
Index: test/Format/dump-config-cxx.h
===
--- /dev/null
+++ test/Format/dump-config-cxx.h
@@ -0,0 +1,3 @@
+// RUN: clang-format -dump-config %s | FileCheck %s
+
+// CHECK: Language: Cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r323159 - Last batch of P0202 constexpr additions: includes/set_intersection/exchange

2018-01-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 22 15:10:40 2018
New Revision: 323159

URL: http://llvm.org/viewvc/llvm-project?rev=323159=rev
Log:
Last batch of P0202 constexpr additions: includes/set_intersection/exchange

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/utility

libcxx/trunk/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
libcxx/trunk/test/std/utilities/utility/exchange/exchange.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=323159=323158=323159=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Jan 22 15:10:40 2018
@@ -412,7 +412,7 @@ template 
-bool  // constexpr in C++20
+constexpr bool// constexpr in C++20
 binary_search(ForwardIterator first, ForwardIterator last, const T& value, 
Compare comp);
 
 template 
@@ -434,11 +434,11 @@ template 
-bool
+constexpr bool// constexpr in C++20
 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 
first2, InputIterator2 last2);
 
 template 
-bool
+constexpr bool// constexpr in C++20
 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 
first2, InputIterator2 last2, Compare comp);
 
 template 
@@ -452,12 +452,12 @@ template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 set_intersection(InputIterator1 first1, InputIterator1 last1,
  InputIterator2 first2, InputIterator2 last2, 
OutputIterator result);
 
 template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 set_intersection(InputIterator1 first1, InputIterator1 last1,
  InputIterator2 first2, InputIterator2 last2, 
OutputIterator result, Compare comp);
 
@@ -5397,7 +5397,7 @@ nth_element(_RandomAccessIterator __firs
 // includes
 
 template 
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 
__first2, _InputIterator2 __last2,
_Compare __comp)
 {
@@ -5412,7 +5412,7 @@ __includes(_InputIterator1 __first1, _In
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 
__first2, _InputIterator2 __last2,
  _Compare __comp)
@@ -5428,7 +5428,7 @@ includes(_InputIterator1 __first1, _Inpu
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 
__first2, _InputIterator2 __last2)
 {
@@ -5494,7 +5494,7 @@ set_union(_InputIterator1 __first1, _Inp
 // set_intersection
 
 template 
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
 __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, 
_OutputIterator __result, _Compare __comp)
 {
@@ -5517,7 +5517,7 @@ __set_intersection(_InputIterator1 __fir
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
  _InputIterator2 __first2, _InputIterator2 __last2, 
_OutputIterator __result, _Compare __comp)
@@ -5533,7 +5533,7 @@ set_intersection(_InputIterator1 __first
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
  _InputIterator2 __first2, _InputIterator2 __last2, 
_OutputIterator __result)

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=323159=323158=323159=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Mon Jan 22 15:10:40 2018
@@ -890,7 +890,7 @@ template
 
 #if _LIBCPP_STD_VER > 11
 template
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _T1 exchange(_T1& __obj, _T2 && __new_value)
 {
 _T1 __old_value = _VSTD::move(__obj);

Modified: 

[PATCH] D42319: [CUDA] CUDA has no device-side library builtins.

2018-01-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D42319#983377, @jlebar wrote:

> How does this affect e.g. calling memcpy()?  There isn't a standard library 
> implementation of this on nvptx, but we do want calls to memcpy() to be 
> lowered to llvm.memcpy so that they can be optimized.


We implement memcpy as a call to __builtin_memcpy() which gets code-gen-ed as 
usual.  NVPTX also lowers all memcpy/memset/memmove as loads/stores, so those 
don't need external library. This behavior is not affected by this patch.

This patch's goal is to prevent clang codegen-ing its idea of the library 
builtin function while ignoring the implementation we've provided in the 
headers for device side.

Original issue I had was triggered by code roughly similar to this:

  extern "C" __device__ int logf(float a) { return __nv_logf(a); }
  __global__ void kernel() { logf(0.0f); }

In the AST, the kernel was calling the logf functions above However, when clang 
generated code, it considered that logf is a library builtin with known 
semantics and happily codegen'ed a call to @llvm.log.f32, which NVPTX back-end 
has no way to lower. The patch adds a safety net in clang so it does not 
generate code for builtins which we have disabled (or can't handle) in NVPTX.


https://reviews.llvm.org/D42319



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


[PATCH] D42396: [analyzer] Do not attempt to get the pointee of void* .

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 130967.
alexshap added a comment.

indents


Repository:
  rL LLVM

https://reviews.llvm.org/D42396

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/malloc.c


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void **ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,10 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if (const auto *S = Reg->getAsSymbol())
+if (S->getType().getCanonicalType()->isVoidPointerType())
+  continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void **ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,10 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if (const auto *S = Reg->getAsSymbol())
+if (S->getType().getCanonicalType()->isVoidPointerType())
+  continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42273: Add hasTrailingReturn AST matcher

2018-01-22 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC323158: Add hasTrailingReturn AST matcher (authored by 
juliehockett, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42273

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2749,6 +2749,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasTrailingReturn
+Matches a 
function declared with a trailing return type.
+
+Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+int X() {}
+auto Y() - int {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisConstexpr
 Matches constexpr 
variable and function declarations.
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5893,6 +5893,19 @@
   return Node.isScoped();
 }
 
+/// \brief Matches a function declared with a trailing return type.
+///
+/// Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+/// \code
+/// int X() {}
+/// auto Y() -> int {}
+/// \endcode
+AST_MATCHER(FunctionDecl, hasTrailingReturn) {
+  if (const auto *F = Node.getType()->getAs())
+return F->hasTrailingReturn();
+  return false;
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -296,6 +296,7 @@
   REGISTER_MATCHER(hasTemplateArgument);
   REGISTER_MATCHER(hasThen);
   REGISTER_MATCHER(hasThreadStorageDuration);
+  REGISTER_MATCHER(hasTrailingReturn);
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2112,5 +2112,24 @@
   EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
 }
 
+TEST(HasTrailingReturn, MatchesTrailingReturn) {
+  EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X() { return 0; }", 
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn(;
+}
+
+TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
+  EXPECT_TRUE(matches(
+  "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches(
+  "auto lambda2 = [](double x, double y) {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+}
+
 } // namespace ast_matchers
 } // namespace clang


Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2749,6 +2749,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasTrailingReturn
+Matches a function declared with a trailing return type.
+
+Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+int X() {}
+auto Y() - int {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisConstexpr
 Matches constexpr variable and function declarations.
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5893,6 +5893,19 @@
   return Node.isScoped();
 }
 
+/// \brief Matches a function declared with a trailing return type.
+///
+/// Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+/// \code
+/// int X() {}
+/// auto Y() -> int {}
+/// \endcode
+AST_MATCHER(FunctionDecl, hasTrailingReturn) {
+  if (const auto *F = Node.getType()->getAs())
+return F->hasTrailingReturn();
+  return false;
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -296,6 +296,7 @@
   

r323158 - Add hasTrailingReturn AST matcher

2018-01-22 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Mon Jan 22 14:45:23 2018
New Revision: 323158

URL: http://llvm.org/viewvc/llvm-project?rev=323158=rev
Log:
Add hasTrailingReturn AST matcher

Adds AST matcher for a FunctionDecl that has a trailing return type.

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=323158=323157=323158=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Jan 22 14:45:23 2018
@@ -2749,6 +2749,15 @@ Usable as: Matcherhttp://cl
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasTrailingReturn
+Matches a 
function declared with a trailing return type.
+
+Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+int X() {}
+auto Y() - int {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisConstexpr
 Matches constexpr 
variable and function declarations.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=323158=323157=323158=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jan 22 14:45:23 2018
@@ -5893,6 +5893,19 @@ AST_MATCHER(EnumDecl, isScoped) {
   return Node.isScoped();
 }
 
+/// \brief Matches a function declared with a trailing return type.
+///
+/// Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+/// \code
+/// int X() {}
+/// auto Y() -> int {}
+/// \endcode
+AST_MATCHER(FunctionDecl, hasTrailingReturn) {
+  if (const auto *F = Node.getType()->getAs())
+return F->hasTrailingReturn();
+  return false;
+}
+
 } // namespace ast_matchers
 } // namespace clang
 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=323158=323157=323158=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Jan 22 14:45:23 2018
@@ -296,6 +296,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasTemplateArgument);
   REGISTER_MATCHER(hasThen);
   REGISTER_MATCHER(hasThreadStorageDuration);
+  REGISTER_MATCHER(hasTrailingReturn);
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=323158=323157=323158=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Mon Jan 22 
14:45:23 2018
@@ -2112,5 +2112,24 @@ TEST(IsScopedEnum, MatchesScopedEnum) {
   EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
 }
 
+TEST(HasTrailingReturn, MatchesTrailingReturn) {
+  EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X() { return 0; }", 
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn(;
+}
+
+TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
+  EXPECT_TRUE(matches(
+  "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches(
+  "auto lambda2 = [](double x, double y) {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+}
+
 } // namespace ast_matchers
 } // namespace clang


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


[PATCH] D42396: [analyzer] Do not attempt to get the pointee of void* .

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap added reviewers: NoQ, dcoughlin.
Herald added subscribers: llvm-commits, a.sidorin, szepet, xazax.hun.

Do not attempt to get the pointee of void* while generating a bug report 
(otherwise it will trigger an assert inside RegionStoreManager::getBinding 
assert(!T->isVoidType() && "Attempting to dereference a void pointer!")).
(the call stack:

  (anonymous namespace)::RegionStoreManager::getBinding
  clang::ento::ProgramState::getSVal
  clang::ento::StackHintGeneratorForSymbol::getMessage
  clang::ento::PathDiagnosticEventPiece::getCallStackMessage 
  

)
Test plan: make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D42396

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/malloc.c


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void** ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,10 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if (const auto *S = Reg->getAsSymbol())
+if (S->getType().getCanonicalType()->isVoidPointerType())
+  continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {


Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1786,6 +1786,18 @@
   free(p);
 }
 
+void allocateSomeMemory(void *offendingParameter, void** ptr) {
+  *ptr = malloc(1);
+}
+
+void testNoCrashOnOffendingParameter() {
+  // "extern" is necessary to avoid unrelated warnings 
+  // on passing uninitialized value.
+  extern void *offendingParameter;
+  void* ptr;
+  allocateSomeMemory(offendingParameter, );
+} // expected-warning {{Potential leak of memory pointed to by 'ptr'}}
+
 // 
 // False negatives.
 
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1211,6 +1211,10 @@
 
 // Check if the parameter is a pointer to the symbol.
 if (Optional Reg = SV.getAs()) {
+  // Do not attempt to dereference void*.
+  if (const auto *S = Reg->getAsSymbol())
+if (S->getType().getCanonicalType()->isVoidPointerType())
+  continue;
   SVal PSV = N->getState()->getSVal(Reg->getRegion());
   SymbolRef AS = PSV.getAsLocSymbol();
   if (AS == Sym) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC323157: [ASTMatchers] [NFC] Fix code examples (authored by 
MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42213?vs=130922=130965#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h

Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -700,7 +700,7 @@
 Given
   switch(a) { case 42: break; default: break; }
 caseStmt()
-  matches 'case 42: break;'.
+  matches 'case 42:'.
 
 
 
@@ -741,7 +741,7 @@
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcompoundStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html;>CompoundStmt...
 Matches compound statements.
 
-Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+Example matches '{}' and '{{}}' in 'for (;;) {{}}'
   for (;;) {{}}
 
 
@@ -1028,7 +1028,7 @@
 Given
   switch(a) { case 42: break; default: break; }
 defaultStmt()
-  matches 'default: break;'.
+  matches 'default:'.
 
 
 
@@ -1197,9 +1197,9 @@
 materializeTemporaryExpr() matches 'f()' in these statements
   T u(f());
   g(f());
+  f().func();
 but does not match
   f();
-  f().func();
 
 
 
@@ -1369,7 +1369,7 @@
 Given
   switch(a) { case 42: break; default: break; }
 switchCase()
-  matches 'case 42: break;' and 'default: break;'.
+  matches 'case 42:' and 'default:'.
 
 
 
@@ -2940,11 +2940,11 @@
   void j(int i);
   void k(int x, int y, int z, ...);
 functionDecl(parameterCountIs(2))
-  matches void g(int i, int j) {}
+  matches g and h
 functionProtoType(parameterCountIs(2))
-  matches void h(int i, int j)
+  matches g and h
 functionProtoType(parameterCountIs(3))
-  matches void k(int x, int y, int z, ...);
+  matches k
 
 
 
@@ -2990,11 +2990,11 @@
   void j(int i);
   void k(int x, int y, int z, ...);
 functionDecl(parameterCountIs(2))
-  matches void g(int i, int j) {}
+  matches g and h
 functionProtoType(parameterCountIs(2))
-  matches void h(int i, int j)
+  matches g and h
 functionProtoType(parameterCountIs(3))
-  matches void k(int x, int y, int z, ...);
+  matches k
 
 
 
@@ -3534,7 +3534,7 @@
 representation of that integral value in base 10.
 
 Given
-  templateint T struct A {};
+  templateint T struct C {};
   C42 c;
 classTemplateSpecializationDecl(
   hasAnyTemplateArgument(equalsIntegralValue("42")))
@@ -3546,7 +3546,7 @@
 Matches a TemplateArgument that is an integral value.
 
 Given
-  templateint T struct A {};
+  templateint T struct C {};
   C42 c;
 classTemplateSpecializationDecl(
   hasAnyTemplateArgument(isIntegral()))
@@ -3973,10 +3973,11 @@
 Matches AST nodes that have descendant AST nodes that match the
 provided matcher.
 
-Example matches X, A, B, C
+Example matches X, A, A::X, B, B::C, B::C::X
   (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")
-  class X {};  Matches X, because X::X is a class of name X inside X.
-  class A { class X {}; };
+  class X {};
+  class A { class X {}; };  Matches A, because A::X is a class of name
+X inside A.
   class B { class C { class X {}; }; };
 
 DescendantT must be an AST base type.
@@ -3999,10 +4000,11 @@
 Matches AST nodes that have child AST nodes that match the
 provided matcher.
 
-Example matches X, Y
+Example matches X, Y, Y::X, Z::Y, Z::Y::X
   (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
-  class X {};  Matches X, because X::X is a class of name X inside X.
-  class Y { class X {}; };
+  class X {};
+  class Y { class X {}; };  Matches Y, because Y::X is a class of name X
+inside Y.
   class Z { class Y { class X {}; }; };  Does not match Z.
 
 ChildT must be an AST base type.
@@ -4479,7 +4481,7 @@
 Example matches y.x()
   (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))
   class Y { public: void x(); };
-  void z() { Y y; y.x(); }",
+  void z() { Y y; y.x(); }
 
 FIXME: Overload to allow directly matching types?
 
@@ -4795,7 +4797,7 @@
   Abool, int b;
   Aint, bool c;
 
-  templatetypename T f() {};
+  templatetypename T void f() {}
   void func() { fint(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
 1, refersToType(asString("int"
@@ -5312,7 +5314,7 @@
   Abool, int b;
   Aint, bool c;
 
-  templatetypename T f() {};
+  templatetypename T void f() {}
   void func() { fint(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
 1, refersToType(asString("int"
@@ -6000,8 +6002,8 @@
 Matches a sugar TemplateArgument that refers to a certain expression.
 
 Given
-  templatetypename T struct A {};
-  struct B { B* next; };
+  struct B { int next; };
+  templateint(B::*next_ptr) struct A {};
   AB::next a;
 templateSpecializationType(hasAnyTemplateArgument(
   

[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

2018-01-22 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC323156: Reland [CodeGen] Fix crash when a function 
taking transparent union is… (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41311?vs=130038=130964#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41311

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/kr-func-promote.c
  test/CodeGen/transparent-union-redecl.c
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/Sema/transparent-union.c

Index: test/CodeGen/transparent-union-redecl.c
===
--- test/CodeGen/transparent-union-redecl.c
+++ test/CodeGen/transparent-union-redecl.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+
+// Test that different order of declarations is acceptable and that
+// implementing different redeclarations is acceptable.
+// rdar://problem/34949329
+
+typedef union {
+  int i;
+  float f;
+} TU __attribute__((transparent_union));
+
+// CHECK-LABEL: define void @f0(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
+// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
+void f0(TU tu) {}
+void f0(int i);
+
+// CHECK-LABEL: define void @f1(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
+// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
+void f1(int i);
+void f1(TU tu) {}
+
+// CHECK-LABEL: define void @f2(i32 %i)
+// CHECK: %i.addr = alloca i32, align 4
+// CHECK: store i32 %i, i32* %i.addr, align 4
+void f2(TU tu);
+void f2(int i) {}
+
+// CHECK-LABEL: define void @f3(i32 %i)
+// CHECK: %i.addr = alloca i32, align 4
+// CHECK: store i32 %i, i32* %i.addr, align 4
+void f3(int i) {}
+void f3(TU tu);
+
+// Also test functions with parameters specified K style.
+// CHECK-LABEL: define void @knrStyle(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 0, i32 0
+// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
+void knrStyle(int i);
+void knrStyle(tu) TU tu; {}
Index: test/CodeGen/kr-func-promote.c
===
--- test/CodeGen/kr-func-promote.c
+++ test/CodeGen/kr-func-promote.c
@@ -1,6 +1,12 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
-// CHECK: i32 @a(i32)
 
+// CHECK: i32 @a(i32
 int a();
 int a(x) short x; {return x;}
 
+// CHECK: void @b(double
+// CHECK: %[[ADDR:.*]] = alloca float, align 4
+// CHECK: %[[TRUNC:.*]] = fptrunc double %0 to float
+// CHECK: store float %[[TRUNC]], float* %[[ADDR]], align 4
+void b();
+void b(f) float f; {}
Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -25,6 +25,7 @@
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPM@A@AEXXZ"
 // Note that the vtordisp is applied before really adjusting to D*.
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -36,6 +37,7 @@
 // CHECK: ret void
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPI@3AEXXZ"
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -64,7 +66,8 @@
 
 G::G() {}  // Forces vftable emission.
 
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*)
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.E* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
Index: test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
+++ 

r323156 - Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."

2018-01-22 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Mon Jan 22 14:29:24 2018
New Revision: 323156

URL: http://llvm.org/viewvc/llvm-project?rev=323156=rev
Log:
Reland "[CodeGen] Fix crash when a function taking transparent union is 
redeclared."

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

Now the fix is in converting from ABIArgInfo type to VarDecl type and using
argument demotion when necessary.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak

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

Added:
cfe/trunk/test/CodeGen/transparent-union-redecl.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/kr-func-promote.c
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=323156=323155=323156=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jan 22 14:29:24 2018
@@ -2251,11 +2251,16 @@ void CodeGenFunction::EmitFunctionProlog
   for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
i != e; ++i, ++info_it, ++ArgNo) {
 const VarDecl *Arg = *i;
-QualType Ty = info_it->type;
 const ABIArgInfo  = info_it->info;
 
 bool isPromoted =
   isa(Arg) && cast(Arg)->isKNRPromoted();
+// We are converting from ABIArgInfo type to VarDecl type directly, unless
+// the parameter is promoted. In this case we convert to
+// CGFunctionInfo::ArgInfo type with subsequent argument demotion.
+QualType Ty = isPromoted ? info_it->type : Arg->getType();
+assert(hasScalarEvaluationKind(Ty) ==
+   hasScalarEvaluationKind(Arg->getType()));
 
 unsigned FirstIRArg, NumIRArgs;
 std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);

Modified: cfe/trunk/test/CodeGen/kr-func-promote.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/kr-func-promote.c?rev=323156=323155=323156=diff
==
--- cfe/trunk/test/CodeGen/kr-func-promote.c (original)
+++ cfe/trunk/test/CodeGen/kr-func-promote.c Mon Jan 22 14:29:24 2018
@@ -1,6 +1,12 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck 
%s
-// CHECK: i32 @a(i32)
 
+// CHECK: i32 @a(i32
 int a();
 int a(x) short x; {return x;}
 
+// CHECK: void @b(double
+// CHECK: %[[ADDR:.*]] = alloca float, align 4
+// CHECK: %[[TRUNC:.*]] = fptrunc double %0 to float
+// CHECK: store float %[[TRUNC]], float* %[[ADDR]], align 4
+void b();
+void b(f) float f; {}

Added: cfe/trunk/test/CodeGen/transparent-union-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union-redecl.c?rev=323156=auto
==
--- cfe/trunk/test/CodeGen/transparent-union-redecl.c (added)
+++ cfe/trunk/test/CodeGen/transparent-union-redecl.c Mon Jan 22 14:29:24 2018
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+
+// Test that different order of declarations is acceptable and that
+// implementing different redeclarations is acceptable.
+// rdar://problem/34949329
+
+typedef union {
+  int i;
+  float f;
+} TU __attribute__((transparent_union));
+
+// CHECK-LABEL: define void @f0(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
+// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
+void f0(TU tu) {}
+void f0(int i);
+
+// CHECK-LABEL: define void @f1(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
+// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
+void f1(int i);
+void f1(TU tu) {}
+
+// CHECK-LABEL: define void @f2(i32 %i)
+// CHECK: %i.addr = alloca i32, align 4
+// CHECK: store i32 %i, i32* 

[PATCH] D42335: [ASTImporter] Supporting CXXOperatorCallExpr, SizeOfPackExpr, DependentTemplateSpecializationType, DependentSizedArray importing.

2018-01-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D42335#983878, @a.sidorin wrote:

> Hello Peter,
>
> Thank you for the patch! It is almost LGTM, just a few minor questions inline.
>  Am I understand correctly that it is partially based on 
> https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp?
>  Also, FYI: you can use ASTMerge and clang-import-test facilities for 
> testing. ASTMatchers  are completely fine, but usage of imported AST samples 
> as Sema lookup source can uncover some subtle issues in the built AST.


Yeah that is right. One reason I prefer matcher based tests because they tend 
to be more lightweight, but I think you are right, it is not a bad idea to 
utilize other tools as well.


https://reviews.llvm.org/D42335



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


[PATCH] D42335: [ASTImporter] Supporting CXXOperatorCallExpr, SizeOfPackExpr, DependentTemplateSpecializationType, DependentSizedArray importing.

2018-01-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 130961.
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

- Address review comments.


https://reviews.llvm.org/D42335

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

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -480,6 +480,16 @@
  vaArgExpr(;
 }
 
+TEST(ImportExpr, CXXTemporaryObjectExpr) {
+  MatchVerifier Verifier;
+  testImport("struct C {};"
+ "void declToImport() { C c = C(); }",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(hasBody(compoundStmt(has(
+ declStmt(has(varDecl(has(exprWithCleanups(has(cxxConstructExpr(
+ has(materializeTemporaryExpr(has(implicitCastExpr(
+ has(cxxTemporaryObjectExpr());
+}
 
 TEST(ImportType, ImportAtomicType) {
   MatchVerifier Verifier;
@@ -564,6 +574,50 @@
  declRefExpr());
 }
 
+const internal::VariadicDynCastAllOfMatcher
+dependentTemplateSpecializationType;
+
+TEST(ImportType, ImportDependentTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template"
+ "struct A;"
+ "template"
+ "struct declToImport {"
+ "  typename A::template B a;"
+ "};",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(has(
+ fieldDecl(hasType(dependentTemplateSpecializationType(;
+}
+
+const internal::VariadicDynCastAllOfMatcher
+sizeOfPackExpr;
+
+TEST(ImportExpr, ImportSizeOfPackExpr) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "void declToImport() {"
+ "  const int i = sizeof...(Ts);"
+ "};"
+ "void g() { declToImport(); }",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ functionTemplateDecl(has(functionDecl(
+ hasBody(compoundStmt(has(declStmt(has(varDecl(hasInitializer(
+ implicitCastExpr(has(sizeOfPackExpr());
+  testImport(
+  "template "
+  "using X = int[sizeof...(Ts)];"
+  "template "
+  "struct Y {"
+  "  X f;"
+  "};"
+  "Y declToImport;",
+  Lang_CXX11, "", Lang_CXX11, Verifier,
+  varDecl(hasType(classTemplateSpecializationDecl(has(fieldDecl(hasType(
+  hasUnqualifiedDesugaredType(constantArrayType(hasSize(7));
+}
+
 /// \brief Matches __builtin_types_compatible_p:
 /// GNU extension to check equivalent types
 /// Given
@@ -691,5 +745,25 @@
  binaryOperator(has(cxxUnresolvedConstructExpr());
 }
 
+TEST(ImportExpr, CXXOperatorCallExpr) {
+  MatchVerifier Verifier;
+  testImport("class declToImport {"
+ "  void f() { *this = declToImport(); }"
+ "};",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ cxxRecordDecl(has(cxxMethodDecl(hasBody(compoundStmt(
+ has(exprWithCleanups(has(cxxOperatorCallExpr());
+}
+
+TEST(ImportExpr, DependentSizedArrayType) {
+  MatchVerifier Verifier;
+  testImport("template class declToImport {"
+ "  T data[Size];"
+ "};",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(fieldDecl(hasType(dependentSizedArrayType(;
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -52,7 +52,7 @@
 QualType VisitConstantArrayType(const ConstantArrayType *T);
 QualType VisitIncompleteArrayType(const IncompleteArrayType *T);
 QualType VisitVariableArrayType(const VariableArrayType *T);
-// FIXME: DependentSizedArrayType
+QualType VisitDependentSizedArrayType(const DependentSizedArrayType *T);
 // FIXME: DependentSizedExtVectorType
 QualType VisitVectorType(const VectorType *T);
 QualType VisitExtVectorType(const ExtVectorType *T);
@@ -78,7 +78,8 @@
 QualType VisitElaboratedType(const ElaboratedType *T);
 // FIXME: DependentNameType
 QualType VisitPackExpansionType(const PackExpansionType *T);
-// FIXME: DependentTemplateSpecializationType
+QualType VisitDependentTemplateSpecializationType(
+const DependentTemplateSpecializationType *T);
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 QualType VisitObjCObjectType(const ObjCObjectType *T);
 QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
@@ -282,6 +283,7 @@
 Expr 

r323155 - Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injec

2018-01-22 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Mon Jan 22 14:05:25 2018
New Revision: 323155

URL: http://llvm.org/viewvc/llvm-project?rev=323155=rev
Log:
Introduce the "retpoline" x86 mitigation technique for variant #2 of the 
speculative execution vulnerabilities disclosed today, specifically identified 
by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to 
Spectre..

Summary:
First, we need to explain the core of the vulnerability. Note that this
is a very incomplete description, please see the Project Zero blog post
for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative execution
of the processor to some "gadget" of executable code by poisoning the
prediction of indirect branches with the address of that gadget. The
gadget in turn contains an operation that provides a side channel for
reading data. Most commonly, this will look like a load of secret data
followed by a branch on the loaded value and then a load of some
predictable cache line. The attacker then uses timing of the processors
cache to determine which direction the branch took *in the speculative
execution*, and in turn what one bit of the loaded value was. Due to the
nature of these timing side channels and the branch predictor on Intel
processors, this allows an attacker to leak data only accessible to
a privileged domain (like the kernel) back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In many
cases, the compiler can simply use directed conditional branches and
a small search tree. LLVM already has support for lowering switches in
this way and the first step of this patch is to disable jump-table
lowering of switches and introduce a pass to rewrite explicit indirectbr
sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as
a trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures the
processor predicts the return to go to a controlled, known location. The
retpoline then "smashes" the return address pushed onto the stack by the
call with the desired target of the original indirect call. The result
is a predicted return to the next instruction after a call (which can be
used to trap speculative execution within an infinite loop) and an
actual indirect branch to an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this device.
For 32-bit ABIs there isn't a guaranteed scratch register and so several
different retpoline variants are introduced to use a scratch register if
one is available in the calling convention and to otherwise use direct
stack push/pop sequences to pass the target address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the retpoline
thunk by the compiler to allow for custom thunks if users want them.
These are particularly useful in environments like kernels that
routinely do hot-patching on boot and want to hot-patch their thunk to
different code sequences. They can write this custom thunk and use
`-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
case, on x86-64 thu thunk names must be:
```
  __llvm_external_retpoline_r11
```
or on 32-bit:
```
  __llvm_external_retpoline_eax
  __llvm_external_retpoline_ecx
  __llvm_external_retpoline_edx
  __llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are from
precompiled runtimes (such as crt0.o and similar). The ones we have
found are not really attackable, and so we have not focused on them
here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z retpolineplt`
(or use similar functionality from some other linker). We strongly
recommend also using `-z now` as non-lazy binding 

[libcxx] r323152 - Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy

2018-01-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 22 13:43:04 2018
New Revision: 323152

URL: http://llvm.org/viewvc/llvm-project?rev=323152=rev
Log:
Another batch of P0202 constepr algirithms. 
remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented 
out) for rotate_copy, because that depends on std::copy

Modified:
libcxx/trunk/include/algorithm

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=323152=323151=323152=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Jan 22 13:43:04 2018
@@ -236,19 +236,19 @@ template 
-ForwardIterator
+constexpr ForwardIterator // constexpr in C++20
 remove(ForwardIterator first, ForwardIterator last, const T& value);
 
 template 
-ForwardIterator
+constexpr ForwardIterator // constexpr in C++20
 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
 
 template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 remove_copy(InputIterator first, InputIterator last, OutputIterator 
result, const T& value);
 
 template 
-OutputIterator
+constexpr OutputIterator // constexpr in C++20
 remove_copy_if(InputIterator first, InputIterator last, OutputIterator 
result, Predicate pred);
 
 template 
@@ -272,7 +272,7 @@ template 
 reverse(BidirectionalIterator first, BidirectionalIterator last);
 
 template 
-OutputIterator
+constexpr OutputIterator   // constexpr in C++20
 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, 
OutputIterator result);
 
 template 
@@ -2098,7 +2098,7 @@ generate_n(_OutputIterator __first, _Siz
 // remove
 
 template 
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
 {
 __first = _VSTD::find(__first, __last, __value_);
@@ -2120,7 +2120,7 @@ remove(_ForwardIterator __first, _Forwar
 // remove_if
 
 template 
-_ForwardIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
 remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
 {
 __first = _VSTD::find_if<_ForwardIterator, typename 
add_lvalue_reference<_Predicate>::type>
@@ -2143,7 +2143,7 @@ remove_if(_ForwardIterator __first, _For
 // remove_copy
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator 
__result, const _Tp& __value_)
 {
@@ -2161,7 +2161,7 @@ remove_copy(_InputIterator __first, _Inp
 // remove_copy_if
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator 
__result, _Predicate __pred)
 {
@@ -2327,7 +2327,7 @@ reverse(_BidirectionalIterator __first,
 // reverse_copy
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator
 reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, 
_OutputIterator __result)
 {

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp?rev=323152=323151=323152=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
 Mon Jan 22 13:43:04 2018
@@ -12,7 +12,7 @@
 // template
 //   requires OutputIterator
 // && HasEqualTo
-//   Iter
+//   constexpr Iter // constexpr after C++17
 //   remove(Iter first, Iter last, const T& value);
 
 #include 
@@ -22,6 +22,18 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+int ia[] = {1, 3, 5, 2, 5, 6};
+
+auto it = std::remove(std::begin(ia), std::end(ia), 5);
+
+return (std::begin(ia) + std::size(ia) - 2) == it 

[PATCH] D40854: [clang-tidy] WIP implement cppcoreguidelines check for mixed integer arithmetic

2018-01-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

The guideline authors will focus on mixing integer length and integer signdness.

> Thank you for the suggestion! Per our editor's discussion, we agree with "If 
> one then mixes integer lengths and signedness in calculations confusion on 
> what happens might occur" and would like to focus the discussion there.
>  signed and unsigned are defined in the standard and we cannot quibble with 
> those but we can discuss mixed arithmetic. We should consider this separately.
> 
> Bjarne will add some text to this item.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40854



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


[clang-tools-extra] r323149 - [clangd] Drop ~destructor completions - rarely helpful and work inconsistently

2018-01-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jan 22 13:05:00 2018
New Revision: 323149

URL: http://llvm.org/viewvc/llvm-project?rev=323149=rev
Log:
[clangd] Drop ~destructor completions - rarely helpful and work inconsistently

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=323149=323148=323149=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon Jan 22 13:05:00 2018
@@ -361,6 +361,10 @@ struct CompletionRecorder : public CodeC
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  // Destructor completion is rarely useful, and works inconsistently.
+  // (s.^ completes ~string, but s.~st^ is an error).
+  if (dyn_cast_or_null(Result.Declaration))
+continue;
   Results.push_back(Result);
 }
   }

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=323149=323148=323149=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Mon Jan 22 
13:05:00 2018
@@ -461,7 +461,7 @@ TEST(CompletionTest, NoDuplicates) {
   {cls("Adapter")});
 
   // Make sure there are no duplicate entries of 'Adapter'.
-  EXPECT_THAT(Results.items, ElementsAre(Named("Adapter"), Named("~Adapter")));
+  EXPECT_THAT(Results.items, ElementsAre(Named("Adapter")));
 }
 
 TEST(CompletionTest, ScopedNoIndex) {


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


r323148 - [CodeComplete] Omit templated constructors from member list too.

2018-01-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jan 22 12:44:47 2018
New Revision: 323148

URL: http://llvm.org/viewvc/llvm-project?rev=323148=rev
Log:
[CodeComplete] Omit templated constructors from member list too.

Also avoid printing a 'void' return type for constructor expressions.

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp
cfe/trunk/test/Index/complete-exprs.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=323148=323147=323148=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Jan 22 12:44:47 2018
@@ -843,6 +843,12 @@ void ResultBuilder::MaybeAddConstructorR
   }
 }
 
+static bool isConstructor(const Decl *ND) {
+  if (const auto *Tmpl = dyn_cast(ND))
+ND = Tmpl->getTemplatedDecl();
+  return isa(ND);
+}
+
 void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
   assert(!ShadowMaps.empty() && "Must enter into a results scope");
   
@@ -870,7 +876,7 @@ void ResultBuilder::MaybeAddResult(Resul
 return;
   
   // C++ constructors are never found by name lookup.
-  if (isa(R.Declaration))
+  if (isConstructor(R.Declaration))
 return;
 
   ShadowMap  = ShadowMaps.back();
@@ -983,7 +989,7 @@ void ResultBuilder::AddResult(Result R,
 return;
   
   // C++ constructors are never found by name lookup.
-  if (isa(R.Declaration))
+  if (isConstructor(R.Declaration))
 return;
 
   if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
@@ -2145,7 +2151,7 @@ static void AddResultTypeChunk(ASTContex
 
   // Skip constructors and conversion functions, which have their return types
   // built into their names.
-  if (isa(ND) || isa(ND))
+  if (isConstructor(ND) || isa(ND))
 return;
 
   // Determine the type of the declaration (if it has a type).

Modified: cfe/trunk/test/CodeCompletion/member-access.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=323148=323147=323148=diff
==
--- cfe/trunk/test/CodeCompletion/member-access.cpp (original)
+++ cfe/trunk/test/CodeCompletion/member-access.cpp Mon Jan 22 12:44:47 2018
@@ -16,6 +16,8 @@ struct Base3 : Base1, Base2 {
 };
 
 struct Derived : Base3 {
+  template  Derived(T);
+  Derived(int);
   int member4;
   int memfun3(int);
 };
@@ -48,7 +50,7 @@ struct Bar {
   }
 };
 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:31:6 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 --implicit-check-not="Derived : Derived(" %s
   // CHECK-CC1: Base1 : Base1::
   // CHECK-CC1: member1 : [#int#][#Base1::#]member1
   // CHECK-CC1: member1 : [#int#][#Base2::#]member1
@@ -62,10 +64,10 @@ struct Bar {
   // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>)
 
 // Make sure this doesn't crash
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:7 %s -verify
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:38:7 %s -verify
 
 // Make sure this also doesn't crash
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:47:14 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:49:14 %s
 
 
 template
@@ -100,8 +102,8 @@ void completeDependentMembers(TemplateCl
 // CHECK-CC2: overload1 : [#void#]overload1(<#const T 

[libcxx] r323147 - Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare

2018-01-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 22 12:44:33 2018
New Revision: 323147

URL: http://llvm.org/viewvc/llvm-project?rev=323147=rev
Log:
Still more P0202 constexpr-ifying. This batch is: 
for_each/for_each_n/lexicographical_compare

Modified:
libcxx/trunk/include/algorithm

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/for_each_n.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=323147=323146=323147=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Jan 22 12:44:33 2018
@@ -32,11 +32,12 @@ template 
-Function
+constexpr Function  // constexpr in C++20
 for_each(InputIterator first, InputIterator last, Function f);
 
 template
-InputIterator for_each_n(InputIterator first, Size n, Function f); // C++17
+constexpr InputIterator // constexpr in C++20
+for_each_n(InputIterator first, Size n, Function f); // C++17
 
 template 
 constexpr InputIterator // constexpr in C++20
@@ -311,7 +312,7 @@ template 
-pair
+constexpr pair   // constexpr in C++20
 partition_copy(InputIterator first, InputIterator last,
OutputIterator1 out_true, OutputIterator2 out_false,
Predicate pred);
@@ -607,11 +608,11 @@ template
 minmax(initializer_list t, Compare comp);  // constexpr in C++14
 
 template 
-bool
+constexpr bool // constexpr in C++20
 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, 
InputIterator2 first2, InputIterator2 last2);
 
 template 
-bool
+constexpr bool // constexpr in C++20
 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
 InputIterator2 first2, InputIterator2 last2, 
Compare comp);
 
@@ -958,7 +959,7 @@ none_of(_InputIterator __first, _InputIt
 // for_each
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _Function
 for_each(_InputIterator __first, _InputIterator __last, _Function __f)
 {
@@ -971,7 +972,7 @@ for_each(_InputIterator __first, _InputI
 // for_each_n
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _InputIterator
 for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
 {
@@ -3288,7 +3289,7 @@ partition(_ForwardIterator __first, _For
 
 template 
-pair<_OutputIterator1, _OutputIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
 partition_copy(_InputIterator __first, _InputIterator __last,
_OutputIterator1 __out_true, _OutputIterator2 __out_false,
_Predicate __pred)
@@ -5658,7 +5659,7 @@ set_symmetric_difference(_InputIterator1
 // lexicographical_compare
 
 template 
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
   _InputIterator2 __first2, _InputIterator2 __last2, 
_Compare __comp)
 {
@@ -5673,7 +5674,7 @@ __lexicographical_compare(_InputIterator
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
 _InputIterator2 __first2, _InputIterator2 __last2, 
_Compare __comp)
@@ -5689,7 +5690,7 @@ lexicographical_compare(_InputIterator1
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
 _InputIterator2 __first2, _InputIterator2 __last2)

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp?rev=323147=323146=323147=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
 Mon Jan 22 12:44:33 2018
@@ -11,7 +11,7 @@
 
 // template 
-// pair
+// constexpr 

[PATCH] D42388: [analyzer] Protect against dereferencing a null pointer

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323146: [analyzer] Protect against dereferencing a null 
pointer (authored by alexshap, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42388?vs=130935=130946#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42388

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1185,6 +1185,9 @@
 StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+  if (!N)
+return getMessageForSymbolNotFound();
+
   ProgramPoint P = N->getLocation();
   CallExitEnd CExit = P.castAs();
 
@@ -1194,9 +1197,6 @@
   if (!CE)
 return "";
 
-  if (!N)
-return getMessageForSymbolNotFound();
-
   // Check if one of the parameters are set to the interesting symbol.
   unsigned ArgIndex = 0;
   for (CallExpr::const_arg_iterator I = CE->arg_begin(),


Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1185,6 +1185,9 @@
 StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+  if (!N)
+return getMessageForSymbolNotFound();
+
   ProgramPoint P = N->getLocation();
   CallExitEnd CExit = P.castAs();
 
@@ -1194,9 +1197,6 @@
   if (!CE)
 return "";
 
-  if (!N)
-return getMessageForSymbolNotFound();
-
   // Check if one of the parameters are set to the interesting symbol.
   unsigned ArgIndex = 0;
   for (CallExpr::const_arg_iterator I = CE->arg_begin(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r323146 - [analyzer] Protect against dereferencing a null pointer

2018-01-22 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Jan 22 12:18:42 2018
New Revision: 323146

URL: http://llvm.org/viewvc/llvm-project?rev=323146=rev
Log:
[analyzer] Protect against dereferencing a null pointer

The check (inside StackHintGeneratorForSymbol::getMessage)
if (!N)
return getMessageForSymbolNotFound()
is moved to the beginning of the function.

Differential revision: https://reviews.llvm.org/D42388

Test plan: make check-all

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=323146=323145=323146=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Mon Jan 22 12:18:42 
2018
@@ -1185,6 +1185,9 @@ void PathDiagnostic::FullProfile(llvm::F
 StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+  if (!N)
+return getMessageForSymbolNotFound();
+
   ProgramPoint P = N->getLocation();
   CallExitEnd CExit = P.castAs();
 
@@ -1194,9 +1197,6 @@ std::string StackHintGeneratorForSymbol:
   if (!CE)
 return "";
 
-  if (!N)
-return getMessageForSymbolNotFound();
-
   // Check if one of the parameters are set to the interesting symbol.
   unsigned ArgIndex = 0;
   for (CallExpr::const_arg_iterator I = CE->arg_begin(),


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


[PATCH] D40787: [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions

2018-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp:45
+
+  if ((C = Result.Nodes.getNodeAs("call_expr"))) {
+BeginLoc = C->getLocStart();

Can remove spurious parens.



Comment at: docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst:7
+This check will warn on calls to ``std::uncaught_exception`` and replace them 
with
+calls to ``std::uncaught_exceptions``, since std::uncaught_exception was 
deprecated
+in C++17.

Backtick the use of `std::uncaught_exception`.



Comment at: docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst:65
+}
\ No newline at end of file


Please add the newline to the end of the file.



Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:43
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: 'std::uncaught_exception' is 
deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = std::uncaught_exceptions() > 0;
+

This is not ideal (the implicit conversion here would do the correct thing).



Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:45
+
+  using std::uncaught_exception;
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: 'std::uncaught_exception' is 
deprecated, use 'std::uncaught_exceptions' instead

I'd like to see this, and the other examples that require it, moved into its 
own function body (to segregate it from cases we don't want to see the 
diagnostics).



Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:64
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is 
deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: foo = _exceptions;
+

Applying this fix will break the code so that it no longer compiles.



Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:68
+  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: 'std::uncaught_exception' is 
deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = doSomething2();
+

This fix seems bad. If the user accepts the fix, then the code will diagnose 
because there's no longer a matching call to `doSomething2()`.


https://reviews.llvm.org/D40787



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


[PATCH] D42273: Add hasTrailingReturn AST matcher

2018-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


https://reviews.llvm.org/D42273



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


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you! Do you need me to commit on your behalf?


Repository:
  rC Clang

https://reviews.llvm.org/D42213



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


[PATCH] D42388: [analyzer] Protect against dereferencing a null pointer

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

no, i have not seen any crashes related to this particular case, but i've been 
working on a fix for a separate issue (a bit more involved) (not far from here) 
(I will send a diff for review soon) 
and decided to clean it up as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D42388



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


[PATCH] D41623: [cmake] [libcxxabi] Fix find_path() problems when cross compiling

2018-01-22 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323145: [cmake] [libcxxabi] Fix find_path() problems when 
cross compiling (authored by dhinton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41623

Files:
  libcxxabi/trunk/CMakeLists.txt


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -115,6 +115,7 @@
 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
 ${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
 ${LLVM_INCLUDE_DIR}/c++/v1
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
@@ -127,6 +128,7 @@
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LIBCXXABI_LIBCXX_SRC_DIRS}
   NO_DEFAULT_PATH
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
@@ -425,6 +427,7 @@
   ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
   ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
 
   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -115,6 +115,7 @@
 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
 ${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
 ${LLVM_INCLUDE_DIR}/c++/v1
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
@@ -127,6 +128,7 @@
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LIBCXXABI_LIBCXX_SRC_DIRS}
   NO_DEFAULT_PATH
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
@@ -425,6 +427,7 @@
   ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
   ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
 
   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r323145 - [cmake] [libcxxabi] Fix find_path() problems when cross compiling

2018-01-22 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Jan 22 11:41:05 2018
New Revision: 323145

URL: http://llvm.org/viewvc/llvm-project?rev=323145=rev
Log:
[cmake] [libcxxabi] Fix find_path() problems when cross compiling

When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, these find_path() invocations are looking for paths in
the libcxx and libunwind projects on the host system, not the
target system, which can be done by passing
NO_CMAKE_FIND_ROOT_PATH.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=323145=323144=323145=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Jan 22 11:41:05 2018
@@ -115,6 +115,7 @@ find_path(
 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
 ${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
 ${LLVM_INCLUDE_DIR}/c++/v1
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
@@ -127,6 +128,7 @@ find_path(
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LIBCXXABI_LIBCXX_SRC_DIRS}
   NO_DEFAULT_PATH
+  NO_CMAKE_FIND_ROOT_PATH
   )
 
 if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
@@ -425,6 +427,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
   ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
   ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
 
   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")


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


[PATCH] D42388: [analyzer] Protect against dereferencing a null pointer

2018-01-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a reviewer: george.karpenkov.
NoQ added a comment.
This revision is now accepted and ready to land.

Neat. I wonder if you've actually found it by running the analyzer :) Did it 
crash or just made sense to fix, i.e. should there be tests?


Repository:
  rL LLVM

https://reviews.llvm.org/D42388



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


[PATCH] D42388: [analyzer] Protect against dereferencing a null pointer

2018-01-22 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap added reviewers: NoQ, dcoughlin.
Herald added subscribers: llvm-commits, a.sidorin, szepet, xazax.hun.

The check (inside StackHintGeneratorForSymbol::getMessage)

  if (!N)
  return getMessageForSymbolNotFound()

is moved to the beginning of the function.


Repository:
  rL LLVM

https://reviews.llvm.org/D42388

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp


Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1185,6 +1185,9 @@
 StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+  if (!N)
+return getMessageForSymbolNotFound();
+
   ProgramPoint P = N->getLocation();
   CallExitEnd CExit = P.castAs();
 
@@ -1194,9 +1197,6 @@
   if (!CE)
 return "";
 
-  if (!N)
-return getMessageForSymbolNotFound();
-
   // Check if one of the parameters are set to the interesting symbol.
   unsigned ArgIndex = 0;
   for (CallExpr::const_arg_iterator I = CE->arg_begin(),


Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -1185,6 +1185,9 @@
 StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
+  if (!N)
+return getMessageForSymbolNotFound();
+
   ProgramPoint P = N->getLocation();
   CallExitEnd CExit = P.castAs();
 
@@ -1194,9 +1197,6 @@
   if (!CE)
 return "";
 
-  if (!N)
-return getMessageForSymbolNotFound();
-
   // Check if one of the parameters are set to the interesting symbol.
   unsigned ArgIndex = 0;
   for (CallExpr::const_arg_iterator I = CE->arg_begin(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41622: [cmake] [libcxx] Fix find_path() problems when cross compiling.

2018-01-22 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323143: [cmake] [libcxx] Fix find_path() problems when cross 
compiling. (authored by dhinton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41622

Files:
  libcxx/trunk/CMakeLists.txt


Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -123,6 +123,7 @@
   ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
   ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
   if (LIBCXX_TARGETING_MSVC)
 # FIXME: Figure out how to configure the ABI library on Windows.


Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -123,6 +123,7 @@
   ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
   ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
   if (LIBCXX_TARGETING_MSVC)
 # FIXME: Figure out how to configure the ABI library on Windows.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r323143 - [cmake] [libcxx] Fix find_path() problems when cross compiling.

2018-01-22 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Jan 22 11:26:38 2018
New Revision: 323143

URL: http://llvm.org/viewvc/llvm-project?rev=323143=rev
Log:
[cmake] [libcxx] Fix find_path() problems when cross compiling.

When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, this find_path() invocation is looking for a path in the
libcxxabi project on the host system, not the target system,
which can be done by passing NO_CMAKE_FIND_ROOT_PATH.

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

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=323143=323142=323143=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan 22 11:26:38 2018
@@ -123,6 +123,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
   ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
   ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
 NO_DEFAULT_PATH
+NO_CMAKE_FIND_ROOT_PATH
   )
   if (LIBCXX_TARGETING_MSVC)
 # FIXME: Figure out how to configure the ABI library on Windows.


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


[PATCH] D41621: [cmake] [libunwind] Fix find_path() problems when cross compiling

2018-01-22 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323141: [cmake] [libunwind] Fix find_path() problems when 
cross compiling (authored by dhinton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41621

Files:
  libunwind/trunk/CMakeLists.txt


Index: libunwind/trunk/CMakeLists.txt
===
--- libunwind/trunk/CMakeLists.txt
+++ libunwind/trunk/CMakeLists.txt
@@ -329,7 +329,8 @@
   PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
 ${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
   NO_DEFAULT_PATH
-)
+  NO_CMAKE_FIND_ROOT_PATH
+  )
 if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
 IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
   set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")


Index: libunwind/trunk/CMakeLists.txt
===
--- libunwind/trunk/CMakeLists.txt
+++ libunwind/trunk/CMakeLists.txt
@@ -329,7 +329,8 @@
   PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
 ${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
   NO_DEFAULT_PATH
-)
+  NO_CMAKE_FIND_ROOT_PATH
+  )
 if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
 IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
   set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r323141 - [cmake] [libunwind] Fix find_path() problems when cross compiling

2018-01-22 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Mon Jan 22 11:15:06 2018
New Revision: 323141

URL: http://llvm.org/viewvc/llvm-project?rev=323141=rev
Log:
[cmake] [libunwind] Fix find_path() problems when cross compiling

When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, this find_path() invocation is looking for a path in the
libcxx project on the host system, not the target system,
which can be done by passing NO_CMAKE_FIND_ROOT_PATH.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=323141=323140=323141=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Jan 22 11:15:06 2018
@@ -329,7 +329,8 @@ find_path(
   PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
 ${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
   NO_DEFAULT_PATH
-)
+  NO_CMAKE_FIND_ROOT_PATH
+  )
 if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
 IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
   set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")


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


[PATCH] D41885: [libcxxabi][demangler] Improve handling of variadic templates

2018-01-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Thanks for working on this!




Comment at: src/cxa_demangle.cpp:260-261
+
+#if 0
+  void dump() const {
+char *Buffer = static_cast(std::malloc(1024));

Why is this behind `#if 0`?  Should you just use something like 
`LLVM_DUMP_METHOD`?



Comment at: src/cxa_demangle.cpp:604
+
+  void printLeft(OutputStream ) const override {
+Pointee->printLeft(S);

I'd rather style changes like this were separated out into NFC commits (pre or 
post), since they make it hard to see what actually changed.



Comment at: src/cxa_demangle.cpp:1412-1414
+setCachedRHSComponent(false);
+setCachedArray(false);
+setCachedFunction(false);

This seems like a super-common sequence in constructors of subclasses of 
`Node`.  Can you pull out a common subclass of `Node` (say, `CachingNode`)?



Comment at: test/test_demangle.pass.cpp:29607
 {"_ZTHN3fooE", "thread-local initialization routine for foo"},
-{"_Z4algoIJiiiEEvZ1gEUlT_E_", "void algo(g::'lambda'(int, 
int, int))"},
+{"_Z4algoIJiiiEEvZ1gEUlDpT_E_", "void algo(g::'lambda'(int, 
int, int))"},
 // attribute abi_tag

erik.pilkington wrote:
> I just generated this symbol by hand because I couldn't get clang to do it 
> without crashing. Turns out I forgot the Dp!
Why was it crashing?  (Did you file a bug?)


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D41885



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


[PATCH] D42354: Fix libcxx MSVC C++17 redefinition of 'align_val_t'

2018-01-22 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Seems reasonable to me.


Repository:
  rCXX libc++

https://reviews.llvm.org/D42354



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


[PATCH] D42073: [clangd] Use accessible scopes to query indexes for global code completion.

2018-01-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/CodeComplete.cpp:868
+}
+log(Ctx, "Query scopes: [");
+for (auto  : Req.Scopes)

hokein wrote:
> sammccall wrote:
> > log doesn't work that way - you need to combine into a single message :-)
> > 
> > I think since we don't have verbosity levels, it's best to remove this - 
> > it's much more fine-grained than anything else we log, so it will be spammy.
> > (If we do want to log something, we should summarize the whole query.)
> I think the log here is pretty useful for debugging. 
SG. It might be worth more clearly tying the log message to the other code 
complete one:, e.g. "Code complete: fuzzyFind(\"{0}\", Scopes=[{1}])"



Comment at: clangd/CodeComplete.cpp:652
 
-SpecifiedScope getSpecifiedScope(Sema , const CXXScopeSpec ) {
-  SpecifiedScope Info;
-  auto  = S.getSourceManager();
-  auto SpecifierRange = SS.getRange();
-  Info.Written = Lexer::getSourceText(
-  CharSourceRange::getCharRange(SpecifierRange), SM, clang::LangOptions());
-  if (!Info.Written.empty())
-Info.Written += "::"; // Sema excludes the trailing ::.
-  if (SS.isValid()) {
-DeclContext *DC = S.computeDeclContext(SS);
-if (auto *NS = llvm::dyn_cast(DC)) {
-  Info.Resolved = NS->getQualifiedNameAsString() + "::";
-} else if (llvm::dyn_cast(DC) != nullptr) {
-  Info.Resolved = "";
+// Get all scopes that will be queried in indexes.
+std::vector getQueryScopes(Sema ,

could you move this to be right after the closely-related SpecifiedScope 
struct? I can't remember why they got separated, probably my fault :-)



Comment at: clangd/CodeComplete.cpp:653
+// Get all scopes that will be queried in indexes.
+std::vector getQueryScopes(Sema ,
+CodeCompletionContext ) {

as Ilya pointed out to me, passing Sema around is a big scary thing that we 
should try to avoid. Here it's only used to get the text if the CXXScopeSpec is 
invalid. Can we pass just the SourceManager, or better yet, the text as a 
StringPiece?



Comment at: clangd/CodeComplete.cpp:695
+  Info.UnresolvedQualifier =
+  Lexer::getSourceText(CharSourceRange::getCharRange((*SS)->getRange()),
+   S.getSourceManager(), clang::LangOptions());

do you need to remove any leading :: here?



Comment at: unittests/clangd/CodeCompleteTests.cpp:679
 }
 
+class IndexRequestCollector : public SymbolIndex {

Can you factor out the common code into a function?

e.g. 
  vector captureIndexRequests(string example) {
IndexRequestCollector Index; // actually the class can be local here
...
  }

Like completions(), this avoids boilerplate in the tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42073



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


[libcxx] r323137 - Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.

2018-01-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 22 10:38:18 2018
New Revision: 323137

URL: http://llvm.org/viewvc/llvm-project?rev=323137=rev
Log:
Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n.  
These will be enabled when that part of P0202 is implemented. NFC at this time.

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp?rev=323137=323136=323137=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
 Mon Jan 22 10:38:18 2018
@@ -10,14 +10,27 @@
 // 
 
 // template 
OutIter>
-//   OutIter
+//   constexpr OutIter   // constexpr after C++17
 //   copy(InIter first, InIter last, OutIter result);
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
 
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {1, 2, 3, 4, 5};
+// int ic[] = {6, 6, 6, 6, 6, 6, 6};
+// 
+// auto p = std::copy(std::begin(ia), std::end(ia), std::begin(ic));
+// return std::equal(std::begin(ia), std::end(ia), std::begin(ic), p)
+// && std::all_of(p, std::end(ic), [](int a){return a == 6;})
+// ;   
+// }
+// #endif
+
 template 
 void
 test()
@@ -70,4 +83,8 @@ int main()
 test >();
 test >();
 test();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
 }

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp?rev=323137=323136=323137=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
 Mon Jan 22 10:38:18 2018
@@ -11,13 +11,28 @@
 
 // template
 //   requires OutputIterator
-//   OutIter
+//   constexpr OutIter   // constexpr after C++17
 //   copy_backward(InIter first, InIter last, OutIter result);
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
+#include "user_defined_integral.hpp"
+
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {1, 2, 3, 4, 5};
+// int ic[] = {6, 6, 6, 6, 6, 6, 6};
+// 
+// size_t N = std::size(ia);
+// auto p = std::copy_backward(std::begin(ia), std::end(ia), 
std::begin(ic) + N);
+// return std::equal(std::begin(ic), p, std::begin(ia))
+// && std::all_of(p, std::end(ic), [](int a){return a == 6;})
+// ;   
+// }
+// #endif
 
 template 
 void
@@ -48,4 +63,8 @@ int main()
 test >();
 test >();
 test();
+
+// #if TEST_STD_VER > 17
+// static_assert(test_constexpr());
+// #endif
 }

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp?rev=323137=323136=323137=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
 Mon Jan 22 10:38:18 2018
@@ -12,14 +12,27 @@
 // template 
OutIter,
 //  Predicate Pred>
 //   requires CopyConstructible
-//   OutIter
+//   constexpr OutIter   // constexpr after C++17
 //   copy_if(InIter first, InIter last, OutIter result, Pred pred);
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
 
+// #if TEST_STD_VER > 17
+// TEST_CONSTEXPR bool test_constexpr() {
+// int ia[] = {2, 4, 6, 8, 6};
+// int ic[] = {0, 0, 0, 0, 0, 0};
+// 
+// auto p = std::copy_if(std::begin(ia), std::end(ia), std::begin(ic), 
is6);
+// return std::all_of(std::begin(ic), p, [](int a){return a == 6;})
+// && std::all_of(p, std::end(ic),   [](int a){return a == 0;})
+// ;   
+// }
+// #endif
+
 struct Pred
 {
 bool operator()(int i) {return i % 3 == 0;}
@@ -77,4 +90,8 @@ int main()
 test 

[PATCH] D42371: Issue local statics in correct DWARF lexical scope

2018-01-22 Thread Paul Robinson via Phabricator via cfe-commits
probinson added subscribers: cfe-commits, probinson.
probinson added a comment.

+cfe-commits
See also the LLVM change in https://reviews.llvm.org/D42369 and Clang change in 
https://reviews.llvm.org/D42370.


https://reviews.llvm.org/D42371



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


[PATCH] D42370: Issue local statics in correct DWARF lexical scope

2018-01-22 Thread Paul Robinson via Phabricator via cfe-commits
probinson added subscribers: cfe-commits, probinson.
probinson added a comment.

+cfe-commits
See also the LLVM change in https://reviews.llvm.org/D42369 and a 
debuginfo-tests test in https://reviews.llvm.org/D42371.


https://reviews.llvm.org/D42370



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


[PATCH] D41885: [libcxxabi][demangler] Improve handling of variadic templates

2018-01-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D41885



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


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130922.
MaskRay added a comment.

Regenerate HTML docs

$ cd docs/tools # yes, cd
$ ./dump_ast_matchers.py


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   A c;
 ///
-///   template f() {};
+///   template void f() {}
 ///   void func() { f(); };
 /// \endcode
 /// classTemplateSpecializationDecl(hasTemplateArgument(
@@ -880,12 +880,12 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::next> with \c fieldDecl(...) matching
 /// \c B::next
 AST_MATCHER_P(TemplateArgument, refersToDeclaration,
@@ -899,8 +899,8 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
-///   struct B { B* next; };
+///   struct B { int next; };
+///   template struct A {};
 ///   A<::next> a;
 /// \endcode
 /// templateSpecializationType(hasAnyTemplateArgument(
@@ -917,7 +917,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -932,7 +932,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -953,7 +953,7 @@
 ///
 /// Given
 /// \code
-///   template struct A {};
+///   template struct C {};
 ///   C<42> c;
 /// \endcode
 /// classTemplateSpecializationDecl(
@@ -1523,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -1799,7 +1799,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// switchCase()
-///   matches 'case 42: break;' and 'default: break;'.
+///   matches 'case 42:' and 'default:'.
 extern const internal::VariadicDynCastAllOfMatcher switchCase;
 
 /// \brief Matches case statements inside switch statements.
@@ -1809,7 +1809,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// caseStmt()
-///   matches 'case 42: break;'.
+///   matches 'case 42:'.
 extern const internal::VariadicDynCastAllOfMatcher caseStmt;
 
 /// \brief Matches default statements inside switch statements.
@@ -1819,13 +1819,13 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// defaultStmt()
-///   matches 'default: break;'.
+///   matches 'default:'.
 extern const internal::VariadicDynCastAllOfMatcher
 defaultStmt;
 
 /// \brief Matches compound statements.
 ///
-/// Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+/// Example matches '{}' and '{{}}' in 'for (;;) {{}}'
 /// \code
 ///   for (;;) {{}}
 /// \endcode
@@ -2502,11 +2502,12 @@
 /// \brief Matches AST nodes that have child AST nodes that match the
 /// provided matcher.
 ///
-/// Example matches X, Y
+/// Example matches X, Y, Y::X, Z::Y, Z::Y::X
 ///   (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
 /// \code
-///   class X {};  // Matches X, because X::X is a class of name X inside X.
-///   class Y { class X {}; };
+///   class X {};
+///   class Y { class X {}; };  // Matches Y, because Y::X is a class of name X
+/// // inside Y.
 ///   class Z { class Y { class X {}; }; };  // Does not match Z.
 /// \endcode
 ///
@@ -2522,11 +2523,12 @@
 /// \brief Matches AST nodes that have descendant AST nodes that match the
 /// provided matcher.
 ///
-/// Example matches X, A, B, C
+/// Example matches X, A, A::X, B, B::C, B::C::X
 ///   (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")
 /// \code
-///   class X {};  // Matches X, because X::X is a class of name X inside X.
-///   class A { class X {}; };
+///   class X {};
+///   class A { class X {}; };  // Matches A, because A::X is a class of name
+/// // X inside A.
 ///   class B { class C { class X {}; }; };
 /// \endcode
 ///
@@ -2681,7 +2683,7 @@
 ///   (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))
 /// \code
 ///   class Y { public: void x(); };
-///   void z() { Y y; y.x(); 

[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-01-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a reviewer: arphaman.
vsk added a comment.

In https://reviews.llvm.org/D42043#981409, @elsteveogrande wrote:

> Fixes, but first, a question for reviewers:
>
> Looking at the description of `clang_disposeString`:
>
>   /**
>* \brief Free the given string.
>*/
>   CINDEX_LINKAGE void clang_disposeString(CXString string);
>   
>
> Does it seem incorrect to acquire some `const char *` pointer into this 
> string, dispose the string, and then access the characters?


I'm inclined to say that this is incorrect, but skimming through the codebase 
it seems like we "get away" with this behavior all over the place.

> I've seen this happen a couple of times now.  As I make changes to my code I 
> run into this pattern.  (Since now this triggers a use-after-free abort.)
> 
> I wanted to ask because, though it seemed obvious to me that this is 
> incorrect usage, I'm now wondering if the expectation is that it's ok.

I've CC'd some Apple folks who can say more definitively how difficult it'd be 
to move away from this behavior. IMO it should be doable as long as there's 
some way to audit the codebase (e.g with ASan).

>   Or maybe wasn't technically ok, and we just "got away with it" before.  :)
>
> 
> Anyway, assuming it's only correct to use the string before disposing it, 
> then the fixes this time around are:
> 
> - Fix an ASAN use-after-free in `c-index-test` mentioned above.  Get the 
> `CXString`, pass it around, then dispose when we're done with it.
> - Change `createEmpty` and `createNull` to delegate through `createRef`
> - `createRef` tolerates `nullptr` correctly.
> - I previously ran into ASAN aborts due to mixing malloc/free/operator 
> new/delete.  I had changed everything to use operator new/delete.  However 
> from C-land I can't `new char[length]`, only `malloc` (or `strdup` or 
> whatever).  Change everything to malloc/free instead.


Repository:
  rC Clang

https://reviews.llvm.org/D42043



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


[PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Yes, please document this in itanium-cxx-abi. Thanks!


https://reviews.llvm.org/D41039



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


[PATCH] D42357: Under limitation of allocated buffer, inplace_merge() does NOT take usage of partial allocated buffer but applies native rotate directly.

2018-01-22 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/algorithm:2511
+difference_type __len1, __len2;
+__len1 = __middle - __first;
+__len2 = __last - __middle;

These iterator calculations only work for random access iterators.
Does this actually work with forward iterators?





Comment at: include/algorithm:2515
+{
+pointer __buff_end = __move(__first, __middle,  __buff);
+__move(__middle, __last, __first);

Probably a good idea to qualify these calls with `_VSTD::` to ensure that no 
inadvertent ADL happens.



Comment at: include/algorithm:4582
+//__middle = _VSTD::rotate(__m1, __middle, __m2);
+__middle = _VSTD::__buffered_rotate(__m1, __middle, __m2, __buff, 
__buff_size);
 // __len12 and __len21 now have swapped meanings

It seems a shame to calculate `__len1`, etc on L#2511 above when you have them 
right here.


Repository:
  rCXX libc++

https://reviews.llvm.org/D42357



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


[PATCH] D42154: Don't generate inline atomics for i386/i486

2018-01-22 Thread Wei Mi via Phabricator via cfe-commits
wmi added a comment.

In https://reviews.llvm.org/D42154#983840, @rjmccall wrote:

> In https://reviews.llvm.org/D42154#977991, @wmi wrote:
>
> > In https://reviews.llvm.org/D42154#977975, @efriedma wrote:
> >
> > > The LLVM backend currently assumes every CPU is Pentium-compatible.  If 
> > > we're going to change that in clang, we should probably fix the backend 
> > > as well.
> >
> >
> > With the patch, for i386/i486 targets, clang will generate more atomic 
> > libcalls than before, for which llvm backend will not do anything extra, so 
> > no fix is necessary in llvm backend for the patch to work.
>
>
> I think Eli's point is that we do not currently support generating code for 
> the 386 and 486 because there are other things in the x86 backend that assume 
> that the target is at minimum a Pentium.  If you're looking to support 
> targeting those chips, you should look into that.


I am not looking to support those chips. Just because 
https://reviews.llvm.org/rL314145 changed the status of FreeBSD ports on 32 
bits x86 as reported in https://bugs.llvm.org/show_bug.cgi?id=34347#c6, I want 
to provide a workaround and give them a relief. 
This is also the intention of keeping MaxAtomicInlineWidth to be 64 for 
CK_Generic. In this way, it provides the minimum churn for current status -- 
otherwise at least a bunch of tests need to be fixed.


Repository:
  rC Clang

https://reviews.llvm.org/D42154



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


[PATCH] D42351: Emit DWARF "constructor" calling convention for every supported Clang CC

2018-01-22 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

If we take https://reviews.llvm.org/D42350, taking this is fairly obvious, 
though it could use a testcase.


Repository:
  rC Clang

https://reviews.llvm.org/D42351



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


[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2018-01-22 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.

Thanks for adding the test! LGTM, will submit it shortly.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535



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


[PATCH] D42241: [CodeComplete] Fix completion in the middle of idents in macro calls

2018-01-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323133: [CodeComplete] Fix completion in the middle of 
idents in macro calls (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42241

Files:
  cfe/trunk/lib/Lex/Preprocessor.cpp
  cfe/trunk/test/CodeCompletion/inside-macros.cpp


Index: cfe/trunk/test/CodeCompletion/inside-macros.cpp
===
--- cfe/trunk/test/CodeCompletion/inside-macros.cpp
+++ cfe/trunk/test/CodeCompletion/inside-macros.cpp
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+  ID(input_var) = true;
+  // Check that input_var shows up when completing at the start, in the middle
+  // and at the end of the identifier.
+  //
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | 
FileCheck %s
+
+  // CHECK: input_var
+}
Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -773,8 +773,13 @@
 }
   } while (!ReturnedToken);
 
-  if (Result.is(tok::code_completion))
+  if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
+// Remember the identifier before code completion token.
 setCodeCompletionIdentifierInfo(Result.getIdentifierInfo());
+// Set IdenfitierInfo to null to avoid confusing code that handles both
+// identifiers and completion tokens.
+Result.setIdentifierInfo(nullptr);
+  }
 
   LastTokenWasAt = Result.is(tok::at);
 }


Index: cfe/trunk/test/CodeCompletion/inside-macros.cpp
===
--- cfe/trunk/test/CodeCompletion/inside-macros.cpp
+++ cfe/trunk/test/CodeCompletion/inside-macros.cpp
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+  ID(input_var) = true;
+  // Check that input_var shows up when completing at the start, in the middle
+  // and at the end of the identifier.
+  //
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | FileCheck %s
+
+  // CHECK: input_var
+}
Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -773,8 +773,13 @@
 }
   } while (!ReturnedToken);
 
-  if (Result.is(tok::code_completion))
+  if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
+// Remember the identifier before code completion token.
 setCodeCompletionIdentifierInfo(Result.getIdentifierInfo());
+// Set IdenfitierInfo to null to avoid confusing code that handles both
+// identifiers and completion tokens.
+Result.setIdentifierInfo(nullptr);
+  }
 
   LastTokenWasAt = Result.is(tok::at);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r323133 - [CodeComplete] Fix completion in the middle of idents in macro calls

2018-01-22 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jan 22 09:18:28 2018
New Revision: 323133

URL: http://llvm.org/viewvc/llvm-project?rev=323133=rev
Log:
[CodeComplete] Fix completion in the middle of idents in macro calls

Summary:
This patch removes IdentifierInfo from completion token after remembering
the identifier in the preprocessor.

Prior to this patch, completion token had the IdentifierInfo set to null when
completing at the start of identifier and to the II for completion prefix
when in the middle of identifier.

This patch unifies how code completion token is handled when it is insterted
before the identifier and in the middle of the identifier.

The actual IdentifierInfo can still be obtained from the Preprocessor.

Reviewers: bkramer, arphaman

Reviewed By: bkramer

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeCompletion/inside-macros.cpp
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=323133=323132=323133=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Jan 22 09:18:28 2018
@@ -773,8 +773,13 @@ void Preprocessor::Lex(Token ) {
 }
   } while (!ReturnedToken);
 
-  if (Result.is(tok::code_completion))
+  if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
+// Remember the identifier before code completion token.
 setCodeCompletionIdentifierInfo(Result.getIdentifierInfo());
+// Set IdenfitierInfo to null to avoid confusing code that handles both
+// identifiers and completion tokens.
+Result.setIdentifierInfo(nullptr);
+  }
 
   LastTokenWasAt = Result.is(tok::at);
 }

Added: cfe/trunk/test/CodeCompletion/inside-macros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/inside-macros.cpp?rev=323133=auto
==
--- cfe/trunk/test/CodeCompletion/inside-macros.cpp (added)
+++ cfe/trunk/test/CodeCompletion/inside-macros.cpp Mon Jan 22 09:18:28 2018
@@ -0,0 +1,13 @@
+#define ID(X) X
+
+void test(bool input_var) {
+  ID(input_var) = true;
+  // Check that input_var shows up when completing at the start, in the middle
+  // and at the end of the identifier.
+  //
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | 
FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | 
FileCheck %s
+
+  // CHECK: input_var
+}


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


[PATCH] D42174: [clangd] Refactored threading in ClangdServer

2018-01-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a subscriber: ioeric.

So, I simultaneously think this is basically ready to land, and I want 
substantial changes :-)

This is much better already than what we have, and where I think we can further 
improve the design, this is a natural point on the way.

My preferred next steps would be:

- we discuss a little bit the directions I've outlined below, without the 
assumption that they belong in this patch.
- to the extent you agree, you make the less-invasive changes here (e.g. adding 
a VersionConstraint API, but only actually supporting the cases you've 
implemented)
- once we're on the same page for the other stuff, I'm happy to pick up any 
amount of it myself - whatever's not going to step on your toes




Comment at: clangd/ClangdServer.cpp:37
+template 
+Ret waitForASTAction(Scheduler , PathRef File, Func &) {
+  std::packaged_task Task(

Would be nice to have parallel names to the Scheduler methods, e.g. 
blockingASTRead() and blockingPreambleRead()



Comment at: clangd/ClangdServer.cpp:222
+  }
+  // We currently do all the reads of the AST on a running thread to avoid
+  // inconsistent states coming from subsequent updates.

Having trouble with this one.
is this the same as "We currently block the calling thread until the AST is 
available, to avoid..."?



Comment at: clangd/ClangdServer.h:164
 
+/// Handles running tasks for ClangdServer and managing the resources (e.g.,
+/// preambles and ASTs) for opened files.

This is a nice abstraction, so much better than dealing with Cppfile! A couple 
of observations:

1) all methods refer to a single file, neither the contracts nor the 
implementation have any interactions between files. An API that reflects this 
seems more natural. e.g. it naturally provides operations like "are we tracking 
this file", and makes it natural to be able to e.g. lock at the per-file level. 
e.g.

  class WorkingSet {
 shared_ptr get(Path);
 shared_ptr getOrCreate(Path)
   }
   class TranslationUnit {
 void update(ParseInputs);
 void read(Callback);
   }

This seems like it would make it easier to explain what the semantics of 
scheduleRemove are, too.

2) The callbacks from individual methods seem more powerful than needed, and 
encourage deeper coupling. Basically, the inputs (changes) and outputs 
(diagnostics, reads) don't seem to want to interact with the same code. This 
suggests decoupling them: the changes are a sequence of input events, 
diagnostics are a sequence of output events, reads look much as they do now.

One benefit here is that the versioning relationship between inputs and outputs 
no longer show up in the function signatures (by coupling an input to a 
matching output). Expressing them as data makes it easier to tweak them.

3) It's not spelled out how this interacts with drafts: whether text<->version 
is maintained here or externally, and what the contracts around versions are. 
There are no options offered, so I would guess that scheduleUpdate delivers 
new-version-or-nothing, and scheduleASTRead delivers... current-or-newer? 
current-or-nothing?

I think it would *probably* be clearer to have versions minted by the external 
DraftStore, that way we can decouple "we know about the contents of this file" 
from "we're building this file". e.g. we probably want wildly different 
policies for discarding resources of old versions, when "resources" = source 
code vs "resources" = ASTs and preambles.

4) Scheduler (or anything it decomposes into) is important and isolated enough 
that it deserves its own header.



Comment at: clangd/ClangdServer.h:169
+  Scheduler(unsigned AsyncThreadsCount, bool StorePreamblesInMemory,
+std::shared_ptr PCHs,
+ASTParsedCallback ASTCallback);

this is a performance optimization, right?
I think the scheduler does enough of the compiling that giving it one of its 
own isn't too wasteful.



Comment at: clangd/ClangdServer.h:173
+  /// Get the CompileCommand passed at the last scheduleUpdate call for \p 
File.
+  llvm::Optional getLatestCommand(PathRef File) const;
+

This seems like a smell - the command is sometimes an input from callsites that 
want builds, and sometimes an output to callsites that want builds. Also this 
class is all about threading, scheduling, and versions, and this method 
bypasses all of that.

(If this is a hack to keep code complete working while we refactor, that's fine 
- but the docs should say that and we should know what next steps look like!)

ISTM the issue here is coupling updates to the source with updates to the 
compile command.
Ultimately we should indeed be compiling a given version with a fixed CC, but 
that doesn't seem like the clearest interface for callers.

One option is:
  - Scheduler has a reference to the CDB (or a 

[PATCH] D42036: [clang-format] Keep comments aligned to macros

2018-01-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1725
+   NextNonComment.Type == LT_ImportStatement) &&
+  NextNonComment.Level > 0 && !Comment.InPPDirective)
+return NextNonComment.First->Next &&

Why are we checking `NextNonComment.Level > 0` here? We could be aligned with 
the next preprocessor directive even at level 0.



Comment at: lib/Format/TokenAnnotator.cpp:1729
+NextNonComment.First->Next->OriginalColumn)
+   ? CA_Directive
+   : CA_None;

I think this should be enabled only if preprocessor indentation has been 
enabled.



Comment at: lib/Format/TokenAnnotator.cpp:1761
+  if (Alignment == CA_Directive)
+(*I)->LevelOffset = 1;
 } else {

Could you add a comment that this `1` comes from the `#` in the preprocessor 
directive?



Comment at: unittests/Format/FormatTest.cpp:2629
+   "#  define B 0\n"
+   "   // Trailing aligned comment\n"
+   "#endif\n"

I would expect this comment to be aligned with the `#endif` on the next line.



Comment at: unittests/Format/FormatTest.cpp:2657
+   " * Trailing aligned comment\n"
+   " */\n"
+   "#endif\n"

Same here.


Repository:
  rC Clang

https://reviews.llvm.org/D42036



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


[PATCH] D42366: [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CodeGenTBAA.h:67
   /* BaseType= */ nullptr, /* AccessType= */ nullptr,
-  /* Offset= */ 0, /* Size= */ 0);
+  /* Offset= */ 0, /* Size= */ UINT64_MAX);
   }

Hmm.  I think you should talk this part over with Hal.  If the size should be 
ignored then I think it's better to just leave this as 0; it's certainly easier 
to recognize 0 as a "size unknown" value.


Repository:
  rL LLVM

https://reviews.llvm.org/D42366



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


[PATCH] D42318: [ARM] Pass _Float16 as int or float

2018-01-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks for reviewing!

We are trying to achieve correct AAPCS parameter passing:

"If the argument is a Half-precision Floating  Point Type its size is set to 4 
bytes as if it 
had been copied to the least significant bits of a 32-bit register and the 
remaining bits filled
with unspecified values"

and for returning results:

"A Half-precision Floating Point Type is returned in the least significant 16 
bits of r0."

Summarising: AAPCS compliance for passing/returning _Float16 values.

Ideal solution would be to lower this:

  _Float16 sub(_Float16 a, _Float16 b) {
return a + b;
  }

to this:

  define half @sub(half %a, half %b) local_unnamed_addr {
  entry:
%add = fadd half %a, %b
ret half %add
  }

but with this patch we are generating:

  define float @sub(float %a.coerce, float %b.coerce) local_unnamed_addr #0 {
  entry:
%0 = bitcast float %a.coerce to i32
%tmp.0.extract.trunc = trunc i32 %0 to i16
%1 = bitcast i16 %tmp.0.extract.trunc to half

%add = fadd half %1, %3

  }

With this we achieve that we pass a float, and interpret only the lower 16 bits 
(and 
similar approach for the return value that I've omitted here).

Thus, we are working around the problem of legalizing f16 arguments/return 
values; 
we are now doing this in Clang and thus don't have to do anything at all in the 
backend. 
This is a 2-lines change, and enables to make progress with the Armv8.2-A FP16 
tablegen 
descriptions and also to start testing/using them; adjusting the calling 
conventions in the backend are 
a bit more involved. I will start working on this ideal solution now, and once 
that is in place, 
we can properly pass the half types and remove this workaround.


https://reviews.llvm.org/D42318



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


[PATCH] D42273: Add hasTrailingReturn AST matcher

2018-01-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 130908.
juliehockett added a comment.

Adding test case -- thank you for the advice!


https://reviews.llvm.org/D42273

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2112,5 +2112,24 @@
   EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
 }
 
+TEST(HasTrailingReturn, MatchesTrailingReturn) {
+  EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X() { return 0; }", 
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn(;
+}
+
+TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
+  EXPECT_TRUE(matches(
+  "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches(
+  "auto lambda2 = [](double x, double y) {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -296,6 +296,7 @@
   REGISTER_MATCHER(hasTemplateArgument);
   REGISTER_MATCHER(hasThen);
   REGISTER_MATCHER(hasThreadStorageDuration);
+  REGISTER_MATCHER(hasTrailingReturn);
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5891,6 +5891,19 @@
   return Node.isScoped();
 }
 
+/// \brief Matches a function declared with a trailing return type.
+///
+/// Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+/// \code
+/// int X() {}
+/// auto Y() -> int {}
+/// \endcode
+AST_MATCHER(FunctionDecl, hasTrailingReturn) {
+  if (const auto *F = Node.getType()->getAs())
+return F->hasTrailingReturn();
+  return false;
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2749,6 +2749,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasTrailingReturn
+Matches a 
function declared with a trailing return type.
+
+Example matches Y (matcher = functionDecl(hasTrailingReturn()))
+int X() {}
+auto Y() - int {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisConstexpr
 Matches constexpr 
variable and function declarations.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2112,5 +2112,24 @@
   EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
 }
 
+TEST(HasTrailingReturn, MatchesTrailingReturn) {
+  EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X() { return 0; }", 
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn(;
+}
+
+TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
+  EXPECT_TRUE(matches(
+  "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+  EXPECT_TRUE(notMatches(
+  "auto lambda2 = [](double x, double y) {return x + y;};",
+  functionDecl(hasTrailingReturn(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -296,6 +296,7 @@
   REGISTER_MATCHER(hasTemplateArgument);
   REGISTER_MATCHER(hasThen);
   REGISTER_MATCHER(hasThreadStorageDuration);
+  

[PATCH] D42092: implement C++ dr388 for the Itanium C++ ABI: proper handling of catching exceptions by reference

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This is definitely something that the personality function should handle.  If 
we want to do heroic things in the absence of personality function support, we 
can, but the code should at least be written to be conditional on personality 
support.

If we can rev the personality function, we should also fix the longstanding 
problem with references to pointers to classes.


Repository:
  rC Clang

https://reviews.llvm.org/D42092



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


[PATCH] D42360: [6.0.0 Release] Release notes for configuration files in clang

2018-01-22 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323132: [6.0.0 Release] Release notes for configuration 
files in clang (authored by sepavloff, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42360

Files:
  cfe/branches/release_60/docs/ReleaseNotes.rst


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -163,6 +163,15 @@
 - The presence of __attribute__((availability(...))) on a declaration no longer
   implies default visibility for that declaration on macOS.
 
+- Clang now supports configuration files. These are collections of driver
+  options, which can be applied by specifying the configuration file, either
+  using command line option `--config foo.cfg` or encoding it into executable
+  name `foo-clang`. Clang behaves as if the options from this file were 
inserted
+  before the options specified in command line. This feature is primary 
intended
+  to facilitate cross compilation. Details can be found in
+  `Clang Compiler User's Manual
+  `.
+
 - ...
 
 Windows Support


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -163,6 +163,15 @@
 - The presence of __attribute__((availability(...))) on a declaration no longer
   implies default visibility for that declaration on macOS.
 
+- Clang now supports configuration files. These are collections of driver
+  options, which can be applied by specifying the configuration file, either
+  using command line option `--config foo.cfg` or encoding it into executable
+  name `foo-clang`. Clang behaves as if the options from this file were inserted
+  before the options specified in command line. This feature is primary intended
+  to facilitate cross compilation. Details can be found in
+  `Clang Compiler User's Manual
+  `.
+
 - ...
 
 Windows Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40787: [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions

2018-01-22 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 130905.

https://reviews.llvm.org/D40787

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tidy/modernize/UseUncaughtExceptionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst
  test/clang-tidy/modernize-use-uncaught-exceptions.cpp

Index: test/clang-tidy/modernize-use-uncaught-exceptions.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-uncaught-exceptions.cpp
@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy %s modernize-use-uncaught-exceptions %t -- -- -std=c++1z
+#define MACRO std::uncaught_exception
+// CHECK-FIXES: #define MACRO std::uncaught_exception
+
+bool uncaught_exception() {
+  return 0;
+}
+
+namespace std {
+  bool uncaught_exception() {
+return 0;
+  }
+}
+
+template 
+bool doSomething(T t) { 
+  return t();
+  // CHECK-FIXES: return t();
+}
+
+template 
+bool doSomething2() { 
+  return T();
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: return T();
+}
+
+int main() {
+  bool res;
+
+  res = uncaught_exception();
+  // CHECK-FIXES: res = uncaught_exception();
+
+  res = doSomething(uncaught_exception);
+  // CHECK-FIXES: res = doSomething(uncaught_exception);
+
+  res = MACRO();
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = MACRO();
+
+  res = std::uncaught_exception();
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = std::uncaught_exceptions() > 0;
+
+  using std::uncaught_exception;
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: using std::uncaught_exceptions;
+
+  res = uncaught_exception();
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = std::uncaught_exceptions() > 0;
+
+  res = doSomething(std::uncaught_exception);
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = doSomething(std::uncaught_exceptions);
+
+  res = doSomething(uncaught_exception);
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = doSomething(uncaught_exceptions);
+
+  bool (*foo)();
+  foo = _exception;
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: foo = _exceptions;
+
+  res = doSomething2();
+  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: res = doSomething2();
+
+  bool b{std::uncaught_exception()};
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+  // CHECK-FIXES: bool b{std::uncaught_exceptions() > 0};
+
+  return res;
+}
Index: docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst
@@ -0,0 +1,64 @@
+.. title:: clang-tidy - modernize-use-uncaught-exceptions
+
+modernize-use-uncaught-exceptions
+
+
+This check will warn on calls to ``std::uncaught_exception`` and replace them with
+calls to ``std::uncaught_exceptions``, since std::uncaught_exception was deprecated
+in C++17.
+
+Below are a few examples of what kind of occurrences will be found and what
+they will be replaced with.
+
+.. code-block:: c++
+
+#define MACRO1 std::uncaught_exception
+#define MACRO2 std::uncaught_exception
+
+int uncaught_exception() {
+return 0;
+}
+
+int main() {
+int res;
+
+res = uncaught_exception();
+// No warning, since it is not the deprecated function from namespace std
+
+res = MACRO2();
+// Warning, but will not be replaced
+
+res = std::uncaught_exception();
+// Warning and replaced
+
+using std::uncaught_exception;
+// Warning and replaced
+
+res = uncaught_exception();
+// Warning and replaced
+}
+
+After applying the fixes the code will look like the following:
+
+.. code-block:: c++
+
+#define MACRO1 std::uncaught_exception
+#define MACRO2 std::uncaught_exception
+
+int uncaught_exception() {
+return 0;
+}
+
+int main() {
+int res;
+

[PATCH] D42335: [ASTImporter] Supporting CXXOperatorCallExpr, SizeOfPackExpr, DependentTemplateSpecializationType, DependentSizedArray importing.

2018-01-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Peter,

Thank you for the patch! It is almost LGTM, just a few minor questions inline.
Am I understand correctly that it is partially based on 
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp?
Also, FYI: you can use ASTMerge and clang-import-test facilities for testing. 
ASTMatchers  are completely fine, but usage of imported AST samples as Sema 
lookup source can uncover some subtle issues in the built AST.




Comment at: lib/AST/ASTImporter.cpp:523
+  QualType ToElementType = Importer.Import(T->getElementType());
+
+  if (ToElementType.isNull())

Redundant newline? (Same below).



Comment at: lib/AST/ASTImporter.cpp:5829
 
+Expr *ASTNodeImporter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+  QualType T = Importer.Import(E->getType());

This can be merged with VisitCallExpr to avoid code duplication.


Repository:
  rC Clang

https://reviews.llvm.org/D42335



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


[PATCH] D42318: [ARM] Pass _Float16 as int or float

2018-01-22 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

Hi Sjoerd,

Seems sensible to me to treat these two types the same way, though I must admit 
having different half types confuses me... So a few questions for my 
understanding:

- What issue are you trying to workaround?

-What would the ideal solution be?

- Why do we need a workaround instead of implementing the ideal solution?

cheers!




Comment at: test/CodeGen/arm-float16-arguments.c:4
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs -mfloat-abi 
soft -fnative-half-arguments-and-returns -emit-llvm -o - -O1 %s | FileCheck %s 
--check-prefix=NATIVE
+
+_Float16 g;

Probably worth keeping these in arm-fp16-arguments.c since they're basically 
the same.


https://reviews.llvm.org/D42318



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


[PATCH] D41539: [CodeGen] Decorate aggregate accesses with TBAA tags

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thank you.  Maybe there should be an overload of EmitAggregateCopy that takes 
LValues?  A lot of these cases start with an LValue on at least one side, and 
there are already some convenience functions to turn an Address into a 
naturally-typed LValue.


https://reviews.llvm.org/D41539



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


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: docs/ReleaseNotes.rst:230
+  applications, please rebuild the runtime library with 
`-DLIBOMP_OMPT_SUPPORT=OFF`
+  and file a bug at `LLVM's Bugzilla `.

hans wrote:
> Is there a missing right-angle bracket, >, here?
Yes, and an underscore. I though I was smart enough to write reStructuredText 
without actually "testing" it...


https://reviews.llvm.org/D42352



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


[PATCH] D42352: [ReleaseNotes] Mention OpenMP Tools Interface in runtime library

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

Address review comments.


https://reviews.llvm.org/D42352

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -222,6 +222,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface 
(OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. If you 
observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with 
`-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message 
to the
+  `OpenMP development list 
`_.
+
 Internal API Changes
 
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -222,6 +222,13 @@
 - Added support for `reduction`-based clauses on `task`-based directives from
   upcoming OpenMP 5.0.
 
+- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface (OMPT)
+  on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. If you observe
+  a measurable performance impact on one of your applications without a tool
+  attached, please rebuild the runtime library with `-DLIBOMP_OMPT_SUPPORT=OFF` and
+  file a bug at `LLVM's Bugzilla `_ or send a message to the
+  `OpenMP development list `_.
+
 Internal API Changes
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42154: Don't generate inline atomics for i386/i486

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D42154#977991, @wmi wrote:

> In https://reviews.llvm.org/D42154#977975, @efriedma wrote:
>
> > The LLVM backend currently assumes every CPU is Pentium-compatible.  If 
> > we're going to change that in clang, we should probably fix the backend as 
> > well.
>
>
> With the patch, for i386/i486 targets, clang will generate more atomic 
> libcalls than before, for which llvm backend will not do anything extra, so 
> no fix is necessary in llvm backend for the patch to work.


I think Eli's point is that we do not currently support generating code for the 
386 and 486 because there are other things in the x86 backend that assume that 
the target is at minimum a Pentium.  If you're looking to support targeting 
those chips, you should look into that.

I don't have any objections to this patch.


Repository:
  rC Clang

https://reviews.llvm.org/D42154



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


[PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Looks great to me!  Thanks for taking this on, it's a pretty major improvement 
for users.

Would you like to create an issue with itanium-cxx-abi to document this, or do 
you want me to handle that?


https://reviews.llvm.org/D41039



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


[PATCH] D42261: [clang-tidy objc-property-declaration] New option IncludeDefaultAcronyms

2018-01-22 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE323130: [clang-tidy objc-property-declaration] New option 
IncludeDefaultAcronyms (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42261?vs=130661=130899#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42261

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.h
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration-additional.m
  test/clang-tidy/objc-property-declaration-custom.m

Index: clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tidy/objc/PropertyDeclarationCheck.h
@@ -34,7 +34,8 @@
   void storeOptions(ClangTidyOptions::OptionMap ) override;
 
 private:
-const std::vector SpecialAcronyms;
+  const std::vector SpecialAcronyms;
+  const bool IncludeDefaultAcronyms;
 };
 
 } // namespace objc
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -11,6 +11,7 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -26,61 +27,62 @@
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
 ///
 /// Keep this list sorted.
-constexpr char DefaultSpecialAcronyms[] =
-"ACL;"
-"API;"
-"ARGB;"
-"ASCII;"
-"BGRA;"
-"CMYK;"
-"DNS;"
-"FPS;"
-"FTP;"
-"GIF;"
-"GPS;"
-"HD;"
-"HDR;"
-"HTML;"
-"HTTP;"
-"HTTPS;"
-"HUD;"
-"ID;"
-"JPG;"
-"JS;"
-"LAN;"
-"LZW;"
-"MDNS;"
-"MIDI;"
-"OS;"
-"PDF;"
-"PIN;"
-"PNG;"
-"POI;"
-"PSTN;"
-"PTR;"
-"QA;"
-"QOS;"
-"RGB;"
-"RGBA;"
-"RGBX;"
-"ROM;"
-"RPC;"
-"RTF;"
-"RTL;"
-"SDK;"
-"SSO;"
-"TCP;"
-"TIFF;"
-"TTS;"
-"UI;"
-"URI;"
-"URL;"
-"VC;"
-"VOIP;"
-"VPN;"
-"VR;"
-"WAN;"
-"XML";
+constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = {
+"ACL",
+"API",
+"ARGB",
+"ASCII",
+"BGRA",
+"CMYK",
+"DNS",
+"FPS",
+"FTP",
+"GIF",
+"GPS",
+"HD",
+"HDR",
+"HTML",
+"HTTP",
+"HTTPS",
+"HUD",
+"ID",
+"JPG",
+"JS",
+"LAN",
+"LZW",
+"MDNS",
+"MIDI",
+"OS",
+"PDF",
+"PIN",
+"PNG",
+"POI",
+"PSTN",
+"PTR",
+"QA",
+"QOS",
+"RGB",
+"RGBA",
+"RGBX",
+"ROM",
+"RPC",
+"RTF",
+"RTL",
+"SDK",
+"SSO",
+"TCP",
+"TIFF",
+"TTS",
+"UI",
+"URI",
+"URL",
+"VC",
+"VOIP",
+"VPN",
+"VR",
+"WAN",
+"XML",
+};
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -97,14 +99,7 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector ) {
-  std::vector EscapedAcronyms;
-  EscapedAcronyms.reserve(Acronyms.size());
-  // In case someone defines a custom prefix which includes a regex
-  // special character, escape all the prefixes.
-  std::transform(Acronyms.begin(), Acronyms.end(),
- std::back_inserter(EscapedAcronyms), [](const std::string& s) {
-   return llvm::Regex::escape(s); });
+std::string validPropertyNameRegex(const std::vector ) {
   // Allow any of these names:
   // foo
   // fooBar
@@ -123,15 +118,32 @@
 PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  SpecialAcronyms(utils::options::parseStringList(
-  Options.get("Acronyms", DefaultSpecialAcronyms))) {}
+  SpecialAcronyms(
+  utils::options::parseStringList(Options.get("Acronyms", ""))),
+  IncludeDefaultAcronyms(Options.get("IncludeDefaultAcronyms", true)) {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  std::vector EscapedAcronyms;
+  if (IncludeDefaultAcronyms) {
+EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
+SpecialAcronyms.size());
+// No need to regex-escape the default acronyms.
+EscapedAcronyms.insert(EscapedAcronyms.end(),
+   std::begin(DefaultSpecialAcronyms),
+   std::end(DefaultSpecialAcronyms));
+  } else {
+EscapedAcronyms.reserve(SpecialAcronyms.size());
+  }
+  // In case someone defines a prefix 

[PATCH] D42261: [clang-tidy objc-property-declaration] New option IncludeDefaultAcronyms

2018-01-22 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323130: [clang-tidy objc-property-declaration] New option 
IncludeDefaultAcronyms (authored by benhamilton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42261?vs=130661=130898#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42261

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
  clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-additional.m
  clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m

Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
@@ -34,7 +34,8 @@
   void storeOptions(ClangTidyOptions::OptionMap ) override;
 
 private:
-const std::vector SpecialAcronyms;
+  const std::vector SpecialAcronyms;
+  const bool IncludeDefaultAcronyms;
 };
 
 } // namespace objc
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -11,6 +11,7 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -26,61 +27,62 @@
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
 ///
 /// Keep this list sorted.
-constexpr char DefaultSpecialAcronyms[] =
-"ACL;"
-"API;"
-"ARGB;"
-"ASCII;"
-"BGRA;"
-"CMYK;"
-"DNS;"
-"FPS;"
-"FTP;"
-"GIF;"
-"GPS;"
-"HD;"
-"HDR;"
-"HTML;"
-"HTTP;"
-"HTTPS;"
-"HUD;"
-"ID;"
-"JPG;"
-"JS;"
-"LAN;"
-"LZW;"
-"MDNS;"
-"MIDI;"
-"OS;"
-"PDF;"
-"PIN;"
-"PNG;"
-"POI;"
-"PSTN;"
-"PTR;"
-"QA;"
-"QOS;"
-"RGB;"
-"RGBA;"
-"RGBX;"
-"ROM;"
-"RPC;"
-"RTF;"
-"RTL;"
-"SDK;"
-"SSO;"
-"TCP;"
-"TIFF;"
-"TTS;"
-"UI;"
-"URI;"
-"URL;"
-"VC;"
-"VOIP;"
-"VPN;"
-"VR;"
-"WAN;"
-"XML";
+constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = {
+"ACL",
+"API",
+"ARGB",
+"ASCII",
+"BGRA",
+"CMYK",
+"DNS",
+"FPS",
+"FTP",
+"GIF",
+"GPS",
+"HD",
+"HDR",
+"HTML",
+"HTTP",
+"HTTPS",
+"HUD",
+"ID",
+"JPG",
+"JS",
+"LAN",
+"LZW",
+"MDNS",
+"MIDI",
+"OS",
+"PDF",
+"PIN",
+"PNG",
+"POI",
+"PSTN",
+"PTR",
+"QA",
+"QOS",
+"RGB",
+"RGBA",
+"RGBX",
+"ROM",
+"RPC",
+"RTF",
+"RTL",
+"SDK",
+"SSO",
+"TCP",
+"TIFF",
+"TTS",
+"UI",
+"URI",
+"URL",
+"VC",
+"VOIP",
+"VPN",
+"VR",
+"WAN",
+"XML",
+};
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -97,14 +99,7 @@
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector ) {
-  std::vector EscapedAcronyms;
-  EscapedAcronyms.reserve(Acronyms.size());
-  // In case someone defines a custom prefix which includes a regex
-  // special character, escape all the prefixes.
-  std::transform(Acronyms.begin(), Acronyms.end(),
- std::back_inserter(EscapedAcronyms), [](const std::string& s) {
-   return llvm::Regex::escape(s); });
+std::string validPropertyNameRegex(const std::vector ) {
   // Allow any of these names:
   // foo
   // fooBar
@@ -123,15 +118,32 @@
 PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  SpecialAcronyms(utils::options::parseStringList(
-  Options.get("Acronyms", DefaultSpecialAcronyms))) {}
+  SpecialAcronyms(
+  utils::options::parseStringList(Options.get("Acronyms", ""))),
+  IncludeDefaultAcronyms(Options.get("IncludeDefaultAcronyms", true)) {}
 
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+  std::vector EscapedAcronyms;
+  if (IncludeDefaultAcronyms) {
+EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
+SpecialAcronyms.size());
+// No need to regex-escape the 

[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D41311



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


[PATCH] D42372: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

2018-01-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir abandoned this revision.
krasimir added a comment.

Superseded by https://reviews.llvm.org/D42376


Repository:
  rC Clang

https://reviews.llvm.org/D42372



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


[PATCH] D42372: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

2018-01-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Thanks! I created https://reviews.llvm.org/D42376 which does the same in a much 
simpler way!


Repository:
  rC Clang

https://reviews.llvm.org/D42372



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


[clang-tools-extra] r323130 - [clang-tidy objc-property-declaration] New option IncludeDefaultAcronyms

2018-01-22 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Mon Jan 22 07:45:25 2018
New Revision: 323130

URL: http://llvm.org/viewvc/llvm-project?rev=323130=rev
Log:
[clang-tidy objc-property-declaration] New option IncludeDefaultAcronyms

Summary:
The existing option objc-property-declaration.Acronyms
replaces the built-in set of acronyms.

While this behavior is OK for clients that don't want the default
behavior, many clients may just want to add their own custom acronyms
to the default list.

This revision introduces a new option,
objc-property-declaration.IncludeDefaultAcronyms, which controls
whether the acronyms in objc-property-declaration.Acronyms are
appended to the default list (the default behavior) or whether they
replace.

I also updated the documentation.

Test Plan: make -j12 check-clang-tools

Reviewers: Wizard, hokein, klimek

Reviewed By: hokein

Subscribers: Eugene.Zelenko, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-additional.m
  - copied, changed from r323112, 
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m
Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration-custom.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=323130=323129=323130=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Mon 
Jan 22 07:45:25 2018
@@ -11,6 +11,7 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -26,61 +27,62 @@ namespace {
 /// 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
 ///
 /// Keep this list sorted.
-constexpr char DefaultSpecialAcronyms[] =
-"ACL;"
-"API;"
-"ARGB;"
-"ASCII;"
-"BGRA;"
-"CMYK;"
-"DNS;"
-"FPS;"
-"FTP;"
-"GIF;"
-"GPS;"
-"HD;"
-"HDR;"
-"HTML;"
-"HTTP;"
-"HTTPS;"
-"HUD;"
-"ID;"
-"JPG;"
-"JS;"
-"LAN;"
-"LZW;"
-"MDNS;"
-"MIDI;"
-"OS;"
-"PDF;"
-"PIN;"
-"PNG;"
-"POI;"
-"PSTN;"
-"PTR;"
-"QA;"
-"QOS;"
-"RGB;"
-"RGBA;"
-"RGBX;"
-"ROM;"
-"RPC;"
-"RTF;"
-"RTL;"
-"SDK;"
-"SSO;"
-"TCP;"
-"TIFF;"
-"TTS;"
-"UI;"
-"URI;"
-"URL;"
-"VC;"
-"VOIP;"
-"VPN;"
-"VR;"
-"WAN;"
-"XML";
+constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = {
+"ACL",
+"API",
+"ARGB",
+"ASCII",
+"BGRA",
+"CMYK",
+"DNS",
+"FPS",
+"FTP",
+"GIF",
+"GPS",
+"HD",
+"HDR",
+"HTML",
+"HTTP",
+"HTTPS",
+"HUD",
+"ID",
+"JPG",
+"JS",
+"LAN",
+"LZW",
+"MDNS",
+"MIDI",
+"OS",
+"PDF",
+"PIN",
+"PNG",
+"POI",
+"PSTN",
+"PTR",
+"QA",
+"QOS",
+"RGB",
+"RGBA",
+"RGBX",
+"ROM",
+"RPC",
+"RTF",
+"RTL",
+"SDK",
+"SSO",
+"TCP",
+"TIFF",
+"TTS",
+"UI",
+"URI",
+"URL",
+"VC",
+"VOIP",
+"VPN",
+"VR",
+"WAN",
+"XML",
+};
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to
@@ -97,14 +99,7 @@ FixItHint generateFixItHint(const ObjCPr
   return FixItHint();
 }
 
-std::string validPropertyNameRegex(const std::vector ) {
-  std::vector EscapedAcronyms;
-  EscapedAcronyms.reserve(Acronyms.size());
-  // In case someone defines a custom prefix which includes a regex
-  // special character, escape all the prefixes.
-  std::transform(Acronyms.begin(), Acronyms.end(),
- std::back_inserter(EscapedAcronyms), [](const std::string& s) 
{
-   return llvm::Regex::escape(s); });
+std::string validPropertyNameRegex(const std::vector 
) {
   // Allow any of these names:
   // foo
   // fooBar
@@ -123,15 +118,32 @@ std::string validPropertyNameRegex(const
 PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  SpecialAcronyms(utils::options::parseStringList(
-  Options.get("Acronyms", DefaultSpecialAcronyms))) {}
+  SpecialAcronyms(
+ 

[PATCH] D42376: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

2018-01-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rC Clang

https://reviews.llvm.org/D42376

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestTextProto.cpp


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -290,5 +290,17 @@
"  product_data \n"
">");
 }
+
+TEST_F(FormatTestTextProto, DiscardsUnbreakableTailIfCanBreakAfter) {
+  // The two closing braces count towards the string UnbreakableTailLength, but
+  // since we have broken after the corresponding opening braces, we don't
+  // consider that length for string breaking.
+  verifyFormat(
+  "foo: {\n"
+  "  bar: {\n"
+  "text: \"\"\n"
+  "  }\n"
+  "}");
+}
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1576,9 +1576,12 @@
   Text.startswith(Prefix = "u8\"") ||
   Text.startswith(Prefix = "L\""))) ||
 (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) 
{
+  unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+   ? 0
+   : Current.UnbreakableTailLength;
   return llvm::make_unique(
-  Current, StartColumn, Prefix, Postfix, State.Line->InPPDirective,
-  Encoding, Style);
+  Current, StartColumn, Prefix, Postfix, UnbreakableTailLength,
+  State.Line->InPPDirective, Encoding, Style);
 }
   } else if (Current.is(TT_BlockComment)) {
 if (!Style.ReflowComments ||
Index: lib/Format/BreakableToken.h
===
--- lib/Format/BreakableToken.h
+++ lib/Format/BreakableToken.h
@@ -238,8 +238,8 @@
   /// after formatting.
   BreakableStringLiteral(const FormatToken , unsigned StartColumn,
  StringRef Prefix, StringRef Postfix,
- bool InPPDirective, encoding::Encoding Encoding,
- const FormatStyle );
+ unsigned UnbreakableTailLength, bool InPPDirective,
+ encoding::Encoding Encoding, const FormatStyle 
);
 
   Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit,
  unsigned ReflowColumn,
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -214,11 +214,11 @@
 
 BreakableStringLiteral::BreakableStringLiteral(
 const FormatToken , unsigned StartColumn, StringRef Prefix,
-StringRef Postfix, bool InPPDirective, encoding::Encoding Encoding,
-const FormatStyle )
+StringRef Postfix, unsigned UnbreakableTailLength, bool InPPDirective,
+encoding::Encoding Encoding, const FormatStyle )
 : BreakableToken(Tok, InPPDirective, Encoding, Style),
   StartColumn(StartColumn), Prefix(Prefix), Postfix(Postfix),
-  UnbreakableTailLength(Tok.UnbreakableTailLength) {
+  UnbreakableTailLength(UnbreakableTailLength) {
   assert(Tok.TokenText.startswith(Prefix) && Tok.TokenText.endswith(Postfix));
   Line = Tok.TokenText.substr(
   Prefix.size(), Tok.TokenText.size() - Prefix.size() - Postfix.size());


Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -290,5 +290,17 @@
"  product_data \n"
">");
 }
+
+TEST_F(FormatTestTextProto, DiscardsUnbreakableTailIfCanBreakAfter) {
+  // The two closing braces count towards the string UnbreakableTailLength, but
+  // since we have broken after the corresponding opening braces, we don't
+  // consider that length for string breaking.
+  verifyFormat(
+  "foo: {\n"
+  "  bar: {\n"
+  "text: \"\"\n"
+  "  }\n"
+  "}");
+}
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1576,9 +1576,12 @@
   Text.startswith(Prefix = "u8\"") ||
   Text.startswith(Prefix = "L\""))) ||
 (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) {
+  unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+   

[PATCH] D41553: Support parsing double square-bracket attributes in ObjC

2018-01-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/Attr.td:239
+  bit IncludeC = includeC;
+}
 

aaron.ballman wrote:
> rjmccall wrote:
> > aaron.ballman wrote:
> > > rjmccall wrote:
> > > > aaron.ballman wrote:
> > > > > rjmccall wrote:
> > > > > > I have no objection to allowing ObjC attributes to be spelled in 
> > > > > > [[clang::objc_whatever]] style.  We can debate giving them a more 
> > > > > > appropriate standard name in the objc namespace at a later time — 
> > > > > > or even the primary namespace, if we really want to flex our 
> > > > > > Somewhat Major Language muscles.
> > > > > > 
> > > > > > I feel like this IncludeC is not the best name for this tablegen 
> > > > > > property.  Perhaps AllowInC?
> > > > > > 
> > > > > > Also, a random positional 1 argument is pretty obscure TableGen 
> > > > > > design.  Do we really expect to be making very many attributes that 
> > > > > > intentionally disallow C2x?  What would these be, just C++-specific 
> > > > > > attributes without C analogues?  It doesn't seem important to 
> > > > > > prohibit those at the parsing level rather than at the semantic 
> > > > > > level, since, after all, we are still allowing the GNU-style 
> > > > > > spelling, and these would still qualified with ``clang::``.
> > > > > > 
> > > > > > I would suggest standardizing in the opposite direction:  instead 
> > > > > > of forcing attributes to opt in to being allowed in C, we should 
> > > > > > make attributes that we really don't want to allow in the C2x 
> > > > > > [[clang::]] namespace be explicit about it.  If there are a lot of 
> > > > > > C++-specific attributes like that, we can make a ClangCXXOnly 
> > > > > > subclass.
> > > > > > I have no objection to allowing ObjC attributes to be spelled in 
> > > > > > [[clang::objc_whatever]] style. We can debate giving them a more 
> > > > > > appropriate standard name in the objc namespace at a later time — 
> > > > > > or even the primary namespace, if we really want to flex our 
> > > > > > Somewhat Major Language muscles.
> > > > > 
> > > > > Thanks -- are you okay with where the attributes are allowed in the 
> > > > > syntax? I tried to follow the position they're allowed in C and C++ 
> > > > > as closely as I could, but having confirmation would be nice.
> > > > > 
> > > > > As for putting the attributes in the primary namespace, that would be 
> > > > > reasonable for using the attributes in ObjC or ObjC++ but not so much 
> > > > > for using the same attributes in a pure C or C++ compilation.
> > > > > 
> > > > > > I feel like this IncludeC is not the best name for this tablegen 
> > > > > > property. Perhaps AllowInC?
> > > > > 
> > > > > I'm fine with that name. I'll change it in D41317 when I commit that.
> > > > > 
> > > > > > Also, a random positional 1 argument is pretty obscure TableGen 
> > > > > > design. Do we really expect to be making very many attributes that 
> > > > > > intentionally disallow C2x? What would these be, just C++-specific 
> > > > > > attributes without C analogues? 
> > > > > 
> > > > > I agree -- I was toying with using a named entity rather than a 
> > > > > numeric literal, but I wanted to see how the design shook out in 
> > > > > practice once I had a better feel for how many attributes are 
> > > > > impacted. I'm glad you recommend going the opposite direction as that 
> > > > > was my ultimate goal. :-) Basically, my initial approach is to 
> > > > > disallow everything in C and then start enabling the attributes that 
> > > > > make sense. At some point, I believe we'll have more attributes in 
> > > > > both language modes than not, and then I plan to reverse the meaning 
> > > > > of the flag so that an attribute has to opt-out rather than opt-in. I 
> > > > > don't expect we'll have many attributes that are disallowed in C2x. I 
> > > > > think they'll fall into two categories: C++ attributes that don't 
> > > > > make sense in C and attributes that are governed by some other body.
> > > > > 
> > > > > > It doesn't seem important to prohibit those at the parsing level 
> > > > > > rather than at the semantic level, since, after all, we are still 
> > > > > > allowing the GNU-style spelling, and these would still qualified 
> > > > > > with `clang::`.
> > > > > 
> > > > > I think it's important for C targets when 
> > > > > `-fdouble-square-bracket-attributes` is not enabled, as the 
> > > > > attributes cannot syntactically appear in those positions.
> > > > > 
> > > > > > I would suggest standardizing in the opposite direction
> > > > > 
> > > > > I suspect I will ultimately get there. I chose this approach to be 
> > > > > more conservative about what we expose.
> > > > > Thanks -- are you okay with where the attributes are allowed in the 
> > > > > syntax? I tried to follow the position they're allowed in C and C++ 
> > > > > as closely as I could, but having confirmation would be nice.
> > > > 
> > > > I'll leave 

[PATCH] D42349: [DOCS] Mention OpenMP Tools Interface in runtime library

2018-01-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D42349#983611, @hans wrote:

> In https://reviews.llvm.org/D42349#983180, @Hahnfeld wrote:
>
> > @hans I'd also like to merge this to `release_60` because the support 
> > landed before the branching. Is this ok?
>
>
> Sounds good to me. Go ahead and merge, or let me know and I'll do it.


Merge in r323128.


Repository:
  rC Clang

https://reviews.llvm.org/D42349



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


[PATCH] D42372: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

2018-01-22 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I think I understand now. I think I'd prefer pulling all of the "+ 
UnbreakableTailLength" calculations out of getRemainingLength so that you don't 
have to pass around the new parameter CanBreakAfter. Instead, only add it if 
necessary outside of the function.




Comment at: lib/Format/BreakableToken.cpp:503
+   bool CanBreakAfter) const {
   return UnbreakableTailLength +
  getRangeLength(LineIndex, Offset, StringRef::npos, StartColumn);

Forgot to check CanBreakAfter here?


Repository:
  rC Clang

https://reviews.llvm.org/D42372



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


  1   2   >