[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-06 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun marked an inline comment as done.
khuttun added inline comments.



Comment at: clang-tidy/bugprone/UnusedReturnValueCheck.cpp:69
+ "the value returned by %0 should normally be used")
+<< dyn_cast_or_null(Matched->getCalleeDecl())
+<< Matched->getSourceRange();

aaron.ballman wrote:
> In the event this returns null, the diagnostic is going to look rather odd. 
> Because the value of the call expression is unused, this will most often 
> trigger in a context where the method call can be inferred (especially 
> because you're now highlighting the source range). It might make sense to 
> simply replace the %0 with "this call expression" or somesuch in the 
> diagnostic.
I can remove the function name from the diagnostic. Out of curiosity, in which 
situations could it be null?


https://reviews.llvm.org/D41655



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-06 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun updated this revision to Diff 128844.
khuttun added a comment.

Fix review comments


https://reviews.llvm.org/D41655

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tidy/bugprone/UnusedReturnValueCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-unused-return-value.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-unused-return-value-custom.cpp
  test/clang-tidy/bugprone-unused-return-value.cpp

Index: test/clang-tidy/bugprone-unused-return-value.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-unused-return-value.cpp
@@ -0,0 +1,208 @@
+// RUN: %check_clang_tidy %s bugprone-unused-return-value %t
+
+namespace std {
+
+using size_t = decltype(sizeof(int));
+
+using max_align_t = long double;
+
+struct future {};
+
+enum class launch {
+  async,
+  deferred
+};
+
+template 
+future async(Function &&, Args &&...);
+
+template 
+future async(launch, Function &&, Args &&...);
+
+template 
+bool empty(const T&);
+
+// the check should be able to match std lib calls even if the functions are
+// declared inside inline namespaces
+inline namespace v1 {
+
+template 
+T *launder(T *);
+
+} // namespace v1
+
+template 
+struct allocator {
+  using value_type = T;
+  T *allocate(std::size_t);
+  T *allocate(std::size_t, const void *);
+};
+
+template 
+struct allocator_traits {
+  using value_type = typename Alloc::value_type;
+  using pointer = value_type *;
+  using size_type = size_t;
+  using const_void_pointer = const void *;
+  static pointer allocate(Alloc &, size_type);
+  static pointer allocate(Alloc &, size_type, const_void_pointer);
+};
+
+template 
+struct scoped_allocator_adaptor : public OuterAlloc {
+  using pointer = typename allocator_traits::pointer;
+  using size_type = typename allocator_traits::size_type;
+  using const_void_pointer = typename allocator_traits::const_void_pointer;
+  pointer allocate(size_type);
+  pointer allocate(size_type, const_void_pointer);
+};
+
+template 
+struct default_delete {};
+
+template >
+struct unique_ptr {
+  using pointer = T *;
+  pointer release() noexcept;
+};
+
+template >
+struct vector {
+  bool empty() const noexcept;
+};
+
+namespace filesystem {
+
+struct path {
+  bool empty() const noexcept;
+};
+
+} // namespace filesystem
+
+namespace pmr {
+
+struct memory_resource {
+  void *allocate(size_t, size_t = alignof(max_align_t));
+};
+
+template 
+struct polymorphic_allocator {
+  T *allocate(size_t);
+};
+
+} // namespace pmr
+
+} // namespace std
+
+struct Foo {
+  void f();
+};
+
+int increment(int i) {
+  return i + 1;
+}
+
+void useFuture(const std::future &fut);
+
+struct FooAlloc {
+  using value_type = Foo;
+};
+
+void warning() {
+  std::async(increment, 42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::async(std::launch::async, increment, 42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  Foo F;
+  std::launder(&F);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::unique_ptr UP;
+  UP.release();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::allocator FA;
+  FA.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  FA.allocate(1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::allocator_traits>::allocate(FA, 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  std::allocator_traits>::allocate(FA, 1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::scoped_allocator_adaptor SAA;
+  SAA.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+  SAA.allocate(1, nullptr);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::pmr::memory_resource MR;
+  MR.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::pmr::polymorphic_allocator PA;
+  PA.allocate(1);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+
+  std::vector FV;
+  FV.empty();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the val

[PATCH] D41538: [analyzer] Fix some checker's output plist not containing the checker name #2

2018-01-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321933: [analyzer] Fix some check's output plist not 
containing the check name (authored by xazax, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41538?vs=128630&id=128845#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41538

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/malloc.c

Index: include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
@@ -32,27 +32,39 @@
   const CheckName Check;
   const std::string Name;
   const std::string Category;
-  bool SuppressonSink;
+  const CheckerBase *Checker;
+  bool SuppressOnSink;
 
   virtual void anchor();
+
 public:
-  BugType(class CheckName check, StringRef name, StringRef cat)
-  : Check(check), Name(name), Category(cat), SuppressonSink(false) {}
-  BugType(const CheckerBase *checker, StringRef name, StringRef cat)
-  : Check(checker->getCheckName()), Name(name), Category(cat),
-SuppressonSink(false) {}
-  virtual ~BugType() {}
+  BugType(CheckName Check, StringRef Name, StringRef Cat)
+  : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
+SuppressOnSink(false) {}
+  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
+  : Check(Checker->getCheckName()), Name(Name), Category(Cat),
+Checker(Checker), SuppressOnSink(false) {}
+  virtual ~BugType() = default;
 
-  // FIXME: Should these be made strings as well?
   StringRef getName() const { return Name; }
   StringRef getCategory() const { return Category; }
-  StringRef getCheckName() const { return Check.getName(); }
+  StringRef getCheckName() const {
+// FIXME: This is a workaround to ensure that the correct check name is used
+// The check names are set after the constructors are run.
+// In case the BugType object is initialized in the checker's ctor
+// the Check field will be empty. To circumvent this problem we use 
+// CheckerBase whenever it is possible.
+StringRef CheckName =
+Checker ? Checker->getCheckName().getName() : Check.getName();
+assert(!CheckName.empty() && "Check name is not set properly.");
+return CheckName;
+  }
 
   /// isSuppressOnSink - Returns true if bug reports associated with this bug
   ///  type should be suppressed if the end node of the report is post-dominated
   ///  by a sink node.
-  bool isSuppressOnSink() const { return SuppressonSink; }
-  void setSuppressOnSink(bool x) { SuppressonSink = x; }
+  bool isSuppressOnSink() const { return SuppressOnSink; }
+  void setSuppressOnSink(bool x) { SuppressOnSink = x; }
 
   virtual void FlushReports(BugReporter& BR);
 };
@@ -74,7 +86,7 @@
   StringRef getDescription() const { return desc; }
 };
 
-} // end GR namespace
+} // end ento namespace
 
 } // end clang namespace
 #endif
Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1720,13 +1720,6 @@
   }
 }
 
-char *dupstrWarn(const char *s) {
-  const int len = strlen(s);
-  char *p = (char*) smallocWarn(len + 1);
-  strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
-  return p;
-}
-
 int *radar15580979() {
   int *data = (int *)malloc(32);
   int *p = data ?: (int*)malloc(32); // no warning
Index: lib/StaticAnalyzer/Checkers/ValistChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ValistChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ValistChecker.cpp
@@ -64,7 +64,7 @@
  CheckerContext &C) const;
   void reportLeakedVALists(const RegionVector &LeakedVALists, StringRef Msg1,
StringRef Msg2, CheckerContext &C, ExplodedNode *N,
-   bool ForceReport = false) const;
+   bool ReportUninit = false) const;
 
   void checkVAListStartCall(const CallEvent &Call, CheckerContext &C,
 bool IsCopy) const;
