[PATCH] D40024: Fix skipping of flags in getClangStripDependencyFileAdjuster

2017-11-15 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 123131.
kastiglione added a comment.

Add tests


https://reviews.llvm.org/D40024

Files:
  lib/Tooling/ArgumentsAdjusters.cpp
  unittests/Tooling/ToolingTest.cpp


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,6 +402,37 @@
   EXPECT_FALSE(Found);
 }
 
+// Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
+TEST(ClangToolTest, StripDependencyFileAdjuster) {
+  FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+[](const CommandLineArguments , StringRef /*unused*/) {
+  FinalArgs = Args;
+  return Args;
+};
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [](const std::string ) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-MD"));
+  EXPECT_FALSE(HasFlag("-MMD"));
+  EXPECT_TRUE(HasFlag("-c"));
+  EXPECT_TRUE(HasFlag("-w"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same target. We expect that there is at least one target
Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -58,14 +58,14 @@
   StringRef Arg = Args[i];
   // All dependency-file options begin with -M. These include -MM,
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M"))
+  if (!Arg.startswith("-M")) {
 AdjustedArgs.push_back(Args[i]);
+continue;
+  }
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -402,6 +402,37 @@
   EXPECT_FALSE(Found);
 }
 
+// Check getClangStripDependencyFileAdjuster doesn't strip args after -MD/-MMD.
+TEST(ClangToolTest, StripDependencyFileAdjuster) {
+  FixedCompilationDatabase Compilations("/", {"-MD", "-c", "-MMD", "-w"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+[](const CommandLineArguments , StringRef /*unused*/) {
+  FinalArgs = Args;
+  return Args;
+};
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [](const std::string ) {
+return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
+   FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("-MD"));
+  EXPECT_FALSE(HasFlag("-MMD"));
+  EXPECT_TRUE(HasFlag("-c"));
+  EXPECT_TRUE(HasFlag("-w"));
+}
+
 namespace {
 /// Find a target name such that looking for it in TargetRegistry by that name
 /// returns the same target. We expect that there is at least one target
Index: lib/Tooling/ArgumentsAdjusters.cpp
===
--- lib/Tooling/ArgumentsAdjusters.cpp
+++ lib/Tooling/ArgumentsAdjusters.cpp
@@ -58,14 +58,14 @@
   StringRef Arg = Args[i];
   // All dependency-file options begin with -M. These include -MM,
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M"))
+  if (!Arg.startswith("-M")) {
 AdjustedArgs.push_back(Args[i]);
+continue;
+  }
 
-  if ((Arg == "-MF") || (Arg == "-MT") || (Arg == "-MQ") ||
-  (Arg == "-MD") || (Arg == "-MMD")) {
-// Output is specified as -MX foo. Skip the next argument also.
+  if (Arg == "-MF" || Arg == "-MT" || Arg == "-MQ")
+// These flags take an argument: -MX foo. Skip the next argument also.
 ++i;
-  }
 }
 return AdjustedArgs;
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D39632: [libunwind] [docs] Mention that dwarf unwinding should be supported on arm64/windows

2017-11-15 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318383: [docs] Mention that dwarf unwinding should be 
supported on arm64/windows (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D39632?vs=121601=123130#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39632

Files:
  libunwind/trunk/docs/index.rst


Index: libunwind/trunk/docs/index.rst
===
--- libunwind/trunk/docs/index.rst
+++ libunwind/trunk/docs/index.rst
@@ -41,19 +41,19 @@
 
 libunwind is known to work on the following platforms:
 
-   
-OS   Arch CompilersUnwind Info
-   
-Any  i386, x86_64, ARMClangSjLj
-Bare Metal   ARM  Clang, GCC   EHABI
-FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
-iOS  ARM  ClangSjLj
-LinuxARM  Clang, GCC   EHABI
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
-NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386, x86_64, ARMClangDWARF CFI
-   
+   
+OS   Arch CompilersUnwind Info
+   
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
+iOS  ARM  ClangSjLj
+LinuxARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+NetBSD   x86_64   Clang, GCC   DWARF CFI
+Windows  i386, x86_64, ARM, ARM64 ClangDWARF CFI
+   
 
 The following minimum compiler versions are strongly recommended.
 


Index: libunwind/trunk/docs/index.rst
===
--- libunwind/trunk/docs/index.rst
+++ libunwind/trunk/docs/index.rst
@@ -41,19 +41,19 @@
 
 libunwind is known to work on the following platforms:
 
-   
-OS   Arch CompilersUnwind Info
-   
-Any  i386, x86_64, ARMClangSjLj
-Bare Metal   ARM  Clang, GCC   EHABI
-FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
-iOS  ARM  ClangSjLj
-LinuxARM  Clang, GCC   EHABI
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
-NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386, x86_64, ARMClangDWARF CFI
-   
+   
+OS   Arch CompilersUnwind Info
+   
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
+iOS  ARM  ClangSjLj
+LinuxARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+NetBSD   x86_64   Clang, GCC   DWARF CFI
+Windows  i386, x86_64, ARM, ARM64 ClangDWARF CFI
+   
 
 The following minimum compiler versions are strongly recommended.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r318383 - [docs] Mention that dwarf unwinding should be supported on arm64/windows

2017-11-15 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Nov 15 23:16:36 2017
New Revision: 318383

URL: http://llvm.org/viewvc/llvm-project?rev=318383=rev
Log:
[docs] Mention that dwarf unwinding should be supported on arm64/windows

This didn't require any further changes to libunwind as long as win64
in general is handled correctly.

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

Modified:
libunwind/trunk/docs/index.rst

Modified: libunwind/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/index.rst?rev=318383=318382=318383=diff
==
--- libunwind/trunk/docs/index.rst (original)
+++ libunwind/trunk/docs/index.rst Wed Nov 15 23:16:36 2017
@@ -41,19 +41,19 @@ Platform and Compiler Support
 
 libunwind is known to work on the following platforms:
 
-   
-OS   Arch CompilersUnwind Info
-   
-Any  i386, x86_64, ARMClangSjLj
-Bare Metal   ARM  Clang, GCC   EHABI
-FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
-iOS  ARM  ClangSjLj
-LinuxARM  Clang, GCC   EHABI
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
-NetBSD   x86_64   Clang, GCC   DWARF CFI
-Windows  i386, x86_64, ARMClangDWARF CFI
-   
+   
+OS   Arch CompilersUnwind Info
+   
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
+iOS  ARM  ClangSjLj
+LinuxARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+NetBSD   x86_64   Clang, GCC   DWARF CFI
+Windows  i386, x86_64, ARM, ARM64 ClangDWARF CFI
+   
 
 The following minimum compiler versions are strongly recommended.
 


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


[libcxx] r318378 - More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in filesystem::path

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 21:48:32 2017
New Revision: 318378

URL: http://llvm.org/viewvc/llvm-project?rev=318378=rev
Log:
More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in 
filesystem::path

Added:

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/empty.fail.cpp
Modified:
libcxx/trunk/include/experimental/filesystem

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=318378=318377=318378=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Wed Nov 15 21:48:32 2017
@@ -972,7 +972,8 @@ public:
 _LIBCPP_INLINE_VISIBILITY path extension()  const { return 
string_type(__extension()); }
 
 // query
-_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return 
__pn_.empty(); }
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 
+bool empty() const _NOEXCEPT { return __pn_.empty(); }
 
 _LIBCPP_INLINE_VISIBILITY bool has_root_name()  const { return 
!__root_name().empty(); }
 _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return 
!__root_directory().empty(); }

Added: 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/empty.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/empty.fail.cpp?rev=318378=auto
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/empty.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/empty.fail.cpp
 Wed Nov 15 21:48:32 2017
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// class path
+
+// bool empty() const noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+
+#include 
+
+#include "test_macros.h"
+
+int main ()
+{
+std::experimental::filesystem::path c;
+c.empty();  // expected-error {{ignoring return value of function declared 
with 'nodiscard' attribute}}
+}

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp?rev=318378=318377=318378=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
 Wed Nov 15 21:48:32 2017
@@ -177,7 +177,8 @@ void decompFilenameTest()
   for (auto const & TC : FilenameTestCases) {
 path p(TC.raw);
 assert(p == TC.raw);
-
+ASSERT_NOEXCEPT(p.empty());
+
 assert(p.filename() == TC.filename);
 assert(p.has_filename() != TC.filename.empty());
 


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


[libcxx] r318375 - More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in match_results.

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 20:48:34 2017
New Revision: 318375

URL: http://llvm.org/viewvc/llvm-project?rev=318375=rev
Log:
More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in 
match_results. 

Added:
libcxx/trunk/test/std/re/re.results/re.results.size/empty.fail.cpp
Modified:
libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=318375=318374=318375=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Wed Nov 15 20:48:34 2017
@@ -5240,11 +5240,11 @@ public:
 
 // size:
 _LIBCPP_INLINE_VISIBILITY
-size_type size() const {return __matches_.size();}
+size_type size() const _NOEXCEPT {return __matches_.size();}
 _LIBCPP_INLINE_VISIBILITY
-size_type max_size() const {return __matches_.max_size();}
-_LIBCPP_INLINE_VISIBILITY
-bool empty() const {return size() == 0;}
+size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+bool empty() const _NOEXCEPT {return size() == 0;}
 
 // element access:
 _LIBCPP_INLINE_VISIBILITY

Added: libcxx/trunk/test/std/re/re.results/re.results.size/empty.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.results/re.results.size/empty.fail.cpp?rev=318375=auto
==
--- libcxx/trunk/test/std/re/re.results/re.results.size/empty.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.results/re.results.size/empty.fail.cpp Wed Nov 
15 20:48:34 2017
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// class match_results
+// bool empty() const;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+
+#include 
+
+#include "test_macros.h"
+
+int main ()
+{
+std::match_results c;
+c.empty();  // expected-error {{ignoring return value of function declared 
with 'nodiscard' attribute}}
+}


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


[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2017-11-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

And, btw, sorry for the long delay. I've been on travelling / on vacation for 
the last few weeks.


https://reviews.llvm.org/D38171



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


[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2017-11-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D38171#925929, @xazax.hun wrote:

> In https://reviews.llvm.org/D38171#909346, @leanil wrote:
>
> > In https://reviews.llvm.org/D38171#901427, @xazax.hun wrote:
> >
> > > One problem to think about when we add all clang-diagnostic as "first or 
> > > second" class citizen, `checkes=*` might now enable all the warnings 
> > > which make no sense and might be surprising to the users. What do you 
> > > think?
> >
> >
> > This is a good point. Should I insert ",-clang-diagnostic*" after any 
> > (positive) * ?
>
>
> @alexfh do you have some thoughts on this?


I don't think this particular point is a large concern. As I mentioned multiple 
times, enabling all checks is almost never useful due to many checks 
overlapping or producing conflicting advice. The only place I can think of, 
where -checks=* is useful is in combination with -list-checks, where the 
presence of clang-diagnostic- entries would be desired anyway.


https://reviews.llvm.org/D38171



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


r318371 - Add NDEBUG checks around LLVM_DUMP_METHOD functions for Wunused-function warnings.

2017-11-15 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Nov 15 19:18:09 2017
New Revision: 318371

URL: http://llvm.org/viewvc/llvm-project?rev=318371=rev
Log:
Add NDEBUG checks around LLVM_DUMP_METHOD functions for Wunused-function 
warnings.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp?rev=318371=318370=318371=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp Wed Nov 15 
19:18:09 2017
@@ -259,6 +259,7 @@ void ArrayBoundCheckerV2::reportOOB(Chec
   llvm::make_unique(*BT, os.str(), errorNode));
 }
 
+#ifndef NDEBUG
 LLVM_DUMP_METHOD void RegionRawOffsetV2::dump() const {
   dumpToStream(llvm::errs());
 }
@@ -266,7 +267,7 @@ LLVM_DUMP_METHOD void RegionRawOffsetV2:
 void RegionRawOffsetV2::dumpToStream(raw_ostream ) const {
   os << "raw_offset_v2{" << getRegion() << ',' << getByteOffset() << '}';
 }
-
+#endif
 
 // Lazily computes a value to be used by 'computeOffset'.  If 'val'
 // is unknown or undefined, we lazily substitute '0'.  Otherwise,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=318371=318370=318371=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed Nov 15 19:18:09 2017
@@ -134,7 +134,9 @@ namespace llvm {
   };
 } // end llvm namespace
 
+#ifndef NDEBUG
 LLVM_DUMP_METHOD void BindingKey::dump() const { llvm::errs() << *this; }
+#endif
 
 
//===--===//
 // Actual Store type.


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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention new module in docs/clang-tidy/index.rst.


Repository:
  rL LLVM

https://reviews.llvm.org/D40108



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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/fuchsia/FuchsiaTidyModule.cpp:31
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+
+CheckFactories.registerCheck(

Please remove empty line.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:100
+Result.Nodes.getNodeAs("decl")) {
+
+// Check against map to see if if the class inherits from multiple 

Please remove empty line.



Comment at: docs/ReleaseNotes.rst:63
+
+  Check to prevent multiple inheritance in Fuchsia.
+

//Check to// should be removed, just //Prevent//. Same in other places.


Repository:
  rL LLVM

https://reviews.llvm.org/D40108



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


[PATCH] D39994: Loosen MSVC 2017 path requirements

2017-11-15 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

I'm not suuuper opposed, but at the same time if this code is bothering people 
(and it is, consistently), I don't changing the requirements from "confusing 
rule A" to "confusing rule B" is going to solve the long term burden that 
people keep running into.

Not asking you to do this work, but my ideal solution is probably to teach 
clang-cl to recognize 3 new environment variables.

`CLANGCL_MSVC_BIN` - Where to look for `cl.exe`, and `link.exe`. Under no 
circumstances do we consult `PATH` or anything else.  This is only used when we 
need to fallback to `cl` (rarely, anymore) or when the compiler needs to invoke 
the linker.   But!  At the same time we make `-fuse-ld=lld` the default.  We 
only do something else if the user specifies `-fuse-ld=link`, and in that case 
it uses `CLANGCL_MSVC_BIN` (or if you specified `-fuse-ld=` then the 
env var isn't needed).

`CLANGCL_WINSDK` - Points to the root of the Windows SDK.  The folder here 
should have a "standard" layout so that it least pretends to be an 
installation, so that we can find the right lib directory when cross-compiling.

`CLANGCL_MSVCRT` - Same as before, but for the CRT.

I would honestly like to delete just about 100% of this stuff about finding 
MSVC.  We should just use exactly what we're told to use and nothing else.  
Simple, easy to understand, and easy to explain.

Anyway, I'm just venting.  If rnk@ wants to lgtm this, I'm fine.


https://reviews.llvm.org/D39994



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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please split this review with one check per review.




Comment at: docs/ReleaseNotes.rst:83
+
+  Check to prevent creation of  statically-stored objects in Fuchsia.
+

Please fix double space



Comment at: docs/clang-tidy/checks/fuchsia-default-arguments.rst:8
+
+Ex. The declaration:
+

Please don't use abbreviations. Same in other places.



Comment at: docs/clang-tidy/checks/fuchsia-default-arguments.rst:19
+a warning:
+.. code-block:: c++
+

Please insert empty line above.



Comment at: docs/clang-tidy/checks/fuchsia-statically-constructed-objects.rst:7
+Warns if statically-stored objects are created, unless constructed
+with constexpr.
+

Please highlight constexpr with ``. Same in other places.



Comment at: docs/clang-tidy/checks/fuchsia-thread-local.rst:6
+
+Warns if thread-local storage is used.
+

Please highlight thread-local and extern with ``. Same in other places.


Repository:
  rL LLVM

https://reviews.llvm.org/D40108



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


[PATCH] D40109: [MS] Apply adjustments after storing 'this'

2017-11-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This seems to cause a crash on startup in some gtest binaries when I self-host, 
so I guess I should debug that tomorrow before committing. The rest of clang's 
tests pass. I guess we don't use virtual inheritance. =S


https://reviews.llvm.org/D40109



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


[clang-tools-extra] r318366 - add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Wed Nov 15 17:28:29 2017
New Revision: 318366

URL: http://llvm.org/viewvc/llvm-project?rev=318366=rev
Log:
add check to avoid throwing objc exception according to Google Objective-C guide

Summary:
This is a small check to avoid throwing objc exceptions.
In specific it will detect the usage of @throw statement and throw warning.

Reviewers: hokein, benhamilton

Reviewed By: hokein, benhamilton

Subscribers: cfe-commits, mgorny

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

Added:

clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst

clang-tools-extra/trunk/test/clang-tidy/google-objc-avoid-throwing-exception.m
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Added: 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp?rev=318366=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
Wed Nov 15 17:28:29 2017
@@ -0,0 +1,47 @@
+//===--- AvoidThrowingObjCExceptionCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidThrowingObjCExceptionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+  Finder->addMatcher(
+  objcMessageExpr(anyOf(hasSelector("raise:format:"),
+hasSelector("raise:format:arguments:")),
+  hasReceiverType(asString("NSException")))
+  .bind("raiseException"),
+  this);
+}
+
+void AvoidThrowingObjCExceptionCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *MatchedStmt =
+  Result.Nodes.getNodeAs("throwStmt");
+  const auto *MatchedExpr =
+  Result.Nodes.getNodeAs("raiseException");
+  auto SourceLoc = MatchedStmt == nullptr ? MatchedExpr->getSelectorStartLoc()
+  : MatchedStmt->getThrowLoc();
+  diag(SourceLoc,
+   "pass in NSError ** instead of throwing exception to indicate "
+   "Objective-C errors");
+}
+
+}  // namespace objc
+}  // namespace google
+}  // namespace tidy
+}  // namespace clang

Added: 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h?rev=318366=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h 
(added)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h 
Wed Nov 15 17:28:29 2017
@@ -0,0 +1,39 @@
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+/// The check is to find usage of @throw invocation in Objective-C code.
+/// We should avoid using @throw for Objective-C exceptions according to
+/// the Google Objective-C Style Guide.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/google-objc-avoid-throwing-exception.html
+class AvoidThrowingObjCExceptionCheck : public ClangTidyCheck {
+ public:
+  AvoidThrowingObjCExceptionCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void 

r318367 - [DeclPrinter] Extract function PrintConstructorInitializers, NFC

2017-11-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov 15 17:31:27 2017
New Revision: 318367

URL: http://llvm.org/viewvc/llvm-project?rev=318367=rev
Log:
[DeclPrinter] Extract function PrintConstructorInitializers, NFC

Patch by Nikolai Kosjar!

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=318367=318366=318367=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed Nov 15 17:31:27 2017
@@ -37,6 +37,8 @@ namespace {
 void ProcessDeclGroup(SmallVectorImpl& Decls);
 
 void Print(AccessSpecifier AS);
+void PrintConstructorInitializers(CXXConstructorDecl *CDecl,
+  std::string );
 
 /// Print an Objective-C method type in parentheses.
 ///
@@ -274,6 +276,71 @@ void DeclPrinter::Print(AccessSpecifier
   }
 }
 
+void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
+   std::string ) {
+  bool HasInitializerList = false;
+  for (const auto *BMInitializer : CDecl->inits()) {
+if (BMInitializer->isInClassMemberInitializer())
+  continue;
+
+if (!HasInitializerList) {
+  Proto += " : ";
+  Out << Proto;
+  Proto.clear();
+  HasInitializerList = true;
+} else
+  Out << ", ";
+
+if (BMInitializer->isAnyMemberInitializer()) {
+  FieldDecl *FD = BMInitializer->getAnyMember();
+  Out << *FD;
+} else {
+  Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
+}
+
+Out << "(";
+if (!BMInitializer->getInit()) {
+  // Nothing to print
+} else {
+  Expr *Init = BMInitializer->getInit();
+  if (ExprWithCleanups *Tmp = dyn_cast(Init))
+Init = Tmp->getSubExpr();
+
+  Init = Init->IgnoreParens();
+
+  Expr *SimpleInit = nullptr;
+  Expr **Args = nullptr;
+  unsigned NumArgs = 0;
+  if (ParenListExpr *ParenList = dyn_cast(Init)) {
+Args = ParenList->getExprs();
+NumArgs = ParenList->getNumExprs();
+  } else if (CXXConstructExpr *Construct =
+ dyn_cast(Init)) {
+Args = Construct->getArgs();
+NumArgs = Construct->getNumArgs();
+  } else
+SimpleInit = Init;
+
+  if (SimpleInit)
+SimpleInit->printPretty(Out, nullptr, Policy, Indentation);
+  else {
+for (unsigned I = 0; I != NumArgs; ++I) {
+  assert(Args[I] != nullptr && "Expected non-null Expr");
+  if (isa(Args[I]))
+break;
+
+  if (I)
+Out << ", ";
+  Args[I]->printPretty(Out, nullptr, Policy, Indentation);
+}
+  }
+}
+Out << ")";
+if (BMInitializer->isPackExpansion())
+  Out << "...";
+  }
+}
+
 //
 // Common C declarations
 //
