r332576 - Fix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.

2018-05-16 Thread Clement Courbet via cfe-commits
Author: courbet
Date: Wed May 16 23:46:15 2018
New Revision: 332576

URL: http://llvm.org/viewvc/llvm-project?rev=332576&view=rev
Log:
Fix rL332458: [AST] Added a helper to extract a user-friendly text of a comment.

Older gcc versions do not support raw string literals within macros.

Modified:
cfe/trunk/unittests/AST/CommentTextTest.cpp

Modified: cfe/trunk/unittests/AST/CommentTextTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentTextTest.cpp?rev=332576&r1=332575&r2=332576&view=diff
==
--- cfe/trunk/unittests/AST/CommentTextTest.cpp (original)
+++ cfe/trunk/unittests/AST/CommentTextTest.cpp Wed May 16 23:46:15 2018
@@ -58,49 +58,54 @@ For example,
this result.
 That's about it.)";
   // Two-slash comments.
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  auto Formatted = formatComment(
 R"cpp(
 // This function does this and that.
 // For example,
 //Runnning it in that case will give you
 //this result.
-// That's about it.)cpp"));
+// That's about it.)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
 
   // Three-slash comments.
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  Formatted = formatComment(
 R"cpp(
 /// This function does this and that.
 /// For example,
 ///Runnning it in that case will give you
 ///this result.
-/// That's about it.)cpp"));
+/// That's about it.)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
 
   // Block comments.
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  Formatted = formatComment(
 R"cpp(
 /* This function does this and that.
  * For example,
  *Runnning it in that case will give you
  *this result.
- * That's about it.*/)cpp"));
+ * That's about it.*/)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
 
   // Doxygen-style block comments.
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  Formatted = formatComment(
 R"cpp(
 /** This function does this and that.
   * For example,
   *Runnning it in that case will give you
   *this result.
-  * That's about it.*/)cpp"));
+  * That's about it.*/)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
 
   // Weird indentation.
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  Formatted = formatComment(
 R"cpp(
// This function does this and that.
   //  For example,
   // Runnning it in that case will give you
 //   this result.
-   // That's about it.)cpp"));
+   // That's about it.)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
   // clang-format on
 }
 
@@ -111,11 +116,12 @@ R"(\brief This is the brief part of the
 \param a something about a.
 @param b something about b.)";
 
-  EXPECT_EQ(ExpectedOutput, formatComment(
+  auto Formatted = formatComment(
 R"cpp(
 /// \brief This is the brief part of the comment.
 /// \param a something about a.
-/// @param b something about b.)cpp"));
+/// @param b something about b.)cpp");
+  EXPECT_EQ(ExpectedOutput, Formatted);
   // clang-format on
 }
 


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


[PATCH] D46998: [XRay][clang+compiler-rt] Make XRay depend on a C++ standard lib

2018-05-16 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.
dberris added reviewers: dblaikie, echristo.

This is related to http://llvm.org/PR32274.

When building with XRay, always depend on a C++ standard library.

We're doing this to automate the linking of the C++ ABI functionality
that the modes use by default. In particular, we depend on some
function-local static initialisation.

The alternative change here is to re-write the modes to only use
libc/pthreads functionality. We're choosing to do this instead as it's
minimally invasive. In the future we can revisit this when we have a
better idea as to why not depending on the C++ ABI functionality is a
better solution.


https://reviews.llvm.org/D46998

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/test/xray/TestCases/Posix/c-test.cc


Index: compiler-rt/test/xray/TestCases/Posix/c-test.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Posix/c-test.cc
@@ -0,0 +1,4 @@
+// RUN: %clang_xray -g -o %t %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+int main() {}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -713,7 +713,8 @@
   return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
-bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, 
ArgStringList &CmdArgs) {
+bool tools::addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
   if (Args.hasArg(options::OPT_shared))
 return false;
 
@@ -723,6 +724,11 @@
 for (const auto &Mode : TC.getXRayArgs().modeList())
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
 CmdArgs.push_back("-no-whole-archive");
+
+// If we're linking a non-C++ application, we'd need to link in the C++
+// runtime.
+if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
 return true;
   }
 


Index: compiler-rt/test/xray/TestCases/Posix/c-test.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Posix/c-test.cc
@@ -0,0 +1,4 @@
+// RUN: %clang_xray -g -o %t %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+int main() {}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -713,7 +713,8 @@
   return !StaticRuntimes.empty() || !NonWholeStaticRuntimes.empty();
 }
 
-bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringList &CmdArgs) {
+bool tools::addXRayRuntime(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
   if (Args.hasArg(options::OPT_shared))
 return false;
 
@@ -723,6 +724,11 @@
 for (const auto &Mode : TC.getXRayArgs().modeList())
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
 CmdArgs.push_back("-no-whole-archive");
+
+// If we're linking a non-C++ application, we'd need to link in the C++
+// runtime.
+if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46929: Fix a mangling failure on clang-cl C++17

2018-05-16 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a comment.

In https://reviews.llvm.org/D46929#1101780, @rnk wrote:

> I searched around, and I noticed that `VTableContext::getMethodVTableIndex` 
> has the same implied contract that the caller must always provide a canonical 
> declaration or things will break. It looks like it has three callers, and 
> they all do this. We should probably sink the canonicalization into this 
> helper as well and clean up the now-superfluous canonicalizations at the call 
> site.


Updated.
As I'm not sure if it's safe to use non-canonicalized CXXMethodDecl for 
EmitVirtualMemPtrThunk and CGCall, I left using the canonical decl.
For other part, non-canonical decl looks working fine to me.


Repository:
  rC Clang

https://reviews.llvm.org/D46929



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


[PATCH] D46929: Fix a mangling failure on clang-cl C++17

2018-05-16 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik updated this revision to Diff 147244.

Repository:
  rC Clang

https://reviews.llvm.org/D46929

Files:
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/PR37481.cpp

Index: test/CodeGenCXX/PR37481.cpp
===
--- /dev/null
+++ test/CodeGenCXX/PR37481.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -o /dev/null -emit-llvm -std=c++17 -triple x86_64-pc-windows-msvc %s
+
+struct Foo {
+  virtual void f();
+  virtual void g();
+};
+
+void Foo::f() {}
+void Foo::g() {}
+
+template 
+void h() {}
+
+void x() {
+  h<&Foo::f>();
+  h<&Foo::g>();
+}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -228,7 +228,6 @@
 
   const CXXRecordDecl *
   getThisArgumentTypeForMethod(const CXXMethodDecl *MD) override {
-MD = MD->getCanonicalDecl();
 if (MD->isVirtual() && !isa(MD)) {
   MethodVFTableLocation ML =
   CGM.getMicrosoftVTableContext().getMethodVFTableLocation(MD);
@@ -1320,23 +1319,21 @@
 
 CharUnits
 MicrosoftCXXABI::getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {
-  GD = GD.getCanonicalDecl();
   const CXXMethodDecl *MD = cast(GD.getDecl());
 
-  GlobalDecl LookupGD = GD;
   if (const CXXDestructorDecl *DD = dyn_cast(MD)) {
 // Complete destructors take a pointer to the complete object as a
 // parameter, thus don't need this adjustment.
 if (GD.getDtorType() == Dtor_Complete)
   return CharUnits();
 
 // There's no Dtor_Base in vftable but it shares the this adjustment with
 // the deleting one, so look it up instead.
-LookupGD = GlobalDecl(DD, Dtor_Deleting);
+GD = GlobalDecl(DD, Dtor_Deleting);
   }
 
   MethodVFTableLocation ML =
-  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(LookupGD);
+  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
   CharUnits Adjustment = ML.VFPtrOffset;
 
   // Normal virtual instance methods need to adjust from the vfptr that first
@@ -1370,7 +1367,6 @@
 return CGF.Builder.CreateConstByteGEP(This, Adjustment);
   }
 
-  GD = GD.getCanonicalDecl();
   const CXXMethodDecl *MD = cast(GD.getDecl());
 
   GlobalDecl LookupGD = GD;
@@ -1839,7 +1835,6 @@
 Address This,
 llvm::Type *Ty,
 SourceLocation Loc) {
-  GD = GD.getCanonicalDecl();
   CGBuilderTy &Builder = CGF.Builder;
 
   Ty = Ty->getPointerTo()->getPointerTo();
@@ -1878,7 +1873,7 @@
 VFunc = Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
   }
 
-  CGCallee Callee(MethodDecl, VFunc);
+  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
   return Callee;
 }
 
@@ -2737,7 +2732,6 @@
 MicrosoftCXXABI::EmitMemberFunctionPointer(const CXXMethodDecl *MD) {
   assert(MD->isInstance() && "Member function must not be static!");
 
-  MD = MD->getCanonicalDecl();
   CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();
   const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();
   CodeGenTypes &Types = CGM.getTypes();
@@ -2760,7 +2754,7 @@
   } else {
 auto &VTableContext = CGM.getMicrosoftVTableContext();
 MethodVFTableLocation ML = VTableContext.getMethodVFTableLocation(MD);
-FirstField = EmitVirtualMemPtrThunk(MD, ML);
+FirstField = EmitVirtualMemPtrThunk(MD->getCanonicalDecl(), ML);
 // Include the vfptr adjustment if the method is in a non-primary vftable.
 NonVirtualBaseAdjustment += ML.VFPtrOffset;
 if (ML.VBase)
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -825,7 +825,6 @@
 llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,
   CharUnits ThisAdjustment) {
   assert(MD->isInstance() && "Member function must not be static!");
-  MD = MD->getCanonicalDecl();
 
   CodeGenTypes &Types = CGM.getTypes();
 
@@ -1640,7 +1639,6 @@
   Address This,
   llvm::Type *Ty,
   SourceLocation Loc) {
-  GD = GD.getCanonicalDecl();
   Ty = Ty->getPointerTo()->getPointerTo();
   auto *MethodDecl = cast(GD.getDecl());
   llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, MethodDecl->getParent());
@@ -1674,7 +1672,7 @@
 VFunc = VFuncLoad;
   }
 
-  CGCallee Callee(MethodDecl, VFunc);
+  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
   return Callee;
 }
 
Index: lib/CodeGen/CGCXX.cpp
===
--- lib/CodeGen/CGCXX.cpp
+++ lib/CodeGen/CGCXX.cpp
@@ -267,7 +267,6 @@
 

[libcxx] r332571 - [libcxx] [test] Remove unused local typedef in test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp

2018-05-16 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Wed May 16 21:59:34 2018
New Revision: 332571

URL: http://llvm.org/viewvc/llvm-project?rev=332571&view=rev
Log:
[libcxx] [test] Remove unused local typedef in 
test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp

Modified:
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp?rev=332571&r1=332570&r2=332571&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp 
Wed May 16 21:59:34 2018
@@ -22,7 +22,6 @@ void
 test1()
 {
 typedef std::linear_congruential_engine LCE;
-typedef typename LCE::result_type result_type;
 LCE e1;
 LCE e2;
 e2.seed();


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


[PATCH] D46820: Fix __uuidof handling on non-type template parameter in C++17

2018-05-16 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik marked an inline comment as done.
tzik added inline comments.



Comment at: test/SemaCXX/PR24986.cpp:12
+  f<&__uuidof(0)>();
+}

thakis wrote:
> Maybe this test could be in test/SemaCXX/ms-uuid.cpp instead?
OK, moved there.


Repository:
  rC Clang

https://reviews.llvm.org/D46820



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


[PATCH] D46820: Fix __uuidof handling on non-type template parameter in C++17

2018-05-16 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik updated this revision to Diff 147238.

Repository:
  rC Clang

https://reviews.llvm.org/D46820

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
-Wno-deprecated-declarations
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
@@ -92,4 +93,16 @@
 // the previous case).
 [uuid("00A0---C000-0049"),
  uuid("00A0---C000-0049")] class C10;
+
+template 
+void F1() {
+  // Regression test for PR24986. The given GUID should just work as a pointer.
+  const GUID* q = p;
+}
+
+void F2() {
+  // The UUID should work for a non-type template parameter.
+  F1<&__uuidof(C1)>();
+}
+
 }
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6245,7 +6245,7 @@
   // -- a predefined __func__ variable
   if (auto *E = Value.getLValueBase().dyn_cast()) {
 if (isa(E)) {
-  Converted = TemplateArgument(const_cast(E));
+  Converted = TemplateArgument(ArgResult.get());
   break;
 }
 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
@@ -92,4 +93,16 @@
 // the previous case).
 [uuid("00A0---C000-0049"),
  uuid("00A0---C000-0049")] class C10;
+
+template 
+void F1() {
+  // Regression test for PR24986. The given GUID should just work as a pointer.
+  const GUID* q = p;
+}
+
+void F2() {
+  // The UUID should work for a non-type template parameter.
+  F1<&__uuidof(C1)>();
+}
+
 }
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6245,7 +6245,7 @@
   // -- a predefined __func__ variable
   if (auto *E = Value.getLValueBase().dyn_cast()) {
 if (isa(E)) {
-  Converted = TemplateArgument(const_cast(E));
+  Converted = TemplateArgument(ArgResult.get());
   break;
 }
 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46452: [sanitizer] Don't add --export-dynamic for Myriad

2018-05-16 Thread Walter Lee via Phabricator via cfe-commits
waltl updated this revision to Diff 147233.
waltl added a comment.

Address CR comments


Repository:
  rL LLVM

https://reviews.llvm.org/D46452

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -538,6 +538,11 @@
   // the option, so don't try to pass it.
   if (TC.getTriple().getOS() == llvm::Triple::Solaris)
 return true;
+  // Myriad is static linking only.  Furthermore, some versions of its
+  // linker have the bug where --export-dynamic overrides -static, so
+  // don't use --export-dynamic on that platform.
+  if (TC.getTriple().getVendor() == llvm::Triple::Myriad)
+return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
 CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -538,6 +538,11 @@
   // the option, so don't try to pass it.
   if (TC.getTriple().getOS() == llvm::Triple::Solaris)
 return true;
+  // Myriad is static linking only.  Furthermore, some versions of its
+  // linker have the bug where --export-dynamic overrides -static, so
+  // don't use --export-dynamic on that platform.
+  if (TC.getTriple().getVendor() == llvm::Triple::Myriad)
+return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
 CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D46665#1102348, @rsmith wrote:

> In https://reviews.llvm.org/D46665#1102290, @rjmccall wrote:
>
> > I believe static and dynamic linkers — at least on ELF and Mach-O — will 
> > always drop weak symbols for strong ones.  Now, I think that isn't LLVM's 
> > posted semantics for linkonce_odr, but to me that means that LLVM's 
> > semantics are inadequate, not that we should decline to take advantage of 
> > them.
> >
> > If we can't rely on that, it probably means that the type name symbol for 
> > class types always has to be linkonce_odr, even if it's for a type with a 
> > key function.
>
>
> That all makes sense to me. (But I think `weak_odr` would be more formally 
> correct, even though the symbol will never actually be discarded as it's 
> referenced from the type_info and vtable.)


Yes, of course.

> The rule that ASan is using is that if there is an `external` definition for 
> a global variable, there should not be any other definitions for that symbol, 
> which seems right given LLVM's semantics, but wrong here.

I agree.

> For now, the simplest thing to do seem to be to weaken `external` linkage to 
> `weak_odr` for the type info name.

Yes.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D45900: CodeGen: Fix invalid bitcast for lifetime.start/end

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

LGTM.


https://reviews.llvm.org/D45900



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


[libcxx] r332567 - Add void casts to suppress nodiscard on linear_congruential_engine.

2018-05-16 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Wed May 16 19:58:26 2018
New Revision: 332567

URL: http://llvm.org/viewvc/llvm-project?rev=332567&view=rev
Log:
Add void casts to suppress nodiscard on linear_congruential_engine.

Modified:
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp?rev=332567&r1=332566&r2=332567&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp 
Wed May 16 19:58:26 2018
@@ -25,7 +25,7 @@ test1()
 E e1;
 E e2;
 assert(e1 == e2);
-e1();
+(void)e1();
 e2 = e1;
 assert(e1 == e2);
 }

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp?rev=332567&r1=332566&r2=332567&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp 
Wed May 16 19:58:26 2018
@@ -25,8 +25,8 @@ test1()
 E e1;
 E e2 = e1;
 assert(e1 == e2);
-e1();
-e2();
+(void)e1();
+(void)e2();
 assert(e1 == e2);
 }
 


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