@@ -267,15 +267,19 @@
 void ValistChecker::reportLeakedVALists(const RegionVector &LeakedVALists,
 StringRef Msg1, StringRef Msg2,
 CheckerContext &C, ExplodedNode *N,
-bool ForceReport) const {
+bool ReportUninit) const {
   if (!(ChecksEnabled[CK_Unterminated] ||
-(ChecksEnabled[CK_Uninitialized] && ForceReport)))
+(ChecksEnabled[CK_Uninitialized] && ReportUninit)))
 return;
   for (auto Reg : LeakedVALists) {
 if (!BT_leakedvalist) {
- 

[PATCH] D37437: [analyzer] Fix some checker's output plist not containing the checker name

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

https://reviews.llvm.org/D41538 is superior and committed.


https://reviews.llvm.org/D37437



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


r321933 - [analyzer] Fix some check's output plist not containing the check name

2018-01-06 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Sat Jan  6 02:51:00 2018
New Revision: 321933

URL: http://llvm.org/viewvc/llvm-project?rev=321933&view=rev
Log:
[analyzer] Fix some check's output plist not containing the check name

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/test/Analysis/malloc.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h?rev=321933&r1=321932&r2=321933&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h Sat Jan  
6 02:51:00 2018
@@ -32,27 +32,39 @@ private:
   const CheckName Check;
   const std::string Name;
   const std::string Category;
-  bool SuppressonSink;
+  const CheckerBase *Checker;
+  bool SuppressOnSink;
 
   virtual void anchor();
+
 public:
-  BugType(class CheckName check, StringRef name, StringRef cat)
-  : Check(check), Name(name), Category(cat), SuppressonSink(false) {}
-  BugType(const CheckerBase *checker, StringRef name, StringRef cat)
-  : Check(checker->getCheckName()), Name(name), Category(cat),
-SuppressonSink(false) {}
-  virtual ~BugType() {}
+  BugType(CheckName Check, StringRef Name, StringRef Cat)
+  : Check(Check), Name(Name), Category(Cat), Checker(nullptr),
+SuppressOnSink(false) {}
+  BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
+  : Check(Checker->getCheckName()), Name(Name), Category(Cat),
+Checker(Checker), SuppressOnSink(false) {}
+  virtual ~BugType() = default;
 
-  // FIXME: Should these be made strings as well?
   StringRef getName() const { return Name; }
   StringRef getCategory() const { return Category; }
-  StringRef getCheckName() const { return Check.getName(); }
+  StringRef getCheckName() const {
+// FIXME: This is a workaround to ensure that the correct check name is 
used
+// The check names are set after the constructors are run.
+// In case the BugType object is initialized in the checker's ctor
+// the Check field will be empty. To circumvent this problem we use 
+// CheckerBase whenever it is possible.
+StringRef CheckName =
+Checker ? Checker->getCheckName().getName() : Check.getName();
+assert(!CheckName.empty() && "Check name is not set properly.");
+return CheckName;
+  }
 
   /// isSuppressOnSink - Returns true if bug reports associated with this bug
   ///  type should be suppressed if the end node of the report is 
post-dominated
   ///  by a sink node.
-  bool isSuppressOnSink() const { return SuppressonSink; }
-  void setSuppressOnSink(bool x) { SuppressonSink = x; }
+  bool isSuppressOnSink() const { return SuppressOnSink; }
+  void setSuppressOnSink(bool x) { SuppressOnSink = x; }
 
   virtual void FlushReports(BugReporter& BR);
 };
@@ -74,7 +86,7 @@ public:
   StringRef getDescription() const { return desc; }
 };
 
-} // end GR namespace
+} // end ento namespace
 
 } // end clang namespace
 #endif

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=321933&r1=321932&r2=321933&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sat Jan  6 02:51:00 
2018
@@ -2900,8 +2900,13 @@ void ento::registerNewDeleteLeaksChecker
   mgr.getCurrentCheckName();
   // We currently treat NewDeleteLeaks checker as a subchecker of NewDelete
   // checker.
-  if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker])
+  if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker]) {
 checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker] = true;
+// FIXME: This does not set the correct name, but without this workaround
+//no name will be set at all.
+checker->CheckNames[MallocChecker::CK_NewDeleteChecker] =
+mgr.getCurrentCheckName();
+  }
 }
 
 #define REGISTER_CHECKER(name) 
\

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp?rev=321933&r1=321932&r2=321933&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp Sat Jan  6 02:51:00 
2018
@@ -64,7 +64,7 @@ private:
  

[PATCH] D41740: [clang-tidy] Adding a new bugprone check for streaming objects of type int8_t or uint8_t

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

In https://reviews.llvm.org/D41740#968567, @BRevzin wrote:

> In https://reviews.llvm.org/D41740#968134, @JonasToth wrote:
>
> > Could you please add a test case with a template that reduces the type to 
> > int8 or uint8?
>
>
> I don't actually know how to do that. I tried a few things, but getting the 
> type of the expression through a template gets me directly to `unsigned 
> char`, not to `uint8_t`.


Yes that is possible. Templates ignore the typedefnames. I think that needs to 
be considered. It might be relevant for a templated operator<<.

It would be nice to have these cases in tests to document the issue. A note in 
the docs wouldn't hurt too.


https://reviews.llvm.org/D41740



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


[PATCH] D41740: [clang-tidy] Adding a new bugprone check for streaming objects of type int8_t or uint8_t

2018-01-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/bugprone/StreamInt8Check.h:20
+/// Checks that objects of types int8_t or uint8_t aren't streamed to ostreams,
+/// where the intended behavior is likely to stream them as ints
+///

Missing full stop in comment


https://reviews.llvm.org/D41740



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


[PATCH] D41326: [clang-tidy] Added diagnostics about incorrect usage of NOLINT comment

2018-01-06 Thread Anton via Phabricator via cfe-commits
xgsa added inline comments.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:839-840
+case NolintCommentType::Nolint:
+  Message = "there is no diagnostics on this line, "
+"the NOLINT comment is redundant";
+  break;