@@ -608,70 +675,8 @@ void DeclPrinter::VisitFunctionDecl(Func
 }
 
 if (CDecl) {
-  if (!Policy.TerseOutput) {
-bool HasInitializerList = false;
-for (const auto *BMInitializer : CDecl->inits()) {
-  if (BMInitializer->isInClassMemberInitializer())
-continue;
-
-  if (!HasInitializerList) {
-Proto += " : ";
-Out << Proto;
-Proto.clear();
-HasInitializerList = true;
-  } else
-Out << ", ";
-
-  if (BMInitializer->isAnyMemberInitializer()) {
-FieldDecl *FD = BMInitializer->getAnyMember();
-Out << *FD;
-  } else {
-Out << QualType(BMInitializer->getBaseClass(), 0)
-   .getAsString(Policy);
-  }
-
-  Out << "(";
-  if (!BMInitializer->getInit()) {
-// Nothing to print
-  } else {
-Expr *Init = BMInitializer->getInit();
-if (ExprWithCleanups *Tmp = dyn_cast(Init))
-  Init = Tmp->getSubExpr();
-
-Init = Init->IgnoreParens();
-
-Expr *SimpleInit = nullptr;
-Expr **Args = nullptr;
-unsigned NumArgs = 0;
-if (ParenListExpr *ParenList = dyn_cast(Init)) {
-  Args = ParenList->getExprs();
-  NumArgs = ParenList->getNumExprs();
-} else if (CXXConstructExpr *Construct =
-   dyn_cast(Init)) {
-  Args = Construct->getArgs();
-  NumArgs = Construct->getNumArgs();
-} else
-  SimpleInit = Init;
-
-if (SimpleInit)
-  SimpleInit->printPretty(Out, nullptr, Policy, Indentation);
-else {
-  for (unsigned I = 0; I != NumArgs; ++I) {
-

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318366: add check to avoid throwing objc exception according 
to Google Objective-C guide (authored by Wizard).

Repository:
  rL LLVM

https://reviews.llvm.org/D40058

Files:
  clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
  clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 CheckFactories.registerCheck(
 "google-objc-global-variable-declaration");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
@@ -0,0 +1,39 @@
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+/// The check is to find usage of @throw invocation in Objective-C code.
+/// We should avoid using @throw for Objective-C exceptions according to
+/// the Google Objective-C Style Guide.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/google-objc-avoid-throwing-exception.html
+class AvoidThrowingObjCExceptionCheck : public ClangTidyCheck {
+ public:
+  AvoidThrowingObjCExceptionCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+}  // namespace objc
+}  // namespace google
+}  // namespace tidy
+}  // namespace clang
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_OBJC_AVOID_THROWING_EXCEPTION_H
Index: clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -0,0 +1,47 @@
+//===--- AvoidThrowingObjCExceptionCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidThrowingObjCExceptionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+namespace objc {
+
+void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+  Finder->addMatcher(
+  objcMessageExpr(anyOf(hasSelector("raise:format:"),
+hasSelector("raise:format:arguments:")),
+  hasReceiverType(asString("NSException")))
+  .bind("raiseException"),
+  this);
+}
+
+void AvoidThrowingObjCExceptionCheck::check(
+const MatchFinder::MatchResult ) 

r318365 - [DeclPrinter] Honor TerseOutput for constructors

2017-11-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov 15 17:28:25 2017
New Revision: 318365

URL: http://llvm.org/viewvc/llvm-project?rev=318365=rev
Log:
[DeclPrinter] Honor TerseOutput for constructors

Patch by Nikolai Kosjar!

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Index/comment-cplus-decls.cpp
cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=318365=318364=318365=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed Nov 15 17:28:25 2017
@@ -608,66 +608,69 @@ void DeclPrinter::VisitFunctionDecl(Func
 }
 
 if (CDecl) {
-  bool HasInitializerList = false;
-  for (const auto *BMInitializer : CDecl->inits()) {
-if (BMInitializer->isInClassMemberInitializer())
-  continue;
-
-if (!HasInitializerList) {
-  Proto += " : ";
-  Out << Proto;
-  Proto.clear();
-  HasInitializerList = true;
-} else
-  Out << ", ";
-
-if (BMInitializer->isAnyMemberInitializer()) {
-  FieldDecl *FD = BMInitializer->getAnyMember();
-  Out << *FD;
-} else {
-  Out << QualType(BMInitializer->getBaseClass(), 
0).getAsString(Policy);
-}
-
-Out << "(";
-if (!BMInitializer->getInit()) {
-  // Nothing to print
-} else {
-  Expr *Init = BMInitializer->getInit();
-  if (ExprWithCleanups *Tmp = dyn_cast(Init))
-Init = Tmp->getSubExpr();
-  
-  Init = Init->IgnoreParens();
-
-  Expr *SimpleInit = nullptr;
-  Expr **Args = nullptr;
-  unsigned NumArgs = 0;
-  if (ParenListExpr *ParenList = dyn_cast(Init)) {
-Args = ParenList->getExprs();
-NumArgs = ParenList->getNumExprs();
-  } else if (CXXConstructExpr *Construct
-= dyn_cast(Init)) {
-Args = Construct->getArgs();
-NumArgs = Construct->getNumArgs();
+  if (!Policy.TerseOutput) {
+bool HasInitializerList = false;
+for (const auto *BMInitializer : CDecl->inits()) {
+  if (BMInitializer->isInClassMemberInitializer())
+continue;
+
+  if (!HasInitializerList) {
+Proto += " : ";
+Out << Proto;
+Proto.clear();
+HasInitializerList = true;
   } else
-SimpleInit = Init;
-  
-  if (SimpleInit)
-SimpleInit->printPretty(Out, nullptr, Policy, Indentation);
-  else {
-for (unsigned I = 0; I != NumArgs; ++I) {
-  assert(Args[I] != nullptr && "Expected non-null Expr");
-  if (isa(Args[I]))
-break;
-  
-  if (I)
-Out << ", ";
-  Args[I]->printPretty(Out, nullptr, Policy, Indentation);
+Out << ", ";
+
+  if (BMInitializer->isAnyMemberInitializer()) {
+FieldDecl *FD = BMInitializer->getAnyMember();
+Out << *FD;
+  } else {
+Out << QualType(BMInitializer->getBaseClass(), 0)
+   .getAsString(Policy);
+  }
+
+  Out << "(";
+  if (!BMInitializer->getInit()) {
+// Nothing to print
+  } else {
+Expr *Init = BMInitializer->getInit();
+if (ExprWithCleanups *Tmp = dyn_cast(Init))
+  Init = Tmp->getSubExpr();
+
+Init = Init->IgnoreParens();
+
+Expr *SimpleInit = nullptr;
+Expr **Args = nullptr;
+unsigned NumArgs = 0;
+if (ParenListExpr *ParenList = dyn_cast(Init)) {
+  Args = ParenList->getExprs();
+  NumArgs = ParenList->getNumExprs();
+} else if (CXXConstructExpr *Construct =
+   dyn_cast(Init)) {
+  Args = Construct->getArgs();
+  NumArgs = Construct->getNumArgs();
+} else
+  SimpleInit = Init;
+
+if (SimpleInit)
+  SimpleInit->printPretty(Out, nullptr, Policy, Indentation);
+else {
+  for (unsigned I = 0; I != NumArgs; ++I) {
+assert(Args[I] != nullptr && "Expected non-null Expr");
+if (isa(Args[I]))
+  break;
+
+if (I)
+  Out << ", ";
+Args[I]->printPretty(Out, nullptr, Policy, Indentation);
+  }
 }
   }
+  Out << ")";
+  if (BMInitializer->isPackExpansion())
+Out << "...";
 }
-Out << ")";
-if (BMInitializer->isPackExpansion())
-  Out << "...";
   }
 } else if 

[PATCH] D40115: Driver: remove `SupportsObjCGC`

2017-11-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff, jfb.

This option is not used in the frontend.  Remove the method.


Repository:
  rL LLVM

https://reviews.llvm.org/D40115

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/BareMetal.h
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h


Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -49,7 +49,6 @@
   bool isPICDefaultForced() const override;
   bool IsIntegratedAssemblerDefault() const override;
   bool hasBlocksRuntime() const override;
-  bool SupportsObjCGC() const override;
   bool SupportsProfiling() const override;
   bool HasNativeLLVMSupport() const override;
   void addClangTargetOptions(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -98,9 +98,6 @@

 bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }

-// TODO: Support Objective C stuff.
-bool WebAssembly::SupportsObjCGC() const { return false; }
-
 bool WebAssembly::hasBlocksRuntime() const { return false; }

 // TODO: Support profiling.
Index: lib/Driver/ToolChains/Darwin.h
===
--- lib/Driver/ToolChains/Darwin.h
+++ lib/Driver/ToolChains/Darwin.h
@@ -245,8 +245,6 @@

   bool SupportsProfiling() const override;

-  bool SupportsObjCGC() const override { return false; }
-
   bool UseDwarfDebugFlags() const override;

   bool UseSjLjExceptions(const llvm::opt::ArgList ) const override {
@@ -455,8 +453,6 @@
 return 0;
   }

-  bool SupportsObjCGC() const override;
-
   void CheckObjCARC() const override;

   bool UseSjLjExceptions(const llvm::opt::ArgList ) const override;
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -2041,8 +2041,6 @@
   }
 }

-bool Darwin::SupportsObjCGC() const { return isTargetMacOS(); }
-
 void Darwin::CheckObjCARC() const {
   if (isTargetIOSBased() || isTargetWatchOSBased() ||
   (isTargetMacOS() && !isMacosxVersionLT(10, 6)))
Index: lib/Driver/ToolChains/Cuda.h
===
--- lib/Driver/ToolChains/Cuda.h
+++ lib/Driver/ToolChains/Cuda.h
@@ -156,7 +156,6 @@
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
-  bool SupportsObjCGC() const override { return false; }
   bool IsMathErrnoDefault() const override { return false; }

   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/BareMetal.h
===
--- lib/Driver/ToolChains/BareMetal.h
+++ lib/Driver/ToolChains/BareMetal.h
@@ -37,7 +37,6 @@
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
-  bool SupportsObjCGC() const override { return false; }

   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -366,9 +366,6 @@
   /// SupportsProfiling - Does this tool chain support -pg.
   virtual bool SupportsProfiling() const { return true; }

-  /// Does this tool chain support Objective-C garbage collection.
-  virtual bool SupportsObjCGC() const { return true; }
-
   /// Complain if this tool chain doesn't support Objective-C ARC.
   virtual void CheckObjCARC() const {}



Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -49,7 +49,6 @@
   bool isPICDefaultForced() const override;
   bool IsIntegratedAssemblerDefault() const override;
   bool hasBlocksRuntime() const override;
-  bool SupportsObjCGC() const override;
   bool SupportsProfiling() const override;
   bool HasNativeLLVMSupport() const override;
   void addClangTargetOptions(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -98,9 +98,6 @@

 bool WebAssembly::IsIntegratedAssemblerDefault() 

[PATCH] D40115: Driver: remove `SupportsObjCGC`

2017-11-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@rjmccall this is quite a straightforward change, just not sure if there is 
some use for this that I cant think of off the top of my head to preserve this.


Repository:
  rL LLVM

https://reviews.llvm.org/D40115



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


[PATCH] D40109: [MS] Apply adjustments after storing 'this'

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D40109



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


[PATCH] D39994: Loosen MSVC 2017 path requirements

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I think the patch is fine, but Zach should probably sign off on it.


https://reviews.llvm.org/D39994



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


[PATCH] D35181: Defer addition of keywords to identifier table when loading AST

2017-11-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thanks for the patch!




Comment at: lib/Frontend/ASTUnit.cpp:541
+// language.
+PP.getIdentifierTable().AddKeywords(LangOpt);
+

Have you tried adding the keywords in `PP.Initialize`? We might not need an 
additional parameter to the constructor then.


https://reviews.llvm.org/D35181



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


[PATCH] D40112: [CodeGen][X86] Fix handling of __fp16 vectors

2017-11-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
Herald added a subscriber: javed.absar.

IRGen for __fp16 vectors on X86 is currently completely broken. For example 
when the following code is compiled:

  half4 hv0, hv1, hv2; // these are vectors of __fp16.
  
  void foo221() {
hv0 = hv1 + hv2;
  }

clang generates the following IR, in which two i16 values are added:

  @hv1 = common global <4 x i16> zeroinitializer, align 8
  @hv2 = common global <4 x i16> zeroinitializer, align 8
  @hv0 = common global <4 x i16> zeroinitializer, align 8
  
  define void @foo221() {
  entry:
%0 = load <4 x i16>, <4 x i16>* @hv1, align 8
%1 = load <4 x i16>, <4 x i16>* @hv2, align 8
%add = add <4 x i16> %0, %1
store <4 x i16> %add, <4 x i16>* @hv0, align 8
ret void
  }

To fix IRGen for __fp16 vectors, this patch uses the code committed in r314056, 
which modified clang to promote and truncate __fp16 vectors to and from float 
vectors in the AST. Also, as the first step toward doing away with the __fp16 
conversion intrinsics such as @llvm.convert.to.fp16 (see 
http://lists.llvm.org/pipermail/llvm-dev/2014-July/074689.html),  I made 
changes to IRGen for __fp16 scalars so that fpext/fptrunc instructions are 
emitted instead of the __fp16 conversion intrinsics IRGen currently emits. This 
fixes another IRGen bug where a short value is assigned to an __fp16 variable 
without any integer-to-floating-point conversion, as shown in the following 
example:

C code
--

  __fp16 a;
  short b;
  
  void foo1() {
a = b;
  }



generated IR


  @b = common global i16 0, align 2
  @a = common global i16 0, align 2
  
  define void @foo1() #0 {
  entry:
%0 = load i16, i16* @b, align 2
store i16 %0, i16* @a, align 2
ret void
  }

I haven't spent too much time inspecting the code the X86 backend emits, but 
the code I've seen so far seems at least functionally correct (although it 
doesn't look very efficient since the backend scalarizes __fp16 vectors).


https://reviews.llvm.org/D40112

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/fp16-ops.c
  test/CodeGen/fp16vec-ops.c
  test/CodeGenCXX/float16-declarations.cpp
  test/CodeGenCXX/fp16-mangle.cpp

Index: test/CodeGenCXX/fp16-mangle.cpp
===
--- test/CodeGenCXX/fp16-mangle.cpp
+++ test/CodeGenCXX/fp16-mangle.cpp
@@ -4,9 +4,9 @@
 template  struct S { static int i; };
 template <> int S<__fp16, __fp16>::i = 3;
 
-// CHECK-LABEL: define void @_Z1fPDh(i16* %x)
+// CHECK-LABEL: define void @_Z1fPDh(half* %x)
 void f (__fp16 *x) { }
 
-// CHECK-LABEL: define void @_Z1gPDhS_(i16* %x, i16* %y)
+// CHECK-LABEL: define void @_Z1gPDhS_(half* %x, half* %y)
 void g (__fp16 *x, __fp16 *y) { }
 
Index: test/CodeGenCXX/float16-declarations.cpp
===
--- test/CodeGenCXX/float16-declarations.cpp
+++ test/CodeGenCXX/float16-declarations.cpp
@@ -11,16 +11,14 @@
 // CHECK-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global half 0xH, align 2
 
   _Float16 f2n = 33.f16;
-// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global half 0xH5020, align 2
-// CHECK-X86-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global i16 20512, align 2
+// CHECK-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global half 0xH5020, align 2
 
   _Float16 arr1n[10];
 // CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 2
 // CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 16
 
   _Float16 arr2n[] = { 1.2, 3.0, 3.e4 };
-// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x half] [half 0xH3CCD, half 0xH4200, half 0xH7753], align 2
-// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x i16] [i16 15565, i16 16896, i16 30547], align 2
+// CHECK-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x half] [half 0xH3CCD, half 0xH4200, half 0xH7753], align 2
 
   const volatile _Float16 func1n(const _Float16 ) {
 return arg + f2n + arr1n[4] - arr2n[1];
@@ -35,16 +33,14 @@
 // CHECK-X86-DAG: @f1f = global half 0xH, align 2
 
 _Float16 f2f = 32.4;
-// CHECK-AARCH64-DAG: @f2f = global half 0xH500D, align 2
-// CHECK-X86-DAG: @f2f = global i16 20493, align 2
+// CHECK-DAG: @f2f = global half 0xH500D, align 2
 
 _Float16 arr1f[10];
 // CHECK-AARCH64-DAG: @arr1f = global [10 x half] zeroinitializer, align 2
 // CHECK-X86-DAG: @arr1f = global [10 x half] zeroinitializer, align 16
 
 _Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
-// CHECK-AARCH64-DAG: @arr2f = global [3 x half] [half 0xHBCCD, half 0xHC200, half 0xHF753], align 2
-// CHECK-X86-DAG: @arr2f = global [3 x i16] [i16 -17203, i16 -15872, i16 -2221], align 2
+// CHECK-DAG: @arr2f = global 

[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8845
+
+  // Structures with either a non-trivial destructor or a non-trivial
+  // copy constructor are always indirectly.

Comment sounds incomplete.



Comment at: lib/CodeGen/TargetInfo.cpp:8943
+  // Arguments bigger than 2*xlen bytes are passed indirectly.
+  bool IsIndirect = TyInfo.first.getQuantity() > ((2 * XLen) / 8);
+

Parentheses around 2 * XLen can be skipped.


https://reviews.llvm.org/D40023



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


[PATCH] D40109: [MS] Apply adjustments after storing 'this'

2017-11-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
Herald added a subscriber: aprantl.

The MS ABI convention is that the 'this' pointer on entry is the address
of the vfptr that was used to make the virtual method call. In other
words, the pointer on entry always points to the base subobject that
introduced the virtual method. Consider this hierarchy:

  struct A { virtual void f() = 0; };
  struct B { virtual void g() = 0; };
  struct C : A, B {
void f() override;
void g() override;
  };

On entry to C::g, [ER]CX will contain the address of C's B subobject,
and C::g will have to subtract sizeof(A) to recover a pointer to C.

Before this change, we applied this adjustment in the prologue and
stored the new value into the "this" local variable alloca used for
debug info. However, MSVC does not do this, presumably because it is
often profitable to fold the adjustment into later field accesses. This
creates a problem, because the debugger expects the variable to be
unadjusted. Unfortunately, CodeView doesn't have anything like DWARF
expressions for computing variables that aren't in the program anymore,
so we have to declare 'this' to be the unadjusted value if we want the
debugger to see the right value.

This has the side benefit that, in optimized builds, the 'this' pointer
will usually be available on function entry because it doesn't require
any adjustment.


https://reviews.llvm.org/D40109

Files:
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  
clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp
@@ -196,7 +196,11 @@
 }
 
 // BITCODE-LABEL: define void @"\01?g@C@pr30293@@UAAXUNonTrivial@2@@Z"(<{ i8*, %"struct.pr30293::NonTrivial" }>* inalloca)
-// BITCODE: %[[this1:[^ ]*]] = load i8*, i8** %[[thisaddr:[^ ]*]], align 4
-// BITCODE-NEXT: %[[this2:[^ ]*]] = getelementptr inbounds i8, i8* %[[this1]], i32 -4
-// BITCODE-NEXT: store i8* %[[this2]], i8** %[[thisaddr]], align 4
+// BITCODE: %[[thisaddr:[^ ]*]] = getelementptr inbounds <{ i8*, %"struct.pr30293::NonTrivial" }>, <{ i8*, %"struct.pr30293::NonTrivial" }>* {{.*}}, i32 0, i32 0
+// BITCODE: %[[thisaddr1:[^ ]*]] = bitcast i8** %[[thisaddr]] to %"struct.pr30293::C"**
+// BITCODE: %[[this1:[^ ]*]] = load %"struct.pr30293::C"*, %"struct.pr30293::C"** %[[thisaddr1]], align 4
+// BITCODE: %[[this2:[^ ]*]] = bitcast %"struct.pr30293::C"* %[[this1]] to i8*
+// BITCODE: %[[this3:[^ ]*]] = getelementptr inbounds i8, i8* %[[this2]], i32 -4
+// BITCODE: %[[this4:[^ ]*]] = bitcast i8* %[[this3]] to %"struct.pr30293::C"*
+// BITCODE: store %"struct.pr30293::C"* %[[this4]], %"struct.pr30293::C"** @"\01?whatsthis@pr30293@@3PAUC@1@A", align 4
 }
Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 %s -fno-rtti -triple=i386-pc-win32 -emit-llvm -o %t
+// RUN: %clang_cc1 %s -fno-rtti -std=c++11 -Wno-inaccessible-base -triple=i386-pc-win32 -emit-llvm -o %t
 // RUN: FileCheck %s < %t
 // RUN: FileCheck --check-prefix=CHECK2 %s < %t
 
 // For now, just make sure x86_64 doesn't crash.
-// RUN: %clang_cc1 %s -fno-rtti -triple=x86_64-pc-win32 -emit-llvm -o %t
+// RUN: %clang_cc1 %s -fno-rtti -std=c++11 -Wno-inaccessible-base -triple=x86_64-pc-win32 -emit-llvm -o %t
 
 struct VBase {
   virtual ~VBase();
@@ -52,12 +52,14 @@
 
 B::~B() {
   // CHECK-LABEL: define x86_thiscallcc void @"\01??1B@@UAE@XZ"
-  // Adjust the this parameter:
-  // CHECK:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* {{.*}} to i8*
-  // CHECK:   %[[THIS_i8:.*]] = getelementptr inbounds i8, i8* %[[THIS_PARAM_i8]], i32 -8
-  // CHECK:   %[[THIS:.*]] = bitcast i8* %[[THIS_i8]] to %struct.B*
-  // CHECK:   store %struct.B* %[[THIS]], %struct.B** %[[THIS_ADDR:.*]], align 4
-  // CHECK:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
+  // Store initial this:
+  // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
+  // CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
+  // Reload and adjust the this parameter:
+  // CHECK:   %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
+  // CHECK:   

[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-15 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

This adds a Fuchsia module to clang-tidy to warn for features that are 
disallowed. The following checks were added to the new module:

fuchsia-default-arguments: Check to prevent use of default arguments in 
declared or called functions.
fuchsia-overloaded-operator: Check to prevent operator overloading.
fuchsia-statically-constructed-objects: Check to prevent creation of  
statically-stored objects.
fuchsia-thread-local: Check to prevent thread-local storage.
fuchsia-trailing-return: Check to prevent functions with trailing returns.
fuchsia-virtual-inheritance: Check to prevent the definition of classes with 
virtual inheritance.
fuchsia-multiple-inheritance: Check to prevent multiple inheritance in Fuchsia.

Tests and documentation are also updated.


https://reviews.llvm.org/D40108

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.h
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
  clang-tidy/fuchsia/OverloadedOperatorCheck.h
  clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp
  clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.h
  clang-tidy/fuchsia/ThreadLocalCheck.cpp
  clang-tidy/fuchsia/ThreadLocalCheck.h
  clang-tidy/fuchsia/TrailingReturnCheck.cpp
  clang-tidy/fuchsia/TrailingReturnCheck.h
  clang-tidy/fuchsia/VirtualInheritanceCheck.cpp
  clang-tidy/fuchsia/VirtualInheritanceCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-default-arguments.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/fuchsia-overloaded-operator.rst
  docs/clang-tidy/checks/fuchsia-statically-constructed-objects.rst
  docs/clang-tidy/checks/fuchsia-thread-local.rst
  docs/clang-tidy/checks/fuchsia-trailing-return.rst
  docs/clang-tidy/checks/fuchsia-virtual-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-default-arguments.cpp
  test/clang-tidy/fuchsia-multiple-inheritance.cpp
  test/clang-tidy/fuchsia-overloaded-operator.cpp
  test/clang-tidy/fuchsia-statically-constructed-objects.cpp
  test/clang-tidy/fuchsia-thread-local.cpp
  test/clang-tidy/fuchsia-trailing-return.cpp
  test/clang-tidy/fuchsia-virtual-inheritance.cpp

Index: test/clang-tidy/fuchsia-virtual-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-virtual-inheritance.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s fuchsia-virtual-inheritance %t
+
+class A {
+public:
+  A(int value) : val(value) {}
+
+  int do_A() { return val; }
+
+private:
+  int val;
+};
+
+class B : public virtual A {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: [kernel-c++] virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class B : public virtual A {
+public:
+  B() : A(0) {}
+  int do_B() { return 1 + do_A(); }
+};
+
+class C : public virtual A {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: [kernel-c++] virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class C : public virtual A {
+public:
+  C() : A(0) {}
+  int do_C() { return 2 + do_A(); }
+};
+
+class D : public B, public C {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: [kernel-c++] virtual inheritance is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT: class C : public B, public C {
+public:
+  D(int value) : A(value), B(), C() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: [kernel-c++] constructing a class which inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D(int value) : A(value), B(), C() {}
+  // CHECK-MESSAGES: [[@LINE-3]]:33: warning: [kernel-c++] constructing a class which inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D(int value) : A(value), B(), C() {}
+
+  int do_D() { return do_A() + do_B() + do_C(); }
+};
+
+int main(void) {
+  A *a = new A(0);
+  B *b = new B();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: [kernel-c++] constructing a class which inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  B *b = new B();
+  C *c = new C();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: [kernel-c++] constructing a class which inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  C *c = new C();
+  D *d = new D(0);
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: [kernel-c++] constructing a class which inherits a virtual base class is disallowed [fuchsia-virtual-inheritance]
+  // CHECK-NEXT:  D *d = new D(0);
+  return 0;
+}
Index: 

[PATCH] D37860: [MSan] Enable use-after-dtor instrumentation by default.

2017-11-15 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Patch is out-of-date.  But the flag has been enabled internally for over a 
month with no issues.  I'll update this patch soon, so we can flip the default 
here.


https://reviews.llvm.org/D37860



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


[PATCH] D39279: Stringizing raw string literals containing newline

2017-11-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

On the first glance string erase and insert seem to be done correctly. But we 
can still improve the tests. Can you please add tests for tricky cases where 
new line or backslash appear in unexpected places? Some of the examples are

  R"ab\
  cd"
  
  R"ab
  
  c"
  
  R"ab
  \"
  
  R"ab
  \\"

I didn't check if all of them are valid but I hope you got the idea.




Comment at: lib/Lex/Lexer.cpp:223
+  ++e;
+} else if (auto Size = getEscapedNewLineSize(Result.substr(i).data())) {
+  Result.erase(Result.begin() + i, Result.begin() + i + Size);

`getEscapedNewLineSize` mentions
> P[-1] is known to be a "\" or a trigraph equivalent on entry to this function.
Is this precondition correct in this case?

And `std::string::substr` creates a copy of a substring. It is inefficient in 
the loop and looks like you don't really need `std::string` here anyway.


https://reviews.llvm.org/D39279



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


[PATCH] D40024: Fix skipping of flags in getClangStripDependencyFileAdjuster

2017-11-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

probably a test would be useful


https://reviews.llvm.org/D40024



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.

LGTM


https://reviews.llvm.org/D40058



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


[PATCH] D37860: [MSan] Enable use-after-dtor instrumentation by default.

2017-11-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

What is the status of this patch?


https://reviews.llvm.org/D37860



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123093.
Wizard added a comment.

nit fix


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

File names look good now, thanks.




Comment at: clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp:1
+//===--- AvoidThrowingObjcExceptionCheck.cpp - 
clang-tidy--===//
+//

Objc -> ObjC



https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123091.
Wizard marked an inline comment as done.
Wizard added a comment.

rename again


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjCExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123090.
Wizard marked 6 inline comments as done.
Wizard added a comment.

rename file


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjC2ExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjC2ExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@interface NotException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NotException raise:@"NotException" format:@"Test"];
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect throwing exceptions in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 

r318347 - clang/module.modulemap: clang/Basic/X86Target.def may be textual header.

2017-11-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Nov 15 15:04:44 2017
New Revision: 318347

URL: http://llvm.org/viewvc/llvm-project?rev=318347=rev
Log:
clang/module.modulemap: clang/Basic/X86Target.def may be textual header.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=318347=318346=318347=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Wed Nov 15 15:04:44 2017
@@ -49,6 +49,7 @@ module Clang_Basic {
   textual header "Basic/OperatorKinds.def"
   textual header "Basic/Sanitizers.def"
   textual header "Basic/TokenKinds.def"
+  textual header "Basic/X86Target.def"
 
   module * { export * }
 }


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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123089.
Wizard marked 2 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(NSString *)args; // using NSString type since va_list cannot be recognized here
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+[NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds finds uses of throwing exceptions usages in Objective-C files.
+For the same reason as the Google C++ style guide, we prefer not throwing 
+exceptions from Objective-C code.
+
+The corresponding C++ style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect usage of @throw in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 

[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: test/Driver/riscv64-toolchain.c:1
+// A basic clang -cc1 command-line, and simple environment check.
+

I just saw that this test fails with the error:

error: backend data layout 'e-m:e-i64:64-n32:64-S128' does not match expected 
target description 'e-m:e-p:64:64-i64:64-i128:128-n64-S128'


https://reviews.llvm.org/D39963



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


[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

@asb I cherry-picked this patch and was able to compile a simple program for 
elf triple. By manually adding a few libs on the link line I was also able to 
make it link for linux triple.
Could you please respond to the comment about risv32-ld? Other than that this 
patch LGTM!


https://reviews.llvm.org/D39963



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


r318345 - Add X86Target.def that was forgotten in r30734

2017-11-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Nov 15 14:36:24 2017
New Revision: 318345

URL: http://llvm.org/viewvc/llvm-project?rev=318345=rev
Log:
Add X86Target.def that was forgotten in r30734

Added:
cfe/trunk/include/clang/Basic/X86Target.def

Added: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=318345=auto
==
--- cfe/trunk/include/clang/Basic/X86Target.def (added)
+++ cfe/trunk/include/clang/Basic/X86Target.def Wed Nov 15 14:36:24 2017
@@ -0,0 +1,228 @@
+//===--- X86Target.def - X86 Feature/Processor Database -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines the X86-specific Features and Processors, as used by
+// the X86 Targets.
+//
+//===--===//
+
+
+#ifndef PROC
+#define PROC(ENUM, STRING, IS64BIT)
+#endif
+
+#ifndef PROC_ALIAS
+#define PROC_ALIAS(ENUM, ALIAS)
+#endif
+
+#define PROC_64_BIT true
+#define PROC_32_BIT false
+
+/// \name i386
+/// i386-generation processors.
+//@{
+PROC(i386, "i386", PROC_32_BIT)
+//@}
+
+/// \name i486
+/// i486-generation processors.
+//@{
+PROC(i486, "i486", PROC_32_BIT)
+PROC(WinChipC6, "winchip-c6", PROC_32_BIT)
+PROC(WinChip2, "winchip2", PROC_32_BIT)
+PROC(C3, "c3", PROC_32_BIT)
+//@}
+
+/// \name i586
+/// i586-generation processors, P5 microarchitecture based.
+//@{
+PROC(i586, "i586", PROC_32_BIT)
+PROC(Pentium, "pentium", PROC_32_BIT)
+PROC(PentiumMMX, "pentium-mmx", PROC_32_BIT)
+//@}
+
+/// \name i686
+/// i686-generation processors, P6 / Pentium M microarchitecture based.
+//@{
+PROC(PentiumPro, "pentiumpro", PROC_32_BIT)
+PROC_ALIAS(PentiumPro, "i686")
+PROC(Pentium2, "pentium2", PROC_32_BIT)
+PROC(Pentium3, "pentium3", PROC_32_BIT)
+PROC_ALIAS(Pentium3, "pentium3m")
+PROC(PentiumM, "pentium-m", PROC_32_BIT)
+PROC(C3_2, "c3-2", PROC_32_BIT)
+
+/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
+/// Clang however has some logic to support this.
+// FIXME: Warn, deprecate, and potentially remove this.
+PROC(Yonah, "yonah", PROC_32_BIT)
+//@}
+
+/// \name Netburst
+/// Netburst microarchitecture based processors.
+//@{
+PROC(Pentium4, "pentium4", PROC_32_BIT)
+PROC_ALIAS(Pentium4, "pentium4m")
+
+PROC(Prescott, "prescott", PROC_32_BIT)
+PROC(Nocona, "nocona", PROC_64_BIT)
+//@}
+
+/// \name Core
+/// Core microarchitecture based processors.
+//@{
+PROC(Core2, "core2", PROC_64_BIT)
+
+/// This enumerator, like Yonah, is a bit odd. It is another
+/// codename which GCC no longer accepts as an option to -march, but Clang
+/// has some logic for recognizing it.
+// FIXME: Warn, deprecate, and potentially remove this.
+PROC(Penryn, "penryn", PROC_64_BIT)
+//@}
+
+/// \name Atom
+/// Atom processors
+//@{
+PROC(Bonnell, "bonnell", PROC_64_BIT)
+PROC_ALIAS(Bonnell, "atom")
+
+PROC(Silvermont, "silvermont", PROC_64_BIT)
+PROC_ALIAS(Silvermont, "slm")
+
+PROC(Goldmont, "goldmont", PROC_64_BIT)
+//@}
+
+/// \name Nehalem
+/// Nehalem microarchitecture based processors.
+PROC(Nehalem, "nehalem", PROC_64_BIT)
+PROC_ALIAS(Nehalem, "corei7")
+
+/// \name Westmere
+/// Westmere microarchitecture based processors.
+PROC(Westmere, "westmere", PROC_64_BIT)
+
+/// \name Sandy Bridge
+/// Sandy Bridge microarchitecture based processors.
+PROC(SandyBridge, "sandybridge", PROC_64_BIT)
+PROC_ALIAS(SandyBridge, "corei7-avx")
+
+/// \name Ivy Bridge
+/// Ivy Bridge microarchitecture based processors.
+PROC(IvyBridge, "ivybridge", PROC_64_BIT)
+PROC_ALIAS(IvyBridge, "core-avx-i")
+
+/// \name Haswell
+/// Haswell microarchitecture based processors.
+PROC(Haswell, "haswell", PROC_64_BIT)
+PROC_ALIAS(Haswell, "core-avx2")
+
+/// \name Broadwell
+/// Broadwell microarchitecture based processors.
+PROC(Broadwell, "broadwell", PROC_64_BIT)
+
+/// \name Skylake Client
+/// Skylake client microarchitecture based processors.
+PROC(SkylakeClient, "skylake", PROC_64_BIT)
+
+/// \name Skylake Server
+/// Skylake server microarchitecture based processors.
+PROC(SkylakeServer, "skylake-avx512", PROC_64_BIT)
+PROC_ALIAS(SkylakeServer, "skx")
+
+/// \name Cannonlake Client
+/// Cannonlake client microarchitecture based processors.
+PROC(Cannonlake, "cannonlake", PROC_64_BIT)
+
+/// \name Knights Landing
+/// Knights Landing processor.
+PROC(KNL, "knl", PROC_64_BIT)
+
+/// \name Knights Mill
+/// Knights Mill processor.
+PROC(KNM, "knm", PROC_64_BIT)
+
+/// \name Lakemont
+/// Lakemont microarchitecture based processors.
+PROC(Lakemont, "lakemont", PROC_32_BIT)
+
+/// \name K6
+/// K6 architecture processors.
+//@{
+PROC(K6, "k6", PROC_32_BIT)
+PROC(K6_2, "k6-2", PROC_32_BIT)
+PROC(K6_3, 

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

benhamilton wrote:
> Don't forget to rename the file to AvoidThrowingObjcExceptionCheck.h.
> 
Oops! I mean, rename the file to AvoidThrowingObjCExceptionCheck.h. :)


https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: test/clang-tidy/google-objc-avoid-throwing-exception.m:17-20
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of 
throwing exception to indicate Objective-C errors 
[google-objc-avoid-throwing-exception]
+}

Would be nice to have a test that confirms sending -raise:format: to a 
different object does not hit the warning.


https://reviews.llvm.org/D40058



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


[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

Looking good. Please rename the files correctly, or it will not build on Linux.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:23
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+  Finder->addMatcher(objcMessageExpr(hasSelector("raise:format:"),
+ hasReceiverType(asString("NSException")))

Also need to match `raise:format:arguments:`.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjCExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

Don't forget to rename the file to AvoidThrowingObjcExceptionCheck.h.




Comment at: clang-tidy/google/CMakeLists.txt:5
   AvoidCStyleCastsCheck.cpp
+  AvoidThrowingObjcExceptionCheck.cpp
   DefaultArgumentsCheck.cpp

Rename to AvoidThrowingObjCExceptionCheck.cpp



Comment at: clang-tidy/google/GoogleTidyModule.cpp:18
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"

I think you renamed the #include but not the file.. should test on Linux, it 
won't work with a case-sensitive file system ;)



Comment at: docs/ReleaseNotes.rst:63
+
+  Add new check to detect usage of @throw in Objective-C code, which should be 
avoided.
+

detect usage of @throw -> detect throwing exceptions



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C 
code.

Can you include the link to the C++ style guide section here instead of at the 
end? http://google.github.io/styleguide/cppguide.html#Exceptions



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C 
code.

benhamilton wrote:
> Can you include the link to the C++ style guide section here instead of at 
> the end? http://google.github.io/styleguide/cppguide.html#Exceptions
finds @throw usages -> finds uses of throwing exceptions


https://reviews.llvm.org/D40058



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


[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318343: Split x86 "Processor" info into its own def file. 
[NFC] (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D40093?vs=123081=123083#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40093

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case 

[PATCH] D39994: Loosen MSVC 2017 path requirements

2017-11-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I haven't dug into this code to really understand if this is right and won't 
change our version detection logic, but yes, broadly I believe we should just 
consult PATH, find a cl.exe, and check its version. I'd like to reduce this 
path validation to a minimum.


https://reviews.llvm.org/D39994



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


r318343 - Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Nov 15 14:25:39 2017
New Revision: 318343

URL: http://llvm.org/viewvc/llvm-project?rev=318343=rev
Log:
Split x86 "Processor" info into its own def file. [NFC]

A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.

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


Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318343=318342=318343=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Wed Nov 15 14:25:39 2017
@@ -1504,121 +1504,19 @@ bool X86TargetInfo::checkCPUKind(CPUKind
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case CK_PentiumMMX:
-  case CK_PentiumPro:
-  case CK_Pentium2:
-  case CK_Pentium3:
-  case CK_PentiumM:
-  case CK_Yonah:
-  case CK_C3_2:
-  case CK_Pentium4:
-  case CK_Lakemont:
-  case CK_Prescott:
-  case CK_K6:
-  case CK_K6_2:
-  case CK_K6_3:
-  case CK_Athlon:
-  case CK_AthlonXP:
-  case CK_Geode:
-// Only accept certain architectures when compiling in 32-bit mode.
-if (getTriple().getArch() != llvm::Triple::x86)
-  return false;
-
-LLVM_FALLTHROUGH;
-  case CK_Nocona:
-  case CK_Core2:
-  case CK_Penryn:
-  case CK_Bonnell:
-  case CK_Silvermont:
-  case CK_Goldmont:
-  case CK_Nehalem:
-  case CK_Westmere:
-  case CK_SandyBridge:
-  case CK_IvyBridge:
-  case CK_Haswell:
-  case CK_Broadwell:
-  case CK_SkylakeClient:
-  case CK_SkylakeServer:
-  case CK_Cannonlake:
-  case CK_KNL:
-  case CK_KNM:
-  case CK_K8:
-  case CK_K8SSE3:
-  case CK_AMDFAM10:
-  case CK_BTVER1:
-  case CK_BTVER2:
-  case CK_BDVER1:
-  case CK_BDVER2:
-  case CK_BDVER3:
-  case CK_BDVER4:
-  case CK_ZNVER1:
-  case CK_x86_64:
-return true;
+#define PROC(ENUM, STRING, IS64BIT)
\
+  case CK_##ENUM:  
\
+return IS64BIT || getTriple().getArch() == llvm::Triple::x86;
+#include "clang/Basic/X86Target.def"
   }
   llvm_unreachable("Unhandled CPU kind");
 }
 
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
-  .Case("i386", CK_i386)
-  .Case("i486", CK_i486)
-  .Case("winchip-c6", CK_WinChipC6)
-  .Case("winchip2", CK_WinChip2)
-  .Case("c3", CK_C3)
-  .Case("i586", CK_i586)
-  .Case("pentium", CK_Pentium)
-  .Case("pentium-mmx", CK_PentiumMMX)
-  .Cases("i686", "pentiumpro", CK_PentiumPro)
-  .Case("pentium2", CK_Pentium2)
-  .Cases("pentium3", "pentium3m", CK_Pentium3)
-  .Case("pentium-m", CK_PentiumM)
-  .Case("c3-2", CK_C3_2)
-  .Case("yonah", CK_Yonah)
-  .Cases("pentium4", "pentium4m", CK_Pentium4)
-  .Case("prescott", CK_Prescott)
-  .Case("nocona", CK_Nocona)
-  .Case("core2", CK_Core2)
-  .Case("penryn", CK_Penryn)
-  .Cases("bonnell", "atom", CK_Bonnell)
-  .Cases("silvermont", "slm", CK_Silvermont)
-  .Case("goldmont", CK_Goldmont)
-  .Cases("nehalem", "corei7", CK_Nehalem)
-  .Case("westmere", CK_Westmere)
-  .Cases("sandybridge", "corei7-avx", CK_SandyBridge)
-  .Cases("ivybridge", "core-avx-i", CK_IvyBridge)
-  .Cases("haswell", "core-avx2", CK_Haswell)
-  .Case("broadwell", CK_Broadwell)
-  .Case("skylake", CK_SkylakeClient)
-  .Cases("skylake-avx512", "skx", CK_SkylakeServer)
-  .Case("cannonlake", CK_Cannonlake)
-  .Case("knl", CK_KNL)
-  .Case("knm", CK_KNM)
-  .Case("lakemont", CK_Lakemont)
-  .Case("k6", CK_K6)
-  .Case("k6-2", CK_K6_2)
-  .Case("k6-3", CK_K6_3)
-  .Cases("athlon", "athlon-tbird", CK_Athlon)
-  .Cases("athlon-xp", "athlon-mp", "athlon-4", CK_AthlonXP)
-  .Cases("k8", "athlon64", "athlon-fx", "opteron", CK_K8)
-  .Cases("k8-sse3", "athlon64-sse3", "opteron-sse3", CK_K8SSE3)
-  .Cases("amdfam10", "barcelona", CK_AMDFAM10)
-  .Case("btver1", CK_BTVER1)
-  .Case("btver2", CK_BTVER2)
-  .Case("bdver1", CK_BDVER1)
-  .Case("bdver2", CK_BDVER2)
-  .Case("bdver3", CK_BDVER3)
-  .Case("bdver4", CK_BDVER4)
-  .Case("znver1", CK_ZNVER1)
-  .Case("x86-64", CK_x86_64)
-  .Case("geode", CK_Geode)
+#define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)
+#define PROC_ALIAS(ENUM, ALIAS) .Case(ALIAS, CK_##ENUM)
+#include "clang/Basic/X86Target.def"
   .Default(CK_Generic);
 }
 

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 

[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D40093



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


[PATCH] D40093: Split x86 "Processor" info into its own def file. [NFC]

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 123081.
erichkeane retitled this revision from "Split x86 "Processor" info into its own 
def file." to "Split x86 "Processor" info into its own def file. [NFC]".
erichkeane added a comment.

realized I had added amdfam17 as an alias, which
isn't supposed to happen.  Also makes this NFC to
remove that.


https://reviews.llvm.org/D40093

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 123079.
Wizard marked 10 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D40058

Files:
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp
  clang-tidy/google/AvoidThrowingObjcExceptionCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-avoid-throwing-exception.m

Index: test/clang-tidy/google-objc-avoid-throwing-exception.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-avoid-throwing-exception.m
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+@class NSString;
+
+@interface NSException
+
++ (void)raise:(NSString *)name format:(NSString *)format;
+
+@end
+
+@implementation Foo
+- (void)f {
+NSString *foo = @"foo";
+@throw foo;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+
+- (void)f2 {
+[NSException raise:@"TestException" format:@"Test"];
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+}
+@end
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -60,6 +60,7 @@
google-default-arguments
google-explicit-constructor
google-global-names-in-headers
+   google-objc-avoid-throwing-exception
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - google-objc-avoid-throwing-exception
+
+google-objc-avoid-throwing-exception
+
+
+This check finds @throw usages in Objective-C files. For the same reason as the
+Google C++ style guide, we prefer not throwing exceptions from Objective-C code.
+
+Instead, prefer passing in ``NSError **`` and return ``BOOL`` to indicate success or failure.
+
+A counterexample:
+
+.. code-block:: objc
+
+  - (void)readFile {
+if ([self isError]) {
+  @throw [NSException exceptionWithName:...];
+}
+  }
+
+Instead, returning an error via ``NSError **`` is preferred:
+
+.. code-block:: objc
+
+  - (BOOL)readFileWithError:(NSError **)error {
+if ([self isError]) {
+  *error = [NSError errorWithDomain:...];
+  return NO;
+}
+return YES;
+  }
+
+The corresponding style guide rule:
+https://google.github.io/styleguide/cppguide.html#Exceptions
+http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `google-avoid-throwing-objc-exception
+  `_ check
+
+  Add new check to detect usage of @throw in Objective-C code, which should be avoided.
+
 - New `objc-property-declaration
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
@@ -49,6 +50,8 @@
 "google-explicit-constructor");
 CheckFactories.registerCheck(
 "google-global-names-in-headers");
+CheckFactories.registerCheck(
+"google-objc-avoid-throwing-exception");
 CheckFactories.registerCheck(
 "google-objc-global-variable-declaration");
 CheckFactories.registerCheck(
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  AvoidThrowingObjcExceptionCheck.cpp
   DefaultArgumentsCheck.cpp
   

[clang-tools-extra] r318339 - [clangd] Loosen more brittle tests

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 13:50:53 2017
New Revision: 318339

URL: http://llvm.org/viewvc/llvm-project?rev=318339=rev
Log:
[clangd] Loosen more brittle tests

Modified:
clang-tools-extra/trunk/test/clangd/completion-snippet.test
clang-tools-extra/trunk/test/clangd/completion.test

Modified: clang-tools-extra/trunk/test/clangd/completion-snippet.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-snippet.test?rev=318339=318338=318339=diff
==
--- clang-tools-extra/trunk/test/clangd/completion-snippet.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion-snippet.test Wed Nov 15 
13:50:53 2017
@@ -61,16 +61,6 @@ Content-Length: 148
 # CHECK-NEXT:"label": "fake::",
 # CHECK-NEXT:"sortText": "75fake"
 # CHECK-NEXT:  },
-# CHECK-NEXT:  {
-# CHECK-NEXT:"detail": "fake &",
-# CHECK-NEXT:"filterText": "operator=",
-# CHECK-NEXT:"insertText": "operator=(${1:const fake &})",
-# CHECK-NEXT:"insertTextFormat": 2,
-# CHECK-NEXT:"kind": 2,
-# CHECK-NEXT:"label": "operator=(const fake &)",
-# CHECK-NEXT:"sortText": "79operator="
-# CHECK-NEXT:  },
-# FIXME: Why do some buildbots show an extra operator==(fake&&) here?
 #  CHECK:  {
 #  CHECK:"detail": "void",
 # CHECK-NEXT:"filterText": "~fake",

Modified: clang-tools-extra/trunk/test/clangd/completion.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion.test?rev=318339=318338=318339=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Wed Nov 15 13:50:53 2017
@@ -61,16 +61,7 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fake::",
 # CHECK-NEXT:  "sortText": "75fake"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fake &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
-# FIXME: Why do some buildbots show an extra operator==(fake&&) here?
+# FIXME: Why do buildbots show different operator=s here?
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fake",
@@ -133,15 +124,6 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fake::",
 # CHECK-NEXT:  "sortText": "75fake"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fake &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fake",
@@ -182,15 +164,6 @@ Content-Length: 148
 # CHECK-NEXT:  "label": "fancy::",
 # CHECK-NEXT:  "sortText": "75fancy"
 # CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "fancy &",
-# CHECK-NEXT:  "filterText": "operator=",
-# CHECK-NEXT:  "insertText": "operator=",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "operator=(const fancy &)",
-# CHECK-NEXT:  "sortText": "79operator="
-# CHECK-NEXT:},
 #  CHECK:{
 #  CHECK:  "detail": "void",
 # CHECK-NEXT:  "filterText": "~fancy",


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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

Hahnfeld wrote:
> rjmccall wrote:
> > ABataev wrote:
> > > Hahnfeld wrote:
> > > > rjmccall wrote:
> > > > > Hahnfeld wrote:
> > > > > > rjmccall wrote:
> > > > > > > Hahnfeld wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > ABataev wrote:
> > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > > > The way you've written this makes it sound 
> > > > > > > > > > > > > > > > > like "does the target support VLAs?", but the 
> > > > > > > > > > > > > > > > > actual semantic checks treat it as "do OpenMP 
> > > > > > > > > > > > > > > > > devices on this target support VLAs?"  Maybe 
> > > > > > > > > > > > > > > > > there should be a more specific way to query 
> > > > > > > > > > > > > > > > > things about OpenMP devices instead of 
> > > > > > > > > > > > > > > > > setting a global flag for the target?
> > > > > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never 
> > > > > > > > > > > > > > > > support VLAs. So I felt like it would be more 
> > > > > > > > > > > > > > > > correct to make this a global property of the 
> > > > > > > > > > > > > > > > target.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > The difference is that the other programming 
> > > > > > > > > > > > > > > > models (OpenCL and CUDA) error out 
> > > > > > > > > > > > > > > > immediatelyand regardless of the target because 
> > > > > > > > > > > > > > > > this limitation is reflected in the standards 
> > > > > > > > > > > > > > > > that disallow VLAs (see SemaType.cpp). For 
> > > > > > > > > > > > > > > > OpenMP we might have target devices that 
> > > > > > > > > > > > > > > > support VLA so we shouldn't error out for those.
> > > > > > > > > > > > > > > If you want to make it a global property of the 
> > > > > > > > > > > > > > > target, that's fine, but then I don't understand 
> > > > > > > > > > > > > > > why your diagnostic only fires when 
> > > > > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > > > > That is because of how OpenMP offloading works and 
> > > > > > > > > > > > > > how it is implemented in Clang. Consider the 
> > > > > > > > > > > > > > following snippet from the added test case:
> > > > > > > > > > > > > > ```lang=c
> > > > > > > > > > > > > > int vla[arg];
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > > > > {
> > > > > > > > > > > > > >// more code here...
> > > > > > > > > > > > > > }
> > > > > > > > > > > > > > ```
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Clang will take the following steps to compile this 
> > > > > > > > > > > > > > into a working binary for a GPU:
> > > > > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is 
> > > > > > > > > > > > > > for the host and produce LLVM Bitcode.
> > > > > > > > > > > > > > 2. Parse and analyze again the code as-is and 
> > > > > > > > > > > > > > generate code for the offloading target, the GPU in 
> > > > > > > > > > > > > > this case.
> > > > > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary 
> > > > > > > > > > > > > > and embed target binary from 3.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the 
> > > > > > > > > > > > > > complete source code is analyzed. So to not throw 
> > > > > > > > > > > > > > errors for the host code, we have to make sure that 
> > > > > > > > > > > > > > we are actually generating code for the target 
> > > > > > > > > > > > > > device. This is either in a `target` directive or 
> > > > > > > > > > > > > > in a `declare target` region.
> > > > > > > > > > > > > > Note that this is quite similar to what CUDA does, 
> > > > > > > > > > > > > > only they have `CUDADiagIfDeviceCode` for this 
> > > > > > > > > > > > > > logic. If you want me to add something of that kind 
> > > > > > > > > > > > > > for OpenMP target devices, I'm fine with that. 
> > > > > > > > > > > > > > However for the given case, it's a bit different 
> > > > > > > > > > > > > > because this error should only be thrown for target 
> > > > > > > > > > > > > > devices that don't support VLAs...
> > > > > > > > > > > > > I see.  So the entire translation unit is re-parsed 
> > > > > > > > > > > > > and re-Sema'ed from scratch for the target?  Which 
> > > > > > > > > > > > > means you need to avoid generating errors about 
> > > > > > > > > > > > 

[PATCH] D39049: [analyzer] Fix wrong calculation of offset in ArrayBoundsV2

2017-11-15 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

> Could you do a similar analysis that I did above to check why does this not 
> work for the multidimensional case? (I.e.: checking what constraints are 
> generated and what the analyzer does with them.)

the "location.dump()" will just say "x".

the ProgramState is:

Expressions:
 (0x2acd12a78a0,0x2acd1478b80) buf : 
 (0x2acd12a78a0,0x2acd1478bf8) buf : {buf,0 S64b,int [3]}
 (0x2acd12a78a0,0x2acd1478c10) buf[1] : {buf,1 S64b,int [3]}
 (0x2acd12a78a0,0x2acd1478c38) x : 
 (0x2acd12a78a0,0x2acd1478c88) buf[1] : {element{buf,1 S64b,int [3]},0 
S64b,int}
Ranges of symbol values:
 reg_$0 : { [4, 10] }

rawOffsetVal => 0

extentBegin => 0

For getSimplifiedOffset() , the offset is not a SymIntExpr it will just return 
0.


Repository:
  rL LLVM

https://reviews.llvm.org/D39049



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


[clang-tools-extra] r318337 - [clangd] Revert broken r318329 and disable tests on PS4

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 13:33:56 2017
New Revision: 318337

URL: http://llvm.org/viewvc/llvm-project?rev=318337=rev
Log:
[clangd] Revert broken r318329 and disable tests on PS4

(Clearly this is not a permanent solution)

Added:
clang-tools-extra/trunk/test/clangd/lit.local.cfg
Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318337=318336=318337=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
13:33:56 2017
@@ -31,11 +31,7 @@ static void addExtraFlags(tooling::Compi
 }
 
 tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
-  // We don't specify --std because we want to infer it from the filename.
-  // We force PC because PS4 will change --std from under us.
-  // FIXME: there must be a more principled way to do this!
-  std::vector CommandLine{
-  "clang", "-fsyntax-only", "-target=unknown-pc-unknown", File.str()};
+  std::vector CommandLine{"clang", "-fsyntax-only", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");

Added: clang-tools-extra/trunk/test/clangd/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/lit.local.cfg?rev=318337=auto
==
--- clang-tools-extra/trunk/test/clangd/lit.local.cfg (added)
+++ clang-tools-extra/trunk/test/clangd/lit.local.cfg Wed Nov 15 13:33:56 2017
@@ -0,0 +1,6 @@
+import re
+# We rely on the default -std being derived from the filetype.
+# PS4 sets a different -std, and many tests break.
+# FIXME: make our tests less brittle instead.
+if re.match(r'.*-scei-ps4', config.target_triple):
+  config.unsupported = True


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


[PATCH] D39879: AMDGPU: Remove -mamdgpu-debugger-abi option

2017-11-15 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl abandoned this revision.
kzhuravl added a comment.

Agreed to do it later.


https://reviews.llvm.org/D39879



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


[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

jtbandes wrote:
> aaron.ballman wrote:
> > I don't think this diagnostic needs to be moved and renamed; the old name 
> > was more clear than "other" on the new name.
> How about `_bad_type`? I was hoping to give these all similar names since 
> they happen during the same implicit conversion. Also, while "implicit object 
> parameter" is technically a correct name, it seems to be not very commonly 
> used and would confuse users. Though it's also valuable for the diagnostic id 
> to be similar to the actual text...
I'm not too worried about the identifier used for the diagnostic; it doesn't 
seem likely to confuse many people working on Clang (or at least, not confuse 
them for long). However, I wouldn't be opposed to 
`err_member_function_call_bad_type`.


https://reviews.llvm.org/D39937



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-15 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 123069.
Nebiroth marked 3 inline comments as done.
Nebiroth added a comment.

Added test for didChangeConfiguration notification.
Compilation database and extra file flags are now properly reloaded when 
changing database path.
ClangdConfigurationParams now used instead of map.
changeConfiguration removed from ClangdServer. This class will now handle more 
specific settings.
Added more checks when parsing notification from client..


https://reviews.llvm.org/D39571

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/did-change-configuration.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -1,3 +1,4 @@
+
 # RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
@@ -18,6 +19,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -48,4 +50,4 @@
 # CHECK-NEXT:  "result": null
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -1,3 +1,4 @@
+
 # RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
@@ -18,6 +19,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -45,4 +47,4 @@
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/did-change-configuration.test
===
--- /dev/null
+++ test/clangd/did-change-configuration.test
@@ -0,0 +1,46 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 150
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"voidmain(){}"}}}
+
+Content-Length: 86
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":""}}
+#Failed to decode workspace/didChangeConfiguration request.
+#Incorrect mapping node
+
+Content-Length: 114
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":{
+#Failed to decode workspace/didChangeConfiguration request.
+#compilationDatabasePath is not a scalar node
+
+Content-Length: 140
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/","testBadValue":"foo1234"}}}
+#Ignored unknown field "testBadValue"
+#Failed to find compilation database for / in overriden directory /
+#Bad field, bad compilation database
+
+Content-Length: 722
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///compile_commands.json","languageId":"json","version":1,"text":"[\n{\n"directory":"/",\n"command":"/usr/bin/c++-DGTEST_HAS_RTTI=0-D_GNU_SOURCE-D__STDC_CONSTANT_MACROS-D__STDC_FORMAT_MACROS-D__STDC_LIMIT_MACROS-Ilib/Demangle-I../lib/Demangle-I/usr/include/libxml2-Iinclude-I../include-fPIC-fvisibility-inlines-hidden-Werror=date-time-std=c++11-Wall-W-Wno-unused-parameter-Wwrite-strings-Wcast-qual-Wno-missing-field-initializers-pedantic-Wno-long-long-Wno-maybe-uninitialized-Wdelete-non-virtual-dtor-Wno-comment-O0-g-fno-exceptions-fno-rtti-o/foo.c.o-c/foo.c",\n"file":"/foo.c"\n},"}}}
+
+Content-Length: 115
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/"}}}

[clang-tools-extra] r318329 - [clangd] Fix flag name from r318327

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 12:10:14 2017
New Revision: 318329

URL: http://llvm.org/viewvc/llvm-project?rev=318329=rev
Log:
[clangd] Fix flag name from r318327

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318329=318328=318329=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
12:10:14 2017
@@ -35,7 +35,7 @@ tooling::CompileCommand getDefaultCompil
   // We force PC because PS4 will change --std from under us.
   // FIXME: there must be a more principled way to do this!
   std::vector CommandLine{
-  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
+  "clang", "-fsyntax-only", "-target=unknown-pc-unknown", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");


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


[libcxx] r318328 - More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in string, string_view, and the free function std::empty(). Removed tabs from , which is why th

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 12:02:27 2017
New Revision: 318328

URL: http://llvm.org/viewvc/llvm-project?rev=318328=rev
Log:
More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in 
string, string_view, and the free function std::empty(). Removed tabs from 
, which is why the diff is so big.

Added:
libcxx/trunk/test/std/iterators/iterator.container/empty.array.fail.cpp
libcxx/trunk/test/std/iterators/iterator.container/empty.container.fail.cpp

libcxx/trunk/test/std/iterators/iterator.container/empty.initializer_list.fail.cpp
libcxx/trunk/test/std/strings/basic.string/string.capacity/empty.fail.cpp

libcxx/trunk/test/std/strings/string.view/string.view.capacity/empty.fail.cpp
Modified:
libcxx/trunk/include/iterator
libcxx/trunk/include/string
libcxx/trunk/include/string_view
libcxx/trunk/test/std/strings/basic.string/string.capacity/empty.pass.cpp

libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=318328=318327=318328=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed Nov 15 12:02:27 2017
@@ -1791,30 +1791,39 @@ end(const _Cp& __c)
 
 #if _LIBCPP_STD_VER > 14
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr auto size(const _Cont& __c) -> decltype(__c.size()) { return 
__c.size(); }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr auto empty(const _Cont& __c) -> decltype(__c.empty()) { return 
__c.empty(); }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() 
== 0; }
 
 template  constexpr
+inline _LIBCPP_INLINE_VISIBILITY
 auto data(_Cont& __c) -> decltype(__c.data()) { return __c.data(); }
 
 template  constexpr
+inline _LIBCPP_INLINE_VISIBILITY
 auto data(const _Cont& __c) -> decltype(__c.data()) { return __c.data(); }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return 
__il.begin(); }
 #endif
 

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=318328=318327=318328=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Nov 15 12:02:27 2017
@@ -608,7 +608,7 @@ struct __libcpp_string_gets_noexcept_ite
 
 template 
 struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT(
-   ( is_convertible 
>::value &&
+( is_convertible >::value &&
  !is_convertible::value)) {};
 
 #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
@@ -901,7 +901,8 @@ public:
 void shrink_to_fit() _NOEXCEPT {reserve();}
 _LIBCPP_INLINE_VISIBILITY
 void clear() _NOEXCEPT;
-_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 
0;}
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+bool empty() const _NOEXCEPT {return size() == 0;}
 
 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) 
const _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY reference   operator[](size_type __pos)  
 _NOEXCEPT;
@@ -1756,10 +1757,10 @@ template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
  const _Tp& __t, size_type __pos, size_type __n, const 
allocator_type& __a,
-typename 
enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 
void>::type *)
+ typename enable_if<__can_be_converted_to_string_view<_CharT, 
_Traits, _Tp>::value, void>::type *)
 : __r_(__second_tag(), __a)
 {
-   __self_view __sv = __self_view(__t).substr(__pos, __n);
+__self_view __sv = __self_view(__t).substr(__pos, __n);
 __init(__sv.data(), __sv.size());
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -2145,7 +2146,7 @@ template 
 typename enable_if
 <
 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
-   basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>&
 >::type
 basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type 
__pos, size_type __n)
 {
@@ -2493,7 +2494,7 @@ template 
 typename enable_if
 <
 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
-   basic_string<_CharT, _Traits, _Allocator>&

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

aaron.ballman wrote:
> I don't think this diagnostic needs to be moved and renamed; the old name was 
> more clear than "other" on the new name.
How about `_bad_type`? I was hoping to give these all similar names since they 
happen during the same implicit conversion. Also, while "implicit object 
parameter" is technically a correct name, it seems to be not very commonly used 
and would confuse users. Though it's also valuable for the diagnostic id to be 
similar to the actual text...


https://reviews.llvm.org/D39937



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


Re: [clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Sam McCall via cfe-commits
On Wed, Nov 15, 2017 at 8:43 PM, Alex L  wrote:

> This doesn't seem like a good permanent solution (as Paul pointed out -std
> will change in the future).
>
Right, clearly not :-) It's a temporary fix to get the tests to pass.
Reverting the patch isn't that useful because it only masks the problem
(our testcases already include hacks around this)

Will you be able to avoid this in the future?
>
Ideally we would make most of the tests independent of the default --std,
probably by pinning it to something specific.
Then we'd just need one explicit test that we have the right default
behavior, which would be updated when the default changes.

I can do some work on this, but I could use some advice from people more
familiar with lit testing patterns. (Mostly this all seems like an argument
for unit-testing instead, to me :-)

On 15 November 2017 at 11:38, Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Wed Nov 15 11:38:09 2017
>> New Revision: 318327
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318327=rev
>> Log:
>> [clangd] Try to unbreak tests on PS4 by targeting PC explicitly
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/GlobalCompilationDatabase.cpp?rev=318327=318326&
>> r2=318327=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov
>> 15 11:38:09 2017
>> @@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
>>  }
>>
>>  tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
>> -  std::vector CommandLine{"clang", "-fsyntax-only",
>> File.str()};
>> +  // We don't specify --std because we want to infer it from the
>> filename.
>> +  // We force PC because PS4 will change --std from under us.
>> +  // FIXME: there must be a more principled way to do this!
>> +  std::vector CommandLine{
>> +  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown",
>> File.str()};
>>return tooling::CompileCommand(llvm::sys::path::parent_path(File),
>>   llvm::sys::path::filename(File),
>> CommandLine,
>>   /*Output=*/"");
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Alex L via cfe-commits
This doesn't seem like a good permanent solution (as Paul pointed out -std
will change in the future). Will you be able to avoid this in the future?

On 15 November 2017 at 11:38, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Nov 15 11:38:09 2017
> New Revision: 318327
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318327=rev
> Log:
> [clangd] Try to unbreak tests on PS4 by targeting PC explicitly
>
> Modified:
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/
> GlobalCompilationDatabase.cpp?rev=318327=318326=318327=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
> (original)
> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov
> 15 11:38:09 2017
> @@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
>  }
>
>  tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
> -  std::vector CommandLine{"clang", "-fsyntax-only",
> File.str()};
> +  // We don't specify --std because we want to infer it from the filename.
> +  // We force PC because PS4 will change --std from under us.
> +  // FIXME: there must be a more principled way to do this!
> +  std::vector CommandLine{
> +  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
>return tooling::CompileCommand(llvm::sys::path::parent_path(File),
>   llvm::sys::path::filename(File),
> CommandLine,
>   /*Output=*/"");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r318327 - [clangd] Try to unbreak tests on PS4 by targeting PC explicitly

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 11:38:09 2017
New Revision: 318327

URL: http://llvm.org/viewvc/llvm-project?rev=318327=rev
Log:
[clangd] Try to unbreak tests on PS4 by targeting PC explicitly

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=318327=318326=318327=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Nov 15 
11:38:09 2017
@@ -31,7 +31,11 @@ static void addExtraFlags(tooling::Compi
 }
 
 tooling::CompileCommand getDefaultCompileCommand(PathRef File) {
-  std::vector CommandLine{"clang", "-fsyntax-only", File.str()};
+  // We don't specify --std because we want to infer it from the filename.
+  // We force PC because PS4 will change --std from under us.
+  // FIXME: there must be a more principled way to do this!
+  std::vector CommandLine{
+  "clang", "-fsyntax-only", "-triple=unknown-pc-unknown", File.str()};
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File), CommandLine,
  /*Output=*/"");


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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-15 Thread Volodymyr Sapsai via cfe-commits
On Nov 12, 2017, at 12:37, Reimar Döffinger  wrote:
> 
> On Thu, Nov 09, 2017 at 05:37:32PM -0800, Volodymyr Sapsai wrote:
>> On Nov 9, 2017, at 12:13, Reimar Döffinger  wrote:
>>> 
>>> Hello!
>>> 
>>> On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote:
 Thanks for the patch, Reimar. Can you please add tests to ensure this 
 functionality doesn’t regress? As null character is required by the 
 standard (27.7.2.3p21), a good starting point seems to be
 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
>>> 
>>> New patch attached, though I went the lazy way of just adding one case.
>>> Not sure that's "good enough" - in principle I think it should be.
>> I think it makes sense to cover wchar_t as well. And I think it would be 
>> useful to test the case with specified delimiter too. Most likely 
>> implementation should be reused for the case with explicit delimiter and 
>> default new line delimiter. But I prefer not to rely on this assumption and 
>> test explicitly.
> 
> Well, it was rather trivial to do anyway, so done.
Thanks for adding more tests.

>>> More tricky would be to add a test for the _LIBCPP_NO_EXCEPTIONS case,
>>> is there any code testing that at all?
>> According to tests, exceptions are tested in various ways. Let me find how 
>> to configure the build to run tests in these modes.
> 
> There aren't many references to that mode, and I am not sure
> running in a separate mode would make for a good test anyway.
> Maybe not how it should done, but for now I added a separate file
> that just defines _LIBCPP_NO_EXCEPTIONS before the includes.
> <0001-Ensure-std-istream-getline-always-0-terminates-strin.patch>

libc++ can be built with exceptions enabled or disabled (see 
LIBCXX_ENABLE_EXCEPTIONS 
)
 and we need to support both configurations. The problem with your 
_LIBCPP_NO_EXCEPTIONS approach is that it won't work when exceptions are 
disabled. Various exception-related tests are usually guarded with 
TEST_HAS_NO_EXCEPTIONS macro defined in “test_macros.h”. You can check other 
tests for examples of TEST_HAS_NO_EXCEPTIONS usage, I had in mind something like

#ifndef TEST_HAS_NO_EXCEPTIONS
{
testbuf sb(" ");
std::istream is();
char s[5] = "test";
is.exceptions(std::istream::eofbit | std::istream::badbit);
try
{
is.getline(s, 5);
assert(false);
}
catch (std::ios_base::failure&)
{
}
assert( is.eof());
assert( is.fail());
assert(std::string(s) == " ");
assert(is.gcount() == 1);
}
#endif

Non-empty `sb` allows to test null-termination at correct place in array; 
initializing `s` with “test” avoids spurious correct values in memory; 
try-catch block and badbit are to make it more obvious we are testing code path 
throwing an exception.___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8913
+  }
+  return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
+}

The spec says "Aggregates larger than 2✕XLEN bits are passed by reference and 
are replaced in the argument list with the address".  That's not byval.


https://reviews.llvm.org/D40023



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


[PATCH] D40093: Split x86 "Processor" info into its own def file.

2017-11-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.


https://reviews.llvm.org/D40093

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -95,178 +95,8 @@
   /// loosely correspond to the options passed to '-march' or '-mtune' flags.
   enum CPUKind {
 CK_Generic,
-
-/// \name i386
-/// i386-generation processors.
-//@{
-CK_i386,
-//@}
-
-/// \name i486
-/// i486-generation processors.
-//@{
-CK_i486,
-CK_WinChipC6,
-CK_WinChip2,
-CK_C3,
-//@}
-
-/// \name i586
-/// i586-generation processors, P5 microarchitecture based.
-//@{
-CK_i586,
-CK_Pentium,
-CK_PentiumMMX,
-//@}
-
-/// \name i686
-/// i686-generation processors, P6 / Pentium M microarchitecture based.
-//@{
-CK_PentiumPro,
-CK_Pentium2,
-CK_Pentium3,
-CK_PentiumM,
-CK_C3_2,
-
-/// This enumerator is a bit odd, as GCC no longer accepts -march=yonah.
-/// Clang however has some logic to support this.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Yonah,
-//@}
-
-/// \name Netburst
-/// Netburst microarchitecture based processors.
-//@{
-CK_Pentium4,
-CK_Prescott,
-CK_Nocona,
-//@}
-
-/// \name Core
-/// Core microarchitecture based processors.
-//@{
-CK_Core2,
-
-/// This enumerator, like \see CK_Yonah, is a bit odd. It is another
-/// codename which GCC no longer accepts as an option to -march, but Clang
-/// has some logic for recognizing it.
-// FIXME: Warn, deprecate, and potentially remove this.
-CK_Penryn,
-//@}
-
-/// \name Atom
-/// Atom processors
-//@{
-CK_Bonnell,
-CK_Silvermont,
-CK_Goldmont,
-//@}
-
-/// \name Nehalem
-/// Nehalem microarchitecture based processors.
-CK_Nehalem,
-
-/// \name Westmere
-/// Westmere microarchitecture based processors.
-CK_Westmere,
-
-/// \name Sandy Bridge
-/// Sandy Bridge microarchitecture based processors.
-CK_SandyBridge,
-
-/// \name Ivy Bridge
-/// Ivy Bridge microarchitecture based processors.
-CK_IvyBridge,
-
-/// \name Haswell
-/// Haswell microarchitecture based processors.
-CK_Haswell,
-
-/// \name Broadwell
-/// Broadwell microarchitecture based processors.
-CK_Broadwell,
-
-/// \name Skylake Client
-/// Skylake client microarchitecture based processors.
-CK_SkylakeClient,
-
-/// \name Skylake Server
-/// Skylake server microarchitecture based processors.
-CK_SkylakeServer,
-
-/// \name Cannonlake Client
-/// Cannonlake client microarchitecture based processors.
-CK_Cannonlake,
-
-/// \name Knights Landing
-/// Knights Landing processor.
-CK_KNL,
-
-/// \name Knights Mill
-/// Knights Mill processor.
-CK_KNM,
-
-/// \name Lakemont
-/// Lakemont microarchitecture based processors.
-CK_Lakemont,
-
-/// \name K6
-/// K6 architecture processors.
-//@{
-CK_K6,
-CK_K6_2,
-CK_K6_3,
-//@}
-
-/// \name K7
-/// K7 architecture processors.
-//@{
-CK_Athlon,
-CK_AthlonXP,
-//@}
-
-/// \name K8
-/// K8 architecture processors.
-//@{
-CK_K8,
-CK_K8SSE3,
-CK_AMDFAM10,
-//@}
-
-/// \name Bobcat
-/// Bobcat architecture processors.
-//@{
-CK_BTVER1,
-CK_BTVER2,
-//@}
-
-/// \name Bulldozer
-/// Bulldozer architecture processors.
-//@{
-CK_BDVER1,
-CK_BDVER2,
-CK_BDVER3,
-CK_BDVER4,
-//@}
-
-/// \name zen
-/// Zen architecture processors.
-//@{
-CK_ZNVER1,
-//@}
-
-/// This specification is deprecated and will be removed in the future.
-/// Users should prefer \see CK_K8.
-// FIXME: Warn on this when the CPU is set to it.
-//@{
-CK_x86_64,
-//@}
-
-/// \name Geode
-/// Geode processors.
-//@{
-CK_Geode
-//@}
+#define PROC(ENUM, STRING, IS64BIT) CK_##ENUM,
+#include "clang/Basic/X86Target.def"
   } CPU = CK_Generic;
 
   bool checkCPUKind(CPUKind Kind) const;
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -1504,121 +1504,19 @@
   case CK_Generic:
 // No processor selected!
 return false;
-
-  case CK_i386:
-  case CK_i486:
-  case CK_WinChipC6:
-  case CK_WinChip2:
-  case CK_C3:
-  case CK_i586:
-  case CK_Pentium:
-  case CK_PentiumMMX:
-  case CK_PentiumPro:
-  case CK_Pentium2:
-  case CK_Pentium3:
-  case CK_PentiumM:
-  case CK_Yonah:
-  case CK_C3_2:
-  

[PATCH] D39221: [libcxx] [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-11-15 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318325: [test] Alignment must be > 
__STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D39221?vs=119990=123062#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39221

Files:
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -24,7 +24,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -35,7 +35,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 bool A_constructed = false;
 
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

[libcxx] r318325 - [test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

2017-11-15 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Wed Nov 15 11:14:45 2017
New Revision: 318325

URL: http://llvm.org/viewvc/llvm-project?rev=318325=rev
Log:
[test] Alignment must be > __STDCPP_DEFAULT_NEW_ALIGNMENT__ to call aligned new

Differential Revision: D39221

Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=318325=318324=318325=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -36,7 +36,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int unsized_delete_called = 0;
 int unsized_delete_nothrow_called = 0;

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp?rev=318325=318324=318325=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -38,7 +38,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp?rev=318325=318324=318325=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -37,7 +37,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
 
 int new_handler_called = 0;
 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp?rev=318325=318324=318325=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 Wed Nov 15 11:14:45 2017
@@ -34,7 +34,7 @@
 
 #include "test_macros.h"
 
-constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+constexpr auto OverAligned = 

Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Sam McCall via cfe-commits
Sorry about these - I've finally understood what's going on.
It looks like the PS4 has a different default --std, which probably doesn't
make sense for clangd. I'll override it.

On Wed, Nov 15, 2017 at 7:49 PM, Robinson, Paul 
wrote:

> Hi Sam,
> It looks like llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast has been
> failing a couple of clangd tests ever since this went in.
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/13517
>
> Please fix or revert ASAP when bots go red.  Failures like this interfere
> with our CI process.
>
> Thanks,
> --paulr
> PS4 code owner
>
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Sam McCall via cfe-commits
> > Sent: Wednesday, November 15, 2017 1:16 AM
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r318287 - [clangd] Support returning a
> > limited number of completion results.
> >
> > Author: sammccall
> > Date: Wed Nov 15 01:16:29 2017
> > New Revision: 318287
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=318287=rev
> > Log:
> > [clangd] Support returning a limited number of completion results.
> >
> > Summary:
> > All results are scored, we only process CodeCompletionStrings for the
> > winners.
> > We now return CompletionList rather than CompletionItem[] (both are
> > valid).
> > sortText is now based on CodeCompletionResult::orderedName (mostly the
> > same).
> >
> > This is the first clangd-only completion option, so plumbing changed.
> > It requires a small clangd patch (exposing
> > CodeCompletionResult::orderedName).
> >
> > (This can't usefully be enabled yet: we don't support server-side
> > filtering)
> >
> > Reviewers: ilya-biryukov
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D39852
> >
> > Modified:
> > clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> > clang-tools-extra/trunk/clangd/ClangdServer.cpp
> > clang-tools-extra/trunk/clangd/ClangdServer.h
> > clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> > clang-tools-extra/trunk/clangd/ClangdUnit.h
> > clang-tools-extra/trunk/clangd/Protocol.cpp
> > clang-tools-extra/trunk/clangd/Protocol.h
> > clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> > clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> > clang-tools-extra/trunk/test/clangd/completion-priorities.test
> > clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> > clang-tools-extra/trunk/test/clangd/completion-snippet.test
> > clang-tools-extra/trunk/test/clangd/completion.test
> > clang-tools-extra/trunk/test/clangd/protocol.test
> > clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> >
> > Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/ClangdLSPServer.cpp?rev=318287=318286=318287&
> view
> > =diff
> > 
> ==
> > 
> > --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> > +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
> 01:16:29
> > 2017
> > @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
> >  }
> >
> >  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> > ) {
> > -  auto Items = Server
> > -   .codeComplete(Params.textDocument.uri.file,
> > - Position{Params.position.line,
> > -  Params.position.character})
> > -   .get() // FIXME(ibiryukov): This could be made async
> > if we
> > -  // had an API that would allow to attach
> > callbacks to
> > -  // futures returned by ClangdServer.
> > -   .Value;
> > -  C.reply(json::ary(Items));
> > +  auto List = Server
> > +  .codeComplete(
> > +  Params.textDocument.uri.file,
> > +  Position{Params.position.line,
> > Params.position.character})
> > +  .get() // FIXME(ibiryukov): This could be made async
> if
> > we
> > + // had an API that would allow to attach
> > callbacks to
> > + // futures returned by ClangdServer.
> > +  .Value;
> > +  C.reply(List);
> >  }
> >
> >  void ClangdLSPServer::onSignatureHelp(Ctx C,
> >
> > Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> > extra/trunk/clangd/ClangdServer.cpp?rev=318287&
> r1=318286=318287=di
> > ff
> > 
> ==
> > 
> > --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> > +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> > 2017
> > 

[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rsmith, aaron.ballman.
aaron.ballman added a comment.

I think the new wording is a bit more clear, in general.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1595-1597
+def err_member_function_call_other : Error<
+  "cannot initialize object parameter of type %0 with an expression "
+  "of type %1">;

I don't think this diagnostic needs to be moved and renamed; the old name was 
more clear than "other" on the new name.



Comment at: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp:22-24
+  void lvalue() &; // expected-note 2 {{'lvalue' declared here}}
+  void const_lvalue() const&;
+  void rvalue() &&; // expected-note {{'rvalue' declared here}}

Can you add examples that cover the other diagnostic wordings as well 
(volatile, restrict, combinations, etc)?


https://reviews.llvm.org/D39937



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


Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Galina Kistanova via cfe-commits
Also at least one more builder is affected:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13517

Thanks

Galina

On Wed, Nov 15, 2017 at 10:54 AM, Galina Kistanova 
wrote:

> Hello Sam,
>
> One of tests is failing on
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-ubuntu-fast/builds/20638
>
> Please have a look?
>
> Thanks
>
> Galina
>
> ...
>
> Failing Tests (1):
> Clang Tools :: clangd/completion.test
>
>
> On Wed, Nov 15, 2017 at 1:16 AM, Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Wed Nov 15 01:16:29 2017
>> New Revision: 318287
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318287=rev
>> Log:
>> [clangd] Support returning a limited number of completion results.
>>
>> Summary:
>> All results are scored, we only process CodeCompletionStrings for the
>> winners.
>> We now return CompletionList rather than CompletionItem[] (both are
>> valid).
>> sortText is now based on CodeCompletionResult::orderedName (mostly the
>> same).
>>
>> This is the first clangd-only completion option, so plumbing changed.
>> It requires a small clangd patch (exposing CodeCompletionResult::orderedN
>> ame).
>>
>> (This can't usefully be enabled yet: we don't support server-side
>> filtering)
>>
>> Reviewers: ilya-biryukov
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D39852
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.h
>> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
>> clang-tools-extra/trunk/clangd/ClangdUnit.h
>> clang-tools-extra/trunk/clangd/Protocol.cpp
>> clang-tools-extra/trunk/clangd/Protocol.h
>> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
>> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
>> clang-tools-extra/trunk/test/clangd/completion-priorities.test
>> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
>> clang-tools-extra/trunk/test/clangd/completion-snippet.test
>> clang-tools-extra/trunk/test/clangd/completion.test
>> clang-tools-extra/trunk/test/clangd/protocol.test
>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdLSPServer.cpp?rev=318287=318286=318287=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
>> 01:16:29 2017
>> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>>  }
>>
>>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
>> ) {
>> -  auto Items = Server
>> -   .codeComplete(Params.textDocument.uri.file,
>> - Position{Params.position.line,
>> -  Params.position.character})
>> -   .get() // FIXME(ibiryukov): This could be made async
>> if we
>> -  // had an API that would allow to attach
>> callbacks to
>> -  // futures returned by ClangdServer.
>> -   .Value;
>> -  C.reply(json::ary(Items));
>> +  auto List = Server
>> +  .codeComplete(
>> +  Params.textDocument.uri.file,
>> +  Position{Params.position.line,
>> Params.position.character})
>> +  .get() // FIXME(ibiryukov): This could be made async
>> if we
>> + // had an API that would allow to attach
>> callbacks to
>> + // futures returned by ClangdServer.
>> +  .Value;
>> +  C.reply(List);
>>  }
>>
>>  void ClangdLSPServer::onSignatureHelp(Ctx C,
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.cpp?rev=318287=318286=318287=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
>> 2017
>> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>>   std::move(TaggedFS));
>>  }
>>
>> -std::future>
>> +std::future
>>  ClangdServer::codeComplete(PathRef File, Position Pos,
>> llvm::Optional OverridenContents,
>> IntrusiveRefCntPtr *UsedFS)
>> {
>> -  using ResultType = Tagged;
>> +  using ResultType = Tagged;
>>
>>std::promise ResultPromise;
>>
>> @@ -242,11 +242,10 

[PATCH] D39955: [Driver] Add command-line flags for the new TBAA metadata format

2017-11-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  I'm fine with living with both formats as long as we're not exposing 
this as a feature.


Repository:
  rL LLVM

https://reviews.llvm.org/D39955



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


Re: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Galina Kistanova via cfe-commits
Hello Sam,

One of tests is failing on
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/20638

Please have a look?

Thanks

Galina

...

Failing Tests (1):
Clang Tools :: clangd/completion.test


On Wed, Nov 15, 2017 at 1:16 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Nov 15 01:16:29 2017
> New Revision: 318287
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318287=rev
> Log:
> [clangd] Support returning a limited number of completion results.
>
> Summary:
> All results are scored, we only process CodeCompletionStrings for the
> winners.
> We now return CompletionList rather than CompletionItem[] (both are valid).
> sortText is now based on CodeCompletionResult::orderedName (mostly the
> same).
>
> This is the first clangd-only completion option, so plumbing changed.
> It requires a small clangd patch (exposing CodeCompletionResult::
> orderedName).
>
> (This can't usefully be enabled yet: we don't support server-side
> filtering)
>
> Reviewers: ilya-biryukov
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D39852
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> clang-tools-extra/trunk/clangd/ClangdUnit.h
> clang-tools-extra/trunk/clangd/Protocol.cpp
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> clang-tools-extra/trunk/test/clangd/completion-priorities.test
> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> clang-tools-extra/trunk/test/clangd/completion-snippet.test
> clang-tools-extra/trunk/test/clangd/completion.test
> clang-tools-extra/trunk/test/clangd/protocol.test
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdLSPServer.cpp?rev=318287=318286=318287=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15
> 01:16:29 2017
> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>  }
>
>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> ) {
> -  auto Items = Server
> -   .codeComplete(Params.textDocument.uri.file,
> - Position{Params.position.line,
> -  Params.position.character})
> -   .get() // FIXME(ibiryukov): This could be made async
> if we
> -  // had an API that would allow to attach
> callbacks to
> -  // futures returned by ClangdServer.
> -   .Value;
> -  C.reply(json::ary(Items));
> +  auto List = Server
> +  .codeComplete(
> +  Params.textDocument.uri.file,
> +  Position{Params.position.line,
> Params.position.character})
> +  .get() // FIXME(ibiryukov): This could be made async if
> we
> + // had an API that would allow to attach
> callbacks to
> + // futures returned by ClangdServer.
> +  .Value;
> +  C.reply(List);
>  }
>
>  void ClangdLSPServer::onSignatureHelp(Ctx C,
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.cpp?rev=318287=318286=318287=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>   std::move(TaggedFS));
>  }
>
> -std::future>
> +std::future
>  ClangdServer::codeComplete(PathRef File, Position Pos,
> llvm::Optional OverridenContents,
> IntrusiveRefCntPtr *UsedFS) {
> -  using ResultType = Tagged;
> +  using ResultType = Tagged;
>
>std::promise ResultPromise;
>
> @@ -242,11 +242,10 @@ ClangdServer::codeComplete(PathRef File,
>  }
>
>  void ClangdServer::codeComplete(
> -UniqueFunction)> Callback,
> -PathRef File, Position Pos, llvm::Optional
> OverridenContents,
> +UniqueFunction Callback, PathRef File,
> +Position Pos, llvm::Optional OverridenContents,
>  IntrusiveRefCntPtr *UsedFS) {
> -  using 

[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:13
+
+#include 
+#include 

Including  is forbidden by our coding standard. However, it doesn't 
appear to be used in the source file, either.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:41
+  switchStmt(hasCondition(allOf(
+  // Match on switch statements that have either bitfield or 
integer
+  // condition.

either bitfield or integer condition -> either a bit-field or an integer 
condition



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:43
+  // condition.
+  // The ordering in 'anyOf()' is important, since the last
+  // condition is the most general.

since -> because

Also, drop the comma.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:48
+hasDescendant(declRefExpr().bind("non-enum-condition"))),
+  // 'unless()' must be the last match here and must be binded,
+  // otherwise the matcher does not work correctly.

binded -> bound



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:54
+
+  /// This option is noisy, therefore matching is configurable.
+  if (WarnOnMissingElse) {

Don't use doxygen comments here.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:63
+
+namespace {
+unsigned countCaseLabels(const SwitchStmt *Switch) {

Our usual preference is to make these methods static rather than put them in an 
anonymous namespace (types go into anonymous namespaces, however).



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:80
+
+  return Bits > 0 && DiscreteValues <= 1
+ ? std::numeric_limits::max()

This logic does not make sense to me -- the goal is to test for overflow, which 
can be done solely by looking at the value of `Bits` and the size of 
`std::size_t`. The current logic appears to return 1 if `Bits == 0` and will 
only return the max value if the wraparound happens to precisely create the 
value 0 or 1. I'd replace with:
```
return Bits >= std::numeric_limits::digits() ? 
std::numeric_limits::max() : static_cast(1) << Bits;
```



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:84
+}
+/// Get the number of different values for the Type T, that is switched on.
+///

How about: Get the number of possible values that can be switched on for the 
type T



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:91-92
+  // Context.getTypeSize(T) returns the number of bits T uses.
+  // Calculates the number of discrete values that are representable by this
+  // type.
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))

I don't think this comment adds value.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:94
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))
+: twoPow(0ul);
+}

No need for the `ul` suffix -- the type will undergo implicit conversion with 
or without the suffix.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:94
+  return T->isIntegralType(Context) ? twoPow(Context.getTypeSize(T))
+: twoPow(0ul);
+}

aaron.ballman wrote:
> No need for the `ul` suffix -- the type will undergo implicit conversion with 
> or without the suffix.
Why call toPow instead of just returning the value `1` directly?



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:102
+diag(ElseIfWithoutElse->getLocStart(),
+ "potential uncovered codepath; add an ending else branch");
+return;

potential uncovered codepath -> potentially uncovered code path
branch -> statement



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:131
+const SwitchStmt *Switch) {
+  const unsigned CaseCount = countCaseLabels(Switch);
+  assert(CaseCount > 0 && "Switch statementt with supposedly one default "

No need to make this `const` (we only do that for reference and pointer types, 
not other local variable or parameter types). Here and elsewhere.



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:132
+  const unsigned CaseCount = countCaseLabels(Switch);
+  assert(CaseCount > 0 && "Switch statementt with supposedly one default "
+  "branch did not contain any case labels");

statementt -> statement



Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:138
+ ? "degenerated switch with default label only"
+ : "switch could be 

RE: [clang-tools-extra] r318287 - [clangd] Support returning a limited number of completion results.

2017-11-15 Thread Robinson, Paul via cfe-commits
Hi Sam,
It looks like llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast has been
failing a couple of clangd tests ever since this went in.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13517

Please fix or revert ASAP when bots go red.  Failures like this interfere
with our CI process.

Thanks,
--paulr
PS4 code owner


> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Sam McCall via cfe-commits
> Sent: Wednesday, November 15, 2017 1:16 AM
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r318287 - [clangd] Support returning a
> limited number of completion results.
> 
> Author: sammccall
> Date: Wed Nov 15 01:16:29 2017
> New Revision: 318287
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=318287=rev
> Log:
> [clangd] Support returning a limited number of completion results.
> 
> Summary:
> All results are scored, we only process CodeCompletionStrings for the
> winners.
> We now return CompletionList rather than CompletionItem[] (both are
> valid).
> sortText is now based on CodeCompletionResult::orderedName (mostly the
> same).
> 
> This is the first clangd-only completion option, so plumbing changed.
> It requires a small clangd patch (exposing
> CodeCompletionResult::orderedName).
> 
> (This can't usefully be enabled yet: we don't support server-side
> filtering)
> 
> Reviewers: ilya-biryukov
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D39852
> 
> Modified:
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/ClangdUnit.cpp
> clang-tools-extra/trunk/clangd/ClangdUnit.h
> clang-tools-extra/trunk/clangd/Protocol.cpp
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/test/clangd/authority-less-uri.test
> clang-tools-extra/trunk/test/clangd/completion-items-kinds.test
> clang-tools-extra/trunk/test/clangd/completion-priorities.test
> clang-tools-extra/trunk/test/clangd/completion-qualifiers.test
> clang-tools-extra/trunk/test/clangd/completion-snippet.test
> clang-tools-extra/trunk/test/clangd/completion.test
> clang-tools-extra/trunk/test/clangd/protocol.test
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> 
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/ClangdLSPServer.cpp?rev=318287=318286=318287
> =diff
> ==
> 
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -195,15 +195,15 @@ void ClangdLSPServer::onCodeAction(Ctx C
>  }
> 
>  void ClangdLSPServer::onCompletion(Ctx C, TextDocumentPositionParams
> ) {
> -  auto Items = Server
> -   .codeComplete(Params.textDocument.uri.file,
> - Position{Params.position.line,
> -  Params.position.character})
> -   .get() // FIXME(ibiryukov): This could be made async
> if we
> -  // had an API that would allow to attach
> callbacks to
> -  // futures returned by ClangdServer.
> -   .Value;
> -  C.reply(json::ary(Items));
> +  auto List = Server
> +  .codeComplete(
> +  Params.textDocument.uri.file,
> +  Position{Params.position.line,
> Params.position.character})
> +  .get() // FIXME(ibiryukov): This could be made async if
> we
> + // had an API that would allow to attach
> callbacks to
> + // futures returned by ClangdServer.
> +  .Value;
> +  C.reply(List);
>  }
> 
>  void ClangdLSPServer::onSignatureHelp(Ctx C,
> 
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-
> extra/trunk/clangd/ClangdServer.cpp?rev=318287=318286=318287=di
> ff
> ==
> 
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 01:16:29
> 2017
> @@ -222,11 +222,11 @@ std::future ClangdServer::forceRep
>   std::move(TaggedFS));
>  }
> 
> -std::future>
> +std::future
>  ClangdServer::codeComplete(PathRef File, Position Pos,
> llvm::Optional OverridenContents,
> IntrusiveRefCntPtr *UsedFS) {
> -  using ResultType = Tagged;
> +  using ResultType = Tagged;
> 
>std::promise ResultPromise;
> 
> @@ -242,11 +242,10 @@ 

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:683
+  if (LangOpts.SEHExceptions)
+Builder.defineMacro("__SEH__");
 

Please define `__ARM_DWARF_EH__` if dwarf is enabled on arm, see D39533, as I 
commented earlier. (Sorry, I forgot about it and thought it was fixed already.)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[clang-tools-extra] r318317 - [clangd] clang-format the source code. NFC.

2017-11-15 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Nov 15 10:04:56 2017
New Revision: 318317

URL: http://llvm.org/viewvc/llvm-project?rev=318317=rev
Log:
[clangd] clang-format the source code. NFC.

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=318317=318316=318317=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Nov 15 10:04:56 2017
@@ -132,9 +132,8 @@ void ClangdLSPServer::onRename(Ctx C, Re
   auto File = Params.textDocument.uri.file;
   auto Replacements = Server.rename(File, Params.position, Params.newName);
   if (!Replacements) {
-C.replyError(
-ErrorCode::InternalError,
-llvm::toString(Replacements.takeError()));
+C.replyError(ErrorCode::InternalError,
+ llvm::toString(Replacements.takeError()));
 return;
   }
   std::string Code = Server.getDocument(File);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=318317=318316=318317=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Nov 15 10:04:56 2017
@@ -9,11 +9,11 @@
 
 #include "ClangdServer.h"
 #include "clang/Format/Format.h"
-#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
-#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=318317=318316=318317=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Wed Nov 15 10:04:56 
2017
@@ -66,13 +66,15 @@ void RequestContext::reply(json::Expr &&
   });
 }
 
-void RequestContext::replyError(ErrorCode code, const llvm::StringRef 
) {
+void RequestContext::replyError(ErrorCode code,
+const llvm::StringRef ) {
   Out.log("Error " + Twine(static_cast(code)) + ": " + Message + "\n");
   if (ID) {
 Out.writeMessage(json::obj{
 {"jsonrpc", "2.0"},
 {"id", *ID},
-{"error", json::obj{{"code", static_cast(code)}, {"message", 
Message}}},
+{"error",
+ json::obj{{"code", static_cast(code)}, {"message", Message}}},
 });
   }
 }

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=318317=318316=318317=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Wed Nov 15 10:04:56 2017
@@ -1094,7 +1094,7 @@ RenameParams::parse(llvm::yaml::MappingN
 
 if (KeyValue == "textDocument") {
   auto *Value =
-dyn_cast_or_null(NextKeyValue.getValue());
+  dyn_cast_or_null(NextKeyValue.getValue());
   if (!Value)
 continue;
   auto *Map = dyn_cast(Value);

Modified: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp?rev=318317=318316=318317=diff
==
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp Wed Nov 15 
10:04:56 2017
@@ -94,20 +94,18 @@ TEST(JSONExprTests, PrettyPrinting) {
   }
 })";
 
-  EXPECT_EQ(
-  str,
-  sp(obj{
-  {"empty_object", obj{}},
-  {"empty_array", {}},
-  {"full_array", {1, nullptr}},
-  {"full_object",
-   obj{
-   {"nested_array",
-{obj{
-{"property", "value"},
-}}},
-   }},
-  }));
+  EXPECT_EQ(str, sp(obj{
+ {"empty_object", obj{}},
+   

[clang-tools-extra] r318316 - [clangd] Fix time units in clangd performance trace

2017-11-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Nov 15 09:53:46 2017
New Revision: 318316

URL: http://llvm.org/viewvc/llvm-project?rev=318316=rev
Log:
[clangd] Fix time units in clangd performance trace

Modified:
clang-tools-extra/trunk/clangd/Trace.cpp

Modified: clang-tools-extra/trunk/clangd/Trace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Trace.cpp?rev=318316=318315=318316=diff
==
--- clang-tools-extra/trunk/clangd/Trace.cpp (original)
+++ clang-tools-extra/trunk/clangd/Trace.cpp Wed Nov 15 09:53:46 2017
@@ -74,7 +74,7 @@ private:
 
   double timestamp() {
 using namespace std::chrono;
-return duration(system_clock::now() - Start).count();
+return duration(system_clock::now() - Start).count();
   }
 
   std::mutex Mu;


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


[PATCH] D39730: Enabling constructor code completion

2017-11-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D39730#926108, @jkorous-apple wrote:

> Sorry, what do you mean by "this works in the body of the class"?
>
> Definition of constructor inside class definition has been working even 
> before:
>
>   struct foo {
> foo();
> f
>   };
>   
>
> Do you mean that a test shall be added in order to check that it still works?


You're right, but we don't actually code-complete constructor in this case, but 
the struct name. I suppose we don't need to complete the constructor here, but 
we do need the destructor, i.e.:

  struct foo {
  ~
  };


https://reviews.llvm.org/D39730



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


r318314 - Try to fix test/SemaCXX/deleted-operator.cpp after r318309

2017-11-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Nov 15 09:47:58 2017
New Revision: 318314

URL: http://llvm.org/viewvc/llvm-project?rev=318314=rev
Log:
Try to fix test/SemaCXX/deleted-operator.cpp after r318309

The number of 'built-in candidate' notes now varies since __float128 may
or may not be a candidate depending on the target.

Modified:
cfe/trunk/test/SemaCXX/deleted-operator.cpp

Modified: cfe/trunk/test/SemaCXX/deleted-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-operator.cpp?rev=318314=318313=318314=diff
==
--- cfe/trunk/test/SemaCXX/deleted-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/deleted-operator.cpp Wed Nov 15 09:47:58 2017
@@ -8,8 +8,8 @@ struct PR10757 {
 int PR10757f() {
   PR10757 a1;
   // FIXME: We get a ridiculous number of "built-in candidate" notes here...
-  if(~a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 8 {{built-in candidate}}
-  if(a1==a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 144 {{built-in candidate}}
+  if(~a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 6-8 {{built-in candidate}}
+  if(a1==a1) {} // expected-error {{overload resolution selected deleted 
operator}} expected-note 1-144 {{built-in candidate}}
 }
 
 struct DelOpDel {


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


[libcxx] r318313 - Clean up the tests for free data(), size() and empty()

2017-11-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 15 09:47:09 2017
New Revision: 318313

URL: http://llvm.org/viewvc/llvm-project?rev=318313=rev
Log:
Clean up the tests for free data(), size() and empty()

Modified:
libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp

Modified: libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp?rev=318313=318312=318313=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp Wed Nov 15 
09:47:09 2017
@@ -7,51 +7,54 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto data(C& c) -> decltype(c.data()); 
  // C++17
 // template  constexpr auto data(const C& c) -> decltype(c.data());   
  // C++17
 // template  constexpr T* data(T ()[N]) noexcept; 
  // C++17
 // template  constexpr const E* data(initializer_list il) 
noexcept;  // C++17
 
-#include "test_macros.h"
-
-#if TEST_STD_VER <= 14
-int main () {}
-#else
-
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template
 void test_const_container( const C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::data(c)   == c.data());
 }
 
 template
 void test_const_container( const std::initializer_list& c )
 {
+ASSERT_NOEXCEPT(std::data(c));
 assert ( std::data(c)   == c.begin());
 }
 
 template
 void test_container( C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::data(c)   == c.data());
 }
 
 template
 void test_container( std::initializer_list& c)
 {
+ASSERT_NOEXCEPT(std::data(c));
 assert ( std::data(c)   == c.begin());
 }
 
 template
 void test_const_array( const T ()[Sz] )
 {
+ASSERT_NOEXCEPT(std::data(array));
 assert ( std::data(array) == [0]);
 }
 
@@ -72,5 +75,3 @@ int main()
 static constexpr int arrA [] { 1, 2, 3 };
 test_const_array ( arrA );
 }
-
-#endif

Modified: libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp?rev=318313=318312=318313=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp Wed Nov 
15 09:47:09 2017
@@ -7,17 +7,13 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto empty(const C& c) -> decltype(c.empty()); 
  // C++17
 // template  constexpr bool empty(const T ()[N]) 
noexcept;  // C++17
 // template  constexpr bool empty(initializer_list il) noexcept;   
  // C++17
 
-#include "test_macros.h"
-
-#if TEST_STD_VER <= 14
-int main () {}
-#else
-
 #include 
 #include 
 #include 
@@ -25,9 +21,12 @@ int main () {}
 #include 
 #include 
 
+#include "test_macros.h"
+
 template
 void test_const_container( const C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::empty(c)   == c.empty());
 }
 
@@ -40,18 +39,21 @@ void test_const_container( const std::in
 template
 void test_container( C& c )
 {
+//  Can't say noexcept here because the container might not be
 assert ( std::empty(c)   == c.empty());
 }
 
 template
 void test_container( std::initializer_list& c )
 {
+ASSERT_NOEXCEPT(std::empty(c));
 assert ( std::empty(c)   == (c.size() == 0));
 }
 
 template
 void test_const_array( const T ()[Sz] )
 {
+ASSERT_NOEXCEPT(std::empty(array));
 assert (!std::empty(array));
 }
 
@@ -75,5 +77,3 @@ int main()
 static constexpr int arrA [] { 1, 2, 3 };
 test_const_array ( arrA );
 }
-
-#endif

Modified: libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp?rev=318313=318312=318313=diff
==
--- libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp Wed Nov 15 
09:47:09 2017
@@ -7,16 +7,12 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
 // 
 // template  constexpr auto size(const C& c) -> decltype(c.size());   
  // C++17
 // template  

[PATCH] D40089: [clangd] Make completion scores use 0-1 floats internally.

2017-11-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

This scale is much easier to mix with other signals, such as fuzzy match 
strength.
Mostly NFC, but it does reorder some low-priority items that get folded 
together at a score of 0 (see completion-qualifiers.test).
Removed the exact sortText from the testcases, because it's the ranking that we 
want to test.


https://reviews.llvm.org/D40089

Files:
  clangd/ClangdUnit.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-items-kinds.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test

Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -39,7 +39,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 
@@ -68,7 +68,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
@@ -97,7 +97,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 7,
 # CHECK-NEXT:"label": "fake::",
-# CHECK-NEXT:"sortText": "75fake"
+# CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
 Content-Length: 1024
Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -24,51 +24,51 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "a",
-# CHECK-NEXT:  "sortText": "35a"
+# CHECK-NEXT:  "sortText": "{{.*}}a"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "bb",
 # CHECK-NEXT:  "insertText": "bb",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "bb",
-# CHECK-NEXT:  "sortText": "35bb"
+# CHECK-NEXT:  "sortText": "{{.*}}bb"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "ccc",
 # CHECK-NEXT:  "insertText": "ccc",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "ccc",
-# CHECK-NEXT:  "sortText": "35ccc"
+# CHECK-NEXT:  "sortText": "{{.*}}ccc"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "f",
 # CHECK-NEXT:  "insertText": "f",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 2,
 # CHECK-NEXT:  "label": "f(int i, const float f) const",
-# CHECK-NEXT:  "sortText": "35f"
+# CHECK-NEXT:  "sortText": "{{.*}}f"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "filterText": "fake",
 # CHECK-NEXT:  "insertText": "fake",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 7,
 # CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
+# CHECK-NEXT:  "sortText": "{{.*}}fake"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "fake &",
 # CHECK-NEXT:  "filterText": "operator=",
 # CHECK-NEXT:  "insertText": "operator=",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 2,
 # CHECK-NEXT:  "label": "operator=(const fake &)",
-# CHECK-NEXT:  "sortText": "79operator="
+# CHECK-NEXT:  "sortText": "{{.*}}operator="
 # CHECK-NEXT:},
 # FIXME: Why do some buildbots show an extra operator==(fake&&) here?
 #  CHECK:{
@@ -78,7 +78,7 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 4,
 # CHECK-NEXT:  "label": "~fake()",
-# CHECK-NEXT:  "sortText": "79~fake"
+# CHECK-NEXT:  "sortText": "{{.*}}~fake"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 Content-Length: 148
@@ -96,60 +96,60 @@
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "a",
-# CHECK-NEXT:  "sortText": "35a"
+# CHECK-NEXT:  "sortText": "{{.*}}"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "bb",
 # CHECK-NEXT:  "insertText": "bb",
 # CHECK-NEXT:  "insertTextFormat": 1,
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "bb",
-# CHECK-NEXT:  "sortText": "35bb"
+# CHECK-NEXT:  "sortText": "{{.*}}"
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": 

[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 123035.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Removed /*ref*/.
- Changed the command-line flag: it's -pch-storage now instead of 
-in-memory-pchs.
- Actually pass the StoreInMemory flag to PrecompiledPreamble::Build.
- Fixed a new usage of ClangdServer after rebase (In ClangdTests).


https://reviews.llvm.org/D39843

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/tool/ClangdMain.cpp
  test/clangd/completion.test
  test/clangd/diagnostics-preamble.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -332,6 +332,7 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+/*StorePreamblesInMemory=*/true,
 clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto  : ExtraFiles)
@@ -396,6 +397,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -442,6 +444,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -490,7 +493,9 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -524,7 +529,9 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -573,7 +580,9 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
+  /*AsyncThreadsCount=*/0,
+  /*StorePreamblesInMemory=*/true,
+  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -641,6 +650,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
   clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
@@ -701,7 +711,8 @@
   clangd::CodeCompleteOptions Opts;
   Opts.Limit = 2;
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  Opts, EmptyLogger::getInstance());
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   FS.Files[FooCpp] = "";
@@ -796,7 +807,8 @@
 
   auto TestWithOpts = [&](clangd::CodeCompleteOptions Opts) {
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-Opts, EmptyLogger::getInstance());
+/*StorePreamblesInMemory=*/true, Opts,
+EmptyLogger::getInstance());
 // No need to sync reparses here as there are no asserts on diagnostics (or
 // other async operations).
 Server.addDocument(FooCpp, GlobalCompletion.Text);
@@ -989,6 +1001,7 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, 

[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-11-15 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 123044.
cameron314 added a comment.

Fully rebased, with a test.


https://reviews.llvm.org/D20124

Files:
  include/clang/Lex/PreprocessingRecord.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/Module.h
  lib/Lex/PPDirectives.cpp
  lib/Lex/PreprocessingRecord.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/libclang/LibclangTest.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -572,3 +572,52 @@
   EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
   DisplayDiagnostics();
 }
+
+TEST_F(LibclangReparseTest, PreprocessorSkippedRanges) {
+  std::string Header = "header.h", Main = "main.cpp";
+  WriteFile(Header,
+"#ifdef MANGOS\n"
+"printf(\"mmm\");\n"
+"#endif");
+  WriteFile(Main,
+"#include \"header.h\"\n"
+"#ifdef KIWIS\n"
+"printf(\"mmm!!\");\n"
+"#endif");
+
+  unsigned flags = TUFlags |
+CXTranslationUnit_PrecompiledPreamble;//|
+  //CXTranslationUnit_CreatePreambleOnFirstParse;
+  for (int i = 0; i != 5; ++i) {
+if (i == 0) {
+  // first parse
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
+   nullptr, 0, flags);
+}
+else {
+  // reparse
+  ASSERT_TRUE(ReparseTU(0, nullptr /* No unsaved files. */));
+}
+
+CXSourceRangeList *Ranges = clang_getAllSkippedRanges(ClangTU);
+EXPECT_EQ(2U, Ranges->count);
+
+CXSourceLocation cxl;
+unsigned line;
+cxl = clang_getRangeStart(Ranges->ranges[0]);
+clang_getSpellingLocation(cxl, nullptr, , nullptr, nullptr);
+EXPECT_EQ(1U, line);
+cxl = clang_getRangeEnd(Ranges->ranges[0]);
+clang_getSpellingLocation(cxl, nullptr, , nullptr, nullptr);
+EXPECT_EQ(3U, line);
+
+cxl = clang_getRangeStart(Ranges->ranges[1]);
+clang_getSpellingLocation(cxl, nullptr, , nullptr, nullptr);
+EXPECT_EQ(2U, line);
+cxl = clang_getRangeEnd(Ranges->ranges[1]);
+clang_getSpellingLocation(cxl, nullptr, , nullptr, nullptr);
+EXPECT_EQ(4U, line);
+
+clang_disposeSourceRangeList(Ranges);
+  }
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1104,6 +1104,7 @@
   RECORD(UNUSED_FILESCOPED_DECLS);
   RECORD(PPD_ENTITIES_OFFSETS);
   RECORD(VTABLE_USES);
+  RECORD(PPD_SKIPPED_RANGES);
   RECORD(REFERENCED_SELECTOR_POOL);
   RECORD(TU_UPDATE_LEXICAL);
   RECORD(SEMA_DECL_REFS);
@@ -2725,6 +2726,26 @@
 Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
   bytes(PreprocessedEntityOffsets));
   }
+
+  // Write the skipped region table for the preprocessing record.
+  ArrayRef SkippedRanges = PPRec.getSkippedRanges();
+  if (SkippedRanges.size() > 0) {
+std::vector SerializedSkippedRanges;
+SerializedSkippedRanges.reserve(SkippedRanges.size());
+for (auto const& Range : SkippedRanges)
+  SerializedSkippedRanges.emplace_back(Range);
+
+using namespace llvm;
+auto Abbrev = std::make_shared();
+Abbrev->Add(BitCodeAbbrevOp(PPD_SKIPPED_RANGES));
+Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
+unsigned PPESkippedRangeAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
+
+Record.clear();
+Record.push_back(PPD_SKIPPED_RANGES);
+Stream.EmitRecordWithBlob(PPESkippedRangeAbbrev, Record,
+  bytes(SerializedSkippedRanges));
+  }
 }
 
 unsigned ASTWriter::getLocalOrImportedSubmoduleID(Module *Mod) {
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3214,6 +3214,24 @@
   break;
 }
 
+case PPD_SKIPPED_RANGES: {
+  F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange*)Blob.data();
+  assert(Blob.size() % sizeof(PPSkippedRange) == 0);
+  F.NumPreprocessedSkippedRanges = Blob.size() / sizeof(PPSkippedRange);
+
+  if (!PP.getPreprocessingRecord())
+PP.createPreprocessingRecord();
+  if (!PP.getPreprocessingRecord()->getExternalSource())
+PP.getPreprocessingRecord()->SetExternalSource(*this);
+  F.BasePreprocessedSkippedRangeID = PP.getPreprocessingRecord()
+  ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
+  
+  if (F.NumPreprocessedSkippedRanges > 0)
+GlobalSkippedRangeMap.insert(
+std::make_pair(F.BasePreprocessedSkippedRangeID, ));
+  break;
+}
+
 case DECL_UPDATE_OFFSETS:
   if (Record.size() % 2 != 0) {
 Error("invalid DECL_UPDATE_OFFSETS block in AST file");
@@ -5379,6 +5397,20 @@
  Mod.FileSortedDecls + 

[PATCH] D39579: BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318309: BuiltinOperatorOverloadBuilder: Don't consider types 
that are unavailable on… (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D39579?vs=121824=123041#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39579

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp

Index: cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
===
--- cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
+++ cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 -DMS %s
+
+template  struct enable_if {};
+template<> struct enable_if { typedef void type; };
+
+template  struct is_same { static constexpr bool value = false; };
+template  struct is_same { static constexpr bool value = true; };
+
+
+
+
+struct S {
+  // The only numeric types S can be converted to is __int128 and __float128.
+  template ::value ||
+  is_same::value ||
+  is_same::value)>::type>
+  operator T() { return T(); }
+};
+
+void f() {
+#ifdef MS
+  // When targeting Win32, __float128 and __int128 do not exist, so the S
+  // object cannot be converted to anything usable in the expression.
+  // expected-error@+2{{invalid operands to binary expression ('S' and 'double')}}
+#endif
+  double d = S() + 1.0;
+#ifndef MS
+  // expected-error@-2{{use of overloaded operator '+' is ambiguous}}
+  // expected-note@-3 36{{built-in candidate operator+}}
+#endif
+}
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7615,53 +7615,62 @@
   SmallVectorImpl 
   OverloadCandidateSet 
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  static constexpr int ArithmeticTypesCap = 24;
+  SmallVector ArithmeticTypes;
+
+  // Define some indices used to iterate over the arithemetic types in
+  // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  static const unsigned FirstIntegralType = 4;
-  static const unsigned LastIntegralType = 21;
-  static const unsigned FirstPromotedIntegralType = 4,
-LastPromotedIntegralType = 12;
-  static const unsigned FirstPromotedArithmeticType = 0,
-LastPromotedArithmeticType = 12;
-  static const unsigned NumArithmeticTypes = 21;
-
-  /// \brief Get the canonical type for a given arithmetic type index.
-  CanQualType getArithmeticType(unsigned index) {
-assert(index < NumArithmeticTypes);
-static CanQualType ASTContext::* const
-  ArithmeticTypes[NumArithmeticTypes] = {
-  // Start of promoted types.
-  ::FloatTy,
-  ::DoubleTy,
-  ::LongDoubleTy,
-  ::Float128Ty,
-
-  // Start of integral types.
-  ::IntTy,
-  ::LongTy,
-  ::LongLongTy,
-  ::Int128Ty,
-  ::UnsignedIntTy,
-  ::UnsignedLongTy,
-  ::UnsignedLongLongTy,
-  ::UnsignedInt128Ty,
-  // End of promoted types.
-
-  ::BoolTy,
-  ::CharTy,
-  ::WCharTy,
-  ::Char16Ty,
-  ::Char32Ty,
-  ::SignedCharTy,
-  ::ShortTy,
-  ::UnsignedCharTy,
-  ::UnsignedShortTy,
-  // End of integral types.
-  // FIXME: What about complex? What about half?
-};
-return S.Context.*ArithmeticTypes[index];
+  unsigned FirstIntegralType,
+   LastIntegralType;
+  unsigned FirstPromotedIntegralType,
+   LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType,
+   LastPromotedArithmeticType;
+  unsigned NumArithmeticTypes;
+
+  void InitArithmeticTypes() {
+// Start of promoted types.
+FirstPromotedArithmeticType = 0;
+ArithmeticTypes.push_back(S.Context.FloatTy);
+ArithmeticTypes.push_back(S.Context.DoubleTy);
+ArithmeticTypes.push_back(S.Context.LongDoubleTy);
+if (S.Context.getTargetInfo().hasFloat128Type())
+  ArithmeticTypes.push_back(S.Context.Float128Ty);
+
+// Start of integral types.
+FirstIntegralType = ArithmeticTypes.size();
+FirstPromotedIntegralType = ArithmeticTypes.size();
+ArithmeticTypes.push_back(S.Context.IntTy);
+ArithmeticTypes.push_back(S.Context.LongTy);
+ArithmeticTypes.push_back(S.Context.LongLongTy);
+if (S.Context.getTargetInfo().hasInt128Type())
+  

[PATCH] D39579: BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:7618
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  SmallVector ArithmeticTypes;
+

rsmith wrote:
> Can we do better than a magic number here? I don't like that getting this 
> wrong will lead to a silent performance change. (Can we at least assert 
> `isSmall()` below or something?)
It turns out `isSmall()` isn't public, so I can't use that directly, but I've 
added a constant for the capacity and an assert against that.

I don't actually know if there's any good reason for `isSmall()` to not be 
public. If you agree, I can follow up and just use that.


https://reviews.llvm.org/D39579



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


r318309 - BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)

2017-11-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Nov 15 09:11:53 2017
New Revision: 318309

URL: http://llvm.org/viewvc/llvm-project?rev=318309=rev
Log:
BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on 
the target (PR35174)

In the PR, Clang ended up in a situation where it tried to mangle the
__float128 type, which isn't supported when targetingt MSVC, because
Clang instantiated a variable template with that type when searching for
a conversion to use in an arithmetic expression.

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

Added:
cfe/trunk/test/SemaCXX/microsoft-vs-float128.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=318309=318308=318309=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 15 09:11:53 2017
@@ -7615,53 +7615,62 @@ class BuiltinOperatorOverloadBuilder {
   SmallVectorImpl 
   OverloadCandidateSet 
 
-  // Define some constants used to index and iterate over the arithemetic types
-  // provided via the getArithmeticType() method below.
-  // The "promoted arithmetic types" are the arithmetic
+  static constexpr int ArithmeticTypesCap = 24;
+  SmallVector ArithmeticTypes;
+
+  // Define some indices used to iterate over the arithemetic types in
+  // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  static const unsigned FirstIntegralType = 4;
-  static const unsigned LastIntegralType = 21;
-  static const unsigned FirstPromotedIntegralType = 4,
-LastPromotedIntegralType = 12;
-  static const unsigned FirstPromotedArithmeticType = 0,
-LastPromotedArithmeticType = 12;
-  static const unsigned NumArithmeticTypes = 21;
-
-  /// \brief Get the canonical type for a given arithmetic type index.
-  CanQualType getArithmeticType(unsigned index) {
-assert(index < NumArithmeticTypes);
-static CanQualType ASTContext::* const
-  ArithmeticTypes[NumArithmeticTypes] = {
-  // Start of promoted types.
-  ::FloatTy,
-  ::DoubleTy,
-  ::LongDoubleTy,
-  ::Float128Ty,
-
-  // Start of integral types.
-  ::IntTy,
-  ::LongTy,
-  ::LongLongTy,
-  ::Int128Ty,
-  ::UnsignedIntTy,
-  ::UnsignedLongTy,
-  ::UnsignedLongLongTy,
-  ::UnsignedInt128Ty,
-  // End of promoted types.
-
-  ::BoolTy,
-  ::CharTy,
-  ::WCharTy,
-  ::Char16Ty,
-  ::Char32Ty,
-  ::SignedCharTy,
-  ::ShortTy,
-  ::UnsignedCharTy,
-  ::UnsignedShortTy,
-  // End of integral types.
-  // FIXME: What about complex? What about half?
-};
-return S.Context.*ArithmeticTypes[index];
+  unsigned FirstIntegralType,
+   LastIntegralType;
+  unsigned FirstPromotedIntegralType,
+   LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType,
+   LastPromotedArithmeticType;
+  unsigned NumArithmeticTypes;
+
+  void InitArithmeticTypes() {
+// Start of promoted types.
+FirstPromotedArithmeticType = 0;
+ArithmeticTypes.push_back(S.Context.FloatTy);
+ArithmeticTypes.push_back(S.Context.DoubleTy);
+ArithmeticTypes.push_back(S.Context.LongDoubleTy);
+if (S.Context.getTargetInfo().hasFloat128Type())
+  ArithmeticTypes.push_back(S.Context.Float128Ty);
+
+// Start of integral types.
+FirstIntegralType = ArithmeticTypes.size();
+FirstPromotedIntegralType = ArithmeticTypes.size();
+ArithmeticTypes.push_back(S.Context.IntTy);
+ArithmeticTypes.push_back(S.Context.LongTy);
+ArithmeticTypes.push_back(S.Context.LongLongTy);
+if (S.Context.getTargetInfo().hasInt128Type())
+  ArithmeticTypes.push_back(S.Context.Int128Ty);
+ArithmeticTypes.push_back(S.Context.UnsignedIntTy);
+ArithmeticTypes.push_back(S.Context.UnsignedLongTy);
+ArithmeticTypes.push_back(S.Context.UnsignedLongLongTy);
+if (S.Context.getTargetInfo().hasInt128Type())
+  ArithmeticTypes.push_back(S.Context.UnsignedInt128Ty);
+LastPromotedIntegralType = ArithmeticTypes.size();
+LastPromotedArithmeticType = ArithmeticTypes.size();
+// End of promoted types.
+
+ArithmeticTypes.push_back(S.Context.BoolTy);
+ArithmeticTypes.push_back(S.Context.CharTy);
+ArithmeticTypes.push_back(S.Context.WCharTy);
+ArithmeticTypes.push_back(S.Context.Char16Ty);
+ArithmeticTypes.push_back(S.Context.Char32Ty);
+ArithmeticTypes.push_back(S.Context.SignedCharTy);
+ArithmeticTypes.push_back(S.Context.ShortTy);
+ArithmeticTypes.push_back(S.Context.UnsignedCharTy);
+ArithmeticTypes.push_back(S.Context.UnsignedShortTy);
+LastIntegralType = ArithmeticTypes.size();
+NumArithmeticTypes = 

r318304 - ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in headers

2017-11-15 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Nov 15 08:52:12 2017
New Revision: 318304

URL: http://llvm.org/viewvc/llvm-project?rev=318304=rev
Log:
ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in 
headers

Internal linkage variables ODR referenced from inline functions create
ODR violations (the same inline function ends up having different
definitions in each TU, since it references different variables - rather
than one definition).

This also happens to break modular code generation - so this is the last
fix to allow clang to compile with modular code generation.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=318304=318303=318304=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Nov 15 08:52:12 2017
@@ -178,7 +178,7 @@ inline internal::TrueMatcher anything()
 /// \endcode
 /// decl(hasDeclContext(translationUnitDecl()))
 ///   matches "int X", but not "int Y".
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 translationUnitDecl;
 
 /// \brief Matches typedef declarations.
@@ -190,7 +190,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typedefDecl()
 ///   matches "typedef int X", but not "using Y = int"
-const internal::VariadicDynCastAllOfMatcher typedefDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+typedefDecl;
 
 /// \brief Matches typedef name declarations.
 ///
@@ -201,7 +202,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typedefNameDecl()
 ///   matches "typedef int X" and "using Y = int"
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 typedefNameDecl;
 
 /// \brief Matches type alias declarations.
@@ -213,7 +214,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// typeAliasDecl()
 ///   matches "using Y = int", but not "typedef int X"
-const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+typeAliasDecl;
 
 /// \brief Matches type alias template declarations.
 ///
@@ -222,7 +224,7 @@ const internal::VariadicDynCastAllOfMatc
 ///   template 
 ///   using Y = X;
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 typeAliasTemplateDecl;
 
 /// \brief Matches AST nodes that were expanded within the main-file.
@@ -313,7 +315,7 @@ AST_POLYMORPHIC_MATCHER_P(isExpansionInF
 /// friend X;
 ///   };
 /// \endcode
-const internal::VariadicAllOfMatcher decl;
+extern const internal::VariadicAllOfMatcher decl;
 
 /// \brief Matches a declaration of a linkage specification.
 ///
@@ -323,7 +325,7 @@ const internal::VariadicAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 linkageSpecDecl;
 
 /// \brief Matches a declaration of anything that could have a name.
@@ -337,7 +339,7 @@ const internal::VariadicDynCastAllOfMatc
 /// } U;
 ///   };
 /// \endcode
-const internal::VariadicDynCastAllOfMatcher namedDecl;
+extern const internal::VariadicDynCastAllOfMatcher namedDecl;
 
 /// \brief Matches a declaration of label.
 ///
@@ -348,7 +350,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// labelDecl()
 ///   matches 'FOO:'
-const internal::VariadicDynCastAllOfMatcher labelDecl;
+extern const internal::VariadicDynCastAllOfMatcher labelDecl;
 
 /// \brief Matches a declaration of a namespace.
 ///
@@ -359,7 +361,8 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// namespaceDecl()
 ///   matches "namespace {}" and "namespace test {}"
-const internal::VariadicDynCastAllOfMatcher namespaceDecl;
+extern const internal::VariadicDynCastAllOfMatcher
+namespaceDecl;
 
 /// \brief Matches a declaration of a namespace alias.
 ///
@@ -370,7 +373,7 @@ const internal::VariadicDynCastAllOfMatc
 /// \endcode
 /// namespaceAliasDecl()
 ///   matches "namespace alias" but not "namespace test"
-const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
 namespaceAliasDecl;
 
 /// \brief Matches class, struct, and union declarations.
@@ -382,9 +385,7 @@ const internal::VariadicDynCastAllOfMatc
 ///   struct S {};
 ///   union U {};
 /// \endcode

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

benhamilton wrote:
> Naming nit-pick: We are currently using `ObjC`, not `Objc`.
We also need to rename the file name. 



Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6-7
+
+This check finds @throw usages in Objective-C files. According to Google's 
Objective-C
+Guide, we should not use @throw to handle exceptions.
+

benhamilton wrote:
> How about:
> 
> This check finds @throw usages in Objective-C files. [For the same reasons as 
> the Google C++ style 
> guide](https://google.github.io/styleguide/cppguide.html#Exceptions), we 
> [prefer not throwing exceptions from Objective-C 
> code](http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions).
> 
> Instead, prefer passing in `NSError **` and return `BOOL` to indicate success 
> or failure. A counterexample:
> 
> ```lang=objectivec
> - (void)readFile {
>   if ([self isError]) {
> @throw [NSException exceptionWithName:...];
>   }
> }
> ```
> 
> Instead, returning an error via `NSError **` is preferred:
> 
> ```lang=objectivec
> - (BOOL)readFileWithError:(NSError **)error {
>   if ([self isError]) {
> *error = [NSError errorWithDomain:...];
> return NO;
>   }
>   return YES;
> }
> ```
> 
+1 on an illustrated sample :)


https://reviews.llvm.org/D40058



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


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:238
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, Buffer.get());
+Preamble->AddImplicitPreamble(*CI, /*ref*/ VFS, Buffer.get());
   } else {

sammccall wrote:
> ref is still here :-)
Thx. Missed that. Removed.



Comment at: clangd/tool/ClangdMain.cpp:48
 
+static llvm::cl::opt StorePreamblesInMemory(
+"in-memory-pchs",

sammccall wrote:
> Couple of questions about the flag syntax:
>  - I wonder about the granularity - if we had another temp storage 
> (indexes?), would we want another flag or something shared like 
> `-in-memory-storage`
>  - Having this as a bool seems confusing compared to 
> `-pch-storage={memory/disk}`. (We could also overload such a flag to allow 
> setting the location, but nobody's asked for that yet)
  - Indexes are fundamentally different because we actually want to persist 
them across multiple sessions. But I see your point. I'd go with another flag 
for greater flexibility. We do want clangd work great by-default, so those 
flags are mostly for people who know what they're doing and can figure out 
which flags they want to change and why. Maybe I'm not right, though, and 
people would want those kinds of switches.
  - Totally like the `-pch-storage={memory/disk}`  more, updated the change 
accordingly.




https://reviews.llvm.org/D39843



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


[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-11-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 123027.
jdenny added a comment.

1. Capitalized some of the new local variables according to coding standards.

2. Rebased on master/trunk fetched today.


https://reviews.llvm.org/D39694

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticOptions.h
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  test/Frontend/verify-prefixes.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.cpp
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence -x c++ %s
 
 unsigned uvalue(void);
 signed int svalue(void);
@@ -13,13 +13,8 @@
 void TFunc() {
   // Make sure that we do warn for normal variables in template functions !
   unsigned char c = svalue();
-#ifdef TEST
   if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
   return;
-#else
-  if (c < 0)
-  return;
-#endif
 
   if (c < macro(0))
   return;
@@ -39,7 +34,8 @@
 
   unsigned un = uvalue();
 
-#ifdef TEST
+  // silence-no-diagnostics
+
   if (un == 0)
   return 0;
   if (un != 0)
@@ -91,65 +87,10 @@
   return 0;
   if (0UL >= un)
   return 0;
-#else
-// expected-no-diagnostics
-  if (un == 0)
-  return 0;
-  if (un != 0)
-  return 0;
-  if (un < 0)
-  return 0;
-  if (un <= 0)
-  return 0;
-  if (un > 0)
-  return 0;
-  if (un >= 0)
-  return 0;
-
-  if (0 == un)
-  return 0;
-  if (0 != un)
-  return 0;
-  if (0 < un)
-  return 0;
-  if (0 <= un)
-  return 0;
-  if (0 > un)
-  return 0;
-  if (0 >= un)
-  return 0;
-
-  if (un == 0UL)
-  return 0;
-  if (un != 0UL)
-  return 0;
-  if (un < 0UL)
-  return 0;
-  if (un <= 0UL)
-  return 0;
-  if (un > 0UL)
-  return 0;
-  if (un >= 0UL)
-  return 0;
-
-  if (0UL == un)
-  return 0;
-  if (0UL != un)
-  return 0;
-  if (0UL < un)
-  return 0;
-  if (0UL <= un)
-  return 0;
-  if (0UL > un)
-  return 0;
-  if (0UL >= un)
-  return 0;
-#endif
 
 
   signed int a = svalue();
 
-#ifdef TEST
   if (a == 0)
   return 0;
   if (a != 0)
@@ -201,60 +142,6 @@
   return 0;
   if (0UL >= a)
   return 0;
-#else
-// expected-no-diagnostics
-  if (a == 0)
-  return 0;
-  if (a != 0)
-  return 0;
-  if (a < 0)
-  return 0;
-  if (a <= 0)
-  return 0;
-  if (a > 0)
-  return 0;
-  if (a >= 0)
-  return 0;
-
-  if (0 == a)
-  return 0;
-  if (0 != a)
-  return 0;
-  if (0 < a)
-  return 0;
-  if (0 <= a)
-  return 0;
-  if (0 > a)
-  return 0;
-  if (0 >= a)
-  return 0;
-
-  if (a == 0UL)
-  return 0;
-  if (a != 0UL)
-  return 0;
-  if (a < 0UL)
-  return 0;
-  if (a <= 0UL)
-  return 0;
-  if (a > 0UL)
-  return 0;
-  if (a >= 0UL)
-  return 0;
-
-  if (0UL == a)
-  return 0;
-  if (0UL != a)
-  return 0;
-  if (0UL < a)
-  return 0;
-  if (0UL <= a)
-  return 0;
-  if (0UL > a)
-  return 0;
-  if (0UL >= a)
-  return 0;
-#endif
 
 
   float fl = 0;
Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp
===
--- test/Sema/tautological-unsigned-enum-zero-compare.cpp
+++ test/Sema/tautological-unsigned-enum-zero-compare.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSILENCE -Wno-tautological-unsigned-enum-zero-compare -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only \
+// RUN:-verify=unsigned,unsigned-signed,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:-verify=unsigned-signed,signed-silence,expected %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only \
+// RUN:

[PATCH] D40058: add check to avoid throwing objc exception according to Google Objective-C guide

2017-11-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

Almost there.




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:22
+void AvoidThrowingObjcExceptionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
+}

It looks like we also need to catch (no pun intended :) people who invoke the 
following class methods:

```
+[NSException raise:format:]
+[NSException raise:format:arguments:]
```

We actually have a few places that use these:

http://google3/googlemac/iPhone/Maps/SDK/Maps/GMSServices.mm?l=412=174266104
http://google3/googlemac/iPhone/Bigtop/Source/Actions/ActionHandler.m?l=1942=174353485
http://google3/googlemac/iPhone/Applecrisp/Sketchy/Classes/Sketchy/SketchyLib/SketchyApplicationContext.mm?l=398=175173348




Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.cpp:30
+  diag(MatchedStmt->getThrowLoc(),
+   "avoid using @throw to handle Objective-C exceptions");
+}

Suggested wording:

"Pass in NSError ** instead of using @throw to indicate Objective-C errors"



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:1
+//===--- AvoidThrowingObjcExceptionCheck.h - clang-tidy--*- C++ 
-*-===//
+//

Naming nit-pick: We are currently using `ObjC`, not `Objc`.



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:21-22
+/// The check is to find usage of @throw invocation in Objective-C code.
+/// We should avoid using @throw for Objective-C exceptions according to
+/// Google Objective-C Style Guide.
+///

Grammar nit:

according to Google Objective-C Style Guide -> according to the Google 
Objective-C Style Guide



Comment at: clang-tidy/google/AvoidThrowingObjcExceptionCheck.h:26
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/google-objc-avoid-throwing-exception.html
+class AvoidThrowingObjcExceptionCheck : public ClangTidyCheck {
+ public:

`Objc` -> `ObjC`




Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:6-7
+
+This check finds @throw usages in Objective-C files. According to Google's 
Objective-C
+Guide, we should not use @throw to handle exceptions.
+

How about:

This check finds @throw usages in Objective-C files. [For the same reasons as 
the Google C++ style 
guide](https://google.github.io/styleguide/cppguide.html#Exceptions), we 
[prefer not throwing exceptions from Objective-C 
code](http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions).

Instead, prefer passing in `NSError **` and return `BOOL` to indicate success 
or failure. A counterexample:

```lang=objectivec
- (void)readFile {
  if ([self isError]) {
@throw [NSException exceptionWithName:...];
  }
}
```

Instead, returning an error via `NSError **` is preferred:

```lang=objectivec
- (BOOL)readFileWithError:(NSError **)error {
  if ([self isError]) {
*error = [NSError errorWithDomain:...];
return NO;
  }
  return YES;
}
```




Comment at: docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst:10
+The corresponding style guide rule:
+http://go/objc-style#Avoid_Throwing_Exceptions

hokein wrote:
> Use the public link: 
> http://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions
+1


https://reviews.llvm.org/D40058



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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:206
+  std::unique_ptr Storage;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > It looks like we should pass in the output stream, not the storage?
> > We're not actually using the `Storage` variable, it's a leftover from 
> > previous versions. Removed it.
> > 
> > Or did you mean that we should pass in the output stream directly to 
> > `PrecompilePreambleAction`'s constructor?
> Yes, I'm generally looking at things that might be better to decide at a 
> higher abstraction level and pass in, rather than having switches for 
> behavior (like InMemStorage) all over the place. Generally, I think we should 
> have a storage (PCHStorage sounds like it was the right abstraction, but 
> perhaps that one currently has a bad name) and the things dealing with that 
> storage shouldn't care whether it's in memory or on the file system.
It's a bit easier to share code with `GeneratePCHAction` this way in a way that 
would obviously works (as we call the same functions at the same points in the 
compilation pipeline, that is in `CreateASTConsumer`). 

`PCHStorage` is not a public interface and `PrecompiledPreamble` is exactly the 
interface that let's you use it without caring whether PCHs are stored in 
memory or on disk. It also feels ok for it to have the storage-dependent code 
as part of its own implementation.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:490
   PreprocessorOpts.DisablePCHValidation = true;
+  if (Storage.getKind() == PCHStorage::Kind::TempFile) {
+const TempPCHFile  = Storage.asFile();

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > This looks a bit like we should push it into the PCHStorage.
> > I've extracted a function here to make the code read simpler.
> > However, I placed it directly into the `PrecompiledPreamble` instead of 
> > `PCHStorage` to keep `PCHStorage` responsible for just one thing: managing 
> > the `variant`-like union.
> It being called PCHStorage makes it sound like it handles the abstraction for 
> how the preamble is stored. Given that the variant-like union is basically an 
> interface with an implementation switch, I think all switching on it is also 
> the responsibility of that class. Otherwise we'd need another abstraction on 
> top of it?
Abstraction on top of it is `PrecompiledPreamble` itself. And `PCHStorage` is 
just an implementation detail.
Does that sound reasonable?


https://reviews.llvm.org/D39842



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

> Mips is the only other implementer of shouldSignExtUnsignedType but is 
> unaffected, as unlike classifyArgumentType, classifyReturnType will not 
> extend i32 values (@sdardis: is this a bug?).

I believe this is an oversight that is addressed in the backend. The MIPS64 
backend treats 'trunc i64 %x to i32' as '(SLL (EXTRACT_SUBREG GPR64:$src, 
sub_32), 0)', which is required to match MIPS32 arithmetic works on MIPS64.

I will take a longer look at this issue.

Thanks.


https://reviews.llvm.org/D40023



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


[PATCH] D39812: [Driver, CodeGen] pass through and apply -fassociative-math

2017-11-15 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Ping.


https://reviews.llvm.org/D39812



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


[PATCH] D39730: Enabling constructor code completion

2017-11-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added a comment.

Sorry, what do you mean by "this works in the body of the class"?

Definition of constructor inside class definition has been working even before:

struct foo {

  foo();
  f

};

Do you mean that a test shall be added in order to check that it still works?


https://reviews.llvm.org/D39730



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

rjmccall wrote:
> ABataev wrote:
> > Hahnfeld wrote:
> > > rjmccall wrote:
> > > > Hahnfeld wrote:
> > > > > rjmccall wrote:
> > > > > > Hahnfeld wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > ABataev wrote:
> > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > Hahnfeld wrote:
> > > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > > The way you've written this makes it sound like 
> > > > > > > > > > > > > > > > "does the target support VLAs?", but the actual 
> > > > > > > > > > > > > > > > semantic checks treat it as "do OpenMP devices 
> > > > > > > > > > > > > > > > on this target support VLAs?"  Maybe there 
> > > > > > > > > > > > > > > > should be a more specific way to query things 
> > > > > > > > > > > > > > > > about OpenMP devices instead of setting a 
> > > > > > > > > > > > > > > > global flag for the target?
> > > > > > > > > > > > > > > Actually, the NVPTX and SPIR targets never 
> > > > > > > > > > > > > > > support VLAs. So I felt like it would be more 
> > > > > > > > > > > > > > > correct to make this a global property of the 
> > > > > > > > > > > > > > > target.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > The difference is that the other programming 
> > > > > > > > > > > > > > > models (OpenCL and CUDA) error out immediatelyand 
> > > > > > > > > > > > > > > regardless of the target because this limitation 
> > > > > > > > > > > > > > > is reflected in the standards that disallow VLAs 
> > > > > > > > > > > > > > > (see SemaType.cpp). For OpenMP we might have 
> > > > > > > > > > > > > > > target devices that support VLA so we shouldn't 
> > > > > > > > > > > > > > > error out for those.
> > > > > > > > > > > > > > If you want to make it a global property of the 
> > > > > > > > > > > > > > target, that's fine, but then I don't understand 
> > > > > > > > > > > > > > why your diagnostic only fires when 
> > > > > > > > > > > > > > (S.isInOpenMPDeclareTargetContext() || 
> > > > > > > > > > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > > > > > > > > > That is because of how OpenMP offloading works and 
> > > > > > > > > > > > > how it is implemented in Clang. Consider the 
> > > > > > > > > > > > > following snippet from the added test case:
> > > > > > > > > > > > > ```lang=c
> > > > > > > > > > > > > int vla[arg];
> > > > > > > > > > > > > 
> > > > > > > > > > > > > #pragma omp target map(vla[0:arg])
> > > > > > > > > > > > > {
> > > > > > > > > > > > >// more code here...
> > > > > > > > > > > > > }
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Clang will take the following steps to compile this 
> > > > > > > > > > > > > into a working binary for a GPU:
> > > > > > > > > > > > > 1. Parse and (semantically) analyze the code as-is 
> > > > > > > > > > > > > for the host and produce LLVM Bitcode.
> > > > > > > > > > > > > 2. Parse and analyze again the code as-is and 
> > > > > > > > > > > > > generate code for the offloading target, the GPU in 
> > > > > > > > > > > > > this case.
> > > > > > > > > > > > > 3. Take LLVM Bitcode from 1., generate host binary 
> > > > > > > > > > > > > and embed target binary from 3.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > `OpenMPIsDevice` will be true for 2., but the 
> > > > > > > > > > > > > complete source code is analyzed. So to not throw 
> > > > > > > > > > > > > errors for the host code, we have to make sure that 
> > > > > > > > > > > > > we are actually generating code for the target 
> > > > > > > > > > > > > device. This is either in a `target` directive or in 
> > > > > > > > > > > > > a `declare target` region.
> > > > > > > > > > > > > Note that this is quite similar to what CUDA does, 
> > > > > > > > > > > > > only they have `CUDADiagIfDeviceCode` for this logic. 
> > > > > > > > > > > > > If you want me to add something of that kind for 
> > > > > > > > > > > > > OpenMP target devices, I'm fine with that. However 
> > > > > > > > > > > > > for the given case, it's a bit different because this 
> > > > > > > > > > > > > error should only be thrown for target devices that 
> > > > > > > > > > > > > don't support VLAs...
> > > > > > > > > > > > I see.  So the entire translation unit is re-parsed and 
> > > > > > > > > > > > re-Sema'ed from scratch for the target?  Which means 
> > > > > > > > > > > > you need to avoid generating errors about things in the 
> > > > > > > > > > > > outer translation unit that aren't part of the target 
> > > > > > > > > > > > directive that you actually want to compile.  I 
> > > > > > > > > > > > 

[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 123020.
asb marked an inline comment as done.
asb added a comment.

Updated to address review comments. I've added some extra test coverage that 
demonstrates that argument lowering happens the same once registers are 
exhausted, as well as more coverage around varargs. Also updated to properly 
handle the "aligned register pair" rule for variadic arguments, and added tests 
for this.


https://reviews.llvm.org/D40023

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/riscv32-abi.c
  test/CodeGen/riscv64-abi.c
  test/Driver/riscv32-toolchain.c
  test/Driver/riscv64-toolchain.c

Index: test/Driver/riscv64-toolchain.c
===
--- test/Driver/riscv64-toolchain.c
+++ test/Driver/riscv64-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 8
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: define zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define signext i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define signext i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i64 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define signext i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i64 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i64 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/Driver/riscv32-toolchain.c
===
--- test/Driver/riscv32-toolchain.c
+++ test/Driver/riscv32-toolchain.c
@@ -42,3 +42,50 @@
 
 // CHECK: @align_vl = global i32 4
 int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: zeroext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: define signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: define i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: define i32 @check_wchar_t()
+int check_wchar_t() { return 0; }
+
+// CHECK: define i32 @check_long()
+long check_long() { return 0; }
+
+// CHECK: define i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: define zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: define zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: define i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: define i32 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: define i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: define i32 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: define float @check_float()
+float check_float() { return 0; }
+
+// CHECK: define double @check_double()
+double check_double() { return 0; }
+
+// CHECK: define fp128 @check_longdouble()
+long double check_longdouble() { return 0; }
Index: test/CodeGen/riscv64-abi.c
===
--- /dev/null
+++ test/CodeGen/riscv64-abi.c
@@ -0,0 +1,406 @@
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
+
+#include 
+#include 
+
+// CHECK-LABEL: define void @f_void()
+void f_void(void) {}
+
+// Scalar arguments and return values smaller than the word size are extended
+// according to the sign of their type, up to 32 bits
+
+// CHECK-LABEL: define signext i8 @f_scalar_1(i8 signext %x)
+int8_t f_scalar_1(int8_t x) { return x; }
+
+// CHECK-LABEL: define zeroext i8 @f_scalar_2(i8 zeroext %x)
+uint8_t f_scalar_2(uint8_t x) { return x; }
+
+// CHECK-LABEL: define signext i32 @f_scalar_3(i32 signext %x)
+uint32_t f_scalar_3(int32_t x) { return x; }
+
+// CHECK-LABEL: define i64 @f_scalar_4(i64 %x)
+int64_t f_scalar_4(int64_t x) { return x; }
+
+// CHECK-LABEL: define float @f_fp_scalar_1(float %x)
+float f_fp_scalar_1(float x) { return x; }
+
+// CHECK-LABEL: define double @f_fp_scalar_2(double %x)
+double f_fp_scalar_2(double x) { return x; }
+
+// CHECK-LABEL: define fp128 @f_fp_scalar_3(fp128 %x)
+long double f_fp_scalar_3(long double x) { return x; }
+
+// Aggregates <= 2*xlen may be passed in registers, so will be coerced to
+// integer arguments. The rules 

[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8858
+  else
+NeededArgGPRs = 1;
+

efriedma wrote:
> It looks like the ABI says there's a special rule for varargs here?
You're right, I neglected vararg calls. Now addressed and test cases added. The 
difference is only observable on RV64 I believe (as we only use the GPR 
tracking to decide whether an argument should be extended or not, and the 
argument promotion rules mean you'll never see signext/zeroext on varargs in 
RV32).



Comment at: lib/CodeGen/TargetInfo.cpp:8914
+Address RISCVABIInfo::EmitVAArg(CodeGenFunction , Address VAListAddr,
+QualType Ty) const {
+  CharUnits SlotSize = CharUnits::fromQuantity(XLen / 8);

efriedma wrote:
> The type of va_list and the behavior of va_arg should be documented in the 
> ABI doc... but apparently it's missing at the moment?  (I mean, this is the 
> obvious implementation from what is mentioned, but it would be nice to see 
> something more explicit.)
I've started an attempt to better document things 
https://github.com/riscv/riscv-elf-psabi-doc/pull/60



Comment at: test/CodeGen/riscv32-abi.c:118
+// single 2*xlen-sized argument, to ensure that alignment can be maintained if
+// it spills to the stack
+

efriedma wrote:
> Please clarify this comment; the ABI doc doesn't say anything about aligning 
> arguments whose alignment is 2✕XLEN, except in the case of varargs.
I've corrected the comment to say "if passed on the stack" and submitted a PR 
to clarify the ABI doc https://github.com/riscv/riscv-elf-psabi-doc/pull/59


https://reviews.llvm.org/D40023



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-11-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for your respone! However, I think you (not you, Artem, but you three 
at Apple) do not really understand that I need to compare A+m to B+n not only 
because of the iterator range checking, but also in later parts. So your 
proposal means that I am not allowed to fix the shortcomings of the constraint 
solver neither in the engine nor in the checker. Maybe part 2 of the iterator 
checkers patch will work, but then we will restart the whole dispute at a later 
part.

As I mentioned, I need these comparisons in a lot of places, not only in range 
checking. This is the core part of my solution. It is primarily needed for 
invalidation, which is the most solid part. The latest version (not part 10, 
but a fixed version of the whole chekcer set) finds only 5 false positives for 
invalidated iterator access, which I could further reduce by adding more 
detailed simulation of insertion and erasement.

So still the options are to fix it in the checker or fix it in the engine (the 
max/4 or the type extension solution), but leaving it unfixed is not an option. 
I am open to any solution, but only full solutions and no partial solutions, 
because they will not help us enough.


https://reviews.llvm.org/D35109



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-11-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The unconstrained rearrangements for `+`/`-`/`==`/`!=` are definitely good to 
go regardless of anything else.

Within the checker, we propose to manually simplify both `$x - N < $x` and `$x 
+ N > $x` to true (where N is positive), because in general this is unsound 
(due to potential overflows), but for iterator position symbols this is **the** 
intended behavior (if `container.end() + N` overflows, it's even worse than a 
regular past-end access).

For the rest of the cases (`>`/`<` with mixed symbols), we propose to delay the 
decision for now. For now simply admit that the solver is not awesome. If we 
had a perfect solver, we wouldn't have to rearrange anything, so the root cause 
of the problem is in the solver, and we shouldn't be fixing it on the checker 
side. If, before turning the checker on by default, we prove through evaluation 
that this shortcoming of the solver is indeed a bigger problem for this checker 
than for the rest of the analyzer, and is also the biggest problem with the 
checker, we can still come up with something (eg. the already-existing max/4 
approach). But let's delay this until we see how bad this part of the problem 
actually is.


https://reviews.llvm.org/D35109



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


  1   2   >