[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46665#1102413, @efriedma wrote:

> What exactly is the asan odr checker actually checking for?  The distinction 
> between common/linkonce_odr/linkonce/weak_odr/weak only affects IR 
> optimizers, not code generation.


It's checking that there is only one definition of each global variable for 
which only one definition is expected; it believes that if there is an 
`external` definition, then there should not be any other definitions.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

What exactly is the asan odr checker actually checking for?  The distinction 
between common/linkonce_odr/linkonce/weak_odr/weak only affects IR optimizers, 
not code generation.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D46834#1102407, @rsmith wrote:

> In https://reviews.llvm.org/D46834#1102395, @dexonsmith wrote:
>
> > In https://reviews.llvm.org/D46834#1102391, @rsmith wrote:
> >
> > > The policy certainly seems designed around the CLI use case. For 
> > > serialized diagnostics, it would make sense to either serialize the 
> > > snippet or enough information that the snippet can be reconstructed. And 
> > > if that can't be done, or fails to satisfy some other use case, then we 
> > > should discuss how we proceed -- for instance, we could consider having 
> > > different diagnostic messages for the case where we have a snippet and 
> > > for the case where we do not.
> >
> >
> > Right.  There are places in the IDE where there is a condensed view of all 
> > diagnostics (like a Vim location list), and others where the diagnostics 
> > are shown inline with the sources.  I think what we want is an optional 
> > auxiliary record/field in a diagnostic with that contains context for when 
> > the source context is missing, and then the IDE can choose which to 
> > display.  It's optional because most diagnostics are good enough as is for 
> > location lists.
>
>
> That sounds good to me. I think it would also make sense to use the alternate 
> form for the CLI case if the user is using `-fno-caret-diagnostics` for some 
> reason.


Yes that sounds right.


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46834#1102395, @dexonsmith wrote:

> In https://reviews.llvm.org/D46834#1102391, @rsmith wrote:
>
> > The policy certainly seems designed around the CLI use case. For serialized 
> > diagnostics, it would make sense to either serialize the snippet or enough 
> > information that the snippet can be reconstructed. And if that can't be 
> > done, or fails to satisfy some other use case, then we should discuss how 
> > we proceed -- for instance, we could consider having different diagnostic 
> > messages for the case where we have a snippet and for the case where we do 
> > not.
>
>
> Right.  There are places in the IDE where there is a condensed view of all 
> diagnostics (like a Vim location list), and others where the diagnostics are 
> shown inline with the sources.  I think what we want is an optional auxiliary 
> record/field in a diagnostic with that contains context for when the source 
> context is missing, and then the IDE can choose which to display.  It's 
> optional because most diagnostics are good enough as is for location lists.


That sounds good to me. I think it would also make sense to use the alternate 
form for the CLI case if the user is using `-fno-caret-diagnostics` for some 
reason.


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[PATCH] D46995: [test-suite] Enable CUDA complex tests with libc++ now that D25403 is resolved.

2018-05-16 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
Herald added subscribers: llvm-commits, sanjoy.
Herald added a reviewer: EricWF.

Repository:
  rT test-suite

https://reviews.llvm.org/D46995

Files:
  External/CUDA/complex.cu


Index: External/CUDA/complex.cu
===
--- External/CUDA/complex.cu
+++ External/CUDA/complex.cu
@@ -18,15 +18,10 @@
 #include 
 
 // These tests are pretty annoying to write without C++11, so we require that.
-// In addition, these tests currently don't compile with libc++, because of the
-// issue in https://reviews.llvm.org/D25403.
-//
-// TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
 //
 // In addition, these tests don't work in C++14 mode with pre-C++14 versions of
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
 #include 
 #include 


Index: External/CUDA/complex.cu
===
--- External/CUDA/complex.cu
+++ External/CUDA/complex.cu
@@ -18,15 +18,10 @@
 #include 
 
 // These tests are pretty annoying to write without C++11, so we require that.
-// In addition, these tests currently don't compile with libc++, because of the
-// issue in https://reviews.llvm.org/D25403.
-//
-// TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
 //
 // In addition, these tests don't work in C++14 mode with pre-C++14 versions of
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
 #include 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D46834#1102391, @rsmith wrote:

> In https://reviews.llvm.org/D46834#1101586, @jkorous wrote:
>
> > We reconsidered this in light of the policy - thanks for pointing that out 
> > Richard! 
> >  Just to be sure that I understand it - the policy is meant for CLI and not 
> > serialized diagnostics, right?
>
>
> The policy certainly seems designed around the CLI use case. For serialized 
> diagnostics, it would make sense to either serialize the snippet or enough 
> information that the snippet can be reconstructed. And if that can't be done, 
> or fails to satisfy some other use case, then we should discuss how we 
> proceed -- for instance, we could consider having different diagnostic 
> messages for the case where we have a snippet and for the case where we do 
> not.


Right.  There are places in the IDE where there is a condensed view of all 
diagnostics (like a Vim location list), and others where the diagnostics are 
shown inline with the sources.  I think what we want is an optional auxiliary 
record/field in a diagnostic with that contains context for when the source 
context is missing, and then the IDE can choose which to display.  It's 
optional because most diagnostics are good enough as is for location lists.


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[PATCH] D46993: [CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

2018-05-16 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, thanks!


https://reviews.llvm.org/D46993



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


[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46834#1101586, @jkorous wrote:

> We reconsidered this in light of the policy - thanks for pointing that out 
> Richard! 
>  Just to be sure that I understand it - the policy is meant for CLI and not 
> serialized diagnostics, right?


The policy certainly seems designed around the CLI use case. For serialized 
diagnostics, it would make sense to either serialize the snippet or enough 
information that the snippet can be reconstructed. And if that can't be done, 
or fails to satisfy some other use case, then we should discuss how we proceed 
-- for instance, we could consider having different diagnostic messages for the 
case where we have a snippet and for the case where we do not.


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-16 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
Herald added subscribers: llvm-commits, mgorny, sanjoy.

Previously (https://reviews.llvm.org/D46993) std::min/max didn't work in C++14 
mode with a C++11
stdlib; we'd assumed that compiler std=c++14 implied stdlib in C++14
mode.


Repository:
  rT test-suite

https://reviews.llvm.org/D46994

Files:
  External/CUDA/CMakeLists.txt
  External/CUDA/algorithm.cu
  External/CUDA/cmath.cu
  External/CUDA/complex.cu

Index: External/CUDA/complex.cu
===
--- External/CUDA/complex.cu
+++ External/CUDA/complex.cu
@@ -7,25 +7,29 @@
 //
 //===--===//
 
-#include 
-#include 
-#include 
-
 // These are loosely adapted from libc++'s tests.  In general, we don't care a
 // ton about verifying the return types or results we get, on the assumption
 // that our standard library is correct. But we care deeply about calling every
 // overload of every function (so that we verify that everything compiles).
 //
 // We do care about the results of complex multiplication / division, since
 // these use code we've written.
 
+#include 
+
 // These tests are pretty annoying to write without C++11, so we require that.
 // In addition, these tests currently don't compile with libc++, because of the
 // issue in https://reviews.llvm.org/D25403.
 //
 // TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION)
+//
+// In addition, these tests don't work in C++14 mode with pre-C++14 versions of
+// libstdc++ (compile errors in ).
+#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
+(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
+#include 
+#include 
 #include 
 
 template 
@@ -69,7 +73,7 @@
 }
 
 __device__ void test_literals() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
   using namespace std::literals::complex_literals;
 
   {
Index: External/CUDA/cmath.cu
===
--- External/CUDA/cmath.cu
+++ External/CUDA/cmath.cu
@@ -1145,7 +1145,7 @@
 assert(std::hypot(3.f, 4.) == 5);
 assert(std::hypot(3.f, 4.f) == 5);
 
-#if TEST_STD_VER > 14
+#if __cplusplus >= 201703L && STDLIB_VERSION >= 2017
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
@@ -1158,8 +1158,8 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 
-assert(std::hypot(2,3,6) == 7);
-assert(std::hypot(1,4,8) == 9);
+assert(std::hypot(2, 3, 6) == 7);
+assert(std::hypot(1, 4, 8) == 9);
 #endif
 }
 
Index: External/CUDA/algorithm.cu
===
--- External/CUDA/algorithm.cu
+++ External/CUDA/algorithm.cu
@@ -27,7 +27,7 @@
 // initializer_lists until C++14, when it gets these for free from the standard
 // library (because they're constexpr).
 __device__ void cpp14_tests() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
   assert(std::greater()(1, 0));
   assert(std::min({5, 1, 10}) == 1);
   assert(std::max({5, 1, 10}, std::less()) == 10);
Index: External/CUDA/CMakeLists.txt
===
--- External/CUDA/CMakeLists.txt
+++ External/CUDA/CMakeLists.txt
@@ -316,26 +316,31 @@
   set(_Std_LDFLAGS -std=${_Std})
   foreach(_GccPath IN LISTS GCC_PATHS)
 get_version(_GccVersion ${_GccPath})
-# libstdc++ seems not to support C++14 before version 5.0.
-if(${_Std} STREQUAL "c++14" AND ${_GccVersion} VERSION_LESS "5.0")
-  continue()
-endif()
 set(_Gcc_Suffix "libstdc++-${_GccVersion}")
 # Tell clang to use libstdc++ and where to find it.
 set(_Stdlib_CPPFLAGS -stdlib=libstdc++ -gcc-toolchain ${_GccPath})
 set(_Stdlib_LDFLAGS  -stdlib=libstdc++)
 # Add libstdc++ as link dependency.
 set(_Stdlib_Libs libstdcxx-${_GccVersion})
 
+# libstdc++ seems not to support C++14 before version 5.0.  We still
+# want to run in C++14 mode with old libstdc++s to test compiler C++14
+# with stdlib C++11, but we add a -D so that our tests can detect this.
+if (${_GccVersion} VERSION_LESS "5.0")
+  list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2011)
+else()
+  list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2014)
+endif()
+
 create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-${_Gcc_Suffix}")
   endforeach()
 
   if(HAVE_LIBCXX)
 	# Same as above, but for libc++
 	# Tell clang to use libc++
 	# We also need to add compiler's include path for cxxabi.h
 	get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
-	set(_Stdlib_CPPFLAGS -std

[PATCH] D46993: [CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

2018-05-16 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
Herald added a subscriber: sanjoy.

https://reviews.llvm.org/D46993

Files:
  clang/lib/Headers/cuda_wrappers/algorithm


Index: clang/lib/Headers/cuda_wrappers/algorithm
===
--- clang/lib/Headers/cuda_wrappers/algorithm
+++ clang/lib/Headers/cuda_wrappers/algorithm
@@ -24,28 +24,36 @@
 #ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM
 #define __CLANG_CUDA_WRAPPERS_ALGORITHM
 
-// This header defines __device__ overloads of std::min/max, but only if we're
-// <= C++11.  In C++14, these functions are constexpr, and so are implicitly
-// __host__ __device__.
+// This header defines __device__ overloads of std::min/max.
 //
-// We don't support the initializer_list overloads because
-// initializer_list::begin() and end() are not __host__ __device__ functions.
+// Ideally we'd declare these functions only if we're <= C++11.  In C++14,
+// these functions are constexpr, and so are implicitly __host__ __device__.
 //
-// When compiling in C++14 mode, we could force std::min/max to have different
-// implementations for host and device, by declaring the device overloads
-// before the constexpr overloads appear.  We choose not to do this because
-
-//  a) why write our own implementation when we can use one from the standard
-// library? and
-//  b) libstdc++ is evil and declares min/max inside a header that is included
-// *before* we include .  So we'd have to unconditionally
-// declare our __device__ overloads of min/max, but that would pollute
-// things for people who choose not to include .
+// However, the compiler being in C++14 mode does not imply that the standard
+// library supports C++14.  There is no macro we can test to check that the
+// stdlib has constexpr std::min/max.  Thus we have to unconditionally define
+// our device overloads.
+//
+// A host+device function cannot be overloaded, and a constexpr function
+// implicitly become host device if there's no explicitly host or device
+// overload preceding it.  So the simple thing to do would be to declare our
+// device min/max overloads, and then #include_next .  This way our
+// device overloads would come first, and so if we have a C++14 stdlib, its
+// min/max won't become host+device and conflict with our device overloads.
+//
+// But that also doesn't work.  libstdc++ is evil and declares std::min/max in
+// an internal header that is included *before* .  Thus by the time
+// we're inside of this file, std::min/max may already have been declared, and
+// thus we can't prevent them from becoming host+device if they're constexpr.
+//
+// Therefore we perpetrate the following hack: We mark our __device__ overloads
+// with __attribute__((enable_if(true, ""))).  This causes the signature of the
+// function to change without changing anything else about it.  (Except that
+// overload resolution will prefer it over the __host__ __device__ version
+// rather than considering them equally good).
 
 #include_next 
 
-#if __cplusplus <= 201103L
-
 // We need to define these overloads in exactly the namespace our standard
 // library uses (including the right inline namespace), otherwise they won't be
 // picked up by other functions in the standard library (e.g. functions in
@@ -60,24 +68,28 @@
 #endif
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__a, __b) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b) {
   return __a < __b ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__b, __a) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b) {
   return __a < __b ? __a : __b;
@@ -92,5 +104,4 @@
 } // namespace std
 #endif
 
-#endif // __cplusplus <= 201103L
 #endif // __CLANG_CUDA_WRAPPERS_ALGORITHM


Index: clang/lib/Headers/cuda_wrappers/algorithm
===
--- clang/lib/Headers/cuda_wrappers/algorithm
+++ clang/lib/Headers/cuda_wrappers/algorithm
@@ -24,28 +24,36 @@
 #ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM
 #define __CLANG_CUDA_WRAPPERS_ALGORITHM
 
-// This header defines __device__ overloads of std::min/max, but only if we're
-// <= C++11.  In C++14, these functions are constexpr, and so are implicitly
-// __host__ __device__.
+// This header defines __device__ overloads of std::min/max.
 //
-// We don't support the initializer_list overloads because
-// initializer_list::begin() and end() are not __host__ __device__ functions.
+// Ideally we'd declare these functions only if we're <= C++11.  In C++14,
+// these functions are constexpr, and so are implicitly __host__ __device_

[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46665#1102361, @efriedma wrote:

> The only difference between weak_odr and linkonce_odr is that the LLVM 
> optimizers can discard linkonce_odr globals.  From your description, you want 
> to remove the odr-ness, by changing the linkage to "linkonce", I think?


The odr-ness is fine; the definitions are all the same. The symbol emitted with 
the key function should be non-discardable, which is why I'm suggesting we 
change the linkage to `weak_odr` rather than changing it to `linkonce_odr`.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The only difference between weak_odr and linkonce_odr is that the LLVM 
optimizers can discard linkonce_odr globals.  From your description, you want 
to remove the odr-ness, by changing the linkage to "linkonce", I think?

That said, I don't think the usage here violates LangRef's definition of 
linkonce_odr; the "odr"-ness refers to the global's initializer, not its 
linkage.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


Re: r276514 - [cxx1z-constexpr-lambda] Make a lambda's closure type eligible as a literal-type in C++1z

2018-05-16 Thread Richard Smith via cfe-commits
On 17 February 2017 at 18:03, Richard Smith  wrote:

> On 22 July 2016 at 21:05, Faisal Vali via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: faisalv
>> Date: Fri Jul 22 23:05:19 2016
>> New Revision: 276514
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276514&view=rev
>> Log:
>> [cxx1z-constexpr-lambda] Make a lambda's closure type eligible as a
>> literal-type in C++1z
>>
>>
>> Additionally, for pre-C++1z, instead of forbidding a lambda's closure
>> type from being a literal type through circumlocutorily setting
>> HasNonLiteralTypeFieldsOrBases falsely to true -- handle lambda's more
>> directly in CXXRecordDecl::isLiteral().
>>
>> One additional small step towards implementing constexpr-lambdas.
>>
>
> I don't know if this problem started with this change, but we now accept
> this invalid code in C++14 mode:
>
> constexpr auto a = [] {};
>

This was a result of two separate bugs. I've fixed one of them, but another
remains, and can be observed in this example:

constexpr int f() { return ([]{}, 0); }
constexpr int n = f();

This is ill-formed before C++17, and yet we accept it in C++11 mode.


> Thanks to Richard Smith for his review!
>> https://reviews.llvm.org/D22662
>>
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> AST/DeclCXX.h?rev=276514&r1=276513&r2=276514&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Jul 22 23:05:19 2016
>> @@ -535,11 +535,10 @@ class CXXRecordDecl : public RecordDecl
>>  MethodTyInfo(Info) {
>>IsLambda = true;
>>
>> -  // C++11 [expr.prim.lambda]p3:
>> -  //   This class type is neither an aggregate nor a literal type.
>> +  // C++1z [expr.prim.lambda]p4:
>> +  //   This class type is not an aggregate type.
>>Aggregate = false;
>>PlainOldData = false;
>> -  HasNonLiteralTypeFieldsOrBases = true;
>>  }
>>
>>  /// \brief Whether this lambda is known to be dependent, even if its
>> @@ -1338,11 +1337,15 @@ public:
>>///
>>/// We resolve DR1361 by ignoring the second bullet. We resolve DR1452
>> by
>>/// treating types with trivial default constructors as literal types.
>> +  ///
>> +  /// Only in C++1z and beyond, are lambdas literal types.
>>bool isLiteral() const {
>>  return hasTrivialDestructor() &&
>> -   (isAggregate() || hasConstexprNonCopyMoveConstructor() ||
>> -hasTrivialDefaultConstructor()) &&
>> -   !hasNonLiteralTypeFieldsOrBases();
>> +   (!isLambda() || getASTContext().getLangOpts().CPlusPlus1z) &&
>> +   !hasNonLiteralTypeFieldsOrBases() &&
>> +   (isAggregate() || isLambda() ||
>> +hasConstexprNonCopyMoveConstructor() ||
>> +hasTrivialDefaultConstructor());
>>}
>>
>>/// \brief If this record is an instantiation of a member class,
>>
>> Modified: cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> cxx1z-constexpr-lambdas.cpp?rev=276514&r1=276513&r2=276514&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Fri Jul 22
>> 23:05:19 2016
>> @@ -1,8 +1,8 @@
>>  // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks %s
>>  // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
>> -fdelayed-template-parsing %s
>> -// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
>> -fms-extensions %s
>> -// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
>> -fdelayed-template-parsing -fms-extensions %s
>> +// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -fblocks %s
>> -DCPP14_AND_EARLIER
>>
>> +#ifndef CPP14_AND_EARLIER
>>  namespace test_constexpr_checking {
>>
>>  namespace ns1 {
>> @@ -33,4 +33,16 @@ namespace ns3 {
>>L(3); //expected-note{{non-constexpr function}}
>>  }
>>
>> -} // end ns test_constexpr_call
>> \ No newline at end of file
>> +} // end ns test_constexpr_call
>> +
>> +#endif
>> +
>> +namespace test_lambda_is_literal {
>> +#ifdef CPP14_AND_EARLIER
>> +//expected-error@+4{{not a literal type}}
>> +//expected-note@+2{{not an aggregate and has no constexpr constructors}}
>> +#endif
>> +auto L = [] { };
>> +constexpr int foo(decltype(L) l) { return 0; }
>> +
>> +}
>> \ No newline at end of file
>>
>>
>> ___
>> 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@list

[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46665#1102290, @rjmccall wrote:

> I believe static and dynamic linkers — at least on ELF and Mach-O — will 
> always drop weak symbols for strong ones.  Now, I think that isn't LLVM's 
> posted semantics for linkonce_odr, but to me that means that LLVM's semantics 
> are inadequate, not that we should decline to take advantage of them.
>
> If we can't rely on that, it probably means that the type name symbol for 
> class types always has to be linkonce_odr, even if it's for a type with a key 
> function.


That all makes sense to me. (But I think `weak_odr` would be more formally 
correct, even though the symbol will never actually be discarded as it's 
referenced from the type_info and vtable.)

The rule that ASan is using is that if there is an `external` definition for a 
global variable, there should not be any other definitions for that symbol, 
which seems right given LLVM's semantics, but wrong here.

For now, the simplest thing to do seem to be to weaken `external` linkage to 
`weak_odr` for the type info name.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46990: [Fixed Point Arithmetic] Validation Test for Saturated Multiplication

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch contains changes for multiplication on saturated _Fract types.

Since we already upcast the underlying integer for the fixed point type, we can 
do a simple check to see if the resulting value is larger or smaller than the 
max or min for the fixed point types.

This is a child of https://reviews.llvm.org/D46987


Repository:
  rC Clang

https://reviews.llvm.org/D46990

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -97,6 +97,8 @@
 a = -0.7 ## SUFFIX; \
 b = 0.9 ## SUFFIX; \
 ASSERT(sub ## ID(a, b) == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
+a = -0.5 ## SUFFIX - 0.5 ## SUFFIX; \
+ASSERT(mul ## ID(a, a) == 1.0 ## SUFFIX); \
   }
 
 int main(){
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -690,11 +690,84 @@
 bufferWidth = 128;
   }
 
-  LHSVal = Builder.CreateIntCast(LHSVal, Builder.getIntNTy(bufferWidth), isSignedResult);
-  RHSVal = Builder.CreateIntCast(RHSVal, Builder.getIntNTy(bufferWidth), isSignedResult);
+  llvm::Type *ResultTy = Builder.getIntNTy(bufferWidth);
+  LHSVal = Builder.CreateIntCast(LHSVal, ResultTy, isSignedResult);
+  RHSVal = Builder.CreateIntCast(RHSVal, ResultTy, isSignedResult);
 
   llvm::Value* MulResult = Builder.CreateMul(LHSVal, RHSVal);
   MulResult = Builder.CreateAShr(MulResult, getFixedPointFBits(Ops.Ty));
+
+  // At this point, MulResult has not been truncated yet and still has extra
+  // assigned bits we can use to check for magnitude overflows.
+  if (Ops.Ty->isSaturatedFixedPointType()) {
+llvm::Value *SatMaxVal = llvm::ConstantInt::get(
+ResultTy, getFixedPointMaxVal(Ops.Ty));
+llvm::Value *SatMinVal = llvm::ConstantInt::get(
+ResultTy, getFixedPointMinVal(Ops.Ty));
+
+unsigned FixedPointBits;
+if (Ops.Ty->isSignedFixedPointType()) {
+  FixedPointBits = getFixedPointIBits(Ops.Ty) + getFixedPointFBits(Ops.Ty) + 1;
+} else {
+  FixedPointBits = getFixedPointIBits(Ops.Ty) + getFixedPointFBits(Ops.Ty);
+}
+unsigned MSBBitShift = FixedPointBits - 1;
+
+// Number of data + sign bits used in multiplication result after
+// shifting but before truncation.
+unsigned UntruncatedBitWidth = FixedPointBits * 2;
+unsigned BitMask = (1 << UntruncatedBitWidth) - 1;
+llvm::Value *MaskedMulResult = Builder.CreateAnd(MulResult, BitMask);
+
+if (Ops.Ty->isSignedFixedPointType()) {
+  if (Ops.Ty->isAccumFixedPointType()) {
+llvm::Type *Int1Ty = llvm::Type::getInt1Ty(Ops.LHS->getContext());
+llvm::Value *LHSMSB = Builder.CreateIntCast(Builder.CreateLShr(Ops.LHS, MSBBitShift),
+Int1Ty, /*isSigned=*/true);
+llvm::Value *RHSMSB = Builder.CreateIntCast(Builder.CreateLShr(Ops.RHS, MSBBitShift),
+Int1Ty, /*isSigned=*/true);
+
+// Cap at max if both operand signs were the same and the result is greater than the
+// max possible value.
+llvm::Value *UseSatMax = Builder.CreateAnd(
+Builder.CreateICmpEQ(LHSMSB, RHSMSB),
+Builder.CreateICmpUGT(MaskedMulResult, SatMaxVal));
+
+// Cap at min if the operands were different, and the unsigned
+// respresentation of the result is greater than the maximum possible
+// unsigned value that can be represented with the resulting fixed
+// point bits. Don't use SatMaxVal here since it represents the max
+// for an signed value.
+llvm::Value *UseSatMin = Builder.CreateAnd(
+Builder.CreateXor(LHSMSB, RHSMSB),
+Builder.CreateICmpUGT(MaskedMulResult, llvm::ConstantInt::get(ResultTy, BitMask)));
+
+MulResult = Builder.CreateSelect(
+UseSatMax, SatMaxVal, Builder.CreateSelect(UseSatMin, SatMinVal, MulResult));
+  } else {
+// The only situation a _Fract overflows is if both are signed and
+// equal to -1. Signed multiplication would yield a result of -1 when
+// the result should be 1. Instead return the max possible value.
+assert(Ops.Ty->isFractFixedPointType());
+
+unsigned FractMask = (1ULL << FixedPointBits) - 1;
+llvm::Value *MaskedLHSVal = Builder.CreateAnd(LHSVal, FractMask, "Mask

[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I believe static and dynamic linkers — at least on ELF and Mach-O — will always 
drop weak symbols for strong ones.  Now, I think that isn't LLVM's posted 
semantics for linkonce_odr, but to me that means that LLVM's semantics are 
inadequate, not that we should decline to take advantage of them.

If we can't rely on that, it probably means that the type name symbol for class 
types always has to be linkonce_odr, even if it's for a type with a key 
function.


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46987: [Fixed Point Arithmetic] Validation Test for Saturated Subtraction on Signed _Fracts

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch includes the logic for subtraction on saturated _Fract types and a 
test for thm.

- Also fixed incorrect minimum value for each _Fract type
- Getters for each fixed point min and max value for a given type
- Correction when casting from a fixed point to a float. If the fixed point 
data and sign bits do not take up the whole width of the integer (ie. has 
padding), we will need to either zero out the padding or extend the sign into 
the padding if it is negative to ensure the correct floating point value is 
produced after casting.

This is a child of https://reviews.llvm.org/D46986


Repository:
  rC Clang

https://reviews.llvm.org/D46987

Files:
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h.in
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -88,6 +88,15 @@
 TYPE a = 0.7 ## SUFFIX; \
 TYPE b = 0.9 ## SUFFIX; \
 ASSERT(add ## ID(a, b) == 1.0 ## SUFFIX); \
+a = -0.7 ## SUFFIX; \
+b = -0.9 ## SUFFIX; \
+ASSERT(add ## ID(a, b) == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
+a = 0.7 ## SUFFIX; \
+b = -0.9 ## SUFFIX; \
+ASSERT(sub ## ID(a, b) == 1.0 ## SUFFIX); \
+a = -0.7 ## SUFFIX; \
+b = 0.9 ## SUFFIX; \
+ASSERT(sub ## ID(a, b) == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
   }
 
 int main(){
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -806,6 +806,11 @@
   }
   Value *VisitAsTypeExpr(AsTypeExpr *CE);
   Value *VisitAtomicExpr(AtomicExpr *AE);
+
+  // For all fixed point values, we usually do not care about the padding bits,
+  // but if we convert to another type dependent on the whole value of the
+  // underlying type, we will need to either zero extend or sign extend.
+  llvm::Value* FixedPointExtendSignToPadding(const QualType& Ty, llvm::Value* Val);
 };
 }  // end anonymous namespace.
 
@@ -1675,6 +1680,41 @@
   return true;
 }
 
+// For all fixed point values, we usually do not care about the padding bits,
+// but if we convert to another type dependent on the whole value of the
+// underlying type, we will need to either zero extend or sign extend.
+llvm::Value* ScalarExprEmitter::FixedPointExtendSignToPadding(const QualType& Ty,
+  llvm::Value* Val) {
+  assert(Ty->isFixedPointType());
+
+  llvm::Type *opTy = CGF.CGM.getTypes().ConvertType(Ty);
+  unsigned BitWidth = opTy->getIntegerBitWidth();
+  unsigned fbits = getFixedPointFBits(Ty);
+  unsigned ibits = getFixedPointIBits(Ty);
+
+  if (Ty->isSignedFixedPointType()) {
+assert((BitWidth >= fbits + ibits + 1) &&
+   "Cannot fit signed fixed point bits into integral type");
+
+unsigned ShiftBits = BitWidth - (fbits + ibits + 1);
+if (!ShiftBits) {
+  return Val;
+}
+
+return Builder.CreateAShr(Builder.CreateShl(Val, ShiftBits), ShiftBits);
+  } else {
+assert((BitWidth >= fbits + ibits) &&
+   "Cannot fit unsigned fixed point bits into integral type");
+
+unsigned ShiftBits = BitWidth - (fbits + ibits);
+if (!ShiftBits) {
+  return Val;
+}
+
+return Builder.CreateLShr(Builder.CreateShl(Val, ShiftBits), ShiftBits);
+  }
+}
+
 // VisitCastExpr - Emit code for an explicit or implicit cast.  Implicit casts
 // have to handle a more broad range of conversions than explicit casts, as they
 // handle things like function to ptr-to-function decay etc.
@@ -1894,8 +1934,12 @@
 assert(DestTy->isFloatingType());
 assert(E->getType()->isFixedPointType());
 unsigned fbits = getFixedPointFBits(E->getType());
-return Builder.CreateFDiv(EmitScalarConversion(Visit(E), E->getType(), DestTy, CE->getExprLoc()),
-  llvm::ConstantFP::get(CGF.CGM.FloatTy, (1ULL << fbits) * 1.0));
+
+llvm::Value *Val = FixedPointExtendSignToPadding(E->getType(), Visit(E));
+Val = EmitScalarConversion(Val, E->getType(), DestTy, CE->getExprLoc());
+
+return Builder.CreateFDiv(
+Val, llvm::ConstantFP::get(CGF.CGM.FloatTy, (1ULL << fbits) * 1.0));
   }
 
   case CK_IntegralCast:
@@ -3104,61 +3148,10 @@
 assert(op.LHS->getType() == op.RHS->getType());
 assert(op.LHS->getType() == opTy);
 
-llvm::Value *SatMaxVal;
-llvm::Value *SatMinVal;
-
-const auto &BT = op.Ty->getAs();
-switch (BT->getKind()) {
-  default: llvm_unreachable("Unhandled saturated signed fixed point type");
-  case BuiltinType::SatShortAccum:
- SatMaxVal = llvm::ConstantInt::get(opTy, SACCUM_MAX_AS_INT

r332544 - [analyzer] Change the warning message for GCD antipattern checker

2018-05-16 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed May 16 15:46:47 2018
New Revision: 332544

URL: http://llvm.org/viewvc/llvm-project?rev=332544&view=rev
Log:
[analyzer] Change the warning message for GCD antipattern checker

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
cfe/trunk/test/Analysis/gcdantipatternchecker_test.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp?rev=332544&r1=332543&r2=332544&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp Wed May 16 
15:46:47 2018
@@ -187,8 +187,8 @@ static void emitDiagnostics(const BoundN
 
   std::string Diagnostics;
   llvm::raw_string_ostream OS(Diagnostics);
-  OS << "Waiting on a " << Type << " with Grand Central Dispatch creates "
- << "useless threads and is subject to priority inversion; consider "
+  OS << "Waiting on a callback using a " << Type << " creates useless threads "
+ << "and is subject to priority inversion; consider "
  << "using a synchronous API or changing the caller to be asynchronous";
 
   BR.EmitBasicReport(

Modified: cfe/trunk/test/Analysis/gcdantipatternchecker_test.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/gcdantipatternchecker_test.m?rev=332544&r1=332543&r2=332544&view=diff
==
--- cfe/trunk/test/Analysis/gcdantipatternchecker_test.m (original)
+++ cfe/trunk/test/Analysis/gcdantipatternchecker_test.m Wed May 16 15:46:47 
2018
@@ -34,7 +34,7 @@ void use_semaphor_antipattern() {
   func(^{
   dispatch_semaphore_signal(sema);
   });
-  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
 }
 
 // It's OK to use pattern in tests.
@@ -54,14 +54,14 @@ void use_semaphor_antipattern_multiple_t
   func(^{
   dispatch_semaphore_signal(sema1);
   });
-  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
 
   dispatch_semaphore_t sema2 = dispatch_semaphore_create(0);
 
   func(^{
   dispatch_semaphore_signal(sema2);
   });
-  dispatch_semaphore_wait(sema2, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema2, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
 }
 
 void use_semaphor_antipattern_multiple_wait() {
@@ -71,8 +71,8 @@ void use_semaphor_antipattern_multiple_w
   dispatch_semaphore_signal(sema1);
   });
   // FIXME: multiple waits on same semaphor should not raise a warning.
-  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
-  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
+  dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
 }
 
 void warn_incorrect_order() {
@@ -80,7 +80,7 @@ void warn_incorrect_order() {
   // if out of order.
   dispatch_semaphore_t sema = dispatch_semaphore_create(0);
 
-  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
callback}}
   func(^{
   dispatch_semaphore_signal(sema);
   });
@@ -92,7 +92,7 @@ void warn_w_typedef() {
   func_w_typedef(^{
   dispatch_semaphore_signal(sema);
   });
-  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
callback using a semaphore}}
 }
 
 void warn_nested_ast() {
@@ -107,7 +107,7 @@ void warn_nested_ast() {
  dispatch_semaphore_signal(sema);
  });
   }
-  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inver

r332546 - [analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with autoreleasing variables

2018-05-16 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed May 16 15:47:05 2018
New Revision: 332546

URL: http://llvm.org/viewvc/llvm-project?rev=332546&view=rev
Log:
[analyzer] Extend ObjCAutoreleaseWriteChecker to catch block declarations with 
autoreleasing variables

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
cfe/trunk/test/Analysis/autoreleasewritechecker_test.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp?rev=332546&r1=332545&r2=332546&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp Wed 
May 16 15:47:05 2018
@@ -115,14 +115,16 @@ static void emitDiagnostics(BoundNodes &
   QualType Ty = PVD->getType();
   if (Ty->getPointeeType().getObjCLifetime() != Qualifiers::OCL_Autoreleasing)
 return;
-  const char *WarningMsg = "Write to";
+  const char *ActionMsg = "Write to";
   const auto *MarkedStmt = Match.getNodeAs(ProblematicWriteBind);
+  bool IsCapture = false;
 
   // Prefer to warn on write, but if not available, warn on capture.
   if (!MarkedStmt) {
 MarkedStmt = Match.getNodeAs(CapturedBind);
 assert(MarkedStmt);
-WarningMsg = "Capture of";
+ActionMsg = "Capture of";
+IsCapture = true;
   }
 
   SourceRange Range = MarkedStmt->getSourceRange();
@@ -130,12 +132,14 @@ static void emitDiagnostics(BoundNodes &
   MarkedStmt, BR.getSourceManager(), ADC);
   bool IsMethod = Match.getNodeAs(IsMethodBind) != nullptr;
   const char *Name = IsMethod ? "method" : "function";
+
   BR.EmitBasicReport(
   ADC->getDecl(), Checker,
-  /*Name=*/(llvm::Twine(WarningMsg)
+  /*Name=*/(llvm::Twine(ActionMsg)
 + " autoreleasing out parameter inside autorelease 
pool").str(),
   /*Category=*/"Memory",
-  (llvm::Twine(WarningMsg) + " autoreleasing out parameter inside " +
+  (llvm::Twine(ActionMsg) + " autoreleasing out parameter " +
+   (IsCapture ? "'" + PVD->getName() + "'" + " " : "") + "inside " +
"autorelease pool that may exit before " + Name + " returns; consider "
"writing first to a strong local variable declared outside of the 
block")
   .str(),
@@ -153,7 +157,7 @@ void ObjCAutoreleaseWriteChecker::checkA
   .bind(ParamBind);
 
   auto ReferencedParamM =
-  declRefExpr(to(parmVarDecl(DoublePointerParamM)));
+  declRefExpr(to(parmVarDecl(DoublePointerParamM))).bind(CapturedBind);
 
   // Write into a binded object, e.g. *ParamBind = X.
   auto WritesIntoM = binaryOperator(
@@ -169,7 +173,7 @@ void ObjCAutoreleaseWriteChecker::checkA
 ignoringParenImpCasts(ReferencedParamM));
   auto CapturedInParamM = stmt(anyOf(
   callExpr(ArgumentCaptureM),
-  objcMessageExpr(ArgumentCaptureM))).bind(CapturedBind);
+  objcMessageExpr(ArgumentCaptureM)));
 
   // WritesIntoM happens inside a block passed as an argument.
   auto WritesOrCapturesInBlockM = hasAnyArgument(allOf(
@@ -192,7 +196,8 @@ void ObjCAutoreleaseWriteChecker::checkA
 
   auto MatcherM = decl(anyOf(
   objcMethodDecl(HasParamAndWritesInMarkedFuncM).bind(IsMethodBind),
-  functionDecl(HasParamAndWritesInMarkedFuncM)));
+  functionDecl(HasParamAndWritesInMarkedFuncM),
+  blockDecl(HasParamAndWritesInMarkedFuncM)));
 
   auto Matches = match(MatcherM, *D, AM.getASTContext());
   for (BoundNodes Match : Matches)

Modified: cfe/trunk/test/Analysis/autoreleasewritechecker_test.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/autoreleasewritechecker_test.m?rev=332546&r1=332545&r2=332546&view=diff
==
--- cfe/trunk/test/Analysis/autoreleasewritechecker_test.m (original)
+++ cfe/trunk/test/Analysis/autoreleasewritechecker_test.m Wed May 16 15:47:05 
2018
@@ -265,5 +265,17 @@ void multipleErrors(NSError *__autorelea
   }];
 }
 
+typedef void (^errBlock)(NSError *__autoreleasing *error);
+
+extern void expectError(errBlock);
+
+void captureAutoreleasingVarFromBlock(NSDictionary *dict) {
+  expectError(^(NSError *__autoreleasing *err) {
+[dict enumerateKeysAndObjectsUsingBlock:^{
+  writeIntoError(err); // expected-warning{{Capture of autoreleasing out 
parameter 'err'}}
+}];
+  });
+}
+
 #endif
 


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


r332545 - [ASTMatchers] Introduce a blockDecl matcher for matching block declarations

2018-05-16 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed May 16 15:47:03 2018
New Revision: 332545

URL: http://llvm.org/viewvc/llvm-project?rev=332545&view=rev
Log:
[ASTMatchers] Introduce a blockDecl matcher for matching block declarations

Blocks can be matched just as well as functions or Objective-C methods.

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=332545&r1=332544&r2=332545&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed May 16 15:47:03 2018
@@ -124,6 +124,18 @@ accessSpecDecl()
 
 
 
+MatcherDecl>blockDeclMatcherBlockDecl>...
+Matches block 
declarations.
+
+Example matches the declaration of the nameless block printing an input
+integer.
+
+  myFunc(^(int p) {
+printf("%d", p);
+  })
+
+
+
 MatcherDecl>classTemplateDeclMatcherClassTemplateDecl>...
 Matches C++ class 
template declarations.
 
@@ -4352,6 +4364,55 @@ Example matches b (matcher = binaryOpera
 
 
 
+MatcherBlockDecl>hasAnyParameterMatcherParmVarDecl>
 InnerMatcher
+Matches any 
parameter of a function or an ObjC method declaration or a
+block.
+
+Does not match the 'this' parameter of a method.
+
+Given
+  class X { void f(int x, int y, int z) {} };
+cxxMethodDecl(hasAnyParameter(hasName("y")))
+  matches f(int x, int y, int z) {}
+with hasAnyParameter(...)
+  matching int y
+
+For ObjectiveC, given
+  @interface I - (void) f:(int) y; @end
+
+the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
+matches the declaration of method f with hasParameter
+matching y.
+
+For blocks, given
+  b = ^(int y) { printf("%d", y) };
+
+the matcher blockDecl(hasAnyParameter(hasName("y")))
+matches the declaration of the block b with hasParameter
+matching y.
+
+
+
+MatcherBlockDecl>hasParameterunsigned N, MatcherParmVarDecl>
 InnerMatcher
+Matches the n'th 
parameter of a function or an ObjC method
+declaration or a block.
+
+Given
+  class X { void f(int x) {} };
+cxxMethodDecl(hasParameter(0, hasType(varDecl(
+  matches f(int x) {}
+with hasParameter(...)
+  matching int x
+
+For ObjectiveC, given
+  @interface I - (void) f:(int) y; @end
+
+the matcher objcMethodDecl(hasParameter(0, hasName("y")))
+matches the declaration of method f with hasParameter
+matching y.
+
+
+
 MatcherBlockPointerTypeLoc>pointeeLocMatcherTypeLoc>
 Narrows PointerType (and 
similar) matchers to those where the
 pointee matches a given matcher.
@@ -5336,7 +5397,8 @@ matches 'int x = 0' in
 
 
 MatcherFunctionDecl>hasAnyParameterMatcherParmVarDecl>
 InnerMatcher
-Matches any 
parameter of a function or ObjC method declaration.
+Matches any 
parameter of a function or an ObjC method declaration or a
+block.
 
 Does not match the 'this' parameter of a method.
 
@@ -5353,6 +5415,13 @@ For ObjectiveC, given
 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
 matches the declaration of method f with hasParameter
 matching y.
+
+For blocks, given
+  b = ^(int y) { printf("%d", y) };
+
+the matcher blockDecl(hasAnyParameter(hasName("y")))
+matches the declaration of the block b with hasParameter
+matching y.
 
 
 
@@ -5393,7 +5462,7 @@ with compoundStmt()
 
 MatcherFunctionDecl>hasParameterunsigned N, MatcherParmVarDecl>
 InnerMatcher
 Matches the n'th 
parameter of a function or an ObjC method
-declaration.
+declaration or a block.
 
 Given
   class X { void f(int x) {} };
@@ -5767,7 +5836,8 @@ matches the [webView ...] message invoca
 
 
 MatcherObjCMethodDecl>hasAnyParameterMatcher

[PATCH] D46986: [Fixed Point Arithmetic] Validation Test for Fixed Point Binary Operations and Saturated Addition

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch contains tests for validating the logic behind each builtin 
operation on fixed point types and tests on addition between saturated _Fract 
types.

- More macros wer added to the FixedPoint.h header on the min and max values 
for each type which will be required for operations on saturated types.
- Updated the logic when converting between fixed point types to take into 
account saturation. Fixed point type conversions do not fall under the "usual 
arithmetic conversions" where the resulting type on a binary operation 
resulting in a fixed point type does not need to be the type of either operands.
- Rounded down _Fract literals of 1 (1.0hr, 1.0r, 1.0lr) to the respective 
maximum values for each _Fract type.

This is a child of https://reviews.llvm.org/D46979


Repository:
  rC Clang

https://reviews.llvm.org/D46986

Files:
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h.in
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Werror %s
+// RUN: %clang_cc1 -Werror  -S -emit-llvm %s -o - | lli
 
 // Check that we can use all supported binary and unary operations according to
 // clause 4.1.6 in N1169.
@@ -48,3 +48,59 @@
 ALL_OPERATIONS(short _Accum, ShortAccum);
 ALL_OPERATIONS(_Accum, Accum);
 ALL_OPERATIONS(long _Accum, LongAccum);
+
+#define ASSERT(x) if (!(x)) return 1;
+
+#define BINARY_OPS_FOR_TYPE(TYPE, ID, SUFFIX) \
+  { \
+TYPE a = 0.5 ## SUFFIX; \
+TYPE b = 0.25 ## SUFFIX; \
+ASSERT(add ## ID(a, b) == 0.75 ## SUFFIX); \
+ASSERT(sub ## ID(a, b) == 0.25 ## SUFFIX); \
+ASSERT(mul ## ID(a, b) == 0.125 ## SUFFIX); \
+ASSERT(div ## ID(b, a) == 0.5 ## SUFFIX); \
+ASSERT(shl ## ID(b, 1) == a); \
+ASSERT(shr ## ID(a, 1) == b); \
+ASSERT(lt  ## ID(b, a)); \
+ASSERT(le  ## ID(b, a)); \
+ASSERT(gt  ## ID(a, b)); \
+ASSERT(ge  ## ID(a, b)); \
+ASSERT(eq  ## ID(a, b) == 0); \
+ASSERT(ne  ## ID(a, b)); \
+ASSERT(augmented_add ## ID(a, b) == 0.75 ## SUFFIX); \
+ASSERT(augmented_sub ## ID(a, b) == 0.25 ## SUFFIX); \
+ASSERT(augmented_mul ## ID(a, b) == 0.125 ## SUFFIX); \
+ASSERT(augmented_div ## ID(b, a) == 0.5 ## SUFFIX); \
+ASSERT(augmented_shl ## ID(b, 1) == a); \
+ASSERT(augmented_shr ## ID(a, 1) == b); \
+  }
+
+#define BINARY_OPS(TYPE, ID, SUFFIX) \
+  BINARY_OPS_FOR_TYPE(TYPE, ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(signed TYPE, Signed ## ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(unsigned TYPE, Unsigned ## ID, u ## SUFFIX); \
+  BINARY_OPS_FOR_TYPE(_Sat TYPE, Sat ## ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(_Sat signed TYPE, SatSigned ## ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(_Sat unsigned TYPE, SatUnsigned ## ID, u ## SUFFIX);
+
+#define FRACT_SAT_BINARY_OPS(TYPE, ID, SUFFIX) \
+  { \
+TYPE a = 0.7 ## SUFFIX; \
+TYPE b = 0.9 ## SUFFIX; \
+ASSERT(add ## ID(a, b) == 1.0 ## SUFFIX); \
+  }
+
+int main(){
+  BINARY_OPS(short _Fract, ShortFract, hr);
+  BINARY_OPS(_Fract, Fract, r);
+  BINARY_OPS(long _Fract, LongFract, lr);
+  BINARY_OPS(short _Accum, ShortAccum, hk);
+  BINARY_OPS(_Accum, Accum, k);
+  BINARY_OPS(long _Accum, LongAccum, lk);
+
+  FRACT_SAT_BINARY_OPS(_Sat short _Fract, SatShortFract, hr);
+  FRACT_SAT_BINARY_OPS(_Sat _Fract, SatFract, r);
+  FRACT_SAT_BINARY_OPS(_Sat long _Fract, SatLongFract, lr);
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1254,8 +1254,12 @@
   return FixedPointTy;
 }
 
-/// \brief Handle arithmethic conversion with fixed point types.  Helper
-/// function of UsualArithmeticConversions().
+/// \brief Handle arithmethic conversion with fixed point types. The usual
+/// arithmetic conversions do not apply to fixed point type conversions between
+/// integers or other fixed point types due to potential loss of precision.
+/// For this case of fixed point types, the resulting type in a binary operation
+/// does not need to be exactly one of the 2 operand types.
+/// Implemented according to Clause 6.3.1.8 of ISO/IEC JTC1 SC22 WG14 N1169.
 static QualType handleFixedPointConversion(Sema &S, ExprResult &LHS,
ExprResult &RHS, QualType LHSType,
QualType RHSType,
@@ -1267,30 +1271,25 @@
   bool RHSFixed = RHSType->isFixedPointType();
 
   if (LHSFixed && RHSFixed) {
-// Cast up the smaller operand to the bigger
+bool LHSSigned = LHSType->isSignedFixedPointType();
+bool RHSSigned = R

[libcxx] r332543 - Condition usage of locale stdlib functions on Android API version

2018-05-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed May 16 15:40:12 2018
New Revision: 332543

URL: http://llvm.org/viewvc/llvm-project?rev=332543&view=rev
Log:
Condition usage of locale stdlib functions on Android API version

Some *_l functions were not available in some versions of Bionic. This CL
checks that the NDK version supports the functions, and if not, falls back
on the corresponding functions that don't take a locale.

Patch by Tom Anderson!

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

Modified:
libcxx/trunk/include/support/android/locale_bionic.h

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=332543&r1=332542&r2=332543&view=diff
==
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Wed May 16 15:40:12 
2018
@@ -27,14 +27,14 @@ extern "C" {
 #if defined(__ANDROID__)
 
 #include 
-
-// Android gained most locale aware functions in L (API level 21)
-#if __ANDROID_API__ < 21
+#include 
 #include 
-#endif
-
-// The strto* family was added in O (API Level 26)
-#if __ANDROID_API__ < 26
+// In NDK versions later than 16, locale-aware functions are provided by
+// legacy_stdlib_inlines.h
+#if __NDK_MAJOR__ <= 16
+#if __ANDROID_API__ < 21
+#include 
+#elif __ANDROID_API__ < 26
 
 #if defined(__cplusplus)
 extern "C" {
@@ -61,6 +61,7 @@ inline _LIBCPP_ALWAYS_INLINE long strtol
 
 #endif // __ANDROID_API__ < 26
 
+#endif // __NDK_MAJOR__ <= 16
 #endif // defined(__ANDROID__)
 
 #endif // defined(__BIONIC__)


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


[PATCH] D46982: Do not enable RTTI with -fexceptions, for PS4

2018-05-16 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava created this revision.
Sunil_Srivastava added a reviewer: filcab.
Herald added a subscriber: cfe-commits.

NFC for targets other than PS4.

This patch is a change in behavior for PS4, in that PS4 will no longer enable
RTTI when -fexceptions is specified (RTTI and Exceptions are disabled by default
on PS4).  RTTI will remain disabled except for types being thrown or caught.
Also, '-fexceptions -fno-rtti' (previously prohibited on PS4) is now accepted,
as it is for other targets.

This patch removes some PS4 specific code, making the code cleaner.

Also, in the test file rtti-options.cpp, PS4 tests where the behavior is the
same as the generic x86_64-linux are removed, making the test cleaner.


Repository:
  rC Clang

https://reviews.llvm.org/D46982

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/ToolChain.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/rtti-options.cpp

Index: test/Driver/rtti-options.cpp
===
--- test/Driver/rtti-options.cpp
+++ test/Driver/rtti-options.cpp
@@ -1,11 +1,11 @@
 // Check that we emit warnings/errors for different combinations of
-// exceptions, rtti, and vptr sanitizer flags when targeting the PS4.
+// exceptions, rtti, and vptr sanitizer flags for generic (unknown) x86 linux,
+// and for PS4 when its behaviour differs from the generic x86-linux.
 // No warnings/errors should be emitted for unknown, except if combining
 // the vptr sanitizer with -fno-rtti
 
 // Special cases: -fcxx-exceptions in C code should warn about unused arguments
 // We should also not have any rtti-related arguments
-// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
 // RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
 
 // Make sure we keep the last -frtti/-fno-rtti argument
@@ -22,39 +22,26 @@
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // Exceptions + no/default rtti
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR-CXX %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // In C++, -fexceptions implies -fcxx-exceptions
-// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR %s
-// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s
 // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // -frtti + exceptions
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
 
 // -f{no-,}rtti/default
-// RUN: %clang -### -c -target x86_64-scei-ps4 -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
-// RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s
 // RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s
 // RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
 
 // CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions'
 // CHECK-SAN-WARN: implicitly disabling vptr sanitizer because rtti was

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-16 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGException.cpp:1164
+  CurrentFuncletPad);
+  llvm::BasicBlock *CatchStartBlock = nullptr;
+  if (EHPersonality::get(*this).isWasmPersonality()) {

Maybe this should be called WasmCatchStartBlock?



Comment at: lib/CodeGen/CGException.cpp:1173
+cast(CatchStartBlock->getFirstNonPHI());
+CurrentFuncletPad = CPI;
+  }

Hmm, why is this done? Won't RestoreCurrentFuncletPad undo this?



Comment at: lib/CodeGen/CGException.cpp:1241-1245
+while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) {
+  llvm::BranchInst *BI = cast(TI);
+  assert(BI->isConditional());
+  RethrowBlock = BI->getSuccessor(1);
+}

This seems pretty fragile, why is this guaranteed to work? Could we maintain a 
map from CatchSwitchInst to catch-all block?


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D46665: [Itanium] Emit type info names with external linkage.

2018-05-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This is causing ASan's ODR violation detector to fire. I think the problematic 
case looks like this:

TU 1:

  struct X;
  /*...*/ typeid(X*); /*...*/

TU 2:

  struct X { virtual void f(); };
  void X::f() {}

Now, TU 1 will emit a `linkonce_odr` definition of the `_ZTS` symbol, and TU 2 
will emit a strong definition of it. ASan doesn't like that.

There's no way we can know that there will be a strong definition of the 
typeinfo name at the point where we emit the tentative copy for the pointer 
`type_info`. It seems to me there are two things we could do about this:

1. decide this is not a bug and suppress the ASan ODR checker report, or
2. decide this is a bug, and only emit `linkonce_odr` typeinfo names for 
pointers to incomplete classes, not for incomplete classes themselves (this 
would mean that `operator==` etc would do the wrong thing for users who use the 
 to inspect the pointee type of a pointer type info; in particular, 
we'd need to check that ubsan's vptr sanitizer can cope with this -- right now 
it assumes that it can compare the type name address except on iOS64, just like 
libc++'s `` does).


Repository:
  rC Clang

https://reviews.llvm.org/D46665



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


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-05-16 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling added a comment.

If there are no objections to this change, may I request a commit based on the 
approval that @jfb provided?


Repository:
  rC Clang

https://reviews.llvm.org/D46024



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


[PATCH] D44352: [Concepts] Constrained template parameters

2018-05-16 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 147190.
saar.raz added a comment.

Adjusted to changes in dependent patches.


Repository:
  rC Clang

https://reviews.llvm.org/D44352

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/TemplateBase.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/ODRHash.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaCXXScopeSpec.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.param/p10.cpp
  test/Parser/cxx-constrained-template-param-with-partial-id.cpp
  test/Parser/cxx-constrained-template-param.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -750,6 +750,10 @@
 }
 
 bool CursorVisitor::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
+
   // Visit the default argument.
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
 if (TypeSourceInfo *DefArg = D->getDefaultArgumentInfo())
@@ -898,6 +902,10 @@
 bool CursorVisitor::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
   if (VisitDeclaratorDecl(D))
 return true;
+
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
   
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
 if (Expr *DefArg = D->getDefaultArgument())
@@ -929,7 +937,11 @@
 bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
-  
+
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
+
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited() &&
   VisitTemplateArgumentLoc(D->getDefaultArgument()))
 return true;
Index: test/Parser/cxx-constrained-template-param.cpp
===
--- /dev/null
+++ test/Parser/cxx-constrained-template-param.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ %s -verify
+// expected-no-diagnostics
+
+namespace type
+{
+  template
+  concept C1 = true;
+
+  template
+  using A = T[10];
+
+  using a = A;
+
+  namespace ns {
+template
+concept C2 = true;
+  }
+
+  template requires sizeof(T1) <= sizeof(T2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
+
+namespace non_type
+{
+  template
+  concept C1 = true;
+
+  template
+  int A = v;
+
+  int& a = A<1>;
+
+  namespace ns {
+template
+concept C2 = true;
+  }
+
+  template requires sizeof(v1) <= sizeof(v2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
+
+namespace temp
+{
+  template
+  struct test1 { };
+
+  template
+  struct test2 { };
+
+  template typename T>
+  concept C1 = true;
+
+  template
+  using A = TT;
+
+  using a = A;
+
+  namespace ns {
+template typename... TT>
+concept C2 = true;
+  }
+
+  template
+requires sizeof(TT1) <= sizeof(TT2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
\ No newline at end of file
Index: test/Parser/cxx-constrained-template-param-with-partial-id.cpp
===
--- /dev/null
+++ test/Parser/cxx-constrained-template-param-with-partial-id.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ %s -verify
+
+template
+concept C1 = true;
+
+template // expected-error {{concept 'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
+using badA = T[10];
+
+template T>
+using A = T[10];
+
+using a = A;
+
+namespace ns {
+  template
+  concept C2 = true;
+}
+
+template // expected-error 2{{concept 'C2' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
+requires sizeof(T1) <= sizeof(T2)
+struct badB { };
+
+template T1, ::ns::C2 T2>
+  requires sizeof(T1) <= sizeof(T2)
+struct B { };
+
+using b = B;
+
+template // expected-error {{concept 'C2' requires more than 1 template argument; provide the 

[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-05-16 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

In https://reviews.llvm.org/D46652#1101952, @kimgr wrote:

>




> - Can you test what happens when you do `clang-cl.exe /Yc stdafx.h /Tp 
> stdafx.h`, i.e. compile the header directly as C++ code and generate .pch 
> from it?  The normal MSVC modus operandi is to have stdafx.h included in all 
> source files (with /Yu) and stdafx.cpp to generate it (with /Yc). That 
> stdafx.cpp file serves no purpose, so I've played this trick to generate PCH 
> from the header directly. If it works, it might also be useful for your tests.

It isn't always the case that the .cpp file serves no purpose.  It's true that 
the MS project generators give you this setup but we've seen many projects over 
the years that use a regular source file with code in it to generate the PCH.  
The object file generated during PCH create can have real code and the compiler 
can take advantage of that fact by compiling less code in the compilation units 
that use the PCH (for example not instantiating some COMDAT data/functions that 
are know to be in the create object).  This can speed up compilations 
significantly in some cases.

I am not sure about your command:  `clang-cl.exe /Yc stdafx.h /Tp stdafx.h`.  
The space makes this a compile with just /Yc (no through header).  This patch 
doesn't address /Yc without the through header.  Something like clang-cl /Yc 
/Tpstdafx.h would probably work if/when that is implemented.

> - I think the current skip-warning is over-specific -- what if I put an 
> inline function before my PCH include? A global variable? A #pragma? Or am I 
> misunderstanding what skipping does? It seems to me that any non-comment 
> tokens before the PCH #include should raise a warning.

Not any tokens.  The through header "feature" compiles all the code in the file 
up to the through header.  So normally you are used to seeing just comments and 
#include .  That's one usage but your PCH can be created from a 
source like this:

  #include 
  #ifdef FOO
  #define FOO1
  #endif
  #include 
  #include 

If the files using the PCH also have exactly this 'pch prefix' there is no 
problem and certainly no warning is expected.  Some compilers also check that 
this 'prefix' matches and won't use a PCH if it doesn't match. The MS compiler 
does not do this but they do give a warning if a #define is seen that doesn't 
match the definition in the PCH (that may be new I hadn't noticed it before you 
mentioned it).  It's a sign that the user is likely doing something wrong so a 
warning is probably warranted.   We can do some simple checks here but I 
suppose the user is most interested in compilation speed when using a PCH.

> - I find the "through header" terminology is a little hard to interpret, but 
> I did find it on MSDN, so maybe it's well established.

Sorry about the terminology.  I've been responsible for emulating this PCH 
mechanism for many years so I may be one of the few that understands it.  I did 
try to keep that terminology out of the diagnostics but I don't really have a 
better name for through header.

Thanks for taking a look at this.


https://reviews.llvm.org/D46652



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


[PATCH] D43357: [Concepts] Function trailing requires clauses

2018-05-16 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 147188.
saar.raz added a comment.

- Fixed handling of empty/non-expression after trailing requires keyword.
- Unified satisfaction check for templated/non-templated constraint exprs


Repository:
  rC Clang

https://reviews.llvm.org/D43357

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/ODRHash.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/class.derived/class.virtual/p6.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
  test/CXX/concepts-ts/dcl.dcl/lit.cfg.py
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/lit.cfg.py
  test/CXX/concepts-ts/dcl/dcl.decl/p3.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/mixed-constraints.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p4.cpp
  test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
  test/CXX/concepts-ts/over/over.over/p4.cpp

Index: test/CXX/concepts-ts/over/over.over/p4.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/over/over.over/p4.cpp
@@ -0,0 +1,56 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+template
+concept AtLeast2 = sizeof(T) >= 2;
+
+template
+concept AtMost8 = sizeof(T) <= 8;
+
+int foo() requires AtLeast2 && AtMost8 {
+  return 0;
+}
+
+double foo() requires AtLeast2 {
+  return 0.0;
+}
+
+char bar() requires AtLeast2 { // expected-note {{possible target for call}}
+  return 1.0;
+}
+
+short bar() requires AtLeast2 && AtMost8 { // expected-note {{possible target for call}} expected-note {{candidate function}}
+  return 0.0;
+}
+
+int bar() requires AtMost8 && AtLeast2 { // expected-note {{possible target for call}} expected-note {{candidate function}}
+  return 0.0;
+}
+
+char baz() requires AtLeast2 {
+  return 1.0;
+}
+
+short baz() requires AtLeast2 && AtMost8 {
+  return 0.0;
+}
+
+int baz() requires AtMost8 && AtLeast2 {
+  return 0.0;
+}
+
+long baz() requires AtMost8 && AtLeast2 && AtLeast2 {
+  return 3.0;
+}
+
+void a() {
+  static_assert(is_same_v);
+  static_assert(is_same_v); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error{{call to 'bar' is ambiguous}}
+  static_assert(is_same_v);
+}
\ No newline at end of file
Index: test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
@@ -0,0 +1,65 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+namespace templates
+{
+  template
+  concept AtLeast1 = sizeof(T) >= 1;
+
+  template
+  int foo(T t) requires sizeof(T) == 4 { // expected-note {{candidate function}}
+return 0;
+  }
+
+  template
+  char foo(T t) requires AtLeast1 { // expected-note {{candidate function}}
+return 'a';
+  }
+
+  template
+  double foo(T t) requires AtLeast1 && sizeof(T) <= 2 {
+return 'a';
+  }
+
+  void bar() {
+static_assert(is_same_v); // expected-error {{call to 'foo' is ambiguous}}
+static_assert(is_same_v);
+  }
+}
+
+namespace non_template
+{
+  template
+  concept AtLeast2 = sizeof(T) >= 2;
+
+  template
+  concept AtMost8 = sizeof(T) <= 8;
+
+  int foo() requires AtLeast2 && AtMost8 {
+return 0;
+  }
+
+  double foo() requires AtLeast2 {
+return 0.0;
+  }
+
+  double baz() req

[PATCH] D46979: [Fixed Point Arithmetic] Test for Conversion Between Valid Builtin Types

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch contains changes and a test for checking that fixed point types can 
be converted between all other valid types. Fixed point types can be converted 
between floating point types, integral types, and other fixed point types.

This is a child of https://reviews.llvm.org/D46963


Repository:
  rC Clang

https://reviews.llvm.org/D46979

Files:
  include/clang/AST/OperationKinds.def
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_all_conversions.c

Index: test/Frontend/fixed_point_all_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_all_conversions.c
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -Werror %s
+
+// Test for conversions between fixed point types and all other valid types.
+
+// Conversion from one type to another type
+#define CONVERT(FROM_TYPE, FROM_ID, TO_TYPE, TO_ID) \
+  TO_TYPE FROM_ID ## _to_ ## TO_ID (FROM_TYPE x) { return x; }
+
+// Conversion between 2 types
+#define CONVERT_COMBINATION(TYPE1, ID1, TYPE2, ID2) \
+  CONVERT(TYPE1, ID1, TYPE2, ID2) \
+  CONVERT(TYPE2, ID2, TYPE1, ID1)
+
+// Conversion between one type and floating point types
+#define CONVERT_BETWEEN_FLOATS(TYPE, ID) \
+  CONVERT_COMBINATION(TYPE, ID, float, Float) \
+  CONVERT_COMBINATION(TYPE, ID, double, Double)
+
+// Conversion between one type and an integral type with differant signage
+#define CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, INT_TYPE, INT_ID) \
+  CONVERT_COMBINATION(TYPE, ID, INT_TYPE, INT_ID) \
+  CONVERT_COMBINATION(TYPE, ID, signed INT_TYPE, Signed ## INT_ID) \
+  CONVERT_COMBINATION(TYPE, ID, unsigned INT_TYPE, Unsigned ## INT_ID)
+
+// Conversion between one type and all integral types
+#define CONVERT_BETWEEN_INTEGRALS(TYPE, ID) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, char, Char) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, short, Short) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, int, Int) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, long, Long) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, long long, LongLong)
+
+// Conversion between one type and a fixed point type with different saturation
+#define CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_COMBINATION(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_COMBINATION(TYPE, ID, _Sat FIXED_TYPE, Sat ## FIXED_ID)
+
+// Conversion between one type and a fixed point type with different signage
+#define CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, signed FIXED_TYPE, Signed ## FIXED_ID) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, unsigned FIXED_TYPE, Unsigned ## FIXED_ID)
+
+// Convert between one type and all fixed point types.
+// Add "Type" to the end of the ID to avoid multiple definitions of a function
+// if the Type is a fixed point type.
+#define CONVERT_BETWEEN_FIXED_POINT(TYPE, ID) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, _Fract, FractType) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, _Accum, AccumType)
+
+// Convert between one type and all other types
+#define CONVERT_BETWEEN_ALL_TYPES(TYPE, ID) \
+  CONVERT_BETWEEN_FLOATS(TYPE, ID) \
+  CONVERT_BETWEEN_INTEGRALS(TYPE, ID) \
+  CONVERT_BETWEEN_FIXED_POINT(TYPE, ID)
+
+#define CONVERT_FIXED_POINT_TYPE_WITH_SAT(TYPE, ID) \
+  CONVERT_BETWEEN_ALL_TYPES(TYPE, ID) \
+  CONVERT_BETWEEN_ALL_TYPES(_Sat TYPE, Sat ## ID)
+
+#define CONVERT_FIXED_POINT_TYPE(TYPE, ID) \
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(TYPE, ID) \
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(signed TYPE, Signed ## ID) \
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(unsigned TYPE, Unsigned ## ID)
+
+CONVERT_FIXED_POINT_TYPE(short _Fract, ShortFract);
+CONVERT_FIXED_POINT_TYPE(_Fract, Fract);
+CONVERT_FIXED_POINT_TYPE(long _Fract, LongFract);
+
+CONVERT_FIXED_POINT_TYPE(short _Accum, ShortAccum);
+CONVERT_FIXED_POINT_TYPE(_Accum, Accum);
+CONVERT_FIXED_POINT_TYPE(long _Accum, LongAccum);
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -321,6 +321,7 @@
 const LocationContext *LCtx = Pred->getLocationContext();
 
 switch (CastE->getCastKind()) {
+  case CK_FloatingToFixedPoint: llvm_unreachable("CK_FloatingToFixedPoint");
   case CK_FixedPointToFloating: llvm_unreachable("Unimplemented logic for CK_FixedPointToFloating");
   case CK_IntegralToFixedPoint

[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2018-05-16 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 147187.
saar.raz added a comment.

- Adjusted constraint normalization to piecewise constraint substitution
- Normalized constraints are now represented as described in the standard (a 
non-substituted expression along with a list of "template arguments").


Repository:
  rC Clang

https://reviews.llvm.org/D41910

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.normal/p1.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a = false; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a = true; // expected-error{{variable template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+bool b = false;
+
+template requires C1 && sizeof(T) <= 10
+bool b = true;
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c = false;
+
+template requires C1
+bool c = true;
+
+template
+bool d = false;
+
+template
+bool d = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template requires C1
+bool e = false;
+
+template
+bool e = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template
+constexpr int f = 1;
+
+template requires C1 && C2
+constexpr int f = 2;
+
+template requires C1 || C2
+constexpr int f = 3;
+
+static_assert(f == 2);
+static_assert(f == 3);
+static_assert(f == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a() { return false; } // expected-note {{candidate function [with T = unsigned int]}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a() { return true; } // expected-note {{candidate function [with T = unsigned int]}}
+
+bool av = a(); // expected-error {{call to 'a' is ambiguous}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+constexpr bool b() { return false; }
+
+template requires C1 && sizeof(T) <= 10
+constexpr bool b() { return true; }
+
+static_assert(b());
+static_assert(!b());
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c() { return false; }
+
+template requires C1
+bool c() { return true; }
+
+template requires C1
+constexpr bool d() { return false; }
+
+template
+constexpr bool d() { return true; }
+
+static_assert(!d());
+
+template
+constexpr int e() { return 1; }
+
+template requires C1 && C2
+constexpr int e() { return 2; }
+
+template requires C1 || C2
+constexpr int e() { return 3; }
+
+static_assert(e() == 2);
+static_assert(e() == 3);
+static_assert(e() == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+class A{}; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+class A{}; // expected-error{{class template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+class B{};
+
+template requires C1 && sizeof(T) <= 10
+class B{};
+
+template
+con

Re: r332458 - [AST] Added a helper to extract a user-friendly text of a comment.

2018-05-16 Thread Galina Kistanova via cfe-commits
Also few other builders are affected:

http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test
http://lab.llvm.org:8011/builders/clang-lld-x86_64-2stage
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu


Thanks

Galina

On Wed, May 16, 2018 at 12:58 PM, Galina Kistanova 
wrote:

> Hello Ilya,
>
> This commit broke build step for couple of our builders:
>
> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/8541
> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu
>
> . . .
> FAILED: 
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o
>
> /usr/bin/c++   -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0
> -DGTEST_LANG_CXX11=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/unittests/AST
> -I/home/buildslave/buildslave1a/clang-with-lto-
> ubuntu/llvm.src/tools/clang/unittests/AST -I/home/buildslave/
> buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/include
> -Itools/clang/include -Iinclude -I/home/buildslave/
> buildslave1a/clang-with-lto-ubuntu/llvm.src/include -I/home/buildslave/
> buildslave1a/clang-with-lto-ubuntu/llvm.src/utils/unittest/googletest/include
> -I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/utils/unittest/googlemock/include
> -fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
> -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
> -Wno-comment -ffunction-sections -fdata-sections -fno-common
> -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG
> -Wno-variadic-macros -fno-exceptions -fno-rtti -MD -MT
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o
> -MF tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o.d
> -o tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o
> -c /home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.
> src/tools/clang/unittests/AST/CommentTextTest.cpp
> /home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.
> src/tools/clang/unittests/AST/CommentTextTest.cpp:62:1: error:
> unterminated raw string
>  R"cpp(
>  ^
> . . .
>
> Please have a look?
>
> The builder was already red and did not send notifications.
>
> Thanks
>
> Galina
>
>
>
> On Wed, May 16, 2018 at 5:30 AM, Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Wed May 16 05:30:09 2018
>> New Revision: 332458
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=332458&view=rev
>> Log:
>> [AST] Added a helper to extract a user-friendly text of a comment.
>>
>> Summary:
>> The helper is used in clangd for documentation shown in code completion
>> and storing the docs in the symbols. See D45999.
>>
>> This patch reuses the code of the Doxygen comment lexer, disabling the
>> bits that do command and html tag parsing.
>> The new helper works on all comments, including non-doxygen comments.
>> However, it does not understand or transform any doxygen directives,
>> i.e. cannot extract brief text, etc.
>>
>> Reviewers: sammccall, hokein, ioeric
>>
>> Reviewed By: ioeric
>>
>> Subscribers: mgorny, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D46000
>>
>> Added:
>> cfe/trunk/unittests/AST/CommentTextTest.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/CommentLexer.h
>> cfe/trunk/include/clang/AST/RawCommentList.h
>> cfe/trunk/lib/AST/CommentLexer.cpp
>> cfe/trunk/lib/AST/RawCommentList.cpp
>> cfe/trunk/unittests/AST/CMakeLists.txt
>>
>> Modified: cfe/trunk/include/clang/AST/CommentLexer.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> AST/CommentLexer.h?rev=332458&r1=332457&r2=332458&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/CommentLexer.h (original)
>> +++ cfe/trunk/include/clang/AST/CommentLexer.h Wed May 16 05:30:09 2018
>> @@ -281,6 +281,11 @@ private:
>>/// command, including command marker.
>>SmallString<16> VerbatimBlockEndCommandName;
>>
>> +  /// If true, the commands, html tags, etc will be parsed and reported
>> as
>> +  /// separate tokens inside the comment body. If false, the comment
>> text will
>> +  /// be parsed into text and newline tokens.
>> +  bool ParseCommands;
>> +
>>/// Given a character reference name (e.g., "lt"), return the
>> character that
>>/// it stands for (e.g., "<").
>>StringRef resolveHTMLNamedCharacterReference(StringRef Name) const;
>> @@ -315,12 +320,11 @@ private:
>>/// Eat string matching regexp \code \s*\* \endcode.
>>void skipLineStartingDecorations();
>>
>> -  /// Lex stuff inside comments.  CommentEnd should be set correctly.
>> +  /// Lex comment text, including commands if ParseCommands is set to
>> true.
>>void lexCommentText(Token &T);
>>
>> -  void setupAndLexVerbatimBlock(Token &T,
>> -const char *Text

[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I should probably add some tests for the implicit deduction guides, too.


https://reviews.llvm.org/D46975



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


[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-16 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.

Great, LGTM!


https://reviews.llvm.org/D46747



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


[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 147184.
jkorous added a comment.
This revision is now accepted and ready to land.

After some internal discussion we agreed that we can simplify things and get 
consistent behaviour by using dot everywhere in diagnostics.

This is pretty much revert of r219124 + update of tests.


https://reviews.llvm.org/D46747

Files:
  AST/DeclBase.cpp
  Basic/VersionTuple.cpp
  Misc/ast-print-objectivec.m
  Parse/ParseDecl.cpp
  Sema/availability-guard-format.mm
  SemaObjC/attr-availability-1.m
  clang/Basic/VersionTuple.h

Index: SemaObjC/attr-availability-1.m
===
--- SemaObjC/attr-availability-1.m
+++ SemaObjC/attr-availability-1.m
@@ -25,10 +25,10 @@
 // rdar://11475360
 @interface B : A
 - (void)method; // NOTE: we expect 'method' to *not* inherit availability.
-- (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on macOS (10_4 vs. 10_3)}}
+- (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on macOS (10.4 vs. 10.3)}}
 - (void)overridden2 __attribute__((availability(macosx,introduced=10_2)));
 - (void)overridden3 __attribute__((availability(macosx,deprecated=10_4)));
-- (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on macOS (10_3 vs. 10_2)}}
+- (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on macOS (10.3 vs. 10.2)}}
 - (void)overridden5 __attribute__((availability(macosx,introduced=10_3)));
 - (void)overridden6 __attribute__((availability(macosx,unavailable))); // expected-warning{{overriding method cannot be unavailable on macOS when its overridden method is available}}
 @end
Index: Sema/availability-guard-format.mm
===
--- /dev/null
+++ Sema/availability-guard-format.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability -fdiagnostics-parseable-fixits -fsyntax-only -verify %s
+
+// Testing that even for source code using '_' as a delimiter in availability version tuple '.' is actually used in diagnostic output as a delimiter.
+
+@interface foo
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been explicitly marked partial here}}
+@end
+
+int main() {
+[foo method_bar]; // \
+// expected-warning {{'method_bar' is only available on macOS 10.12 or newer}} \
+// expected-note {{enclose 'method_bar' in an @available check to silence this warning}} \
+// CHECK: "fix-it:.*if (@available(macOS 10.12, *))"
+return 0;
+}
Index: Misc/ast-print-objectivec.m
===
--- Misc/ast-print-objectivec.m
+++ Misc/ast-print-objectivec.m
@@ -30,7 +30,7 @@
 // CHECK: @end
 
 // CHECK: @interface I(CAT)
-// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2)));
+// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @implementation I
Index: Parse/ParseDecl.cpp
===
--- Parse/ParseDecl.cpp
+++ Parse/ParseDecl.cpp
@@ -762,8 +762,10 @@
 ///
 /// version:
 ///   simple-integer
-///   simple-integer ',' simple-integer
-///   simple-integer ',' simple-integer ',' simple-integer
+///   simple-integer '.' simple-integer
+///   simple-integer '_' simple-integer
+///   simple-integer '.' simple-integer '.' simple-integer
+///   simple-integer '_' simple-integer '_' simple-integer
 VersionTuple Parser::ParseVersionTuple(SourceRange &Range) {
   Range = SourceRange(Tok.getLocation(), Tok.getEndLoc());
 
@@ -841,7 +843,7 @@
   return VersionTuple();
 }
 
-return VersionTuple(Major, Minor, (AfterMajorSeparator == '_'));
+return VersionTuple(Major, Minor);
   }
 
   const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
@@ -872,7 +874,7 @@
 return VersionTuple();
   }
   ConsumeToken();
-  return VersionTuple(Major, Minor, Subminor, (AfterMajorSeparator == '_'));
+  return VersionTuple(Major, Minor, Subminor);
 }
 
 /// Parse the contents of the "availability" attribute.
Index: Basic/VersionTuple.cpp
===
--- Basic/VersionTuple.cpp
+++ Basic/VersionTuple.cpp
@@ -29,11 +29,11 @@
  const VersionTuple &V) {
   Out << V.getMajor();
   if (Optional Minor = V.getMinor())
-Out << (V.usesUnderscores() ? '_' : '.') << *Minor;
+Out << '.' << *Minor;
   if (Optional Subminor = V.getSubminor())
-Out << (V.usesUndersc

Re: [clang-tools-extra] r332363 - [clangd] Populate #include insertions as additional edits in completion items.

2018-05-16 Thread Eric Liu via cfe-commits
r332520 fixed the broken build in clangd.

On Wed, May 16, 2018 at 9:48 PM Eric Liu  wrote:

> Looking... sorry that I missed the email from this bot.
>
> On Wed, May 16, 2018 at 9:43 PM Galina Kistanova 
> wrote:
>
>> Hello Eric,
>>
>> This commit broke one of our builders:
>> http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399
>>
>> . . .
>> 387.403 [725/64/4163] Building CXX object
>> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
>> FAILED:
>> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
>>
>> /usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>> -Itools/clang/tools/extra/clangd
>> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
>> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
>> -Itools/clang/include -Iinclude
>> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/include
>> -fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
>> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
>> -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
>> -Wno-comment -ffunction-sections -fdata-sections -fno-common
>> -Woverloaded-virtual -fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions
>> -fno-rtti -MD -MT
>> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
>> -MF
>> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o.d
>> -o
>> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
>> -c
>> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp
>> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:
>> In function ‘clang::clangd::SignatureHelp
>> clang::clangd::signatureHelp(clang::clangd::PathRef, const
>> clang::tooling::CompileCommand&, const clang::PrecompiledPreamble*,
>> llvm::StringRef, clang::clangd::Position,
>> llvm::IntrusiveRefCntPtr,
>> std::shared_ptr)’:
>> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:1127:37:
>> error: invalid initialization of reference of type ‘const
>> clang::clangd::{anonymous}::SemaCompleteInput&’ from expression of type
>> ‘’
>>  std::move(PCHs)});
>>  ^
>> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:710:6:
>> error: in passing argument 3 of ‘bool
>> clang::clangd::{anonymous}::semaCodeComplete(std::unique_ptr,
>> const clang::CodeCompleteOptions&, const
>> clang::clangd::{anonymous}::SemaCompleteInput&,
>> std::unique_ptr*)’
>>
>>  bool semaCodeComplete(std::unique_ptr Consumer,
>>   ^
>> . . .
>>
>> Please have a look?
>>
>> It is not good idea to keep the bot red for too long. This hides new
>> problem which later hard to track down.
>>
>> Thanks
>>
>>
>> Galina
>>
>>
>>
>> On Tue, May 15, 2018 at 8:29 AM, Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ioeric
>>> Date: Tue May 15 08:29:32 2018
>>> New Revision: 332363
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=332363&view=rev
>>> Log:
>>> [clangd] Populate #include insertions as additional edits in completion
>>> items.
>>>
>>> Summary:
>>> o Remove IncludeInsertion LSP command.
>>> o Populate include insertion edits synchromously in completion items.
>>> o Share the code completion compiler instance and precompiled preamble
>>> to get existing inclusions in main file.
>>> o Include insertion logic lives only in CodeComplete now.
>>> o Use tooling::HeaderIncludes for inserting new includes.
>>> o Refactored tests.
>>>
>>> Reviewers: sammccall
>>>
>>> Reviewed By: sammccall
>>>
>>> Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D46497
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> clang-tools-extra/trunk/clangd/CodeComplete.cpp
>>> clang-tools-extra/trunk/clangd/CodeComplete.h
>>> clang-tools-extra/trunk/clangd/Headers.cpp
>>> clang-tools-extra/trunk/clangd/Headers.h
>>> clang-tools-extra/trunk/clangd/Protocol.h
>>> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
>>> clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=332363&r1=332362&r2=332363&view=diff
>>>
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 15 08:29

[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.

Based off of 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0433r2.html


https://reviews.llvm.org/D46975

Files:
  include/deque
  test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp


Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,51 @@
+//===--===//
+//
+// 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
+// XFAIL: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+
+int main()
+{
+   
+{
+   const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+   const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -1461,6 +1465,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ >
+deque(_InputIterator, _InputIterator)
+  -> deque::value_type, _Alloc>;
+
+template::value, void>::type
+ >
+deque(_InputIterator, _InputIterator, _Alloc)
+  -> deque::value_type, _Alloc>;
+#endif
+
+
 template 
 deque<_Tp, _Allocator>::deque(size_type __n)
 {


Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,51 @@
+//===--===//
+//
+// 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
+// XFAIL: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+
+int main()
+{
+	
+{
+	const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+	const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -1461,6 +1465,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+  

[clang-tools-extra] r332520 - Second attempt to fix buildbot failure caused by r332363

2018-05-16 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 16 13:31:38 2018
New Revision: 332520

URL: http://llvm.org/viewvc/llvm-project?rev=332520&view=rev
Log:
Second attempt to fix buildbot failure caused by r332363

http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26501

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=332520&r1=332519&r2=332520&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed May 16 13:31:38 2018
@@ -1067,10 +1067,11 @@ SignatureHelp signatureHelp(PathRef File
   Options.IncludeMacros = false;
   Options.IncludeCodePatterns = false;
   Options.IncludeBriefComments = false;
+  std::vector PreambleInclusions = {}; // Unused for signatureHelp
   semaCodeComplete(llvm::make_unique(Options, Result),
Options,
-   {FileName, Command, Preamble, std::vector(),
-Contents, Pos, std::move(VFS), std::move(PCHs)});
+   {FileName, Command, Preamble, PreambleInclusions, Contents,
+Pos, std::move(VFS), std::move(PCHs)});
   return Result;
 }
 


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


[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

LGTM but my review was fairly superficial.




Comment at: utils/hmaptool/hmaptool:55
+# The number of buckets must be a power of two.
+if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+raise SystemExit("error: %s: invalid number of buckets" % (

bruno wrote:
> jkorous wrote:
> > Wouldn't it be simpler to use modulo 2?
> > 
> > ```
> > if num_buckets % 2 == 0
> > ```
> We want it to be a power of two, not just a multiple.
Of course! Sorry, my mistake.



Comment at: utils/hmaptool/hmaptool:155
+raise ArgumentError
+return 1 if value == 0 else 2**(value - 1).bit_length()
+

Thanks for teaching me bit_length()!


https://reviews.llvm.org/D46485



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


[PATCH] D46942: Add vfs::FileSystem::getRealPath

2018-05-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 147167.
ioeric added a comment.

- Add vfs::FileSystem::getRealPath; change getCanonicalName to use getRealPath


Repository:
  rC Clang

https://reviews.llvm.org/D46942

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/FileManager.cpp
  lib/Basic/VirtualFileSystem.cpp


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -139,6 +139,11 @@
   return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
 }
 
+std::error_code FileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return errc::operation_not_permitted;
+}
+
 bool FileSystem::exists(const Twine &Path) {
   auto Status = status(Path);
   return Status && Status->exists();
@@ -236,6 +241,8 @@
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 };
 
 } // namespace
@@ -274,6 +281,12 @@
   return llvm::sys::fs::set_current_path(Path);
 }
 
+std::error_code
+RealFileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return llvm::sys::fs::real_path(Path, Output);
+}
+
 IntrusiveRefCntPtr vfs::getRealFileSystem() {
   static IntrusiveRefCntPtr FS = new RealFileSystem();
   return FS;
Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -534,23 +534,9 @@
 
   StringRef CanonicalName(Dir->getName());
 
-#ifdef LLVM_ON_UNIX
-  char CanonicalNameBuf[PATH_MAX];
-  if (realpath(Dir->getName().str().c_str(), CanonicalNameBuf))
+  SmallString CanonicalNameBuf;
+  if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
 CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#else
-  SmallString<256> CanonicalNameBuf(CanonicalName);
-  llvm::sys::fs::make_absolute(CanonicalNameBuf);
-  llvm::sys::path::native(CanonicalNameBuf);
-  // We've run into needing to remove '..' here in the wild though, so
-  // remove it.
-  // On Windows, symlinks are significantly less prevalent, so removing
-  // '..' is pretty safe.
-  // Ideally we'd have an equivalent of `realpath` and could implement
-  // sys::fs::canonical across all the platforms.
-  llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true);
-  CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#endif
 
   CanonicalDirNames.insert(std::make_pair(Dir, CanonicalName));
   return CanonicalName;
Index: include/clang/Basic/VirtualFileSystem.h
===
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -248,6 +248,12 @@
   /// Get the working directory of this file system.
   virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
 
+  /// Gets real path of \p Path e.g. collapse all . and .. patterns, resolve
+  /// symlinks. For real file system, this uses `llvm::sys::fs::real_path`.
+  /// This returns errc::operation_not_permitted if not implemented by 
subclass.
+  virtual std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const;
+
   /// Check whether a file exists. Provided for convenience.
   bool exists(const Twine &Path);
 


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -139,6 +139,11 @@
   return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
 }
 
+std::error_code FileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return errc::operation_not_permitted;
+}
+
 bool FileSystem::exists(const Twine &Path) {
   auto Status = status(Path);
   return Status && Status->exists();
@@ -236,6 +241,8 @@
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 };
 
 } // namespace
@@ -274,6 +281,12 @@
   return llvm::sys::fs::set_current_path(Path);
 }
 
+std::error_code
+RealFileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return llvm::sys::fs::real_path(Path, Output);
+}
+
 IntrusiveRefCntPtr vfs::getRealFileSystem() {
   static IntrusiveRefCntPtr FS = new RealFileSystem();
   return FS;
Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib

[PATCH] D46863: [X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

2018-05-16 Thread David Kreitzer via Phabricator via cfe-commits
DavidKreitzer added a comment.

This looks good to me, Craig. I am not worried about the constant folding 
issue, as I think constant folding these conversion intrinsics (assuming 
round-to-nearest) is a perfectly valid optimization in the absence of 
FENV_ACCESS. (FWIW, we don't do this constant folding in icc, but that is only 
because we have never gotten around to implementing it.) I am also not worried 
about the spurious 'inexact' exceptions that the changes to the mask intrinsics 
will cause.


Repository:
  rC Clang

https://reviews.llvm.org/D46863



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


[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-05-16 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

I've done some terrible things with MSVC PCHs over the years, so I'll pile on 
some more questions:

- Can you test what happens when you do `clang-cl.exe /Yc stdafx.h /Tp 
stdafx.h`, i.e. compile the header directly as C++ code and generate .pch from 
it?  The normal MSVC modus operandi is to have stdafx.h included in all source 
files (with /Yu) and stdafx.cpp to generate it (with /Yc). That stdafx.cpp file 
serves no purpose, so I've played this trick to generate PCH from the header 
directly. If it works, it might also be useful for your tests.
- I think the current skip-warning is over-specific -- what if I put an inline 
function before my PCH include? A global variable? A #pragma? Or am I 
misunderstanding what skipping does? It seems to me that any non-comment tokens 
before the PCH #include should raise a warning.
- I find the "through header" terminology is a little hard to interpret, but I 
did find it on MSDN, so maybe it's well established.

I'll try to look more at this patch in context later.


https://reviews.llvm.org/D46652



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


[PATCH] D45702: [clang-tidy] Add a new check, readability-simplify-subscript-expr, that simplifies subscript expressions.

2018-05-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in r332519, thank you for the patch!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[clang-tools-extra] r332519 - Add a new check, readability-simplify-subscript-expr, that diagnoses array subscript expressions that can be simplified.

2018-05-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed May 16 13:12:06 2018
New Revision: 332519

URL: http://llvm.org/viewvc/llvm-project?rev=332519&view=rev
Log:
Add a new check, readability-simplify-subscript-expr, that diagnoses array 
subscript expressions that can be simplified.

Currently, diagnoses code that calls container.data()[some_index] when the 
container exposes a suitable operator[]() method that can be used directly.

Patch by Shuai Wang.

Added:

clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-subscript-expr.rst

clang-tools-extra/trunk/test/clang-tidy/readability-simplify-subscript-expr.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.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/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=332519&r1=332518&r2=332519&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Wed May 16 
13:12:06 2018
@@ -25,6 +25,7 @@ add_clang_library(clangTidyReadabilityMo
   RedundantSmartptrGetCheck.cpp
   RedundantStringInitCheck.cpp
   SimplifyBooleanExprCheck.cpp
+  SimplifySubscriptExprCheck.cpp
   StaticAccessedThroughInstanceCheck.cpp
   StaticDefinitionInAnonymousNamespaceCheck.cpp
   StringCompareCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=332519&r1=332518&r2=332519&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Wed May 16 13:12:06 2018
@@ -32,6 +32,7 @@
 #include "RedundantStringCStrCheck.h"
 #include "RedundantStringInitCheck.h"
 #include "SimplifyBooleanExprCheck.h"
+#include "SimplifySubscriptExprCheck.h"
 #include "StaticAccessedThroughInstanceCheck.h"
 #include "StaticDefinitionInAnonymousNamespaceCheck.h"
 #include "StringCompareCheck.h"
@@ -72,6 +73,8 @@ public:
 "readability-redundant-function-ptr-dereference");
 CheckFactories.registerCheck(
 "readability-redundant-member-init");
+CheckFactories.registerCheck(
+"readability-simplify-subscript-expr");
 CheckFactories.registerCheck(
 "readability-static-accessed-through-instance");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp?rev=332519&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/SimplifySubscriptExprCheck.cpp 
Wed May 16 13:12:06 2018
@@ -0,0 +1,76 @@
+//===--- SimplifySubscriptExprCheck.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 "SimplifySubscriptExprCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+static const char kDefaultTypes[] =
+"::std::basic_string;::std::basic_string_view;::std::vector;::std::array";
+
+SimplifySubscriptExprCheck::SimplifySubscriptExprCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context), Types(utils::options::parseStringList(
+ Options.get("Types", kDefaultTypes))) 
{
+}
+
+void SimplifySubscriptExprCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  const auto TypesMatcher = hasUnqualifiedDesugaredType(
+  recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
+  llvm::SmallVector(Types.begin(), Types.end()));
+
+  Finder->addMatcher(
+  arraySubscriptExpr(hasBase(ignoringParenImpCasts(
+  cxxMemberCallExpr(
+  has(memberEx

[clang-tools-extra] r332518 - [clang-move] Fix a potential bug where realpath doesn't work on VFS.

2018-05-16 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 16 13:10:10 2018
New Revision: 332518

URL: http://llvm.org/viewvc/llvm-project?rev=332518&view=rev
Log:
[clang-move] Fix a potential bug where realpath doesn't work on VFS.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=332518&r1=332517&r2=332518&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed May 16 13:10:10 2018
@@ -95,12 +95,16 @@ std::string MakeAbsolutePath(const Sourc
   llvm::sys::path::parent_path(AbsolutePath.str()));
   if (Dir) {
 StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
-SmallVector AbsoluteFilename;
-llvm::sys::path::append(AbsoluteFilename, DirName,
-llvm::sys::path::filename(AbsolutePath.str()));
-return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size())
-.str();
+// FIXME: getCanonicalName might fail to get real path on VFS.
+if (llvm::sys::path::is_absolute(DirName)) {
+  SmallVector AbsoluteFilename;
+  llvm::sys::path::append(AbsoluteFilename, DirName,
+  llvm::sys::path::filename(AbsolutePath.str()));
+  return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size())
+  .str();
+}
   }
+  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
   return AbsolutePath.str();
 }
 


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


[PATCH] D46659: [clang-tidy/google-readability-casting] Disable check for Objective-C++

2018-05-16 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332516: [clang-tidy/google-readability-casting] Disable 
check for Objective-C++ (authored by benhamilton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46659

Files:
  clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm

Index: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
@@ -100,7 +100,8 @@
   }
 
   // The rest of this check is only relevant to C++.
-  if (!getLangOpts().CPlusPlus)
+  // We also disable it for Objective-C++.
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC1 || getLangOpts().ObjC2)
 return;
   // Ignore code inside extern "C" {} blocks.
   if (!match(expr(hasAncestor(linkageSpecDecl())), *CastExpr, *Result.Context)
Index: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
===
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
@@ -0,0 +1,179 @@
+// RUN: clang-tidy %s -checks=-*,google-readability-casting -- \
+// RUN:   -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+bool g() { return false; }
+
+enum Enum { Enum1 };
+struct X {};
+struct Y : public X {};
+
+void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
+
+  typedef const char *Typedef1;
+  typedef const char *Typedef2;
+  Typedef1 t1;
+  (Typedef2)t1;
+  (const char*)t1;
+  (Typedef1)cpc;
+
+  typedef char Char;
+  char *pc;
+  Char *pChar = (Char*)pc;
+
+  (Char)*cpc;
+
+  (char)*pChar;
+
+  (const char*)cpv;
+
+  char *pc2 = (char*)(cpc + 33);
+
+  const char &crc = *cpc;
+  char &rc = (char&)crc;
+
+  char &rc2 = (char&)*cpc;
+
+  char ** const* const* ppcpcpc;
+  char c = (char)ppcpcpc;
+
+  char ***pppc = (char***)*(ppcpcpc);
+
+  char ***pppc2 = (char***)(*ppcpcpc);
+
+  char *pc5 = (char*)(const char*)(cpv);
+
+  int b1 = (int)b;
+  b1 = (const int&)b;
+
+  b1 = (int) b;
+
+  b1 = (int) b;
+
+  b1 = (int) (b);
+
+  b1 = (int) (b);
+
+  Y *pB = (Y*)pX;
+  Y &rB = (Y&)*pX;
+
+  const char *pc3 = (const char*)cpv;
+
+  char *pc4 = (char*)cpv;
+
+  b1 = (int)Enum1;
+
+  Enum e = (Enum)b1;
+
+  int b2 = int(b);
+  int b3 = static_cast(b);
+  int b4 = b;
+  double aa = a;
+  (void)b2;
+  return (void)g();
+}
+
+template 
+void template_function(T t, int n) {
+  int i = (int)t;
+}
+
+template 
+struct TemplateStruct {
+  void f(T t, int n) {
+int k = (int)t;
+  }
+};
+
+void test_templates() {
+  template_function(1, 42);
+  template_function(1.0, 42);
+  TemplateStruct().f(1, 42);
+  TemplateStruct().f(1.0, 42);
+}
+
+extern "C" {
+void extern_c_code(const char *cpc) {
+  char *pc = (char*)cpc;
+}
+}
+
+#define CAST(type, value) (type)(value)
+void macros(double d) {
+  int i = CAST(int, d);
+}
+
+enum E { E1 = 1 };
+template 
+struct A {
+  // Usage of template argument e = E1 is represented as (E)1 in the AST for
+  // some reason. We have a special treatment of this case to avoid warnings
+  // here.
+  static const E ee = e;
+};
+struct B : public A {};
+
+
+void overloaded_function();
+void overloaded_function(int);
+
+template
+void g(Fn fn) {
+  fn();
+}
+
+void function_casts() {
+  typedef void (*FnPtrVoid)();
+  typedef void (&FnRefVoid)();
+  typedef void (&FnRefInt)(int);
+
+  g((void (*)())overloaded_function);
+  g((void (*)())&overloaded_function);
+  g((void (&)())overloaded_function);
+
+  g((FnPtrVoid)overloaded_function);
+  g((FnPtrVoid)&overloaded_function);
+  g((FnRefVoid)overloaded_function);
+
+  FnPtrVoid fn0 = (void (*)())&overloaded_function;
+  FnPtrVoid fn1 = (void (*)())overloaded_function;
+  FnPtrVoid fn1a = (FnPtrVoid)overloaded_function;
+  FnRefInt fn2 = (void (&)(int))overloaded_function;
+  auto fn3 = (void (*)())&overloaded_function;
+  auto fn4 = (void (*)())overloaded_function;
+  auto fn5 = (void (&)(int))overloaded_function;
+
+  void (*fn6)() = (void (*)())&overloaded_function;
+  void (*fn7)() = (void (*)())overloaded_function;
+  void (*fn8)() = (FnPtrVoid)overloaded_function;
+  void (&fn9)(int) = (void (&)(int))overloaded_function;
+
+  void (*correct1)() = static_cast(overloaded_function);
+  FnPtrVoid correct2 = static_cast(&overloaded_function);
+  FnRefInt correct3 = static_cast(overloaded_function);
+}
+
+struct S {
+S(const char *);
+};
+struct ConvertibleToS {
+  operator S() const;
+};
+struct ConvertibleToSRef {
+  operator const S&() const;
+};
+
+

[clang-tools-extra] r332516 - [clang-tidy/google-readability-casting] Disable check for Objective-C++

2018-05-16 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Wed May 16 13:07:19 2018
New Revision: 332516

URL: http://llvm.org/viewvc/llvm-project?rev=332516&view=rev
Log:
[clang-tidy/google-readability-casting] Disable check for Objective-C++

Summary:
Previously, `google-readability-casting` was disabled for Objective-C.

The Google Objective-C++ style allows both Objective-C and
C++ style in the same file. Since clang-tidy doesn't have a good
way to allow multiple styles per file, this disables the
check for Objective-C++.

Test Plan: New tests added. Ran tests with:
  % make -j16 check-clang-tools
  Before diff, confirmed tests failed:
  https://reviews.llvm.org/P8081
  After diff, confirrmed tests passed.

Reviewers: alexfh, Wizard, hokein, stephanemoore

Reviewed By: alexfh, Wizard, stephanemoore

Subscribers: stephanemoore, cfe-commits, bkramer, klimek

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

Added:
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=332516&r1=332515&r2=332516&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Wed May 
16 13:07:19 2018
@@ -100,7 +100,8 @@ void AvoidCStyleCastsCheck::check(const
   }
 
   // The rest of this check is only relevant to C++.
-  if (!getLangOpts().CPlusPlus)
+  // We also disable it for Objective-C++.
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC1 || getLangOpts().ObjC2)
 return;
   // Ignore code inside extern "C" {} blocks.
   if (!match(expr(hasAncestor(linkageSpecDecl())), *CastExpr, *Result.Context)

Added: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm?rev=332516&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm Wed 
May 16 13:07:19 2018
@@ -0,0 +1,179 @@
+// RUN: clang-tidy %s -checks=-*,google-readability-casting -- \
+// RUN:   -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0
+
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+bool g() { return false; }
+
+enum Enum { Enum1 };
+struct X {};
+struct Y : public X {};
+
+void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
+
+  typedef const char *Typedef1;
+  typedef const char *Typedef2;
+  Typedef1 t1;
+  (Typedef2)t1;
+  (const char*)t1;
+  (Typedef1)cpc;
+
+  typedef char Char;
+  char *pc;
+  Char *pChar = (Char*)pc;
+
+  (Char)*cpc;
+
+  (char)*pChar;
+
+  (const char*)cpv;
+
+  char *pc2 = (char*)(cpc + 33);
+
+  const char &crc = *cpc;
+  char &rc = (char&)crc;
+
+  char &rc2 = (char&)*cpc;
+
+  char ** const* const* ppcpcpc;
+  char c = (char)ppcpcpc;
+
+  char ***pppc = (char***)*(ppcpcpc);
+
+  char ***pppc2 = (char***)(*ppcpcpc);
+
+  char *pc5 = (char*)(const char*)(cpv);
+
+  int b1 = (int)b;
+  b1 = (const int&)b;
+
+  b1 = (int) b;
+
+  b1 = (int) b;
+
+  b1 = (int) (b);
+
+  b1 = (int) (b);
+
+  Y *pB = (Y*)pX;
+  Y &rB = (Y&)*pX;
+
+  const char *pc3 = (const char*)cpv;
+
+  char *pc4 = (char*)cpv;
+
+  b1 = (int)Enum1;
+
+  Enum e = (Enum)b1;
+
+  int b2 = int(b);
+  int b3 = static_cast(b);
+  int b4 = b;
+  double aa = a;
+  (void)b2;
+  return (void)g();
+}
+
+template 
+void template_function(T t, int n) {
+  int i = (int)t;
+}
+
+template 
+struct TemplateStruct {
+  void f(T t, int n) {
+int k = (int)t;
+  }
+};
+
+void test_templates() {
+  template_function(1, 42);
+  template_function(1.0, 42);
+  TemplateStruct().f(1, 42);
+  TemplateStruct().f(1.0, 42);
+}
+
+extern "C" {
+void extern_c_code(const char *cpc) {
+  char *pc = (char*)cpc;
+}
+}
+
+#define CAST(type, value) (type)(value)
+void macros(double d) {
+  int i = CAST(int, d);
+}
+
+enum E { E1 = 1 };
+template 
+struct A {
+  // Usage of template argument e = E1 is represented as (E)1 in the AST for
+  // some reason. We have a special treatment of this case to avoid warnings
+  // here.
+  static const E ee = e;
+};
+struct B : public A {};
+
+
+void overloaded_function();
+void overloaded_function(int);
+
+template
+void g(Fn fn) {
+  fn();
+}
+
+void function_casts() {
+  typedef void (*FnPtrVoid)();
+  typedef void (&FnRefVoid)();
+  typedef void (&FnRefInt)(int);
+
+  g((void (*)())overloaded_function);
+  g((void (*)())&overloaded_function);
+  g((void (&)())overloaded_function);
+
+  g((

[PATCH] D46659: [clang-tidy/google-readability-casting] Disable check for Objective-C++

2018-05-16 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/google/AvoidCStyleCastsCheck.cpp:103-104
   // The rest of this check is only relevant to C++.
-  if (!getLangOpts().CPlusPlus)
+  // We also disable it for Objective-C++.
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC1 || getLangOpts().ObjC2)
 return;

stephanemoore wrote:
> In the future it would probably be good to allow configuring whether or not 
> this is disabled but I think that disabling it for Objective-C++ completely 
> in the interim is a positive change.
Agreed. Filed https://bugs.llvm.org/show_bug.cgi?id=37489 to follow up.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46659



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


[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-16 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

@ioeric You mentioned in https://reviews.llvm.org/D46751 that it would make 
sense to add a flag to disable indexing members. Could you comment on that? 
What kind of granularity were you thinking? Would a "member" flag cover both 
class members (member vars and functions) and enum class enumerators for 
example? I think that would be reasonable. But I will also add symbols in main 
files too, so another flag for that? Hmmm.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[clang-tools-extra] r332515 - Attempt to fix buildbot failure caused by r332363

2018-05-16 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 16 12:59:49 2018
New Revision: 332515

URL: http://llvm.org/viewvc/llvm-project?rev=332515&view=rev
Log:
Attempt to fix buildbot failure caused by r332363

Log: http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=332515&r1=332514&r2=332515&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed May 16 12:59:49 2018
@@ -1069,9 +1069,8 @@ SignatureHelp signatureHelp(PathRef File
   Options.IncludeBriefComments = false;
   semaCodeComplete(llvm::make_unique(Options, Result),
Options,
-   {FileName, Command, Preamble,
-/*PreambleInclusions=*/{}, Contents, Pos, std::move(VFS),
-std::move(PCHs)});
+   {FileName, Command, Preamble, std::vector(),
+Contents, Pos, std::move(VFS), std::move(PCHs)});
   return Result;
 }
 


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


Re: r332458 - [AST] Added a helper to extract a user-friendly text of a comment.

2018-05-16 Thread Galina Kistanova via cfe-commits
Hello Ilya,

This commit broke build step for couple of our builders:

http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/8541
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu

. . .
FAILED:
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o
/usr/bin/c++   -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0
-DGTEST_LANG_CXX11=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/unittests/AST
-I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/unittests/AST
-I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/include
-I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/utils/unittest/googletest/include
-I/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/utils/unittest/googlemock/include
-fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
-Wno-comment -ffunction-sections -fdata-sections -fno-common
-Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG
-Wno-variadic-macros -fno-exceptions -fno-rtti -MD -MT
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o -MF
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o.d
-o tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/CommentTextTest.cpp.o
-c
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/unittests/AST/CommentTextTest.cpp
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/unittests/AST/CommentTextTest.cpp:62:1:
error: unterminated raw string
 R"cpp(
 ^
. . .

Please have a look?

The builder was already red and did not send notifications.

Thanks

Galina



On Wed, May 16, 2018 at 5:30 AM, Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Wed May 16 05:30:09 2018
> New Revision: 332458
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332458&view=rev
> Log:
> [AST] Added a helper to extract a user-friendly text of a comment.
>
> Summary:
> The helper is used in clangd for documentation shown in code completion
> and storing the docs in the symbols. See D45999.
>
> This patch reuses the code of the Doxygen comment lexer, disabling the
> bits that do command and html tag parsing.
> The new helper works on all comments, including non-doxygen comments.
> However, it does not understand or transform any doxygen directives,
> i.e. cannot extract brief text, etc.
>
> Reviewers: sammccall, hokein, ioeric
>
> Reviewed By: ioeric
>
> Subscribers: mgorny, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D46000
>
> Added:
> cfe/trunk/unittests/AST/CommentTextTest.cpp
> Modified:
> cfe/trunk/include/clang/AST/CommentLexer.h
> cfe/trunk/include/clang/AST/RawCommentList.h
> cfe/trunk/lib/AST/CommentLexer.cpp
> cfe/trunk/lib/AST/RawCommentList.cpp
> cfe/trunk/unittests/AST/CMakeLists.txt
>
> Modified: cfe/trunk/include/clang/AST/CommentLexer.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/CommentLexer.h?rev=332458&r1=332457&r2=332458&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/CommentLexer.h (original)
> +++ cfe/trunk/include/clang/AST/CommentLexer.h Wed May 16 05:30:09 2018
> @@ -281,6 +281,11 @@ private:
>/// command, including command marker.
>SmallString<16> VerbatimBlockEndCommandName;
>
> +  /// If true, the commands, html tags, etc will be parsed and reported as
> +  /// separate tokens inside the comment body. If false, the comment text
> will
> +  /// be parsed into text and newline tokens.
> +  bool ParseCommands;
> +
>/// Given a character reference name (e.g., "lt"), return the character
> that
>/// it stands for (e.g., "<").
>StringRef resolveHTMLNamedCharacterReference(StringRef Name) const;
> @@ -315,12 +320,11 @@ private:
>/// Eat string matching regexp \code \s*\* \endcode.
>void skipLineStartingDecorations();
>
> -  /// Lex stuff inside comments.  CommentEnd should be set correctly.
> +  /// Lex comment text, including commands if ParseCommands is set to
> true.
>void lexCommentText(Token &T);
>
> -  void setupAndLexVerbatimBlock(Token &T,
> -const char *TextBegin,
> -char Marker, const CommandInfo *Info);
> +  void setupAndLexVerbatimBlock(Token &T, const char *TextBegin, char
> Marker,
> +const CommandInfo *Info);
>
>void lexVerbatimBlockFirstLine(Token &T);
>
> @@ -343,14 +347,13 @@ private:
>
>  public:
>Lexer(llvm::BumpPtrAllocator &Allocator, DiagnosticsEngine &Diags,
> -const CommandTraits &Traits,
> -SourceLocation Fil

Re: [clang-tools-extra] r332363 - [clangd] Populate #include insertions as additional edits in completion items.

2018-05-16 Thread Eric Liu via cfe-commits
Looking... sorry that I missed the email from this bot.

On Wed, May 16, 2018 at 9:43 PM Galina Kistanova 
wrote:

> Hello Eric,
>
> This commit broke one of our builders:
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399
>
> . . .
> 387.403 [725/64/4163] Building CXX object
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
> FAILED:
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
>
> /usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools/clang/tools/extra/clangd
> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
> -Itools/clang/include -Iinclude
> -I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/include
> -fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
> -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
> -Wno-comment -ffunction-sections -fdata-sections -fno-common
> -Woverloaded-virtual -fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions
> -fno-rtti -MD -MT
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
> -MF
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o.d
> -o
> tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
> -c
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:
> In function ‘clang::clangd::SignatureHelp
> clang::clangd::signatureHelp(clang::clangd::PathRef, const
> clang::tooling::CompileCommand&, const clang::PrecompiledPreamble*,
> llvm::StringRef, clang::clangd::Position,
> llvm::IntrusiveRefCntPtr,
> std::shared_ptr)’:
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:1127:37:
> error: invalid initialization of reference of type ‘const
> clang::clangd::{anonymous}::SemaCompleteInput&’ from expression of type
> ‘’
>  std::move(PCHs)});
>  ^
> /home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:710:6:
> error: in passing argument 3 of ‘bool
> clang::clangd::{anonymous}::semaCodeComplete(std::unique_ptr,
> const clang::CodeCompleteOptions&, const
> clang::clangd::{anonymous}::SemaCompleteInput&,
> std::unique_ptr*)’
>
>  bool semaCodeComplete(std::unique_ptr Consumer,
>   ^
> . . .
>
> Please have a look?
>
> It is not good idea to keep the bot red for too long. This hides new
> problem which later hard to track down.
>
> Thanks
>
>
> Galina
>
>
>
> On Tue, May 15, 2018 at 8:29 AM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ioeric
>> Date: Tue May 15 08:29:32 2018
>> New Revision: 332363
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=332363&view=rev
>> Log:
>> [clangd] Populate #include insertions as additional edits in completion
>> items.
>>
>> Summary:
>> o Remove IncludeInsertion LSP command.
>> o Populate include insertion edits synchromously in completion items.
>> o Share the code completion compiler instance and precompiled preamble to
>> get existing inclusions in main file.
>> o Include insertion logic lives only in CodeComplete now.
>> o Use tooling::HeaderIncludes for inserting new includes.
>> o Refactored tests.
>>
>> Reviewers: sammccall
>>
>> Reviewed By: sammccall
>>
>> Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D46497
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> clang-tools-extra/trunk/clangd/CodeComplete.cpp
>> clang-tools-extra/trunk/clangd/CodeComplete.h
>> clang-tools-extra/trunk/clangd/Headers.cpp
>> clang-tools-extra/trunk/clangd/Headers.h
>> clang-tools-extra/trunk/clangd/Protocol.h
>> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
>> clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=332363&r1=332362&r2=332363&view=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 15 08:29:32
>> 2018
>> @@ -161,6 +161,7 @@ void ClangdServer::codeComplete(PathRef
>>  // both the old and the new version in case only one of them matches.
>>  CompletionList Result = clangd::codeComplete(
>> 

Re: [clang-tools-extra] r332363 - [clangd] Populate #include insertions as additional edits in completion items.

2018-05-16 Thread Galina Kistanova via cfe-commits
Hello Eric,

This commit broke one of our builders:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/26399

. . .
387.403 [725/64/4163] Building CXX object
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
FAILED:
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o

/usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/clang/tools/extra/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/include
-fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
-Wno-comment -ffunction-sections -fdata-sections -fno-common
-Woverloaded-virtual -fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions
-fno-rtti -MD -MT
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
-MF
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o.d
-o
tools/clang/tools/extra/clangd/CMakeFiles/clangDaemon.dir/CodeComplete.cpp.o
-c
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:
In function ‘clang::clangd::SignatureHelp
clang::clangd::signatureHelp(clang::clangd::PathRef, const
clang::tooling::CompileCommand&, const clang::PrecompiledPreamble*,
llvm::StringRef, clang::clangd::Position,
llvm::IntrusiveRefCntPtr,
std::shared_ptr)’:
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:1127:37:
error: invalid initialization of reference of type ‘const
clang::clangd::{anonymous}::SemaCompleteInput&’ from expression of type
‘’
 std::move(PCHs)});
 ^
/home/buildslave/buildslave1a/clang-x86_64-linux-abi-test/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:710:6:
error: in passing argument 3 of ‘bool
clang::clangd::{anonymous}::semaCodeComplete(std::unique_ptr,
const clang::CodeCompleteOptions&, const
clang::clangd::{anonymous}::SemaCompleteInput&,
std::unique_ptr*)’
 bool semaCodeComplete(std::unique_ptr Consumer,
  ^
. . .

Please have a look?

It is not good idea to keep the bot red for too long. This hides new
problem which later hard to track down.

Thanks

Galina



On Tue, May 15, 2018 at 8:29 AM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Tue May 15 08:29:32 2018
> New Revision: 332363
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332363&view=rev
> Log:
> [clangd] Populate #include insertions as additional edits in completion
> items.
>
> Summary:
> o Remove IncludeInsertion LSP command.
> o Populate include insertion edits synchromously in completion items.
> o Share the code completion compiler instance and precompiled preamble to
> get existing inclusions in main file.
> o Include insertion logic lives only in CodeComplete now.
> o Use tooling::HeaderIncludes for inserting new includes.
> o Refactored tests.
>
> Reviewers: sammccall
>
> Reviewed By: sammccall
>
> Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D46497
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/CodeComplete.cpp
> clang-tools-extra/trunk/clangd/CodeComplete.h
> clang-tools-extra/trunk/clangd/Headers.cpp
> clang-tools-extra/trunk/clangd/Headers.h
> clang-tools-extra/trunk/clangd/Protocol.h
> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
> clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.cpp?rev=332363&r1=332362&r2=332363&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 15 08:29:32
> 2018
> @@ -161,6 +161,7 @@ void ClangdServer::codeComplete(PathRef
>  // both the old and the new version in case only one of them matches.
>  CompletionList Result = clangd::codeComplete(
>  File, IP->Command, PreambleData ? &PreambleData->Preamble :
> nullptr,
> +PreambleData ? PreambleData->Inclusions :
> std::vector(),
>  IP->Contents, Pos, FS, PCHs, CodeCompleteOpts);
>  CB(std::move(Result));
>};
>
> Modified: clang-tools-extra/trunk/clangd/Co

[PATCH] D46489: [HIP] Let assembler output bitcode for amdgcn

2018-05-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl abandoned this revision.
yaxunl added a comment.

I have updated https://reviews.llvm.org/D46476 to skip backend and assembler 
phases for amdgcn, therefore this patch is no longer needed.


https://reviews.llvm.org/D46489



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 147156.
yaxunl added a comment.

Skip backend and assemmbler phases for amdgcn since it does not support linking 
of object files.


https://reviews.llvm.org/D46476

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-phases.cu

Index: test/Driver/cuda-phases.cu
===
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -7,195 +7,242 @@
 // REQUIRES: clang-driver
 // REQUIRES: powerpc-registered-target
 // REQUIRES: nvptx-registered-target
-
+// REQUIRES: amdgpu-registered-target
 //
 // Test single gpu architecture with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN %s
-// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
-// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
-// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
-// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
-// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
-// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
-// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler
-// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda)
-// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir
-// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda)
-// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda)
-// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda)
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s
+// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-[[T]])
+// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-[[T]])
+// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-[[T]])
+// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-[[T]])
+// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:sm_30]])
+// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:gfx803]])
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object
+// BIN_NV-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler
+// BIN_NV-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-[[T]])
+// BIN_NV-DAG: [[P11:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-[[T]] ([[TRIPLE]])" {[[P10]]}, ir
+// BIN_NV-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
+// BIN_AMD-DAG: [[P12:[0-9]+]]: backend, {[[P2]]}, assembler, (host-[[T]])
+// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
+// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
+// BIN_AMD-DAG: [[P15:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], [[ARCH]])
+// BIN_AMD-DAG: [[P16:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P14]]},
+// BIN_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P15]]}, object
 
 //
 // Test single gpu architecture up to the assemble phase.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \
-// RUN: | FileCheck -check-prefix=ASM %s
-// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30)
-// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30)
-// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler
-// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda)
-// ASM-DAG: [[P7:[0-9]+]]: compiler, {[[P6]]}, ir, (host-cuda)
-// A

[PATCH] D46659: [clang-tidy/google-readability-casting] Disable check for Objective-C++

2018-05-16 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore added inline comments.



Comment at: clang-tidy/google/AvoidCStyleCastsCheck.cpp:103-104
   // The rest of this check is only relevant to C++.
-  if (!getLangOpts().CPlusPlus)
+  // We also disable it for Objective-C++.
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC1 || getLangOpts().ObjC2)
 return;

In the future it would probably be good to allow configuring whether or not 
this is disabled but I think that disabling it for Objective-C++ completely in 
the interim is a positive change.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46659



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


[PATCH] D46971: [DWARF] Get RA from RA register even if it appears unused

2018-05-16 Thread whitequark via Phabricator via cfe-commits
whitequark updated this revision to Diff 147153.
whitequark added a comment.

Reuploaded diff with context.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D46971

Files:
  src/DwarfInstructions.hpp


Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -192,6 +192,8 @@
   else
 return UNW_EBADREG;
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);
   }
 
   // By definition, the CFA is the stack pointer at the call site, so


Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -192,6 +192,8 @@
   else
 return UNW_EBADREG;
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);
   }
 
   // By definition, the CFA is the stack pointer at the call site, so
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46971: [DWARF] Get RA from RA register even if it appears unused

2018-05-16 Thread whitequark via Phabricator via cfe-commits
whitequark created this revision.
whitequark added a reviewer: compnerd.
Herald added a subscriber: JDevlieghere.

If prolog info lists the RA register as unused, it means that
the current stack frame corresponds to a leaf function which never
needs to save the RA register. The RA register is of course used
to return from this leaf function.

Such a frame may be in the middle of the stack if another frame was
pushed on top of it by a signal or CPU exception. In this case,
unless we extract RA from the RA register, _Unwind_Backtrace would
stop at the frame right above the signal or exception frame.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D46971

Files:
  src/DwarfInstructions.hpp


Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -192,6 +192,8 @@
   else
 return UNW_EBADREG;
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);
   }
 
   // By definition, the CFA is the stack pointer at the call site, so


Index: src/DwarfInstructions.hpp
===
--- src/DwarfInstructions.hpp
+++ src/DwarfInstructions.hpp
@@ -192,6 +192,8 @@
   else
 return UNW_EBADREG;
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);
   }
 
   // By definition, the CFA is the stack pointer at the call site, so
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46443: Add missing cstdalign header

2018-05-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

ping


Repository:
  rCXX libc++

https://reviews.llvm.org/D46443



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


[libunwind] r332513 - [OR1K] Add the EPCR special-purpose register to register state.

2018-05-16 Thread whitequark via cfe-commits
Author: whitequark
Date: Wed May 16 12:09:48 2018
New Revision: 332513

URL: http://llvm.org/viewvc/llvm-project?rev=332513&view=rev
Log:
[OR1K] Add the EPCR special-purpose register to register state.

This makes it possible to unwind hardware exception stack frames,
which necessarily save every register and so need an extra column
for storing the return address. CFI for the exception handler could
then look as follows:

.globl exception_vector
exception_vector:
.cfi_startproc
.cfi_signal_frame
.cfi_return_column 32
l.addi  r1, r1, -0x100
.cfi_def_cfa_offset 0x100
l.sw0x00(r1), r2
.cfi_offset 2, 0x00-0x100
l.sw0x04(r1), r3
.cfi_offset 3, 0x04-0x100
l.sw0x08(r1), r4
.cfi_offset 4, 0x08-0x100
l.mfspr r3, r0, SPR_EPCR_BASE
l.sw0x78(r1), r3
.cfi_offset 32, 0x78-0x100
l.jal   exception_handler
 l.nop
l.lwz   r2, 0x00(r1)
l.lwz   r3, 0x04(r1)
l.lwz   r4, 0x08(r1)
l.jrr9
 l.nop
.cfi_endproc

This register could, of course, also be accessed by the trace
callback or personality function, if so desired.

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindRegistersSave.S

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=332513&r1=332512&r2=332513&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed May 16 12:09:48 2018
@@ -21,7 +21,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 116
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64 95
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  31
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=332513&r1=332512&r2=332513&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed May 16 12:09:48 2018
@@ -745,6 +745,7 @@ enum {
   UNW_OR1K_R29 = 29,
   UNW_OR1K_R30 = 30,
   UNW_OR1K_R31 = 31,
+  UNW_OR1K_EPCR = 32,
 };
 
 // MIPS registers

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=332513&r1=332512&r2=332513&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Wed May 16 12:09:48 2018
@@ -2528,6 +2528,7 @@ private:
   struct or1k_thread_state_t {
 unsigned int __r[32]; // r0-r31
 unsigned int __pc;// Program counter
+unsigned int __epcr;  // Program counter at exception
   };
 
   or1k_thread_state_t _registers;
@@ -2553,6 +2554,8 @@ inline bool Registers_or1k::validRegiste
 return false;
   if (regNum <= UNW_OR1K_R31)
 return true;
+  if (regNum == UNW_OR1K_EPCR)
+return true;
   return false;
 }
 
@@ -2565,6 +2568,8 @@ inline uint32_t Registers_or1k::getRegis
 return _registers.__pc;
   case UNW_REG_SP:
 return _registers.__r[1];
+  case UNW_OR1K_EPCR:
+return _registers.__epcr;
   }
   _LIBUNWIND_ABORT("unsupported or1k register");
 }
@@ -2582,6 +2587,9 @@ inline void Registers_or1k::setRegister(
   case UNW_REG_SP:
 _registers.__r[1] = value;
 return;
+  case UNW_OR1K_EPCR:
+_registers.__epcr = value;
+return;
   }
   _LIBUNWIND_ABORT("unsupported or1k register");
 }
@@ -2677,6 +2685,8 @@ inline const char *Registers_or1k::getRe
 return "r30";
   case UNW_OR1K_R31:
 return "r31";
+  case UNW_OR1K_EPCR:
+return "EPCR";
   default:
 return "unknown register";
   }

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=332513&r1=332512&r2=332513&view=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Wed May 16 12:09:48 2018
@@ -940,6 +940,8 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   l.sw 124(r3), r31
   # store ra to pc
   l.sw 128(r3), r9
+  # zero epcr
+  l.sw 132(r3), r0
 #endif
 
 #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */


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


[libunwind] r332512 - [OR1K] Add a dedicated PC register to register state.

2018-05-16 Thread whitequark via cfe-commits
Author: whitequark
Date: Wed May 16 12:09:41 2018
New Revision: 332512

URL: http://llvm.org/viewvc/llvm-project?rev=332512&view=rev
Log:
[OR1K] Add a dedicated PC register to register state.

Before this commit, R9, the link register, was used as PC register.
However, a stack frame may have R9 not set to PC on entry, either
because it uses a custom calling convention, or, more likely,
because this is a signal or exception stack frame. Using R9 as
PC register made it impossible to unwind such frames.

All other architectures similarly use a dedicated PC register.

Modified:
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=332512&r1=332511&r2=332512&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Wed May 16 12:09:41 2018
@@ -2521,12 +2521,13 @@ public:
 
   uint64_t  getSP() const { return _registers.__r[1]; }
   void  setSP(uint32_t value) { _registers.__r[1] = value; }
-  uint64_t  getIP() const { return _registers.__r[9]; }
-  void  setIP(uint32_t value) { _registers.__r[9] = value; }
+  uint64_t  getIP() const { return _registers.__pc; }
+  void  setIP(uint32_t value) { _registers.__pc = value; }
 
 private:
   struct or1k_thread_state_t {
-unsigned int __r[32];
+unsigned int __r[32]; // r0-r31
+unsigned int __pc;// Program counter
   };
 
   or1k_thread_state_t _registers;
@@ -2561,7 +2562,7 @@ inline uint32_t Registers_or1k::getRegis
 
   switch (regNum) {
   case UNW_REG_IP:
-return _registers.__r[9];
+return _registers.__pc;
   case UNW_REG_SP:
 return _registers.__r[1];
   }
@@ -2576,7 +2577,7 @@ inline void Registers_or1k::setRegister(
 
   switch (regNum) {
   case UNW_REG_IP:
-_registers.__r[9] = value;
+_registers.__pc = value;
 return;
   case UNW_REG_SP:
 _registers.__r[1] = value;

Modified: libunwind/trunk/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=332512&r1=332511&r2=332512&view=diff
==
--- libunwind/trunk/src/UnwindRegistersRestore.S (original)
+++ libunwind/trunk/src/UnwindRegistersRestore.S Wed May 16 12:09:41 2018
@@ -758,7 +758,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
 #  thread_state pointer is in r3
 #
 
-  # restore integral registerrs
+  # restore integral registers
   l.lwz r0,  0(r3)
   l.lwz r1,  4(r3)
   l.lwz r2,  8(r3)
@@ -768,7 +768,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   l.lwz r6, 24(r3)
   l.lwz r7, 28(r3)
   l.lwz r8, 32(r3)
-  l.lwz r9, 36(r3)
+  # skip r9
   l.lwzr10, 40(r3)
   l.lwzr11, 44(r3)
   l.lwzr12, 48(r3)
@@ -795,6 +795,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   # at last, restore r3
   l.lwzr3,  12(r3)
 
+  # load new pc into ra
+  l.lwzr9, 128(r3)
   # jump to pc
   l.jr r9
l.nop

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=332512&r1=332511&r2=332512&view=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Wed May 16 12:09:41 2018
@@ -938,6 +938,8 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   l.sw 116(r3), r29
   l.sw 120(r3), r30
   l.sw 124(r3), r31
+  # store ra to pc
+  l.sw 128(r3), r9
 #endif
 
 #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */


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


[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-05-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

@hans @thakis, do you remember how these flags are supposed to work? I've 
forgotten anything I ever knew about them...


https://reviews.llvm.org/D46652



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


[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332509: [Sema] Fix assertion when constructor is disabled 
with partially specialized… (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46909?vs=146944&id=147144#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46909

Files:
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/test/SemaTemplate/partial-spec-instantiate.cpp

Index: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2398,127 +2398,137 @@
   if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
 return nullptr;
 
-  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
-  CXXRecordDecl *Pattern = nullptr;
-
-  // C++ [temp.class.spec.match]p1:
-  //   When a class template is used in a context that requires an
-  //   instantiation of the class, it is necessary to determine
-  //   whether the instantiation is to be generated using the primary
-  //   template or one of the partial specializations. This is done by
-  //   matching the template arguments of the class template
-  //   specialization with the template argument lists of the partial
-  //   specializations.
-  typedef PartialSpecMatchResult MatchResult;
-  SmallVector Matched;
-  SmallVector PartialSpecs;
-  Template->getPartialSpecializations(PartialSpecs);
-  TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
-  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
-ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
-TemplateDeductionInfo Info(FailedCandidates.getLocation());
-if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
-Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
-  // Store the failed-deduction information for use in diagnostics, later.
-  // TODO: Actually use the failed-deduction info?
-  FailedCandidates.addCandidate().set(
-  DeclAccessPair::make(Template, AS_public), Partial,
-  MakeDeductionFailureInfo(S.Context, Result, Info));
-  (void)Result;
-} else {
-  Matched.push_back(PartialSpecMatchResult());
-  Matched.back().Partial = Partial;
-  Matched.back().Args = Info.take();
+  llvm::PointerUnion
+  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
+  if (!Specialized.is()) {
+// Find best matching specialization.
+ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
+
+// C++ [temp.class.spec.match]p1:
+//   When a class template is used in a context that requires an
+//   instantiation of the class, it is necessary to determine
+//   whether the instantiation is to be generated using the primary
+//   template or one of the partial specializations. This is done by
+//   matching the template arguments of the class template
+//   specialization with the template argument lists of the partial
+//   specializations.
+typedef PartialSpecMatchResult MatchResult;
+SmallVector Matched;
+SmallVector PartialSpecs;
+Template->getPartialSpecializations(PartialSpecs);
+TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
+for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
+  ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
+  TemplateDeductionInfo Info(FailedCandidates.getLocation());
+  if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
+  Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
+// Store the failed-deduction information for use in diagnostics, later.
+// TODO: Actually use the failed-deduction info?
+FailedCandidates.addCandidate().set(
+DeclAccessPair::make(Template, AS_public), Partial,
+MakeDeductionFailureInfo(S.Context, Result, Info));
+(void)Result;
+  } else {
+Matched.push_back(PartialSpecMatchResult());
+Matched.back().Partial = Partial;
+Matched.back().Args = Info.take();
+  }
 }
-  }
 
-  // If we're dealing with a member template where the template parameters
-  // have been instantiated, this provides the original template parameters
-  // from which the member template's parameters were instantiated.
-
-  if (Matched.size() >= 1) {
-SmallVectorImpl::iterator Best = Matched.begin();
-if (Matched.size() == 1) {
-  //   -- If exactly one matching specialization is found, the
-  //  instantiation is generated from that specialization.
-  // We don't need to do anything for this.
-} else {
-  //   -- If more than one matching specialization is found, the
-  //  partial order rules (14.5.4.2) are used to determine

r332509 - [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-16 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed May 16 11:28:58 2018
New Revision: 332509

URL: http://llvm.org/viewvc/llvm-project?rev=332509&view=rev
Log:
[Sema] Fix assertion when constructor is disabled with partially specialized 
template.

The added test case was triggering assertion

> Assertion failed: 
> (!SpecializedTemplate.is() && "Already set 
> to a class template partial specialization!"), function setInstantiationOf, 
> file clang/include/clang/AST/DeclTemplate.h, line 1825.

It was happening with ClassTemplateSpecializationDecl
`enable_if_not_same`. Because this template is specialized for
equal types not to have a definition, it wasn't instantiated and its
specialization kind remained TSK_Undeclared. And because it was implicit
instantiation, we didn't mark the decl as invalid. So when we try to
find the best matching partial specialization the second time, we hit
the assertion as partial specialization is already set.

Fix by reusing stored partial specialization when available, instead of
looking for the best match every time.

rdar://problem/39524996

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: cfe-commits

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


Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/partial-spec-instantiate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=332509&r1=332508&r2=332509&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed May 16 11:28:58 2018
@@ -2398,127 +2398,137 @@ getPatternForClassTemplateSpecialization
   if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
 return nullptr;
 
-  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
-  CXXRecordDecl *Pattern = nullptr;
-
-  // C++ [temp.class.spec.match]p1:
-  //   When a class template is used in a context that requires an
-  //   instantiation of the class, it is necessary to determine
-  //   whether the instantiation is to be generated using the primary
-  //   template or one of the partial specializations. This is done by
-  //   matching the template arguments of the class template
-  //   specialization with the template argument lists of the partial
-  //   specializations.
-  typedef PartialSpecMatchResult MatchResult;
-  SmallVector Matched;
-  SmallVector PartialSpecs;
-  Template->getPartialSpecializations(PartialSpecs);
-  TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
-  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
-ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
-TemplateDeductionInfo Info(FailedCandidates.getLocation());
-if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
-Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
-  // Store the failed-deduction information for use in diagnostics, later.
-  // TODO: Actually use the failed-deduction info?
-  FailedCandidates.addCandidate().set(
-  DeclAccessPair::make(Template, AS_public), Partial,
-  MakeDeductionFailureInfo(S.Context, Result, Info));
-  (void)Result;
-} else {
-  Matched.push_back(PartialSpecMatchResult());
-  Matched.back().Partial = Partial;
-  Matched.back().Args = Info.take();
+  llvm::PointerUnion
+  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
+  if (!Specialized.is()) {
+// Find best matching specialization.
+ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
+
+// C++ [temp.class.spec.match]p1:
+//   When a class template is used in a context that requires an
+//   instantiation of the class, it is necessary to determine
+//   whether the instantiation is to be generated using the primary
+//   template or one of the partial specializations. This is done by
+//   matching the template arguments of the class template
+//   specialization with the template argument lists of the partial
+//   specializations.
+typedef PartialSpecMatchResult MatchResult;
+SmallVector Matched;
+SmallVector PartialSpecs;
+Template->getPartialSpecializations(PartialSpecs);
+TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
+for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
+  ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
+  TemplateDeductionInfo Info(FailedCandidates.getLocation());
+  if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
+  Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
+// Store the failed-deduction information for use in diagnostics, 
later.
+// TODO: Actually use the failed-deduction info?
+FailedCandidates.ad

[PATCH] D46929: Fix a mangling failure on clang-cl C++17

2018-05-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I searched around, and I noticed that `VTableContext::getMethodVTableIndex` has 
the same implied contract that the caller must always provide a canonical 
declaration or things will break. It looks like it has three callers, and they 
all do this. We should probably sink the canonicalization into this helper as 
well and clean up the now-superfluous canonicalizations at the call site.


Repository:
  rC Clang

https://reviews.llvm.org/D46929



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


[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the quick review, Richard. I'll keep in mind the idea with comparing 
results of multiple lookups when I work on other partial specialization-related 
bugs.


https://reviews.llvm.org/D46909



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1560-1566
 // If the size is known to be zero, we're done.
 if (StateZeroSize && !StateNonZeroSize) {
   StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
   C.addTransition(StateZeroSize);
   return;
 }
 

One more cornercase where the return value needs to be corrected. It'd be great 
to de-duplicate this code to avoid similar problems in the future.

Test case:
```
int foo(char *dst, const char *src) {
  return strlcpy(dst, src, 0); // no-crash
}
```


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D45702: [clang-tidy] Add a new check, readability-simplify-subscript-expr, that simplifies subscript expressions.

2018-05-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment.

In https://reviews.llvm.org/D45702#1101136, @aaron.ballman wrote:

> In https://reviews.llvm.org/D45702#1097294, @shuaiwang wrote:
>
> > Addressed review comments.
>
>
> This patch was approved; do you need someone to commit this for you?


Yes please :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



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


[PATCH] D46939: [Timers] TimerGroup: add constructor from StringMap

2018-05-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332506: [Timers] TimerGroup: add constructor from 
StringMap (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46939?vs=147055&id=147140#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46939

Files:
  llvm/trunk/include/llvm/Support/Timer.h
  llvm/trunk/lib/Support/Timer.cpp


Index: llvm/trunk/include/llvm/Support/Timer.h
===
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_SUPPORT_TIMER_H
 #define LLVM_SUPPORT_TIMER_H
 
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataTypes.h"
 #include 
@@ -194,6 +195,10 @@
 
 public:
   explicit TimerGroup(StringRef Name, StringRef Description);
+
+  explicit TimerGroup(StringRef Name, StringRef Description,
+  const StringMap &Records);
+
   ~TimerGroup();
 
   void setName(StringRef NewName, StringRef NewDescription) {
Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -236,6 +236,15 @@
   TimerGroupList = this;
 }
 
+TimerGroup::TimerGroup(StringRef Name, StringRef Description,
+   const StringMap &Records)
+: TimerGroup(Name, Description) {
+  TimersToPrint.reserve(Records.size());
+  for (const auto &P : Records)
+TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey());
+  assert(TimersToPrint.size() == Records.size() && "Size mismatch");
+}
+
 TimerGroup::~TimerGroup() {
   // If the timer group is destroyed before the timers it owns, accumulate and
   // print the timing data.


Index: llvm/trunk/include/llvm/Support/Timer.h
===
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_SUPPORT_TIMER_H
 #define LLVM_SUPPORT_TIMER_H
 
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataTypes.h"
 #include 
@@ -194,6 +195,10 @@
 
 public:
   explicit TimerGroup(StringRef Name, StringRef Description);
+
+  explicit TimerGroup(StringRef Name, StringRef Description,
+  const StringMap &Records);
+
   ~TimerGroup();
 
   void setName(StringRef NewName, StringRef NewDescription) {
Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -236,6 +236,15 @@
   TimerGroupList = this;
 }
 
+TimerGroup::TimerGroup(StringRef Name, StringRef Description,
+   const StringMap &Records)
+: TimerGroup(Name, Description) {
+  TimersToPrint.reserve(Records.size());
+  for (const auto &P : Records)
+TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey());
+  assert(TimersToPrint.size() == Records.size() && "Size mismatch");
+}
+
 TimerGroup::~TimerGroup() {
   // If the timer group is destroyed before the timers it owns, accumulate and
   // print the timing data.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46937: [Timers] TimerGroup::printJSONValue(): print doubles with no precision loss

2018-05-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332504: [Timers] TimerGroup::printJSONValue(): print doubles 
with no precision loss (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46937?vs=147053&id=147138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46937

Files:
  llvm/trunk/lib/Support/Timer.cpp


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -22,6 +22,8 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+
 using namespace llvm;
 
 // This ugly hack is brought to you courtesy of constructor/destructor ordering
@@ -367,10 +369,12 @@
 void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
 const char *suffix, double Value) {
   assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&
- "TimerGroup name needs no quotes");
+ "TimerGroup name should not need quotes");
   assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None &&
- "Timer name needs no quotes");
-  OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value;
+ "Timer name should not need quotes");
+  constexpr auto max_digits10 = std::numeric_limits::max_digits10;
+  OS << "\t\"time." << Name << '.' << R.Name << suffix
+ << "\": " << format("%.*e", max_digits10 - 1, Value);
 }
 
 const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -22,6 +22,8 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+
 using namespace llvm;
 
 // This ugly hack is brought to you courtesy of constructor/destructor ordering
@@ -367,10 +369,12 @@
 void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
 const char *suffix, double Value) {
   assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&
- "TimerGroup name needs no quotes");
+ "TimerGroup name should not need quotes");
   assert(yaml::needsQuotes(R.Name) == yaml::QuotingType::None &&
- "Timer name needs no quotes");
-  OS << "\t\"time." << Name << '.' << R.Name << suffix << "\": " << Value;
+ "Timer name should not need quotes");
+  constexpr auto max_digits10 = std::numeric_limits::max_digits10;
+  OS << "\t\"time." << Name << '.' << R.Name << suffix
+ << "\": " << format("%.*e", max_digits10 - 1, Value);
 }
 
 const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46938: [Timers] TimerGroup: make printJSONValues() method public

2018-05-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332505: [Timers] TimerGroup: make printJSONValues() method 
public (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46938?vs=147054&id=147139#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46938

Files:
  llvm/trunk/include/llvm/Support/Timer.h
  llvm/trunk/lib/Support/Timer.cpp


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -378,6 +378,8 @@
 }
 
 const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {
+  sys::SmartScopedLock L(*TimerLock);
+
   prepareToPrintList();
   for (const PrintRecord &R : TimersToPrint) {
 OS << delim;
Index: llvm/trunk/include/llvm/Support/Timer.h
===
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -207,6 +207,8 @@
   /// This static method prints all timers and clears them all out.
   static void printAll(raw_ostream &OS);
 
+  const char *printJSONValues(raw_ostream &OS, const char *delim);
+
   /// Prints all timers as JSON key/value pairs, and clears them all out.
   static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
 
@@ -223,7 +225,6 @@
   void PrintQueuedTimers(raw_ostream &OS);
   void printJSONValue(raw_ostream &OS, const PrintRecord &R,
   const char *suffix, double Value);
-  const char *printJSONValues(raw_ostream &OS, const char *delim);
 };
 
 } // end namespace llvm


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -378,6 +378,8 @@
 }
 
 const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) {
+  sys::SmartScopedLock L(*TimerLock);
+
   prepareToPrintList();
   for (const PrintRecord &R : TimersToPrint) {
 OS << delim;
Index: llvm/trunk/include/llvm/Support/Timer.h
===
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -207,6 +207,8 @@
   /// This static method prints all timers and clears them all out.
   static void printAll(raw_ostream &OS);
 
+  const char *printJSONValues(raw_ostream &OS, const char *delim);
+
   /// Prints all timers as JSON key/value pairs, and clears them all out.
   static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
 
@@ -223,7 +225,6 @@
   void PrintQueuedTimers(raw_ostream &OS);
   void printJSONValue(raw_ostream &OS, const PrintRecord &R,
   const char *suffix, double Value);
-  const char *printJSONValues(raw_ostream &OS, const char *delim);
 };
 
 } // end namespace llvm
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46936: [Timers] TimerGroup::printJSONValues(): print mem timer with .mem suffix

2018-05-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332503: [Timers] TimerGroup::printJSONValues(): print mem 
timer with .mem suffix (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46936?vs=147052&id=147137#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46936

Files:
  llvm/trunk/lib/Support/Timer.cpp


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -387,7 +387,7 @@
 printJSONValue(OS, R, ".sys", T.getSystemTime());
 if (T.getMemUsed()) {
   OS << delim;
-  printJSONValue(OS, R, ".sys", T.getMemUsed());
+  printJSONValue(OS, R, ".mem", T.getMemUsed());
 }
   }
   TimersToPrint.clear();


Index: llvm/trunk/lib/Support/Timer.cpp
===
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -387,7 +387,7 @@
 printJSONValue(OS, R, ".sys", T.getSystemTime());
 if (T.getMemUsed()) {
   OS << delim;
-  printJSONValue(OS, R, ".sys", T.getMemUsed());
+  printJSONValue(OS, R, ".mem", T.getMemUsed());
 }
   }
   TimersToPrint.clear();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files

2018-05-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:188
+format to stderr. When this option is passed,
+these per-TU profiles are instead stored as YAML.)"),
+  cl::value_desc("prefix"),

Quuxplusone wrote:
> Drive-by nit: Each other help string ends with a newline (`)"),` on a line by 
> itself). This one presumably should too.
Hmm, yeah, at least for consistency.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46602



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


[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files

2018-05-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:188
+format to stderr. When this option is passed,
+these per-TU profiles are instead stored as YAML.)"),
+  cl::value_desc("prefix"),

Drive-by nit: Each other help string ends with a newline (`)"),` on a line by 
itself). This one presumably should too.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46602



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


[PATCH] D46964: Implement class deduction guides for `std::array`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.

According to 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0433r2.html

Once this is reviewed, I'll do the rest of the sequence containers.


https://reviews.llvm.org/D46964

Files:
  include/array
  test/std/containers/sequences/array/array.cons/deduct.fail.cpp
  test/std/containers/sequences/array/array.cons/deduct.pass.cpp

Index: test/std/containers/sequences/array/array.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/array/array.cons/deduct.pass.cpp
+++ test/std/containers/sequences/array/array.cons/deduct.pass.cpp
@@ -0,0 +1,45 @@
+//===--===//
+//
+// 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
+// XFAIL: libcpp-no-deduction-guides
+
+
+// template 
+//   array(T, U...) -> array;
+//
+//  Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed.
+
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+{
+std::array arr{1,2,3};
+static_assert(std::is_same_v>, "");
+assert(arr[0] == 1);
+assert(arr[1] == 2);
+assert(arr[2] == 3);
+}
+
+{
+std::array arr{1L, 4L, 9L, 16L};
+static_assert(std::is_same_v, "");
+static_assert(arr.size() == 4, "");
+assert(arr[0] == 1);
+assert(arr[1] == 4);
+assert(arr[2] == 9);
+}
+}
Index: test/std/containers/sequences/array/array.cons/deduct.fail.cpp
===
--- test/std/containers/sequences/array/array.cons/deduct.fail.cpp
+++ test/std/containers/sequences/array/array.cons/deduct.fail.cpp
@@ -0,0 +1,32 @@
+//===--===//
+//
+// 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
+// XFAIL: libcpp-no-deduction-guides
+
+
+// template 
+//   array(T, U...) -> array;
+//
+//  Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed.
+
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+{
+std::array arr{1,2,3L}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'array'}}
+}
+}
Index: include/array
===
--- include/array
+++ include/array
@@ -72,6 +72,9 @@
 const T* data() const noexcept;
 };
 
+  template 
+array(T, U...) -> array;
+
 template 
   bool operator==(const array& x, const array& y);
 template 
@@ -354,6 +357,14 @@
 };
 
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template && ...), void>::type
+ >
+array(_Tp, _Args...)
+  -> array<_Tp, 1 + sizeof...(_Args)>;
+#endif
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46846: [Attr] Fix loss of enum forward decl from decl context

2018-05-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 147130.
jdenny retitled this revision from "[Attr] Fix printing attrs for enum forward 
decl at file scope" to "[Attr] Fix loss of enum forward decl from decl context".
jdenny edited the summary of this revision.
jdenny added a comment.

Made the suggested change.  Thanks!


https://reviews.llvm.org/D46846

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/ast-print.c
  test/SemaCXX/MicrosoftCompatibility.cpp


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -239,6 +239,15 @@
ENUM2_c = 0x1 // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwardDecl::E NsEnumForwardDecl_e;
+namespace NsEnumForwardDecl {
+  extern E e;
+}
 
 namespace PR11791 {
   template
Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been 
explicitly marked deprecated here}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
@@ -86,8 +88,7 @@
   // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
-// FIXME: If enum is forward-declared at file scope, attributes are lost.
-// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 
*EnumWithAttributes2Ptr;
 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -14343,7 +14343,6 @@
   // PrevDecl.
   TagDecl *New;
 
-  bool IsForwardReference = false;
   if (Kind == TTK_Enum) {
 // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
 // enum X { A, B, C } D;D should chain to X.
@@ -14373,12 +14372,6 @@
 else if (getLangOpts().CPlusPlus)
   DiagID = diag::err_forward_ref_enum;
 Diag(Loc, DiagID);
-
-// If this is a forward-declared reference to an enumeration, make a
-// note of it; we won't actually be introducing the declaration into
-// the declaration context.
-if (TUK == TUK_Reference)
-  IsForwardReference = true;
   }
 }
 
@@ -14536,9 +14529,7 @@
 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
   } else if (Name) {
 S = getNonFieldDeclScope(S);
-PushOnScopeChains(New, S, !IsForwardReference);
-if (IsForwardReference)
-  SearchDC->makeDeclVisibleInContext(New);
+PushOnScopeChains(New, S, true);
   } else {
 CurContext->addDecl(New);
   }


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -239,6 +239,15 @@
 	ENUM2_c = 0x1 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwardDecl::E NsEnumForwardDecl_e;
+namespace NsEnumForwardDecl {
+  extern E e;
+}
 
 namespace PR11791 {
   template
Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is depre

[PATCH] D46963: [Fixed Point Arithmetic] Test for All Builtin Operations

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147131.

Repository:
  rC Clang

https://reviews.llvm.org/D46963

Files:
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- /dev/null
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -Werror %s
+
+// Check that we can use all supported binary and unary operations according to
+// clause 4.1.6 in N1169.
+
+#define ALL_OPERATIONS_FOR_TYPE(TYPE, ID) \
+  TYPE unary_add ## ID (TYPE a)  { return +a; } \
+  TYPE unary_sub ## ID (TYPE a)  { return -a; } \
+  int logical_not ## ID (TYPE a)  { return !a; } \
+  TYPE add ## ID (TYPE a, TYPE b) { return a + b; } \
+  TYPE sub ## ID (TYPE a, TYPE b) { return a - b; } \
+  TYPE mul ## ID (TYPE a, TYPE b) { return a * b; } \
+  TYPE div ## ID (TYPE a, TYPE b) { return a / b; } \
+  TYPE shl ## ID (TYPE a, int b) { return a << b; } \
+  TYPE shr ## ID (TYPE a, int b) { return a >> b; } \
+  TYPE augmented_add ## ID (TYPE a, TYPE b) { a += b; return a; } \
+  TYPE augmented_sub ## ID (TYPE a, TYPE b) { a -= b; return a; } \
+  TYPE augmented_mul ## ID (TYPE a, TYPE b) { a *= b; return a; } \
+  TYPE augmented_div ## ID (TYPE a, TYPE b) { a /= b; return a; } \
+  TYPE augmented_shl ## ID (TYPE a, int b) { a <<= b; return a; } \
+  TYPE augmented_shr ## ID (TYPE a, int b) { a >>= b; return a; } \
+  int eq ## ID (TYPE a, TYPE b) { return a == b; } \
+  int ne ## ID (TYPE a, TYPE b) { return a != b; } \
+  int lt ## ID (TYPE a, TYPE b) { return a < b; } \
+  int le ## ID (TYPE a, TYPE b) { return a <= b; } \
+  int ge ## ID (TYPE a, TYPE b) { return a >= b; } \
+  int gt ## ID (TYPE a, TYPE b) { return a > b; } \
+  TYPE pre_inc ## ID (TYPE a) { return ++a; } \
+  TYPE pre_dec ## ID (TYPE a) { return --a; } \
+  TYPE post_inc ## ID (TYPE a) { return a++; } \
+  TYPE post_dec ## ID (TYPE a) { return a--; } \
+  TYPE deref_pre_inc ## ID (TYPE *a) { return ++(*a); } \
+  TYPE deref_pre_dec ## ID (TYPE *a) { return --(*a); } \
+  TYPE deref_post_inc ## ID (TYPE *a) { return (*a)++; } \
+  TYPE deref_post_dec ## ID (TYPE *a) { return (*a)--; }
+
+#define ALL_OPERATIONS(TYPE, ID) \
+  ALL_OPERATIONS_FOR_TYPE(TYPE, ID) \
+  ALL_OPERATIONS_FOR_TYPE(signed TYPE, Signed ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(unsigned TYPE, Unsigned ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat TYPE, Sat ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat signed TYPE, SatSigned ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat unsigned TYPE, SatUnsigned ## ID)
+
+ALL_OPERATIONS(short _Fract, ShortFract);
+ALL_OPERATIONS(_Fract, Fract);
+ALL_OPERATIONS(long _Fract, LongFract);
+ALL_OPERATIONS(short _Accum, ShortAccum);
+ALL_OPERATIONS(_Accum, Accum);
+ALL_OPERATIONS(long _Accum, LongAccum);
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2204,17 +2204,29 @@
 const auto *BT = type->getAs();
 switch (BT->getKind()) {
   default: llvm_unreachable("Not a fixed point type!");
+  case BuiltinType::SatShortAccum:
   case BuiltinType::ShortAccum:   fbits = BUILTIN_SACCUM_FBIT; break;
+  case BuiltinType::SatAccum:
   case BuiltinType::Accum:fbits = BUILTIN_ACCUM_FBIT; break;
+  case BuiltinType::SatLongAccum:
   case BuiltinType::LongAccum:fbits = BUILTIN_LACCUM_FBIT; break;
+  case BuiltinType::SatUShortAccum:
   case BuiltinType::UShortAccum:  fbits = BUILTIN_USACCUM_FBIT; break;
+  case BuiltinType::SatUAccum:
   case BuiltinType::UAccum:   fbits = BUILTIN_UACCUM_FBIT; break;
+  case BuiltinType::SatULongAccum:
   case BuiltinType::ULongAccum:   fbits = BUILTIN_ULACCUM_FBIT; break;
+  case BuiltinType::SatShortFract:
   case BuiltinType::ShortFract:   fbits = BUILTIN_SFRACT_FBIT; break;
+  case BuiltinType::SatFract:
   case BuiltinType::Fract:fbits = BUILTIN_FRACT_FBIT; break;
+  case BuiltinType::SatLongFract:
   case BuiltinType::LongFract:fbits = BUILTIN_LFRACT_FBIT; break;
+  case BuiltinType::SatUShortFract:
   case BuiltinType::UShortFract:  fbits = BUILTIN_USFRACT_FBIT; break;
+  case BuiltinType::SatUFract:
   case BuiltinType::UFract:   fbits = BUILTIN_UFRACT_FBIT; break;
+  case BuiltinType::SatULongFract:
   case BuiltinType::ULongFract:   fbits = BUILTIN_ULFRACT_FBIT; break;
 }
 llvm::Value *amt = llvm::ConstantInt::get(value->getType(), 1ULL << fbits,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1797,6 +1797,10 @@
 case BuiltinType::UShortAccum:
 case BuiltinType::ShortFract:
 case BuiltinType::UShortFract:
+case BuiltinType::SatShortAccum:
+case BuiltinTy

[PATCH] D46603: [Support] TimerGroup changes

2018-05-16 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> Not sure yet whether i will land them right away, or wait for clang-tidy part.

I think it's better to land, as otherwise you risk merge conflicts, and 
implicit conflicts (git reports no errors, but the resulting code is bad) can 
be very annoying.


Repository:
  rL LLVM

https://reviews.llvm.org/D46603



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


[PATCH] D46603: [Support] TimerGroup changes

2018-05-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D46603#1101047, @lebedev.ri wrote:

> In https://reviews.llvm.org/D46603#1100455, @george.karpenkov wrote:
>
> > I see four separate changes: s/.sys/mem one (can be committed without 
> > review), exposing printJSONValues and consequent adding of a lock, adding a 
> > constructor accepting a map, and fixing formatting in `printJSONValue`. All 
> > four look good to me, but probably should be reviewed separately.
>
>
> Thank you for taking a look!
>  Posted as https://reviews.llvm.org/D46936, https://reviews.llvm.org/D46937, 
> https://reviews.llvm.org/D46938, https://reviews.llvm.org/D46939


@alexfh & @george.karpenkov Thanks for reviewing those!
Not sure yet whether i will land them right away, or wait for clang-tidy part.


Repository:
  rL LLVM

https://reviews.llvm.org/D46603



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


[PATCH] D46937: [Timers] TimerGroup::printJSONValue(): print doubles with no precision loss

2018-05-16 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D46937



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


[PATCH] D46944: [analyzer] Use sufficiently large types for index/size calculation.

2018-05-16 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1344
   // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize, false);
+  return svalBuilder.makeIntVal(RegionSize / EleSize, Ctx.getSignedSizeType());
 }

a.sidorin wrote:
> ebevhan wrote:
> > a.sidorin wrote:
> > > I think we should initialize SValBuilder::ArrayIndexTy with 
> > > getSignedSizeType() instead of LongLongTy and use 
> > > `svalBuilder.getArrayIndexType()` here instead.
> > I made the change, but it caused a spurious out of bounds warning in 
> > index-type.c for the 32-bit case. Making the type signed means that 
> > anything above MAX/2 will break, and the test uses arrays of that size.
> Hm, yes. ssize_t is 32-bit on 32-bit targets but our indices can exceed it. 
> Even if so, `svalBuilder.getArrayIndexType()` should be fine.
Well, the problem is that it's only enough for objects whose size is less than 
half of the range. If they're larger, the out of bounds calculation overflows 
and it thinks that we're trying to index outside the object (at a lower 
address).

The 64-bit test avoids this since its array is smaller. It's MAX/16 instead.


Repository:
  rC Clang

https://reviews.llvm.org/D46944



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


[PATCH] D46963: [Fixed Point Arithmetic] Test for All Builtin Operations

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch includes a test for checking that all supported builtin operations 
can be syntactically declared with fixed point types. Tests for asserting the 
correctness behind each operation will be added in future patches.

This is a child of https://reviews.llvm.org/D46960


Repository:
  rC Clang

https://reviews.llvm.org/D46963

Files:
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- /dev/null
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -Werror %s
+
+// Check that we can use all supported binary and unary operations according to
+// clause 4.1.6 in N1169.
+
+#define ALL_OPERATIONS_FOR_TYPE(TYPE, ID) \
+  TYPE unary_add ## ID (TYPE a)  { return +a; } \
+  TYPE unary_sub ## ID (TYPE a)  { return -a; } \
+  int logical_not ## ID (TYPE a)  { return !a; } \
+  TYPE add ## ID (TYPE a, TYPE b) { return a + b; } \
+  TYPE sub ## ID (TYPE a, TYPE b) { return a - b; } \
+  TYPE mul ## ID (TYPE a, TYPE b) { return a * b; } \
+  TYPE div ## ID (TYPE a, TYPE b) { return a / b; } \
+  TYPE shl ## ID (TYPE a, int b) { return a << b; } \
+  TYPE shr ## ID (TYPE a, int b) { return a >> b; } \
+  TYPE augmented_add ## ID (TYPE a, TYPE b) { a += b; return a; } \
+  TYPE augmented_sub ## ID (TYPE a, TYPE b) { a -= b; return a; } \
+  TYPE augmented_mul ## ID (TYPE a, TYPE b) { a *= b; return a; } \
+  TYPE augmented_div ## ID (TYPE a, TYPE b) { a /= b; return a; } \
+  TYPE augmented_shl ## ID (TYPE a, int b) { a <<= b; return a; } \
+  TYPE augmented_shr ## ID (TYPE a, int b) { a >>= b; return a; } \
+  int eq ## ID (TYPE a, TYPE b) { return a == b; } \
+  int ne ## ID (TYPE a, TYPE b) { return a != b; } \
+  int lt ## ID (TYPE a, TYPE b) { return a < b; } \
+  int le ## ID (TYPE a, TYPE b) { return a <= b; } \
+  int ge ## ID (TYPE a, TYPE b) { return a >= b; } \
+  int gt ## ID (TYPE a, TYPE b) { return a > b; } \
+  TYPE pre_inc ## ID (TYPE a) { return ++a; } \
+  TYPE pre_dec ## ID (TYPE a) { return --a; } \
+  TYPE post_inc ## ID (TYPE a) { return a++; } \
+  TYPE post_dec ## ID (TYPE a) { return a--; } \
+  TYPE deref_pre_inc ## ID (TYPE *a) { return ++(*a); } \
+  TYPE deref_pre_dec ## ID (TYPE *a) { return --(*a); } \
+  TYPE deref_post_inc ## ID (TYPE *a) { return (*a)++; } \
+  TYPE deref_post_dec ## ID (TYPE *a) { return (*a)--; }
+
+#define ALL_OPERATIONS(TYPE, ID) \
+  ALL_OPERATIONS_FOR_TYPE(TYPE, ID) \
+  ALL_OPERATIONS_FOR_TYPE(signed TYPE, Signed ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(unsigned TYPE, Unsigned ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat TYPE, Sat ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat signed TYPE, SatSigned ## ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat unsigned TYPE, SatUnsigned ## ID)
+
+ALL_OPERATIONS(short _Fract, sf);
+ALL_OPERATIONS(_Fract, f);
+ALL_OPERATIONS(long _Fract, lf);
+ALL_OPERATIONS(short _Accum, sa);
+ALL_OPERATIONS(_Accum, a);
+ALL_OPERATIONS(long _Accum, la);
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2204,17 +2204,29 @@
 const auto *BT = type->getAs();
 switch (BT->getKind()) {
   default: llvm_unreachable("Not a fixed point type!");
+  case BuiltinType::SatShortAccum:
   case BuiltinType::ShortAccum:   fbits = BUILTIN_SACCUM_FBIT; break;
+  case BuiltinType::SatAccum:
   case BuiltinType::Accum:fbits = BUILTIN_ACCUM_FBIT; break;
+  case BuiltinType::SatLongAccum:
   case BuiltinType::LongAccum:fbits = BUILTIN_LACCUM_FBIT; break;
+  case BuiltinType::SatUShortAccum:
   case BuiltinType::UShortAccum:  fbits = BUILTIN_USACCUM_FBIT; break;
+  case BuiltinType::SatUAccum:
   case BuiltinType::UAccum:   fbits = BUILTIN_UACCUM_FBIT; break;
+  case BuiltinType::SatULongAccum:
   case BuiltinType::ULongAccum:   fbits = BUILTIN_ULACCUM_FBIT; break;
+  case BuiltinType::SatShortFract:
   case BuiltinType::ShortFract:   fbits = BUILTIN_SFRACT_FBIT; break;
+  case BuiltinType::SatFract:
   case BuiltinType::Fract:fbits = BUILTIN_FRACT_FBIT; break;
+  case BuiltinType::SatLongFract:
   case BuiltinType::LongFract:fbits = BUILTIN_LFRACT_FBIT; break;
+  case BuiltinType::SatUShortFract:
   case BuiltinType::UShortFract:  fbits = BUILTIN_USFRACT_FBIT; break;
+  case BuiltinType::SatUFract:
   case BuiltinType::UFract:   fbits = BUILTIN_UFRACT_FBIT; break;
+  case BuiltinType::SatULongFract:
   case BuiltinType::ULongFract:   fbits = BUILTIN_ULFRACT_FBIT; break;
 }
 llvm::Value *amt = llvm::ConstantInt::get(value->getType(), 1ULL << fbits,
Index: lib/AST/A

[PATCH] D46602: [clang-tidy] Store checks profiling info as YAML files

2018-05-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 147120.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

Rename getter/setter functions.

Thank you for taking a look!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46602

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyProfiling.cpp
  clang-tidy/ClangTidyProfiling.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/clang-tidy-enable-check-profile-one-tu.cpp
  test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
  test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp

Index: test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-store-check-profile-one-tu.cpp
@@ -0,0 +1,37 @@
+// RUN: rm -rf %T/out
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s
+// RUN: cat %T/out/*-clang-tidy-store-check-profile-one-tu.cpp.yaml | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-FILE %s
+// RUN: rm -rf %T/out
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s
+// RUN: cat %T/out/*-clang-tidy-store-check-profile-one-tu.cpp.yaml | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-FILE %s
+
+// CHECK-CONSOLE-NOT: ===-===
+// CHECK-CONSOLE-NOT: {{.*}}  --- Name ---
+// CHECK-CONSOLE-NOT: {{.*}}  readability-function-size
+// CHECK-CONSOLE-NOT: {{.*}}  Total
+// CHECK-CONSOLE-NOT: ===-===
+
+// CHECK-FILE: {
+// CHECK-FILE-NEXT:"file": "{{.*}}clang-tidy-store-check-profile-one-tu.cpp",
+// CHECK-FILE-NEXT:"timestamp": "{{[0-9]+}}-{{[0-9]+}}-{{[0-9]+}} {{[0-9]+}}:{{[0-9]+}}:{{[0-9]+}}.{{[0-9]+}}",
+// CHECK-FILE-NEXT:"profile": {
+// CHECK-FILE-NEXT:	"time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NEXT:	"time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NEXT:	"time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
+// CHECK-FILE-NEXT: }
+// CHECK-FILE-NEXT: }
+
+// CHECK-FILE-NOT: {
+// CHECK-FILE-NOT: "file": {{.*}}clang-tidy-store-check-profile-one-tu.cpp{{.*}},
+// CHECK-FILE-NOT: "timestamp": "{{[0-9]+}}-{{[0-9]+}}-{{[0-9]+}} {{[0-9]+}}:{{[0-9]+}}:{{[0-9]+}}.{{[0-9]+}}",
+// CHECK-FILE-NOT: "profile": {
+// CHECK-FILE-NOT:	"time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NOT:	"time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NOT:	"time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
+// CHECK-FILE-NOT: }
+// CHECK-FILE-NOT: }
+
+class A {
+  A() {}
+  ~A() {}
+};
Index: test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
===
--- test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
+++ test/clang-tidy/clang-tidy-enable-check-profile-two-tu.cpp
@@ -1,22 +1,31 @@
 // RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s %s 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK: ===-===
-// CHECK-NEXT: {{.*}}  --- Name ---
+// CHECK-NEXT:  clang-tidy checks profiling
+// CHECK-NEXT: ===-===
+// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK: {{.*}}  --- Name ---
 // CHECK-NEXT: {{.*}}  readability-function-size
 // CHECK-NEXT: {{.*}}  Total
-// CHECK-NEXT: ===-===
 
 // CHECK: ===-===
-// CHECK-NEXT: {{.*}}  --- Name ---
+// CHECK-NEXT:  clang-tidy checks profiling
+// CHECK-NEXT: ===-===
+// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK: {{.*}}  --- Name ---
 // CHECK-NEXT: {{.*}}  readability-function-size
 /

[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous abandoned this revision.
jkorous added a comment.

We reconsidered this in light of the policy - thanks for pointing that out 
Richard! 
Just to be sure that I understand it - the policy is meant for CLI and not 
serialized diagnostics, right?


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[PATCH] D43352: Add support for __declspec(code_seg("segname"))

2018-05-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Woops, forgot the tests when commiting, so see R332492 for the lit tests.


Repository:
  rC Clang

https://reviews.llvm.org/D43352



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


r332492 - Add lit tests forgotten for R332470

2018-05-16 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 16 10:04:47 2018
New Revision: 332492

URL: http://llvm.org/viewvc/llvm-project?rev=332492&view=rev
Log:
Add lit tests forgotten for R332470

I forgot to svn-add the lit tests for R332470.  
Added here!

Added:
cfe/trunk/test/CodeGenCXX/code_seg1.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg2.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg3.cpp   (with props)
cfe/trunk/test/CodeGenCXX/code_seg4.cpp   (with props)
cfe/trunk/test/SemaCXX/code_seg.cpp   (with props)
cfe/trunk/test/SemaCXX/code_seg1.cpp   (with props)

Added: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/code_seg1.cpp?rev=332492&view=auto
==
--- cfe/trunk/test/CodeGenCXX/code_seg1.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/code_seg1.cpp Wed May 16 10:04:47 2018
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o 
- %s | FileCheck %s
+// expected-no-diagnostics
+
+// Simple case
+
+int __declspec(code_seg("foo_one")) bar_one() { return 1; }
+//CHECK: define {{.*}}bar_one{{.*}} section "foo_one"
+
+// Simple case - explicit attribute used over pragma
+#pragma code_seg("foo_two")
+int __declspec(code_seg("foo_three")) bar2() { return 2; }
+//CHECK: define {{.*}}bar2{{.*}} section "foo_three"
+
+// Check that attribute on one function doesn't affect another
+int another1() { return 1001; }
+//CHECK: define {{.*}}another1{{.*}} section "foo_two"
+
+// Member functions
+
+struct __declspec(code_seg("foo_four")) Foo {
+  int bar3() {return 0;}
+  int bar4();
+  int __declspec(code_seg("foo_six")) bar6() { return 6; }
+  int bar7() { return 7; }
+  struct Inner {
+int bar5() { return 5; }
+  } z;
+  virtual int baz1() { return 1; }
+};
+
+struct __declspec(code_seg("foo_four")) FooTwo : Foo {
+  int baz1() { return 20; }
+};
+
+int caller1() {
+  Foo f; return f.bar3();
+}
+
+//CHECK: define {{.*}}bar3@Foo{{.*}} section "foo_four"
+int Foo::bar4() { return 4; }
+//CHECK: define {{.*}}bar4@Foo{{.*}} section "foo_four"
+
+#pragma code_seg("someother")
+
+int caller2() {
+  Foo f;
+  Foo *fp = new FooTwo;
+  return f.z.bar5() + f.bar6() + f.bar7() + fp->baz1();
+}
+// TBD: MS Compiler and Docs do not match for nested routines
+// Doc says:  define {{.*}}bar5@Inner@Foo{{.*}} section "foo_four"
+// Compiler says: define {{.*}}bar5@Inner@Foo{{.*}} section "foo_two"
+//CHECK: define {{.*}}bar6@Foo{{.*}} section "foo_six"
+//CHECK: define {{.*}}bar7@Foo{{.*}} section "foo_four"
+// Check that code_seg active at class declaration is not used on member
+// declared outside class when it is not active.
+
+#pragma code_seg(push,"AnotherSeg")
+
+struct FooThree {
+  int bar8();
+  int bar9() { return 9; }
+};
+
+#pragma code_seg(pop)
+
+
+int FooThree::bar8() {return 0;}
+
+int caller3()
+{
+  FooThree f;
+  return f.bar8() + f.bar9();
+}
+
+//CHECK: define {{.*}}bar8@FooThree{{.*}} section "someother"
+//CHECK: define {{.*}}bar9@FooThree{{.*}} section "AnotherSeg"
+
+struct NonTrivialCopy {
+  NonTrivialCopy();
+  NonTrivialCopy(const NonTrivialCopy&);
+  ~NonTrivialCopy();
+};
+
+// check the section for compiler-generated function with declspec.
+
+struct __declspec(code_seg("foo_seven")) FooFour {
+  FooFour() {}
+  int __declspec(code_seg("foo_eight")) bar10(int t) { return t; }
+  NonTrivialCopy f;
+};
+
+//CHECK: define {{.*}}0FooFour@@QAE@ABU0@@Z{{.*}} section "foo_seven"
+// check the section for compiler-generated function with no declspec.
+
+struct FooFive {
+  FooFive() {}
+  int __declspec(code_seg("foo_nine")) bar11(int t) { return t; }
+  NonTrivialCopy f;
+};
+
+//CHECK: define {{.*}}0FooFive@@QAE@ABU0@@Z{{.*}} section "someother"
+
+#pragma code_seg("YetAnother")
+int caller4()
+{
+  FooFour z1;
+  FooFour z2 = z1;
+  FooFive y1;
+  FooFive y2 = y1;
+  return z2.bar10(0) + y2.bar11(1);
+}
+
+//CHECK: define {{.*}}bar10@FooFour{{.*}} section "foo_eight"
+//CHECK: define {{.*}}bar11@FooFive{{.*}} section "foo_nine"
+
+struct FooSix {
+  #pragma code_seg("foo_ten")
+  int bar12() { return 12; }
+  #pragma code_seg("foo_eleven")
+  int bar13() { return 13; }
+};
+
+int bar14() { return 14; }
+//CHECK: define {{.*}}bar14{{.*}} section "foo_eleven"
+
+int caller5()
+{
+  FooSix fsix;
+  return fsix.bar12() + fsix.bar13();
+}
+
+//CHECK: define {{.*}}bar12@FooSix{{.*}} section "foo_ten"
+//CHECK: define {{.*}}bar13@FooSix{{.*}} section "foo_eleven"
+//CHECK: define {{.*}}baz1@FooTwo{{.*}} section "foo_four"

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGenCXX/code_seg1.cpp
--

r332491 - [Modules] Do not diagnose missing import in recovery mode if there isn't a decl to lookup

2018-05-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed May 16 10:00:24 2018
New Revision: 332491

URL: http://llvm.org/viewvc/llvm-project?rev=332491&view=rev
Log:
[Modules] Do not diagnose missing import in recovery mode if there isn't a decl 
to lookup

Clang often tries to create implicit module import for error recovery,
which does a great job helping out with diagnostics. However, sometimes
clang does not have enough information given that it's using an invalid
context to move on. Be more strict in those cases to avoid crashes.

We hit crash on invalids because of this but unfortunately there are no
testcases and I couldn't manage to create one. The crashtrace however
indicates pretty clear why it's happening.

rdar://problem/39313933

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

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=332491&r1=332490&r2=332491&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 16 10:00:24 2018
@@ -7613,7 +7613,7 @@ bool Sema::RequireCompleteTypeImpl(Sourc
   // If the user is going to see an error here, recover by making the
   // definition visible.
   bool TreatAsComplete = Diagnoser && !isSFINAEContext();
-  if (Diagnoser)
+  if (Diagnoser && SuggestedDef)
 diagnoseMissingImport(Loc, SuggestedDef, MissingImportKind::Definition,
   /*Recover*/TreatAsComplete);
   return !TreatAsComplete;


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


[PATCH] D46958: [ASTImporter] Fix missing implict CXXRecordDecl

2018-05-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

So, we fail to add injected name to a CXXRecordDecl that has a described class 
template? Nice catch! LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D46958



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


[PATCH] D46960: [Fixed Point Arithmetic] Predefined Precision Macros

2018-05-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch contains the addition of the precision macros for integral and 
fractional bits according to clause 7.18a.3 of 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf. The macros are 
integer constants and added as predefined macros.

  // Fractional bits of _Accum types
  __SACCUM_FBIT__
  __ACCUM_FBIT__
  __LACCUM_FBIT__
  __USACCUM_FBIT__
  __UACCUM_FBIT__
  __ULACCUM_FBIT__
  
  // Fractional bits of _Fract types
  __SFRACT_FBIT__
  __FRACT_FBIT__
  __LFRACT_FBIT__
  __USFRACT_FBIT__
  __UFRACT_FBIT__
  __ULFRACT_FBIT__
  
  // Integral bits of _Accum types
  __SACCUM_IBIT__
  __ACCUM_IBIT__
  __LACCUM_IBIT__
  __USACCUM_IBIT__
  __UACCUM_IBIT__
  __ULACCUM_IBIT__

This is a child of https://reviews.llvm.org/D46927


Repository:
  rC Clang

https://reviews.llvm.org/D46960

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Frontend/fixed_point_builtin_macros.c

Index: test/Frontend/fixed_point_builtin_macros.c
===
--- /dev/null
+++ test/Frontend/fixed_point_builtin_macros.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+
+#define assert(b) if (!(b)) { return 1; }
+
+int main() {
+  // Test using the recommended values for a typical desktop processor (Annex
+  // A.3). These are also the default values when building clang.
+  // Fractional bits of _Accum types
+  assert(__SACCUM_FBIT__  == 7);
+  assert(__ACCUM_FBIT__   == 15);
+  assert(__LACCUM_FBIT__  == 31);
+  assert(__USACCUM_FBIT__ == 8);
+  assert(__UACCUM_FBIT__  == 16);
+  assert(__ULACCUM_FBIT__ == 32);
+
+  // Fractional bits of _Fract types
+  assert(__SFRACT_FBIT__  == 7);
+  assert(__FRACT_FBIT__   == 15);
+  assert(__LFRACT_FBIT__  == 31);
+  assert(__USFRACT_FBIT__ == 8);
+  assert(__UFRACT_FBIT__  == 16);
+  assert(__ULFRACT_FBIT__ == 32);
+
+  // Integral bits of _Accum types
+  assert(__SACCUM_IBIT__  == 8);
+  assert(__ACCUM_IBIT__   == 16);
+  assert(__LACCUM_IBIT__  == 32);
+  assert(__USACCUM_IBIT__ == 8);
+  assert(__UACCUM_IBIT__  == 16);
+  assert(__ULACCUM_IBIT__ == 32);
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
@@ -355,6 +356,31 @@
   Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro(*this, "__INCLUDE_LEVEL__");
   Ident__TIMESTAMP__ = RegisterBuiltinMacro(*this, "__TIMESTAMP__");
 
+  // Fixed point macros (ISO/IEC JTC1 SC22 WG14 N1169)
+  // Fractional bits of _Accum types
+  Ident__SACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__SACCUM_FBIT__");
+  Ident__ACCUM_FBIT__= RegisterBuiltinMacro(*this, "__ACCUM_FBIT__");
+  Ident__LACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__LACCUM_FBIT__");
+  Ident__USACCUM_FBIT__  = RegisterBuiltinMacro(*this, "__USACCUM_FBIT__");
+  Ident__UACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__UACCUM_FBIT__");
+  Ident__ULACCUM_FBIT__  = RegisterBuiltinMacro(*this, "__ULACCUM_FBIT__");
+
+  // Fractional bits of _Fract types
+  Ident__SFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__SFRACT_FBIT__");
+  Ident__FRACT_FBIT__= RegisterBuiltinMacro(*this, "__FRACT_FBIT__");
+  Ident__LFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__LFRACT_FBIT__");
+  Ident__USFRACT_FBIT__  = RegisterBuiltinMacro(*this, "__USFRACT_FBIT__");
+  Ident__UFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__UFRACT_FBIT__");
+  Ident__ULFRACT_FBIT__  = RegisterBuiltinMacro(*this, "__ULFRACT_FBIT__");
+
+  // Integral bits of _Accum types
+  Ident__SACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__SACCUM_IBIT__");
+  Ident__ACCUM_IBIT__= RegisterBuiltinMacro(*this, "__ACCUM_IBIT__");
+  Ident__LACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__LACCUM_IBIT__");
+  Ident__USACCUM_IBIT__  = RegisterBuiltinMacro(*this, "__USACCUM_IBIT__");
+  Ident__UACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__UACCUM_IBIT__");
+  Ident__ULACCUM_IBIT__  = RegisterBuiltinMacro(*this, "__ULACCUM_IBIT__");
+
   // Microsoft Extensions.
   if (LangOpts.MicrosoftExt) {
 Ident__identifier = RegisterBuiltinMacro(*this, "__identifier");
@@ -1696,6 +1722,68 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
+
+  // Fixed point macros
+  // Fractional bits of _Accum types
+  } else if (II == Ident__SACCUM_FBIT__) {
+OS << BUILTIN_SACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__ACCUM_FBIT__) {
+OS << BUILTIN_ACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident_

  1   2   3   >