aaron.ballman wrote:
> xgsa wrote:
> > aaron.ballman wrote:
> > > xgsa wrote:
> > > > aaron.ballman wrote:
> > > > > xgsa wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I don't think the user is going to care about the distinction 
> > > > > > > between no diagnostics being triggered and the expected 
> > > > > > > diagnostic not being triggered. Also, it's dangerous to claim the 
> > > > > > > lint comment is redundant because it's possible the user has 
> > > > > > > NOLINT(foo, bar) and while foo is not triggered, bar still is. 
> > > > > > > The NOLINT comment itself isn't redundant, it's that the check 
> > > > > > > specified doesn't occur.
> > > > > > > 
> > > > > > > I would consolidate those scenarios into a single diagnostic: 
> > > > > > > "expected diagnostic '%0' not generated" and "expected diagnostic 
> > > > > > > '%0' not generated for the following line".
> > > > > > > 
> > > > > > > One concern I have with this functionality is: how should users 
> > > > > > > silence a lint diagnostic that's target sensitive? e.g., a 
> > > > > > > diagnostic that triggers based on the underlying type of size_t 
> > > > > > > or the signedness of plain char. In that case, the diagnostic may 
> > > > > > > trigger for some targets but not others, but on the targets where 
> > > > > > > the diagnostic is not triggered, they now get a diagnostic they 
> > > > > > > cannot silence. There should be a way to silence the "bad NOLINT" 
> > > > > > > diagnostics.
> > > > > > > I don't think the user is going to care about the distinction 
> > > > > > > between no diagnostics being triggered and the expected 
> > > > > > > diagnostic not being triggered. Also, it's dangerous to claim the 
> > > > > > > lint comment is redundant because it's possible the user has 
> > > > > > > NOLINT(foo, bar) and while foo is not triggered, bar still is. 
> > > > > > > The NOLINT comment itself isn't redundant, it's that the check 
> > > > > > > specified doesn't occur.
> > > > > > > 
> > > > > > > I would consolidate those scenarios into a single diagnostic: 
> > > > > > > "expected diagnostic '%0' not generated" and "expected diagnostic 
> > > > > > > '%0' not generated for the following line".
> > > > > > 
> > > > > > This branch of `if (NolintEntry.first.CheckName == 
> > > > > > NolintCommentsCollector::AnyCheck)` reports only about 
> > > > > > `NOLINT`/`NOLINTNEXTLINE` comments without check list, so I suppose 
> > > > > > it's fair to claim that this comment is redundant (we have already 
> > > > > > checked that no single check reported diagnostics on the line). The 
> > > > > > `else`-branch reports the diagnostics for the definite check in a 
> > > > > > list in case of `NOLINT(foo, bar)` (actually, if neither `foo` nor 
> > > > > > `bar` checks reported diagnostics for the line, there will be a few 
> > > > > > diagnostics from `nolint-usage` - not sure if it's good, but it 
> > > > > > seems acceptable). That is why, I suppose, it is necessary to 
> > > > > > distinct these cases.
> > > > > > 
> > > > > > > One concern I have with this functionality is: how should users 
> > > > > > > silence a lint diagnostic that's target sensitive? e.g., a 
> > > > > > > diagnostic that triggers based on the underlying type of size_t 
> > > > > > > or the signedness of plain char. In that case, the diagnostic may 
> > > > > > > trigger for some targets but not others, but on the targets where 
> > > > > > > the diagnostic is not triggered, they now get a diagnostic they 
> > > > > > > cannot silence. There should be a way to silence the "bad NOLINT" 
> > > > > > > diagnostics.
> > > > > > 
> > > > > > There is such mechanism: it is possible to specify `// 
> > > > > > NOLINT(nolint-usage)` or `//NOLINT(check1, check2, nolint-usage) to 
> > > > > > silence the `nolint-usage`-mechanism. Please, see tests for details 
> > > > > > and more examples. 
> > > > > Can you provide an example where this distinction will make a 
> > > > > difference to the user and help clarify a confusing situation? I 
> > > > > cannot think of one, and it would be nice to simplify this code.
> > > > > 
> > > > > Thank you for the explanation about nolint-usage. This is not 
> > > > > terminology I've seen before -- is this your invention, or is it a 
> > > > > documented feature for NOLINT comments?
> > > > >> Can you provide an example where this distinction will make a 
> > > > >> difference to the user and help clarify a confusing situation? I 
> > > > >> cannot think of one, and it would be nice to simplify this code.
> > > > 
> > > > Example for the diagnostics emitted in the `if`-branch:
> > > > ```
> > > > class A2 { explicit A2(int i); }; // 

[PATCH] D41538: [analyzer] Fix some checker's output plist not containing the checker name #2

2018-01-06 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

It missed the 6.0 branching. Will you try to get it on this branch?
Thanks


Repository:
  rC Clang

https://reviews.llvm.org/D41538



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


[PATCH] D41538: [analyzer] Fix some checker's output plist not containing the checker name #2

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

In https://reviews.llvm.org/D41538#969205, @sylvestre.ledru wrote:

> It missed the 6.0 branching. Will you try to get it on this branch?
> Thanks


Sure! I will try to do so: https://reviews.llvm.org/rC321933


Repository:
  rC Clang

https://reviews.llvm.org/D41538



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


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

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



