Re: [PATCH] D21390: redefinition of '__true_type' struct __true_type {}; - Bug 27991

2016-06-16 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r272877.



Comment at: include/llvm/module.modulemap:121-126
@@ -106,8 +120,8 @@
 
   // FIXME: Is this the right place for these?
   module Pass { header "Pass.h" export * }
   module PassSupport { header "PassSupport.h" export * }
   module PassAnalysisSupport { header "PassAnalysisSupport.h" export * }
   module PassRegistry { header "PassRegistry.h" export * }
   module InitializePasses { header "InitializePasses.h" export * }
 

rsmith wrote:
> You should be able to remove all of these too.
Done.


Repository:
  rL LLVM

http://reviews.llvm.org/D21390



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


Re: [PATCH] D21277: Resubmit r270688: Using new TargetParser in Clang.

2016-06-16 Thread Renato Golin via cfe-commits
rengolin added a comment.

Hi Jojo,

This looks good to me, and I recommend you squash this patch with 
http://reviews.llvm.org/D21276 before commit. But I'll let @echristo and 
@compnerd have the final say.

cheers,
--renato


Repository:
  rL LLVM

http://reviews.llvm.org/D21277



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


Re: r272741 - Headers: tweak for MSVC[<1800]

2016-06-16 Thread Nico Weber via cfe-commits
Maybe this should use the marketing name ("before msvc 2013")? People might
be more familiar with that.
On Jun 15, 2016 2:34 AM, "Saleem Abdulrasool via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Tue Jun 14 19:28:15 2016
> New Revision: 272741
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272741&view=rev
> Log:
> Headers: tweak for MSVC[<1800]
>
> Earlier versions of MSVC did not include inttypes.h.  Ensure that we dont
> try to
> include_next on those releases.
>
> Modified:
> cfe/trunk/lib/Headers/inttypes.h
>
> Modified: cfe/trunk/lib/Headers/inttypes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/inttypes.h?rev=272741&r1=272740&r2=272741&view=diff
>
> ==
> --- cfe/trunk/lib/Headers/inttypes.h (original)
> +++ cfe/trunk/lib/Headers/inttypes.h Tue Jun 14 19:28:15 2016
> @@ -23,6 +23,10 @@
>  #ifndef __CLANG_INTTYPES_H
>  #define __CLANG_INTTYPES_H
>
> +#if defined(_MSC_VER) && _MSC_VER < 1800
> +#error MSVC <= 11.0 does not have inttypes.h
> +#endif
> +
>  #include_next 
>
>  #if defined(_MSC_VER) && _MSC_VER < 1900
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated the summary for this revision.
rogfer01 updated this revision to Diff 60951.
rogfer01 added a comment.

Thanks @rsmith for the suggestions. I removed the whitelisting totally and 
changed the strategy. This patch implements your second suggestion which seemed 
more obvious to me. Since I expect the set of gathered misaligned member 
designations be small, I am using a plain SmallVector but maybe there is a more 
suitable structure.

I am now building Firefox and will post an update with the results.


http://reviews.llvm.org/D20561

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  test/Sema/address-packed-member-memops.c
  test/Sema/address-packed.c
  test/SemaCXX/address-packed-member-memops.cpp
  test/SemaCXX/address-packed.cpp

Index: test/SemaCXX/address-packed.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct __attribute__((packed)) Arguable {
+  int x;
+  char c;
+  static void foo();
+};
+
+extern void f3(void());
+
+namespace Foo {
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+  static void foo();
+};
+}
+
+struct Arguable *get_arguable();
+
+void f4(int &);
+
+void to_void(void *);
+
+template 
+void sink(T...);
+
+void g0() {
+  {
+Foo::Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+
+int &w = arguable.x; // expected-error {{binding reference to packed member 'x' of class or structure 'Foo::Arguable'}}
+sink(w);
+f4(arguable.x); // expected-error {{binding reference to packed member 'x' of class or structure 'Foo::Arguable'}}
+
+to_void(&arguable.x); // no-warning
+void *p1 = &arguable.x;   // no-warning
+void *p2 = static_cast(&arguable.x);  // no-warning
+void *p3 = reinterpret_cast(&arguable.x); // no-warning
+void *p4 = (void *)&arguable.x;   // no-warning
+sink(p1, p2, p3, p4);
+  }
+  {
+Arguable arguable1;
+Arguable &arguable(arguable1);
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable *arguable1;
+Arguable *&arguable(arguable1);
+f1(&arguable->x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable->c);   // no-warning
+f3(&arguable->foo); // no-warning
+  }
+}
+
+struct __attribute__((packed)) A {
+  int x;
+  char c;
+
+  int *f0() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g0() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h0() {
+return &c; // no-warning
+  }
+};
+
+struct B : A {
+  int *f1() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g1() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h1() {
+return &c; // no-warning
+  }
+};
+
+template 
+class __attribute__((packed)) S {
+  Ty X;
+
+public:
+  const Ty *get() const {
+return &X; // expected-warning {{packed member 'X' of class or structure 'S'}}
+   // expected-warning@-1 {{packed member 'X' of class or structure 'S'}}
+  }
+};
+
+template 
+void h(Ty *);
+
+void g1() {
+  S s1;
+  s1.get(); // expected-note {{in instantiation of member function 'S::get'}}
+
+  S s2;
+  s2.get();
+
+  S s3;
+  s3.get(); // expected-note {{in instantiation of member function 'S::get'}}
+}
Index: test/SemaCXX/address-packed-member-memops.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed-member-memops.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct B {
+  int x, y, z, w;
+} b;
+
+struct __attribute__((packed)) A {
+  struct B b;
+} a;
+
+typedef __typeof__(sizeof(int)) size_t;
+
+extern "C" {
+void *memcpy(void *dest, const void *src, size_t n);
+int memcmp(const void *s1, const void *s2, size_t n);
+void *memmove(void *dest, const void *src, size_t n);
+void *memset(void *s, int c, size_t n);
+}
+
+int x;
+
+void foo() {
+  memcpy(&a.b, &b, sizeof(b));
+  memmove(&a.b, &b, sizeof(b));
+  memset(&a.b, 0, sizeof(b));
+  x = memcmp(&a.b, &b, sizeof(b));
+}
Index: test/Sema/address-packed.c
===
--- /dev/null
+++ test/Sema/address-packed.c
@@ -0,0 +1,143 @@
+// RUN: %clang_cc1

Re: [PATCH] D21277: Resubmit r270688: Using new TargetParser in Clang.

2016-06-16 Thread jojo.ma via cfe-commits
jojo added a comment.

>   I recommend you squash this patch with D21276 before commit. 


Hi, Renato,
Do you mean updating the diff to let it include the change of 
http://reviews.llvm.org/D21276,or commiting these two reviews as one commit?


Repository:
  rL LLVM

http://reviews.llvm.org/D21277



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


Re: [PATCH] D15321: [OpenMP 4.0]Parsing and Sema support for 'omp declare target' directive (accelerator support)

2016-06-16 Thread Alexey Bataev via cfe-commits
ABataev abandoned this revision.
ABataev added a comment.

Revision is abandoned as the construct is supported already.


http://reviews.llvm.org/D15321



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


Re: [PATCH] D21150: [OpenMP] Cast captures by copy when passed to fork call so that they are compatible to what the runtime library expects.

2016-06-16 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D21150



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


Re: [PATCH] D19274: Compilation for Intel MCU (Part 2/3)

2016-06-16 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272883: Compilation for Intel MCU (Part 2/3) (authored by 
aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D19274?vs=57017&id=60958#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19274

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/miamcu-opt.c
  cfe/trunk/test/Driver/miamcu-opt.cpp

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -418,6 +418,10 @@
   virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const;
 
+  /// \brief Add arguments to use MCU GCC toolchain includes.
+  virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const;
+
   /// \brief Return sanitizers which are available in this toolchain.
   virtual SanitizerMask getSupportedSanitizers() const;
 
Index: cfe/trunk/test/Driver/miamcu-opt.c
===
--- cfe/trunk/test/Driver/miamcu-opt.c
+++ cfe/trunk/test/Driver/miamcu-opt.c
@@ -16,3 +16,6 @@
 // CHECK: "-static-define"
 // CHECK: "-mfloat-abi" "soft"
 // CHECK: "-mstack-alignment=4"
+
+// CHECK: bin/ld
+// CHECK: "-static"
Index: cfe/trunk/test/Driver/miamcu-opt.cpp
===
--- cfe/trunk/test/Driver/miamcu-opt.cpp
+++ cfe/trunk/test/Driver/miamcu-opt.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang -miamcu %s -### -o %t.o 2>&1 | FileCheck %s
+
+// CHECK: error: the clang compiler does not support 'C++ for IAMCU'
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -295,6 +295,7 @@
 const InputInfoList &Inputs,
 const ToolChain *AuxToolChain) const {
   Arg *A;
+  const bool IsIAMCU = getToolChain().getTriple().isOSIAMCU();
 
   CheckPreprocessingOptions(D, Args);
 
@@ -562,10 +563,15 @@
   AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
   }
 
-  // Add system include arguments.
-  getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
-  if (AuxToolChain)
+  // Add system include arguments for all targets but IAMCU.
+  if (!IsIAMCU) {
+getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
+if (AuxToolChain)
   AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+  } else {
+// For IAMCU add special include arguments.
+getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
+  }
 
   // Add CUDA include arguments, if needed.
   if (types::isCuda(Inputs[0].getType()))
@@ -3742,6 +3748,7 @@
   getToolChain().getTriple().isWindowsCygwinEnvironment();
   bool IsWindowsMSVC = getToolChain().getTriple().isWindowsMSVCEnvironment();
   bool IsPS4CPU = getToolChain().getTriple().isPS4CPU();
+  bool IsIAMCU = getToolChain().getTriple().isOSIAMCU();
 
   // Check number of inputs for sanity. We need at least one input.
   assert(Inputs.size() >= 1 && "Must have at least one input.");
@@ -3752,6 +3759,10 @@
   bool IsCuda = types::isCuda(Input.getType());
   assert((IsCuda || Inputs.size() == 1) && "Unable to handle multiple inputs.");
 
+  // C++ is not supported for IAMCU.
+  if (IsIAMCU && types::isCXX(Input.getType()))
+D.Diag(diag::err_drv_clang_unsupported) << "C++ for IAMCU";
+
   // Invoke ourselves in -cc1 mode.
   //
   // FIXME: Implement custom jobs for internal actions.
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2482,6 +2482,7 @@
   TC = new toolchains::Minix(*this, Target, Args);
   break;
 case llvm::Triple::Linux:
+case llvm::Triple::ELFIAMCU:
   if (Target.getArch() == llvm::Triple::hexagon)
 TC = new toolchains::HexagonToolChain(*this, Target, Args);
   else if ((Target.getVendor() == llvm::Triple::MipsTechnologies) &&
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -696,3 +696,6 @@
 
 void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {}
+
+void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ArgStringList &CC1Args) const {}
Index: cfe/trunk/lib/Driver

r272883 - Compilation for Intel MCU (Part 2/3)

2016-06-16 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Thu Jun 16 05:36:09 2016
New Revision: 272883

URL: http://llvm.org/viewvc/llvm-project?rev=272883&view=rev
Log:
Compilation for Intel MCU (Part 2/3)

This is the second patch required to support compilation for Intel MCU target 
(e.g. Intel(R) Quark(TM) micro controller D 2000).
When IAMCU triple is used:
 * Recognize and use IAMCU GCC toolchain
 * Set up include paths
 * Forbid C++

Differential Revision: http://reviews.llvm.org/D19274

Added:
cfe/trunk/test/Driver/miamcu-opt.cpp   (with props)
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/miamcu-opt.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=272883&r1=272882&r2=272883&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Jun 16 05:36:09 2016
@@ -418,6 +418,10 @@ public:
   virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const;
 
