[PATCH] D33493: Speed up preamble loading

2017-06-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 101995.
yvvan added a comment.

"what kind of performance benefits do you get for the preamble load times?"
In cases where many windows headers are included preamble loading takes almost 
the half of reparse time. With this fix time to load preamble goes towards zero.


https://reviews.llvm.org/D33493

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1159,6 +1159,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+PreambleSrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -2601,23 +2603,26 @@
   // remap all the locations to the new view. This includes the diag location,
   // any associated source ranges, and the source ranges of associated fix-its.
   // FIXME: There should be a cleaner way to do this.
-
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
-  FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+SourceLocation FileLoc;
+auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
+if (ItFileID == PreambleSrcLocCache.end()) {
+  FileID FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  PreambleSrcLocCache[SD.Filename] = FileLoc;
+} else {
+  FileLoc = ItFileID->getValue();
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -188,6 +188,14 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// Cache contains only source locations from preamble so it is
+  /// guaranteed that they stay valid when the SourceManager is recreated.
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading. It must be cleared when preamble is recreated.
+  llvm::StringMap PreambleSrcLocCache;
+
 public:
   class PreambleData {
 const FileEntry *File;


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1159,6 +1159,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+PreambleSrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -2601,23 +2603,26 @@
   // remap all the locations to the new view. This includes the diag location,
   // any associated source ranges, and the source ranges of associated fix-its.
   // FIXME: There should be a cleaner way to do this.
-
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
-  FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+SourceLocation FileLoc;
+auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
+if (ItFileID == PreambleSrcLocCache.end()) {
+  FileID FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  PreambleSrcLocCache[SD.Filename] = FileLoc;
+} else {
+  FileLoc = ItFileID->getValue();
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -188,6 +188,14 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// Cache contains only source locations from preamble so it is
+  /// guaranteed that they stay valid when the SourceManager is recreated.
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading. It must be cleared when prea

[PATCH] D30375: Function with unparsed body is a definition

2017-06-08 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 101993.
sepavloff added a comment.

Changed implementation


https://reviews.llvm.org/D30375

Files:
  include/clang/AST/Decl.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -170,3 +170,15 @@
 template class Test;
 
 }
+
+namespace pr14785 {
+template
+struct Somewhat {
+  void internal() const { }
+  friend void operator+(int const &, Somewhat const &) {}  // expected-error{{redefinition of 'operator+'}}
+};
+
+void operator+(int const &, Somewhat const &x) {  // expected-note {{previous definition is here}}
+  x.internal();  // expected-note{{in instantiation of template class 'pr14785::Somewhat' requested here}}
+}
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1782,6 +1782,12 @@
   Previous.clear();
   }
 
+  if (isFriend) {
+Function->setObjectOfFriendDecl();
+if (FunctionTemplate)
+  FunctionTemplate->setObjectOfFriendDecl();
+  }
+
   SemaRef.CheckFunctionDeclaration(/*Scope*/ nullptr, Function, Previous,
isExplicitSpecialization);
 
@@ -1792,7 +1798,6 @@
   // If the original function was part of a friend declaration,
   // inherit its namespace state and add it to the owner.
   if (isFriend) {
-PrincipalDecl->setObjectOfFriendDecl();
 DC->makeDeclVisibleInContext(PrincipalDecl);
 
 bool QueuedInstantiation = false;
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13878,6 +13878,9 @@
 return;
   }
 
+  // Deleted function does not have a body.
+  Fn->setWillHaveBody(false);
+
   if (const FunctionDecl *Prev = Fn->getPreviousDecl()) {
 // Don't consider the implicit declaration we generate for explicit
 // specializations. FIXME: Do not generate these implicit declarations.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12218,6 +12218,7 @@
 
   if (FD) {
 FD->setBody(Body);
+FD->setWillHaveBody(false);
 
 if (getLangOpts().CPlusPlus14) {
   if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() &&
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -629,12 +629,6 @@
   // emitted, because (say) the definition could include "inline".
   FunctionDecl *Def = FD->getDefinition();
 
-  // We may currently be parsing the body of FD, in which case
-  // FD->getDefinition() will be null, but we still want to treat FD as though
-  // it's a definition.
-  if (!Def && FD->willHaveBody())
-Def = FD;
-
   if (Def &&
   !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
 return true;
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1837,7 +1837,7 @@
   ///
   bool isThisDeclarationADefinition() const {
 return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed ||
-  hasDefiningAttr();
+  WillHaveBody || hasDefiningAttr();
   }
 
   /// doesThisDeclarationHaveABody - Returns whether this specific
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30375: Function with unparsed body is a definition

2017-06-08 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thank you for explanation. Probably making new semantic action is an overkill.

The intent was to postpone setting flag `WillHaveBody` as late as possible, to 
the moment when it becomes clear that the function indeed will have a body. 
Otherwise parsing of deleted functions is broken. Also in the case of invalid 
input the resulting function declaration become definition while previously 
they were not, it also changes existing behavior. The new semantic action set 
the flag enough late after the call to `ActOnStartOfFunctionBody`, when this 
treatment is already made.

The new solution uses different path. As previously, `ActOnStartOfFunctionBody` 
sets `WillHaveBody` but this flag is reset when it becomes clear that body will 
be available. Such technique is already uses for defaulted functions, so only 
deleted require the flag reset. `WillHaveBody` is also reset when parsing of 
function is finished. This transient flag is not needed after the function 
parsing is done. If `ActOnFinishFunctionBody` is always  called after 
`ActOnStartOfFunctionBody`, erroneous functions are not leaked as definition.


https://reviews.llvm.org/D30375



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


[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 101989.
mclow.lists added a comment.

Turn the for loops into do-while loops, saving a comparison.


https://reviews.llvm.org/D34038

Files:
  include/numeric
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
+++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
@@ -0,0 +1,137 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op);
+
+
+#include 
+#include 
+#include 
+// #include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+//	Test not in-place
+std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+
+//	Test in-place
+	v.clear();
+	v.assign(first, last);
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,  5,   7,   9};
+const int pResI0[] = { 0,  1,  4,   9,  16};// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0};
+const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0};
+const int pResI2[] = { 2,  3,  6,  11,  18};// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210};
+const int pResN2[] = { 2,  1, -2,  -7, -14};// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210};
+const unsigned sa = sizeof(ia) / sizeof(ia[0]);
+static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, pResN2, pResN2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
+}
+}
+
+int triangle(int n) { return n*(n+1)/2; }
+
+//  Basic sanity
+void basic_tests()
+{
+{
+std::ve

[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 101988.
mclow.lists added a comment.

Added a `_VSTD::`, made some assertions `static_assert`, and addressed Bryce's 
concerns about doing an init when the input range is empty.


https://reviews.llvm.org/D34038

Files:
  include/numeric
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
+++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
@@ -0,0 +1,137 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op);
+
+
+#include 
+#include 
+#include 
+// #include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+//	Test not in-place
+std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+
+//	Test in-place
+	v.clear();
+	v.assign(first, last);
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,  5,   7,   9};
+const int pResI0[] = { 0,  1,  4,   9,  16};// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0};
+const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0};
+const int pResI2[] = { 2,  3,  6,  11,  18};// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210};
+const int pResN2[] = { 2,  1, -2,  -7, -14};// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210};
+const unsigned sa = sizeof(ia) / sizeof(ia[0]);
+static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, pResN2, pResN2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
+}
+}
+
+int triangle(int n) { ret

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> Should the non-parallel implementation of reduce static_assert or SFINAE away 
> when these requirements are not met?

That may be desirable, but that's not what the standard says.
There's nothing there about "shall not participate in overload resolution".

//Requires:// in the standard is a requirement on the caller.
Failure to satisfy those requirements is UB - and it can compile, not compile, 
explode at runtime, give the right answer, whatever.

(Look at `copy`, say)


https://reviews.llvm.org/D33997



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


[clang-tools-extra] r305046 - [clangd] Update for ASTUnit API change.

2017-06-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Jun  8 21:04:19 2017
New Revision: 305046

URL: http://llvm.org/viewvc/llvm-project?rev=305046&view=rev
Log:
[clangd] Update for ASTUnit API change.

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=305046&r1=305045&r2=305046&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Jun  8 21:04:19 2017
@@ -52,6 +52,7 @@ ClangdUnit::ClangdUnit(PathRef FileName,
   /*IncludeBriefCommentsInCodeCompletion=*/true,
   /*AllowPCHWithCompilerErrors=*/true,
   /*SkipFunctionBodies=*/false,
+  /*SingleFileParse=*/false,
   /*UserFilesAreVolatile=*/false, /*ForSerialization=*/false,
   /*ModuleFormat=*/llvm::None,
   /*ErrAST=*/nullptr, VFS));


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


r305045 - Remove 'Filename' parameter from BeginSourceFileAction.

2017-06-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun  8 20:36:10 2017
New Revision: 305045

URL: http://llvm.org/viewvc/llvm-project?rev=305045&view=rev
Log:
Remove 'Filename' parameter from BeginSourceFileAction.

No-one was using this, and it's not meaningful in general -- FrontendActions
can be run on inputs that don't have a corresponding source file. The current
frontend input can be obtained by asking the FrontendAction if any future
action actually needs it.

Modified:
cfe/trunk/include/clang/Frontend/FrontendAction.h
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/Frontend/ASTMerge.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/tools/clang-check/ClangCheck.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=305045&r1=305044&r2=305045&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Thu Jun  8 20:36:10 2017
@@ -76,8 +76,7 @@ protected:
   ///
   /// \return True on success; on failure ExecutionAction() and
   /// EndSourceFileAction() will not be called.
-  virtual bool BeginSourceFileAction(CompilerInstance &CI,
- StringRef Filename) {
+  virtual bool BeginSourceFileAction(CompilerInstance &CI) {
 return true;
   }
 
@@ -291,7 +290,7 @@ protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;
   bool BeginInvocation(CompilerInstance &CI) override;
-  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) 
override;
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
   void ExecuteAction() override;
   void EndSourceFileAction() override;
 

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=305045&r1=305044&r2=305045&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Jun  8 20:36:10 2017
@@ -91,7 +91,7 @@ public:
   ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile,
   std::string &Sysroot, std::string &OutputFile);
 
-  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) 
override;
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
 };
 
 class GenerateModuleAction : public ASTFrontendAction {
@@ -111,15 +111,13 @@ protected:
 
 class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
 private:
-  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) 
override;
-
   std::unique_ptr
   CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
 };
 
 class GenerateModuleInterfaceAction : public GenerateModuleAction {
 private:
-  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) 
override;
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
 
   std::unique_ptr
   CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
@@ -181,8 +179,7 @@ protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;
 
-  bool BeginSourceFileAction(CompilerInstance &CI,
- StringRef Filename) override;
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
 
   void ExecuteAction() override;
   void EndSourceFileAction() override;

Modified: cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=305045&r1=305044&r2=305045&view=diff
==
--- cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h Thu Jun  8 
20:36:10 2017
@@ -34,8 +34,7 @@ protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override;
 
-  bool BeginSourceFileAction(CompilerInstance &CI,
- StringRef Filename) override;
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
 
   void EndSourceFileAction() override;
 

Modified: cfe/trunk/include/cl

[PATCH] D34021: [coroutines] Fix co_await for range statement