Comment at: include/clang/Basic/Attr.td:1159
+def TrivialABI : InheritableAttr {
+  let Spellings = [Clang<"trivial_abi">];
+  let Subjects = SubjectList<[CXXRecord]>;

Would this attribute make sense in C, or does it really only make sense in C++? 
If it doesn't make sense in C++, then you should also set `LangOpts` to be 
`CPlusPlus`. If it does make sense in C, then the Clang spelling should be 
`Clang<"trivial_abi", 1>`



Comment at: lib/Sema/SemaDeclCXX.cpp:7594
+  for (const auto &B : RD.bases()) {
+CXXRecordDecl *BaseClassDecl
+= cast(B.getType()->getAs()->getDecl());

Can use `const auto *` here.



Comment at: lib/Sema/SemaDeclCXX.cpp:7640
+  // See if trivial_abi has to be dropped.
+  auto *RD = dyn_cast_or_null(TagDecl);
+  if (RD && RD->hasAttr())

This should use `dyn_cast` instead of `dyn_cast_or_null`.


https://reviews.llvm.org/D41039



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

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



Comment at: clang-tidy/bugprone/UnusedReturnValueCheck.cpp:69
+ "the value returned by %0 should normally be used")
+<< dyn_cast_or_null(Matched->getCalleeDecl())
+<< Matched->getSourceRange();

khuttun wrote:
> aaron.ballman wrote:
> > In the event this returns null, the diagnostic is going to look rather odd. 
> > Because the value of the call expression is unused, this will most often 
> > trigger in a context where the method call can be inferred (especially 
> > because you're now highlighting the source range). It might make sense to 
> > simply replace the %0 with "this call expression" or somesuch in the 
> > diagnostic.
> I can remove the function name from the diagnostic. Out of curiosity, in 
> which situations could it be null?
Situations where the call doesn't refer back to a declaration at all. For 
instance, a lambda or block.



Comment at: docs/clang-tidy/checks/bugprone-unused-return-value.rst:22
+   - ``std::unique_ptr::release()``. Not using the return value can lead to
+ resource leaks, if the same pointer isn't stored anywhere else. Often
+ ignoring the ``release()`` return value indicates that the programmer

resource leaks, if the -> resource leaks if the
Often -> Often, 



Comment at: docs/clang-tidy/checks/bugprone-unused-return-value.rst:31
+ ``std::filesystem::path::empty()`` and ``std::empty()``. Not using the
+ return value doesn't cause any issues on itself, but often it indicates
+ that the programmer confused the function with ``clear()``.

I'd reword this sentence to: Not using the return value often indicates that 
the programmer confused the function with clear().



Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+  auto AsyncRetval1 = std::async(increment, 42);

Sorry, I just realized that we're missing a test case for a common situation -- 
where the result is used as part of another call expression. Can you add a test 
to `noWarning()` to make sure this does not warn:
```
std::vector v;
extern void f(bool);

f(v.empty()); // Should not warn
```


https://reviews.llvm.org/D41655



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


[PATCH] D41546: [clang-tidy] Adding Fuchsia checker for statically constructed objects

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



Comment at: clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp:48
+  if (const auto *D = Result.Nodes.getNodeAs("decl")) {
+diag(D->getLocStart(), "explicit global static objects are disallowed: if "
+   "possible, use a constexpr constructor instead "

Replace the colon with a semicolon.



Comment at: clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp:50
+   "possible, use a constexpr constructor instead "
+   "[fuchsia-statically-constructed-objects]");
+  }

You should drop this part of the string (it should be automatically added by 
the diagnostics engine).



Comment at: docs/ReleaseNotes.rst:63
+
+  Warns if global non-trivial objects with explicit static storage are 
+  constructed, unless the object either has a ``constexpr`` constructor or has 

global non-trivial -> global, non-trivial



Comment at: docs/clang-tidy/checks/fuchsia-statically-constructed-objects.rst:6
+
+Warns if global non-trivial objects with explicit static storage are 
+constructed, unless the object either has a ``constexpr`` constructor or has 
no 

global non-trivial -> global, non-trivial



Comment at: test/clang-tidy/fuchsia-statically-constructed-objects.cpp:26-27
+ClassWithConstexpr C;
+ClassWithConstexpr E(0);
+ClassWithCtor G(0);
+

This may be expected behavior, but I find it somewhat strange.  This kind of 
rule is usually in place because you want to prohibit constructors that trigger 
during program initialization. What is the rule trying to accomplish by 
disallowing static globals that are declared static while allowing static 
globals that are not declared with an explicit `static` keyword?

If the rule is trying to prevent constructors from triggering prior to 
executing main(), what about constexpr constructors that must be evaluated at 
runtime? e.g.,
```
class S {
  int Val;
public:
  constexpr S(int i) : Val(100 / i) {}
  int getVal() const { return Val; }
};

static S s1(1); // Constructor call is constexpr; s1 does not need to be 
dynamically initialized
static S s2(0); // Constructor call is not constexpr; s2 must be dynamically 
initialized

extern int get_i();
static S s3(get_i()); // Constructor call is not constexpr; s3 must be 
dynamically initialized
```


https://reviews.llvm.org/D41546



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


[PATCH] D41740: [clang-tidy] Adding a new bugprone check for streaming objects of type int8_t or uint8_t

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



Comment at: clang-tidy/bugprone/BugproneTidyModule.cpp:64
+CheckFactories.registerCheck(
+"bugprone-stream-int8");
 CheckFactories.registerCheck(

I don't think this is a good name for the check, especially because the check 
can be configured for types other than integers. How about 
"bugprone-suspicious-stream-value-type"? If you rename the check name, you 
should also update the name of the files and check accordingly.



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:25
+  "StreamTypes",
+  "std::basic_ostream"))),
+AliasTypes(utils::options::parseStringList(Options.get(

This should be `::std::basic_ostream` just in case someone does something awful 
like put `namespace std` inside another namespace.



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:48
+anyOf(asString("signed char"),
+  asString("const signed char"),
+  asString("unsigned char"),

It'd be nice to have a qualifier-agnostic way of expressing this (there are 
other qualifiers, like `volatile`, and we don't want to have to list them all 
out unless it's important for the check functionality).



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:56-57
+bool StreamInt8Check::isBugproneAlias(StringRef Name) const {
+  return std::find(AliasTypes.begin(), AliasTypes.end(), Name)
+ != AliasTypes.end();
+}

You can use `llvm::find(AliasTypes, Name)` here instead.

It might also make sense to use an `llvm::StringSet` instead of a vector of 
strings that you have to do a linear search over.



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:63
+
+  for (auto Typedef = Offender->getType().getTypePtr()->getAs(); 
Typedef; ) {
+auto Name = Typedef->getDecl()->getNameAsString();

`const auto *`?



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:64
+  for (auto Typedef = Offender->getType().getTypePtr()->getAs(); 
Typedef; ) {
+auto Name = Typedef->getDecl()->getNameAsString();
+if (isBugproneAlias(Name)) {

Should not use `auto` here.



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:67
+  diag(Offender->getLocStart(),
+   "streaming %0; did you mean to stream an int?")
+<< Name << Offender->getSourceRange();

This diagnostic doesn't really explain what the issue is. It should probably be 
reworded to something more along the lines of "%0 will not undergo integral 
promotion prior to streaming; cast to 'int' to prevent streaming a character".



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:68
+   "streaming %0; did you mean to stream an int?")
+<< Name << Offender->getSourceRange();
+  break;

If you pass in `Name`, then it won't be properly quoted. You should pass 
`Typedef->getDecl()` (but not repeat the expression from above).



Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:72-73
+
+QualType Underlying = Typedef->getDecl()->getUnderlyingType();
+Typedef = Underlying.getTypePtr()->getAs();
+  }

You can hoist this into the `for` loop.



Comment at: clang-tidy/bugprone/StreamInt8Check.h:19
+
+/// Checks that objects of types int8_t or uint8_t aren't streamed to ostreams,
+/// where the intended behavior is likely to stream them as ints

types -> type



Comment at: docs/ReleaseNotes.rst:63
+
+  Checks that objects of type ``int8_t`` or ``uint8_t`` aren't streamed,  if 
those
+  are typedefs to ``signed char`` or ``unsigned char``, as this likely intends 
to

Extra space between the comma and "if".

I'd reword this a bit to:

Checks that an object of type int8_t or uint8_t is not streamed. Those types 
are usually a typedef to a character type that are printed as a character 
rather than an integer. The user likely intends to stream such a value as an 
int instead.

(Or something like this.)



Comment at: docs/clang-tidy/checks/bugprone-stream-int8.rst:6-8
+Checks that objects of type ``int8_t`` or ``uint8_t`` aren't streamed,  if 
those
+are typedefs to ``signed char`` or ``unsigned char``, as this likely intends to
+be streaming these types as ``int`` s instead.

Same wording suggestions as above.


https://reviews.llvm.org/D41740



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


[libcxx] r321937 - Correct mistake in pragma usage for Windows

2018-01-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Jan  6 10:47:03 2018
New Revision: 321937

URL: http://llvm.org/viewvc/llvm-project?rev=321937&view=rev
Log:
Correct mistake in pragma usage for Windows

The autolink pragma was missing the pragma name itself.  This would
result in the pragma being silently dropped.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=321937&r1=321936&r2=321937&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sat Jan  6 10:47:03 2018
@@ -1278,9 +1278,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 
 #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
 # if defined(_DLL)
-#   pragma(lib, "c++.lib")
+#   pragma comment(lib, "c++.lib")
 # else
-#   pragma(lib, "libc++.lib")
+#   pragma comment(lib, "libc++.lib")
 # endif
 #endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
 


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


[PATCH] D33563: Track whether a unary operation can overflow

2018-01-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for the review!




Comment at: include/clang/AST/Expr.h:1728
+  UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK,
+ExprObjectKind OK, SourceLocation l, bool CanOverflow = false)
+  : Expr(UnaryOperatorClass, type, VK, OK,

efriedma wrote:
> Is the default argument necessary here?  Better to avoid when possible.
It's not required, but there are quite a few places where we gin up a 
UnaryOperator for things like address of or dereference where there is no 
overflow possible. However, I agree that less default arguments are better, so 
I've made it a required formal argument.



Comment at: test/Misc/ast-dump-stmt.c:66
+  // CHECK:ImplicitCastExpr
+  // CHECK:  DeclRefExpr{{.*}}'T2' 'int'
+}

efriedma wrote:
> What does it mean for bitwise complement to "overflow"?
When the sign bit flips on a signed value, e.g., `~0`.


https://reviews.llvm.org/D33563



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


[PATCH] D33563: Track whether a unary operation can overflow

2018-01-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 128858.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.
Herald added a subscriber: javed.absar.

Updated based on review feedback.


https://reviews.llvm.org/D33563

Files:
  include/clang/AST/Expr.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Misc/ast-dump-stmt.c

Index: test/Misc/ast-dump-stmt.c
===
--- test/Misc/ast-dump-stmt.c
+++ test/Misc/ast-dump-stmt.c
@@ -33,3 +33,35 @@
 // CHECK-NEXT:   OpaqueValueExpr
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT:   IntegerLiteral
+
+void TestUnaryOperatorExpr(void) {
+  char T1 = 1;
+  int T2 = 1;
+
+  T1++;
+  T2++;
+  // CHECK:  UnaryOperator{{.*}}postfix '++' cannot overflow
+  // CHECK-NEXT:   DeclRefExpr{{.*}}'T1' 'char'
+  // CHECK-NOT:  UnaryOperator{{.*}}postfix '++' cannot overflow
+  // CHECK:DeclRefExpr{{.*}}'T2' 'int'
+
+  -T1;
+  -T2;
+  // CHECK:  UnaryOperator{{.*}}prefix '-' cannot overflow
+  // CHECK-NEXT:   ImplicitCastExpr
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT:   DeclRefExpr{{.*}}'T1' 'char'
+  // CHECK-NOT:  UnaryOperator{{.*}}prefix '-' cannot overflow
+  // CHECK:ImplicitCastExpr
+  // CHECK:  DeclRefExpr{{.*}}'T2' 'int'
+
+  ~T1;
+  ~T2;
+  // CHECK:  UnaryOperator{{.*}}prefix '~' cannot overflow
+  // CHECK-NEXT:   ImplicitCastExpr
+  // CHECK-NEXT: ImplicitCastExpr
+  // CHECK-NEXT:   DeclRefExpr{{.*}}'T1' 'char'
+  // CHECK-NOT:  UnaryOperator{{.*}}prefix '~' cannot overflow
+  // CHECK:ImplicitCastExpr
+  // CHECK:  DeclRefExpr{{.*}}'T2' 'int'
+}
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -509,6 +509,7 @@
   Record.AddStmt(E->getSubExpr());
   Record.push_back(E->getOpcode()); // FIXME: stable encoding
   Record.AddSourceLocation(E->getOperatorLoc());
+  Record.push_back(E->canOverflow());
   Code = serialization::EXPR_UNARY_OPERATOR;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -553,6 +553,7 @@
   E->setSubExpr(Record.readSubExpr());
   E->setOpcode((UnaryOperator::Opcode)Record.readInt());
   E->setOperatorLoc(ReadSourceLocation());
+  E->setCanOverflow(Record.readInt());
 }
 
 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Index: lib/Sema/SemaPseudoObject.cpp
===
--- lib/Sema/SemaPseudoObject.cpp
+++ lib/Sema/SemaPseudoObject.cpp
@@ -132,7 +132,8 @@
  uop->getType(),
  uop->getValueKind(),
  uop->getObjectKind(),
- uop->getOperatorLoc());
+ uop->getOperatorLoc(),
+ uop->canOverflow());
   }
 
   if (GenericSelectionExpr *gse = dyn_cast(e)) {
@@ -527,9 +528,12 @@
   (result.get()->isTypeDependent() || CanCaptureValue(result.get(
 setResultToLastSemantic();
 
-  UnaryOperator *syntactic =
-new (S.Context) UnaryOperator(syntacticOp, opcode, resultType,
-  VK_LValue, OK_Ordinary, opcLoc);
+  UnaryOperator *syntactic = new (S.Context) UnaryOperator(
+  syntacticOp, opcode, resultType, VK_LValue, OK_Ordinary, opcLoc,
+  !resultType->isDependentType()
+  ? S.Context.getTypeSize(resultType) >=
+S.Context.getTypeSize(S.Context.IntTy)
+  : false);
   return complete(syntactic);
 }
 
@@ -1550,7 +1554,7 @@
   // Do nothing if the operand is dependent.
   if (op->isTypeDependent())
 return new (Context) UnaryOperator(op, opcode, Context.DependentTy,
-   VK_RValue, OK_Ordinary, opcLoc);
+   VK_RValue, OK_Ordinary, opcLoc, false);
 
   assert(UnaryOperator::isIncrementDecrementOp(opcode));
   Expr *opaqueRef = op->IgnoreParens();
@@ -1633,9 +1637,9 @@
   Expr *syntax = E->getSyntacticForm();
   if (UnaryOperator *uop = dyn_cast(syntax)) {
 Expr *op = stripOpaqueValuesFromPseudoObjectRef(*this, uop->getSubExpr());
-return new (Context) UnaryOperator(op, uop->getOpcode(), uo

r321948 - Add support for a limited subset of TS 18661-3 math builtins.

2018-01-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Jan  6 13:49:54 2018
New Revision: 321948

URL: http://llvm.org/viewvc/llvm-project?rev=321948&view=rev
Log:
Add support for a limited subset of TS 18661-3 math builtins.

These just overloads for _Float128. They're supported by GCC 7 and used
by glibc. APFloat support is already there so just add the overloads.

__builtin_copysignf128
__builtin_fabsf128
__builtin_huge_valf128
__builtin_inff128
__builtin_nanf128
__builtin_nansf128

This is the same support that GCC has, according to the documentation,
but limited to _Float128.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/math-builtins.c
cfe/trunk/test/Sema/constant-builtins-2.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sat Jan  6 13:49:54 2018
@@ -48,8 +48,8 @@
 //  . -> "...".  This may only occur at the end of the function list.
 //
 // Types may be prefixed with the following modifiers:
-//  L   -> long (e.g. Li for 'long int')
-//  LL  -> long long
+//  L   -> long (e.g. Li for 'long int', Ld for 'long double')
+//  LL  -> long long (e.g. LLi for 'long long int', LLd for __float128)
 //  LLL -> __int128_t (e.g. LLLi)
 //  W   -> int64_t
 //  N   -> 'int' size if target is LP64, 'L' otherwise.
@@ -110,9 +110,11 @@ BUILTIN(__builtin_abs  , "ii"  , "ncF")
 BUILTIN(__builtin_copysign, "ddd", "ncF")
 BUILTIN(__builtin_copysignf, "fff", "ncF")
 BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
+BUILTIN(__builtin_copysignf128, "LLdLLdLLd", "ncF")
 BUILTIN(__builtin_fabs , "dd"  , "ncF")
 BUILTIN(__builtin_fabsf, "ff"  , "ncF")
 BUILTIN(__builtin_fabsl, "LdLd", "ncF")
+BUILTIN(__builtin_fabsf128, "LLdLLd", "ncF")
 BUILTIN(__builtin_fmod , "ddd"  , "Fne")
 BUILTIN(__builtin_fmodf, "fff"  , "Fne")
 BUILTIN(__builtin_fmodl, "LdLdLd", "Fne")
@@ -122,9 +124,11 @@ BUILTIN(__builtin_frexpl, "LdLdi*", "Fn"
 BUILTIN(__builtin_huge_val, "d", "nc")
 BUILTIN(__builtin_huge_valf, "f", "nc")
 BUILTIN(__builtin_huge_vall, "Ld", "nc")
+BUILTIN(__builtin_huge_valf128, "LLd", "nc")
 BUILTIN(__builtin_inf  , "d"   , "nc")
 BUILTIN(__builtin_inff , "f"   , "nc")
 BUILTIN(__builtin_infl , "Ld"  , "nc")
+BUILTIN(__builtin_inff128 , "LLd"  , "nc")
 BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
 BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
 BUILTIN(__builtin_ldexp , "ddi"  , "Fne")
@@ -136,9 +140,11 @@ BUILTIN(__builtin_modfl, "LdLdLd*", "Fn"
 BUILTIN(__builtin_nan,  "dcC*" , "ncF")
 BUILTIN(__builtin_nanf, "fcC*" , "ncF")
 BUILTIN(__builtin_nanl, "LdcC*", "ncF")
+BUILTIN(__builtin_nanf128, "LLdcC*", "ncF")
 BUILTIN(__builtin_nans,  "dcC*" , "ncF")
 BUILTIN(__builtin_nansf, "fcC*" , "ncF")
 BUILTIN(__builtin_nansl, "LdcC*", "ncF")
+BUILTIN(__builtin_nansf128, "LLdcC*", "ncF")
 BUILTIN(__builtin_powi , "ddi"  , "Fnc")
 BUILTIN(__builtin_powif, "ffi"  , "Fnc")
 BUILTIN(__builtin_powil, "LdLdi", "Fnc")

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Jan  6 13:49:54 2018
@@ -8929,10 +8929,12 @@ static QualType DecodeTypeFromStr(const
 Type = Context.FloatTy;
 break;
   case 'd':
-assert(HowLong < 2 && !Signed && !Unsigned &&
+assert(HowLong < 3 && !Signed && !Unsigned &&
"Bad modifiers used with 'd'!");
-if (HowLong)
+if (HowLong == 1)
   Type = Context.LongDoubleTy;
+else if (HowLong == 2)
+  Type = Context.Float128Ty;
 else
   Type = Context.DoubleTy;
 break;

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=321948&r1=321947&r2=321948&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Jan  6 13:49:54 2018
@@ -9170,9 +9170,11 @@ bool FloatExprEvaluator::VisitCallExpr(c
   case Builtin::BI__builtin_huge_val:
   case Builtin::BI__builtin_huge_valf:
   case Builtin::BI__builtin_huge_vall:
+  case Builtin::BI__builtin_huge_valf128:
   case Builtin::BI__builtin_inf:
   case Builtin::BI__builtin_inff:
-  case Builtin::BI__builtin_infl: {
+  case Builtin::BI__builtin_infl:
+  case Builtin::BI__builtin_inff128: {
 const llvm::fltSemantics &Sem =
   Info.Ctx.getFloatTypeSemantics(E->getType());
 Result = llvm::APFloat::getInf(Sem);
@@ -9182,6 +9184,7 @@ bool Floa

Re: [libcxx] r319736 - Land D28253 which fixes PR28929 (which we mistakenly marked as fixed before)

2018-01-06 Thread Dimitry Andric via cfe-commits
On 5 Dec 2017, at 05:09, Marshall Clow via cfe-commits 
 wrote:
> 
> Author: marshall
> Date: Mon Dec  4 20:09:49 2017
> New Revision: 319736
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=319736&view=rev
> Log:
> Land D28253 which fixes PR28929 (which we mistakenly marked as fixed before)
...
> --- libcxx/trunk/include/memory (original)
> +++ libcxx/trunk/include/memory Mon Dec  4 20:09:49 2017
...
> @@ -4357,6 +4362,7 @@ template shared_ptr<_Tp>
> shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
> {
> +static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
> construct object in make_shared" );
> typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
> typedef allocator<_CntrlBlk> _Alloc2;
> typedef __allocator_destructor<_Alloc2> _D2;

This commit causes g++ to no longer be able to compile  in pre-C++11 
mode, giving errors in the static assertions, like the following:

$ g++7 -nostdinc++ -isystem /share/dim/src/libcxx/trunk/include -std=c++03 -c 
test.cpp
In file included from /share/dim/src/libcxx/trunk/include/memory:648:0,
 from test.cpp:1:
/share/dim/src/libcxx/trunk/include/memory: In static member function 'static 
std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, 
_A2&)':
/share/dim/src/libcxx/trunk/include/memory:4365:5: error: wrong number of 
template arguments (4, should be at least 1)
 static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in make_shared" );
 ^
In file included from /share/dim/src/libcxx/trunk/include/memory:649:0,
 from test.cpp:1:
/share/dim/src/libcxx/trunk/include/type_traits:3193:29: note: provided for 
'template struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
 ^~~~
In file included from /share/dim/src/libcxx/trunk/include/memory:648:0,
 from test.cpp:1:
/share/dim/src/libcxx/trunk/include/memory:4365:5: error: template argument 1 
is invalid
 static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in make_shared" );
 ^
/share/dim/src/libcxx/trunk/include/memory: In static member function 'static 
std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const 
_Alloc&, _A0&, _A1&, _A2&)':
/share/dim/src/libcxx/trunk/include/memory::5: error: wrong number of 
template arguments (4, should be at least 1)
 static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in allocate_shared" );
 ^
In file included from /share/dim/src/libcxx/trunk/include/memory:649:0,
 from test.cpp:1:
/share/dim/src/libcxx/trunk/include/type_traits:3193:29: note: provided for 
'template struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
 ^~~~
In file included from /share/dim/src/libcxx/trunk/include/memory:648:0,
 from test.cpp:1:
/share/dim/src/libcxx/trunk/include/memory::5: error: template argument 1 
is invalid
 static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in allocate_shared" );
 ^

It could be a gcc problem, since clang does not complain about it, but hints on 
how to solve it would be welcome.

-Dimitry



signature.asc
Description: Message signed with OpenPGP
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41805: Add pre-C++11 is_constructible wrappers for 3 arguments

2018-01-06 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
dim added reviewers: EricWF, mclow.lists.
Herald added a subscriber: krytarowski.

After https://reviews.llvm.org/rL319736 for https://reviews.llvm.org/D28253 
(which fixes PR28929), gcc cannot compile `` anymore in pre-C+11 modes, 
complaining:

  In file included from /usr/include/c++/v1/memory:648:0,
   from test.cpp:1:
  /usr/include/c++/v1/memory: In static member function 'static 
std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, 
_A2&)':
  /usr/include/c++/v1/memory:4365:5: error: wrong number of template arguments 
(4, should be at least 1)
   static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in make_shared" );
   ^
  In file included from /usr/include/c++/v1/memory:649:0,
   from test.cpp:1:
  /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template struct std::__1::is_constructible'
   struct _LIBCPP_TEMPLATE_VIS is_constructible
   ^~~~
  In file included from /usr/include/c++/v1/memory:648:0,
   from test.cpp:1:
  /usr/include/c++/v1/memory:4365:5: error: template argument 1 is invalid
   static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in make_shared" );
   ^
  /usr/include/c++/v1/memory: In static member function 'static 
std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const 
_Alloc&, _A0&, _A1&, _A2&)':
  /usr/include/c++/v1/memory::5: error: wrong number of template arguments 
(4, should be at least 1)
   static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in allocate_shared" );
   ^
  In file included from /usr/include/c++/v1/memory:649:0,
   from test.cpp:1:
  /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template struct std::__1::is_constructible'
   struct _LIBCPP_TEMPLATE_VIS is_constructible
   ^~~~
  In file included from /usr/include/c++/v1/memory:648:0,
   from test.cpp:1:
  /usr/include/c++/v1/memory::5: error: template argument 1 is invalid
   static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't 
construct object in allocate_shared" );
   ^

This is also reported in https://bugs.freebsd.org/224946 (FreeBSD is apparently 
one of the very few projects that regularly builds programs against libc++ with 
gcc).

The reason is that the static assertions are invoking `is_constructible` with 
three arguments, while gcc does not have the built-in `is_constructible` 
feature, and the pre-C++11 `is_constructible` wrappers in `` only 
provide up to two arguments.

I have added additional wrappers for three arguments, modified the 
`is_constructible` entry point to take three arguments instead, and added a 
simple test to is_constructible.pass.cpp.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41805

Files:
  include/type_traits
  test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp

Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -30,6 +30,7 @@
 {
 explicit A(int);
 A(int, double);
+A(int, long, double);
 #if TEST_STD_VER >= 11
 private:
 #endif
@@ -106,6 +107,16 @@
 #endif
 }
 
+template 
+void test_is_constructible()
+{
+static_assert(( std::is_constructible::value), "");
+LIBCPP11_STATIC_ASSERT((std::__libcpp_is_constructible::type::value), "");
+#if TEST_STD_VER > 14
+static_assert(( std::is_constructible_v), "");
+#endif
+}
+
 template 
 void test_is_not_constructible()
 {
@@ -146,6 +157,7 @@
 test_is_constructible ();
 test_is_constructible ();
 test_is_constructible ();
+test_is_constructible ();
 test_is_constructible ();
 
 test_is_not_constructible ();
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -3172,6 +3172,14 @@
 false_type
 __is_constructible2_test(__any, _A0&, _A1&);
 
+template 
+decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>(), _VSTD::declval<_A2>()), true_type()))
+__is_constructible3_test(_Tp&, _A0&, _A1&, _A2&);
+
+template 
+false_type
+__is_constructible3_test(__any, _A0&, _A1&, _A2&);
+
 template 
 struct __is_constructible0_imp // false, _Tp is not a scalar
 : public common_type
@@ -3196,6 +3204,14 @@
  >::type
 {};
 
+template 
+struct __is_constructible3_imp // false, _Tp is not a scalar
+: public common_type
+ <
+ decltype(__is_constructible3_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>(), declval<_A2>()))
+ >::type
+{};
+

[PATCH] D41507: avxintrin.h documentation fixes and updates

2018-01-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung updated this revision to Diff 128861.
dyung added a comment.

Updated change to address review feedback.


https://reviews.llvm.org/D41507

Files:
  avxintrin.h

Index: avxintrin.h
===
--- avxintrin.h
+++ avxintrin.h
@@ -1120,7 +1120,7 @@
 /// \param A
 ///A 256-bit vector of [8 x float].
 /// \param C
-///An immediate integer operand specifying how the values are to be \n
+///An immediate integer operand specifying how the values are to be
 ///copied. \n
 ///Bits [1:0]: \n
 ///  00: Bits [31:0] of the source are copied to bits [31:0] of the
@@ -1150,7 +1150,7 @@
 ///  11: Bits [127:96] of the source are copied to bits [95:64] of the
 ///  returned vector. \n
 ///Bits [7:6]: \n
-///  00: Bits [31:qq0] of the source are copied to bits [127:96] of the
+///  00: Bits [31:0] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
 ///  01: Bits [63:32] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
@@ -1665,38 +1665,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///0x00: Equal (ordered, non-signaling) \n
+///0x01: Less-than (ordered, signaling) \n
+///0x02: Less-than-or-equal (ordered, signaling) \n
+///0x03: Unordered (non-signaling) \n
+///0x04: Not-equal (unordered, non-signaling) \n
+///0x05: Not-less-than (unordered, signaling) \n
+///0x06: Not-less-than-or-equal (unordered, signaling) \n
+///0x07: Ordered (non-signaling) \n
+///0x08: Equal (unordered, non-signaling) \n
+///0x09: Not-greater-than-or-equal (unordered, signaling) \n
+///0x0A: Not-greater-than (unordered, signaling) \n
+///0x0B: False (ordered, non-signaling) \n
+///0x0C: Not-equal (ordered, non-signaling) \n
+///0x0D: Greater-than-or-equal (ordered, signaling) \n
+///0x0E: Greater-than (ordered, signaling) \n
+///0x0F: True (unordered, non-signaling) \n
+///0x10: Equal (ordered, signaling) \n
+///0x11: Less-than (ordered, non-signaling) \n
+///0x12: Less-than-or-equal (ordered, non-signaling) \n
+///0x13: Unordered (signaling) \n
+///0x14: Not-equal (unordered, signaling) \n
+///0x15: Not-less-than (unordered, non-signaling) \n
+///0x16: Not-less-than-or-equal (unordered, non-signaling) \n
+///0x17: Ordered (signaling) \n
+///0x18: Equal (unordered, signaling) \n
+///0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
+///0x1A: Not-greater-than (unordered, non-signaling) \n
+///0x1B: False (ordered, signaling) \n
+///0x1C: Not-equal (ordered, signaling) \n
+///0x1D: Greater-than-or-equal (ordered, non-signaling) \n
+///0x1E: Greater-than (ordered, non-signaling) \n
+///0x1F: True (unordered, signaling)
 /// \returns A 128-bit vector of [2 x double] containing the comparison results.
 #define _mm_cmp_pd(a, b, c) __extension__ ({ \
   (__m128d)__builtin_ia32_cmppd((__v2df)(__m128d)(a), \
@@ -1725,38 +1725,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equa

[PATCH] D41807: [cmake] Delete redundant install command for clang-refactor.

2018-01-06 Thread Don Hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: arphaman, beanz.
Herald added a subscriber: mgorny.

Delete redundant install command for clang-refactor.  Install
targets for clang tools are controled by CLANG_BUILD_TOOLS, and when
OFF, cmake issues the following warning:

WARNING: Target "clang-refactor" has EXCLUDE_FROM_ALL set and will not
be built by default but an install rule has been provided for it.
CMake does not define behavior for this case.


Repository:
  rC Clang

https://reviews.llvm.org/D41807

Files:
  tools/clang-refactor/CMakeLists.txt


Index: tools/clang-refactor/CMakeLists.txt
===
--- tools/clang-refactor/CMakeLists.txt
+++ tools/clang-refactor/CMakeLists.txt
@@ -20,5 +20,3 @@
   clangToolingCore
   clangToolingRefactor
   )
-
-install(TARGETS clang-refactor RUNTIME DESTINATION bin)


Index: tools/clang-refactor/CMakeLists.txt
===
--- tools/clang-refactor/CMakeLists.txt
+++ tools/clang-refactor/CMakeLists.txt
@@ -20,5 +20,3 @@
   clangToolingCore
   clangToolingRefactor
   )
-
-install(TARGETS clang-refactor RUNTIME DESTINATION bin)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41623: [cmake] [libcxxabi] Fix path problems when cross compiling.

2018-01-06 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

ping...


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D41623



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


[PATCH] D41622: [cmake] [libcxx] Fix path and flag problems when cross compiling.

2018-01-06 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

ping...


Repository:
  rCXX libc++

https://reviews.llvm.org/D41622



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


[PATCH] D41621: [cmake] [libunwind] Fix path problems when cross compiling.

2018-01-06 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

ping...


https://reviews.llvm.org/D41621



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


r321957 - Simplify the internal API for checking whether swiftcall passes a type indirectly and expose that API externally.

2018-01-06 Thread John McCall via cfe-commits
Author: rjmccall
Date: Sat Jan  6 22:28:49 2018
New Revision: 321957

URL: http://llvm.org/viewvc/llvm-project?rev=321957&view=rev
Log:
Simplify the internal API for checking whether swiftcall passes a type 
indirectly and expose that API externally.

Modified:
cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=321957&r1=321956&r2=321957&view=diff
==
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Sat Jan  6 22:28:49 2018
@@ -116,6 +116,12 @@ private:
   void splitVectorEntry(unsigned index);
 };
 
+/// Should an aggregate which expands to the given type sequence
+/// be passed/returned indirectly under swiftcall?
+bool shouldPassIndirectly(CodeGenModule &CGM,
+  ArrayRef types,
+  bool asReturnValue);
+
 /// Return the maximum voluntary integer size for the current target.
 CharUnits getMaximumVoluntaryIntegerSize(CodeGenModule &CGM);
 

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=321957&r1=321956&r2=321957&view=diff
==
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Sat Jan  6 22:28:49 2018
@@ -137,8 +137,7 @@ namespace swiftcall {
 
 bool supportsSwift() const final override { return true; }
 
-virtual bool shouldPassIndirectlyForSwift(CharUnits totalSize,
-  ArrayRef types,
+virtual bool shouldPassIndirectlyForSwift(ArrayRef types,
   bool asReturnValue) const = 0;
 
 virtual bool isLegalVectorTypeForSwift(CharUnits totalSize,

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=321957&r1=321956&r2=321957&view=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Sat Jan  6 22:28:49 2018
@@ -579,11 +579,9 @@ bool SwiftAggLowering::shouldPassIndirec
   // Empty types don't need to be passed indirectly.
   if (Entries.empty()) return false;
 
-  CharUnits totalSize = Entries.back().End;
-
   // Avoid copying the array of types when there's just a single element.
   if (Entries.size() == 1) {
-return getSwiftABIInfo(CGM).shouldPassIndirectlyForSwift(totalSize,
+return getSwiftABIInfo(CGM).shouldPassIndirectlyForSwift(
Entries.back().Type,
  asReturnValue);   
 
   }
@@ -593,8 +591,14 @@ bool SwiftAggLowering::shouldPassIndirec
   for (auto &entry : Entries) {
 componentTys.push_back(entry.Type);
   }
-  return getSwiftABIInfo(CGM).shouldPassIndirectlyForSwift(totalSize,
-   componentTys,
+  return getSwiftABIInfo(CGM).shouldPassIndirectlyForSwift(componentTys,
+   asReturnValue);
+}
+
+bool swiftcall::shouldPassIndirectly(CodeGenModule &CGM,
+ ArrayRef componentTys,
+ bool asReturnValue) {
+  return getSwiftABIInfo(CGM).shouldPassIndirectlyForSwift(componentTys,
asReturnValue);
 }
 

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=321957&r1=321956&r2=321957&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Jan  6 22:28:49 2018
@@ -1028,8 +1028,7 @@ public:
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 
-  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
-ArrayRef scalars,
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
 bool asReturnValue) const override {
 // LLVM's x86-32 lowering currently only assigns up to three
 // integer registers and three fp registers.  Oddly, it'll use up to
@@ -2168,8 +2167,7 @@ public:
 return Has64BitPointers;
   }
 
-  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
-ArrayRef scalars,
+  bool shouldP