+  /// \brief Add arguments to use MCU GCC toolchain includes.
+  virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const;
+
   /// \brief Return sanitizers which are available in this toolchain.
   virtual SanitizerMask getSupportedSanitizers() const;
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=272883&r1=272882&r2=272883&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jun 16 05:36:09 2016
@@ -2482,6 +2482,7 @@ const ToolChain &Driver::getToolChain(co
   TC = new toolchains::Minix(*this, Target, Args);
   break;
 case llvm::Triple::Linux:
+case llvm::Triple::ELFIAMCU:
   if (Target.getArch() == llvm::Triple::hexagon)
 TC = new toolchains::HexagonToolChain(*this, Target, Args);
   else if ((Target.getVendor() == llvm::Triple::MipsTechnologies) &&

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=272883&r1=272882&r2=272883&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Jun 16 05:36:09 2016
@@ -696,3 +696,6 @@ SanitizerMask ToolChain::getSupportedSan
 
 void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {}
+
+void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ArgStringList &CC1Args) const {}

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=272883&r1=272882&r2=272883&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Jun 16 05:36:09 2016
@@ -1618,9 +1618,13 @@ bool Generic_GCC::GCCInstallationDetecto
 break;
   case llvm::Triple::x86:
 LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
-TripleAliases.append(begin(X86Triples), end(X86Triples));
-BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
+// MCU toolchain is 32 bit only and its triple alias is TargetTriple
+// itself, which will be appended below.
+if (!TargetTriple.isOSIAMCU()) {
+  TripleAliases.append(begin(X86Triples), end(X86Triples));
+  BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
+}
 break;
   case llvm::Triple::mips:
 LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
@@ -1770,14 +1774,14 @@ void Generic_GCC::CudaInstallationDetect
 namespace {
 // Filter to remove Multilibs that don't exist as a suffix to Path
 class FilterNonExistent {
-  StringRef Base;
+  StringRef Base, File;
   vfs::FileSystem &VFS;
 
 public:
-  FilterNonExistent(StringRef Base, vfs::FileSystem &VFS)
-  : Base(Base), VFS(VFS) {}
+  FilterNonExistent(StringRef Base, StringRef File, vfs::FileSystem &VFS)
+  : Base(Base), File(File), VFS(VFS) {}
   bool operator()(const Multilib &M) {
-return !VFS.exists(Base + M.gccSuffix() + "/crtbegin.o");
+return !VFS.exists(Base + M.gccSuffix() + File);
   }
 };
 } //

r272885 - Compilation for Intel MCU (Part 3/3)

2016-06-16 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Thu Jun 16 05:49:27 2016
New Revision: 272885

URL: http://llvm.org/viewvc/llvm-project?rev=272885&view=rev
Log:
Compilation for Intel MCU (Part 3/3)

This is the last patch required to support compilation for Intel MCU target 
(e.g. Intel(R) Quark(TM) micro controller D 2000).

When IAMCU triple is used:
 * Use IAMCU linker output format
 * Link with IAMCU crt objects
 * Link with IAMCU libraries

Differential Revision: http://reviews.llvm.org/D20675

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/miamcu-opt.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=272885&r1=272884&r2=272885&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jun 16 05:49:27 2016
@@ -9065,6 +9065,7 @@ static void AddLibgcc(const llvm::Triple
   ArgStringList &CmdArgs, const ArgList &Args) {
   bool isAndroid = Triple.isAndroid();
   bool isCygMing = Triple.isOSCygMing();
+  bool IsIAMCU = Triple.isOSIAMCU();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
   Args.hasArg(options::OPT_static);
   if (!D.CCCIsCXX())
@@ -9081,7 +9082,7 @@ static void AddLibgcc(const llvm::Triple
   CmdArgs.push_back("--no-as-needed");
   }
 
-  if (StaticLibgcc && !isAndroid)
+  if (StaticLibgcc && !isAndroid && !IsIAMCU)
 CmdArgs.push_back("-lgcc_eh");
   else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX())
 CmdArgs.push_back("-lgcc");
@@ -9129,6 +9130,8 @@ static void AddRunTimeLibs(const ToolCha
 static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) {
   switch (T.getArch()) {
   case llvm::Triple::x86:
+if (T.isOSIAMCU())
+  return "elf_iamcu";
 return "elf_i386";
   case llvm::Triple::aarch64:
 return "aarch64linux";
@@ -9188,6 +9191,7 @@ void gnutools::Linker::ConstructJob(Comp
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
   const bool isAndroid = ToolChain.getTriple().isAndroid();
+  const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE =
   !Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
   (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
@@ -9264,7 +9268,7 @@ void gnutools::Linker::ConstructJob(Comp
   CmdArgs.push_back(Output.getFilename());
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-if (!isAndroid) {
+if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
 if (Args.hasArg(options::OPT_pg))
@@ -9280,18 +9284,22 @@ void gnutools::Linker::ConstructJob(Comp
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
 }
 
-const char *crtbegin;
-if (Args.hasArg(options::OPT_static))
-  crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
-else if (Args.hasArg(options::OPT_shared))
-  crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-else if (IsPIE)
-  crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
-else
-  crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
+if (IsIAMCU)
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+else {
+  const char *crtbegin;
+  if (Args.hasArg(options::OPT_static))
+crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
+  else if (Args.hasArg(options::OPT_shared))
+crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
+  else if (IsPIE)
+crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
+  else
+crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
 
-if (HasCRTBeginEndFiles)
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
+  if (HasCRTBeginEndFiles)
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
+}
 
 // Add crtfastmath.o if available and fast math is enabled.
 ToolChain.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -9375,13 +9383,24 @@ void gnutools::Linker::ConstructJob(Comp
 
   CmdArgs.push_back("-lc");
 
+  // Add IAMCU specific libs, if needed.
+  if (IsIAMCU)
+CmdArgs.push_back("-lgloss");
+
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--end-group");
   else
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add IAMCU specific libs (outside the group), if needed.
+  if (IsIAMCU) {
+CmdArgs.push_back("--as-needed");
+CmdArgs.push_back("-lsoftfp");
+CmdArgs.push_back("--no-as-needed");
+  }
 }
 
-if (!Args.hasArg(options::OPT_nostartfiles)) {
+if (!Args.hasArg(options::OPT_nostartfiles) && !IsIAMCU) {
   const char *crtend;
   if (Args.hasArg(options::OPT_shared))
  

Re: [PATCH] D20675: Compilation for Intel MCU (Part 3/3)

2016-06-16 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272885: Compilation for Intel MCU (Part 3/3) (authored by 
aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D20675?vs=58592&id=60960#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20675

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/miamcu-opt.c

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9065,6 +9065,7 @@
   ArgStringList &CmdArgs, const ArgList &Args) {
   bool isAndroid = Triple.isAndroid();
   bool isCygMing = Triple.isOSCygMing();
+  bool IsIAMCU = Triple.isOSIAMCU();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
   Args.hasArg(options::OPT_static);
   if (!D.CCCIsCXX())
@@ -9081,7 +9082,7 @@
   CmdArgs.push_back("--no-as-needed");
   }
 
-  if (StaticLibgcc && !isAndroid)
+  if (StaticLibgcc && !isAndroid && !IsIAMCU)
 CmdArgs.push_back("-lgcc_eh");
   else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX())
 CmdArgs.push_back("-lgcc");
@@ -9129,6 +9130,8 @@
 static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) {
   switch (T.getArch()) {
   case llvm::Triple::x86:
+if (T.isOSIAMCU())
+  return "elf_iamcu";
 return "elf_i386";
   case llvm::Triple::aarch64:
 return "aarch64linux";
@@ -9188,6 +9191,7 @@
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
   const bool isAndroid = ToolChain.getTriple().isAndroid();
+  const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE =
   !Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
   (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
@@ -9264,7 +9268,7 @@
   CmdArgs.push_back(Output.getFilename());
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-if (!isAndroid) {
+if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
 if (Args.hasArg(options::OPT_pg))
@@ -9280,18 +9284,22 @@
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
 }
 
-const char *crtbegin;
-if (Args.hasArg(options::OPT_static))
-  crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
-else if (Args.hasArg(options::OPT_shared))
-  crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-else if (IsPIE)
-  crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
-else
-  crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
+if (IsIAMCU)
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+else {
+  const char *crtbegin;
+  if (Args.hasArg(options::OPT_static))
+crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
+  else if (Args.hasArg(options::OPT_shared))
+crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
+  else if (IsPIE)
+crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
+  else
+crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
 
-if (HasCRTBeginEndFiles)
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
+  if (HasCRTBeginEndFiles)
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
+}
 
 // Add crtfastmath.o if available and fast math is enabled.
 ToolChain.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -9375,13 +9383,24 @@
 
   CmdArgs.push_back("-lc");
 
+  // Add IAMCU specific libs, if needed.
+  if (IsIAMCU)
+CmdArgs.push_back("-lgloss");
+
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--end-group");
   else
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add IAMCU specific libs (outside the group), if needed.
+  if (IsIAMCU) {
+CmdArgs.push_back("--as-needed");
+CmdArgs.push_back("-lsoftfp");
+CmdArgs.push_back("--no-as-needed");
+  }
 }
 
-if (!Args.hasArg(options::OPT_nostartfiles)) {
+if (!Args.hasArg(options::OPT_nostartfiles) && !IsIAMCU) {
   const char *crtend;
   if (Args.hasArg(options::OPT_shared))
 crtend = isAndroid ? "crtend_so.o" : "crtendS.o";
Index: cfe/trunk/test/Driver/miamcu-opt.c
===
--- cfe/trunk/test/Driver/miamcu-opt.c
+++ cfe/trunk/test/Driver/miamcu-opt.c
@@ -18,4 +18,12 @@
 // CHECK: "-mstack-alignment=4"
 
 // CHECK: bin/ld
+// CHECK: "-m" "elf_iamcu"
 // CHECK: "-static"
+// CHECK-NOT: crt1
+// CHECK-NOT: crti
+// CHECK-NOT: ctrbegin
+// CHECK: crt0
+// CHECK: "--start-group" "-lgcc" "-lc" "-lgloss" "--end-group" "--as-needed" "-lsoftfp" "--no-as-needed"
+// CHECK-NOT: crtend
+// CHECK-NOT: ctrn
___

Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Firefox build shows a couple of warnings in the sctp library that already gave 
warnings with the earlier patches.

That code has the following structure.

  #define SCTP_PACKED __attribute__((packed))
  #define SCTP_IDENTIFICATION_SIZE 16
  // ...
  /* state cookie header */
  struct sctp_state_cookie {/* this is our definition... */
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
struct timeval time_entered;/* the time I built cookie */
  // other fields
  } SCTP_PACKED;

The warning is triggered by the following code (the other occurence is almost 
exact).

  net->RTO = sctp_calculate_rto(stcb, asoc, net,
  &cookie->time_entered,   // ← warning 
here!
  sctp_align_unsafe_makecopy,
  SCTP_RTT_FROM_NON_DATA);

the called function being declared as

  uint32_t
  sctp_calculate_rto(struct sctp_tcb *stcb,
   struct sctp_association *asoc,
   struct sctp_nets *net,
   struct timeval *told,
   int safe, int rtt_from_sack)
  {
...

So I think that is a legitimate warning.

But the code is working (assuming this function is ever called that I didn't 
check). Checking the code, though, reveals a curious usage of `told`.

/* Copy it out for sparc64 */
if (safe == sctp_align_unsafe_makecopy) {
old = &then;
memcpy(&then, told, sizeof(struct timeval));
} else if (safe == sctp_align_safe_nocopy) {
old = told;
} else {
/* error */
SCTP_PRINTF("Huh, bad rto calc call\n");
return (0);
}

which suggests that the code somehow knows that the pointer is unaligned and 
cannot be copied straightforwardly.

We can cast to `void*` and back to the original pointer type.

  net->RTO = sctp_calculate_rto(stcb, asoc, net,
  (struct 
timeval*)(void*)&cookie->time_entered, // note: the cast is because this 
pointer is unaligned
  sctp_align_unsafe_makecopy,
  SCTP_RTT_FROM_NON_DATA);

Which looks a bit ugly to me but clearly pinpoints a problem and can be wrapped 
in a macro.

  #define UNALIGNED_ADDRESS(x) ((__typeof__(x))(void*)(x))
  
  ...
  
  net->RTO = sctp_calculate_rto(stcb, asoc, net,
  UNALIGNED_ADDRESS(&cookie->time_entered),
  sctp_align_unsafe_makecopy,
  SCTP_RTT_FROM_NON_DATA);

What do you think?


http://reviews.llvm.org/D20561



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


[libcxx] r272886 - Remove CloudABI specific workaround.

2016-06-16 Thread Ed Schouten via cfe-commits
Author: ed
Date: Thu Jun 16 06:53:11 2016
New Revision: 272886

URL: http://llvm.org/viewvc/llvm-project?rev=272886&view=rev
Log:
Remove CloudABI specific workaround.

CloudABI has gained the mblen_l() function in the meantime that does
properly return whether the character set has shift-states (read:
never).

Modified:
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/src/locale.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=272886&r1=272885&r2=272886&view=diff
==
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Thu Jun 16 06:53:11 2016
@@ -1660,10 +1660,8 @@ codecvt::do_un
 int
 codecvt::do_encoding() const  _NOEXCEPT
 {
-#ifndef __CloudABI__
 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
 return -1;
-#endif
 
 // stateless encoding
 if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1)  // there are no known 
constant length encodings


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


r272887 - Patch "Compilation for Intel MCU (Part 2/3)" caused the clang-x64-ninja-win7

2016-06-16 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Thu Jun 16 07:26:20 2016
New Revision: 272887

URL: http://llvm.org/viewvc/llvm-project?rev=272887&view=rev
Log:
Patch "Compilation for Intel MCU (Part 2/3)" caused the clang-x64-ninja-win7
buildbot to fail because of inaccurate CHECK in the test. This is a quick fix
for the test to make it platform independent.


Modified:
cfe/trunk/test/Driver/miamcu-opt.c

Modified: cfe/trunk/test/Driver/miamcu-opt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/miamcu-opt.c?rev=272887&r1=272886&r2=272887&view=diff
==
--- cfe/trunk/test/Driver/miamcu-opt.c (original)
+++ cfe/trunk/test/Driver/miamcu-opt.c Thu Jun 16 07:26:20 2016
@@ -11,13 +11,13 @@
 
 // NOT-X86: error: unsupported option '-miamcu' for target 'armv8---eabi'
 
-// CHECK: "-cc1"
+// CHECK: "{{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-triple" "i586-intel-elfiamcu"
 // CHECK: "-static-define"
 // CHECK: "-mfloat-abi" "soft"
 // CHECK: "-mstack-alignment=4"
 
-// CHECK: bin/ld
+// CHECK: "{{.*}}ld{{(.exe)?}}"
 // CHECK: "-m" "elf_iamcu"
 // CHECK: "-static"
 // CHECK-NOT: crt1


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


r272890 - A follow-up fixing on cuda-march.cu: Don't match clang to other place.

2016-06-16 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jun 16 08:27:02 2016
New Revision: 272890

URL: http://llvm.org/viewvc/llvm-project?rev=272890&view=rev
Log:
A follow-up fixing on cuda-march.cu: Don't match clang to other place.

Modified:
cfe/trunk/test/Driver/cuda-march.cu

Modified: cfe/trunk/test/Driver/cuda-march.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-march.cu?rev=272890&r1=272889&r2=272890&view=diff
==
--- cfe/trunk/test/Driver/cuda-march.cu (original)
+++ cfe/trunk/test/Driver/cuda-march.cu Thu Jun 16 08:27:02 2016
@@ -6,19 +6,17 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang -### -target x86_64-linux-gnu -c -march=haswell %s 2>&1 | 
FileCheck %s
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-linux-gnu -c \
+// RUN: -march=haswell %s 2>&1 | FileCheck %s
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-linux-gnu -c \
+// RUN: -march=haswell --cuda-gpu-arch=sm_20 %s 2>&1 | FileCheck %s
 
-// RUN: %clang -### -target x86_64-linux-gnu -c -march=haswell 
--cuda-gpu-arch=sm_20 %s 2>&1 | \
-// RUN: FileCheck %s
-
-// CHECK: bin{{/|\\+}}clang
-// CHECK: "-cc1"
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK-SAME: "-triple" "nvptx
 // CHECK-SAME: "-target-cpu" "sm_20"
 
 // CHECK: ptxas
 // CHECK-SAME: "--gpu-name" "sm_20"
 
-// CHECK: bin{{/|\\+}}clang
-// CHECK-SAME: "-cc1"
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK-SAME: "-target-cpu" "haswell"


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


r272893 - [Builtin] Make __builtin_thread_pointer target-independent.

2016-06-16 Thread Marcin Koscielnicki via cfe-commits
Author: koriakin
Date: Thu Jun 16 08:41:54 2016
New Revision: 272893

URL: http://llvm.org/viewvc/llvm-project?rev=272893&view=rev
Log:
[Builtin] Make __builtin_thread_pointer target-independent.

This is now supported for ARM, AArch64, PowerPC, SystemZ, SPARC, Mips.

Differential Revision: http://reviews.llvm.org/D19589

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-arm64.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=272893&r1=272892&r2=272893&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Jun 16 08:41:54 2016
@@ -467,6 +467,7 @@ BUILTIN(__builtin_eh_return_data_regno,
 BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
 BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
+BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 // GCC exception builtins
 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=272893&r1=272892&r2=272893&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Thu Jun 16 08:41:54 2016
@@ -60,6 +60,5 @@ BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
-BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 #undef BUILTIN

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=272893&r1=272892&r2=272893&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Thu Jun 16 08:41:54 2016
@@ -20,7 +20,6 @@
 
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
-BUILTIN(__builtin_thread_pointer, "v*", "")
 
 // Saturating arithmetic
 BUILTIN(__builtin_arm_qadd, "iii", "nc")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=272893&r1=272892&r2=272893&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 16 08:41:54 2016
@@ -2158,6 +2158,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_canonicalizef:
   case Builtin::BI__builtin_canonicalizel:
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::canonicalize));
+
+  case Builtin::BI__builtin_thread_pointer: {
+if (!getContext().getTargetInfo().isTLSSupported())
+  CGM.ErrorUnsupported(E, "__builtin_thread_pointer");
+// Fall through - it's already mapped to the intrinsic by GCCBuiltin.
+break;
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit

Modified: cfe/trunk/test/CodeGen/builtins-arm64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm64.c?rev=272893&r1=272892&r2=272893&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-arm64.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm64.c Thu Jun 16 08:41:54 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-linux -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s
 
 void f0(void *a, void *b) {
__clear_cache(a,b);


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


Re: [PATCH] D19589: [clang] [Builtin] Make __builtin_thread_pointer target-independent.

2016-06-16 Thread Marcin Kościelnicki via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272893: [Builtin] Make __builtin_thread_pointer 
target-independent. (authored by koriakin).

Changed prior to commit:
  http://reviews.llvm.org/D19589?vs=55216&id=60966#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19589

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/include/clang/Basic/BuiltinsARM.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-arm64.c

Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -60,6 +60,5 @@
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
-BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 #undef BUILTIN
Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -20,7 +20,6 @@
 
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
-BUILTIN(__builtin_thread_pointer, "v*", "")
 
 // Saturating arithmetic
 BUILTIN(__builtin_arm_qadd, "iii", "nc")
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -467,6 +467,7 @@
 BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
 BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
+BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 // GCC exception builtins
 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!
Index: cfe/trunk/test/CodeGen/builtins-arm64.c
===
--- cfe/trunk/test/CodeGen/builtins-arm64.c
+++ cfe/trunk/test/CodeGen/builtins-arm64.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-linux -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s
 
 void f0(void *a, void *b) {
__clear_cache(a,b);
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -2158,6 +2158,13 @@
   case Builtin::BI__builtin_canonicalizef:
   case Builtin::BI__builtin_canonicalizel:
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::canonicalize));
+
+  case Builtin::BI__builtin_thread_pointer: {
+if (!getContext().getTargetInfo().isTLSSupported())
+  CGM.ErrorUnsupported(E, "__builtin_thread_pointer");
+// Fall through - it's already mapped to the intrinsic by GCCBuiltin.
+break;
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit


Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -60,6 +60,5 @@
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
-BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 #undef BUILTIN
Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -20,7 +20,6 @@
 
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
-BUILTIN(__builtin_thread_pointer, "v*", "")
 
 // Saturating arithmetic
 BUILTIN(__builtin_arm_qadd, "iii", "nc")
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -467,6 +467,7 @@
 BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
 BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
+BUILTIN(__builtin_thread_pointer, "v*", "nc")
 
 // GCC exception builtins
 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!
Index: cfe/trunk/test/CodeGen/builtins-arm64.c
===
--- cfe/trunk/test/CodeGen/builtins-arm64.c
+++ cfe/trunk/test/CodeGen/builtins-arm64.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-linux -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
 
 void f0(void *a, void *b

Re: [PATCH] D21392: [clang-tidy] Enhance redundant-expression check

2016-06-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:114
@@ -112,1 +113,3 @@
 
+// Perform a comparison bitween APSInt with respect to bit-width and 
signedness.
+static int compareValues(const llvm::APSInt &ValueLHS,

s/bitween/between, however, I don't think this function adds much value; why 
not just call `APSInt::compareValues()` directly?


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:131
@@ +130,3 @@
+
+  // Handle the case where constants are off by one: x <= 4  <==>  x < 5.
+  llvm::APSInt ValueLHS_plus1 = ValueLHS;

Why is off-by-one more useful than a stronger range analysis?


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:171
@@ +170,3 @@
+  ++ValueLHS_plus1;
+  if (compareValues(ValueLHS_plus1, ValueRHS) == 0 && OpcodeLHS == BO_GT &&
+  OpcodeRHS == BO_LT) {

Same question here as above.


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:177
@@ +176,3 @@
+  // Handle cases where the constants are different.
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))

Can this be done before doing the more expensive value comparisons?


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:227
@@ +226,3 @@
+
+static bool doRangeSubsumeRange(BinaryOperatorKind OpcodeLHS,
+const llvm::APSInt &ValueLHS,

s/do/does


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:267
@@ +266,3 @@
+Opcode = BO_Add;
+Value = -Value;
+  }

I can never remember myself, but how well does APSInt handle this situation if 
it causes overflow of the signed value? e.g., an 8-bit APSInt holding the value 
-128 being negated to 128 (which is outside the range of an 8-bit signed 
integer).


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:294
@@ +293,3 @@
+// Returns a matcher for a generic expression (not a constant expression).
+static ast_matchers::internal::Matcher matchGenericExpr(StringRef Id) {
+  std::string SymId = (Id + "-gen").str();

I'm not keen on this name because C11 has `_Generic`, for which we have a 
`GenericSelectionExpr` which is awfully close to this name.


Comment at: clang-tidy/misc/RedundantExpressionCheck.h:31
@@ +30,3 @@
+private:
+  void checkArithmeticExpr(const ast_matchers::MatchFinder::MatchResult & R);
+  void checkBitwiseExpr(const ast_matchers::MatchFinder::MatchResult &R);

`&` should bind to `R`.

Also, all of these functions can be marked `const`.


http://reviews.llvm.org/D21392



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


Re: [PATCH] D21277: Resubmit r270688: Using new TargetParser in Clang.

2016-06-16 Thread Renato Golin via cfe-commits
rengolin added a comment.

In http://reviews.llvm.org/D21277#459703, @jojo wrote:

> Do you mean updating the diff to let it include the change of 
> http://reviews.llvm.org/D21276,or commiting these two reviews as one commit?


Committing them as one, after they're both approved.


Repository:
  rL LLVM

http://reviews.llvm.org/D21277



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


Re: [PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

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

LGTM, but you should wait for @alexfh to sign off as well since he had some 
comments.


http://reviews.llvm.org/D21223



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


Re: [PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

2016-06-16 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thanks!


http://reviews.llvm.org/D21223



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


Re: [PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

2016-06-16 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

BTW, I'll commit the patch for you.


http://reviews.llvm.org/D21223



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


Re: [PATCH] D21366: [clang-tidy] misc-move-const-arg: Fix typos

2016-06-16 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. I'll commit the patch for you.


http://reviews.llvm.org/D21366



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


[clang-tools-extra] r272897 - [clang-tidy] misc-move-const-arg: Fix typos

2016-06-16 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun 16 09:32:54 2016
New Revision: 272897

URL: http://llvm.org/viewvc/llvm-project?rev=272897&view=rev
Log:
[clang-tidy] misc-move-const-arg: Fix typos

Reviewers: alexfh

Subscribers: cfe-commits

Patch by Martin Boehme!

Differential Revision: http://reviews.llvm.org/D21366

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=272897&r1=272896&r2=272897&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp Thu 
Jun 16 09:32:54 2016
@@ -1,4 +1,4 @@
-//===--- MoveConstandArgumentCheck.cpp - clang-tidy 
---===//
+//===--- MoveConstantArgumentCheck.cpp - clang-tidy 
---===//
 //
 // The LLVM Compiler Infrastructure
 //

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h?rev=272897&r1=272896&r2=272897&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h Thu Jun 
16 09:32:54 2016
@@ -1,4 +1,4 @@
-//===--- MoveConstandArgumentCheck.h - clang-tidy 
-===//
+//===--- MoveConstantArgumentCheck.h - clang-tidy 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
 
 #include "../ClangTidy.h"
 
@@ -28,4 +28,4 @@ public:
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H


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


Re: [PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

2016-06-16 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272896: [clang-tidy] misc-move-const-arg: Detect if result 
of std::move() is being… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D21223?vs=60686&id=60974#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21223

Files:
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -17,51 +17,77 @@
 namespace tidy {
 namespace misc {
 
+static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
+   const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  const Expr *Arg = Call->getArg(0);
+
+  CharSourceRange BeforeArgumentsRange = Lexer::makeFileCharRange(
+  CharSourceRange::getCharRange(Call->getLocStart(), Arg->getLocStart()),
+  SM, LangOpts);
+  CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(
+  CharSourceRange::getCharRange(Call->getLocEnd(),
+Call->getLocEnd().getLocWithOffset(1)),
+  SM, LangOpts);
+
+  if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
+Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
+ << FixItHint::CreateRemoval(AfterArgumentsRange);
+  }
+}
+
 void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::std::move"))),
-  argumentCountIs(1),
-  unless(isInTemplateInstantiation()))
- .bind("call-move"),
+
+  auto MoveCallMatcher =
+  callExpr(callee(functionDecl(hasName("::std::move"))), argumentCountIs(1),
+   unless(isInTemplateInstantiation()))
+  .bind("call-move");
+
+  Finder->addMatcher(MoveCallMatcher, this);
+
+  auto ConstParamMatcher = forEachArgumentWithParam(
+  MoveCallMatcher, parmVarDecl(hasType(references(isConstQualified();
+
+  Finder->addMatcher(callExpr(ConstParamMatcher).bind("receiving-expr"), this);
+  Finder->addMatcher(cxxConstructExpr(ConstParamMatcher).bind("receiving-expr"),
  this);
 }
 
 void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *CallMove = Result.Nodes.getNodeAs("call-move");
+  const auto *ReceivingExpr = Result.Nodes.getNodeAs("receiving-expr");
   const Expr *Arg = CallMove->getArg(0);
   SourceManager &SM = Result.Context->getSourceManager();
 
+  CharSourceRange MoveRange =
+  CharSourceRange::getCharRange(CallMove->getSourceRange());
+  CharSourceRange FileMoveRange =
+  Lexer::makeFileCharRange(MoveRange, SM, getLangOpts());
+  if (!FileMoveRange.isValid())
+return;
+
   bool IsConstArg = Arg->getType().isConstQualified();
   bool IsTriviallyCopyable =
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
-auto MoveRange = CharSourceRange::getCharRange(CallMove->getSourceRange());
-auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, getLangOpts());
-if (!FileMoveRange.isValid())
-  return;
 bool IsVariable = isa(Arg);
 auto Diag = diag(FileMoveRange.getBegin(),
  "std::move of the %select{|const }0"
  "%select{expression|variable}1 "
  "%select{|of a trivially-copyable type }2"
  "has no effect; remove std::move()")
 << IsConstArg << IsVariable << IsTriviallyCopyable;
 
-auto BeforeArgumentsRange = Lexer::makeFileCharRange(
-CharSourceRange::getCharRange(CallMove->getLocStart(),
-  Arg->getLocStart()),
-SM, getLangOpts());
-auto AfterArgumentsRange = Lexer::makeFileCharRange(
-CharSourceRange::getCharRange(
-CallMove->getLocEnd(), CallMove->getLocEnd().getLocWithOffset(1)),
-SM, getLangOpts());
-
-if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
-  Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
-   << FixItHint::CreateRemoval(AfterArgumentsRange);
-}
+ReplaceCallWithArg(CallMove, Diag, SM, getLangOpts());
+  } else if (ReceivingExpr) {
+auto Diag = diag(FileMoveRange.getBegin(),
+ "passing result of std::move() as a const reference "
+ "argument; no move will actually happen");
+
+ReplaceCallWithArg(CallMove, Diag, SM, get

Re: [PATCH] D21366: [clang-tidy] misc-move-const-arg: Fix typos

2016-06-16 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272897: [clang-tidy] misc-move-const-arg: Fix typos 
(authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D21366?vs=60802&id=60975#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21366

Files:
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h

Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -1,4 +1,4 @@
-//===--- MoveConstandArgumentCheck.cpp - clang-tidy 
---===//
+//===--- MoveConstantArgumentCheck.cpp - clang-tidy 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -1,14 +1,14 @@
-//===--- MoveConstandArgumentCheck.h - clang-tidy 
-===//
+//===--- MoveConstantArgumentCheck.h - clang-tidy 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
 
 #include "../ClangTidy.h"
 
@@ -28,4 +28,4 @@
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H


Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -1,4 +1,4 @@
-//===--- MoveConstandArgumentCheck.cpp - clang-tidy ---===//
+//===--- MoveConstantArgumentCheck.cpp - clang-tidy ---===//
 //
 // The LLVM Compiler Infrastructure
 //
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -1,14 +1,14 @@
-//===--- MoveConstandArgumentCheck.h - clang-tidy -===//
+//===--- MoveConstantArgumentCheck.h - clang-tidy -===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
 
 #include "../ClangTidy.h"
 
@@ -28,4 +28,4 @@
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r272896 - [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

2016-06-16 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun 16 09:32:41 2016
New Revision: 272896

URL: http://llvm.org/viewvc/llvm-project?rev=272896&view=rev
Log:
[clang-tidy] misc-move-const-arg: Detect if result of std::move() is being 
passed as a const ref argument

Summary:
Conceptually, this is very close to the existing functionality of 
misc-move-const-arg, which is why I'm adding it here and not creating a new 
check. For example, for a type A that is both movable and copyable, this

  const A a1;
  A a2(std::move(a1));

is not only a case where a const argument is being passed to std::move(), but 
the result of std::move() is also being passed as a const reference (due to 
overload resolution).

The new check typically triggers (exclusively) in cases where people think 
they're dealing with a movable type, but in fact the type is not movable.

Reviewers: hokein, aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

Patch by Martin Boehme!

Differential Revision: http://reviews.llvm.org/D21223

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=272896&r1=272895&r2=272896&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp Thu 
Jun 16 09:32:41 2016
@@ -17,30 +17,62 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
+static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
+   const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  const Expr *Arg = Call->getArg(0);
+
+  CharSourceRange BeforeArgumentsRange = Lexer::makeFileCharRange(
+  CharSourceRange::getCharRange(Call->getLocStart(), Arg->getLocStart()),
+  SM, LangOpts);
+  CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(
+  CharSourceRange::getCharRange(Call->getLocEnd(),
+Call->getLocEnd().getLocWithOffset(1)),
+  SM, LangOpts);
+
+  if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
+Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
+ << FixItHint::CreateRemoval(AfterArgumentsRange);
+  }
+}
+
 void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::std::move"))),
-  argumentCountIs(1),
-  unless(isInTemplateInstantiation()))
- .bind("call-move"),
+
+  auto MoveCallMatcher =
+  callExpr(callee(functionDecl(hasName("::std::move"))), 
argumentCountIs(1),
+   unless(isInTemplateInstantiation()))
+  .bind("call-move");
+
+  Finder->addMatcher(MoveCallMatcher, this);
+
+  auto ConstParamMatcher = forEachArgumentWithParam(
+  MoveCallMatcher, parmVarDecl(hasType(references(isConstQualified();
+
+  Finder->addMatcher(callExpr(ConstParamMatcher).bind("receiving-expr"), this);
+  
Finder->addMatcher(cxxConstructExpr(ConstParamMatcher).bind("receiving-expr"),
  this);
 }
 
 void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *CallMove = Result.Nodes.getNodeAs("call-move");
+  const auto *ReceivingExpr = Result.Nodes.getNodeAs("receiving-expr");
   const Expr *Arg = CallMove->getArg(0);
   SourceManager &SM = Result.Context->getSourceManager();
 
+  CharSourceRange MoveRange =
+  CharSourceRange::getCharRange(CallMove->getSourceRange());
+  CharSourceRange FileMoveRange =
+  Lexer::makeFileCharRange(MoveRange, SM, getLangOpts());
+  if (!FileMoveRange.isValid())
+return;
+
   bool IsConstArg = Arg->getType().isConstQualified();
   bool IsTriviallyCopyable =
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
-auto MoveRange = CharSourceRange::getCharRange(CallMove->getSourceRange());
-auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, 
getLangOpts());
-if (!FileMoveRange.isValid())
-  return;
 bool IsVariable = isa(Arg);
 auto Diag = diag(FileMoveRange.getBegin(),
  "std::move of the %select{|const }0"
@@ -49,19 +81,13 @@ void MoveConstantArgumentCheck::check(co
  "has no effect; remove std::move()")
 << IsConstArg << IsVariable << IsTriviallyCopyable;
 
-auto BeforeArgumentsRange = Lexer::makeFileCharRange(
-CharSourceRange::getCharRange(CallMove->getLocStar

r272900 - [OpenMP] Cast captures by copy when passed to fork call so that they are compatible to what the runtime library expects.

2016-06-16 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jun 16 10:09:31 2016
New Revision: 272900

URL: http://llvm.org/viewvc/llvm-project?rev=272900&view=rev
Log:
[OpenMP] Cast captures by copy when passed to fork call so that they are 
compatible to what the runtime library expects.

Summary:
This patch fixes an issue detected when firstprivate variables are passed to an 
OpenMP outlined function vararg list. Currently they are not compatible with 
what the runtime library expects causing malfunction in some targets.

This patch fixes the issue by moving the casting logic already in place for 
offloading to the common code that creates the outline function and arguments 
and updates the regression tests accordingly.

Reviewers: hfinkel, arpith-jacob, carlo.bertolli, kkwli0, ABataev

Subscribers: cfe-commits, caomhin

Differential Revision: http://reviews.llvm.org/D21150

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/single_codegen.cpp
cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=272900&r1=272899&r2=272900&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jun 16 10:09:31 2016
@@ -4815,8 +4815,7 @@ void CGOpenMPRuntime::emitTargetOutlined
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
 
-  OutlinedFn =
-  CGF.GenerateOpenMPCapturedStmtFunction(CS, /*CastValToPtr=*/true);
+  OutlinedFn = CGF.GenerateOpenMPCapturedStmtFunction(CS);
 
   // If this target outline function is not an offload entry, we don't need to
   // register it.
@@ -5485,7 +5484,6 @@ public:
   MappableExprsHandler::MapValuesArrayTy &CurPointers,
   MappableExprsHandler::MapValuesArrayTy &CurSizes,
   MappableExprsHandler::MapFlagsArrayTy &CurMapTypes) {
-auto &Ctx = CGF.getContext();
 
 // Do the default mapping.
 if (CI.capturesThis()) {
@@ -5497,36 +5495,17 @@ public:
   CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_TO |
 MappableExprsHandler::OMP_MAP_FROM);
 } else if (CI.capturesVariableByCopy()) {
+  CurBasePointers.push_back(CV);
+  CurPointers.push_back(CV);
   if (!RI.getType()->isAnyPointerType()) {
-// If the field is not a pointer, we need to save the actual value
-// and load it as a void pointer.
+// We have to signal to the runtime captures passed by value that are
+// not pointers.
 CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_PRIVATE_VAL);
-auto DstAddr = CGF.CreateMemTemp(Ctx.getUIntPtrType(),
- Twine(CI.getCapturedVar()->getName()) 
+
- ".casted");
-LValue DstLV = CGF.MakeAddrLValue(DstAddr, Ctx.getUIntPtrType());
-
-auto *SrcAddrVal = CGF.EmitScalarConversion(
-DstAddr.getPointer(), Ctx.getPointerType(Ctx.getUIntPtrType()),
-Ctx.getPointerType(RI.getType()), SourceLocation());
-LValue SrcLV = CGF.MakeNaturalAlignAddrLValue(SrcAddrVal, 
RI.getType());
-
-// Store the value using the source type pointer.
-CGF.EmitStoreThroughLValue(RValue::get(CV), SrcLV);
-
-// Load the value using the destination type pointer.
-CurBasePointers.push_back(
-CGF.EmitLoadOfLValue(DstLV, SourceLocation()).getScalarVal());
-CurPointers.push_back(CurBasePointers.back());
-
-// Get the size of the type to be used in the map.
 CurSizes.push_back(CGF.getTypeSize(RI.getType()));
   } else {
 // Pointers are implicitly mapped with a zero size and no flags
 // (other than first map that is added for all implicit maps).
 CurMapTypes.push_back(0u);
-CurBasePointers.push_back(CV);
-CurPointers.push_back(CV);
 CurSizes.push_back(llvm::Constant::getNullValue(CGF.SizeTy));
   }
 } else {

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=272900&r1=272899&r2=272900&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jun 16 10:09:31 2016
@@ -136,10 +136,33 @@ void CodeGenFunction::GenerateOpenMPCapt
   CapturedVars.push_back(Val);
 } else if (CurCap

Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-16 Thread Cameron via cfe-commits
cameron314 added a comment.

Ping? :-)


http://reviews.llvm.org/D20338



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


Re: [PATCH] D21392: [clang-tidy] Enhance redundant-expression check

2016-06-16 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 60982.
etienneb marked 7 inline comments as done.
etienneb added a comment.

address comments


http://reviews.llvm.org/D21392

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.h
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s misc-redundant-expression %t
+// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -std=c++11
+
+typedef __INT64_TYPE__ I64;
 
 struct Point {
   int x;
@@ -64,7 +66,7 @@
 
   if ( + "dummy" == + "dummy") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
-  if (L"abc" == L"abc") return 1; 
+  if (L"abc" == L"abc") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
@@ -82,7 +84,7 @@
 
 int Valid(int X, int Y) {
   if (X != Y) return 1;
-  if (X == X + 0) return 1;
+  if (X == Y + 0) return 1;
   if (P.x == P.y) return 1;
   if (P.a[P.x] < P.a[P.y]) return 1;
   if (P.a[0] < P.a[1]) return 1;
@@ -160,3 +162,324 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of overloaded operator are equivalent
 }
 void TestTemplate() { TemplateCheck(); }
+
+int TestArithmetic(int X, int Y) {
+  if (X + 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X - 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1LL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
+  if (X + 1ULL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+
+  if (X == X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X == X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if (X != X - 1U) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X != X - 1LL) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if ((X+X) != (X+X) - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X - 1 == X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 != X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 == X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - (~0)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0U)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0ULL)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  // Should not match.
+  if (X + 0.5 == X) return 1;
+  if (X + 1 == Y) return 1;
+  if (X + 1 == Y + 1) return 1;
+  if (X + 1 == Y + 2) return 1;
+
+  return 0;
+}
+
+int TestBitwise(int X) {
+  if ((X & 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X & 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+  if ((X | 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X | 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+
+  if ((X | 0xFFULL) != 0xF

Re: [PATCH] D21392: [clang-tidy] Enhance redundant-expression check

2016-06-16 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

thx Aaron.



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:131
@@ +130,3 @@
+
+  // Handle the case where constants are off by one: x <= 4  <==>  x < 5.
+  llvm::APSInt ValueLHS_plus1 = ValueLHS;

aaron.ballman wrote:
> Why is off-by-one more useful than a stronger range analysis?
I don't get your point?

This function is comparing two ranges. Ranges are comparable only if they are 
compared to the same constant
OR, if they are off-by one and the operator contains "equality".

As the comment state, x <= 4 is equivalent to x < 5.

To avoid problem with wrap around, the left value is incremented (the left 
value must be the smaller one: canonical form).

I don't get why we should use a range analysis? Is there some utility functions 
I'm not aware of?


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:177
@@ +176,3 @@
+  // Handle cases where the constants are different.
+  if ((OpcodeLHS == BO_EQ || OpcodeLHS == BO_LE || OpcodeLHS == BO_LE) &&
+  (OpcodeRHS == BO_EQ || OpcodeRHS == BO_GT || OpcodeRHS == BO_GE))

aaron.ballman wrote:
> Can this be done before doing the more expensive value comparisons?
it can be done before the previous if. But not the one at line 149 (which 
always returns).


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:267
@@ +266,3 @@
+Opcode = BO_Add;
+Value = -Value;
+  }

aaron.ballman wrote:
> I can never remember myself, but how well does APSInt handle this situation 
> if it causes overflow of the signed value? e.g., an 8-bit APSInt holding the 
> value -128 being negated to 128 (which is outside the range of an 8-bit 
> signed integer).
In this case  -128 (8-bits) will give -128.
The APSInt is behaving the same way than a real value of the same width and 
signedness.

I added an unittest to cover this case.


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:294
@@ +293,3 @@
+// Returns a matcher for a generic expression (not a constant expression).
+static ast_matchers::internal::Matcher matchGenericExpr(StringRef Id) {
+  std::string SymId = (Id + "-gen").str();

aaron.ballman wrote:
> I'm not keen on this name because C11 has `_Generic`, for which we have a 
> `GenericSelectionExpr` which is awfully close to this name.
'Generic' is a too generic name :)


Comment at: clang-tidy/misc/RedundantExpressionCheck.h:31
@@ +30,3 @@
+private:
+  void checkArithmeticExpr(const ast_matchers::MatchFinder::MatchResult & R);
+  void checkBitwiseExpr(const ast_matchers::MatchFinder::MatchResult &R);

aaron.ballman wrote:
> `&` should bind to `R`.
> 
> Also, all of these functions can be marked `const`.
They can't be constant, they are calling 'diag' which is not const.

```
error: no matching function for call to 
‘clang::tidy::misc::RedundantExpressionCheck::diag(clang::SourceLocation, const 
char [35]) const
```


http://reviews.llvm.org/D21392



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


Re: [PATCH] D21392: [clang-tidy] Enhance redundant-expression check

2016-06-16 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 60983.
etienneb added a comment.

refactoring


http://reviews.llvm.org/D21392

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.h
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s misc-redundant-expression %t
+// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -std=c++11
+
+typedef __INT64_TYPE__ I64;
 
 struct Point {
   int x;
@@ -64,7 +66,7 @@
 
   if ( + "dummy" == + "dummy") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
-  if (L"abc" == L"abc") return 1; 
+  if (L"abc" == L"abc") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
@@ -82,7 +84,7 @@
 
 int Valid(int X, int Y) {
   if (X != Y) return 1;
-  if (X == X + 0) return 1;
+  if (X == Y + 0) return 1;
   if (P.x == P.y) return 1;
   if (P.a[P.x] < P.a[P.y]) return 1;
   if (P.a[0] < P.a[1]) return 1;
@@ -160,3 +162,324 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of overloaded operator are equivalent
 }
 void TestTemplate() { TemplateCheck(); }
+
+int TestArithmetic(int X, int Y) {
+  if (X + 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X - 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1LL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
+  if (X + 1ULL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+
+  if (X == X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X == X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if (X != X - 1U) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X != X - 1LL) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if ((X+X) != (X+X) - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X - 1 == X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 != X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 == X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - (~0)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0U)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0ULL)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  // Should not match.
+  if (X + 0.5 == X) return 1;
+  if (X + 1 == Y) return 1;
+  if (X + 1 == Y + 1) return 1;
+  if (X + 1 == Y + 2) return 1;
+
+  return 0;
+}
+
+int TestBitwise(int X) {
+  if ((X & 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X & 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+  if ((X | 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X | 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+
+  if ((X | 0xFFULL) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]

r272908 - Revert r272900 - [OpenMP] Cast captures by copy when passed to fork call so that they are compatible to what the runtime library expects.

2016-06-16 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jun 16 11:06:22 2016
New Revision: 272908

URL: http://llvm.org/viewvc/llvm-project?rev=272908&view=rev
Log:
Revert r272900 - [OpenMP] Cast captures by copy when passed to fork call so 
that they are compatible to what the runtime library expects.

Was causing trouble in one of the regression tests for a 32-bit address space.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/single_codegen.cpp
cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=272908&r1=272907&r2=272908&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jun 16 11:06:22 2016
@@ -4815,7 +4815,8 @@ void CGOpenMPRuntime::emitTargetOutlined
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
 
-  OutlinedFn = CGF.GenerateOpenMPCapturedStmtFunction(CS);
+  OutlinedFn =
+  CGF.GenerateOpenMPCapturedStmtFunction(CS, /*CastValToPtr=*/true);
 
   // If this target outline function is not an offload entry, we don't need to
   // register it.
@@ -5484,6 +5485,7 @@ public:
   MappableExprsHandler::MapValuesArrayTy &CurPointers,
   MappableExprsHandler::MapValuesArrayTy &CurSizes,
   MappableExprsHandler::MapFlagsArrayTy &CurMapTypes) {
+auto &Ctx = CGF.getContext();
 
 // Do the default mapping.
 if (CI.capturesThis()) {
@@ -5495,17 +5497,36 @@ public:
   CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_TO |
 MappableExprsHandler::OMP_MAP_FROM);
 } else if (CI.capturesVariableByCopy()) {
-  CurBasePointers.push_back(CV);
-  CurPointers.push_back(CV);
   if (!RI.getType()->isAnyPointerType()) {
-// We have to signal to the runtime captures passed by value that are
-// not pointers.
+// If the field is not a pointer, we need to save the actual value
+// and load it as a void pointer.
 CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_PRIVATE_VAL);
+auto DstAddr = CGF.CreateMemTemp(Ctx.getUIntPtrType(),
+ Twine(CI.getCapturedVar()->getName()) 
+
+ ".casted");
+LValue DstLV = CGF.MakeAddrLValue(DstAddr, Ctx.getUIntPtrType());
+
+auto *SrcAddrVal = CGF.EmitScalarConversion(
+DstAddr.getPointer(), Ctx.getPointerType(Ctx.getUIntPtrType()),
+Ctx.getPointerType(RI.getType()), SourceLocation());
+LValue SrcLV = CGF.MakeNaturalAlignAddrLValue(SrcAddrVal, 
RI.getType());
+
+// Store the value using the source type pointer.
+CGF.EmitStoreThroughLValue(RValue::get(CV), SrcLV);
+
+// Load the value using the destination type pointer.
+CurBasePointers.push_back(
+CGF.EmitLoadOfLValue(DstLV, SourceLocation()).getScalarVal());
+CurPointers.push_back(CurBasePointers.back());
+
+// Get the size of the type to be used in the map.
 CurSizes.push_back(CGF.getTypeSize(RI.getType()));
   } else {
 // Pointers are implicitly mapped with a zero size and no flags
 // (other than first map that is added for all implicit maps).
 CurMapTypes.push_back(0u);
+CurBasePointers.push_back(CV);
+CurPointers.push_back(CV);
 CurSizes.push_back(llvm::Constant::getNullValue(CGF.SizeTy));
   }
 } else {

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=272908&r1=272907&r2=272908&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jun 16 11:06:22 2016
@@ -136,33 +136,10 @@ void CodeGenFunction::GenerateOpenMPCapt
   CapturedVars.push_back(Val);
 } else if (CurCap->capturesThis())
   CapturedVars.push_back(CXXThisValue);
-else if (CurCap->capturesVariableByCopy()) {
-  llvm::Value *CV =
-  EmitLoadOfLValue(EmitLValue(*I), SourceLocation()).getScalarVal();
-
-  // If the field is not a pointer, we need to save the actual value
-  // and load it as a void pointer.
-  if (!CurField->getType()->isAnyPointerType()) {
-auto &Ctx = getContext();
-auto DstAddr = CreateMemTemp(
-Ctx.getUIntPtrType(),
-

Re: [PATCH] D21020: [clang-tidy] readability-identifier-naming - Support for Macros

2016-06-16 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a couple of nits.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:808
@@ +807,3 @@
+  addUsage(NamingCheckFailures, ID, Range);
+  return;
+}

`return`?


Comment at: clang-tidy/readability/IdentifierNamingCheck.h:94
@@ -86,1 +93,3 @@
 
+  /// Check Macros for style violations
+  void checkMacro(SourceManager &sourceMgr, const Token &MacroNameTok,

Please add trailing periods to comments. See also 
http://llvm.org/docs/CodingStandards.html#commenting


http://reviews.llvm.org/D21020



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


Re: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

2016-06-16 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

The check seems reasonable, I'm surprised there's no warning in Clang that 
catches index[array] syntax ;)

A few comments re: implementation.



Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:43
@@ +42,3 @@
+
+static StringRef getAsString(const MatchFinder::MatchResult &Result,
+ const Expr *E) {

Looks like this repeats getText from clang/Tooling/FixIt.h.


Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:73
@@ +72,3 @@
+
+  D << 
FixItHint::CreateReplacement(ArraySubscriptE->getLHS()->getSourceRange(),
+RHSString);

Looks like you could use createReplacement and/or getText from 
clang/Tooling/FixIt.h.


http://reviews.llvm.org/D21134



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


Re: [PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-16 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 60992.
timshen added a comment.

Updated the patch to use ignorngImplicit/Expr::IgnoreImplicit matcher.

I think there is a systematic way to do this change:
Look at every ignoringImpCasts, ignoringParenCasts, ignoringParenImpCasts, 
ignoringParens, and 
Expr::IgnoreImpCasts, Expr::IgnoreParenCasts, Expr::IgnoreParenImpCasts, 
Expr::IgnoreParens to
see if they can be changed to ignoringImplicit or Expr::IgnoreImplicit (which 
also ignores
ExprWithCleanups).

I'd say for most of the cases ExprWithCleanups should be ignored, but I'm not 
sure if I'm the
right person to look at these patterns.


http://reviews.llvm.org/D21243

Files:
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -39,21 +39,21 @@
  stringLiteral(hasSize(0);
 
   const auto EmptyStringCtorExprWithTemporaries =
-  expr(ignoringImplicit(
-  cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)));
 
   // Match a variable declaration with an empty string literal as initializer.
   // Examples:
   // string foo = "";
   // string bar("");
   Finder->addMatcher(
-  namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
-hasInitializer(
-expr(anyOf(EmptyStringCtorExpr,
-   EmptyStringCtorExprWithTemporaries))
-.bind("expr"))),
-unless(parmVarDecl()))
+  namedDecl(
+  varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
+  hasInitializer(expr(ignoringImplicit(anyOf(
+  EmptyStringCtorExpr,
+  EmptyStringCtorExprWithTemporaries)))
+ .bind("expr"))),
+  unless(parmVarDecl()))
   .bind("decl"),
   this);
 }
Index: clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,8 @@
   if (!Init)
 return false;
 
+  Init = Init->IgnoreImplicit();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast(Init)) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,7 +156,7 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
 return nullptr;
-  E = E->IgnoreParenImpCasts();
+  E = E->IgnoreImplicit();
   if (const auto *ConstructExpr = dyn_cast(E)) {
 // The initial constructor must take exactly one parameter, but base class
 // and deferred constructors can take more.
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
   ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tidy/misc/DanglingHandleCheck.cpp
@@ -8,11 +8,13 @@
 //===--===//

Re: r272867 - [Lex] Try to fix a 'comparison is always false' warning. NFC.

2016-06-16 Thread David Blaikie via cfe-commits
I can't remember the rules - but wouldn't this produce UB on a signed char
platform in the case where Ch is negative? (or is that just unspecified?
implementation defined?)

On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Wed Jun 15 21:30:33 2016
> New Revision: 272867
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272867&view=rev
> Log:
> [Lex] Try to fix a 'comparison is always false' warning. NFC.
>
> Modified:
> cfe/trunk/lib/Lex/PPDirectives.cpp
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016
> @@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str
>SmallString<32> LowerInclude{Include};
>for (char &Ch : LowerInclude) {
>  // In the ASCII range?
> -if (Ch < 0 || Ch > 0x7f)
> +if (static_cast(Ch) > 0x7f)
>return false; // Can't be a standard header
>  // ASCII lowercase:
>  if (Ch >= 'A' && Ch <= 'Z')
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r272867 - [Lex] Try to fix a 'comparison is always false' warning. NFC.

2016-06-16 Thread George Burgess IV via cfe-commits
I don't think so -- 4.7p2 says "If the destination type is unsigned, the
resulting value is the least unsigned integer congruent to the source
integer (modulo 2 n where n is the number of bits used to represent the
unsigned type). [ Note: In a two’s complement representation, this
conversion is conceptual and there is no change in the bit pattern (if
there is no truncation). — end note ]"

OTOH, the other way around (unsigned -> signed) is implementation-defined.
:)

On Thu, Jun 16, 2016 at 10:27 AM, David Blaikie  wrote:

> I can't remember the rules - but wouldn't this produce UB on a signed char
> platform in the case where Ch is negative? (or is that just unspecified?
> implementation defined?)
>
> On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: gbiv
>> Date: Wed Jun 15 21:30:33 2016
>> New Revision: 272867
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272867&view=rev
>> Log:
>> [Lex] Try to fix a 'comparison is always false' warning. NFC.
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPDirectives.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016
>> @@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str
>>SmallString<32> LowerInclude{Include};
>>for (char &Ch : LowerInclude) {
>>  // In the ASCII range?
>> -if (Ch < 0 || Ch > 0x7f)
>> +if (static_cast(Ch) > 0x7f)
>>return false; // Can't be a standard header
>>  // ASCII lowercase:
>>  if (Ch >= 'A' && Ch <= 'Z')
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20630: [OpenCL] Allow -std={cl|CL}{|1.1|1.2|2.0} in driver

2016-06-16 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Ping! It would be nice to have this fix committed soon!

Thanks!


http://reviews.llvm.org/D20630



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


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-06-16 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Ping! :)


http://reviews.llvm.org/D20249



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


Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-06-16 Thread Ziv Izhar via cfe-commits
zizhar updated this revision to Diff 60996.
zizhar added a comment.

A redo, investigated a bit more, had to fix some things, moved it to 
ActOnGCCAsmStmt.
fixed intrin.h (the patch reveals a problem in it).
added tests to check for regression and examples.


http://reviews.llvm.org/D15075

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Headers/Intrin.h
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -28,6 +28,16 @@
   asm ("nop" : : : "204"); // expected-error {{unknown register name '204' in asm}}
   asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
   asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+  register void *clobber_conflict asm ("%rcx");
+  register void *no_clobber_conflict asm ("%rax");
+  int a,b,c;
+  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
 }
 
 // rdar://6094010
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -23,6 +23,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 using namespace clang;
 using namespace sema;
@@ -138,6 +139,94 @@
   return false;
 }
 
+// Extracting the register name from the Expression value,
+// if there is no register name to extract, returns ""
+StringRef ExtractRegisterName(const Expr *Expression,
+  const TargetInfo &Target) {
+  while (const ImplicitCastExpr *P = dyn_cast(Expression)) {
+Expression = P->getSubExpr();
+  }
+  if (const DeclRefExpr *AsmDeclRef = dyn_cast(Expression)) {
+// Handle cases where the expression is a variable
+const VarDecl *Variable = dyn_cast(AsmDeclRef->getDecl());
+if (Variable && Variable->getStorageClass() == SC_Register) {
+  if (AsmLabelAttr *Attr = Variable->getAttr())
+return Target.isValidGCCRegisterName(Attr->getLabel())
+? Target.getNormalizedGCCRegisterName(Attr->getLabel(), true)
+: "";
+}
+  }
+  return "";
+}
+
+// Gets a constraint and returns the register the constraint specifies or "" if
+// there is no register associated with the constraint
+StringRef GetConstraintRegister(const StringRef &Constraint,
+  const Expr *Expression,
+  const TargetInfo &Target) {
+  for (int i = 0; i < Constraint.size(); ++i) {
+switch (Constraint[i]) {
+  // Ignore these
+case '*':
+case '?':
+case '!':
+  // Will see this and the following in mult-alt constraints.
+case '=':
+case '+':
+  continue;
+  // For the register constraints, return the matching register name
+case 'a':
+  return "ax";
+case 'b':
+  return "bx";
+case 'c':
+  return "cx";
+case 'd':
+  return "dx";
+case 'S':
+  return "si";
+case 'D':
+  return "di";
+  // In case the constraint is 'r' we need to extract the register name
+case 'r':
+  return ExtractRegisterName(Expression, Target);
+default:
+  // Default value if there is no constraint for the register
+  return "";
+}
+  }
+  return "";
+}
+
+// Checks if there is a conflict between the input and output lists with the
+// clobbers list
+bool HasClobberConflict(MultiExprArg Exprs, StringLiteral **Constraints,
+  StringLiteral **Clobbers, int NumClobbers,
+  const TargetInfo &Target, ASTContext &Cont) {
+  llvm::StringSet<> InOutVars;
+  // Collect all the input and output registers from the extended asm statement
+  // in order to check for conflicts with the clobber list
+  for (int i = 0; i < Exprs.size(); ++i) {
+StringRef Constraint = Constrai

Re: r272867 - [Lex] Try to fix a 'comparison is always false' warning. NFC.

2016-06-16 Thread David Blaikie via cfe-commits
ah, rightio - thanks for the reminder!

On Thu, Jun 16, 2016 at 10:44 AM, George Burgess IV <
george.burgess...@gmail.com> wrote:

> I don't think so -- 4.7p2 says "If the destination type is unsigned, the
> resulting value is the least unsigned integer congruent to the source
> integer (modulo 2 n where n is the number of bits used to represent the
> unsigned type). [ Note: In a two’s complement representation, this
> conversion is conceptual and there is no change in the bit pattern (if
> there is no truncation). — end note ]"
>
> OTOH, the other way around (unsigned -> signed) is implementation-defined.
> :)
>
> On Thu, Jun 16, 2016 at 10:27 AM, David Blaikie 
> wrote:
>
>> I can't remember the rules - but wouldn't this produce UB on a signed
>> char platform in the case where Ch is negative? (or is that just
>> unspecified? implementation defined?)
>>
>> On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: gbiv
>>> Date: Wed Jun 15 21:30:33 2016
>>> New Revision: 272867
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=272867&view=rev
>>> Log:
>>> [Lex] Try to fix a 'comparison is always false' warning. NFC.
>>>
>>> Modified:
>>> cfe/trunk/lib/Lex/PPDirectives.cpp
>>>
>>> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
>>> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016
>>> @@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str
>>>SmallString<32> LowerInclude{Include};
>>>for (char &Ch : LowerInclude) {
>>>  // In the ASCII range?
>>> -if (Ch < 0 || Ch > 0x7f)
>>> +if (static_cast(Ch) > 0x7f)
>>>return false; // Can't be a standard header
>>>  // ASCII lowercase:
>>>  if (Ch >= 'A' && Ch <= 'Z')
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-06-16 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


http://reviews.llvm.org/D20249



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


r272931 - Re-apply r272900 - [OpenMP] Cast captures by copy when passed to fork call so that they are compatible to what the runtime library expects.

2016-06-16 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jun 16 13:39:34 2016
New Revision: 272931

URL: http://llvm.org/viewvc/llvm-project?rev=272931&view=rev
Log:
Re-apply r272900 - [OpenMP] Cast captures by copy when passed to fork call so 
that they are compatible to what the runtime library expects.

An issue in one of the regression tests was fixed for 32-bit hosts.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/for_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/single_codegen.cpp
cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=272931&r1=272930&r2=272931&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jun 16 13:39:34 2016
@@ -4815,8 +4815,7 @@ void CGOpenMPRuntime::emitTargetOutlined
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
 
-  OutlinedFn =
-  CGF.GenerateOpenMPCapturedStmtFunction(CS, /*CastValToPtr=*/true);
+  OutlinedFn = CGF.GenerateOpenMPCapturedStmtFunction(CS);
 
   // If this target outline function is not an offload entry, we don't need to
   // register it.
@@ -5485,7 +5484,6 @@ public:
   MappableExprsHandler::MapValuesArrayTy &CurPointers,
   MappableExprsHandler::MapValuesArrayTy &CurSizes,
   MappableExprsHandler::MapFlagsArrayTy &CurMapTypes) {
-auto &Ctx = CGF.getContext();
 
 // Do the default mapping.
 if (CI.capturesThis()) {
@@ -5497,36 +5495,17 @@ public:
   CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_TO |
 MappableExprsHandler::OMP_MAP_FROM);
 } else if (CI.capturesVariableByCopy()) {
+  CurBasePointers.push_back(CV);
+  CurPointers.push_back(CV);
   if (!RI.getType()->isAnyPointerType()) {
-// If the field is not a pointer, we need to save the actual value
-// and load it as a void pointer.
+// We have to signal to the runtime captures passed by value that are
+// not pointers.
 CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_PRIVATE_VAL);
-auto DstAddr = CGF.CreateMemTemp(Ctx.getUIntPtrType(),
- Twine(CI.getCapturedVar()->getName()) 
+
- ".casted");
-LValue DstLV = CGF.MakeAddrLValue(DstAddr, Ctx.getUIntPtrType());
-
-auto *SrcAddrVal = CGF.EmitScalarConversion(
-DstAddr.getPointer(), Ctx.getPointerType(Ctx.getUIntPtrType()),
-Ctx.getPointerType(RI.getType()), SourceLocation());
-LValue SrcLV = CGF.MakeNaturalAlignAddrLValue(SrcAddrVal, 
RI.getType());
-
-// Store the value using the source type pointer.
-CGF.EmitStoreThroughLValue(RValue::get(CV), SrcLV);
-
-// Load the value using the destination type pointer.
-CurBasePointers.push_back(
-CGF.EmitLoadOfLValue(DstLV, SourceLocation()).getScalarVal());
-CurPointers.push_back(CurBasePointers.back());
-
-// Get the size of the type to be used in the map.
 CurSizes.push_back(CGF.getTypeSize(RI.getType()));
   } else {
 // Pointers are implicitly mapped with a zero size and no flags
 // (other than first map that is added for all implicit maps).
 CurMapTypes.push_back(0u);
-CurBasePointers.push_back(CV);
-CurPointers.push_back(CV);
 CurSizes.push_back(llvm::Constant::getNullValue(CGF.SizeTy));
   }
 } else {

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=272931&r1=272930&r2=272931&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jun 16 13:39:34 2016
@@ -136,10 +136,33 @@ void CodeGenFunction::GenerateOpenMPCapt
   CapturedVars.push_back(Val);
 } else if (CurCap->capturesThis())
   CapturedVars.push_back(CXXThisValue);
-else if (CurCap->capturesVariableByCopy())
-  CapturedVars.push_back(
-  EmitLoadOfLValue(EmitLValue(*I), SourceLocation()).getScalarVal());
-else {
+else if (CurCap->capturesVariableByCopy()) {
+  llvm::Value *CV =
+  EmitLoadOfLValue(EmitLValue(*I), SourceLocation()).getScalarVal();
+
+  // If the field is not a pointer, we need to save the actual value
+  // and load it as a void pointer.
+  i

r272933 - [x86] generate IR for AVX2 integer min/max builtins

2016-06-16 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Thu Jun 16 13:45:01 2016
New Revision: 272933

URL: http://llvm.org/viewvc/llvm-project?rev=272933&view=rev
Log:
[x86] generate IR for AVX2 integer min/max builtins
Sibling patch to r272932:
http://reviews.llvm.org/rL272932

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=272933&r1=272932&r2=272933&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 16 13:45:01 2016
@@ -6826,28 +6826,40 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_pcmpgtq512_mask:
 return EmitX86MaskedCompare(*this, ICmpInst::ICMP_SGT, Ops);
 
-  // TODO: Handle 64/256/512-bit vector widths of min/max.
+  // TODO: Handle 64/512-bit vector widths of min/max.
   case X86::BI__builtin_ia32_pmaxsb128:
   case X86::BI__builtin_ia32_pmaxsw128:
-  case X86::BI__builtin_ia32_pmaxsd128: {
+  case X86::BI__builtin_ia32_pmaxsd128:
+  case X86::BI__builtin_ia32_pmaxsb256:
+  case X86::BI__builtin_ia32_pmaxsw256:
+  case X86::BI__builtin_ia32_pmaxsd256: {
 Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_SGT, Ops[0], Ops[1]);
 return Builder.CreateSelect(Cmp, Ops[0], Ops[1]);
   }
   case X86::BI__builtin_ia32_pmaxub128:
   case X86::BI__builtin_ia32_pmaxuw128:
-  case X86::BI__builtin_ia32_pmaxud128: {
+  case X86::BI__builtin_ia32_pmaxud128:
+  case X86::BI__builtin_ia32_pmaxub256:
+  case X86::BI__builtin_ia32_pmaxuw256:
+  case X86::BI__builtin_ia32_pmaxud256: {
 Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_UGT, Ops[0], Ops[1]);
 return Builder.CreateSelect(Cmp, Ops[0], Ops[1]);
   }
   case X86::BI__builtin_ia32_pminsb128:
   case X86::BI__builtin_ia32_pminsw128:
-  case X86::BI__builtin_ia32_pminsd128: {
+  case X86::BI__builtin_ia32_pminsd128:
+  case X86::BI__builtin_ia32_pminsb256:
+  case X86::BI__builtin_ia32_pminsw256:
+  case X86::BI__builtin_ia32_pminsd256: {
 Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_SLT, Ops[0], Ops[1]);
 return Builder.CreateSelect(Cmp, Ops[0], Ops[1]);
   }
   case X86::BI__builtin_ia32_pminub128:
   case X86::BI__builtin_ia32_pminuw128:
-  case X86::BI__builtin_ia32_pminud128: {
+  case X86::BI__builtin_ia32_pminud128:
+  case X86::BI__builtin_ia32_pminub256:
+  case X86::BI__builtin_ia32_pminuw256:
+  case X86::BI__builtin_ia32_pminud256: {
 Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_ULT, Ops[0], Ops[1]);
 return Builder.CreateSelect(Cmp, Ops[0], Ops[1]);
   }

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=272933&r1=272932&r2=272933&view=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Thu Jun 16 13:45:01 2016
@@ -717,73 +717,85 @@ void test_mm256_maskstore_epi64(long lon
 
 __m256i test_mm256_max_epi8(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_max_epi8
-  // CHECK: call <32 x i8> @llvm.x86.avx2.pmaxs.b(<32 x i8> %{{.*}}, <32 x i8> 
%{{.*}})
+  // CHECK:   [[CMP:%.*]] = icmp sgt <32 x i8> [[X:%.*]], [[Y:%.*]]
+  // CHECK-NEXT:  select <32 x i1> [[CMP]], <32 x i8> [[X]], <32 x i8> [[Y]]
   return _mm256_max_epi8(a, b);
 }
 
 __m256i test_mm256_max_epi16(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_max_epi16
-  // CHECK: call <16 x i16> @llvm.x86.avx2.pmaxs.w(<16 x i16> %{{.*}}, <16 x 
i16> %{{.*}})
+  // CHECK:   [[CMP:%.*]] = icmp sgt <16 x i16> [[X:%.*]], [[Y:%.*]]
+  // CHECK-NEXT:  select <16 x i1> [[CMP]], <16 x i16> [[X]], <16 x i16> [[Y]]
   return _mm256_max_epi16(a, b);
 }
 
 __m256i test_mm256_max_epi32(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_max_epi32
-  // CHECK: call <8 x i32> @llvm.x86.avx2.pmaxs.d(<8 x i32> %{{.*}}, <8 x i32> 
%{{.*}})
+  // CHECK:   [[CMP:%.*]] = icmp sgt <8 x i32> [[X:%.*]], [[Y:%.*]]
+  // CHECK-NEXT:  select <8 x i1> [[CMP]], <8 x i32> [[X]], <8 x i32> [[Y]]
   return _mm256_max_epi32(a, b);
 }
 
 __m256i test_mm256_max_epu8(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_max_epu8
-  // CHECK: call <32 x i8> @llvm.x86.avx2.pmaxu.b(<32 x i8> %{{.*}}, <32 x i8> 
%{{.*}})
+  // CHECK:   [[CMP:%.*]] = icmp ugt <32 x i8> [[X:%.*]], [[Y:%.*]]
+  // CHECK-NEXT:  select <32 x i1> [[CMP]], <32 x i8> [[X]], <32 x i8> [[Y]]
   return _mm256_max_epu8(a, b);
 }
 
 __m256i test_mm256_max_epu16(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_max_epu16
-  // CHECK: call <16 x i16> @llvm.x86.avx2.pmaxu.w(<16 x i16> %{{.*}}, <16 x 
i16> %{{.*}})
+  // CHECK:   [[CMP:%.*]] = icmp ugt <16 x i16> [[X:%.*]], [[Y:%.*]]
+  // CHECK-NEXT:  select <16 x i1> [[CMP]], <16 x i16> [[X]], <16 x i16> [[Y]]
   return _mm256_max_epu16(a,

Re: [PATCH] D19763: Functions declared in a scope should not hide previous declaration in earlier scopes

2016-06-16 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaLookup.cpp:1091
@@ -1091,2 +1091,2 @@
 bool Found = false;
 for (; I != IEnd && S->isDeclScope(*I); ++I) {

Please rename this to something like `SearchNamespaceScope` (and invert the 
sense of it) to reflect what it now means.


http://reviews.llvm.org/D19763



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-16 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This timeval thing looks like a legitimate warning to me.
I don't think the analysis should go beyond the function boundaries. If a 
callee expects timeval * as part of its signature it should get a properly 
aligned timeval *.


http://reviews.llvm.org/D20561



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


Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-16 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20821



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


Re: [PATCH] D21277: Resubmit r270688: Using new TargetParser in Clang.

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

Fine with me.

-eric



Comment at: lib/Basic/Targets.cpp:5709
@@ -5716,3 +5708,3 @@
 
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {

rengolin wrote:
> We'll have to re-work these parts anyway. When I was looking to do the target 
> parser for aarch64 last year, I realised that there are a lot of weird 
> decisions (like this one), and I'd rather do it slowly and surely, to make 
> sure we do it right.
> 
> IIRC, this function was being used as "checkCPU" instead on the ARM target as 
> well, and we made it do what it says in the tin. There are a lot of changed 
> in the ARM world that we can easily translate here.
> 
> But not on this patch. :)
I suppose, it's pretty terrible either way.


Repository:
  rL LLVM

http://reviews.llvm.org/D21277



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


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-06-16 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGExprCXX.cpp:57-58
@@ -56,2 +56,4 @@
   const FunctionProtoType *FPT = MD->getType()->castAs();
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size());
+  // Don't pass in the MethodDecl, because we should already have the
+  // pass_object_size values in the arglist.
+  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size(), MD);

Comment doesn't seem to match the code; `Args.size()` here includes only the 
'this' pointer and the possible destructor VTT parameter. Delete comment?


Comment at: lib/CodeGen/CGExprCXX.cpp:331
@@ -329,3 +330,3 @@
   // And the rest of the call args
   EmitCallArgs(Args, FPT, E->arguments(), E->getDirectCallee());
   return EmitCall(CGM.getTypes().arrangeCXXMethodCall(Args, FPT, required),

Seems inconsistent to pass `E->getDirectCallee()` here but not above. Since you 
can't take the address of a pass_object_size function, do we need to pass the 
callee in either place?


http://reviews.llvm.org/D17462



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


Re: [PATCH] D20923: [Sema] Fix a crash on invalid where invalid defaulted function is called

2016-06-16 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


http://reviews.llvm.org/D20923



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-06-16 Thread Richard Smith via cfe-commits
rsmith added a comment.

I agree, that looks like correct behavior for the warning. Thanks!



Comment at: lib/Sema/SemaCast.cpp:259-260
@@ -258,2 +258,4 @@
 return ExprError();
+  if (DestType->isVoidPointerType())
+DiscardMisalignedMemberAddress(E);
 }

More generally, I think we should discard it if the destination of the cast is 
a suitably-aligned pointer type. (For instance, casting to char* should be OK, 
and casting an __attribute__((packed,aligned(2))) to a 2-byte-aligned pointer 
type should be OK.)


http://reviews.llvm.org/D20561



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


[PATCH] D21446: Comprehensive static instrumentation (2/3): Clang support

2016-06-16 Thread Tyler Denniston via cfe-commits
tdenniston created this revision.
tdenniston added reviewers: kcc, zhaoqin, bruening.
tdenniston added subscribers: cfe-commits, eugenis, pcc, vitalybuka, aizatsky.
tdenniston set the repository for this revision to rL LLVM.
tdenniston added a project: Comprehensive Static Instrumentation.

This diff encompasses clang support for CSI.

Repository:
  rL LLVM

http://reviews.llvm.org/D21446

Files:
  docs/CSI.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2106,6 +2106,8 @@
   Opts.SanitizeAddressFieldPadding =
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
+
+  Opts.ComprehensiveStaticInstrumentation = Args.hasArg(OPT_fcsi);
 }
 
 static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
@@ -2318,6 +2320,7 @@
 LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
+Res.getLangOpts()->ComprehensiveStaticInstrumentation = Args.hasArg(OPT_fcsi);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4941,6 +4941,10 @@
   const SanitizerArgs &Sanitize = getToolChain().getSanitizerArgs();
   Sanitize.addArgs(getToolChain(), Args, CmdArgs, InputType);
 
+  if (Args.hasArg(options::OPT_fcsi)) {
+Args.AddLastArg(CmdArgs, options::OPT_fcsi);
+  }
+
   // Report an error for -faltivec on anything other than PowerPC.
   if (const Arg *A = Args.getLastArg(options::OPT_faltivec)) {
 const llvm::Triple::ArchType Arch = getToolChain().getArch();
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -258,6 +258,11 @@
   PM.add(createDataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
 }
 
+static void addComprehensiveStaticInstrumentationPass(const PassManagerBuilder &Builder,
+  PassManagerBase &PM) {
+  PM.add(createComprehensiveStaticInstrumentationPass());
+}
+
 static void addEfficiencySanitizerPass(const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
   const PassManagerBuilderWrapper &BuilderWrapper =
@@ -438,6 +443,13 @@
addDataFlowSanitizerPass);
   }
 
+  if (LangOpts.ComprehensiveStaticInstrumentation) {
+PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
+   addComprehensiveStaticInstrumentationPass);
+PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+   addComprehensiveStaticInstrumentationPass);
+  }
+
   if (LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addEfficiencySanitizerPass);
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -687,6 +687,9 @@
   Group, Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Strip (or keep only, if negative) a given number of path components "
"when emitting check metadata.">;
+def fcsi : Flag<["-"], "fcsi">, Group,
+   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+   HelpText<"Turn Comprehensive Static Instrumentation.">;
 def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,
   Group;
 def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">,
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -255,6 +255,8 @@
"field padding (0: none, 1:least "
"aggressive, 2: more aggressive)")
 
+LANGOPT(ComprehensiveStaticInstrumentation, 1, 0, "Turn on Comprehensive Static Instrumentation.")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
Index: docs/CSI.rst
===
--- /dev/null
+++ docs/CSI.rst
@@ -0,0 +1,349 @@
+Comprehensive Static Instrumentation
+
+

r272944 - [DebugInfo] Put the vftable index in the debug info

2016-06-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Jun 16 15:08:51 2016
New Revision: 272944

URL: http://llvm.org/viewvc/llvm-project?rev=272944&view=rev
Log:
[DebugInfo] Put the vftable index in the debug info

This won't always be enough info to call a virtual method from the
debugger, but it's a start.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=272944&r1=272943&r2=272944&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 16 15:08:51 2016
@@ -1185,14 +1185,23 @@ llvm::DISubprogram *CGDebugInfo::CreateC
 else
   Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
 
-// It doesn't make sense to give a virtual destructor a vtable index,
-// since a single destructor has two entries in the vtable.
-// FIXME: Add proper support for debug info for virtual calls in
-// the Microsoft ABI, where we may use multiple vptrs to make a vftable
-// lookup if we have multiple or virtual inheritance.
-if (!isa(Method) &&
-!CGM.getTarget().getCXXABI().isMicrosoft())
-  VIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(Method);
+if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
+  // It doesn't make sense to give a virtual destructor a vtable index,
+  // since a single destructor has two entries in the vtable.
+  if (!isa(Method))
+VIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(Method);
+} else {
+  // Emit MS ABI vftable information.  There is only one entry for the
+  // deleting dtor.
+  const auto *DD = dyn_cast(Method);
+  GlobalDecl GD = DD ? GlobalDecl(DD, Dtor_Deleting) : GlobalDecl(Method);
+  MicrosoftVTableContext::MethodVFTableLocation ML =
+  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
+  VIndex = ML.Index;
+  // FIXME: Pass down ML.VFPtrOffset and ML.VBTableIndex. The debugger 
needs
+  // these to synthesize a call to a virtual method in a complex 
inheritance
+  // hierarchy.
+}
 ContainingType = RecordTy;
   }
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp?rev=272944&r1=272943&r2=272944&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp Thu Jun 16 15:08:51 2016
@@ -3,11 +3,17 @@
 // Tests that certain miscellaneous features work in the MS ABI.
 
 struct Foo {
+  virtual void f();
+  virtual void g();
+  virtual void h();
   struct Nested {};
 };
 Foo f;
 Foo::Nested n;
-// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
+// CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "Foo",
 // CHECK-SAME: identifier: ".?AUFoo@@"
+// CHECK: !DISubprogram(name: "f", {{.*}} containingType: ![[Foo]], 
virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, {{.*}})
+// CHECK: !DISubprogram(name: "g", {{.*}} containingType: ![[Foo]], 
virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1, {{.*}})
+// CHECK: !DISubprogram(name: "h", {{.*}} containingType: ![[Foo]], 
virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, {{.*}})
 // CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
 // CHECK-SAME: identifier: ".?AUNested@Foo@@"


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


r272947 - Minor fixes for miamcpu-opt.c test

2016-06-16 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Jun 16 15:16:49 2016
New Revision: 272947

URL: http://llvm.org/viewvc/llvm-project?rev=272947&view=rev
Log:
Minor fixes for miamcpu-opt.c test

Added -no-canonical-prefixes to make cc1 binary name more predictable.
Added appropriate REQUIRES keywords.

Modified:
cfe/trunk/test/Driver/miamcu-opt.c

Modified: cfe/trunk/test/Driver/miamcu-opt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/miamcu-opt.c?rev=272947&r1=272946&r2=272947&view=diff
==
--- cfe/trunk/test/Driver/miamcu-opt.c (original)
+++ cfe/trunk/test/Driver/miamcu-opt.c Thu Jun 16 15:16:49 2016
@@ -1,9 +1,12 @@
-// RUN: %clang -miamcu %s -### -o %t.o 2>&1 | FileCheck %s
-// RUN: %clang -miamcu -m32 %s -### -o %t.o 2>&1 | FileCheck %s
-// RUN: %clang -miamcu -target x86_64-unknown-linux-gnu %s -### -o %t.o 2>&1 | 
FileCheck %s
-// RUN: %clang -miamcu -m64 %s -### -o %t.o 2>&1 | FileCheck %s 
-check-prefix=M64
-// RUN: %clang -miamcu -dynamic %s -### -o %t.o 2>&1 | FileCheck %s 
-check-prefix=DYNAMIC
-// RUN: %clang -miamcu -target armv8-eabi %s -### -o %t.o 2>&1 | FileCheck %s 
-check-prefix=NOT-X86
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+//
+// RUN: %clang -miamcu -no-canonical-prefixes %s -### -o %t.o 2>&1 | FileCheck 
%s
+// RUN: %clang -miamcu -no-canonical-prefixes -m32 %s -### -o %t.o 2>&1 | 
FileCheck %s
+// RUN: %clang -miamcu -no-canonical-prefixes -target x86_64-unknown-linux-gnu 
%s -### -o %t.o 2>&1 | FileCheck %s
+// RUN: %clang -miamcu -no-canonical-prefixes -m64 %s -### -o %t.o 2>&1 | 
FileCheck %s -check-prefix=M64
+// RUN: %clang -miamcu -no-canonical-prefixes -dynamic %s -### -o %t.o 2>&1 | 
FileCheck %s -check-prefix=DYNAMIC
+// RUN: %clang -miamcu -no-canonical-prefixes  -target armv8-eabi %s -### -o 
%t.o 2>&1 | FileCheck %s -check-prefix=NOT-X86
 
 // M64: error: invalid argument '-miamcu' not allowed with '-m64'
 


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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-16 Thread Piotr Padlewski via cfe-commits
Prazek added a reviewer: hokein.
Prazek added a subscriber: hokein.
Prazek added a comment.

@alexfh or @hokein ping


http://reviews.llvm.org/D20964



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


Re: [PATCH] D21446: Comprehensive static instrumentation (2/3): Clang support

2016-06-16 Thread Kostya Serebryany via cfe-commits
kcc added inline comments.


Comment at: docs/CSI.rst:7
@@ +6,3 @@
+
+CSI:LLVM is a framework providing comprehensive static instrumentation via the
+compiler in order to simplify the task of building efficient and effective

The intro paragraph is important to attract users. 
That's up to you, but I would try to make it shorter. 
E.g. 
"framework providing comprehensive static instrumentation via the compiler"
might be replaced with 
"framework for comprehensive compile-time instrumentation"
etc. 

On the other hand, the intro lacks a single most important sentence, in bold, 
explaining why CSI is cool. Something like "With CSI the tool writers will not 
need to hack the compiler"


Comment at: docs/CSI.rst:22
@@ +21,3 @@
+To ensure high performance of CSI tools, CSI:LLVM ideally should be configured
+to enable link-time optimization (LTO), and the GNU ``gold linker`` is a
+prerequisite for enabling LTO for CSI:LLVM.  (See

gold is not the only linker that supports LTO. 
Say something like "linker needs to support LTO [link]"


Comment at: docs/CSI.rst:29
@@ +28,3 @@
+
+To create a CSI tool, add ``#include `` at the top of the tool source
+and implement function bodies for the hooks relevant to the tool.

Here you may want a bit more detail. 
E.g. "a simple CSI tool may consist of a single C++ file".  


Comment at: docs/CSI.rst:38
@@ +37,3 @@
+
+  % clang++ -c -emit-llvm null-tool.c -o null-tool.o
+  % clang++ -c -emit-llvm my-tool.cpp -o my-tool.o

-emit-llvm here is confusing, at least for me. 
Either explain why you need it here (to combine real object file with LLVM) or 
find another way...

Ideally, this and linking the null tool should be hidden under -fcsi or some 
such,
but this could be done in later patches. 


Comment at: docs/CSI.rst:48
@@ +47,3 @@
+
+The LLVM/Clang used to build the tool does not have to be CSI:LLVM, as long
+as it generates LLVM bitcode compatible with CSI:LLVM.

Even if this is true, the statement is a bit risky. 
What if the LLVM bit code changes? 
I would omit this unless you really need it. 


Comment at: docs/CSI.rst:58
@@ +57,3 @@
+
+* Modify paths in the build process to point to CSI:LLVM (including its Clang
+  driver).

Too complex. Just tell the user that they need to use fresh clang. 


Comment at: docs/CSI.rst:61
@@ +60,3 @@
+* When building object files for the TIX, pass additional arguments ``-fcsi``
+  and ``-emit-llvm`` to the Clang driver, which produces CSI instrumented
+  object files.

-emit-llvm again. It should be hidden inside -fcsi. 
It's ok to fix it later, but then please explain in the docs that it's temporary


Comment at: docs/CSI.rst:64
@@ +63,3 @@
+* During the linking stage for the TIX, add additional arguments
+  ``-fuse-ld=gold`` and ``-flto`` and add the tool object file (e.g.
+  ``my-tool.o``) to be statically linked to the TIX.

again, gold is not the only LTO-enabled linker. 


Comment at: docs/CSI.rst:79
@@ +78,3 @@
+the static library of the CSI runtime to produce the final TIX.  The runtime
+archive is distributed under the ``build/lib/clang//lib/``
+directory. We plan to investigate means of linking with the runtime

this too needs to be hidden under -fcsi


Comment at: docs/CSI.rst:125
@@ +124,3 @@
+  // Value representing unknown CSI ID
+  #define UNKNOWN_CSI_ID ((csi_id_t)-1)
+

avoid the C preprocessor when you can (const var is usually better)


Comment at: docs/CSI.rst:148
@@ +147,3 @@
+``init_priority`` attribute), however, the execution order of that constructor
+relative to ``__csi_init`` is undefined.
+

On Linux, there is preinit_array... Just saying... 


Comment at: docs/CSI.rst:196
@@ +195,3 @@
+
+ void __csi_bb_entry(const csi_id_t bb_id);
+ void __csi_bb_exit(const csi_id_t bb_id);

didn't you want properties here? 
E.g. I have one use case for bb_entry property: whether this BB is important 
for coverage instrumentation or may be omitted. 

(there are plenty of papers on this, e.g. 
http://users.sdsc.edu/~mtikir/publications/papers/issta02.pdf)


Comment at: docs/CSI.rst:216
@@ +215,3 @@
+
+  void __csi_before_call(const csi_id_t call_id, const csi_id_t func_id);
+  void __csi_after_call(const csi_id_t call_id, const csi_id_t func_id);

maybe use callee_id instead of func_id?


Comment at: docs/CSI.rst:245
@@ +244,3 @@
+  // the same basic block.
+  #define CSI_PROP_LOAD_READ_BEFORE_WRITE_IN_BB 0x1
+

avoid #defines.
const or enum should be enough


Comment at: docs/CSI.rst:266
@@ +265,3 @@
+locations in the source code.  The FED tables are indexed by the progr

Re: [PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

2016-06-16 Thread Rudy Pons via cfe-commits
Ilod added a reviewer: rnk.
Ilod updated this revision to Diff 61029.
Ilod added a comment.

Updated to head revision, and pinging this.


http://reviews.llvm.org/D20647

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/inline-hint.cpp

Index: test/CodeGenCXX/inline-hint.cpp
===
--- test/CodeGenCXX/inline-hint.cpp
+++ test/CodeGenCXX/inline-hint.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -fno-inline-implicit-hint -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=EXPLICIT
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-implicit-hint -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=IMPLICIT
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -finline-implicit-hint -fno-inline -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NOINLINE
+
+// Force non-trivial implicit constructors/destructors/operators for B by having explicit ones for A
+struct A {
+  A() {}
+  A(const A&) {}
+  A& operator=(const A&) { return *this; }
+  ~A() {}
+};
+
+struct B {
+  A member;
+  int implicitFunction(int a) { return a + a; }
+  inline int explicitFunction(int a);
+  int noHintFunction(int a);
+  __attribute__((optnone)) int optNoneFunction(int a) { return a + a; }
+};
+
+int B::explicitFunction(int a) { return a + a; }
+// CHECK: @_ZN1B14noHintFunctionEi({{.*}}) [[NOHINT_ATTR:#[0-9]+]]
+int B::noHintFunction(int a) { return a + a; }
+
+constexpr int constexprFunction(int a) { return a + a; }
+
+void foo()
+{
+// CHECK: @_ZN1BC1Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR:#[0-9]+]]
+  B b1;
+// CHECK: @_ZN1BC1ERKS_({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+  B b2(b1);
+// CHECK: @_ZN1BaSERKS_({{.*}}) [[IMPLICIT_CONSTR_ATTR]]
+  b2 = b1;
+// CHECK: @_ZN1B16implicitFunctionEi({{.*}}) [[IMPLICIT_ATTR:#[0-9]+]]
+  b2.implicitFunction(1);
+// CHECK: @_ZN1B16explicitFunctionEi({{.*}}) [[EXPLICIT_ATTR:#[0-9]+]]
+  b2.explicitFunction(2);
+  b2.noHintFunction(3);
+// CHECK: @_ZN1B15optNoneFunctionEi({{.*}}) [[OPTNONE_ATTR:#[0-9]+]]
+  b2.optNoneFunction(4);
+// CHECK: @_Z17constexprFunctioni({{.*}}) [[IMPLICIT_ATTR]]
+  constexprFunction(5);
+// CHECK: @_ZN1BD2Ev({{.*}}) unnamed_addr [[IMPLICIT_CONSTR_ATTR]]
+}
+
+// EXPLICIT-NOT: attributes [[NOHINT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// IMPLICIT-NOT: attributes [[NOHINT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[NOHINT_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-NOT: attributes [[IMPLICIT_ATTR]] = { {{.*}}inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[IMPLICIT_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[IMPLICIT_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[IMPLICIT_CONSTR_ATTR]] = { noinline{{.*}} }
+
+// EXPLICIT-DAG: attributes [[EXPLICIT_ATTR]] = { inlinehint{{.*}} }
+// IMPLICIT-DAG: attributes [[EXPLICIT_ATTR]] = { inlinehint{{.*}} }
+// NOINLINE-DAG: attributes [[EXPLICIT_ATTR]] = { noinline{{.*}} }
+
+// CHECK-DAG: attributes [[OPTNONE_ATTR]] = { noinline{{.*}} }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -447,6 +447,8 @@
   InlineArg->getOption().matches(options::OPT_finline_functions) ?
 CodeGenOptions::NormalInlining : CodeGenOptions::OnlyAlwaysInlining);
   }
+  Opts.ImplicitInlineHint = Args.hasFlag(OPT_finline_implicit_hint,
+ OPT_fno_inline_implicit_hint, false);
 
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -699,12 +699,14 @@
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Pass inline keyword to optimizer if it appears explicitly on any
-  // declaration. Also, in the case of -fno-inline attach NoInline
-  // attribute to all function that are not marked AlwaysInline.
+  // declaration, or implicitly in the case of -finline-implicit-hint.
+  // Also, in the case of -fno-inline attach NoInline attribute to all
+  // function that are not marked AlwaysInline.
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (!CGM.getCodeGenOpts().NoInline) {
   for (auto RI : FD->redecls())
-if (RI->isInlineSpecified()) {
+if (RI->isInlineSpecified() ||
+(CGM.getCodeGenOpts().ImplicitInlineHint && RI->isInlined())) {
   Fn->addFnAttr(llvm::Attribute::InlineHint);
   break;
 }
Index: incl

r272961 - Functions declared in a scope should not hide previous declaration in earlier scopes

2016-06-16 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Jun 16 16:39:46 2016
New Revision: 272961

URL: http://llvm.org/viewvc/llvm-project?rev=272961&view=rev
Log:
Functions declared in a scope should not hide previous declaration in earlier 
scopes

This code should be an error:

 void foo(int);
 void f3() {
   int foo(float);
   {
 float foo(int); // expected-error {{functions that differ only in their 
return type cannot be overloaded}}
   }
 }

the foo(float) function declared at function scope should not hide the 
float(int)
while trying to redeclare functions.

Differential Revision: http://reviews.llvm.org/D19763

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/function-redecl.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=272961&r1=272960&r2=272961&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Jun 16 16:39:46 2016
@@ -1078,32 +1078,35 @@ bool Sema::CppLookupName(LookupResult &R
 
   for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) {
 DeclContext *Ctx = S->getEntity();
-
+bool SearchNamespaceScope = true;
 // Check whether the IdResolver has anything in this scope.
-bool Found = false;
 for (; I != IEnd && S->isDeclScope(*I); ++I) {
   if (NamedDecl *ND = R.getAcceptableDecl(*I)) {
-if (NameKind == LookupRedeclarationWithLinkage) {
+if (NameKind == LookupRedeclarationWithLinkage &&
+!(*I)->isTemplateParameter()) {
+  // If it's a template parameter, we still find it, so we can diagnose
+  // the invalid redeclaration.
+
   // Determine whether this (or a previous) declaration is
   // out-of-scope.
   if (!LeftStartingScope && !Initial->isDeclScope(*I))
 LeftStartingScope = true;
 
   // If we found something outside of our starting scope that
-  // does not have linkage, skip it. If it's a template parameter,
-  // we still find it, so we can diagnose the invalid redeclaration.
-  if (LeftStartingScope && !((*I)->hasLinkage()) &&
-  !(*I)->isTemplateParameter()) {
+  // does not have linkage, skip it.
+  if (LeftStartingScope && !((*I)->hasLinkage())) {
 R.setShadowed();
 continue;
   }
+} else {
+  // We found something in this scope, we should not look at the
+  // namespace scope
+  SearchNamespaceScope = false;
 }
-
-Found = true;
 R.addDecl(ND);
   }
 }
-if (Found) {
+if (!SearchNamespaceScope) {
   R.resolveKind();
   if (S->isClassScope())
 if (CXXRecordDecl *Record = dyn_cast_or_null(Ctx))

Modified: cfe/trunk/test/SemaCXX/function-redecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/function-redecl.cpp?rev=272961&r1=272960&r2=272961&view=diff
==
--- cfe/trunk/test/SemaCXX/function-redecl.cpp (original)
+++ cfe/trunk/test/SemaCXX/function-redecl.cpp Thu Jun 16 16:39:46 2016
@@ -7,7 +7,7 @@ namespace N {
 void bar(int); // expected-note 2{{previous declaration is here}}
   }
 
-  void foo(int); // expected-note 2{{previous declaration is here}}
+  void foo(int); // expected-note 3{{previous declaration is here}}
 
   void f2() {
 int foo(int); // expected-error {{functions that differ only in their 
return type cannot be overloaded}}
@@ -25,6 +25,13 @@ namespace N {
   }
 }
   }
+
+  void f3() {
+int foo(float);
+{
+  float foo(int); // expected-error {{functions that differ only in their 
return type cannot be overloaded}}
+}
+  }
 }
 
 class A {


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


Re: [PATCH] D19763: Functions declared in a scope should not hide previous declaration in earlier scopes

2016-06-16 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272961: Functions declared in a scope should not hide 
previous declaration in earlier… (authored by ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D19763?vs=55712&id=61033#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19763

Files:
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/test/SemaCXX/function-redecl.cpp

Index: cfe/trunk/test/SemaCXX/function-redecl.cpp
===
--- cfe/trunk/test/SemaCXX/function-redecl.cpp
+++ cfe/trunk/test/SemaCXX/function-redecl.cpp
@@ -7,7 +7,7 @@
 void bar(int); // expected-note 2{{previous declaration is here}}
   }
 
-  void foo(int); // expected-note 2{{previous declaration is here}}
+  void foo(int); // expected-note 3{{previous declaration is here}}
 
   void f2() {
 int foo(int); // expected-error {{functions that differ only in their 
return type cannot be overloaded}}
@@ -25,6 +25,13 @@
   }
 }
   }
+
+  void f3() {
+int foo(float);
+{
+  float foo(int); // expected-error {{functions that differ only in their 
return type cannot be overloaded}}
+}
+  }
 }
 
 class A {
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -1078,32 +1078,35 @@
 
   for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) {
 DeclContext *Ctx = S->getEntity();
-
+bool SearchNamespaceScope = true;
 // Check whether the IdResolver has anything in this scope.
-bool Found = false;
 for (; I != IEnd && S->isDeclScope(*I); ++I) {
   if (NamedDecl *ND = R.getAcceptableDecl(*I)) {
-if (NameKind == LookupRedeclarationWithLinkage) {
+if (NameKind == LookupRedeclarationWithLinkage &&
+!(*I)->isTemplateParameter()) {
+  // If it's a template parameter, we still find it, so we can diagnose
+  // the invalid redeclaration.
+
   // Determine whether this (or a previous) declaration is
   // out-of-scope.
   if (!LeftStartingScope && !Initial->isDeclScope(*I))
 LeftStartingScope = true;
 
   // If we found something outside of our starting scope that
-  // does not have linkage, skip it. If it's a template parameter,
-  // we still find it, so we can diagnose the invalid redeclaration.
-  if (LeftStartingScope && !((*I)->hasLinkage()) &&
-  !(*I)->isTemplateParameter()) {
+  // does not have linkage, skip it.
+  if (LeftStartingScope && !((*I)->hasLinkage())) {
 R.setShadowed();
 continue;
   }
+} else {
+  // We found something in this scope, we should not look at the
+  // namespace scope
+  SearchNamespaceScope = false;
 }
-
-Found = true;
 R.addDecl(ND);
   }
 }
-if (Found) {
+if (!SearchNamespaceScope) {
   R.resolveKind();
   if (S->isClassScope())
 if (CXXRecordDecl *Record = dyn_cast_or_null(Ctx))


Index: cfe/trunk/test/SemaCXX/function-redecl.cpp
===
--- cfe/trunk/test/SemaCXX/function-redecl.cpp
+++ cfe/trunk/test/SemaCXX/function-redecl.cpp
@@ -7,7 +7,7 @@
 void bar(int); // expected-note 2{{previous declaration is here}}
   }
 
-  void foo(int); // expected-note 2{{previous declaration is here}}
+  void foo(int); // expected-note 3{{previous declaration is here}}
 
   void f2() {
 int foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
@@ -25,6 +25,13 @@
   }
 }
   }
+
+  void f3() {
+int foo(float);
+{
+  float foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+}
+  }
 }
 
 class A {
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -1078,32 +1078,35 @@
 
   for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) {
 DeclContext *Ctx = S->getEntity();
-
+bool SearchNamespaceScope = true;
 // Check whether the IdResolver has anything in this scope.
-bool Found = false;
 for (; I != IEnd && S->isDeclScope(*I); ++I) {
   if (NamedDecl *ND = R.getAcceptableDecl(*I)) {
-if (NameKind == LookupRedeclarationWithLinkage) {
+if (NameKind == LookupRedeclarationWithLinkage &&
+!(*I)->isTemplateParameter()) {
+  // If it's a template parameter, we still find it, so we can diagnose
+  // the invalid redeclaration.
+
   // Determine whether this (or a previous) declaration is
   // out-of-scope.
   if (!LeftStartingScope && !Initial->isDeclScope

r272962 - Keep invalid functions as part of the AST

2016-06-16 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Jun 16 16:39:55 2016
New Revision: 272962

URL: http://llvm.org/viewvc/llvm-project?rev=272962&view=rev
Log:
Keep invalid functions as part of the AST

Differential Revision: http://reviews.llvm.org/D19764

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Misc/ast-dump-invalid.cpp
cfe/trunk/test/Sema/predefined-function.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=272962&r1=272961&r2=272962&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun 16 16:39:55 2016
@@ -5100,10 +5100,9 @@ NamedDecl *Sema::HandleDeclarator(Scope
   if (!New)
 return nullptr;
 
-  // If this has an identifier and is not an invalid redeclaration or
-  // function template specialization, add it to the scope stack.
-  if (New->getDeclName() && AddToScope &&
-   !(D.isRedeclaration() && New->isInvalidDecl())) {
+  // If this has an identifier and is not a function template specialization,
+  // add it to the scope stack.
+  if (New->getDeclName() && AddToScope) {
 // Only make a locally-scoped extern declaration visible if it is the first
 // declaration of this entity. Qualified lookup for such an entity should
 // only find this declaration if there is no visible declaration of it.

Modified: cfe/trunk/test/Misc/ast-dump-invalid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-invalid.cpp?rev=272962&r1=272961&r2=272962&view=diff
==
--- cfe/trunk/test/Misc/ast-dump-invalid.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-invalid.cpp Thu Jun 16 16:39:55 2016
@@ -41,3 +41,24 @@ int g(int i) {
 // CHECK-NEXT: `-ImplicitCastExpr {{.*}}  'int' 

 // CHECK-NEXT:   `-DeclRefExpr {{.*}}  'int' lvalue ParmVar 
{{.*}} 'i' 'int'
 
+
+namespace TestInvalidFunctionDecl {
+struct Str {
+   double foo1(double, invalid_type);
+};
+double Str::foo1(double, invalid_type)
+{ return 45; }
+}
+// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
+// CHECK-NEXT: |-CXXRecordDecl {{.*}}  line:46:8 struct 
Str definition
+// CHECK-NEXT: | |-CXXRecordDecl {{.*}}  col:8 implicit struct 
Str
+// CHECK-NEXT: | `-CXXMethodDecl {{.*}}  col:11 invalid 
foo1 'double (double, int)'
+// CHECK-NEXT: |   |-ParmVarDecl {{.*}}  col:22 'double'
+// CHECK-NEXT: |   `-ParmVarDecl {{.*}} > col:36 
invalid 'int'
+// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}}  
line:49:13 invalid foo1 'double (double, int)'
+// CHECK-NEXT:   |-ParmVarDecl {{.*}}  col:24 'double'
+// CHECK-NEXT:   |-ParmVarDecl {{.*}} > col:38 invalid 
'int'
+// CHECK-NEXT:   `-CompoundStmt {{.*}} 
+// CHECK-NEXT: `-ReturnStmt {{.*}} 
+// CHECK-NEXT:   `-ImplicitCastExpr {{.*}}  'double' 

+// CHECK-NEXT: `-IntegerLiteral {{.*}}  'int' 45

Modified: cfe/trunk/test/Sema/predefined-function.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/predefined-function.c?rev=272962&r1=272961&r2=272962&view=diff
==
--- cfe/trunk/test/Sema/predefined-function.c (original)
+++ cfe/trunk/test/Sema/predefined-function.c Thu Jun 16 16:39:55 2016
@@ -4,14 +4,13 @@ char *funk(int format);
 enum Test {A=-1};
 char *funk(enum Test x);
 
-int eli(float b); // expected-note {{previous declaration is here}} \
-// expected-note{{passing argument to parameter 'b' here}}
+int eli(float b); // expected-note {{previous declaration is here}}
 int b(int c) {return 1;}
 
 int foo();
 int foo() {
   int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
-  eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible 
type 'float'}}
+  eli(b);
   return 0;
 }
 


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


r272963 - Fix a few issues while skipping function bodies

2016-06-16 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Jun 16 16:40:06 2016
New Revision: 272963

URL: http://llvm.org/viewvc/llvm-project?rev=272963&view=rev
Log:
Fix a few issues while skipping function bodies

 - In functions with try { } catch { }, only the try block would be
   skipped, not the catch blocks

 - The template functions would still be parsed.

 - The initializers within a constructor would still be parsed.

 - The inline functions within class would still be stored, only to be
   discared later.

 - Invalid code with try would assert (as in "int foo() try assert_here")

This attempt to do even less while skipping function bodies.

Differential Revision: http://reviews.llvm.org/D20821

Added:
cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=272963&r1=272962&r2=272963&view=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Jun 16 16:40:06 2016
@@ -101,6 +101,12 @@ NamedDecl *Parser::ParseCXXInlineMethodD
 return FnD;
   }
 
+  if (SkipFunctionBodies && (!FnD || Actions.canSkipFunctionBody(FnD)) &&
+  trySkippingFunctionBody()) {
+Actions.ActOnSkippedFunctionBody(FnD);
+return FnD;
+  }
+
   // In delayed template parsing mode, if we are within a class template
   // or if we are about to parse function member template then consume
   // the tokens and store them for parsing at the end of the translation unit.

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=272963&r1=272962&r2=272963&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jun 16 16:40:06 2016
@@ -2656,6 +2656,12 @@ Parser::ParseObjCAutoreleasePoolStmt(Sou
 /// StashAwayMethodOrFunctionBodyTokens -  Consume the tokens and store them 
 /// for later parsing.
 void Parser::StashAwayMethodOrFunctionBodyTokens(Decl *MDecl) {
+  if (SkipFunctionBodies && (!MDecl || Actions.canSkipFunctionBody(MDecl)) &&
+  trySkippingFunctionBody()) {
+Actions.ActOnSkippedFunctionBody(MDecl);
+return;
+  }
+
   LexedMethod* LM = new LexedMethod(this, MDecl);
   CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
   CachedTokens &Toks = LM->Toks;

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=272963&r1=272962&r2=272963&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Jun 16 16:40:06 2016
@@ -1916,12 +1916,6 @@ Decl *Parser::ParseFunctionStatementBody
   assert(Tok.is(tok::l_brace));
   SourceLocation LBraceLoc = Tok.getLocation();
 
-  if (SkipFunctionBodies && (!Decl || Actions.canSkipFunctionBody(Decl)) &&
-  trySkippingFunctionBody()) {
-BodyScope.Exit();
-return Actions.ActOnSkippedFunctionBody(Decl);
-  }
-
   PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
   "parsing function body");
 
@@ -1964,12 +1958,6 @@ Decl *Parser::ParseFunctionTryBlock(Decl
   else
 Actions.ActOnDefaultCtorInitializers(Decl);
 
-  if (SkipFunctionBodies && Actions.canSkipFunctionBody(Decl) &&
-  trySkippingFunctionBody()) {
-BodyScope.Exit();
-return Actions.ActOnSkippedFunctionBody(Decl);
-  }
-
   // Save and reset current vtordisp stack if we have entered a C++ method 
body.
   bool IsCXXMethod =
   getLangOpts().CPlusPlus && Decl && isa(Decl);
@@ -1990,27 +1978,43 @@ Decl *Parser::ParseFunctionTryBlock(Decl
 }
 
 bool Parser::trySkippingFunctionBody() {
-  assert(Tok.is(tok::l_brace));
   assert(SkipFunctionBodies &&
  "Should only be called when SkipFunctionBodies is enabled");
-
   if (!PP.isCodeCompletionEnabled()) {
-ConsumeBrace();
-SkipUntil(tok::r_brace);
+SkipFunctionBody();
 return true;
   }
 
   // We're in code-completion mode. Skip parsing for all function bodies unless
   // the body contains the code-completion point.
   TentativeParsingAction PA(*this);
-  ConsumeBrace();
-  if (SkipUntil(tok::r_brace, StopAtCodeCompletion)) {
+  bool IsTryCatch = Tok.is(tok::kw_try);
+  CachedTokens Toks;
+  bool ErrorInPrologue = ConsumeAndStoreFunctionPrologue(Toks);
+  if (llvm::any_of(Toks, [](const Token &Tok) {
+return Tok.is(tok::code_completion);
+  })) {
+PA.Revert();
+return 

Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-16 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272963: Fix a few issues while skipping function bodies 
(authored by ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D20821?vs=60340&id=61035#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20821

Files:
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
  cfe/trunk/unittests/Tooling/ToolingTest.cpp

Index: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
===
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
@@ -0,0 +1,41 @@
+struct Base1 {
+  Base1() : {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: Pattern : member1(<#args#>)
+  // CHECK-CC1: COMPLETION: Pattern : member2(<#args#>
+
+  Base1(int) : member1(123), {}
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#args#>)
+  // CHECK-CC2: COMPLETION: Pattern : member2(<#args#>
+
+  int member1;
+  float member2;
+};
+
+struct Derived : public Base1 {
+  Derived();
+  Derived(int);
+  Derived(float);
+  int deriv1;
+};
+
+Derived::Derived() : {}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: COMPLETION: Pattern : Base1(<#args#>)
+// CHECK-CC3: COMPLETION: Pattern : deriv1(<#args#>)
+
+Derived::Derived(int) try : {
+} catch (...) {
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:28:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: Pattern : Base1(<#args#>)
+// CHECK-CC4: COMPLETION: Pattern : deriv1(<#args#>)
+
+Derived::Derived(float) try : Base1(),
+{
+} catch (...) {
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:35:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5-NOT: COMPLETION: Pattern : Base1(<#args#>)
+// CHECK-CC5: COMPLETION: Pattern : deriv1(<#args#>)
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -11384,7 +11384,7 @@
 FD->setHasSkippedBody();
   else if (ObjCMethodDecl *MD = dyn_cast_or_null(Decl))
 MD->setHasSkippedBody();
-  return ActOnFinishFunctionBody(Decl, nullptr);
+  return Decl;
 }
 
 Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) {
Index: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
===
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
@@ -101,6 +101,12 @@
 return FnD;
   }
 
+  if (SkipFunctionBodies && (!FnD || Actions.canSkipFunctionBody(FnD)) &&
+  trySkippingFunctionBody()) {
+Actions.ActOnSkippedFunctionBody(FnD);
+return FnD;
+  }
+
   // In delayed template parsing mode, if we are within a class template
   // or if we are about to parse function member template then consume
   // the tokens and store them for parsing at the end of the translation unit.
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -2656,6 +2656,12 @@
 /// StashAwayMethodOrFunctionBodyTokens -  Consume the tokens and store them 
 /// for later parsing.
 void Parser::StashAwayMethodOrFunctionBodyTokens(Decl *MDecl) {
+  if (SkipFunctionBodies && (!MDecl || Actions.canSkipFunctionBody(MDecl)) &&
+  trySkippingFunctionBody()) {
+Actions.ActOnSkippedFunctionBody(MDecl);
+return;
+  }
+
   LexedMethod* LM = new LexedMethod(this, MDecl);
   CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
   CachedTokens &Toks = LM->Toks;
Index: cfe/trunk/lib/Parse/Parser.cpp
===
--- cfe/trunk/lib/Parse/Parser.cpp
+++ cfe/trunk/lib/Parse/Parser.cpp
@@ -1044,6 +1044,12 @@
 D.complete(DP);
 D.getMutableDeclSpec().abort();
 
+if (SkipFunctionBodies && (!DP || Actions.canSkipFunctionBody(DP)) &&
+trySkippingFunctionBody()) {
+  BodyScope.Exit();
+  return Actions.ActOnSkippedFunctionBody(DP);
+}
+
 CachedTokens Toks;
 LexTemplateFunctionForLateParsing(Toks);
 
@@ -1136,6 +1142,13 @@
 return Res;
   }
 
+  if (SkipFunctionBodies && (!Res || Actions.canSkipFunctionBody(Res)) &&
+  trySkippingFunctionBody()) {
+BodyScope.Exit();
+Actions.ActOnSkippedFunctionBody(Res);
+return Actions.ActOnFinishFunctionBody(Res, nullptr, false);
+  }
+
   if (Tok.is(tok::kw_tr

Re: [PATCH] D19764: Keep invalid functions as part of the AST

2016-06-16 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272962: Keep invalid functions as part of the AST (authored 
by ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D19764?vs=55714&id=61034#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19764

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Misc/ast-dump-invalid.cpp
  cfe/trunk/test/Sema/predefined-function.c

Index: cfe/trunk/test/Sema/predefined-function.c
===
--- cfe/trunk/test/Sema/predefined-function.c
+++ cfe/trunk/test/Sema/predefined-function.c
@@ -4,14 +4,13 @@
 enum Test {A=-1};
 char *funk(enum Test x);
 
-int eli(float b); // expected-note {{previous declaration is here}} \
-// expected-note{{passing argument to parameter 'b' here}}
+int eli(float b); // expected-note {{previous declaration is here}}
 int b(int c) {return 1;}
 
 int foo();
 int foo() {
   int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
-  eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible 
type 'float'}}
+  eli(b);
   return 0;
 }
 
Index: cfe/trunk/test/Misc/ast-dump-invalid.cpp
===
--- cfe/trunk/test/Misc/ast-dump-invalid.cpp
+++ cfe/trunk/test/Misc/ast-dump-invalid.cpp
@@ -41,3 +41,24 @@
 // CHECK-NEXT: `-ImplicitCastExpr {{.*}}  'int' 

 // CHECK-NEXT:   `-DeclRefExpr {{.*}}  'int' lvalue ParmVar 
{{.*}} 'i' 'int'
 
+
+namespace TestInvalidFunctionDecl {
+struct Str {
+   double foo1(double, invalid_type);
+};
+double Str::foo1(double, invalid_type)
+{ return 45; }
+}
+// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
+// CHECK-NEXT: |-CXXRecordDecl {{.*}}  line:46:8 struct 
Str definition
+// CHECK-NEXT: | |-CXXRecordDecl {{.*}}  col:8 implicit struct 
Str
+// CHECK-NEXT: | `-CXXMethodDecl {{.*}}  col:11 invalid 
foo1 'double (double, int)'
+// CHECK-NEXT: |   |-ParmVarDecl {{.*}}  col:22 'double'
+// CHECK-NEXT: |   `-ParmVarDecl {{.*}} > col:36 
invalid 'int'
+// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}}  
line:49:13 invalid foo1 'double (double, int)'
+// CHECK-NEXT:   |-ParmVarDecl {{.*}}  col:24 'double'
+// CHECK-NEXT:   |-ParmVarDecl {{.*}} > col:38 invalid 
'int'
+// CHECK-NEXT:   `-CompoundStmt {{.*}} 
+// CHECK-NEXT: `-ReturnStmt {{.*}} 
+// CHECK-NEXT:   `-ImplicitCastExpr {{.*}}  'double' 

+// CHECK-NEXT: `-IntegerLiteral {{.*}}  'int' 45
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -5100,10 +5100,9 @@
   if (!New)
 return nullptr;
 
-  // If this has an identifier and is not an invalid redeclaration or
-  // function template specialization, add it to the scope stack.
-  if (New->getDeclName() && AddToScope &&
-   !(D.isRedeclaration() && New->isInvalidDecl())) {
+  // If this has an identifier and is not a function template specialization,
+  // add it to the scope stack.
+  if (New->getDeclName() && AddToScope) {
 // Only make a locally-scoped extern declaration visible if it is the first
 // declaration of this entity. Qualified lookup for such an entity should
 // only find this declaration if there is no visible declaration of it.


Index: cfe/trunk/test/Sema/predefined-function.c
===
--- cfe/trunk/test/Sema/predefined-function.c
+++ cfe/trunk/test/Sema/predefined-function.c
@@ -4,14 +4,13 @@
 enum Test {A=-1};
 char *funk(enum Test x);
 
-int eli(float b); // expected-note {{previous declaration is here}} \
-// expected-note{{passing argument to parameter 'b' here}}
+int eli(float b); // expected-note {{previous declaration is here}}
 int b(int c) {return 1;}
 
 int foo();
 int foo() {
   int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
-  eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible type 'float'}}
+  eli(b);
   return 0;
 }
 
Index: cfe/trunk/test/Misc/ast-dump-invalid.cpp
===
--- cfe/trunk/test/Misc/ast-dump-invalid.cpp
+++ cfe/trunk/test/Misc/ast-dump-invalid.cpp
@@ -41,3 +41,24 @@
 // CHECK-NEXT: `-ImplicitCastExpr {{.*}}  'int' 
 // CHECK-NEXT:   `-DeclRefExpr {{.*}}  'int' lvalue ParmVar {{.*}} 'i' 'int'
 
+
+namespace TestInvalidFunctionDecl {
+struct Str {
+   double foo1(double, invalid_type);
+};
+double Str::foo1(double, invalid_type)
+{ return 45; }
+}
+// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
+// CHECK-NEXT: |-CXXRecordDecl {{.*}}  line:46:8 struct Str definition
+// CHECK-NEXT: | |-CXXRecordDecl {{.*}}  col:8 implicit struct Str
+// CHECK-NEXT: | `-CXXMethodDecl {{.*}}  col:11 invalid foo1 'double (double, int)'
+// CHECK-NEXT: |   |-ParmVarDecl {{.*}}  col:22 'do

Re: [PATCH] D19327: Keep invalid function body as part of the AST

2016-06-16 Thread Olivier Goffart via cfe-commits
ogoffart abandoned this revision.
ogoffart added a comment.

Replaced by http://reviews.llvm.org/D19764


http://reviews.llvm.org/D19327



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


[PATCH] D21451: Emit the DWARF tag for the RenderScript language

2016-06-16 Thread Pirama Arumuga Nainar via cfe-commits
pirama created this revision.
pirama added a reviewer: rsmith.
pirama added subscribers: srhines, cfe-commits.

If the RenderScript LangOpt is set, either via '-x renderscript' or the '.rs'
file extension, set the DWARF language tag to be that of RenderScript.

http://reviews.llvm.org/D21451

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-renderscript-tag.rs

Index: test/CodeGen/debug-info-renderscript-tag.rs
===
--- /dev/null
+++ test/CodeGen/debug-info-renderscript-tag.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -383,6 +383,8 @@
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC1) {
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.RenderScript) {
+LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {


Index: test/CodeGen/debug-info-renderscript-tag.rs
===
--- /dev/null
+++ test/CodeGen/debug-info-renderscript-tag.rs
@@ -0,0 +1,3 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -383,6 +383,8 @@
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC1) {
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.RenderScript) {
+LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21451: Emit the DWARF tag for the RenderScript language

2016-06-16 Thread Richard Smith via cfe-commits
LGTM

On 16 Jun 2016 3:07 p.m., "Pirama Arumuga Nainar via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> pirama created this revision.
> pirama added a reviewer: rsmith.
> pirama added subscribers: srhines, cfe-commits.
>
> If the RenderScript LangOpt is set, either via '-x renderscript' or the
> '.rs'
> file extension, set the DWARF language tag to be that of RenderScript.
>
> http://reviews.llvm.org/D21451
>
> Files:
>   lib/CodeGen/CGDebugInfo.cpp
>   test/CodeGen/debug-info-renderscript-tag.rs
>
> Index: test/CodeGen/debug-info-renderscript-tag.rs
> ===
> --- /dev/null
> +++ test/CodeGen/debug-info-renderscript-tag.rs
> @@ -0,0 +1,3 @@
> +// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
> +
> +// CHECK: !DICompileUnit(language: DW_LANG_GOOGLE_RenderScript{{.*}})
> Index: lib/CodeGen/CGDebugInfo.cpp
> ===
> --- lib/CodeGen/CGDebugInfo.cpp
> +++ lib/CodeGen/CGDebugInfo.cpp
> @@ -383,6 +383,8 @@
>LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
>} else if (LO.ObjC1) {
>  LangTag = llvm::dwarf::DW_LANG_ObjC;
> +  } else if (LO.RenderScript) {
> +LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
>} else if (LO.C99) {
>  LangTag = llvm::dwarf::DW_LANG_C99;
>} else {
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-06-16 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 61041.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.

Addressed all feedback.


http://reviews.llvm.org/D17462

Files:
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGVTables.cpp
  test/CodeGen/pass-object-size.c
  test/CodeGenCXX/pass-object-size.cpp

Index: test/CodeGenCXX/pass-object-size.cpp
===
--- test/CodeGenCXX/pass-object-size.cpp
+++ test/CodeGenCXX/pass-object-size.cpp
@@ -53,3 +53,30 @@
   // CHECK: define void @_ZN8delegate1AC1EPvU17pass_object_size0({{[^,]*}}, i8*{{[^,]*}}, i64{{[^,]*}})
   // CHECK: call void @_ZN8delegate1AC2EPvU17pass_object_size0({{[^,]*}}, i8*{{[^,]*}}, i64{{[^,]*}})
 }
+
+namespace variadic {
+// We had an issue where variadic member/operator calls with pass_object_size
+// would cause crashes.
+
+struct AsCtor {
+  AsCtor(const char *const c __attribute__((pass_object_size(0))), double a,
+ ...) {}
+};
+
+struct AsMember {
+  void bar(const char *const c __attribute__((pass_object_size(0))), double a,
+   ...) {}
+  void operator()(const char *const c __attribute__((pass_object_size(0))),
+  double a, ...) {}
+};
+
+// CHECK-LABEL: define void @_ZN8variadic4testEv()
+void test() {
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic6AsCtorC1EPKcU17pass_object_size0dz
+  AsCtor("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMember3barEPKcU17pass_object_size0dz
+  AsMember{}.bar("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMemberclEPKcU17pass_object_size0dz
+  AsMember{}("a", 1.0);
+}
+}
Index: test/CodeGen/pass-object-size.c
===
--- test/CodeGen/pass-object-size.c
+++ test/CodeGen/pass-object-size.c
@@ -351,3 +351,18 @@
   ObjectSize0(++p);
   ObjectSize0(p++);
 }
+
+// There was a bug where variadic functions with pass_object_size would cause
+// problems in the form of failed assertions.
+void my_sprintf(char *const c __attribute__((pass_object_size(0))), ...) {}
+
+// CHECK-LABEL: define void @test14
+void test14(char *c) {
+  // CHECK: @llvm.objectsize
+  // CHECK: call void (i8*, i64, ...) @my_sprintf
+  my_sprintf(c);
+
+  // CHECK: @llvm.objectsize
+  // CHECK: call void (i8*, i64, ...) @my_sprintf
+  my_sprintf(c, 1, 2, 3);
+}
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -290,9 +290,8 @@
   const FunctionProtoType *FPT = MD->getType()->getAs();
 
 #ifndef NDEBUG
-  const CGFunctionInfo &CallFnInfo =
-CGM.getTypes().arrangeCXXMethodCall(CallArgs, FPT,
-   RequiredArgs::forPrototypePlus(FPT, 1));
+  const CGFunctionInfo &CallFnInfo = CGM.getTypes().arrangeCXXMethodCall(
+  CallArgs, FPT, RequiredArgs::forPrototypePlus(FPT, 1, MD));
   assert(CallFnInfo.getRegParm() == CurFnInfo->getRegParm() &&
  CallFnInfo.isNoReturn() == CurFnInfo->isNoReturn() &&
  CallFnInfo.getCallingConvention() == CurFnInfo->getCallingConvention());
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -54,7 +54,7 @@
   }
 
   const FunctionProtoType *FPT = MD->getType()->castAs();
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size());
+  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size(), MD);
 
   // And the rest of the call args.
   if (CE) {
@@ -324,10 +324,11 @@
   // Push the this ptr.
   Args.add(RValue::get(ThisPtrForCall), ThisType);
 
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, 1);
-  
+  RequiredArgs required =
+  RequiredArgs::forPrototypePlus(FPT, 1, /*FD=*/nullptr);
+
   // And the rest of the call args
-  EmitCallArgs(Args, FPT, E->arguments(), E->getDirectCallee());
+  EmitCallArgs(Args, FPT, E->arguments());
   return EmitCall(CGM.getTypes().arrangeCXXMethodCall(Args, FPT, required),
   Callee, ReturnValue, Args);
 }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -141,15 +141,16 @@
 CanQual FTP,
 const FunctionDecl *FD) {
   SmallVector paramInfos;
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FTP, prefix.size());
+  RequiredArgs Required =
+  RequiredArgs::forPrototypePlus(FTP, prefix.size(), FD);
   // FIXME: Kill copy.
   appendParameterTypes(CGT, prefix, paramInfos, FTP, FD);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();
 
   return CGT.arrangeLLVMFunctionInfo(resultType, instanceMethod,
  /*chainCall=*/false, prefix,
  FTP->ge

Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-06-16 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/CodeGen/CGExprCXX.cpp:331
@@ -329,3 +330,3 @@
   // And the rest of the call args
   EmitCallArgs(Args, FPT, E->arguments(), E->getDirectCallee());
   return EmitCall(CGM.getTypes().arrangeCXXMethodCall(Args, FPT, required),

rsmith wrote:
> Seems inconsistent to pass `E->getDirectCallee()` here but not above. Since 
> you can't take the address of a pass_object_size function, do we need to pass 
> the callee in either place?
Good point. :)


http://reviews.llvm.org/D17462



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


Re: [PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

2016-06-16 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Can't we implement /Ob1 by applying noinline to every non-inline specified 
function with weak linkage?


http://reviews.llvm.org/D20647



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


r272971 - [CodeGen] Fix a segfault caused by pass_object_size.

2016-06-16 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Jun 16 18:06:04 2016
New Revision: 272971

URL: http://llvm.org/viewvc/llvm-project?rev=272971&view=rev
Log:
[CodeGen] Fix a segfault caused by pass_object_size.

This patch fixes a bug where we'd segfault (in some cases) if we saw a
variadic function with one or more pass_object_size arguments.

Differential Revision: http://reviews.llvm.org/D17462

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGen/pass-object-size.c
cfe/trunk/test/CodeGenCXX/pass-object-size.cpp

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=272971&r1=272970&r2=272971&view=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Thu Jun 16 18:06:04 2016
@@ -16,8 +16,10 @@
 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
 
+#include "clang/AST/Attr.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CharUnits.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -25,8 +27,6 @@
 #include 
 
 namespace clang {
-class Decl;
-
 namespace CodeGen {
 
 /// ABIArgInfo - Helper class to encapsulate information about how a
@@ -393,23 +393,34 @@ public:
   /// Compute the arguments required by the given formal prototype,
   /// given that there may be some additional, non-formal arguments
   /// in play.
+  ///
+  /// If FD is not null, this will consider pass_object_size params in FD.
   static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype,
-   unsigned additional) {
+   unsigned additional,
+   const FunctionDecl *FD) {
 if (!prototype->isVariadic()) return All;
+if (FD)
+  additional += std::count_if(FD->param_begin(), FD->param_end(),
+  [](const ParmVarDecl *PVD) {
+return PVD->hasAttr();
+  });
 return RequiredArgs(prototype->getNumParams() + additional);
   }
 
-  static RequiredArgs forPrototype(const FunctionProtoType *prototype) {
-return forPrototypePlus(prototype, 0);
+  static RequiredArgs forPrototype(const FunctionProtoType *prototype,
+   const FunctionDecl *FD) {
+return forPrototypePlus(prototype, 0, FD);
   }
 
-  static RequiredArgs forPrototype(CanQual prototype) {
-return forPrototype(prototype.getTypePtr());
+  static RequiredArgs forPrototype(CanQual prototype,
+   const FunctionDecl *FD) {
+return forPrototype(prototype.getTypePtr(), FD);
   }
 
   static RequiredArgs forPrototypePlus(CanQual prototype,
-   unsigned additional) {
-return forPrototypePlus(prototype.getTypePtr(), additional);
+   unsigned additional,
+   const FunctionDecl *FD) {
+return forPrototypePlus(prototype.getTypePtr(), additional, FD);
   }
 
   bool allowsOptionalArgs() const { return NumRequired != ~0U; }

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=272971&r1=272970&r2=272971&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jun 16 18:06:04 2016
@@ -141,7 +141,8 @@ arrangeLLVMFunctionInfo(CodeGenTypes &CG
 CanQual FTP,
 const FunctionDecl *FD) {
   SmallVector paramInfos;
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FTP, prefix.size());
+  RequiredArgs Required =
+  RequiredArgs::forPrototypePlus(FTP, prefix.size(), FD);
   // FIXME: Kill copy.
   appendParameterTypes(CGT, prefix, paramInfos, FTP, FD);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();
@@ -149,7 +150,7 @@ arrangeLLVMFunctionInfo(CodeGenTypes &CG
   return CGT.arrangeLLVMFunctionInfo(resultType, instanceMethod,
  /*chainCall=*/false, prefix,
  FTP->getExtInfo(), paramInfos,
- required);
+ Required);
 }
 
 /// Arrange the argument and result information for a value of the
@@ -338,7 +339,7 @@ CodeGenTypes::arrangeCXXConstructorCall(
 ArgTypes.push_back(Context.getCanonicalParamType(Arg.Ty));
 
   CanQual FPT = GetFormalType(D);
-  RequiredArgs Required = RequiredArgs::

Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-06-16 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272971: [CodeGen] Fix a segfault caused by pass_object_size. 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D17462?vs=61041&id=61048#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17462

Files:
  cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/test/CodeGen/pass-object-size.c
  cfe/trunk/test/CodeGenCXX/pass-object-size.cpp

Index: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
===
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
@@ -16,17 +16,17 @@
 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
 
+#include "clang/AST/Attr.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CharUnits.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/TrailingObjects.h"
 #include 
 
 namespace clang {
-class Decl;
-
 namespace CodeGen {
 
 /// ABIArgInfo - Helper class to encapsulate information about how a
@@ -393,23 +393,34 @@
   /// Compute the arguments required by the given formal prototype,
   /// given that there may be some additional, non-formal arguments
   /// in play.
+  ///
+  /// If FD is not null, this will consider pass_object_size params in FD.
   static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype,
-   unsigned additional) {
+   unsigned additional,
+   const FunctionDecl *FD) {
 if (!prototype->isVariadic()) return All;
+if (FD)
+  additional += std::count_if(FD->param_begin(), FD->param_end(),
+  [](const ParmVarDecl *PVD) {
+return PVD->hasAttr();
+  });
 return RequiredArgs(prototype->getNumParams() + additional);
   }
 
-  static RequiredArgs forPrototype(const FunctionProtoType *prototype) {
-return forPrototypePlus(prototype, 0);
+  static RequiredArgs forPrototype(const FunctionProtoType *prototype,
+   const FunctionDecl *FD) {
+return forPrototypePlus(prototype, 0, FD);
   }
 
-  static RequiredArgs forPrototype(CanQual prototype) {
-return forPrototype(prototype.getTypePtr());
+  static RequiredArgs forPrototype(CanQual prototype,
+   const FunctionDecl *FD) {
+return forPrototype(prototype.getTypePtr(), FD);
   }
 
   static RequiredArgs forPrototypePlus(CanQual prototype,
-   unsigned additional) {
-return forPrototypePlus(prototype.getTypePtr(), additional);
+   unsigned additional,
+   const FunctionDecl *FD) {
+return forPrototypePlus(prototype.getTypePtr(), additional, FD);
   }
 
   bool allowsOptionalArgs() const { return NumRequired != ~0U; }
Index: cfe/trunk/test/CodeGenCXX/pass-object-size.cpp
===
--- cfe/trunk/test/CodeGenCXX/pass-object-size.cpp
+++ cfe/trunk/test/CodeGenCXX/pass-object-size.cpp
@@ -53,3 +53,30 @@
   // CHECK: define void @_ZN8delegate1AC1EPvU17pass_object_size0({{[^,]*}}, i8*{{[^,]*}}, i64{{[^,]*}})
   // CHECK: call void @_ZN8delegate1AC2EPvU17pass_object_size0({{[^,]*}}, i8*{{[^,]*}}, i64{{[^,]*}})
 }
+
+namespace variadic {
+// We had an issue where variadic member/operator calls with pass_object_size
+// would cause crashes.
+
+struct AsCtor {
+  AsCtor(const char *const c __attribute__((pass_object_size(0))), double a,
+ ...) {}
+};
+
+struct AsMember {
+  void bar(const char *const c __attribute__((pass_object_size(0))), double a,
+   ...) {}
+  void operator()(const char *const c __attribute__((pass_object_size(0))),
+  double a, ...) {}
+};
+
+// CHECK-LABEL: define void @_ZN8variadic4testEv()
+void test() {
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic6AsCtorC1EPKcU17pass_object_size0dz
+  AsCtor("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMember3barEPKcU17pass_object_size0dz
+  AsMember{}.bar("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMemberclEPKcU17pass_object_size0dz
+  AsMember{}("a", 1.0);
+}
+}
Index: cfe/trunk/test/CodeGen/pass-object-size.c
===
--- cfe/trunk/test/CodeGen/pass-object-size.c
+++ cfe/trunk/test/CodeGen/pass-object-size.c
@@ -351,3 +351,18 @@
   ObjectSize0(++p);
   ObjectSize0(p++);
 }
+
+// There was a bug where variadic functions with pass_object_size would cause
+// problems in the form of failed assertio

[PATCH] D21453: Add support for attribute "overallocated"

2016-06-16 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, george.burgess.iv, aaron.ballman.
ahatanak added subscribers: cfe-commits, dexonsmith, hfinkel.

This patch adds support for attribute "overallocated", which will be used to 
indicate a union or struct is over-allocated. This is needed to have 
__builtin_object_size correctly compute the size of an object when malloc 
allocates extra space at the end of a struct or union. For example,

struct S {
   int a;
   char s[32];
};

void *p = malloc(sizeof(S) + 64);
unsigned s = builtin_object_size(((struct S*)p)->s, 1); // "s" should be 
32+64=96, not 32.

The link to the relevant discussion on cfe-dev is here:

http://lists.llvm.org/pipermail/cfe-dev/2016-March/047782.html

http://reviews.llvm.org/D21453

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/object-size.c
  test/CodeGen/object-size.cpp

Index: test/CodeGen/object-size.cpp
===
--- test/CodeGen/object-size.cpp
+++ test/CodeGen/object-size.cpp
@@ -62,3 +62,29 @@
   // CHECK: store i32 16
   gi = __builtin_object_size(&c->bs[0].buf[0], 3);
 }
+
+struct S0 {
+  int a[16], b[16];
+} __attribute__((overallocated));
+
+struct S1 : S0 {
+};
+
+struct S2 : S1 {
+} __attribute__((overallocated));
+
+// CHECK-LABEL: define void @_Z5test3v()
+void test3() {
+  struct S0 *s0;
+  struct S1 *s1;
+  struct S2 *s2;
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s0->b, 1);
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s1->b, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s2->b, 1);
+}
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -517,3 +517,49 @@
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(&dsv[9].snd[0], 1);
 }
+
+union U0 {
+  int a[16], b[16];
+} __attribute__((overallocated));
+
+struct S0 {
+  int a[16], b[16];
+};
+
+struct S1 {
+  int a[16], b[16];
+} __attribute__((overallocated));
+
+struct S2 {
+  int a[16], b[16];
+  struct S1 s1;
+  struct S0 s0;
+} __attribute__((overallocated));
+
+// CHECK-LABEL: @test32
+void test32() {
+  union U0 *u0;
+  struct S1 *s1;
+  struct S2 *s2;
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(u0->a, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(u0->b, 1);
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s1->a, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s1->b, 1);
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s2->b, 1);
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s2->s1.b, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(&s2->s0, 1);
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4929,6 +4929,12 @@
   }
 }
 
+static void handleOverAllocatedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  D->addAttr(::new (S.Context)
+ OverAllocatedAttr(Attr.getLoc(), S.Context,
+   Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
   uint32_t NumRegs;
@@ -5394,6 +5400,9 @@
   case AttributeList::AT_X86ForceAlignArgPointer:
 handleX86ForceAlignArgPointerAttr(S, D, Attr);
 break;
+  case AttributeList::AT_OverAllocated:
+handleOverAllocatedAttr(S, D, Attr);
+break;
   case AttributeList::AT_DLLExport:
   case AttributeList::AT_DLLImport:
 handleDLLAttr(S, D, Attr);
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1049,7 +1049,12 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 bool InvalidBase : 1;
-unsigned CallIndex : 31;
+
+// Indicates the enclosing struct is marked overallocated. This is used in
+// computation of __builtin_object_size.
+bool OverAllocated = 1;
+
+unsigned CallIndex : 30;
 SubobjectDesignator Designator;
 
 const APValue::LValueBase getLValueBase() const { return Base; }
@@ -1059,6 +1064,8 @@
 SubobjectDesignator &getLValueDesignator() { return Designator; }
 const SubobjectDesignator &getLValueDesignator() const { return Designator;}
 
+LValue() : OverAllocated(false) {}
+
 void moveInto(APValue &V) const {
   if (Designator.Inval

Re: [PATCH] D20647: Add flag to add InlineHint attribute on implicitly inline functions

2016-06-16 Thread Rudy Pons via cfe-commits
Ilod added a comment.

I don't think weak linkage defines this.

For example, in:

  struct A {
inline int foo() { return 0; }
int bar() { return 1; }
int baz();
  };
  int A::baz() { return 2; }

With /Ob1, we should inline foo and bar, but never baz. But baz doesn't have 
weak linkage, does it?
But indeed, if in CodeGenFunctions.cpp, instead of adding InlineHint attribute 
when we have isInlined(), I add noinline attribute if we don't have it (with 
/Ob1 or equivalent clang flag), I could avoid the work I started to inline only 
hinted functions at http://reviews.llvm.org/D20603


http://reviews.llvm.org/D20647



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


Re: [PATCH] D20389: NVPTX: Add supported CL features

2016-06-16 Thread Jan Vesely via cfe-commits
jvesely added a comment.

ping

@jholewinski, is the exported list of features OK with you?

@Anastasia, are the tests OK now?


Repository:
  rL LLVM

http://reviews.llvm.org/D20389



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


Re: [PATCH] D20388: AMDGPU: Fix supported CL features

2016-06-16 Thread Jan Vesely via cfe-commits
jvesely added a comment.

ping


Repository:
  rL LLVM

http://reviews.llvm.org/D20388



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


LLVM buildmaster will be restarted tonight

2016-06-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted after 8 PM Pacific time today.

Thanks

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


Re: [PATCH] D20388: AMDGPU: Fix supported CL features

2016-06-16 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D20388



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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-16 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:2073-2079
@@ +2072,9 @@
+  let Content = [{
+Use ``overallocated`` to indicate a struct or union is over-allocated. For 
example,
+
+.. code-block:: c++
+
+struct S {
+  char a[4], char b[4];
+} __attribute__((overallocated));
+

I don't think this says what you mean. "Overallocated" alone does not imply 
that you can use S::b to access more than 4 bytes. If you want that to work, I 
think the right model is for the attribute to imply that the final member 
within the struct is treated as a flexible array member, no matter what its 
array bound is.

This should then apply to everywhere we consider flexible array members, not 
just to builtin_object_size.


http://reviews.llvm.org/D21453



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


Re: r272741 - Headers: tweak for MSVC[<1800]

2016-06-16 Thread Saleem Abdulrasool via cfe-commits
On Thu, Jun 16, 2016 at 1:40 AM, Nico Weber  wrote:

> Maybe this should use the marketing name ("before msvc 2013")? People
> might be more familiar with that.
>
Thats a pretty good idea actually.  Ill make a follow up change.


> On Jun 15, 2016 2:34 AM, "Saleem Abdulrasool via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: compnerd
>> Date: Tue Jun 14 19:28:15 2016
>> New Revision: 272741
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272741&view=rev
>> Log:
>> Headers: tweak for MSVC[<1800]
>>
>> Earlier versions of MSVC did not include inttypes.h.  Ensure that we dont
>> try to
>> include_next on those releases.
>>
>> Modified:
>> cfe/trunk/lib/Headers/inttypes.h
>>
>> Modified: cfe/trunk/lib/Headers/inttypes.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/inttypes.h?rev=272741&r1=272740&r2=272741&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Headers/inttypes.h (original)
>> +++ cfe/trunk/lib/Headers/inttypes.h Tue Jun 14 19:28:15 2016
>> @@ -23,6 +23,10 @@
>>  #ifndef __CLANG_INTTYPES_H
>>  #define __CLANG_INTTYPES_H
>>
>> +#if defined(_MSC_VER) && _MSC_VER < 1800
>> +#error MSVC <= 11.0 does not have inttypes.h
>> +#endif
>> +
>>  #include_next 
>>
>>  #if defined(_MSC_VER) && _MSC_VER < 1900
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r272979 - Headers: wordsmith error message

2016-06-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jun 16 19:27:02 2016
New Revision: 272979

URL: http://llvm.org/viewvc/llvm-project?rev=272979&view=rev
Log:
Headers: wordsmith error message

Use the marketing name for the MSVC release as pointed out by Nico Weber!

Modified:
cfe/trunk/lib/Headers/inttypes.h

Modified: cfe/trunk/lib/Headers/inttypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/inttypes.h?rev=272979&r1=272978&r2=272979&view=diff
==
--- cfe/trunk/lib/Headers/inttypes.h (original)
+++ cfe/trunk/lib/Headers/inttypes.h Thu Jun 16 19:27:02 2016
@@ -24,7 +24,7 @@
 #define __CLANG_INTTYPES_H
 
 #if defined(_MSC_VER) && _MSC_VER < 1800
-#error MSVC <= 11.0 does not have inttypes.h
+#error MSVC does not have inttypes.h prior to Visual Studio 2013
 #endif
 
 #include_next 


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


r272983 - [ARM] Add mrrc/mrrc2 intrinsics and update existing mcrr/mcrr2 intrinsics.

2016-06-16 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Thu Jun 16 19:59:41 2016
New Revision: 272983

URL: http://llvm.org/viewvc/llvm-project?rev=272983&view=rev
Log:
[ARM] Add mrrc/mrrc2 intrinsics and update existing mcrr/mcrr2 intrinsics.

Reapplying patch in r272777 which was reverted
because the llvm patch which added support
for generating the mcrr/mcrr2 instructions
from the intrinsic was causing an assertion
failure. This has now been fixed in llvm.


Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-arm.c
cfe/trunk/test/Sema/builtins-arm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=272983&r1=272982&r2=272983&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Thu Jun 16 19:59:41 2016
@@ -57,14 +57,16 @@ BUILTIN(__builtin_arm_stcl, "vUIiUIiv*",
 BUILTIN(__builtin_arm_stc2, "vUIiUIiv*", "")
 BUILTIN(__builtin_arm_stc2l, "vUIiUIiv*", "")
 
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcr, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
-BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
+BUILTIN(__builtin_arm_mcrr, "vUIiUIiLLUiUIi", "")
+BUILTIN(__builtin_arm_mcrr2, "vUIiUIiLLUiUIi", "")
+BUILTIN(__builtin_arm_mrrc, "LLUiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_mrrc2, "LLUiUIiUIiUIi", "")
 
 // CRC32
 BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=272983&r1=272982&r2=272983&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 16 19:59:41 2016
@@ -3800,6 +3800,74 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 return EmitNounwindRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), Ops);
   }
 
+  if (BuiltinID == ARM::BI__builtin_arm_mcrr ||
+  BuiltinID == ARM::BI__builtin_arm_mcrr2) {
+Function *F;
+
+switch (BuiltinID) {
+default: llvm_unreachable("unexpected builtin");
+case ARM::BI__builtin_arm_mcrr:
+  F = CGM.getIntrinsic(Intrinsic::arm_mcrr);
+  break;
+case ARM::BI__builtin_arm_mcrr2:
+  F = CGM.getIntrinsic(Intrinsic::arm_mcrr2);
+  break;
+}
+
+// MCRR{2} instruction has 5 operands but
+// the intrinsic has 4 because Rt and Rt2
+// are represented as a single unsigned 64
+// bit integer in the intrinsic definition
+// but internally it's represented as 2 32
+// bit integers.
+
+Value *Coproc = EmitScalarExpr(E->getArg(0));
+Value *Opc1 = EmitScalarExpr(E->getArg(1));
+Value *RtAndRt2 = EmitScalarExpr(E->getArg(2));
+Value *CRm = EmitScalarExpr(E->getArg(3));
+
+Value *C1 = llvm::ConstantInt::get(Int64Ty, 32);
+Value *Rt = Builder.CreateTruncOrBitCast(RtAndRt2, Int32Ty);
+Value *Rt2 = Builder.CreateLShr(RtAndRt2, C1);
+Rt2 = Builder.CreateTruncOrBitCast(Rt2, Int32Ty);
+
+return Builder.CreateCall(F, {Coproc, Opc1, Rt, Rt2, CRm});
+  }
+
+  if (BuiltinID == ARM::BI__builtin_arm_mrrc ||
+  BuiltinID == ARM::BI__builtin_arm_mrrc2) {
+Function *F;
+
+switch (BuiltinID) {
+default: llvm_unreachable("unexpected builtin");
+case ARM::BI__builtin_arm_mrrc:
+  F = CGM.getIntrinsic(Intrinsic::arm_mrrc);
+  break;
+case ARM::BI__builtin_arm_mrrc2:
+  F = CGM.getIntrinsic(Intrinsic::arm_mrrc2);
+  break;
+}
+
+Value *Coproc = EmitScalarExpr(E->getArg(0));
+Value *Opc1 = EmitScalarExpr(E->getArg(1));
+Value *CRm  = EmitScalarExpr(E->getArg(2));
+Value *RtAndRt2 = Builder.CreateCall(F, {Coproc, Opc1, CRm});
+
+// Returns an unsigned 64 bit integer, represented
+// as two 32 bit integers.
+
+Value *Rt = Builder.CreateExtractValue(RtAndRt2, 1);
+Value *Rt1 = Builder.CreateExtractValue(RtAndRt2, 0);
+Rt = Builder.CreateZExt(Rt, Int64Ty);
+Rt1 = Builder.CreateZExt(Rt1, Int64Ty);
+
+Value *ShiftCast = llvm::ConstantInt::get(Int64Ty, 32);
+RtAndRt2 = Builder.CreateShl(Rt, ShiftCast, "shl", true);
+RtAndRt2 = Builder.CreateOr(RtAndRt2, Rt1);
+
+return Builder.CreateBitCast(RtAndRt2, ConvertType(E->getType()));
+  }
+
   if (BuiltinID == ARM::BI__builtin_arm_ldrexd ||
   ((BuiltinID == ARM::BI__builtin_arm_ldrex ||
 BuiltinID == ARM::BI__builtin_arm_ldaex) &&

Re: r272979 - Headers: wordsmith error message

2016-06-16 Thread Nico Weber via cfe-commits
thanks!

On Fri, Jun 17, 2016 at 2:27 AM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Jun 16 19:27:02 2016
> New Revision: 272979
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272979&view=rev
> Log:
> Headers: wordsmith error message
>
> Use the marketing name for the MSVC release as pointed out by Nico Weber!
>
> Modified:
> cfe/trunk/lib/Headers/inttypes.h
>
> Modified: cfe/trunk/lib/Headers/inttypes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/inttypes.h?rev=272979&r1=272978&r2=272979&view=diff
>
> ==
> --- cfe/trunk/lib/Headers/inttypes.h (original)
> +++ cfe/trunk/lib/Headers/inttypes.h Thu Jun 16 19:27:02 2016
> @@ -24,7 +24,7 @@
>  #define __CLANG_INTTYPES_H
>
>  #if defined(_MSC_VER) && _MSC_VER < 1800
> -#error MSVC <= 11.0 does not have inttypes.h
> +#error MSVC does not have inttypes.h prior to Visual Studio 2013
>  #endif
>
>  #include_next 
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r272985 - ToolingTests/runToolOnCode.TestSkipFunctionBody: Appease msc targets.

2016-06-16 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Jun 16 21:04:51 2016
New Revision: 272985

URL: http://llvm.org/viewvc/llvm-project?rev=272985&view=rev
Log:
ToolingTests/runToolOnCode.TestSkipFunctionBody: Appease msc targets.

Modified:
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=272985&r1=272984&r2=272985&view=diff
==
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Thu Jun 16 21:04:51 2016
@@ -256,6 +256,7 @@ struct SkipBodyAction : public clang::AS
 
 TEST(runToolOnCode, TestSkipFunctionBody) {
   std::vector Args = {"-std=c++11"};
+  std::vector Args2 = {"-fno-delayed-template-parsing"};
 
   EXPECT_TRUE(runToolOnCode(new SkipBodyAction,
 "int skipMe() { an_error_here }"));
@@ -310,9 +311,9 @@ TEST(runToolOnCode, TestSkipFunctionBody
   EXPECT_TRUE(runToolOnCode(
   new SkipBodyAction, "template int skipMe() { an_error_here }"
   "int x = skipMe();"));
-  EXPECT_FALSE(
-  runToolOnCode(new SkipBodyAction,
-"template int skipMeNot() { an_error_here }"));
+  EXPECT_FALSE(runToolOnCodeWithArgs(
+  new SkipBodyAction,
+  "template int skipMeNot() { an_error_here }", Args2));
 }
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {


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


Re: [PATCH] D20821: Fix a few issues while skipping function bodies

2016-06-16 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.


Comment at: cfe/trunk/unittests/Tooling/ToolingTest.cpp:315
@@ -262,1 +314,3 @@
+  runToolOnCode(new SkipBodyAction,
+"template int skipMeNot() { an_error_here }"));
 }

It didn't pass for targeting *-msvc. Tweaked in r272985.


Repository:
  rL LLVM

http://reviews.llvm.org/D20821



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


Re: [PATCH] D20388: AMDGPU: Fix supported CL features

2016-06-16 Thread Jan Vesely via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272986: AMDGPU: Fix supported CL features (authored by 
jvesely).

Changed prior to commit:
  http://reviews.llvm.org/D20388?vs=60259&id=61060#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20388

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
  cfe/trunk/test/Misc/r600.languageOptsOpenCL.cl

Index: cfe/trunk/test/Misc/r600.languageOptsOpenCL.cl
===
--- cfe/trunk/test/Misc/r600.languageOptsOpenCL.cl
+++ cfe/trunk/test/Misc/r600.languageOptsOpenCL.cl
@@ -0,0 +1,225 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cayman
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu cypress
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu turks
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple r600-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -target-cpu turks
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifdef cl_khr_fp16
+#error "Incorrect cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
+
+#ifdef cl_khr_int64_base_atomics
+#error "Incorrect cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_int64_base_atomics' - ignoring}}
+
+#ifdef cl_khr_int64_extended_atomics
+#error "Incorrect cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_int64_extended_atomics' - ignoring}}
+
+#ifdef cl_khr_gl_sharing
+#error "Incorrect cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_gl_sharing' - ignoring}}
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+
+#ifndef cl_khr_byte_addressable_store
+#error "Missing cl_khr_byte_addressable_

r272986 - AMDGPU: Fix supported CL features

2016-06-16 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 16 21:25:03 2016
New Revision: 272986

URL: http://llvm.org/viewvc/llvm-project?rev=272986&view=rev
Log:
AMDGPU: Fix supported CL features

Reviewers: arsenm

Differential Revision: http://reviews.llvm.org/D20388

Added:
cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
cfe/trunk/test/Misc/r600.languageOptsOpenCL.cl
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=272986&r1=272985&r2=272986&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun 16 21:25:03 2016
@@ -2029,6 +2029,8 @@ public:
   Builder.defineMacro("__HAS_FMAF__");
 if (hasLDEXPF)
   Builder.defineMacro("__HAS_LDEXPF__");
+if (hasFP64)
+  Builder.defineMacro("__HAS_FP64__");
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
@@ -2094,29 +2096,26 @@ public:
 return GPU != GK_NONE;
   }
 
-   void setSupportedOpenCLOpts() override {
- auto &Opts = getSupportedOpenCLOpts();
- Opts.cl_clang_storage_class_specifiers = 1;
- Opts.cl_khr_gl_sharing = 1;
- Opts.cl_khr_gl_event = 1;
- Opts.cl_khr_d3d10_sharing = 1;
- Opts.cl_khr_subgroups = 1;
-
- if (hasFP64)
-   Opts.cl_khr_fp64 = 1;
- if (GPU >= GK_NORTHERN_ISLANDS) {
-   Opts.cl_khr_byte_addressable_store = 1;
-   Opts.cl_khr_global_int32_base_atomics = 1;
-   Opts.cl_khr_global_int32_extended_atomics = 1;
-   Opts.cl_khr_local_int32_base_atomics = 1;
-   Opts.cl_khr_local_int32_extended_atomics = 1;
- }
- if (GPU >= GK_SOUTHERN_ISLANDS)
-   Opts.cl_khr_fp16 = 1;
-   Opts.cl_khr_int64_base_atomics = 1;
-   Opts.cl_khr_int64_extended_atomics = 1;
-   Opts.cl_khr_3d_image_writes = 1;
-   Opts.cl_khr_gl_msaa_sharing = 1;
+  void setSupportedOpenCLOpts() override {
+auto &Opts = getSupportedOpenCLOpts();
+Opts.cl_clang_storage_class_specifiers = 1;
+Opts.cl_khr_icd = 1;
+
+if (hasFP64)
+  Opts.cl_khr_fp64 = 1;
+if (GPU >= GK_EVERGREEN) {
+  Opts.cl_khr_byte_addressable_store = 1;
+  Opts.cl_khr_global_int32_base_atomics = 1;
+  Opts.cl_khr_global_int32_extended_atomics = 1;
+  Opts.cl_khr_local_int32_base_atomics = 1;
+  Opts.cl_khr_local_int32_extended_atomics = 1;
+}
+if (GPU >= GK_SOUTHERN_ISLANDS) {
+  Opts.cl_khr_fp16 = 1;
+  Opts.cl_khr_int64_base_atomics = 1;
+  Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_3d_image_writes = 1;
+}
   }
 };
 

Added: cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl?rev=272986&view=auto
==
--- cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl (added)
+++ cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl Thu Jun 16 21:25:03 2016
@@ -0,0 +1,200 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple amdgcn-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple 
amdgcn-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple 
amdgcn-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple 
amdgcn-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple amdgcn-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple 
amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple 
amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple 
amdgcn-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers
+#error "Missing cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifdef cl_khr_gl_sharing
+#error "Incorrect cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_gl_sharing' - 
ignoring}}
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_icd: enable
+
+// Core features in CL 1.1
+
+#ifndef cl_khr_byte_ad

Re: [PATCH] D21459: Implement http://wg21.link/P0254R1: "Integrating std::string_view and std::string"

2016-06-16 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

I know that there are more tests needed.


http://reviews.llvm.org/D21459



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