2017-06-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/SemaCXX/coawait_range_for.cpp:133
+
+struct ForLoopAwaiterCoawaitLookup {
+  struct promise_type {

This test is incorrect WRT ADL  lookup.


https://reviews.llvm.org/D34021



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


r305044 - [libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for parsing a single file only.

2017-06-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Jun  8 20:20:48 2017
New Revision: 305044

URL: http://llvm.org/viewvc/llvm-project?rev=305044&view=rev
Log:
[libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' 
that puts preprocessor in a mode for parsing a single file only.

This is useful for parsing a single file, as a fast/inaccurate 'mode' that can 
still provide declarations from the file, like the classes and their methods.

Added:
cfe/trunk/test/Index/singe-file-parse.m
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=305044&r1=305043&r2=305044&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Jun  8 20:20:48 2017
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 42
+#define CINDEX_VERSION_MINOR 43
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -1234,7 +1234,12 @@ enum CXTranslationUnit_Flags {
* purposes of an IDE, this is undesirable behavior and as much information
* as possible should be reported. Use this flag to enable this behavior.
*/
-  CXTranslationUnit_KeepGoing = 0x200
+  CXTranslationUnit_KeepGoing = 0x200,
+
+  /**
+   * \brief Sets the preprocessor in a mode for parsing a single file only.
+   */
+  CXTranslationUnit_SingleFileParse = 0x400
 };
 
 /**

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=305044&r1=305043&r2=305044&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jun  8 20:20:48 2017
@@ -871,6 +871,7 @@ public:
   bool CacheCodeCompletionResults = false,
   bool IncludeBriefCommentsInCodeCompletion = false,
   bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false,
+  bool SingleFileParse = false,
   bool UserFilesAreVolatile = false, bool ForSerialization = false,
   llvm::Optional ModuleFormat = llvm::None,
   std::unique_ptr *ErrAST = nullptr,

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=305044&r1=305043&r2=305044&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jun  8 20:20:48 2017
@@ -95,6 +95,9 @@ public:
   /// If given, a PTH cache file to use for speeding up header parsing.
   std::string TokenCache;
 
+  /// When enabled, preprocessor is in a mode for parsing a single file only.
+  bool SingleFileParseMode = false;
+
   /// \brief True if the SourceManager should report the original file name for
   /// contents of files that were remapped to other files. Defaults to true.
   bool RemappedFilesKeepOriginalName;
@@ -181,6 +184,7 @@ public:
 ImplicitPCHInclude.clear();
 ImplicitPTHInclude.clear();
 TokenCache.clear();
+SingleFileParseMode = false;
 RetainRemappedFileBuffers = true;
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = 0;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=305044&r1=305043&r2=305044&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jun  8 20:20:48 2017
@@ -1982,7 +1982,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
 unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
 bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
 bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies,
-bool UserFilesAreVolatile, bool ForSerialization,
+bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization,
 llvm::Optional ModuleFormat, std::unique_ptr *ErrAST,
 IntrusiveRefCntPtr VFS) {
   assert(Diags.get() && "no DiagnosticsEngine was provided");
@@ -2011,6 +2011,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
   PPOpts.GeneratePreamble = Precompi

r305039 - Represent debug information compression type fully

2017-06-08 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jun  8 19:40:30 2017
New Revision: 305039

URL: http://llvm.org/viewvc/llvm-project?rev=305039&view=rev
Log:
Represent debug information compression type fully

This is tied with the LLVM side of the change to expose the debug
information compression types to clang.  We now track the compression
type as an enumeration rather than a boolean.  We still use the same
value (GNU) that we did previously.  This is in preparation to support
passing down the compression type and switch it based on the command
line.

Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=305039&r1=305038&r2=305039&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Jun  8 19:40:30 2017
@@ -29,7 +29,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
+ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
+llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=305039&r1=305038&r2=305039&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun  8 19:40:30 2017
@@ -410,7 +410,7 @@ static void initTargetOptions(llvm::Targ
 
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
-  Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+  Options.CompressDebugSections = CodeGenOpts.getCompressDebugSections();
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
 
   // Set EABI version.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=305039&r1=305038&r2=305039&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun  8 19:40:30 2017
@@ -739,7 +739,9 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
-  Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
+  // TODO: map this from -gz in the driver and give it a named value
+  if (Args.hasArg(OPT_compress_debug_sections))
+Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   for (auto A : Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_cuda_bitcode)) 
{

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=305039&r1=305038&r2=305039&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Jun  8 19:40:30 2017
@@ -88,12 +88,13 @@ struct AssemblerInvocation {
   unsigned NoInitialTextSection : 1;
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
-  unsigned CompressDebugSections : 1;
   unsigned RelaxELFRelocations : 1;
   unsigned DwarfVersion;
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
+  llvm::DebugCompressionType CompressDebugSections =
+  llvm::DebugCompressionType::None;
   std::string MainFileName;
 
   /// @}
@@ -201,7 +202,9 @@ bool AssemblerInvocation::CreateFromArgs
   Opts.SaveTemporaryLabels = Args.hasArg(OPT_msave_temp_labels);
   // Any DebugInfoKind implies GenDwarfForAssembly.
   Opts.GenDwarfForAssembly = Args.hasArg(OPT_debug_info_kind_EQ);
-  Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
+  // TODO: base this on -gz instead
+  if (Args.hasArg(OPT_compress_debug_sections))
+Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrela

[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

This implementation works, but performs unnecessary operations.

https://gist.github.com/brycelelbach/907ac3b8a74603cc189897ab789a65a9

The "next" result is calculated in each iteration; this means one unnecessary 
application of the binary op (the "next" result on the final iteration).


https://reviews.llvm.org/D34038



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Android source is suppressing misc-noexcept-move-constructor warnings
because -fno-exceptions is used and Android does not like to add more
exception specific code.

It's not a big deal for Android to suppress this check one way or the other.
I don't mind reverting it, just curious why a compiler cannot assume noexcept 
under -fno-exceptions.


https://reviews.llvm.org/D34002



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


[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

https://gist.github.com/brycelelbach/137f1e45b737d615134e228ec0c84f3a <- some 
crude tests I wrote based on slides/notes of mine.


https://reviews.llvm.org/D34038



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-08 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added inline comments.



Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

aaron.ballman wrote:
> rjmccall wrote:
> > ABataev wrote:
> > > aaron.ballman wrote:
> > > > ABataev wrote:
> > > > > aaron.ballman wrote:
> > > > > > It's a bit strange to me that the non-parameter declaration bits 
> > > > > > now have a field for implicit parameter information. Why here 
> > > > > > instead of `ParmVarDeclBits`?
> > > > > Actually, `ImplicitParamDecl` already uses some bits from the 
> > > > > `NonParmVarDeclBitfields`, at least it may be marked as 
> > > > > `ARCPseudoStrong` for ObjC. That's why I had to reuse 
> > > > > `NonParmVarDeclBitfields` part.
> > > > Ew. That's nasty and we should probably fix that (not as part of this 
> > > > patch). Can you add a FIXME here?
> > > Ok, I will add FIXME for `ARCPseudoStrong` and for the 
> > > `ImplicitParamKind` bitfields
> > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of 
> > ParamVarDecl.
> > 
> > The comment here needs to be updated.
> > The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of 
> > ParamVarDecl.
> 
> Then the class name is poor, because I would not expect to find *anything* 
> about parameter declarations (implicit or otherwise) in a class named 
> `NonParmVarDeclBitfields`. However, I see the logic behind the split better 
> now, so thank you for that. (Nothing needs to be done here for this patch.)
Yeah, I agree that it's unfortunate that we have two separate classes for 
parameter declarations.


https://reviews.llvm.org/D33735



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


Re: r305022 - [ASTMatchers] Add clang-query support for equals matcher

2017-06-08 Thread Peter Wu via cfe-commits
Yes, mea culpa :(

I forgot to rebuild after doing the final revision of the patch (in
which two new tests were added). The failing tests are temporary
disabled in r305025 until a proper fix is developed.

Kind regards,
Peter

On Thu, Jun 08, 2017 at 03:58:01PM -0700, Kostya Serebryany wrote:
> The test seems to be failing:
> llvm/tools/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp:533: Failure
> Value of: matches("double x = 1.2f;", DoubleStmt)
>   Actual: false (Could not find match in "double x = 1.2f;")
> Expected: true
> 
> 
> On Thu, Jun 8, 2017 at 3:00 PM, Peter Wu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > Author: lekensteyn
> > Date: Thu Jun  8 17:00:58 2017
> > New Revision: 305022
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=305022&view=rev
> > Log:
> > [ASTMatchers] Add clang-query support for equals matcher
> >
> > Summary:
> > This allows the clang-query tool to use matchers like
> > "integerLiteral(equals(32))". For this to work, an overloaded function
> > is added for each possible parameter type.
> >
> > Reviewed By: aaron.ballman
> >
> > Differential Revision: https://reviews.llvm.org/D33094
> >
> > Modified:
> > cfe/trunk/docs/LibASTMatchersReference.html
> > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> > cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> > cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
> >
> > Modified: cfe/trunk/docs/LibASTMatchersReference.html
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> > LibASTMatchersReference.html?rev=305022&r1=305021&r2=305022&view=diff
> > 
> > ==
> > --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> > +++ cfe/trunk/docs/LibASTMatchersReference.html Thu Jun  8 17:00:58 2017
> > @@ -1859,17 +1859,36 @@ Example matches a || b (matcher = binary
> >  
> >
> >
> > -Matcher > onclick="toggle('equals2')"> > name="equals2Anchor">equalsValueT
> > Value
> > -Matches literals that
> > are equal to the given value.
> > +Matcher > 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> > onclick="toggle('equals2')"> > name="equals2Anchor">equalsValueT
> > Value
> > +Matches literals that
> > are equal to the given value of type ValueT.
> >
> > -Example matches true (matcher = cxxBoolLiteral(equals(true)))
> > -  true
> > +Given
> > +  f('false, 3.14, 42);
> > +characterLiteral(equals(0))
> > +  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
> > +  match false
> > +floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
> > +  match 3.14
> > +integerLiteral(equals(42))
> > +  matches 42
> >
> > -Usable as: Matcher > doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> > Matcher,
> > +Usable as: Matcher > doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> > Matcher > 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr>,
> > Matcher > doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral>,
> > Matcher > 1IntegerLiteral.html">IntegerLiteral>
> >  
> >
> >
> > +Matcher > 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> > onclick="toggle('equals5')">equalsbool
> > Value
> > +
> > +
> > +
> > +Matcher > 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> > onclick="toggle('equals11')"> > name="equals11Anchor">equalsdouble
> > Value
> > +
> > +
> > +
> > +Matcher > 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> > onclick="toggle('equals8')"> > name="equals8Anchor">equalsunsigned
> > Value
> > +
> > +
> > +
> >  Matcher > 1CXXCatchStmt.html">CXXCatchStmt> > onclick="toggle('isCatchAll0')">
> > isCatchAll
> >  Matches a C++ catch
> > statement that has a catch-all handler.
> >
> > @@ -2296,16 +2315,35 @@ Example: matches the implicit cast aroun
> >
> >
> >  Matcher > 1CharacterLiteral.html">CharacterLiteral> > onclick="toggle('equals3')"> > name="equals3Anchor">equalsValueT
> > Value
> > -Matches literals that
> > are equal to the given value.
> > +Matches literals that
> > are equal to the given value of type ValueT.
> >
> > -Example matches true (matcher = cxxBoolLiteral(equals(true)))
> > -  true
> > +Given
> > +  f('false, 3.14, 42);
> > +characterLiteral(equals(0))
> > +  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
> > +  match false
> > +floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
> > +  match 3.14
> > +integerLiteral(equals(42))
> > +  matches 42
> >
> > -Usable as: Matcher > doxygen/classclang_1_1CharacterLiteral.html

[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added inline comments.



Comment at: include/numeric:182
+{
+   _Tp __saved = __init;
+   for (; __first != __last; ++__first, (void) ++__result) {

If `__first == __last`, this initialization is unnecessary; I'd refactor this 
so that we check for `__first != __last` first.



Comment at: include/numeric:208
+{
+   _Tp __saved = __init;
+   for (; __first != __last; ++__first, (void) ++__result) {

If `__first == __last`, this initialization is unnecessary; I'd refactor this 
so that we check for `__first != __last` first.


https://reviews.llvm.org/D34038



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


r305026 - [sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. Reapplying revisions 304630, 304631, 304632, 304673, see

2017-06-08 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Thu Jun  8 17:58:19 2017
New Revision: 305026

URL: http://llvm.org/viewvc/llvm-project?rev=305026&view=rev
Log:
[sanitizer-coverage] one more flavor of coverage: 
-fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting 
yet. Reapplying revisions 304630, 304631, 304632, 304673, see PR33308 

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=305026&r1=305025&r2=305026&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Jun  8 17:58:19 2017
@@ -293,6 +293,9 @@ def fsanitize_coverage_trace_gep
 def fsanitize_coverage_8bit_counters
 : Flag<["-"], "fsanitize-coverage-8bit-counters">,
   HelpText<"Enable frequency counters in sanitizer coverage">;
+def fsanitize_coverage_inline_8bit_counters
+: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
+  HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
 def fsanitize_coverage_trace_pc
 : Flag<["-"], "fsanitize-coverage-trace-pc">,
   HelpText<"Enable PC tracing in sanitizer coverage">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=305026&r1=305025&r2=305026&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Jun  8 17:58:19 2017
@@ -163,6 +163,7 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0
   ///< in sanitizer coverage.
 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with 
guard
///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=305026&r1=305025&r2=305026&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun  8 17:58:19 2017
@@ -187,6 +187,7 @@ static void addSanitizerCoveragePass(con
   Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
   Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
   Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
+  Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=305026&r1=305025&r2=305026&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Jun  8 17:58:19 2017
@@ -48,13 +48,14 @@ enum CoverageFeature {
   CoverageBB = 1 << 1,
   CoverageEdge = 1 << 2,
   CoverageIndirCall = 1 << 3,
-  CoverageTraceBB = 1 << 4,
+  CoverageTraceBB = 1 << 4,  // Deprecated.
   CoverageTraceCmp = 1 << 5,
   CoverageTraceDiv = 1 << 6,
   CoverageTraceGep = 1 << 7,
-  Coverage8bitCounters = 1 << 8,
+  Coverage8bitCounters = 1 << 8,  // Deprecated.
   CoverageTracePC = 1 << 9,
   CoverageTracePCGuard = 1 << 10,
+  CoverageInline8bitCounters = 1 << 12,
   CoverageNoPrune = 1 << 11,
 };
 
@@ -530,7 +531,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
   }
 
   // trace-pc w/o func/bb/edge implies edge.
-  if ((CoverageFeatures & (CoverageTracePC | CoverageTracePCGuard)) &&
+  if ((CoverageFeatures &
+   (CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters)) 
&&
   !(CoverageFeatures & InsertionPointTypes))
 CoverageFeatures |= CoverageEdge;
 
@@ -637,6 +639,7 @@ void SanitizerArgs::addArgs(const ToolCh
 std::make_pair(Coverage8bitCounters, "-fsanitize-coverage-8bit-counters"),
 std::make_pair(CoverageTracePC, "-fsanitize-coverage-trace-pc"),
 std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard"),
+std::make_pair(CoverageInline8bitCounters, 
"-fsanitize-coverage-inline-8bit-counters"),
 std::make_pair(Coverag

r305025 - [ASTMatchers] temporary disable tests with floating suffix

2017-06-08 Thread Peter Wu via cfe-commits
Author: lekensteyn
Date: Thu Jun  8 17:58:12 2017
New Revision: 305025

URL: http://llvm.org/viewvc/llvm-project?rev=305025&view=rev
Log:
[ASTMatchers] temporary disable tests with floating suffix

r305022 assumed that floatLiteral(equals(1.2)) would also match 1.2f and
1.2l, but apparently that is not the case. Until it is clear how to
match, temporary disable the test to fix CI.

Modified:
cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp?rev=305025&r1=305024&r2=305025&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp Thu Jun  8 
17:58:12 2017
@@ -530,8 +530,11 @@ TEST_F(RegistryTest, EqualsMatcher) {
   "floatLiteral", constructMatcher("equals", VariantValue(1.2)))
   .getTypedMatcher();
   EXPECT_TRUE(matches("double x = 1.2;", DoubleStmt));
+#if 0
+  // FIXME floatLiteral matching should work regardless of suffix.
   EXPECT_TRUE(matches("double x = 1.2f;", DoubleStmt));
   EXPECT_TRUE(matches("double x = 1.2l;", DoubleStmt));
+#endif
   EXPECT_TRUE(matches("double x = 12e-1;", DoubleStmt));
   EXPECT_FALSE(matches("double x = 1.23;", DoubleStmt));
 


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


Re: r305022 - [ASTMatchers] Add clang-query support for equals matcher

2017-06-08 Thread Kostya Serebryany via cfe-commits
The test seems to be failing:
llvm/tools/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp:533: Failure
Value of: matches("double x = 1.2f;", DoubleStmt)
  Actual: false (Could not find match in "double x = 1.2f;")
Expected: true


On Thu, Jun 8, 2017 at 3:00 PM, Peter Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lekensteyn
> Date: Thu Jun  8 17:00:58 2017
> New Revision: 305022
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305022&view=rev
> Log:
> [ASTMatchers] Add clang-query support for equals matcher
>
> Summary:
> This allows the clang-query tool to use matchers like
> "integerLiteral(equals(32))". For this to work, an overloaded function
> is added for each possible parameter type.
>
> Reviewed By: aaron.ballman
>
> Differential Revision: https://reviews.llvm.org/D33094
>
> Modified:
> cfe/trunk/docs/LibASTMatchersReference.html
> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
>
> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> LibASTMatchersReference.html?rev=305022&r1=305021&r2=305022&view=diff
> 
> ==
> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> +++ cfe/trunk/docs/LibASTMatchersReference.html Thu Jun  8 17:00:58 2017
> @@ -1859,17 +1859,36 @@ Example matches a || b (matcher = binary
>  
>
>
> -Matcher onclick="toggle('equals2')">equalsValueT
> Value
> -Matches literals that
> are equal to the given value.
> +Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> onclick="toggle('equals2')">equalsValueT
> Value
> +Matches literals that
> are equal to the given value of type ValueT.
>
> -Example matches true (matcher = cxxBoolLiteral(equals(true)))
> -  true
> +Given
> +  f('false, 3.14, 42);
> +characterLiteral(equals(0))
> +  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
> +  match false
> +floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
> +  match 3.14
> +integerLiteral(equals(42))
> +  matches 42
>
> -Usable as: Matcher doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> Matcher,
> +Usable as: Matcher doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr>,
> Matcher doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral>,
> Matcher 1IntegerLiteral.html">IntegerLiteral>
>  
>
>
> +Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> onclick="toggle('equals5')">equalsbool
> Value
> +
> +
> +
> +Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> onclick="toggle('equals11')"> name="equals11Anchor">equalsdouble
> Value
> +
> +
> +
> +Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr> onclick="toggle('equals8')"> name="equals8Anchor">equalsunsigned
> Value
> +
> +
> +
>  Matcher 1CXXCatchStmt.html">CXXCatchStmt> onclick="toggle('isCatchAll0')">
> isCatchAll
>  Matches a C++ catch
> statement that has a catch-all handler.
>
> @@ -2296,16 +2315,35 @@ Example: matches the implicit cast aroun
>
>
>  Matcher 1CharacterLiteral.html">CharacterLiteral> onclick="toggle('equals3')">equalsValueT
> Value
> -Matches literals that
> are equal to the given value.
> +Matches literals that
> are equal to the given value of type ValueT.
>
> -Example matches true (matcher = cxxBoolLiteral(equals(true)))
> -  true
> +Given
> +  f('false, 3.14, 42);
> +characterLiteral(equals(0))
> +  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
> +  match false
> +floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
> +  match 3.14
> +integerLiteral(equals(42))
> +  matches 42
>
> -Usable as: Matcher doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> Matcher,
> +Usable as: Matcher doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral>,
> Matcher 1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr>,
> Matcher doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral>,
> Matcher 1IntegerLiteral.html">IntegerLiteral>
>  
>
>
> +Matcher 1CharacterLiteral.html">CharacterLiteral> onclick="toggle('equals4')">equalsbool
> Value
> +
> +
> +
> +Matcher<

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

I think we need a test case like this for all of the `transform_*`s

  struct A {};
  struct B {};
  struct C {};
  
  B unary_op(C);
  B unary_op(A) { assert(false); /* unary op applied to init value! */ }
  A binary_op(A, A);
  A binary_op(A, B);
  A binary_op(B, A);
  A binary_op(B, B); 
  
  std::vector v;
  std::tranform_reduce(v.begin(), v.end(), A{}, binary_op, unary_op);

The "inner" transform operation should **never** be applied to the `init` 
parameter.




Comment at: include/numeric:209
+{
+   return transform_reduce(__first1, __last1, __first2, __init, 
_VSTD::plus<>(), _VSTD::multiplies<>());
+}

rsmith wrote:
> Missing _VSTD::
In the patch I downloaded from here, the spacing before the return is tabs, not 
spaces.



Comment at: 
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp:44
+{
+   constexpr const _Tp operator()(const _Tp& __x) const noexcept { return 
2 * __x; }
+};

In the patch I downloaded from here, there is a tab right before `constexpr`.


https://reviews.llvm.org/D33997



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


[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

Here's `partial_sum`:

  template 
  inline _LIBCPP_INLINE_VISIBILITY
  _OutputIterator
  partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator 
__result,
  _BinaryOperation __binary_op)
  {
  if (__first != __last)
  {
  typename iterator_traits<_InputIterator>::value_type __t(*__first);
  *__result = __t;
  for (++__first, (void) ++__result; __first != __last; ++__first, 
(void) ++__result)
  {
  __t = __binary_op(__t, *__first);
  *__result = __t;
  }
  }
  return __result;
  }

And here's the `inclusive_scan` that should be equivalent to that `partial_sum`:

  template 
  inline _LIBCPP_INLINE_VISIBILITY
  _OutputIterator
  inclusive_scan(_InputIterator __first, _InputIterator __last, 
 _OutputIterator __result, _BinaryOp __b)
  {
  if (__first != __last) {
  typename iterator_traits<_InputIterator>::value_type __init = 
*__first++;
  return inclusive_scan(__first, __last, __result, __b, __init);
   }
  
  return __result;
  }

The `inclusive_scan` that it forwards to is:

  template 
  inline _LIBCPP_INLINE_VISIBILITY
  _OutputIterator 
  inclusive_scan(_InputIterator __first, _InputIterator __last, 
 _OutputIterator __result, _BinaryOp __b,  _Tp __init)
  {
  *__result++ = __init;
  for (; __first != __last; ++__first) {
  __init = __b(__init, *__first);
  *__result++ = __init;
   }
  
  return __result;
  }

Inlining it, we get:

  template 
  inline _LIBCPP_INLINE_VISIBILITY
  _OutputIterator
  inclusive_scan(_InputIterator __first, _InputIterator __last, 
 _OutputIterator __result, _BinaryOp __b)
  {
  if (__first != __last) {
  typename iterator_traits<_InputIterator>::value_type __init = 
*__first++;
  *__result++ = __init;
  
  for (; __first != __last; ++__first) {
  __init = __b(__init, *__first);
  *__result++ = __init;
  }
   }
  
  return __result;
  }

That looks equivalent to the `partial_sum` implementation above, so I think it 
is correct.


https://reviews.llvm.org/D34007



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


[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

So, `inclusive_scan` should be equivalent to `partial_sum` for the non-parallel 
version.


https://reviews.llvm.org/D34007



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


[PATCH] D33976: [clang] Fix format specifiers fixits

2017-06-08 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D33976#775918, @alexshap wrote:

> @mehdi_amini , thanks, i see, regarding the "opposite issue" - probably an 
> example / test case would be helpful, that looks like a separate issue.
>  Thanks for adding @ahatanak and @arphaman, that would be wonderful if smb 
> could look at this diff (which, besides the fix, adds tests)


I'll CC you on the bug when I get time to reduce the test case and file the bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D33976



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


[PATCH] D34007: Implement inclusive_scan and transform_inclusive_scan

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

Minor note: there's a mix of tabs and spaces in this diff.


https://reviews.llvm.org/D34007



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


Re: [PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-08 Thread Kamil Rytarowski via cfe-commits
I managed to link a hello world application, however the NetBSD-specific
nits stand for production programs. RPATH is the first difference that
matters.

Unfortunately I'm swamped by other LLVM projects to join LLD.. research
other differences and prepare patches myself.

On 09.06.2017 00:11, Rui Ueyama wrote:
> I don't remember the details, but I believe LLD-generated executables
> are fine with either Linux or on NetBSD
> 
> On Thu, Jun 8, 2017 at 3:08 PM, Kamil Rytarowski  > wrote:
> 
> On 08.06.2017 22:39, Rui Ueyama wrote:
> > On Wed, Jun 7, 2017 at 6:55 AM, Joerg Sonnenberger via Phabricator
> > mailto:revi...@reviews.llvm.org>
> >>
> wrote:
> >
> > joerg added a comment.
> >
> > In https://reviews.llvm.org/D33726#774105
> 
> >  >, @ruiu wrote:
> >
> > > I'm totally against adding per-OS path knowledge to our linker. 
> Compilers already know include paths and I don't want to maintain another 
> list of paths in the linker. Also this can be more confusing than useful when 
> you are doing cross-linking.
> >
> >
> > The only reason for compilers to maintain that list is for finding
> > crt*.o. They otherwise don't care about the library paths at all.
> > There is no confusion for cross-linking as long as proper sysroot
> > support is used. Which we have been doing on NetBSD for ages.
> >
> >
> > That's not what clang is trying to do for all Unix-like systems (except
> > NetBSD due to the bug), right? The compiler driver actually passes
> > library paths to the linker. If you think that is wrong, you should make
> > a change to stop doing that on all systems. I don't see a reason to not
> > do this only on NetBSD.
> >
> 
> I'm convinced that Joerg is right, that there is need some knowledge on
> the LLD side. I'm more relaxed about -L paths as long as they work for
> regular use-cases, but DT_RPATH vs DT_RUNPATH behaves differently on
> Linux and NetBSD.
> 
> > > For all OSes other than NetBSD, LLD works fine with the clang 
> driver as the driver passes include paths to the linker. I don't see any 
> reason not to do the same thing for NetBSD. That stands even if the linker 
> has to have a list of include paths.
> >
> > Sorry, but this is again ignorant and wrong. The very same problem
> > of build systems calling ld directly apply on most other systems.
> > Even then, the list of linker paths is not the only OS-specific
> > knowledge. Things like the DT_RPATH vs DT_RUNPATH mess, init vs
> > init_array all belong into this category. The list goes on.
> >
> >
> > Repository:
> >   rL LLVM
> >
> > https://reviews.llvm.org/D33726
>   >
> >
> >
> >
> >
> 
> 
> 




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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/misc-noexcept-move-constructor.cpp:2
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-std=c++11 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"

FlameTop wrote:
> Could I request that exceptions be explicitly enabled here (-fexceptions) as 
> the test currently fails on targets which are configured with exceptions 
> disabled as default? 
That would be the way to go, if we wanted to keep this change in. However, we 
need to revert it (which should also fix the issues you're talking about).


https://reviews.llvm.org/D34002



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


Re: [PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Aaron Ballman via cfe-commits
On Thu, Jun 8, 2017 at 6:24 PM, Alexander Kornienko via Phabricator
 wrote:
> alexfh added a comment.
>
> In https://reviews.llvm.org/D34002#776193, @chh wrote:
>
>> In https://reviews.llvm.org/D34002#775830, @alexfh wrote:
>>
>> > IIUC, when `vector` (for a class `T` that has both move and copy 
>> > constructors) resizes, it will prefer move constructors, but only if 
>> > they're declared `noexcept`.  This is true even if `-fno-exceptions` is 
>> > on. So I don't think this check should depend on `-fno-exceptions`.
>>
>>
>> Should the compiler assume `noexcept` when -fno-exceptions is on?
>>  That means move constructors should be preferred under -fno-exceptions, and 
>> this check would be unnecessary, right?
>
>
> The compiler doesn't assume `noexcept` and I heard from competent people the 
> reasons why it shouldn't, though I can't immediately recall these reasons. I 
> think, the patch should be reverted.

Yes, in light of this, I agree.

~Aaron

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


[clang-tools-extra] r305024 - [clang-tidy] Use -fexceptions explicitly in the tests that need exceptions.

2017-06-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun  8 17:25:23 2017
New Revision: 305024

URL: http://llvm.org/viewvc/llvm-project?rev=305024&view=rev
Log:
[clang-tidy] Use -fexceptions explicitly in the tests that need exceptions.

This should fix relevant buildbot breakages.

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp?rev=305024&r1=305023&r2=305024&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp 
Thu Jun  8 17:25:23 2017
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
 // RUN:   -config="{CheckOptions: [{key: 
modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
-// RUN:   -- -std=c++11
+// RUN:   -- -std=c++11 -fexceptions
 
 // Example definition of NOEXCEPT -- simplified test to see if noexcept is 
supported.
 #if (__has_feature(cxx_noexcept))

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp?rev=305024&r1=305023&r2=305024&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp Thu 
Jun  8 17:25:23 2017
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
 // RUN:   -config="{CheckOptions: [{key: 
modernize-use-noexcept.UseNoexceptFalse, value: 0}]}" \
-// RUN:   -- -std=c++11
+// RUN:   -- -std=c++11 -fexceptions
 
 class A {};
 class B {};

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp?rev=305024&r1=305023&r2=305024&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp Thu Jun  
8 17:25:23 2017
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
-// RUN:   -- -std=c++11
+// RUN:   -- -std=c++11 -fexceptions
 
 class A {};
 class B {};


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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34002#776193, @chh wrote:

> In https://reviews.llvm.org/D34002#775830, @alexfh wrote:
>
> > IIUC, when `vector` (for a class `T` that has both move and copy 
> > constructors) resizes, it will prefer move constructors, but only if 
> > they're declared `noexcept`.  This is true even if `-fno-exceptions` is on. 
> > So I don't think this check should depend on `-fno-exceptions`.
>
>
> Should the compiler assume `noexcept` when -fno-exceptions is on?
>  That means move constructors should be preferred under -fno-exceptions, and 
> this check would be unnecessary, right?


The compiler doesn't assume `noexcept` and I heard from competent people the 
reasons why it shouldn't, though I can't immediately recall these reasons. I 
think, the patch should be reverted.


https://reviews.llvm.org/D34002



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


Re: [PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-08 Thread Rui Ueyama via cfe-commits
I don't remember the details, but I believe LLD-generated executables are
fine with either Linux or on NetBSD

On Thu, Jun 8, 2017 at 3:08 PM, Kamil Rytarowski  wrote:

> On 08.06.2017 22:39, Rui Ueyama wrote:
> > On Wed, Jun 7, 2017 at 6:55 AM, Joerg Sonnenberger via Phabricator
> > mailto:revi...@reviews.llvm.org>> wrote:
> >
> > joerg added a comment.
> >
> > In https://reviews.llvm.org/D33726#774105
> > , @ruiu wrote:
> >
> > > I'm totally against adding per-OS path knowledge to our linker.
> Compilers already know include paths and I don't want to maintain another
> list of paths in the linker. Also this can be more confusing than useful
> when you are doing cross-linking.
> >
> >
> > The only reason for compilers to maintain that list is for finding
> > crt*.o. They otherwise don't care about the library paths at all.
> > There is no confusion for cross-linking as long as proper sysroot
> > support is used. Which we have been doing on NetBSD for ages.
> >
> >
> > That's not what clang is trying to do for all Unix-like systems (except
> > NetBSD due to the bug), right? The compiler driver actually passes
> > library paths to the linker. If you think that is wrong, you should make
> > a change to stop doing that on all systems. I don't see a reason to not
> > do this only on NetBSD.
> >
>
> I'm convinced that Joerg is right, that there is need some knowledge on
> the LLD side. I'm more relaxed about -L paths as long as they work for
> regular use-cases, but DT_RPATH vs DT_RUNPATH behaves differently on
> Linux and NetBSD.
>
> > > For all OSes other than NetBSD, LLD works fine with the clang
> driver as the driver passes include paths to the linker. I don't see any
> reason not to do the same thing for NetBSD. That stands even if the linker
> has to have a list of include paths.
> >
> > Sorry, but this is again ignorant and wrong. The very same problem
> > of build systems calling ld directly apply on most other systems.
> > Even then, the list of linker paths is not the only OS-specific
> > knowledge. Things like the DT_RPATH vs DT_RUNPATH mess, init vs
> > init_array all belong into this category. The list goes on.
> >
> >
> > Repository:
> >   rL LLVM
> >
> > https://reviews.llvm.org/D33726 
> >
> >
> >
> >
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r304977 - [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread Alexander Kornienko via cfe-commits
It looks like the buildbots have exceptions turned off by default, so the
tests need to use `-fexceptions` explicitly. Testing a fix...

On Thu, Jun 8, 2017 at 11:26 PM, Galina Kistanova 
wrote:

> Hello Alexander,
>
> Couple of our builders do not like this commit:
>
> Failing Tests:
>
> Clang Tools :: clang-tidy/modernize-use-noexcept-opt.cpp
> Clang Tools :: clang-tidy/modernize-use-noexcept.cpp
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-ubuntu-fast/builds/12431
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast
>
> Please have a look at this?
>
> Thanks
>
> Galina
>
> On Thu, Jun 8, 2017 at 7:04 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Thu Jun  8 09:04:16 2017
>> New Revision: 304977
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304977&view=rev
>> Log:
>> [clang-tidy] New checker to replace dynamic exception specifications
>>
>> Summary:
>> New checker to replace dynamic exception
>> specifications
>>
>> This is an alternative to D18575 which relied on reparsing the decl to
>> find the location of dynamic exception specifications, but couldn't
>> deal with preprocessor conditionals correctly without reparsing the
>> entire file.
>>
>> This approach uses D20428 to find dynamic exception specification
>> locations and handles all cases correctly.
>>
>> Reviewers: aaron.ballman, alexfh
>>
>> Reviewed By: aaron.ballman, alexfh
>>
>> Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere,
>> cfe-commits, Eugene.Zelenko, etienneb
>>
>> Patch by Don Hinton!
>>
>> Differential Revision: https://reviews.llvm.org/D20693
>>
>> Added:
>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use
>> -noexcept.rst
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
>> pt-macro.cpp
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
>> pt-opt.cpp
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> clang-tools-extra/trunk/docs/ReleaseNotes.rst
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=304976&r2=
>> 304977&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jun
>> 8 09:04:16 2017
>> @@ -22,6 +22,7 @@ add_clang_library(clangTidyModernizeModu
>>UseEmplaceCheck.cpp
>>UseEqualsDefaultCheck.cpp
>>UseEqualsDeleteCheck.cpp
>> +  UseNoexceptCheck.cpp
>>UseNullptrCheck.cpp
>>UseOverrideCheck.cpp
>>UseTransparentFunctorsCheck.cpp
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyMo
>> dule.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/modernize/ModernizeTidyModule.cpp?rev=304977&r1=
>> 304976&r2=304977&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> Thu Jun  8 09:04:16 2017
>> @@ -28,6 +28,7 @@
>>  #include "UseEmplaceCheck.h"
>>  #include "UseEqualsDefaultCheck.h"
>>  #include "UseEqualsDeleteCheck.h"
>> +#include "UseNoexceptCheck.h"
>>  #include "UseNullptrCheck.h"
>>  #include "UseOverrideCheck.h"
>>  #include "UseTransparentFunctorsCheck.h"
>> @@ -69,6 +70,7 @@ public:
>>  CheckFactories.registerCheck("modern
>> ize-use-equals-default");
>>  CheckFactories.registerCheck(
>>  "modernize-use-equals-delete");
>> +CheckFactories.registerCheck("modernize-us
>> e-noexcept");
>>  CheckFactories.registerCheck("modernize-us
>> e-nullptr");
>>  CheckFactories.registerCheck("modernize-u
>> se-override");
>>  CheckFactories.registerCheck(
>>
>> Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/modernize/UseNoexceptCheck.cpp?rev=304977&view=auto
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> (added)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> Thu Jun  8 09:04:16 2017
>> @@ -0,0 +1,114 @@
>> +//===--- UseNoexceptCheck.cpp - clang-tid

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

For all the `transform_` variants, the spec allows the "inner" operation (the 
transformation)'s return type is not constrained. We should have a test for 
this.

For example, consider the binary-unary `transform_reduce` implementation:

  template 
  inline _LIBCPP_INLINE_VISIBILITY
  _Tp
  transform_reduce(_InputIterator __first, _InputIterator __last, 
   _Tp __init,  _BinaryOp __b, _UnaryOp __u)
  {
  for (; __first != __last; ++__first)
  __init = __b(__init, __u(*__first));
  return __init;
  }

The standard says the algorithm requires all of the following expressions be 
convertible to `_Tp`:

- `__b(__init, __init)`
- `__b(__init, __u(*__first))`
- `__b(__u(*__first), __init)`
- `__b(__u(*__first), __u(*__first))`

So, the following code should be allowed:

  struct A {};
  struct B {};
  struct C {};
  
  B unary_op(C);
  A binary_op(A, A);
  A binary_op(A, B);
  A binary_op(B, A);
  A binary_op(B, B); 
  
  std::vector v;
  std::tranform_reduce(v.begin(), v.end(), A{}, binary_op, unary_op);

Similar cases can be constructed for all the other `transform_` overloads.

I'll try to find time later to put together a concrete test for this.


https://reviews.llvm.org/D33997



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


Re: [PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-08 Thread Kamil Rytarowski via cfe-commits
On 08.06.2017 22:39, Rui Ueyama wrote:
> On Wed, Jun 7, 2017 at 6:55 AM, Joerg Sonnenberger via Phabricator
> mailto:revi...@reviews.llvm.org>> wrote:
> 
> joerg added a comment.
> 
> In https://reviews.llvm.org/D33726#774105
> , @ruiu wrote:
> 
> > I'm totally against adding per-OS path knowledge to our linker. 
> Compilers already know include paths and I don't want to maintain another 
> list of paths in the linker. Also this can be more confusing than useful when 
> you are doing cross-linking.
> 
> 
> The only reason for compilers to maintain that list is for finding
> crt*.o. They otherwise don't care about the library paths at all.
> There is no confusion for cross-linking as long as proper sysroot
> support is used. Which we have been doing on NetBSD for ages.
> 
> 
> That's not what clang is trying to do for all Unix-like systems (except
> NetBSD due to the bug), right? The compiler driver actually passes
> library paths to the linker. If you think that is wrong, you should make
> a change to stop doing that on all systems. I don't see a reason to not
> do this only on NetBSD.
> 

I'm convinced that Joerg is right, that there is need some knowledge on
the LLD side. I'm more relaxed about -L paths as long as they work for
regular use-cases, but DT_RPATH vs DT_RUNPATH behaves differently on
Linux and NetBSD.

> > For all OSes other than NetBSD, LLD works fine with the clang driver as 
> the driver passes include paths to the linker. I don't see any reason not to 
> do the same thing for NetBSD. That stands even if the linker has to have a 
> list of include paths.
> 
> Sorry, but this is again ignorant and wrong. The very same problem
> of build systems calling ld directly apply on most other systems.
> Even then, the list of linker paths is not the only OS-specific
> knowledge. Things like the DT_RPATH vs DT_RUNPATH mess, init vs
> init_array all belong into this category. The list goes on.
> 
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D33726 
> 
> 
> 
> 




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


r305022 - [ASTMatchers] Add clang-query support for equals matcher

2017-06-08 Thread Peter Wu via cfe-commits
Author: lekensteyn
Date: Thu Jun  8 17:00:58 2017
New Revision: 305022

URL: http://llvm.org/viewvc/llvm-project?rev=305022&view=rev
Log:
[ASTMatchers] Add clang-query support for equals matcher

Summary:
This allows the clang-query tool to use matchers like
"integerLiteral(equals(32))". For this to work, an overloaded function
is added for each possible parameter type.

Reviewed By: aaron.ballman

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=305022&r1=305021&r2=305022&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Jun  8 17:00:58 2017
@@ -1859,17 +1859,36 @@ Example matches a || b (matcher = binary
 
 
 
-MatcherequalsValueT  
Value
-Matches literals that are 
equal to the given value.
+MatcherCXXBoolLiteralExpr>equalsValueT  Value
+Matches literals that are 
equal to the given value of type ValueT.
 
-Example matches true (matcher = cxxBoolLiteral(equals(true)))
-  true
+Given
+  f('false, 3.14, 42);
+characterLiteral(equals(0))
+  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
+  match false
+floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
+  match 3.14
+integerLiteral(equals(42))
+  matches 42
 
-Usable as: MatcherCharacterLiteral>,
 Matcher,
+Usable as: MatcherCharacterLiteral>,
 MatcherCXXBoolLiteralExpr>,
MatcherFloatingLiteral>,
 MatcherIntegerLiteral>
 
 
 
+MatcherCXXBoolLiteralExpr>equalsbool Value
+
+
+
+MatcherCXXBoolLiteralExpr>equalsdouble Value
+
+
+
+MatcherCXXBoolLiteralExpr>equalsunsigned Value
+
+
+
 MatcherCXXCatchStmt>isCatchAll
 Matches a C++ catch 
statement that has a catch-all handler.
 
@@ -2296,16 +2315,35 @@ Example: matches the implicit cast aroun
 
 
 MatcherCharacterLiteral>equalsValueT  Value
-Matches literals that are 
equal to the given value.
+Matches literals that are 
equal to the given value of type ValueT.
 
-Example matches true (matcher = cxxBoolLiteral(equals(true)))
-  true
+Given
+  f('false, 3.14, 42);
+characterLiteral(equals(0))
+  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
+  match false
+floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
+  match 3.14
+integerLiteral(equals(42))
+  matches 42
 
-Usable as: MatcherCharacterLiteral>,
 Matcher,
+Usable as: MatcherCharacterLiteral>,
 MatcherCXXBoolLiteralExpr>,
MatcherFloatingLiteral>,
 MatcherIntegerLiteral>
 
 
 
+MatcherCharacterLiteral>equalsbool Value
+
+
+
+MatcherCharacterLiteral>equalsdouble Value
+
+
+
+MatcherCharacterLiteral>equalsunsigned Value
+
+
+
 MatcherClassTemplateSpecializationDecl>templateArgumentCountIsunsigned
 N
 Matches if 
the number of template arguments equals N.
 
@@ -2533,16 +2571,27 @@ fieldDecl(isBitField())
 
 
 MatcherFloatingLiteral>equalsValueT  Value
-Matches literals that are 
equal to the given value.
+Matches literals that are 
equal to the given value of type ValueT.
 
-Example matches true (matcher = cxxBoolLiteral(equals(true)))
-  true
+Given
+  f('false, 3.14, 42);
+cha

r305021 - [ASTMatchers] Add support for floatLiterals

2017-06-08 Thread Peter Wu via cfe-commits
Author: lekensteyn
Date: Thu Jun  8 17:00:50 2017
New Revision: 305021

URL: http://llvm.org/viewvc/llvm-project?rev=305021&view=rev
Log:
[ASTMatchers] Add support for floatLiterals

Summary:
Needed to support something like "floatLiteral(equals(1.0))". The
parser for floating point numbers is kept simple, so instead of ".1" you
have to use "0.1".

Reviewed By: aaron.ballman

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

Modified:
cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h?rev=305021&r1=305020&r2=305021&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h Thu Jun  8 
17:00:50 2017
@@ -76,7 +76,7 @@ public:
 ET_ParserInvalidToken = 106,
 ET_ParserMalformedBindExpr = 107,
 ET_ParserTrailingCode = 108,
-ET_ParserUnsignedError = 109,
+ET_ParserNumberError = 109,
 ET_ParserOverloadedType = 110
   };
 

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=305021&r1=305020&r2=305021&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Jun  8 17:00:50 
2017
@@ -19,9 +19,10 @@
 /// \code
 /// Grammar for the expressions supported:
 /// :=  |  | 
-///:=  |  | 
+///:=  |  |  | 
 ///  := "quoted string"
 ///:= true | false
+/// := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+
 ///   := [0-9]+
 /// := 
 ///  := () |

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=305021&r1=305020&r2=305021&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Thu Jun  8 
17:00:50 2017
@@ -36,6 +36,7 @@ class ArgKind {
   enum Kind {
 AK_Matcher,
 AK_Boolean,
+AK_Double,
 AK_Unsigned,
 AK_String
   };
@@ -243,6 +244,7 @@ struct VariantMatcher::TypedMatcherOps f
 ///
 /// Supported types:
 ///  - \c bool
+//   - \c double
 ///  - \c unsigned
 ///  - \c llvm::StringRef
 ///  - \c VariantMatcher (\c DynTypedMatcher / \c Matcher)
@@ -256,6 +258,7 @@ public:
 
   /// \brief Specific constructors for each supported type.
   VariantValue(bool Boolean);
+  VariantValue(double Double);
   VariantValue(unsigned Unsigned);
   VariantValue(StringRef String);
   VariantValue(const VariantMatcher &Matchers);
@@ -272,6 +275,11 @@ public:
   bool getBoolean() const;
   void setBoolean(bool Boolean);
 
+  /// \brief Double value functions.
+  bool isDouble() const;
+  double getDouble() const;
+  void setDouble(double Double);
+
   /// \brief Unsigned value functions.
   bool isUnsigned() const;
   unsigned getUnsigned() const;
@@ -315,6 +323,7 @@ private:
   enum ValueType {
 VT_Nothing,
 VT_Boolean,
+VT_Double,
 VT_Unsigned,
 VT_String,
 VT_Matcher
@@ -323,6 +332,7 @@ private:
   /// \brief All supported value types.
   union AllValues {
 unsigned Unsigned;
+double Double;
 bool Boolean;
 std::string *String;
 VariantMatcher *Matcher;

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp?rev=305021&r1=305020&r2=305021&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp Thu Jun  8 17:00:50 2017
@@ -118,8 +118,8 @@ static StringRef errorTypeToFormatString
 return "Malformed bind() expression.";
   case Diagnostics::ET_ParserTrailingCode:
 return "Expected end of code.";
-  case Diagnostics::ET_ParserUnsignedError:
-return "Error parsing unsigned token: <$0>";
+  case Diagnostics::ET_ParserNumberError:
+return "Error parsing numeric literal: <$0>";
   case Dia

r305020 - [ASTMatchers] Add support for boolean literals

2017-06-08 Thread Peter Wu via cfe-commits
Author: lekensteyn
Date: Thu Jun  8 17:00:38 2017
New Revision: 305020

URL: http://llvm.org/viewvc/llvm-project?rev=305020&view=rev
Log:
[ASTMatchers] Add support for boolean literals

Summary:
Recognize boolean literals for future extensions ("equals(true)").
Note that a specific VariantValue constructor is added to resolve
ambiguity (like "Value = 5") between unsigned and bool.

Reviewed By: aaron.ballman

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

Modified:
cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h?rev=305020&r1=305019&r2=305020&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h Thu Jun  8 17:00:38 
2017
@@ -19,8 +19,9 @@
 /// \code
 /// Grammar for the expressions supported:
 /// :=  |  | 
-///:=  | 
+///:=  |  | 
 ///  := "quoted string"
+///:= true | false
 ///   := [0-9]+
 /// := 
 ///  := () |

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=305020&r1=305019&r2=305020&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Thu Jun  8 
17:00:38 2017
@@ -35,6 +35,7 @@ class ArgKind {
  public:
   enum Kind {
 AK_Matcher,
+AK_Boolean,
 AK_Unsigned,
 AK_String
   };
@@ -241,6 +242,7 @@ struct VariantMatcher::TypedMatcherOps f
 /// copy/assignment.
 ///
 /// Supported types:
+///  - \c bool
 ///  - \c unsigned
 ///  - \c llvm::StringRef
 ///  - \c VariantMatcher (\c DynTypedMatcher / \c Matcher)
@@ -253,14 +255,23 @@ public:
   VariantValue &operator=(const VariantValue &Other);
 
   /// \brief Specific constructors for each supported type.
+  VariantValue(bool Boolean);
   VariantValue(unsigned Unsigned);
   VariantValue(StringRef String);
   VariantValue(const VariantMatcher &Matchers);
 
+  /// \brief Constructs an \c unsigned value (disambiguation from bool).
+  VariantValue(int Signed) : VariantValue(static_cast(Signed)) {}
+
   /// \brief Returns true iff this is not an empty value.
   explicit operator bool() const { return hasValue(); }
   bool hasValue() const { return Type != VT_Nothing; }
 
+  /// \brief Boolean value functions.
+  bool isBoolean() const;
+  bool getBoolean() const;
+  void setBoolean(bool Boolean);
+
   /// \brief Unsigned value functions.
   bool isUnsigned() const;
   unsigned getUnsigned() const;
@@ -303,6 +314,7 @@ private:
   /// \brief All supported value types.
   enum ValueType {
 VT_Nothing,
+VT_Boolean,
 VT_Unsigned,
 VT_String,
 VT_Matcher
@@ -311,6 +323,7 @@ private:
   /// \brief All supported value types.
   union AllValues {
 unsigned Unsigned;
+bool Boolean;
 std::string *String;
 VariantMatcher *Matcher;
   };

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h?rev=305020&r1=305019&r2=305020&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h Thu Jun  8 17:00:38 2017
@@ -65,6 +65,16 @@ template  struct ArgTypeTraits<
   }
 };
 
+template <> struct ArgTypeTraits {
+  static bool is(const VariantValue &Value) { return Value.isBoolean(); }
+  static bool get(const VariantValue &Value) {
+return Value.getBoolean();
+  }
+  static ArgKind getKind() {
+return ArgKind(ArgKind::AK_Boolean);
+  }
+};
+
 template <> struct ArgTypeTraits {
   static bool is(const VariantValue &Value) { return Value.isUnsigned(); }
   static unsigned get(const VariantValue &Value) {

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=305020&r1=305019&r2=305020&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Thu Jun  8 17:00:38 2017
@@ -153,8 +153,16 @@ private:
 break;
   ++TokenLength;
   

[PATCH] D33094: [ASTMatchers] Add clang-query support for equals matcher

2017-06-08 Thread Peter Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305022: [ASTMatchers] Add clang-query support for equals 
matcher (authored by Lekensteyn).

Changed prior to commit:
  https://reviews.llvm.org/D33094?vs=101817&id=101967#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33094

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

Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -56,20 +56,24 @@
   registerMatcher(#name, internal::makeMatcherAutoMarshall(\
  ::clang::ast_matchers::name, #name));
 
+#define REGISTER_MATCHER_OVERLOAD(name)\
+  registerMatcher(#name,   \
+  llvm::make_unique(name##Callbacks))
+
 #define SPECIFIC_MATCHER_OVERLOAD(name, Id)\
   static_cast<::clang::ast_matchers::name##_Type##Id>( \
   ::clang::ast_matchers::name)
 
+#define MATCHER_OVERLOAD_ENTRY(name, Id)   \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, Id), \
+  #name)
+
 #define REGISTER_OVERLOADED_2(name)\
   do { \
-std::unique_ptr Callbacks[] = { \
-internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),  \
-  #name),  \
-internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1),  \
-  #name)}; \
-registerMatcher(   \
-#name, \
-llvm::make_unique(Callbacks));  \
+std::unique_ptr name##Callbacks[] = {   \
+MATCHER_OVERLOAD_ENTRY(name, 0),   \
+MATCHER_OVERLOAD_ENTRY(name, 1)};  \
+REGISTER_MATCHER_OVERLOAD(name);   \
   } while (0)
 
 /// \brief Generate a registry map with all the known matchers.
@@ -83,7 +87,6 @@
   // findAll
   //
   // Other:
-  // equals
   // equalsNode
 
   REGISTER_OVERLOADED_2(callee);
@@ -96,6 +99,13 @@
   REGISTER_OVERLOADED_2(references);
   REGISTER_OVERLOADED_2(thisPointerType);
 
+  std::unique_ptr equalsCallbacks[] = {
+  MATCHER_OVERLOAD_ENTRY(equals, 0),
+  MATCHER_OVERLOAD_ENTRY(equals, 1),
+  MATCHER_OVERLOAD_ENTRY(equals, 2),
+  };
+  REGISTER_MATCHER_OVERLOAD(equals);
+
   REGISTER_MATCHER(accessSpecDecl);
   REGISTER_MATCHER(addrLabelExpr);
   REGISTER_MATCHER(alignOfExpr);
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -511,6 +511,46 @@
   EXPECT_FALSE(matches("int i = 1;", Value));
 }
 
+TEST_F(RegistryTest, EqualsMatcher) {
+  Matcher BooleanStmt = constructMatcher(
+  "cxxBoolLiteral", constructMatcher("equals", VariantValue(true)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("bool x = true;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = false;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = 0;", BooleanStmt));
+
+  BooleanStmt = constructMatcher(
+  "cxxBoolLiteral", constructMatcher("equals", VariantValue(0)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("bool x = false;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = true;", BooleanStmt));
+  EXPECT_FALSE(matches("bool x = 0;", BooleanStmt));
+
+  Matcher DoubleStmt = constructMatcher(
+  "floatLiteral", constructMatcher("equals", VariantValue(1.2)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("double x = 1.2;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 1.2f;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 1.2l;", DoubleStmt));
+  EXPECT_TRUE(matches("double x = 12e-1;", DoubleStmt));
+  EXPECT_FALSE(matches("double x = 1.23;", DoubleStmt));
+
+  Matcher IntegerStmt = constructMatcher(
+  "integerLiteral", constructMatcher("equals", VariantValue(42)))
+  .getTypedMatcher();
+  EXPECT_TRUE(matches("int x = 42;", IntegerStmt));
+  EXPECT_FALSE(matches("int x = 1;", IntegerStmt));
+
+  Matcher CharStmt = constructMatcher(
+  "characterLiteral", constructMatcher("eq

[PATCH] D33093: [ASTMatchers] Add support for boolean literals

2017-06-08 Thread Peter Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305020: [ASTMatchers] Add support for boolean literals 
(authored by Lekensteyn).

Changed prior to commit:
  https://reviews.llvm.org/D33093?vs=98781&id=101966#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33093

Files:
  cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
  cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -75,6 +75,15 @@
   ExpectedMatchersTy ExpectedMatchers;
 };
 
+TEST(ParserTest, ParseBoolean) {
+  MockSema Sema;
+  Sema.parse("true");
+  Sema.parse("false");
+  EXPECT_EQ(2U, Sema.Values.size());
+  EXPECT_EQ(true, Sema.Values[0].getBoolean());
+  EXPECT_EQ(false, Sema.Values[1].getBoolean());
+}
+
 TEST(ParserTest, ParseUnsigned) {
   MockSema Sema;
   Sema.parse("0");
Index: cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -75,28 +75,40 @@
   EXPECT_TRUE(Value.isString());
   EXPECT_EQ("A", Value.getString());
   EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_EQ("String", Value.getTypeAsString());
 
   Value = VariantMatcher::SingleMatcher(recordDecl());
   EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_TRUE(Value.isMatcher());
   EXPECT_TRUE(Value.getMatcher().hasTypedMatcher());
   EXPECT_FALSE(Value.getMatcher().hasTypedMatcher());
   EXPECT_EQ("Matcher", Value.getTypeAsString());
 
+  Value = true;
+  EXPECT_TRUE(Value.isBoolean());
+  EXPECT_EQ(true, Value.getBoolean());
+  EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isUnsigned());
+  EXPECT_FALSE(Value.isMatcher());
+  EXPECT_FALSE(Value.isString());
+
   Value = 17;
   EXPECT_TRUE(Value.isUnsigned());
   EXPECT_EQ(17U, Value.getUnsigned());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
   Value = VariantValue();
   EXPECT_FALSE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_FALSE(Value.isMatcher());
Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -19,8 +19,9 @@
 /// \code
 /// Grammar for the expressions supported:
 /// :=  |  | 
-///:=  | 
+///:=  |  | 
 ///  := "quoted string"
+///:= true | false
 ///   := [0-9]+
 /// := 
 ///  := () |
Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -35,6 +35,7 @@
  public:
   enum Kind {
 AK_Matcher,
+AK_Boolean,
 AK_Unsigned,
 AK_String
   };
@@ -241,6 +242,7 @@
 /// copy/assignment.
 ///
 /// Supported types:
+///  - \c bool
 ///  - \c unsigned
 ///  - \c llvm::StringRef
 ///  - \c VariantMatcher (\c DynTypedMatcher / \c Matcher)
@@ -253,14 +255,23 @@
   VariantValue &operator=(const VariantValue &Other);
 
   /// \brief Specific constructors for each supported type.
+  VariantValue(bool Boolean);
   VariantValue(unsigned Unsigned);
   VariantValue(StringRef String);
   VariantValue(const VariantMatcher &Matchers);
 
+  /// \brief Constructs an \c unsigned value (disambiguation from bool).
+  VariantValue(int Signed) : VariantValue(static_cast(Signed)) {}
+
   /// \brief Returns true iff this is not an empty value.
   explicit operator bool() const { return hasValue(); }
   bool hasValue() const { return Type != VT_Nothing; }
 
+  /// \brief Boolean value functions.
+  bool isBoolean() const;
+  bool getBoolean() const;
+  void setBoolean(bool Boolean);
+
   /// \brief Unsigned value functions.
   bool isUnsigned() const;
   unsigned getUnsigned() const;
@@ -303,14 +314,16 @@
   /// \brief All supported value types.
   enum ValueType {
 VT_Nothing,
+VT_Boolean,
 VT_Uns

[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

2017-06-08 Thread Peter Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305021: [ASTMatchers] Add support for floatLiterals 
(authored by Lekensteyn).

Changed prior to commit:
  https://reviews.llvm.org/D33135?vs=101816&id=101968#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33135

Files:
  cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
  cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
  cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Diagnostics.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -36,6 +36,7 @@
   enum Kind {
 AK_Matcher,
 AK_Boolean,
+AK_Double,
 AK_Unsigned,
 AK_String
   };
@@ -243,6 +244,7 @@
 ///
 /// Supported types:
 ///  - \c bool
+//   - \c double
 ///  - \c unsigned
 ///  - \c llvm::StringRef
 ///  - \c VariantMatcher (\c DynTypedMatcher / \c Matcher)
@@ -256,6 +258,7 @@
 
   /// \brief Specific constructors for each supported type.
   VariantValue(bool Boolean);
+  VariantValue(double Double);
   VariantValue(unsigned Unsigned);
   VariantValue(StringRef String);
   VariantValue(const VariantMatcher &Matchers);
@@ -272,6 +275,11 @@
   bool getBoolean() const;
   void setBoolean(bool Boolean);
 
+  /// \brief Double value functions.
+  bool isDouble() const;
+  double getDouble() const;
+  void setDouble(double Double);
+
   /// \brief Unsigned value functions.
   bool isUnsigned() const;
   unsigned getUnsigned() const;
@@ -315,14 +323,16 @@
   enum ValueType {
 VT_Nothing,
 VT_Boolean,
+VT_Double,
 VT_Unsigned,
 VT_String,
 VT_Matcher
   };
 
   /// \brief All supported value types.
   union AllValues {
 unsigned Unsigned;
+double Double;
 bool Boolean;
 std::string *String;
 VariantMatcher *Matcher;
Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -19,9 +19,10 @@
 /// \code
 /// Grammar for the expressions supported:
 /// :=  |  | 
-///:=  |  | 
+///:=  |  |  | 
 ///  := "quoted string"
 ///:= true | false
+/// := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+
 ///   := [0-9]+
 /// := 
 ///  := () |
Index: cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
===
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/Diagnostics.h
@@ -76,7 +76,7 @@
 ET_ParserInvalidToken = 106,
 ET_ParserMalformedBindExpr = 107,
 ET_ParserTrailingCode = 108,
-ET_ParserUnsignedError = 109,
+ET_ParserNumberError = 109,
 ET_ParserOverloadedType = 110
   };
 
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -75,6 +75,16 @@
   }
 };
 
+template <> struct ArgTypeTraits {
+  static bool is(const VariantValue &Value) { return Value.isDouble(); }
+  static double get(const VariantValue &Value) {
+return Value.getDouble();
+  }
+  static ArgKind getKind() {
+return ArgKind(ArgKind::AK_Double);
+  }
+};
+
 template <> struct ArgTypeTraits {
   static bool is(const VariantValue &Value) { return Value.isUnsigned(); }
   static unsigned get(const VariantValue &Value) {
Index: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -26,6 +26,8 @@
 return (Twine("Matcher<") + MatcherKind.asStringRef() + ">").str();
   case AK_Boolean:
 return "boolean";
+  case AK_Double:
+return "double";
   case AK_Unsigned:
 return "unsigned";
   case AK_String:
@@ -253,6 +255,10 @@
   setBoolean(Boolean);
 }
 
+VariantValue::VariantValue(double Double) : Type(VT_Nothing) {
+  setDouble(Double);
+}
+
 VariantValue::VariantValue(unsigned Unsigned) : Type(VT_Nothing) {
   setUnsigned(Unsigned);
 }
@@ -274,6 +280,9 @@
   case VT_Boolean:
 setBoolean(Other.getBoolean());
 break;
+  case VT_Double:
+setDouble(Other.getDouble());
+break;
   case VT_Unsigned:
 setUnsigned(Other.getUnsigned());
  

[PATCH] D33976: [clang] Fix format specifiers fixits

2017-06-08 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305018: [clang] Fix format specifiers fixits (authored by 
alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D33976?vs=101962&id=101964#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33976

Files:
  cfe/trunk/include/clang/Edit/EditedSource.h
  cfe/trunk/lib/Edit/EditedSource.cpp
  cfe/trunk/test/FixIt/fixit-format-darwin.m

Index: cfe/trunk/test/FixIt/fixit-format-darwin.m
===
--- cfe/trunk/test/FixIt/fixit-format-darwin.m
+++ cfe/trunk/test/FixIt/fixit-format-darwin.m
@@ -0,0 +1,59 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat -fixit %t
+// RUN: grep -v CHECK %t | FileCheck %s
+
+/* This is a test of code modifications created by darwin format fix-its hints 
+   that are provided as part of warning */
+
+int printf(const char * restrict, ...);
+
+#if __LP64__
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+#else
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#endif
+NSInteger getNSInteger();
+NSUInteger getNSUInteger();
+
+#define Log1(...) \
+do { \
+  printf(__VA_ARGS__); \
+} while (0)
+
+#define Log2(...) \
+do { \
+  printf(__VA_ARGS__); \
+  printf(__VA_ARGS__); \
+} while (0) \
+
+#define Log3(X, Y, Z) \
+do { \
+  printf(X, Y); \
+  printf(X, Z); \
+} while (0) \
+
+void test() {
+  printf("test 1: %s", getNSInteger()); 
+  // CHECK: printf("test 1: %ld", (long)getNSInteger());
+  printf("test 2: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: printf("test 2: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  Log1("test 3: %s", getNSInteger());
+  // CHECK: Log1("test 3: %ld", (long)getNSInteger());
+  Log1("test 4: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: Log1("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  Log2("test 5: %s", getNSInteger());
+  // CHECK: Log2("test 5: %ld", (long)getNSInteger()); 
+  Log2("test 6: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: Log2("test 6: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  // Artificial test to check that X (in Log3(X, Y, Z))
+  // is modified only according to the diagnostics
+  // for the first printf and the modification caused 
+  // by the second printf is dropped.
+  Log3("test 7: %s", getNSInteger(), getNSUInteger());
+  // CHECK: Log3("test 7: %ld", (long)getNSInteger(), (unsigned long)getNSUInteger());
+}
Index: cfe/trunk/lib/Edit/EditedSource.cpp
===
--- cfe/trunk/lib/Edit/EditedSource.cpp
+++ cfe/trunk/lib/Edit/EditedSource.cpp
@@ -25,30 +25,28 @@
 
 void EditedSource::deconstructMacroArgLoc(SourceLocation Loc,
   SourceLocation &ExpansionLoc,
-  IdentifierInfo *&II) {
+  MacroArgUse &ArgUse) {
   assert(SourceMgr.isMacroArgExpansion(Loc));
   SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first;
   ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
   SmallString<20> Buf;
   StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc),
  Buf, SourceMgr, LangOpts);
-  II = nullptr;
-  if (!ArgName.empty()) {
-II = &IdentTable.get(ArgName);
-  }
+  ArgUse = {nullptr, SourceLocation()};
+  if (!ArgName.empty())
+ArgUse = {&IdentTable.get(ArgName), SourceMgr.getSpellingLoc(DefArgLoc)};
 }
 
 void EditedSource::startingCommit() {}
 
 void EditedSource::finishedCommit() {
   for (auto &ExpArg : CurrCommitMacroArgExps) {
 SourceLocation ExpLoc;
-IdentifierInfo *II;
-std::tie(ExpLoc, II) = ExpArg;
-auto &ArgNames = ExpansionToArgMap[ExpLoc.getRawEncoding()];
-if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) {
-  ArgNames.push_back(II);
-}
+MacroArgUse ArgUse;
+std::tie(ExpLoc, ArgUse) = ExpArg;
+auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+if (std::find(ArgUses.begin(), ArgUses.end(), ArgUse) == ArgUses.end())
+  ArgUses.push_back(ArgUse);
   }
   CurrCommitMacroArgExps.clear();
 }
@@ -66,12 +64,15 @@
   }
 
   if (SourceMgr.isMacroArgExpansion(OrigLoc)) {
-IdentifierInfo *II;
 SourceLocation ExpLoc;
-deconstructMacroArgLoc(OrigLoc, ExpLoc, II);
+MacroArgUse ArgUse;
+deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
 auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
 if (I != ExpansionToArgMap.end() &&
-std::find(I->second.begin(), I->second.end(), II) != I->second.end()) {
+std::find_if(
+I->second.begin(), I->second.end(), [&](const MacroArgUse &U) {
+  return ArgUse.first == U.first && ArgUse.second != U.second;
+}) != I->second.end()) {
   // Trying to writ

r305018 - [clang] Fix format specifiers fixits

2017-06-08 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Thu Jun  8 16:44:45 2017
New Revision: 305018

URL: http://llvm.org/viewvc/llvm-project?rev=305018&view=rev
Log:
[clang] Fix format specifiers fixits

This diff fixes printf "fixits" in the case when there is 
a wrapping macro and the format string needs multiple replacements. 
In the presence of a macro there is an extra logic in EditedSource.cpp
to handle multiple uses of the same macro argument 
(see the old comment inside EditedSource::canInsertInOffset)
which was mistriggerred when the argument was used only once 
but required multiple adjustments), as a result the "fixit" 
was breaking down the format string
by dropping the second format specifier, i.e. 
Log1("test 4: %s %s", getNSInteger(), getNSInteger()) 
was getting replaced with 
Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) 
(if one removed the macro and used printf directly it would work fine).
In this diff we track the location where the macro argument is used and 
(as it was before) the modifications originating from all the locations 
except the first one are rejected, but multiple changes are allowed.

Test plan: make check-all

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

Added:
cfe/trunk/test/FixIt/fixit-format-darwin.m
Modified:
cfe/trunk/include/clang/Edit/EditedSource.h
cfe/trunk/lib/Edit/EditedSource.cpp

Modified: cfe/trunk/include/clang/Edit/EditedSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=305018&r1=305017&r2=305018&view=diff
==
--- cfe/trunk/include/clang/Edit/EditedSource.h (original)
+++ cfe/trunk/include/clang/Edit/EditedSource.h Thu Jun  8 16:44:45 2017
@@ -41,9 +41,11 @@ class EditedSource {
   typedef std::map FileEditsTy;
   FileEditsTy FileEdits;
 
-  llvm::DenseMap>
+  // Location of argument use inside the macro body 
+  typedef std::pair MacroArgUse;
+  llvm::DenseMap>
 ExpansionToArgMap;
-  SmallVector, 2>
+  SmallVector, 2>
 CurrCommitMacroArgExps;
 
   IdentifierTable IdentTable;
@@ -84,7 +86,7 @@ private:
   FileEditsTy::iterator getActionForOffset(FileOffset Offs);
   void deconstructMacroArgLoc(SourceLocation Loc,
   SourceLocation &ExpansionLoc,
-  IdentifierInfo *&II);
+  MacroArgUse &ArgUse);
 
   void startingCommit();
   void finishedCommit();

Modified: cfe/trunk/lib/Edit/EditedSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/EditedSource.cpp?rev=305018&r1=305017&r2=305018&view=diff
==
--- cfe/trunk/lib/Edit/EditedSource.cpp (original)
+++ cfe/trunk/lib/Edit/EditedSource.cpp Thu Jun  8 16:44:45 2017
@@ -25,17 +25,16 @@ void EditsReceiver::remove(CharSourceRan
 
 void EditedSource::deconstructMacroArgLoc(SourceLocation Loc,
   SourceLocation &ExpansionLoc,
-  IdentifierInfo *&II) {
+  MacroArgUse &ArgUse) {
   assert(SourceMgr.isMacroArgExpansion(Loc));
   SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first;
   ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
   SmallString<20> Buf;
   StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc),
  Buf, SourceMgr, LangOpts);
-  II = nullptr;
-  if (!ArgName.empty()) {
-II = &IdentTable.get(ArgName);
-  }
+  ArgUse = {nullptr, SourceLocation()};
+  if (!ArgName.empty())
+ArgUse = {&IdentTable.get(ArgName), SourceMgr.getSpellingLoc(DefArgLoc)};
 }
 
 void EditedSource::startingCommit() {}
@@ -43,12 +42,11 @@ void EditedSource::startingCommit() {}
 void EditedSource::finishedCommit() {
   for (auto &ExpArg : CurrCommitMacroArgExps) {
 SourceLocation ExpLoc;
-IdentifierInfo *II;
-std::tie(ExpLoc, II) = ExpArg;
-auto &ArgNames = ExpansionToArgMap[ExpLoc.getRawEncoding()];
-if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) {
-  ArgNames.push_back(II);
-}
+MacroArgUse ArgUse;
+std::tie(ExpLoc, ArgUse) = ExpArg;
+auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+if (std::find(ArgUses.begin(), ArgUses.end(), ArgUse) == ArgUses.end())
+  ArgUses.push_back(ArgUse);
   }
   CurrCommitMacroArgExps.clear();
 }
@@ -66,12 +64,15 @@ bool EditedSource::canInsertInOffset(Sou
   }
 
   if (SourceMgr.isMacroArgExpansion(OrigLoc)) {
-IdentifierInfo *II;
 SourceLocation ExpLoc;
-deconstructMacroArgLoc(OrigLoc, ExpLoc, II);
+MacroArgUse ArgUse;
+deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
 auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
 if (I != ExpansionToArgMap.end() &&
-std::find(I->second.begin(), I->second.end(), II) != I->second.end()) {
+  

[PATCH] D33976: [clang] Fix format specifiers fixits

2017-06-08 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 101962.
alexshap added a comment.

Address comments


Repository:
  rL LLVM

https://reviews.llvm.org/D33976

Files:
  include/clang/Edit/EditedSource.h
  lib/Edit/EditedSource.cpp
  test/FixIt/fixit-format-darwin.m

Index: test/FixIt/fixit-format-darwin.m
===
--- test/FixIt/fixit-format-darwin.m
+++ test/FixIt/fixit-format-darwin.m
@@ -0,0 +1,59 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat -fixit %t
+// RUN: grep -v CHECK %t | FileCheck %s
+
+/* This is a test of code modifications created by darwin format fix-its hints 
+   that are provided as part of warning */
+
+int printf(const char * restrict, ...);
+
+#if __LP64__
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+#else
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#endif
+NSInteger getNSInteger();
+NSUInteger getNSUInteger();
+
+#define Log1(...) \
+do { \
+  printf(__VA_ARGS__); \
+} while (0)
+
+#define Log2(...) \
+do { \
+  printf(__VA_ARGS__); \
+  printf(__VA_ARGS__); \
+} while (0) \
+
+#define Log3(X, Y, Z) \
+do { \
+  printf(X, Y); \
+  printf(X, Z); \
+} while (0) \
+
+void test() {
+  printf("test 1: %s", getNSInteger()); 
+  // CHECK: printf("test 1: %ld", (long)getNSInteger());
+  printf("test 2: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: printf("test 2: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  Log1("test 3: %s", getNSInteger());
+  // CHECK: Log1("test 3: %ld", (long)getNSInteger());
+  Log1("test 4: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: Log1("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  Log2("test 5: %s", getNSInteger());
+  // CHECK: Log2("test 5: %ld", (long)getNSInteger()); 
+  Log2("test 6: %s %s", getNSInteger(), getNSInteger());
+  // CHECK: Log2("test 6: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+  
+  // Artificial test to check that X (in Log3(X, Y, Z))
+  // is modified only according to the diagnostics
+  // for the first printf and the modification caused 
+  // by the second printf is dropped.
+  Log3("test 7: %s", getNSInteger(), getNSUInteger());
+  // CHECK: Log3("test 7: %ld", (long)getNSInteger(), (unsigned long)getNSUInteger());
+}
Index: lib/Edit/EditedSource.cpp
===
--- lib/Edit/EditedSource.cpp
+++ lib/Edit/EditedSource.cpp
@@ -25,30 +25,28 @@
 
 void EditedSource::deconstructMacroArgLoc(SourceLocation Loc,
   SourceLocation &ExpansionLoc,
-  IdentifierInfo *&II) {
+  MacroArgUse &ArgUse) {
   assert(SourceMgr.isMacroArgExpansion(Loc));
   SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first;
   ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
   SmallString<20> Buf;
   StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc),
  Buf, SourceMgr, LangOpts);
-  II = nullptr;
-  if (!ArgName.empty()) {
-II = &IdentTable.get(ArgName);
-  }
+  ArgUse = {nullptr, SourceLocation()};
+  if (!ArgName.empty())
+ArgUse = {&IdentTable.get(ArgName), SourceMgr.getSpellingLoc(DefArgLoc)};
 }
 
 void EditedSource::startingCommit() {}
 
 void EditedSource::finishedCommit() {
   for (auto &ExpArg : CurrCommitMacroArgExps) {
 SourceLocation ExpLoc;
-IdentifierInfo *II;
-std::tie(ExpLoc, II) = ExpArg;
-auto &ArgNames = ExpansionToArgMap[ExpLoc.getRawEncoding()];
-if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) {
-  ArgNames.push_back(II);
-}
+MacroArgUse ArgUse;
+std::tie(ExpLoc, ArgUse) = ExpArg;
+auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+if (std::find(ArgUses.begin(), ArgUses.end(), ArgUse) == ArgUses.end())
+  ArgUses.push_back(ArgUse);
   }
   CurrCommitMacroArgExps.clear();
 }
@@ -66,12 +64,15 @@
   }
 
   if (SourceMgr.isMacroArgExpansion(OrigLoc)) {
-IdentifierInfo *II;
 SourceLocation ExpLoc;
-deconstructMacroArgLoc(OrigLoc, ExpLoc, II);
+MacroArgUse ArgUse;
+deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
 auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
 if (I != ExpansionToArgMap.end() &&
-std::find(I->second.begin(), I->second.end(), II) != I->second.end()) {
+std::find_if(
+I->second.begin(), I->second.end(), [&](const MacroArgUse &U) {
+  return ArgUse.first == U.first && ArgUse.second != U.second;
+}) != I->second.end()) {
   // Trying to write in a macro argument input that has already been
   // written by a previous commit for another expansion of the same macro
   // argument name. For example:
@@ -101,11 +102,11 @@
 return true;
 
   if (SourceMgr.isMacroArgExpansion

Re: [clang-tools-extra] r304977 - [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread Galina Kistanova via cfe-commits
Hello Alexander,

Couple of our builders do not like this commit:

Failing Tests:

Clang Tools :: clang-tidy/modernize-use-noexcept-opt.cpp
Clang Tools :: clang-tidy/modernize-use-noexcept.cpp

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

Please have a look at this?

Thanks

Galina

On Thu, Jun 8, 2017 at 7:04 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Thu Jun  8 09:04:16 2017
> New Revision: 304977
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304977&view=rev
> Log:
> [clang-tidy] New checker to replace dynamic exception specifications
>
> Summary:
> New checker to replace dynamic exception
> specifications
>
> This is an alternative to D18575 which relied on reparsing the decl to
> find the location of dynamic exception specifications, but couldn't
> deal with preprocessor conditionals correctly without reparsing the
> entire file.
>
> This approach uses D20428 to find dynamic exception specification
> locations and handles all cases correctly.
>
> Reviewers: aaron.ballman, alexfh
>
> Reviewed By: aaron.ballman, alexfh
>
> Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere,
> cfe-commits, Eugene.Zelenko, etienneb
>
> Patch by Don Hinton!
>
> Differential Revision: https://reviews.llvm.org/D20693
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-
> use-noexcept.rst
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-
> noexcept-macro.cpp
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=
> 304976&r2=304977&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jun
> 8 09:04:16 2017
> @@ -22,6 +22,7 @@ add_clang_library(clangTidyModernizeModu
>UseEmplaceCheck.cpp
>UseEqualsDefaultCheck.cpp
>UseEqualsDeleteCheck.cpp
> +  UseNoexceptCheck.cpp
>UseNullptrCheck.cpp
>UseOverrideCheck.cpp
>UseTransparentFunctorsCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/
> ModernizeTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=
> 304977&r1=304976&r2=304977&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> Thu Jun  8 09:04:16 2017
> @@ -28,6 +28,7 @@
>  #include "UseEmplaceCheck.h"
>  #include "UseEqualsDefaultCheck.h"
>  #include "UseEqualsDeleteCheck.h"
> +#include "UseNoexceptCheck.h"
>  #include "UseNullptrCheck.h"
>  #include "UseOverrideCheck.h"
>  #include "UseTransparentFunctorsCheck.h"
> @@ -69,6 +70,7 @@ public:
>  CheckFactories.registerCheck("
> modernize-use-equals-default");
>  CheckFactories.registerCheck(
>  "modernize-use-equals-delete");
> +CheckFactories.registerCheck("modernize-
> use-noexcept");
>  CheckFactories.registerCheck("modernize-
> use-nullptr");
>  CheckFactories.registerCheck("modernize-
> use-override");
>  CheckFactories.registerCheck(
>
> Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=304977&view=auto
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp Thu
> Jun  8 09:04:16 2017
> @@ -0,0 +1,114 @@
> +//===--- UseNoexceptCheck.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 "UseNo

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/numeric:145
+{
+return reduce(__first, __last, __init, _VSTD::plus<>());
+}

Missing _VSTD::



Comment at: include/numeric:153
+{
+return reduce(__first, __last, 
+   typename iterator_traits<_InputIterator>::value_type{}, 
_VSTD::plus<>());

Missing _VSTD::



Comment at: include/numeric:209
+{
+   return transform_reduce(__first1, __last1, __first2, __init, 
_VSTD::plus<>(), _VSTD::multiplies<>());
+}

Missing _VSTD::



Comment at: test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp:26
+{
+static_assert( std::is_same::value_type,
+decltype(std::reduce(first, last))>::value, "" 
);

Maybe use _v trait?



Comment at: test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp:27
+static_assert( std::is_same::value_type,
+decltype(std::reduce(first, last))>::value, "" 
);
+assert(std::reduce(first, last) == x);

May as well drop the `, ""` since this test requires C++17 anyway.



Comment at: test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp:37
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+test(Iter(ia), Iter(ia), 0);
+test(Iter(ia), Iter(ia+1), 1);

wash wrote:
>  Just to confirm, this should be 0 because the "default" init value is 
> `iterator_traits<_InputIterator>::value_type{}`, and `int{}` gives you a 
> determinate result (as opposed to `int()` which would not), correct?
`int()` also gives a determinate result.



Comment at: 
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp:36
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }

Maybe use `decltype(auto)` here?



Comment at: 
test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp:41
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+assert(sa == sizeof(ua) / sizeof(ua[0]));   // just to be sure
+

You could static_assert this if you make sa const.


https://reviews.llvm.org/D33997



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


[PATCH] D34022: Repair 2010-05-31-palignr.c test

2017-06-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Thanks!


https://reviews.llvm.org/D34022



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


[PATCH] D34022: Repair 2010-05-31-palignr.c test

2017-06-08 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Raphael and I work together I can take care of it...


https://reviews.llvm.org/D34022



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


Re: [clang-tools-extra] r304949 - [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Galina Kistanova via cfe-commits
Hello Yan,

This commit broke few of our builders:

Failing Tests (1):
Clang Tools :: clang-tidy/misc-noexcept-move-constructor.cpp

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

Please have a look at this?

Thanks

Galina


On Wed, Jun 7, 2017 at 3:39 PM, Yan Wang via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yawanng
> Date: Wed Jun  7 17:39:20 2017
> New Revision: 304949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304949&view=rev
> Log:
> [clang-tidy] When" -fno-exceptions is used", this warning is better to be
> suppressed.
>
> Summary:  "misc-noexcept-move-constructor" is better not to be issued
> when "-fno-exceptions" is set.
>
> Reviewers: chh, alexfh, aaron.ballman
>
> Reviewed By: aaron.ballman
>
> Subscribers: aaron.ballman, cfe-commits, xazax.hun
>
> Tags: #clang-tools-extra
>
> Differential Revision: https://reviews.llvm.org/D34002
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.
> cpp
> clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-
> constructor.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/
> NoexceptMoveConstructorCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.
> cpp?rev=304949&r1=304948&r2=304949&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
> Wed Jun  7 17:39:20 2017
> @@ -20,7 +20,7 @@ namespace misc {
>  void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder)
> {
>// Only register the matchers for C++11; the functionality currently
> does not
>// provide any benefit to other languages, despite being benign.
> -  if (!getLangOpts().CPlusPlus11)
> +  if (!getLangOpts().CPlusPlus11 || !getLangOpts().CXXExceptions)
>  return;
>
>Finder->addMatcher(
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-
> constructor.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?
> rev=304949&r1=304948&r2=304949&view=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
> Wed Jun  7 17:39:20 2017
> @@ -1,16 +1,25 @@
> -// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
> +// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" --
> -std=c++11 \
> +// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
> +// RUN:   -implicit-check-not="{{warning|error}}:"
> +// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" --
> -fno-exceptions -std=c++11 \
> +// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
> +// RUN:   -implicit-check-not="{{warning|error}}:"
> +
>
>  class A {
>A(A &&);
> -  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be
> marked noexcept [misc-noexcept-move-constructor]
> +  // CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: move constructors should
> be marked noexcept [misc-noexcept-move-constructor]
> +  // CHECK-NONEXCEPTIONS-NOT: warning:
>A &operator=(A &&);
> -  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators
> should
> +  // CHECK-EXCEPTIONS: :[[@LINE-1]]:6: warning: move assignment operators
> should
> +  // CHECK-NONEXCEPTIONS-NOT: warning:
>  };
>
>  struct B {
>static constexpr bool kFalse = false;
>B(B &&) noexcept(kFalse);
> -  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the
> move constructor evaluates to 'false' [misc-noexcept-move-constructor]
> +  // CHECK-EXCEPTIONS: :[[@LINE-1]]:20: warning: noexcept specifier on
> the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
> +  // CHECK-NONEXCEPTIONS-NOT: warning:
>  };
>
>  class OK {};
>
>
> ___
> 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


[PATCH] D33094: [ASTMatchers] Add clang-query support for equals matcher

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

LGTM!


https://reviews.llvm.org/D33094



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


[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

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

LGTM!




Comment at: include/clang/ASTMatchers/Dynamic/VariantValue.h:335
 unsigned Unsigned;
+double Double;
 bool Boolean;

Lekensteyn wrote:
> aaron.ballman wrote:
> > Lekensteyn wrote:
> > > aaron.ballman wrote:
> > > > Lekensteyn wrote:
> > > > > aaron.ballman wrote:
> > > > > > This may or may not be a good idea, but do we want to put the 
> > > > > > values into an APFloat rather than a double? My concern with double 
> > > > > > is that (0) it may be subtly different if the user wants a 16- or 
> > > > > > 32-bit float explicitly, (1) it won't be able to represent long 
> > > > > > double values, or quad double.
> > > > > > 
> > > > > > I'm thinking this value could be passed directly from the C++ API 
> > > > > > as an APFloat, float, or double, or provided using a StringRef for 
> > > > > > the dynamic API.
> > > > > (32-bit) double values are a superset of (16-bit) float values, that 
> > > > > should be OK.
> > > > > Long doubles are possible in the AST (e.g. for `0.1L`), but neither 
> > > > > C11 nor C++14 seem to define a quad double literal type (so that 
> > > > > should be of a lesser concern).
> > > > > 
> > > > > Reasons why I chose for double instead of APFloat:
> > > > > - `strtod` is readily available and does not abort the program. By 
> > > > > contrast, `APFloat(StringRef)` trips on assertions if the input is 
> > > > > invalid.
> > > > > - I was not sure if the APFloat class can be used in an union.
> > > > The downside to using `strtod()` is that invalid input is silently 
> > > > accepted. However, assertions on invalid input is certainly not good 
> > > > either. It might be worth modifying `APFloat::convertFromString()` to 
> > > > accept invalid input and return an error.
> > > > 
> > > > I think instead of an `APFloat`, maybe using an `APValue` for both the 
> > > > `Unsigned` and `Double` fields might work. At the very least, it should 
> > > > give you implementation ideas.
> > > > 
> > > > There is a quad double literal suffix: `q`. It's only supported on some 
> > > > architectures, however. There are also imaginary numbers (`i`) and half 
> > > > (`h`).
> > > The strtod conversion was based on parseDouble in 
> > > lib/Support/CommandLine.cpp, so any conversion issues also exist there.
> > > 
> > > Same question, can APFloat/APValue be used in a union?
> > > 
> > > float (or quad-double suffixes) are explicitly not supported now in this 
> > > matcher, maybe they can be added later but for now I decided to keep the 
> > > grammar simple (that is, do not express double/float data types via the 
> > > literal).
> > > The strtod conversion was based on parseDouble in 
> > > lib/Support/CommandLine.cpp, so any conversion issues also exist there.
> > 
> > Good to know.
> > 
> > > Same question, can APFloat/APValue be used in a union?
> > 
> > I believe so, but I've not tried it myself. Also, as I mentioned, `APValue` 
> > demonstrates another implementation strategy in case you cannot use a union 
> > directly.
> > 
> > > float (or quad-double suffixes) are explicitly not supported now in this 
> > > matcher, maybe they can be added later but for now I decided to keep the 
> > > grammar simple (that is, do not express double/float data types via the 
> > > literal).
> > 
> > That's reasonable for an initial implementation.
> I think I'll keep it like this for now and defer eventual conversion to 
> APValue for a future patch that also makes uint64_t possible. Is that OK?
Okay, that seems reasonable to me.


https://reviews.llvm.org/D33135



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

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

Aside from one minor nit, LGTM!




Comment at: include/clang/AST/Decl.h:901
+/// member functions.
+unsigned ImplicitParamKind : 3;
   };

rjmccall wrote:
> ABataev wrote:
> > aaron.ballman wrote:
> > > ABataev wrote:
> > > > aaron.ballman wrote:
> > > > > It's a bit strange to me that the non-parameter declaration bits now 
> > > > > have a field for implicit parameter information. Why here instead of 
> > > > > `ParmVarDeclBits`?
> > > > Actually, `ImplicitParamDecl` already uses some bits from the 
> > > > `NonParmVarDeclBitfields`, at least it may be marked as 
> > > > `ARCPseudoStrong` for ObjC. That's why I had to reuse 
> > > > `NonParmVarDeclBitfields` part.
> > > Ew. That's nasty and we should probably fix that (not as part of this 
> > > patch). Can you add a FIXME here?
> > Ok, I will add FIXME for `ARCPseudoStrong` and for the `ImplicitParamKind` 
> > bitfields
> The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of 
> ParamVarDecl.
> 
> The comment here needs to be updated.
> The FIXME doesn't make sense because ImplicitParamDecl is not a subclass of 
> ParamVarDecl.

Then the class name is poor, because I would not expect to find *anything* 
about parameter declarations (implicit or otherwise) in a class named 
`NonParmVarDeclBitfields`. However, I see the logic behind the split better 
now, so thank you for that. (Nothing needs to be done here for this patch.)



Comment at: lib/Serialization/ASTWriterDecl.cpp:918
 Record.push_back(D->isPreviousDeclInSameBlockScope());
+if (auto *IPD = dyn_cast(D))
+  Record.push_back(static_cast(IPD->getParameterKind()));

aaron.ballman wrote:
> `const auto *`
This is still missing the `const` qualifier.


https://reviews.llvm.org/D33735



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


r305013 - [Sema] Refactor OverloadCandidate::BuiltinTypes. NFC.

2017-06-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Jun  8 15:55:21 2017
New Revision: 305013

URL: http://llvm.org/viewvc/llvm-project?rev=305013&view=rev
Log:
[Sema] Refactor OverloadCandidate::BuiltinTypes. NFC.

As promised in r304996.

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=305013&r1=305012&r2=305013&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Jun  8 15:55:21 2017
@@ -633,11 +633,9 @@ namespace clang {
 /// Might be a UsingShadowDecl or a FunctionTemplateDecl.
 DeclAccessPair FoundDecl;
 
-/// BuiltinTypes - Provides the parameter types of a built-in overload
+/// BuiltinParamTypes - Provides the parameter types of a built-in overload
 /// candidate. Only valid when Function is NULL.
-struct {
-  QualType ParamTypes[3];
-} BuiltinTypes;
+QualType BuiltinParamTypes[3];
 
 /// Surrogate - The conversion function for which this candidate
 /// is a surrogate, but only if IsSurrogate is true.

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=305013&r1=305012&r2=305013&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jun  8 15:55:21 2017
@@ -5281,16 +5281,16 @@ static bool FindConditionalOverload(Sema
   switch (CandidateSet.BestViableFunction(Self, QuestionLoc, Best)) {
 case OR_Success: {
   // We found a match. Perform the conversions on the arguments and move 
on.
-  ExprResult LHSRes =
-Self.PerformImplicitConversion(LHS.get(), 
Best->BuiltinTypes.ParamTypes[0],
-   Best->Conversions[0], 
Sema::AA_Converting);
+  ExprResult LHSRes = Self.PerformImplicitConversion(
+  LHS.get(), Best->BuiltinParamTypes[0], Best->Conversions[0],
+  Sema::AA_Converting);
   if (LHSRes.isInvalid())
 break;
   LHS = LHSRes;
 
-  ExprResult RHSRes =
-Self.PerformImplicitConversion(RHS.get(), 
Best->BuiltinTypes.ParamTypes[1],
-   Best->Conversions[1], 
Sema::AA_Converting);
+  ExprResult RHSRes = Self.PerformImplicitConversion(
+  RHS.get(), Best->BuiltinParamTypes[1], Best->Conversions[1],
+  Sema::AA_Converting);
   if (RHSRes.isInvalid())
 break;
   RHS = RHSRes;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=305013&r1=305012&r2=305013&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  8 15:55:21 2017
@@ -7150,8 +7150,7 @@ void Sema::AddBuiltinCandidate(QualType
   Candidate.Function = nullptr;
   Candidate.IsSurrogate = false;
   Candidate.IgnoreObjectArgument = false;
-  for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
-Candidate.BuiltinTypes.ParamTypes[ArgIdx] = ParamTys[ArgIdx];
+  std::copy(ParamTys, ParamTys + Args.size(), Candidate.BuiltinParamTypes);
 
   // Determine the implicit conversion sequences for each of the
   // arguments.
@@ -10143,13 +10142,13 @@ static void NoteBuiltinOperatorCandidate
   std::string TypeStr("operator");
   TypeStr += Opc;
   TypeStr += "(";
-  TypeStr += Cand->BuiltinTypes.ParamTypes[0].getAsString();
+  TypeStr += Cand->BuiltinParamTypes[0].getAsString();
   if (Cand->Conversions.size() == 1) {
 TypeStr += ")";
 S.Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
   } else {
 TypeStr += ", ";
-TypeStr += Cand->BuiltinTypes.ParamTypes[1].getAsString();
+TypeStr += Cand->BuiltinParamTypes[1].getAsString();
 TypeStr += ")";
 S.Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
   }
@@ -10386,7 +10385,7 @@ static void CompleteNonViableCandidate(S
   } else {
 // Builtin operator.
 assert(ConvCount <= 3);
-ParamTypes = Cand->BuiltinTypes.ParamTypes;
+ParamTypes = Cand->BuiltinParamTypes;
   }
 
   // Fill in the rest of the conversions.
@@ -11992,9 +11991,8 @@ Sema::CreateOverloadedUnaryOp(SourceLoca
   // We matched a built-in operator. Convert the arguments, then
   // break out so that we will build the appropriate built-in
   // operator node.
-  ExprResult InputRes =
-PerformImplicitConversion(Input, Best->BuiltinTypes.ParamTypes[0],
-  Best->Conversions[0], AA_Passing);
+  ExprResult InputRes = PerformImplicitConversion(
+  Input, Best->Built

Re: [PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-08 Thread Rui Ueyama via cfe-commits
On Wed, Jun 7, 2017 at 6:55 AM, Joerg Sonnenberger via Phabricator <
revi...@reviews.llvm.org> wrote:

> joerg added a comment.
>
> In https://reviews.llvm.org/D33726#774105, @ruiu wrote:
>
> > I'm totally against adding per-OS path knowledge to our linker.
> Compilers already know include paths and I don't want to maintain another
> list of paths in the linker. Also this can be more confusing than useful
> when you are doing cross-linking.
>
>
> The only reason for compilers to maintain that list is for finding crt*.o.
> They otherwise don't care about the library paths at all. There is no
> confusion for cross-linking as long as proper sysroot support is used.
> Which we have been doing on NetBSD for ages.


That's not what clang is trying to do for all Unix-like systems (except
NetBSD due to the bug), right? The compiler driver actually passes library
paths to the linker. If you think that is wrong, you should make a change
to stop doing that on all systems. I don't see a reason to not do this only
on NetBSD.

> For all OSes other than NetBSD, LLD works fine with the clang driver as
> the driver passes include paths to the linker. I don't see any reason not
> to do the same thing for NetBSD. That stands even if the linker has to have
> a list of include paths.
>
> Sorry, but this is again ignorant and wrong. The very same problem of
> build systems calling ld directly apply on most other systems. Even then,
> the list of linker paths is not the only OS-specific knowledge. Things like
> the DT_RPATH vs DT_RUNPATH mess, init vs init_array all belong into this
> category. The list goes on.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D33726
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34022: Repair 2010-05-31-palignr.c test

2017-06-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!

Do you need someone to commit it?


https://reviews.llvm.org/D34022



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-06-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 101955.
yaxunl retitled this revision from "Support synchronisation scope in Clang 
atomic builtin functions" to "Add OpenCL 2.0 atomic builtin functions as Clang 
builtin".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Add __opencl_atomic_ builtins.


https://reviews.llvm.org/D28691

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/Basic/Builtins.def
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+
+// Basic parsing/Sema tests for __opencl_atomic_*
+
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+
+struct S { char c[3]; };
+
+char i8;
+short i16;
+int i32;
+int8 i64;
+
+atomic_int gn;
+
+void f(atomic_int *i, const atomic_int *ci,
+   atomic_intptr_t *p, atomic_float *d,
+   int *I, const int *CI,
+   intptr_t *P, float *D, struct S *s1, struct S *s2) {
+  __opencl_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
+  __opencl_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(0); // expected-error {{too few arguments to function}}
+  __opencl_atomic_load(0,0,0,0); // expected-error {{too many arguments to function}}
+  __opencl_atomic_store(0,0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+  __opencl_atomic_store((int*)0,0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+  __opencl_atomic_store(i, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{operand of type 'void'}}
+
+  int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{must be a pointer to _Atomic}}
+
+  __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{must be a pointer to atomic integer or pointer}}
+
+  __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{must be a pointer to atomic integer}}
+
+  bool cmpexch_1 = __opencl_atomic_compare_exchange_strong(i, I, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_item);
+  bool cmpexch_2 = __opencl_atomic_compare_exchange_strong(p, P, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_item);
+  bool cmpexch_3 = __opencl_atomic_compare_exchange_strong(d, I, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_item); // expected-warning {{incompatible pointer types}}
+  (void)__opencl_atomic_compare_exchange_strong(i, CI, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_item); // expected-warning {{passing 'const __generic int *' to parameter of type

[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

I think the test `reduce_iter_iter_T.pass.cpp` can be improved a little bit.

Right now, it:

- Tests that the three argument overload (iterators + init) work correctly when 
the iterator value type is the same as the init type.
- Tests that the return type of the three argument overload is correct in cases 
where the iterator value type differs from the init type.

It does not, however, test whether the result is correct when the iterator 
value type differs from the init type.

I'd suggest:

  void
  test_different_init_type()
  {
  char ca[] = {CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX};
  unsigned sa = sizeof(ca) / sizeof(ca[0]);
  test(ca, ca, int{0}, int{0});
  test(ca, ca+1, int{0}, int{CHAR_MAX});
  test(ca, ca+2, int{0}, int{2*CHAR_MAX});
  test(ca, ca+sa, int{0}, int{4*CHAR_MAX});
  }


https://reviews.llvm.org/D33997



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


[PATCH] D33997: Implement the non-execution policy versions of `reduce` and `transform_reduce` for C++17

2017-06-08 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

Suppose you have:

  struct A {};
  struct B {};
  
  A operator+(A, B);
  
  std::vector v;
  std::reduce(v.begin(), v.end(), A{});

The implementation in this patch works fine for the above case - as would 
`accumulate`, which it is equivalent to. However, `reduce` requires that "All 
of `binary_op(init, *first)`, `binary_op(*first, init)`, `binary_op(init, 
init)`, and `binary_op(*first, *first)` shall be convertible to T.", as all 
those operations may be needed for the parallel execution-policy overload of 
`reduce` (the requirement applies to the non-execution-policy overload as well).

E.g. in the above example, these operations are also required by `reduce`, even 
though the non-parallel implementation does not need them:

  A operator+(B, A);
  A operator+(A, A);
  A operator+(B, B);

Should the non-parallel implementation of `reduce` static_assert or SFINAE away 
when these requirements are not met? I think it might be desirable to ensure 
that if this won't compile:

  std::reduce(std::par, v.begin(), v.end(), A{});

Then this will also not compile:

  std::reduce(v.begin(), v.end(), A{});

(And the spec seems to suggest this too).




Comment at: include/numeric:154
+return reduce(__first, __last, 
+   typename iterator_traits<_InputIterator>::value_type{}, 
_VSTD::plus<>());
+}

In the spec, this overload of `reduce` is described as equivalent to `return 
reduce(std::forward(exec), first, last, typename 
iterator_traits::value_type{});`.  The overload that it calls 
(the three argument version that omits a binary operation) just forwards to the 
four-argument reduce, adding the `plus<>()` argument.

Is there a reason you wanted to avoid the extra layer of function call 
indirection (it should be inlined and optimized away, right)? What you have 
seems perfectly fine, I'm just curious though.



Comment at: test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp:37
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+test(Iter(ia), Iter(ia), 0);
+test(Iter(ia), Iter(ia+1), 1);

 Just to confirm, this should be 0 because the "default" init value is 
`iterator_traits<_InputIterator>::value_type{}`, and `int{}` gives you a 
determinate result (as opposed to `int()` which would not), correct?


https://reviews.llvm.org/D33997



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


[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

I've encountered some new diagnostics when running tests on a stage2 
instrumented clang, and will need more time to investigate them. Sorry for the 
delayed communication, I am a bit swamped this week owing to wwdc and being a 
build cop.


https://reviews.llvm.org/D33910



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


RE: r284060 - Implement MS _BitScan intrinsics

2017-06-08 Thread Erik Schwiebert via cfe-commits
It’s probably also better to not try to infer our weird desired behavior. It 
should probably be controlled by a specific driver directive, like 
“-fms-extensions-lp64-intrinsics” or something like that. Using a new directive 
means that nobody can accidentally get this behavior if they for some reason do 
want LLP64 behavior with Windows intrinsics.

Schwieb

From: Erik Schwiebert
Sent: Thursday, June 8, 2017 10:29 AM
To: 'Saleem Abdulrasool' ; Duncan P. N. Exon Smith 

Cc: Albert Gutowski ; Reid Kleckner ; 
David Majnemer ; cfe-commits 

Subject: RE: r284060 - Implement MS _BitScan intrinsics

Yes, we definitely do not want to introduce pointer-type incompatibility 
warnings. Predicating the behavior change on LP64 vs LLP64 seems better.

What’s the best way to do that?  Brian and I can hack on clang a bit, but we’re 
certainly not experts.

Schwieb

From: Saleem Abdulrasool [mailto:compn...@compnerd.org]
Sent: Wednesday, June 7, 2017 7:32 PM
To: Duncan P. N. Exon Smith mailto:dexonsm...@apple.com>>
Cc: Albert Gutowski mailto:agutow...@google.com>>; Reid 
Kleckner mailto:r...@google.com>>; David Majnemer 
mailto:david.majne...@gmail.com>>; cfe-commits 
mailto:cfe-commits@lists.llvm.org>>; Erik 
Schwiebert mailto:eri...@microsoft.com>>
Subject: Re: r284060 - Implement MS _BitScan intrinsics

I'm worried about changing this signature all the time.  I suspect that it will 
cause the following to be emitted for valid code:

warning: incompatible pointer types passing 'unsigned long *' to parameter of 
type 'unsigned int *' [-Wincompatible-pointer-types]

Switching the signature on LP64 sounds much better to me.

On Wed, Jun 7, 2017 at 2:56 PM, Duncan P. N. Exon Smith via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
[... excuse the necromancy...]

Hi Albert (and Reid and David),

This commit is breaking some uses of -fms-extensions on Apple platforms.  In 
particular, Brian and Erik (CC'ed) build against a version of the Windows SDK 
on Apple platforms.  _BitScanReverse is expected to be 32-bit, matching 
Windows/LLP64, even though long is 64-bit on Darwin/LP64.

One idea we've had for fixing this is to use "int" instead of "long" for these 
intrinsics, either:
- all the time, or
- when in LP64 mode (e.g., Darwin + -fms-extensions).

Any other ideas?

Thanks,
Duncan

> On Oct 12, 2016, at 15:01, Albert Gutowski via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: agutowski
> Date: Wed Oct 12 17:01:05 2016
> New Revision: 284060
>
> URL: 
> http://llvm.org/viewvc/llvm-project?rev=284060&view=rev
> Log:
> Implement MS _BitScan intrinsics
>
> Summary: _BitScan intrinsics (and some others, for example _Interlocked and 
> _bittest) are supposed to work on both ARM and x86. This is an attempt to 
> isolate them, avoiding repeating their code or writing separate function for 
> each builtin.
>
> Reviewers: hans, thakis, rnk, majnemer
>
> Subscribers: RKSimon, cfe-commits, aemerson
>
> Differential Revision: 
> https://reviews.llvm.org/D25264
>
> Modified:
>cfe/trunk/include/clang/Basic/BuiltinsARM.def
>cfe/trunk/include/clang/Basic/BuiltinsX86.def
>cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
>cfe/trunk/lib/Basic/Targets.cpp
>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>cfe/trunk/lib/CodeGen/CodeGenFunction.h
>cfe/trunk/lib/Headers/intrin.h
>cfe/trunk/test/CodeGen/ms-intrinsics.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=284060&r1=284059&r2=284060&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Wed Oct 12 17:01:05 2016
> @@ -18,6 +18,10 @@
> #   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
> #endif
>
> +#if defined(BUILTIN) && !defined(TAR

r305002 - Revert "Frontend support for Nios2 target"

2017-06-08 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Thu Jun  8 13:36:35 2017
New Revision: 305002

URL: http://llvm.org/viewvc/llvm-project?rev=305002&view=rev
Log:
Revert "Frontend support for Nios2 target"

As it breaks many buildbots.

Removed:
cfe/trunk/include/clang/Basic/BuiltinsNios2.def
cfe/trunk/test/Driver/nios2-cpu.c
Modified:
cfe/trunk/include/clang/Basic/TargetBuiltins.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Removed: cfe/trunk/include/clang/Basic/BuiltinsNios2.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNios2.def?rev=305001&view=auto
==
--- cfe/trunk/include/clang/Basic/BuiltinsNios2.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNios2.def (removed)
@@ -1,70 +0,0 @@
-//===-- BuiltinsNios2.def - Nios2 Builtin function 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 Nios2-specific builtin function database. Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-// Nios2 R1 builtins:
-
-//int __builtin_ldbio(volatile const void *);
-BUILTIN(__builtin_ldbio, "ivDC*", "")
-//int __builtin_ldbuio(volatile const void *);
-BUILTIN(__builtin_ldbuio, "ivDC*", "")
-//int __builtin_ldhio(volatile const void *);
-BUILTIN(__builtin_ldhio, "ivDC*", "")
-//int __builtin_ldhuio(volatile const void *);
-BUILTIN(__builtin_ldhuio, "ivDC*", "")
-//int __builtin_ldwio(volatile const void *);
-BUILTIN(__builtin_ldwio, "ivDC*", "")
-//int __builtin_ldwuio(int);
-BUILTIN(__builtin_ldwuio, "ii", "")
-// int __builtin_rdctl(int);
-BUILTIN(__builtin_rdctl, "iIi", "")
-// void __builtin_wrctl(int, int);
-BUILTIN(__builtin_wrctl, "vIii", "")
-// int __builtin_rdprs(int, int);
-BUILTIN(__builtin_rdprs, "iii", "")
-//void __builtin_stbio(volatile void *, int);
-BUILTIN(__builtin_stbio, "vvD*i", "")
-//void __builtin_sthio(volatile void *, int);
-BUILTIN(__builtin_sthio, "vvD*i", "")
-//void __builtin_stwio(volatile void *, int);
-BUILTIN(__builtin_stwio, "vvD*i", "")
-//void __builtin_sync(void);
-BUILTIN(__builtin_sync, "v", "")
-// void __builtin_flushd(volatile void *);
-BUILTIN(__builtin_flushd, "vvD*", "")
-// void __builtin_flushda(volatile void *);
-BUILTIN(__builtin_flushda, "vvD*", "")
-
-// Nios2 R2 builtins:
-
-// int __builtin_wrpie(int);
-TARGET_BUILTIN(__builtin_wrpie, "ii", "", "nios2r2mandatory")
-// void __builtin_eni(int);
-TARGET_BUILTIN(__builtin_eni, "vi", "", "nios2r2mandatory")
-// int __builtin_ldex(volatile const void *);
-TARGET_BUILTIN(__builtin_ldex, "ivDC*", "", "nios2r2mandatory")
-// int __builtin_stex(volatile void *, int);
-TARGET_BUILTIN(__builtin_stex, "ivD*i", "", "nios2r2mandatory")
-// int __builtin_ldsex(volatile const void *);
-TARGET_BUILTIN(__builtin_ldsex, "ivDC*", "", "nios2r2mpx")
-// int __builtin_stsex(volatile void *, int);
-TARGET_BUILTIN(__builtin_stsex, "ivDC*i", "", "nios2r2mpx")
-
-#undef BUILTIN
-#undef TARGET_BUILTIN

Modified: cfe/trunk/include/clang/Basic/TargetBuiltins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetBuiltins.h?rev=305002&r1=305001&r2=305002&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h Thu Jun  8 13:36:35 2017
@@ -150,16 +150,6 @@ namespace clang {
 };
   }
 
-  /// \brief Nios2 builtins
-  namespace Nios2 {
-  enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsNios2.def"
-LastTSBuiltin
-  };
-  }
-
   /// \brief MIPS builtins
   namespace Mips {
 enum {

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=305002&r1=305001&r2=305002&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun  8 13:36:35 2017
@@ -7702,148 +7702,6 @@ public:
   }
 };
 
-class Nios2TargetInfo : public TargetInfo {
-  void setDataLayout() {
-if (BigEndian)
-  resetDataLayout("E-p:32:32:32-i8:8:32-i16:16:32-n32");
-else
-  resetDataLayout("e-p:32:32:32-i8:8:32-i16:16:32-n32");
-  }
-
-  static const Builtin::Info BuiltinInfo[];
-  std::st

[libcxx] r305000 - [libcxx] [test] Update locale names for Windows.

2017-06-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Jun  8 13:22:03 2017
New Revision: 305000

URL: http://llvm.org/viewvc/llvm-project?rev=305000&view=rev
Log:
[libcxx] [test] Update locale names for Windows.

locale.codecvt.byname/ctor_char.pass.cpp:
This test used to use "en_US" as a plain string instead of using 
platform_support.
Need to fix this because MS STL expects "en-US" instead.

platform_support.h:
These are the legacy Windows locale names. Should use IETF tags instead.
I've also added en_US, since a test was using that as a locale string as well.

msvc_stdlib_force_include.hpp:
Remove _MSVC_STL_VER. The libraries will directly define _MSVC_STL_VERSION in 
the future.

Fixes D29351.

Modified:

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
libcxx/trunk/test/support/platform_support.h

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp?rev=305000&r1=304999&r2=305000&view=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
 Thu Jun  8 13:22:03 2017
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include "platform_support.h"
+
 typedef std::codecvt_byname F;
 
 class my_facet
@@ -38,12 +40,12 @@ int my_facet::count = 0;
 int main()
 {
 {
-std::locale l(std::locale::classic(), new my_facet("en_US"));
+std::locale l(std::locale::classic(), new my_facet(LOCALE_en_US));
 assert(my_facet::count == 1);
 }
 assert(my_facet::count == 0);
 {
-my_facet f("en_US", 1);
+my_facet f(LOCALE_en_US, 1);
 assert(my_facet::count == 1);
 {
 std::locale l(std::locale::classic(), &f);
@@ -53,12 +55,12 @@ int main()
 }
 assert(my_facet::count == 0);
 {
-std::locale l(std::locale::classic(), new 
my_facet(std::string("en_US")));
+std::locale l(std::locale::classic(), new 
my_facet(std::string(LOCALE_en_US)));
 assert(my_facet::count == 1);
 }
 assert(my_facet::count == 0);
 {
-my_facet f(std::string("en_US"), 1);
+my_facet f(std::string(LOCALE_en_US), 1);
 assert(my_facet::count == 1);
 {
 std::locale l(std::locale::classic(), &f);

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=305000&r1=304999&r2=305000&view=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Thu Jun  8 13:22:03 
2017
@@ -28,11 +28,6 @@
 #error This header may not be used when targeting libc++
 #endif
 
-// Indicates that we are using the MSVC standard library.
-#ifndef _MSVC_STL_VER
-#define _MSVC_STL_VER 42
-#endif
-
 #ifndef _LIBCXX_IN_DEVCRT
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {

Modified: libcxx/trunk/test/support/platform_support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/platform_support.h?rev=305000&r1=304999&r2=305000&view=diff
==
--- libcxx/trunk/test/support/platform_support.h (original)
+++ libcxx/trunk/test/support/platform_support.h Thu Jun  8 13:22:03 2017
@@ -19,16 +19,18 @@
 #ifdef _WIN32
 // WARNING: Windows does not support UTF-8 codepages.
 // Locales are "converted" using http://docs.moodle.org/dev/Table_of_locales
-#define LOCALE_en_US_UTF_8 "English_United States.1252"
-#define LOCALE_cs_CZ_ISO8859_2 "Czech_Czech Republic.1250"
-#define LOCALE_fr_FR_UTF_8 "French_France.1252"
-#define LOCALE_fr_CA_ISO8859_1 "French_Canada.1252"
-#define LOCALE_ru_RU_UTF_8 "Russian_Russia.1251"
-#define LOCALE_zh_CN_UTF_8 "Chinese_China.936"
+#define LOCALE_en_US   "en-US"
+#define LOCALE_en_US_UTF_8 "en-US"
+#define LOCALE_cs_CZ_ISO8859_2 "cs-CZ"
+#define LOCALE_fr_FR_UTF_8 "fr-FR"
+#define LOCALE_fr_CA_ISO8859_1 "fr-CA"
+#define LOCALE_ru_RU_UTF_8 "ru-RU"
+#define LOCALE_zh_CN_UTF_8 "zh-CN"
 #elif defined(__CloudABI__)
 // Timezones are integrated into locales through LC_TIMEZONE_MASK on
 // CloudABI. LC_ALL_MASK can only be used if a timezone has also been
 // provided. UTC should be all right.
+#define LOCALE_en_US   "en_US"
 #define LOCALE_en_US_UTF_8 "en_US.UTF-8@UTC"
 #define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8@UTC"
 #d

[libcxx] r304999 - [libcxx] [test] Remove a Clang/C2 workaround.

2017-06-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Jun  8 13:21:59 2017
New Revision: 304999

URL: http://llvm.org/viewvc/llvm-project?rev=304999&view=rev
Log:
[libcxx] [test] Remove a Clang/C2 workaround.

Clang/LLVM doesn't need this workaround.

Fixes D33955.

Modified:

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp?rev=304999&r1=304998&r2=304999&view=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp
 Thu Jun  8 13:21:59 2017
@@ -48,7 +48,6 @@ int main()
 assert(X::dtor_called == false);
 assert(static_cast(opt) == false);
 }
-assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997
 {
 optional opt(X{});
 X::dtor_called = false;
@@ -57,5 +56,4 @@ int main()
 assert(static_cast(opt) == false);
 X::dtor_called = false;
 }
-assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997
 }


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


r304997 - Added llvm_unreachable to make sure the switch is always exhaustive.

2017-06-08 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  8 13:20:32 2017
New Revision: 304997

URL: http://llvm.org/viewvc/llvm-project?rev=304997&view=rev
Log:
Added llvm_unreachable to make sure the switch is always exhaustive.

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=304997&r1=304996&r2=304997&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jun  8 13:20:32 2017
@@ -7622,6 +7622,7 @@ Sema::CheckSpecializationInstantiationRe
 
   return true;
 }
+llvm_unreachable("The switch over PrevTSK must be exhaustive.");
 
   case TSK_ExplicitInstantiationDeclaration:
 switch (PrevTSK) {


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


r304996 - [Sema] Remove unused field from OverloadCandidate.

2017-06-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Jun  8 13:19:25 2017
New Revision: 304996

URL: http://llvm.org/viewvc/llvm-project?rev=304996&view=rev
Log:
[Sema] Remove unused field from OverloadCandidate.

The only use in-tree I can find for BuiltinTypes.ResultTy is a single
store to it. We otherwise just recompute what it should be later on (and
sometimes do things like argument conversions in the process of
recomputing it).

Since it's impossible to test if the value stored there is sane, and we
don't use it anyway, we should probably just drop the field.

I'll do a follow-up patch to rename BuiltinTypes.ParamTypes ->
BuiltinParamTypes in a bit. Wanted to keep this patch relatively
minimal.

Thanks to Petr Kudryavtsev for bringing this up!

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=304996&r1=304995&r2=304996&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Jun  8 13:19:25 2017
@@ -633,10 +633,9 @@ namespace clang {
 /// Might be a UsingShadowDecl or a FunctionTemplateDecl.
 DeclAccessPair FoundDecl;
 
-// BuiltinTypes - Provides the return and parameter types of a
-// built-in overload candidate. Only valid when Function is NULL.
+/// BuiltinTypes - Provides the parameter types of a built-in overload
+/// candidate. Only valid when Function is NULL.
 struct {
-  QualType ResultTy;
   QualType ParamTypes[3];
 } BuiltinTypes;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=304996&r1=304995&r2=304996&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun  8 13:19:25 2017
@@ -2727,8 +2727,7 @@ public:
SourceLocation OpLoc, ArrayRef Args,
OverloadCandidateSet& CandidateSet,
SourceRange OpRange = SourceRange());
-  void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
-   ArrayRef Args,
+  void AddBuiltinCandidate(QualType *ParamTys, ArrayRef Args,
OverloadCandidateSet& CandidateSet,
bool IsAssignmentOperator = false,
unsigned NumContextualBoolArguments = 0);

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=304996&r1=304995&r2=304996&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  8 13:19:25 2017
@@ -7136,8 +7136,7 @@ void Sema::AddMemberOperatorCandidates(O
 /// operator. NumContextualBoolArguments is the number of arguments
 /// (at the beginning of the argument list) that will be contextually
 /// converted to bool.
-void Sema::AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
-   ArrayRef Args,
+void Sema::AddBuiltinCandidate(QualType *ParamTys, ArrayRef Args,
OverloadCandidateSet& CandidateSet,
bool IsAssignmentOperator,
unsigned NumContextualBoolArguments) {
@@ -7151,7 +7150,6 @@ void Sema::AddBuiltinCandidate(QualType
   Candidate.Function = nullptr;
   Candidate.IsSurrogate = false;
   Candidate.IgnoreObjectArgument = false;
-  Candidate.BuiltinTypes.ResultTy = ResultTy;
   for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
 Candidate.BuiltinTypes.ParamTypes[ArgIdx] = ParamTys[ArgIdx];
 
@@ -7492,7 +7490,7 @@ static void AddBuiltinAssignmentOperator
   // T& operator=(T&, T)
   ParamTypes[0] = S.Context.getLValueReferenceType(T);
   ParamTypes[1] = T;
-  S.AddBuiltinCandidate(ParamTypes[0], ParamTypes, Args, CandidateSet,
+  S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/true);
 
   if (!S.Context.getCanonicalType(T).isVolatileQualified()) {
@@ -7500,7 +7498,7 @@ static void AddBuiltinAssignmentOperator
 ParamTypes[0]
   = S.Context.getLValueReferenceType(S.Context.getVolatileType(T));
 ParamTypes[1] = T;
-S.AddBuiltinCandidate(ParamTypes[0], ParamTypes, Args, CandidateSet,
+S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/true);
   }
 }
@@ -7620,64 +7618,6 @@ class BuiltinOperatorOverloadBuilder {
 return S.Context.*ArithmeticTypes[index];
   }
 
-  /// \brief Gets the canonical type 

[PATCH] D33976: [clang] Fix format specifiers fixits

2017-06-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks for working on this!

LGTM with a couple of fixes:




Comment at: test/FixIt/fixit-format-darwin.m:3
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks 
-Wformat -fixit %t
+// RUN: grep -v CHECK %t > %t2
+// RUN: FileCheck -input-file=%t2 %s

You can just pipe the result of `grep` into `FileCheck` without using another 
temporary file.



Comment at: test/FixIt/fixit-format-darwin.m:54
+  
+  // Aritificial test to check that X (in Log3(X, Y, Z))
+  // is modified only according to the diagnostics

Typo: `Artificial`.


Repository:
  rL LLVM

https://reviews.llvm.org/D33976



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


[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

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

LGTM


https://reviews.llvm.org/D33366



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


Re: r304697 - Revert "[sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)"

2017-06-08 Thread Kostya Serebryany via cfe-commits
Ah, I see https://bugs.llvm.org/show_bug.cgi?id=33308, moving the
discussion there.

On Thu, Jun 8, 2017 at 10:05 AM, Kostya Serebryany  wrote:

> How did it break it?
> Any logs?
>
> On Mon, Jun 5, 2017 at 12:35 AM, Renato Golin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rengolin
>> Date: Mon Jun  5 02:35:45 2017
>> New Revision: 304697
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304697&view=rev
>> Log:
>> Revert "[sanitizer-coverage] one more flavor of coverage:
>> -fsanitize-coverage=inline-8bit-counters. Experimental so far, not
>> documenting yet. (clang part)"
>>
>> This reverts commit r304631, as it broke ARM/AArch64 bots for 2 days.
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/CC1Options.td
>> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> cfe/trunk/lib/Driver/SanitizerArgs.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/test/Driver/fsanitize-coverage.c
>>
>> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Driver/CC1Options.td?rev=304697&r1=304696&r2=304697&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun  5 02:35:45 2017
>> @@ -293,9 +293,6 @@ def fsanitize_coverage_trace_gep
>>  def fsanitize_coverage_8bit_counters
>>  : Flag<["-"], "fsanitize-coverage-8bit-counters">,
>>HelpText<"Enable frequency counters in sanitizer coverage">;
>> -def fsanitize_coverage_inline_8bit_counters
>> -: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
>> -  HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
>>  def fsanitize_coverage_trace_pc
>>  : Flag<["-"], "fsanitize-coverage-trace-pc">,
>>HelpText<"Enable PC tracing in sanitizer coverage">;
>>
>> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Frontend/CodeGenOptions.def?rev=304697&r1=304696&r2=304697&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
>> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jun  5
>> 02:35:45 2017
>> @@ -163,7 +163,6 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0
>>///< in sanitizer coverage.
>>  CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing
>> with guard
>> ///< in sanitizer
>> coverage.
>> -CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline
>> 8bit counters.
>>  CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
>>  CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for
>> sanitizers.
>>  CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
>>
>> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Ba
>> ckendUtil.cpp?rev=304697&r1=304696&r2=304697&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jun  5 02:35:45 2017
>> @@ -187,7 +187,6 @@ static void addSanitizerCoveragePass(con
>>Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
>>Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
>>Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
>> -  Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
>>PM.add(createSanitizerCoverageModulePass(Opts));
>>  }
>>
>>
>> Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/San
>> itizerArgs.cpp?rev=304697&r1=304696&r2=304697&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
>> +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Jun  5 02:35:45 2017
>> @@ -48,14 +48,13 @@ enum CoverageFeature {
>>CoverageBB = 1 << 1,
>>CoverageEdge = 1 << 2,
>>CoverageIndirCall = 1 << 3,
>> -  CoverageTraceBB = 1 << 4,  // Deprecated.
>> +  CoverageTraceBB = 1 << 4,
>>CoverageTraceCmp = 1 << 5,
>>CoverageTraceDiv = 1 << 6,
>>CoverageTraceGep = 1 << 7,
>> -  Coverage8bitCounters = 1 << 8,  // Deprecated.
>> +  Coverage8bitCounters = 1 << 8,
>>CoverageTracePC = 1 << 9,
>>CoverageTracePCGuard = 1 << 10,
>> -  CoverageInline8bitCounters = 1 << 12,
>>CoverageNoPrune = 1 << 11,
>>  };
>>
>> @@ -531,8 +530,7 @@ SanitizerArgs::SanitizerArgs(const ToolC
>>}
>>
>>// trace-pc w/o func/bb/edge implies edge.
>> -  if ((CoverageFeatures &
>> -   (CoverageTracePC | CoverageTra

r304994 - Frontend support for Nios2 target.

2017-06-08 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Thu Jun  8 12:40:30 2017
New Revision: 304994

URL: http://llvm.org/viewvc/llvm-project?rev=304994&view=rev
Log:
Frontend support for Nios2 target.

Summary:
- Implements TargetInfo class for Nios2 target.
- Enables handling of -march and -mcpu options for Nios2 target.
- Definition of Nios2 builtin functions.

Reviewed By: craig.topper

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

Author: belickim 

Added:
cfe/trunk/include/clang/Basic/BuiltinsNios2.def
cfe/trunk/test/Driver/nios2-cpu.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/TargetBuiltins.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Added: cfe/trunk/include/clang/Basic/BuiltinsNios2.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNios2.def?rev=304994&view=auto
==
--- cfe/trunk/include/clang/Basic/BuiltinsNios2.def (added)
+++ cfe/trunk/include/clang/Basic/BuiltinsNios2.def Thu Jun  8 12:40:30 2017
@@ -0,0 +1,70 @@
+//===-- BuiltinsNios2.def - Nios2 Builtin function 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 Nios2-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===--===//
+
+// The format of this database matches clang/Basic/Builtins.def.
+
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+// Nios2 R1 builtins:
+
+//int __builtin_ldbio(volatile const void *);
+BUILTIN(__builtin_ldbio, "ivDC*", "")
+//int __builtin_ldbuio(volatile const void *);
+BUILTIN(__builtin_ldbuio, "ivDC*", "")
+//int __builtin_ldhio(volatile const void *);
+BUILTIN(__builtin_ldhio, "ivDC*", "")
+//int __builtin_ldhuio(volatile const void *);
+BUILTIN(__builtin_ldhuio, "ivDC*", "")
+//int __builtin_ldwio(volatile const void *);
+BUILTIN(__builtin_ldwio, "ivDC*", "")
+//int __builtin_ldwuio(int);
+BUILTIN(__builtin_ldwuio, "ii", "")
+// int __builtin_rdctl(int);
+BUILTIN(__builtin_rdctl, "iIi", "")
+// void __builtin_wrctl(int, int);
+BUILTIN(__builtin_wrctl, "vIii", "")
+// int __builtin_rdprs(int, int);
+BUILTIN(__builtin_rdprs, "iii", "")
+//void __builtin_stbio(volatile void *, int);
+BUILTIN(__builtin_stbio, "vvD*i", "")
+//void __builtin_sthio(volatile void *, int);
+BUILTIN(__builtin_sthio, "vvD*i", "")
+//void __builtin_stwio(volatile void *, int);
+BUILTIN(__builtin_stwio, "vvD*i", "")
+//void __builtin_sync(void);
+BUILTIN(__builtin_sync, "v", "")
+// void __builtin_flushd(volatile void *);
+BUILTIN(__builtin_flushd, "vvD*", "")
+// void __builtin_flushda(volatile void *);
+BUILTIN(__builtin_flushda, "vvD*", "")
+
+// Nios2 R2 builtins:
+
+// int __builtin_wrpie(int);
+TARGET_BUILTIN(__builtin_wrpie, "ii", "", "nios2r2mandatory")
+// void __builtin_eni(int);
+TARGET_BUILTIN(__builtin_eni, "vi", "", "nios2r2mandatory")
+// int __builtin_ldex(volatile const void *);
+TARGET_BUILTIN(__builtin_ldex, "ivDC*", "", "nios2r2mandatory")
+// int __builtin_stex(volatile void *, int);
+TARGET_BUILTIN(__builtin_stex, "ivD*i", "", "nios2r2mandatory")
+// int __builtin_ldsex(volatile const void *);
+TARGET_BUILTIN(__builtin_ldsex, "ivDC*", "", "nios2r2mpx")
+// int __builtin_stsex(volatile void *, int);
+TARGET_BUILTIN(__builtin_stsex, "ivDC*i", "", "nios2r2mpx")
+
+#undef BUILTIN
+#undef TARGET_BUILTIN

Modified: cfe/trunk/include/clang/Basic/TargetBuiltins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetBuiltins.h?rev=304994&r1=304993&r2=304994&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h Thu Jun  8 12:40:30 2017
@@ -150,6 +150,16 @@ namespace clang {
 };
   }
 
+  /// \brief Nios2 builtins
+  namespace Nios2 {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsNios2.def"
+LastTSBuiltin
+  };
+  }
+
   /// \brief MIPS builtins
   namespace Mips {
 enum {

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304994&r1=304993&r2=304994&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun  8 12:40:30 2017
@@ -7702,6 +7702,148 @@ public:
   }
 };
 
+class Nios2TargetInfo : public Targ

[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-06-08 Thread Nikolai Bozhenov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304994: Frontend support for Nios2 target. (authored by 
n.bozhenov).

Changed prior to commit:
  https://reviews.llvm.org/D33356?vs=100674&id=101941#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33356

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNios2.def
  cfe/trunk/include/clang/Basic/TargetBuiltins.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/nios2-cpu.c

Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -215,6 +215,21 @@
   return "";
 }
 
+static std::string getNios2TargetCPU(const ArgList &Args) {
+  Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (!A)
+A = Args.getLastArg(options::OPT_march_EQ);
+
+  if (!A)
+return "";
+
+  const char *name = A->getValue();
+  return llvm::StringSwitch(name)
+  .Case("r1", "nios2r1")
+  .Case("r2", "nios2r2")
+  .Default(name);
+}
+
 static std::string getLanaiTargetCPU(const ArgList &Args) {
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 return A->getValue();
@@ -267,6 +282,10 @@
   return A->getValue();
 return "";
 
+  case llvm::Triple::nios2: {
+return getNios2TargetCPU(Args);
+  }
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -7702,6 +7702,148 @@
   }
 };
 
+class Nios2TargetInfo : public TargetInfo {
+  void setDataLayout() {
+if (BigEndian)
+  resetDataLayout("E-p:32:32:32-i8:8:32-i16:16:32-n32");
+else
+  resetDataLayout("e-p:32:32:32-i8:8:32-i16:16:32-n32");
+  }
+
+  static const Builtin::Info BuiltinInfo[];
+  std::string CPU;
+  std::string ABI;
+
+public:
+  Nios2TargetInfo(const llvm::Triple &triple, const TargetOptions &opts)
+  : TargetInfo(triple), CPU(opts.CPU), ABI(opts.ABI) {
+SizeType = UnsignedInt;
+PtrDiffType = SignedInt;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+setDataLayout();
+  }
+
+  StringRef getABI() const override { return ABI; }
+  bool setABI(const std::string &Name) override {
+if (Name == "o32" || Name == "eabi") {
+  ABI = Name;
+  return true;
+}
+return false;
+  }
+
+  bool setCPU(const std::string &Name) override {
+if (Name == "nios2r1" || Name == "nios2r2") {
+  CPU = Name;
+  return true;
+}
+return false;
+  }
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+
+Builder.defineMacro("__nios2");
+Builder.defineMacro("__NIOS2");
+Builder.defineMacro("__nios2__");
+Builder.defineMacro("__NIOS2__");
+  }
+
+  ArrayRef getTargetBuiltins() const override {
+return llvm::makeArrayRef(BuiltinInfo, clang::Nios2::LastTSBuiltin -
+   Builtin::FirstTSBuiltin);
+  }
+
+  bool isFeatureSupportedByCPU(StringRef Feature, StringRef CPU) const {
+const bool isR2 = CPU == "nios2r2";
+return llvm::StringSwitch(Feature)
+.Case("nios2r2mandatory", isR2)
+.Case("nios2r2bmx", isR2)
+.Case("nios2r2mpx", isR2)
+.Case("nios2r2cdx", isR2)
+.Default(false);
+  }
+
+  bool initFeatureMap(llvm::StringMap &Features,
+  DiagnosticsEngine &Diags, StringRef CPU,
+  const std::vector &FeatureVec) const override {
+static const char *allFeatures[] = {
+  "nios2r2mandatory", "nios2r2bmx", "nios2r2mpx", "nios2r2cdx"
+};
+for (const char *feature : allFeatures) {
+  Features[feature] = isFeatureSupportedByCPU(feature, CPU);
+}
+return true;
+  }
+
+  bool hasFeature(StringRef Feature) const override {
+return isFeatureSupportedByCPU(Feature, CPU);
+  }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::VoidPtrBuiltinVaList;
+  }
+
+  ArrayRef getGCCRegNames() const override {
+static const char *const GCCRegNames[] = {
+  // CPU register names
+  // Must match second column of GCCRegAliases
+  "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+  "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20",
+  "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30",
+  "r31",
+  // Floating point register names
+  "ctl0", "ctl1", "ctl2", "ctl3", "ctl4", "ctl5", "ctl6", "ctl7", "ctl8",
+  "ctl9", "ctl10", "ctl11", "ctl12", "ctl13", "ctl14", "ctl15"
+};
+return llvm::makeArrayRef(GCCRegNames);
+  }
+
+  bool validateAsm

RE: r284060 - Implement MS _BitScan intrinsics

2017-06-08 Thread Erik Schwiebert via cfe-commits
Yes, we definitely do not want to introduce pointer-type incompatibility 
warnings. Predicating the behavior change on LP64 vs LLP64 seems better.

What’s the best way to do that?  Brian and I can hack on clang a bit, but we’re 
certainly not experts.

Schwieb

From: Saleem Abdulrasool [mailto:compn...@compnerd.org]
Sent: Wednesday, June 7, 2017 7:32 PM
To: Duncan P. N. Exon Smith 
Cc: Albert Gutowski ; Reid Kleckner ; 
David Majnemer ; cfe-commits 
; Erik Schwiebert 
Subject: Re: r284060 - Implement MS _BitScan intrinsics

I'm worried about changing this signature all the time.  I suspect that it will 
cause the following to be emitted for valid code:

warning: incompatible pointer types passing 'unsigned long *' to parameter of 
type 'unsigned int *' [-Wincompatible-pointer-types]

Switching the signature on LP64 sounds much better to me.

On Wed, Jun 7, 2017 at 2:56 PM, Duncan P. N. Exon Smith via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
[... excuse the necromancy...]

Hi Albert (and Reid and David),

This commit is breaking some uses of -fms-extensions on Apple platforms.  In 
particular, Brian and Erik (CC'ed) build against a version of the Windows SDK 
on Apple platforms.  _BitScanReverse is expected to be 32-bit, matching 
Windows/LLP64, even though long is 64-bit on Darwin/LP64.

One idea we've had for fixing this is to use "int" instead of "long" for these 
intrinsics, either:
- all the time, or
- when in LP64 mode (e.g., Darwin + -fms-extensions).

Any other ideas?

Thanks,
Duncan

> On Oct 12, 2016, at 15:01, Albert Gutowski via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: agutowski
> Date: Wed Oct 12 17:01:05 2016
> New Revision: 284060
>
> URL: 
> http://llvm.org/viewvc/llvm-project?rev=284060&view=rev
> Log:
> Implement MS _BitScan intrinsics
>
> Summary: _BitScan intrinsics (and some others, for example _Interlocked and 
> _bittest) are supposed to work on both ARM and x86. This is an attempt to 
> isolate them, avoiding repeating their code or writing separate function for 
> each builtin.
>
> Reviewers: hans, thakis, rnk, majnemer
>
> Subscribers: RKSimon, cfe-commits, aemerson
>
> Differential Revision: 
> https://reviews.llvm.org/D25264
>
> Modified:
>cfe/trunk/include/clang/Basic/BuiltinsARM.def
>cfe/trunk/include/clang/Basic/BuiltinsX86.def
>cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
>cfe/trunk/lib/Basic/Targets.cpp
>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>cfe/trunk/lib/CodeGen/CodeGenFunction.h
>cfe/trunk/lib/Headers/intrin.h
>cfe/trunk/test/CodeGen/ms-intrinsics.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=284060&r1=284059&r2=284060&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Wed Oct 12 17:01:05 2016
> @@ -18,6 +18,10 @@
> #   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
> #endif
>
> +#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
> +#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
> BUILTIN(ID, TYPE, ATTRS)
> +#endif
> +
> // In libgcc
> BUILTIN(__clear_cache, "vv*v*", "i")
>
> @@ -129,5 +133,11 @@ LANGBUILTIN(_MoveFromCoprocessor2, "UiIU
> LANGBUILTIN(_MoveToCoprocessor, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
> LANGBUILTIN(_MoveToCoprocessor2, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
>
> +TARGET_HEADER_BUILTIN(_BitScanForward, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse, "UcULi*ULi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanForward64, "UcULi*ULLi", "n", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(_BitScanReverse64, "UcULi*ULLi", "n", "intrin.h",

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Index/availability.c:20
 // CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
 
 // CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)

rdwampler wrote:
> Can we run `FileCheck` once now? I believe the `CHECK-1` and `CHECK-2` were 
> added since there were no particular order for the availabilities. With this 
> patch the order is guarantee to be stable.
Sure, if the test passes we can use one `FileCheck` invocation. We can also use 
`CHECK-DAG:` to check for strings without obeying a specific order. 


https://reviews.llvm.org/D33478



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


Re: r304697 - Revert "[sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)"

2017-06-08 Thread Kostya Serebryany via cfe-commits
How did it break it?
Any logs?

On Mon, Jun 5, 2017 at 12:35 AM, Renato Golin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rengolin
> Date: Mon Jun  5 02:35:45 2017
> New Revision: 304697
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304697&view=rev
> Log:
> Revert "[sanitizer-coverage] one more flavor of coverage:
> -fsanitize-coverage=inline-8bit-counters. Experimental so far, not
> documenting yet. (clang part)"
>
> This reverts commit r304631, as it broke ARM/AArch64 bots for 2 days.
>
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/Driver/SanitizerArgs.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/Driver/fsanitize-coverage.c
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/CC1Options.td?rev=304697&r1=304696&r2=304697&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun  5 02:35:45 2017
> @@ -293,9 +293,6 @@ def fsanitize_coverage_trace_gep
>  def fsanitize_coverage_8bit_counters
>  : Flag<["-"], "fsanitize-coverage-8bit-counters">,
>HelpText<"Enable frequency counters in sanitizer coverage">;
> -def fsanitize_coverage_inline_8bit_counters
> -: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
> -  HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
>  def fsanitize_coverage_trace_pc
>  : Flag<["-"], "fsanitize-coverage-trace-pc">,
>HelpText<"Enable PC tracing in sanitizer coverage">;
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Frontend/CodeGenOptions.def?rev=304697&r1=304696&r2=304697&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jun  5
> 02:35:45 2017
> @@ -163,7 +163,6 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0
>///< in sanitizer coverage.
>  CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing
> with guard
> ///< in sanitizer coverage.
> -CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline
> 8bit counters.
>  CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
>  CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for
> sanitizers.
>  CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> BackendUtil.cpp?rev=304697&r1=304696&r2=304697&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jun  5 02:35:45 2017
> @@ -187,7 +187,6 @@ static void addSanitizerCoveragePass(con
>Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
>Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
>Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
> -  Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
>PM.add(createSanitizerCoverageModulePass(Opts));
>  }
>
>
> Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> SanitizerArgs.cpp?rev=304697&r1=304696&r2=304697&view=diff
> 
> ==
> --- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
> +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Jun  5 02:35:45 2017
> @@ -48,14 +48,13 @@ enum CoverageFeature {
>CoverageBB = 1 << 1,
>CoverageEdge = 1 << 2,
>CoverageIndirCall = 1 << 3,
> -  CoverageTraceBB = 1 << 4,  // Deprecated.
> +  CoverageTraceBB = 1 << 4,
>CoverageTraceCmp = 1 << 5,
>CoverageTraceDiv = 1 << 6,
>CoverageTraceGep = 1 << 7,
> -  Coverage8bitCounters = 1 << 8,  // Deprecated.
> +  Coverage8bitCounters = 1 << 8,
>CoverageTracePC = 1 << 9,
>CoverageTracePCGuard = 1 << 10,
> -  CoverageInline8bitCounters = 1 << 12,
>CoverageNoPrune = 1 << 11,
>  };
>
> @@ -531,8 +530,7 @@ SanitizerArgs::SanitizerArgs(const ToolC
>}
>
>// trace-pc w/o func/bb/edge implies edge.
> -  if ((CoverageFeatures &
> -   (CoverageTracePC | CoverageTracePCGuard |
> CoverageInline8bitCounters)) &&
> +  if ((CoverageFeatures & (CoverageTracePC | CoverageTracePCGuard)) &&
>!(CoverageFeatures & InsertionPointTypes))
>  CoverageFeatures |= CoverageEdge;
>
> @@ -639,7 +637,6 @@ void SanitizerArgs::addAr

[PATCH] D33493: Speed up preamble loading

2017-06-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM with one inline request below.

I also have a question: what kind of performance benefits do you get for the 
preamble load times?




Comment at: lib/Frontend/ASTUnit.cpp:2620
+if (ItFileID == PreambleSrcLocCache.end()) {
   FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);

Please move the `FileID FID` declaration from above into here because we only 
use it in this `if`.


https://reviews.llvm.org/D33493



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


[clang-tools-extra] r304988 - Wdocumentation fix.

2017-06-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  8 12:01:01 2017
New Revision: 304988

URL: http://llvm.org/viewvc/llvm-project?rev=304988&view=rev
Log:
Wdocumentation fix.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h?rev=304988&r1=304987&r2=304988&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h Thu Jun  8 
12:01:01 2017
@@ -25,7 +25,7 @@ namespace modernize {
 /// Is converted to:
 /// \code
 ///   void foo() ;
-//void bar() noexcept(false);
+///   void bar() noexcept(false);
 /// \endcode
 ///
 /// For the user-facing documentation see:


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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

In https://reviews.llvm.org/D34002#775830, @alexfh wrote:

> IIUC, when `vector` (for a class `T` that has both move and copy 
> constructors) resizes, it will prefer move constructors, but only if they're 
> declared `noexcept`.  This is true even if `-fno-exceptions` is on. So I 
> don't think this check should depend on `-fno-exceptions`.


Should the compiler assume `noexcept` when -fno-exceptions is on?
That means move constructors should be preferred under -fno-exceptions, and 
this check would be unnecessary, right?


https://reviews.llvm.org/D34002



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


[PATCH] D31709: [NFC] Refactor DiagnosticRenderer to use FullSourceLoc

2017-06-08 Thread Christof Douma via Phabricator via cfe-commits
christof added a comment.

@rnk can you let me know if you are happy with the changes?
@rovka I assume the rebase did not change your mind about the patch. But please 
let me know if you have new reservations.

Thanks




Comment at: lib/Frontend/DiagnosticRenderer.cpp:512
   // Produce a stack of macro backtraces.
-  SmallVector LocationStack;
+  SmallVector LocationStack;
   unsigned IgnoredEnd = 0;

sanwou01 wrote:
> rnk wrote:
> > This seems inefficient, it wastes space on `SourceManager` pointers that 
> > will all be the same.
> True, but it does make the rest of this function more readable. I'd prefer to 
> leave it as is. Maybe just reducing the SmallVector size to, say, 4, to take 
> up less stack space?
We indeed waste that space, but it is 8 times a pointer while we printing 
diagnostics. I don't think that this inefficiency is is of any concern, 
especially not considering the amount of buffering that goes on during printing 
anyway.


https://reviews.llvm.org/D31709



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


[PATCH] D31709: [NFC] Refactor DiagnosticRenderer to use FullSourceLoc

2017-06-08 Thread Christof Douma via Phabricator via cfe-commits
christof updated this revision to Diff 101933.
christof marked 6 inline comments as done.
christof added a comment.

Rebased onto current HEAD and addressed the comments from Reid.


https://reviews.llvm.org/D31709

Files:
  include/clang/Basic/SourceLocation.h
  include/clang/Frontend/DiagnosticRenderer.h
  include/clang/Frontend/TextDiagnostic.h
  lib/Basic/SourceLocation.cpp
  lib/Frontend/DiagnosticRenderer.cpp
  lib/Frontend/SerializedDiagnosticPrinter.cpp
  lib/Frontend/TextDiagnostic.cpp
  lib/Frontend/TextDiagnosticPrinter.cpp
  tools/libclang/CIndexDiagnostic.cpp

Index: tools/libclang/CIndexDiagnostic.cpp
===
--- tools/libclang/CIndexDiagnostic.cpp
+++ tools/libclang/CIndexDiagnostic.cpp
@@ -110,40 +110,34 @@
   CurrentSet = &CD.getChildDiagnostics();
   }
 
-  void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- StringRef Message,
+  void emitDiagnosticMessage(FullSourceLoc Loc, PresumedLoc PLoc,
+ DiagnosticsEngine::Level Level, StringRef Message,
  ArrayRef Ranges,
- const SourceManager *SM,
  DiagOrStoredDiag D) override {
 if (!D.isNull())
   return;
 
 CXSourceLocation L;
-if (SM)
-  L = translateSourceLocation(*SM, LangOpts, Loc);
+if (Loc.hasManager())
+  L = translateSourceLocation(Loc.getManager(), LangOpts, Loc);
 else
   L = clang_getNullLocation();
 CurrentSet->appendDiagnostic(
 llvm::make_unique(Message, L));
   }
 
-  void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
+  void emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
  DiagnosticsEngine::Level Level,
- ArrayRef Ranges,
- const SourceManager &SM) override {}
+ ArrayRef Ranges) override {}
 
-  void emitCodeContext(SourceLocation Loc,
-   DiagnosticsEngine::Level Level,
-   SmallVectorImpl& Ranges,
-   ArrayRef Hints,
-   const SourceManager &SM) override {}
+  void emitCodeContext(FullSourceLoc Loc, DiagnosticsEngine::Level Level,
+   SmallVectorImpl &Ranges,
+   ArrayRef Hints) override {}
 
-  void emitNote(SourceLocation Loc, StringRef Message,
-const SourceManager *SM) override {
+  void emitNote(FullSourceLoc Loc, StringRef Message) override {
 CXSourceLocation L;
-if (SM)
-  L = translateSourceLocation(*SM, LangOpts, Loc);
+if (Loc.hasManager())
+  L = translateSourceLocation(Loc.getManager(), LangOpts, Loc);
 else
   L = clang_getNullLocation();
 CurrentSet->appendDiagnostic(
Index: lib/Frontend/TextDiagnosticPrinter.cpp
===
--- lib/Frontend/TextDiagnosticPrinter.cpp
+++ lib/Frontend/TextDiagnosticPrinter.cpp
@@ -150,10 +150,9 @@
  "Unexpected diagnostic with no source manager");
   assert(TextDiag && "Unexpected diagnostic outside source file processing");
 
-  TextDiag->emitDiagnostic(Info.getLocation(), Level, DiagMessageStream.str(),
-   Info.getRanges(),
-   Info.getFixItHints(),
-   &Info.getSourceManager());
+  TextDiag->emitDiagnostic(
+  FullSourceLoc(Info.getLocation(), Info.getSourceManager()), Level,
+  DiagMessageStream.str(), Info.getRanges(), Info.getFixItHints());
 
   OS.flush();
 }
Index: lib/Frontend/TextDiagnostic.cpp
===
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -672,20 +672,16 @@
 
 TextDiagnostic::~TextDiagnostic() {}
 
-void
-TextDiagnostic::emitDiagnosticMessage(SourceLocation Loc,
-  PresumedLoc PLoc,
-  DiagnosticsEngine::Level Level,
-  StringRef Message,
-  ArrayRef Ranges,
-  const SourceManager *SM,
-  DiagOrStoredDiag D) {
+void TextDiagnostic::emitDiagnosticMessage(
+FullSourceLoc Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level,
+StringRef Message, ArrayRef Ranges,
+DiagOrStoredDiag D) {
   uint64_t StartOfLocationInfo = OS.tell();
 
   // Emit the location of this particular diagnostic.
   if (Loc.isValid())
-emitDiagnosticLoc(Loc, PLoc, Level, Ranges, *SM);
-  
+emitDiagnosticLoc(Loc, PLoc, Level, Ranges);
+
   if (DiagOpts->ShowColors)
 OS.resetColor();
   
@@ -787,17 +783,16 @@
 /// This includes extracting as much location information as is present for
 /// the diagnostic and printing it, as

r304984 - [sanitizer-coverage] Allow using KASAN instrumentation with sancov

2017-06-08 Thread Alexander Potapenko via cfe-commits
Author: glider
Date: Thu Jun  8 11:24:21 2017
New Revision: 304984

URL: http://llvm.org/viewvc/llvm-project?rev=304984&view=rev
Log:
[sanitizer-coverage] Allow using KASAN instrumentation with sancov

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=304984&r1=304983&r2=304984&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Jun  8 11:24:21 2017
@@ -31,8 +31,8 @@ enum : SanitizerMask {
   NotAllowedWithTrap = Vptr,
   RequiresPIE = DataFlow,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
-  SupportsCoverage =
-  Address | Memory | Leak | Undefined | Integer | Nullability | DataFlow,
+  SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
+ Integer | Nullability | DataFlow,
   RecoverableByDefault = Undefined | Integer | Nullability,
   Unrecoverable = Unreachable | Return,
   LegacyFsanitizeRecoverMask = Undefined | Integer,

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=304984&r1=304983&r2=304984&view=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Thu Jun  8 11:24:21 2017
@@ -5,6 +5,7 @@
 // CHECK-SANITIZE-COVERAGE-0: -fsanitize=address
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC


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


[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-08 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

These are part of C++17. Later, we'll get the parallel versions.


https://reviews.llvm.org/D34038

Files:
  include/numeric
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
+++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
@@ -0,0 +1,133 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op);
+
+
+#include 
+#include 
+#include 
+// #include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+//  std::cout << v.size() << " vs " << std::distance(rFirst, rLast) << std::endl;
+//  std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " "));
+//  std::cout << std::endl;
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,  5,   7,   9};
+const int pResI0[] = { 0,  1,  4,   9,  16};// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0};
+const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0};
+const int pResI2[] = { 2,  3,  6,  11,  18};// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210};
+const int pResN2[] = { 2,  1, -2,  -7, -14};// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210};
+unsigned sa = sizeof(ia) / sizeof(ia[0]);
+assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, pResN2, pResN2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
+}
+}
+
+int triangle(int n) { return n*(n+1)/2; }
+
+//  Basic sanity
+void basic_tests()
+{
+{
+std::vector v{10};
+std::fill(v.begin(), v.end(), 3);
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, std::plus<>(), id

[PATCH] D31709: [NFC] Refactor DiagnosticRenderer to use FullSourceLoc

2017-06-08 Thread Christof Douma via Phabricator via cfe-commits
christof commandeered this revision.
christof added a reviewer: sanwou01.
christof added a comment.

This refactoring was ready to land some time ago, except for a few small 
details.  It's a shame if we don't commit this refactoring, so with @sanwou01 
his agreement, I'm taking over this patch.


https://reviews.llvm.org/D31709



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


[clang-tools-extra] r304983 - [clangd] extend completion test

2017-06-08 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Jun  8 11:02:27 2017
New Revision: 304983

URL: http://llvm.org/viewvc/llvm-project?rev=304983&view=rev
Log:
[clangd] extend completion test

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

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=304983&r1=304982&r2=304983&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Thu Jun  8 11:02:27 2017
@@ -23,6 +23,32 @@ Content-Length: 148
 # CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
 # CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
 # CHECK: ]}
-Content-Length: 146
+Content-Length: 148
 
-{"jsonrpc":"2.0","id":2,"method":"shutdown"}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
+# Repeat the completion request, expect the same results.
+#
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
+# CHECK-DAG: 
{"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
+# CHECK-DAG: 
{"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","sortText":"operator=","filterText":"operator=","insertText":"operator="}
+# CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
+# CHECK: ]}
+# Update the source file and check for completions again.
+Content-Length: 226
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":2},"contentChanges":[{"text":"struct
 fancy { int (*func())(int, int); };\nint main() {\n  fancy f;\n  f.\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
+# Repeat the completion request, expect the same results.
+#
+# CHECK: {"jsonrpc":"2.0","id":3,"result":[
+# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, 
int)","sortText":"func","filterText":"func","insertText":"func"}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}


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


[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-06-08 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi updated this revision to Diff 101929.
MontyKutyi added a comment.

Just added the whole file instead of a small surrounding to be able to check 
the `DEF_TRAVERSE_DECL` macro too.


https://reviews.llvm.org/D34030

Files:
  include/clang/AST/RecursiveASTVisitor.h


Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -1795,7 +1795,7 @@
  declaration context of the *TemplateSpecializationDecl
\
  (embedded in the DEF_TRAVERSE_DECL() macro)   
\
  which contains the instantiated members of the template. */   
\
-  return true; 
\
+  ShouldVisitChildren = false; 
\
   })
 
 DEF_TRAVERSE_TMPL_SPEC_DECL(Class)


Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -1795,7 +1795,7 @@
  declaration context of the *TemplateSpecializationDecl\
  (embedded in the DEF_TRAVERSE_DECL() macro)   \
  which contains the instantiated members of the template. */   \
-  return true; \
+  ShouldVisitChildren = false; \
   })
 
 DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r304981 - [clangd] Separate authority less uris from completion tests

2017-06-08 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Jun  8 10:21:55 2017
New Revision: 304981

URL: http://llvm.org/viewvc/llvm-project?rev=304981&view=rev
Log:
[clangd] Separate authority less uris from completion tests

Added:
clang-tools-extra/trunk/test/clangd/authority-less-uri.test
  - copied, changed from r304980, 
clang-tools-extra/trunk/test/clangd/completion.test
Modified:
clang-tools-extra/trunk/test/clangd/completion.test

Copied: clang-tools-extra/trunk/test/clangd/authority-less-uri.test (from 
r304980, clang-tools-extra/trunk/test/clangd/completion.test)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/authority-less-uri.test?p2=clang-tools-extra/trunk/test/clangd/authority-less-uri.test&p1=clang-tools-extra/trunk/test/clangd/completion.test&r1=304980&r2=304981&rev=304981&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/authority-less-uri.test Thu Jun  8 
10:21:55 2017
@@ -1,6 +1,7 @@
 # RUN: clangd -run-synchronously < %s | FileCheck %s
 # It is absolutely vital that this file has CRLF line endings.
 #
+# Test authority-less URI
 Content-Length: 125
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
@@ -9,20 +10,6 @@ Content-Length: 246
 
 
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  
fake f;\n  f.\n}\n"}}}
 
-Content-Length: 148
-
-{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
-# The order of results returned by ASTUnit CodeComplete seems to be
-# nondeterministic, so we check regardless of order.
-#
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
-# CHECK-DAG: 
{"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: 
{"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","sortText":"operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
-# CHECK: ]}
 Content-Length: 146
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
@@ -34,10 +21,10 @@ Content-Length: 146
 
 Content-Length: 172
 
-{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
 # CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 Content-Length: 44

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=304981&r1=304980&r2=304981&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Thu Jun  8 10:21:55 2017
@@ -25,21 +25,4 @@ Content-Length: 148
 # CHECK: ]}
 Content-Length: 146
 
-{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
-# Test authority-less URI
-#
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
-# CHECK: ]}
-
-Content-Length: 172
-
-{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
-# Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
-#
-# CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
-# CHECK: ]}
-Content-Length: 44
-
-{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+{"j

[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304980: [clangd] Add parameter and return type information 
to completion results (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D34033?vs=101921&id=101925#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34033

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/test/clangd/completion.test


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -138,9 +138,21 @@
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
+for (CodeCompletionString::Chunk C : *CCS) {
+  switch (C.Kind) {
+  case CodeCompletionString::CK_ResultType:
+Item.detail = C.Text;
+break;
+  case CodeCompletionString::CK_Optional:
+break;
+  default:
+Item.label += C.Text;
+break;
+  }
+}
 assert(CCS->getTypedText());
-Item.label = CCS->getTypedText();
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = Item.sortText = Item.filterText = 
CCS->getTypedText();
 if (CCS->getBriefComment())
   Item.documentation = CCS->getBriefComment();
 Items->push_back(std::move(Item));
Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -5,41 +5,40 @@
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  
fake f;\n  f.\n}\n"}}}
 
 Content-Length: 148
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # The order of results returned by ASTUnit CodeComplete seems to be
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
+# CHECK-DAG: 
{"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
+# CHECK-DAG: 
{"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","sortText":"operator=","filterText":"operator=","insertText":"operator="}
+# CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
 # CHECK: ]}
 Content-Length: 146
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 
 Content-Length: 172
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 Content-Length: 44
 


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -138,9 +138,21 @@
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
+  

[clang-tools-extra] r304980 - [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Jun  8 10:11:51 2017
New Revision: 304980

URL: http://llvm.org/viewvc/llvm-project?rev=304980&view=rev
Log:
[clangd] Add parameter and return type information to completion results

Summary:
This patch adds information about the parameters and return types of completion
candidates.
Previously, for the following code:
```
struct S {
  int func(int a, double b) const;
};
```
the completer would only return the label of the candidate `func`.
Now it will also return the return type `int` and will format the label for the
candidate as `func(int a, double b) const`.

Reviewers: bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=304980&r1=304979&r2=304980&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Jun  8 10:11:51 2017
@@ -138,9 +138,21 @@ public:
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
+for (CodeCompletionString::Chunk C : *CCS) {
+  switch (C.Kind) {
+  case CodeCompletionString::CK_ResultType:
+Item.detail = C.Text;
+break;
+  case CodeCompletionString::CK_Optional:
+break;
+  default:
+Item.label += C.Text;
+break;
+  }
+}
 assert(CCS->getTypedText());
-Item.label = CCS->getTypedText();
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = Item.sortText = Item.filterText = 
CCS->getTypedText();
 if (CCS->getBriefComment())
   Item.documentation = CCS->getBriefComment();
 Items->push_back(std::move(Item));

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=304980&r1=304979&r2=304980&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Thu Jun  8 10:11:51 2017
@@ -5,9 +5,9 @@ Content-Length: 125
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  
fake f;\n  f.\n}\n"}}}
 
 Content-Length: 148
 
@@ -16,9 +16,12 @@ Content-Length: 148
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
+# CHECK-DAG: 
{"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
+# CHECK-DAG: 
{"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","sortText":"operator=","filterText":"operator=","insertText":"operator="}
+# CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
 # CHECK: ]}
 Content-Length: 146
 
@@ -26,9 +29,7 @@ Content-Length: 146
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 
 Content-Length: 172
@@ -37,9 +38,7 @@ Content-Length: 172
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insert

[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added inline comments.
This revision is now accepted and ready to land.



Comment at: test/clangd/completion.test:32
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}

krasimir wrote:
> ilya-biryukov wrote:
> > Should we repeat repeat the checks added above here too?
> This test case is about understanding 'file:/main.cpp', so I don't think 
> repeating everything would be beneficial.
Makes sense.
Testing that the output is the same on repeated runs of completion wouldn't 
probably hurt either.
But if you feel it makes tests too clunky, let's not have it here.


https://reviews.llvm.org/D34033



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


[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 101921.
krasimir marked an inline comment as done.
krasimir added a comment.

- Add sortText and filterText


https://reviews.llvm.org/D34033

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion.test


Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -5,41 +5,40 @@
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  
fake f;\n  f.\n}\n"}}}
 
 Content-Length: 148
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # The order of results returned by ASTUnit CodeComplete seems to be
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
+# CHECK-DAG: 
{"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"}
+# CHECK-DAG: 
{"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","sortText":"operator=","filterText":"operator=","insertText":"operator="}
+# CHECK-DAG: 
{"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"}
 # CHECK: ]}
 Content-Length: 146
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 
 Content-Length: 172
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"}
 # CHECK: ]}
 Content-Length: 44
 
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -138,9 +138,21 @@
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
+for (CodeCompletionString::Chunk C : *CCS) {
+  switch (C.Kind) {
+  case CodeCompletionString::CK_ResultType:
+Item.detail = C.Text;
+break;
+  case CodeCompletionString::CK_Optional:
+break;
+  default:
+Item.label += C.Text;
+break;
+  }
+}
 assert(CCS->getTypedText());
-Item.label = CCS->getTypedText();
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = Item.sortText = Item.filterText = 
CCS->getTypedText();
 if (CCS->getBriefComment())
   Item.documentation = CCS->getBriefComment();
 Items->push_back(std::move(Item));


Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -5,41 +5,40 @@
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","

[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: clangd/ClangdUnit.cpp:153
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = CCS->getTypedText();
 if (CCS->getBriefComment())

ilya-biryukov wrote:
> Should we also update sortText and filterText, which use label by default, 
> just like insertText?
Good point!



Comment at: test/clangd/completion.test:32
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}

ilya-biryukov wrote:
> Should we repeat repeat the checks added above here too?
This test case is about understanding 'file:/main.cpp', so I don't think 
repeating everything would be beneficial.


https://reviews.llvm.org/D34033



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


[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 101919.
krasimir added a comment.

- Remove optional chunks. They might contain control characters


https://reviews.llvm.org/D34033

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion.test


Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -5,41 +5,40 @@
 
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct
 fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  
fake f;\n  f.\n}\n"}}}
 
 Content-Length: 148
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # The order of results returned by ASTUnit CodeComplete seems to be
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","insertText":"bb"}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","insertText":"ccc"}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake 
&","insertText":"operator="}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","insertText":"~fake"}
+# CHECK-DAG: {"label":"f(int i, const float f) 
const","kind":2,"detail":"int","insertText":"f"}
 # CHECK: ]}
 Content-Length: 146
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}
 
 Content-Length: 172
 
 
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}
 Content-Length: 44
 
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -138,9 +138,21 @@
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
+for (CodeCompletionString::Chunk C : *CCS) {
+  switch (C.Kind) {
+  case CodeCompletionString::CK_ResultType:
+Item.detail = C.Text;
+break;
+  case CodeCompletionString::CK_Optional:
+break;
+  default:
+Item.label += C.Text;
+break;
+  }
+}
 assert(CCS->getTypedText());
-Item.label = CCS->getTypedText();
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = CCS->getTypedText();
 if (CCS->getBriefComment())
   Item.documentation = CCS->getBriefComment();
 Items->push_back(std::move(Item));


Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -5,41 +5,40 @@
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 
-Content-Length: 211
+Content-Length: 246
 
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  fake f;\n  f.\n}\n"}}}
 
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # The order of results returned b

[PATCH] D34033: [clangd] Add parameter and return type information to completion results

2017-06-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:153
 Item.kind = getKind(Result.CursorKind);
+Item.insertText = CCS->getTypedText();
 if (CCS->getBriefComment())

Should we also update sortText and filterText, which use label by default, just 
like insertText?



Comment at: test/clangd/completion.test:32
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}

Should we repeat repeat the checks added above here too?



Comment at: test/clangd/completion.test:41
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5}
-# CHECK-DAG: {"label":"bb","kind":5}
-# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","insertText":"a"}
 # CHECK: ]}

Again.
Should we repeat repeat the checks added above here too?


https://reviews.llvm.org/D34033



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


[PATCH] D33598: [libclang] [OpenCL] Expose CIndex functions for typedef and address space

2017-06-08 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304978: [libclang] Expose typedef and address space 
functions (authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D33598?vs=100404&id=101918#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33598

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/bindings/python/tests/cindex/test_type.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/tools/libclang/CXType.cpp
  cfe/trunk/tools/libclang/libclang.exports

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 41
+#define CINDEX_VERSION_MINOR 42
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3417,6 +3417,16 @@
 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
 
 /**
+ * \brief Returns the address space of the given type.
+ */
+CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
+
+/**
+ * \brief Returns the typedef name of the given type.
+ */
+CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
+
+/**
  * \brief For pointer types, returns the type of the pointee.
  */
 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
Index: cfe/trunk/tools/libclang/libclang.exports
===
--- cfe/trunk/tools/libclang/libclang.exports
+++ cfe/trunk/tools/libclang/libclang.exports
@@ -147,6 +147,7 @@
 clang_findReferencesInFileWithBlock
 clang_formatDiagnostic
 clang_free
+clang_getAddressSpace
 clang_getAllSkippedRanges
 clang_getArgType
 clang_getArrayElementType
@@ -259,6 +260,7 @@
 clang_getTypeKindSpelling
 clang_getTypeSpelling
 clang_getTypedefDeclUnderlyingType
+clang_getTypedefName
 clang_hashCursor
 clang_indexLoc_getCXSourceLocation
 clang_indexLoc_getFileLocation
Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/AddressSpaces.h"
 #include "clang/Frontend/ASTUnit.h"
 
 using namespace clang;
@@ -394,6 +395,27 @@
   return T.isLocalRestrictQualified();
 }
 
+unsigned clang_getAddressSpace(CXType CT) {
+  QualType T = GetQualType(CT);
+
+  // For non language-specific address space, use separate helper function.
+  if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) {
+return T.getQualifiers().getAddressSpaceAttributePrintValue();
+  }
+  return T.getAddressSpace();
+}
+
+CXString clang_getTypedefName(CXType CT) {
+  QualType T = GetQualType(CT);
+  const TypedefType *TT = T->getAs();
+  if (TT) {
+TypedefNameDecl *TD = TT->getDecl();
+if (TD)
+  return cxstring::createDup(TD->getNameAsString().c_str());
+  }
+  return cxstring::createEmpty();
+}
+
 CXType clang_getPointeeType(CXType CT) {
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -2162,6 +2162,12 @@
 
 return conf.lib.clang_isFunctionTypeVariadic(self)
 
+def get_address_space(self):
+return conf.lib.clang_getAddressSpace(self)
+
+def get_typedef_name(self):
+return conf.lib.clang_getTypedefName(self)
+
 def is_pod(self):
 """Determine whether this Type represents plain old data (POD)."""
 return conf.lib.clang_isPODType(self)
@@ -3665,6 +3671,11 @@
Type,
Type.from_result),
 
+  ("clang_getTypedefName",
+   [Type],
+   _CXString,
+   _CXString.from_result),
+
   ("clang_getTypeKindSpelling",
[c_uint],
_CXString,
Index: cfe/trunk/bindings/python/tests/cindex/test_type.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_type.py
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py
@@ -37,44 +37,52 @@
 assert not fields[0].type.is_const_qualified()
 assert fields[0].type.kind == TypeKind.INT
 assert fields[0].type.get_canonical().kind == TypeKind.INT
+assert fields[0].type.get_typedef_name() == ''
 
 assert fields[1].spelling == 'b'
 assert not fields[1].type.is_const_qualified()
 assert fields[1].type.kind == TypeKind.TYPEDEF
 assert fields[1].type.get_canonical().kind == TypeKind.INT
 assert fields[1].type.get_declaration().spelling == 'I'
+assert fields[1].type.get_typedef_name() == 'I'
 
 assert fields[2].spelling == 'c'
 assert not field

r304978 - [libclang] Expose typedef and address space functions

2017-06-08 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jun  8 09:22:04 2017
New Revision: 304978

URL: http://llvm.org/viewvc/llvm-project?rev=304978&view=rev
Log:
[libclang] Expose typedef and address space functions

Expose the following functions:
 - clang_getTypedefName
 - clang_getAddressSpace

Patch by Simon Perretta.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_type.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=304978&r1=304977&r2=304978&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Jun  8 09:22:04 2017
@@ -2162,6 +2162,12 @@ class Type(Structure):
 
 return conf.lib.clang_isFunctionTypeVariadic(self)
 
+def get_address_space(self):
+return conf.lib.clang_getAddressSpace(self)
+
+def get_typedef_name(self):
+return conf.lib.clang_getTypedefName(self)
+
 def is_pod(self):
 """Determine whether this Type represents plain old data (POD)."""
 return conf.lib.clang_isPODType(self)
@@ -3665,6 +3671,11 @@ functionList = [
Type,
Type.from_result),
 
+  ("clang_getTypedefName",
+   [Type],
+   _CXString,
+   _CXString.from_result),
+
   ("clang_getTypeKindSpelling",
[c_uint],
_CXString,

Modified: cfe/trunk/bindings/python/tests/cindex/test_type.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_type.py?rev=304978&r1=304977&r2=304978&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py Thu Jun  8 09:22:04 2017
@@ -37,37 +37,44 @@ def test_a_struct():
 assert not fields[0].type.is_const_qualified()
 assert fields[0].type.kind == TypeKind.INT
 assert fields[0].type.get_canonical().kind == TypeKind.INT
+assert fields[0].type.get_typedef_name() == ''
 
 assert fields[1].spelling == 'b'
 assert not fields[1].type.is_const_qualified()
 assert fields[1].type.kind == TypeKind.TYPEDEF
 assert fields[1].type.get_canonical().kind == TypeKind.INT
 assert fields[1].type.get_declaration().spelling == 'I'
+assert fields[1].type.get_typedef_name() == 'I'
 
 assert fields[2].spelling == 'c'
 assert not fields[2].type.is_const_qualified()
 assert fields[2].type.kind == TypeKind.LONG
 assert fields[2].type.get_canonical().kind == TypeKind.LONG
+assert fields[2].type.get_typedef_name() == ''
 
 assert fields[3].spelling == 'd'
 assert not fields[3].type.is_const_qualified()
 assert fields[3].type.kind == TypeKind.ULONG
 assert fields[3].type.get_canonical().kind == TypeKind.ULONG
+assert fields[3].type.get_typedef_name() == ''
 
 assert fields[4].spelling == 'e'
 assert not fields[4].type.is_const_qualified()
 assert fields[4].type.kind == TypeKind.LONG
 assert fields[4].type.get_canonical().kind == TypeKind.LONG
+assert fields[4].type.get_typedef_name() == ''
 
 assert fields[5].spelling == 'f'
 assert fields[5].type.is_const_qualified()
 assert fields[5].type.kind == TypeKind.INT
 assert fields[5].type.get_canonical().kind == TypeKind.INT
+assert fields[5].type.get_typedef_name() == ''
 
 assert fields[6].spelling == 'g'
 assert not fields[6].type.is_const_qualified()
 assert fields[6].type.kind == TypeKind.POINTER
 assert fields[6].type.get_pointee().kind == TypeKind.INT
+assert fields[6].type.get_typedef_name() == ''
 
 assert fields[7].spelling == 'h'
 assert not fields[7].type.is_const_qualified()
@@ -75,6 +82,7 @@ def test_a_struct():
 assert fields[7].type.get_pointee().kind == TypeKind.POINTER
 assert fields[7].type.get_pointee().get_pointee().kind == TypeKind.POINTER
 assert fields[7].type.get_pointee().get_pointee().get_pointee().kind == 
TypeKind.INT
+assert fields[7].type.get_typedef_name() == ''
 
 def test_references():
 """Ensure that a Type maintains a reference to a TranslationUnit."""
@@ -404,3 +412,12 @@ def test_decay():
 assert a.kind == TypeKind.INCOMPLETEARRAY
 assert a.element_type.kind == TypeKind.INT
 assert a.get_canonical().kind == TypeKind.INCOMPLETEARRAY
+
+def test_addrspace():
+"""Ensure the address space can be queried"""
+tu = get_tu('__attribute__((address_space(2))) int testInteger = 3;', 'c')
+
+testInteger = get_cursor(tu, 'testInteger')
+
+assert testInteger is not None, "Could not find testInteger."
+assert testInteger.type.get_address_space() == 2

Modified: cfe/trunk/include/clang

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304977: [clang-tidy] New checker to replace dynamic 
exception specifications (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D20693?vs=101860&id=101910#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20693

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
@@ -0,0 +1,88 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.UseNoexceptFalse, value: 0}]}" \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() ;
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void k() ;
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar()
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) ) ;
+
+#define THROW throw
+void h(void (*fp)(void) THROW(int)) THROW(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void h(void (*fp)(void) ) ;
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider removing it instead [modernize-use-noexcept]
+// CHECK-FIXES: void j() ;
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr)

[clang-tools-extra] r304977 - [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun  8 09:04:16 2017
New Revision: 304977

URL: http://llvm.org/viewvc/llvm-project?rev=304977&view=rev
Log:
[clang-tidy] New checker to replace dynamic exception specifications

Summary:
New checker to replace dynamic exception
specifications

This is an alternative to D18575 which relied on reparsing the decl to
find the location of dynamic exception specifications, but couldn't
deal with preprocessor conditionals correctly without reparsing the
entire file.

This approach uses D20428 to find dynamic exception specification
locations and handles all cases correctly.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman, alexfh

Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, 
cfe-commits, Eugene.Zelenko, etienneb

Patch by Don Hinton!

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=304976&r2=304977&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jun  8 
09:04:16 2017
@@ -22,6 +22,7 @@ add_clang_library(clangTidyModernizeModu
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
+  UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseTransparentFunctorsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=304977&r1=304976&r2=304977&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Jun  8 09:04:16 2017
@@ -28,6 +28,7 @@
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
+#include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseTransparentFunctorsCheck.h"
@@ -69,6 +70,7 @@ public:
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=304977&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp Thu Jun  
8 09:04:16 2017
@@ -0,0 +1,114 @@
+//===--- UseNoexceptCheck.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 "UseNoexceptCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+UseNoexceptCheck::UseNoexceptCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  NoexceptMacro(Options.get("ReplacementString", "")),
+  UseNoexceptFalse(Options.get("UseNoexceptFalse", true)) {}
+
+void UseNoexceptCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "ReplacementString", NoexceptMacro);
+  Options.store(Opts, "UseNoexceptFalse", UseNoexceptFalse);
+}
+
+void UseNoexceptCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Finder->a

[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 101908.
ABataev added a comment.

Removed FIXMEs and corrected comment


https://reviews.llvm.org/D33735

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/captured-statements.c
  test/CodeGenCXX/captured-statements.cpp

Index: test/CodeGenCXX/captured-statements.cpp
===
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
 void call_test_captured_linkage() {
   test_captured_linkage();
 }
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
 // CHECK-GLOBALS:   load i32, i32* @global
 // CHECK-GLOBALS:   load i32, i32* @
 // CHECK-GLOBALS:   load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -915,6 +915,10 @@
 Record.push_back(D->isConstexpr());
 Record.push_back(D->isInitCapture());
 Record.push_back(D->isPreviousDeclInSameBlockScope());
+if (auto *IPD = dyn_cast(D))
+  Record.push_back(static_cast(IPD->getParameterKind()));
+else
+  Record.push_back(0);
   }
   Record.push_back(D->getLinkageInternal());
 
@@ -1989,6 +1993,7 @@
   Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
   Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
   Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
+  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1229,6 +1229,7 @@
 VD->NonParmVarDeclBits.I

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20693#776030, @hintonda wrote:

> Great, thanks for you help.
>
> Could you commit this for me?


Sure, running tests...


https://reviews.llvm.org/D20693



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-06-08 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Great, thanks for you help.

Could you commit this for me?


https://reviews.llvm.org/D20693



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


[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64

2017-06-08 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Soft-float on the runtime environment part. I.e. non-trivial operations are 
lowered to library calls.


Repository:
  rL LLVM

https://reviews.llvm.org/D34018



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


[PATCH] D34031: [OpenCL] Diagnose some reserved types

2017-06-08 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.

Catch uses of the 'long long', 'unsigned long long', and 'long double'
reserved types.

Remove use of 'long long' in test/Misc/languageOptsOpenCL.cl; it
shouldn't have been added there in the first place as the OpenCL
specification explicitly forbids it in s6.1.4.

Initial patch by Simon Perretta.


https://reviews.llvm.org/D34031

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaType.cpp
  test/Misc/languageOptsOpenCL.cl
  test/SemaOpenCL/unsupported.cl


Index: test/SemaOpenCL/unsupported.cl
===
--- test/SemaOpenCL/unsupported.cl
+++ test/SemaOpenCL/unsupported.cl
@@ -11,3 +11,10 @@
 void no_logxor(int n) {
   int logxor = n ^^ n; // expected-error {{^^ is a reserved operator in 
OpenCL}}
 }
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+kernel void no_long_double(global long double *n) {} // expected-error {{'long 
double' is a reserved type in OpenCL}}
+
+kernel void no_long_long(global long long *n) {} // expected-error {{'long 
long' is a reserved type in OpenCL}}
+kernel void no_unsigned_long_long(global unsigned long long *n) {} // 
expected-error {{'unsigned long long' is a reserved type in OpenCL}}
Index: test/Misc/languageOptsOpenCL.cl
===
--- test/Misc/languageOptsOpenCL.cl
+++ test/Misc/languageOptsOpenCL.cl
@@ -8,14 +8,12 @@
   int v1[(__alignof(int)== 4) - 1];
   int v2[(sizeof(long) == 8) - 1];
   int v3[(__alignof(long)== 8) - 1];
-  int v4[(sizeof(long long) == 16) - 1];
-  int v5[(__alignof(long long)== 16) - 1];
-  int v6[(sizeof(float) == 4) - 1];
-  int v7[(__alignof(float)== 4) - 1];
+  int v4[(sizeof(float) == 4) - 1];
+  int v5[(__alignof(float)== 4) - 1];
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
-  int v8[(sizeof(double) == 8) - 1];
-  int v9[(__alignof(double)== 8) - 1];
+  int v6[(sizeof(double) == 8) - 1];
+  int v7[(__alignof(double)== 8) - 1];
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
-  int v10[(sizeof(half) == 2) - 1];
-  int v11[(__alignof(half) == 2) - 1];
+  int v8[(sizeof(half) == 2) - 1];
+  int v9[(__alignof(half) == 2) - 1];
 }
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1363,6 +1363,11 @@
   else
 S.Diag(DS.getTypeSpecWidthLoc(), diag::ext_c99_longlong);
 }
+else if (S.getLangOpts().OpenCL) {
+  // OpenCL v2.0 s6.1.4: 'long long' is a reserved data type.
+  S.Diag(DS.getTypeSpecWidthLoc(), diag::err_ocl_type_reserved)
+<< "long long";
+}
 break;
   }
 } else {
@@ -1382,6 +1387,11 @@
   else
 S.Diag(DS.getTypeSpecWidthLoc(), diag::ext_c99_longlong);
 }
+else if (S.getLangOpts().OpenCL) {
+  // OpenCL v2.0 s6.1.4: 'unsigned long long' is a reserved data type.
+  S.Diag(DS.getTypeSpecWidthLoc(), diag::err_ocl_type_reserved)
+<< "unsigned long long";
+}
 break;
   }
 }
@@ -1399,9 +1409,14 @@
   case DeclSpec::TST_half: Result = Context.HalfTy; break;
   case DeclSpec::TST_float: Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
-if (DS.getTypeSpecWidth() == DeclSpec::TSW_long)
+if (DS.getTypeSpecWidth() == DeclSpec::TSW_long) {
   Result = Context.LongDoubleTy;
-else
+  if (S.getLangOpts().OpenCL) {
+// OpenCL v2.0 s6.1.4: 'long double' is a reserved data type.
+S.Diag(DS.getTypeSpecWidthLoc(), diag::err_ocl_type_reserved)
+  << "long double";
+  }
+} else
   Result = Context.DoubleTy;
 break;
   case DeclSpec::TST_float128:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8156,6 +8156,8 @@
   "feature, not permitted in C++">;
 def err_type_unsupported : Error<
   "%0 is not supported on this target">;
+def err_ocl_type_reserved : Error<
+  "'%0' is a reserved type in OpenCL">;
 def err_nsconsumed_attribute_mismatch : Error<
   "overriding method has mismatched ns_consumed attribute on its"
   " parameter">;


Index: test/SemaOpenCL/unsupported.cl
===
--- test/SemaOpenCL/unsupported.cl
+++ test/SemaOpenCL/unsupported.cl
@@ -11,3 +11,10 @@
 void no_logxor(int n) {
   int logxor = n ^^ n; // expected-error {{^^ is a reserved operator in OpenCL}}
 }
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+kernel void no_long_double(global long double *n) {} // expected-error {{'long double' is a reserved type in OpenCL}}
+
+kernel void no_long_long(global long long *n) {} // expected-error {{'long long' is a reserved type in OpenCL}}
+kernel void no_unsigned_long_long(global unsigned long long *n) {} // expecte

[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-08 Thread Phil Camp via Phabricator via cfe-commits
FlameTop added inline comments.



Comment at: test/clang-tidy/misc-noexcept-move-constructor.cpp:2
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-std=c++11 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"

Could I request that exceptions be explicitly enabled here (-fexceptions) as 
the test currently fails on targets which are configured with exceptions 
disabled as default? 


https://reviews.llvm.org/D34002



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


  1   2   >