Re: [PATCH] D16797: Update clang support on recent Haiku

2016-03-08 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D16797



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


Re: [PATCH] D17516: AMDGPU: Verify subtarget specific builtins

2016-03-08 Thread Eric Christopher via cfe-commits
echristo added a comment.

Replied inline, I hope this is helpful :)



Comment at: lib/Basic/Targets.cpp:2059-2063
@@ +2058,7 @@
+
+  if (Has16BitInsts)
+Features["16-bit-insts"] = true;
+
+  if (hasSMemRealTime)
+Features["s-memrealtime"] = true;
+

arsenm wrote:
> echristo wrote:
> > This is typically more of the "move the cpu checks down here" area from 
> > what you'd have above. Also you're not calling the target independent 
> > version of initFeatureMap - is that done on purpose?
> Not sure what you mean exactly by "move the cpu checks down here". Do you 
> mean setting all of the feature has* member variables should be moved out of 
> the AMDGPUTargetInfo constructor + setCPU into here?
> 
> That was not done on purpose. I'm pretty confused about what all of these 
> functions are for. I kind of expected all of this to automatically work from 
> the target's set of defined features known from the backend. There seem to be 
> a set of functions for manually parsing user specified features on a function 
> and for those implied by the subtarget. Why is initFeatureMap separate from 
> handleTargetFeatures? initFeatureMap seems to be almost the same thing with 
> the addition of the CPU features. It's not clear to me what the difference 
> between hasFeature and validateCpuSupports is supposed to mean, or why 
> setFeatureEnabled is virtual.
> 
Attempting to answer your questions, I'm mostly going phrase by phrase :)

a) Yes, I mean this.
b) None of this code is connected to the backend at all. There's some 
disagreement as to what level the front end should connect to the backend in 
this way. It's probably better left for another day.
c) Yes, these functions are all part of handling features that can be set on a 
function, or are the defaults coming in via the driver.
d) They're separate, sadly, because I couldn't get them together in the time I 
spent rewriting it. Take a look at the comment at Targets.cpp:8086 for a bit 
more detail.
e) validateCpuSupports is only used in one case right now and that's for a 
particular builtin that's only supported on one target. Go ahead and ignore 
that for your purposes now, if you later want to support it we can talk about 
it. 
f) I'm not sure why you care whether or not setFeatureEnabled is virtual, but 
we can discuss it if you'd like - and why you think it shouldn't be :)

Most of these functions have few (or one) use and it is in Targets.cpp. (Don't 
worry about the ones outside of Targets.cpp for now, that's part of the 
function attribute code which was the cause of the cleanup (I promise it was) 
and refactoring I did, but doesn't affect clang initialization.


http://reviews.llvm.org/D17516



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


[PATCH] D17983: Eliminate many benign instances of "potentially uninitialized local variable" warnings

2016-03-08 Thread Alexander Riccio via cfe-commits
ariccio created this revision.
ariccio added subscribers: llvm-commits, cfe-commits.
Herald added a reviewer: tstellarAMD.
Herald added subscribers: joker.eph, dsanders, arsenm, MatzeB.

Currently, the "potentially uninitialized local variable" & "potentially 
uninitialized local pointer variable" warnings are turned off. At some point we 
should probably turn them back on, because they can find serious problems. This 
patch eliminates the most obviously benign offenders. 


This leaves about ~33 not-so-obviously benign offenders. which I'll include 
here for convenience:



|Severity| Code | Description | Project | File | Line | Category | Source | 
Suppression |
    -    -    -     
-- -
|Warning|   C4703| potentially uninitialized local pointer variable 
'ExprOffset' used | LLVMMipsAsmParser | 
c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |
|Warning|   C4701| potentially uninitialized local variable 'Encoding' used 
| clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgdebuginfo.cpp | 573 |
|Warning|   C4701| potentially uninitialized local variable 'result' used | 
clangCodeGen | c:\llvm\llvm\tools\clang\lib\codegen\cgobjc.cpp | 2675 |
|Warning|   C4701| potentially uninitialized local variable 'Nullability' 
used | clangParse | c:\llvm\llvm\tools\clang\lib\parse\parseobjc.cpp | 1202 |
|Warning|   C4701| potentially uninitialized local variable 
'RepresentationMethod' used | clangParse | 
c:\llvm\llvm\tools\clang\lib\parse\parsepragma.cpp | 1582 |
|Warning|   C4701| potentially uninitialized local variable 'FirstOpKind' 
used | clangSema | c:\llvm\llvm\tools\clang\lib\sema\sematemplate.cpp | 4464 |
|Warning|   C4701| potentially uninitialized local variable 
'FnEntry8BitAbbrev' used | LLVMBitWriter | 
c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2353 |
|Warning|   C4701| potentially uninitialized local variable 
'FnEntry7BitAbbrev' used | LLVMBitWriter | 
c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2357 |
|Warning|   C4701| potentially uninitialized local variable 
'FnEntry6BitAbbrev' used | LLVMBitWriter | 
c:\llvm\llvm\lib\bitcode\writer\bitcodewriter.cpp | 2355 |
|Warning|   C4701| potentially uninitialized local variable 'OutIt' used | 
LLVMCodeGen | c:\llvm\llvm\lib\codegen\liveinterval.cpp | 876 |
|Warning|   C4701| potentially uninitialized local variable 'mid' used | 
LLVMHexagonCodeGen | c:\llvm\build\lib\target\hexagon\hexagongeninstrinfo.inc | 
9722 |
|Warning|   C4701| potentially uninitialized local variable 
'RealEightBitCounterArray' used | LLVMInstrumentation | 
c:\llvm\llvm\lib\transforms\instrumentation\sanitizercoverage.cpp | 294 |
|Warning|   C4701| potentially uninitialized local variable 'LoOffset' used 
| LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp 
| 2668 |
|Warning|   C4701| potentially uninitialized local variable 'HiOffset' used 
| LLVMMipsAsmParser | c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp 
| 2659 |
|Warning|   C4701| potentially uninitialized local variable 'ExprOffset' 
used | LLVMMipsAsmParser | 
c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 2668 |
|Warning|   C4701| potentially uninitialized local variable 
'BranchTargetNoTraps' used | LLVMMipsAsmParser | 
c:\llvm\llvm\lib\target\mips\asmparser\mipsasmparser.cpp | 3072 |
Warning|C4701| potentially uninitialized local variable 'MatImm' used | 
LLVMPowerPCCodeGen | c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 808 |
|Warning|   C4701| potentially uninitialized local variable 'MaskEnd' used 
| LLVMPowerPCCodeGen | c:\llvm\llvm\lib\target\powerpc\ppciseldagtodag.cpp | 
809 |
|Warning|   C4701| potentially uninitialized local variable 'FirstLP' used 
| LLVMScalarOpts | c:\llvm\llvm\lib\transforms\scalar\loadcombine.cpp | 198 |
|Warning|   C4701| potentially uninitialized local variable 'CC' used | 
LLVMSelectionDAG | c:\llvm\llvm\lib\codegen\selectiondag\dagcombiner.cpp | 
13889 |
|Warning|   C4701| potentially uninitialized local variable 'Operation' 
used | llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 287 |
|Warning|   C4701| potentially uninitialized local variable 'Kind' used | 
llvm-ar | c:\llvm\llvm\tools\llvm-ar\llvm-ar.cpp | 602 |
|Warning|   C4701| potentially uninitialized local variable 'CurSegAddress' 
used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 8548 |
|Warning|   C4701| potentially uninitialized local variable 'objc_class' 
used | llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 5435 |
|Warning|   C4701| potentially uninitialized local variable 'r_type' used | 
llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1781 |
|Warning|   C4701| potentially uninitialized local variable 'r_value' used 
| llvm-objdump | c:\llvm\llvm\tools\llvm-objdump\machodump.cpp | 1783 |

Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-03-08 Thread Eric Christopher via cfe-commits
On Sat, Mar 5, 2016 at 6:16 AM Daniel Sanders 
wrote:

> dsanders added a comment.
>
> In http://reviews.llvm.org/D16139#368217, @echristo wrote:
>
> > This seems wrong. You should fix setCPU instead or set a default CPU.
>
>
> We already set a default CPU in the constructor (e.g.
> Mips32TargetInfoBase::Mips32TargetInfoBase() provides "mips32r2"). It's the
> CPU argument to initFeatureMap() that's the root problem. In several
> targets, this argument has the same name as a member variable and is not
> subject to anything the constructor or setCPU() does to that member
> variable.
>
>
To be clear, no, this is not the problem.


> I suspect the right thing to do is to drop the CPU argument and use the
> member variable instead but there may be differences in value/usage that
> make this difficult. For now, this patch serves as a stop-gap measure that
> resolves the empty string to a real CPU name.
>
>
This is also not the problem. There are a few problems here:

z) This code is terrible, I did my best to clean it up recently, but it's a
lot of code and a bit painful.
a) There should be a testcase, everything can be done by the driver here as
the code is pretty specialized for that use case.
b) CPUs are not subtarget features (or they shouldn't be), they're CPUs
that contain features. They may be generic names for ISAs as well, but
probably best to keep them separate.
c) You should set the features based on the CPUs given to the function. The
typical way the cpu comes in, is via -target-cpu which comes via:

  case llvm::Triple::mips:
  case llvm::Triple::mipsel:
  case llvm::Triple::mips64:
  case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
mips::getMipsCPUAndABI(Args, T, CPUName, ABIName);
return CPUName;
  }

for mips.

Now if your triple is returning an empty string here you might have gotten
to where you are (I tried mips64r2-linux-gnu as the -target option). Which
is what typically happens down this path.

As I said, I agree the code along this path is terrible, but I don't think
this change is correct - and it should have had a testcase anyhow :)

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


Re: [PATCH] D16797: Update clang support on recent Haiku

2016-03-08 Thread Jérôme Duval via cfe-commits
korli added a comment.

Ping?


Repository:
  rL LLVM

http://reviews.llvm.org/D16797



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


Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-08 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:69
@@ +68,3 @@
+  /// evaluates to false.
+  void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective ,
+StringRef ParentName,

Missed 'virtual'


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:27
@@ +26,3 @@
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
+  {}, "nvptx_warp_size");
+}

Use 'llvm::None' instead of '{}'


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:36
@@ +35,3 @@
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
+  {}, "nvptx_tid");
+}

Use 'llvm::None' instead of '{}'


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:45
@@ +44,3 @@
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
+  {}, "nvptx_num_threads");
+}

Use 'llvm::None' instead of '{}'


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:53
@@ +52,3 @@
+ (), llvm::Intrinsic::nvvm_barrier0),
+ {});
+}

Remove '{}', not required


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:90
@@ +89,3 @@
+};
+} // anonymous namespace
+

Just 'namespace', remove 'anonymous'


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:104
@@ +103,3 @@
+  FunctionType::ExtInfo EI;
+  CGFI = ().arrangeFreeFunctionDeclaration(Ctx.VoidTy, {}, EI,
+/*isVariadic=*/false);

Use '.arrangeNullaryFunction()' instead


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:235
@@ +234,3 @@
+  CGF.EmitBlock(WorkerBB);
+  CGF.EmitCallOrInvoke(WST.WorkerFn, {});
+  CGF.EmitBranch(EST.ExitBB);

Use 'llvm::None' as the second arg


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.h:26
@@ -22,2 +25,3 @@
 
 class CGOpenMPRuntimeNVPTX : public CGOpenMPRuntime {
+  //

All functions must start with a lower case letter


http://reviews.llvm.org/D17877



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


Re: [PATCH] D17979: [OPENMP] Add regression test for codegen of distribute pragma for NVPTX

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

LG


Repository:
  rL LLVM

http://reviews.llvm.org/D17979



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


Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-03-08 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/D17547



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


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-08 Thread whitequark via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262996: Accept absolute paths in the -fuse-ld option. 
(authored by whitequark).

Repository:
  rL LLVM

http://reviews.llvm.org/D17952

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/fuse-ld.c

Index: cfe/trunk/test/Driver/fuse-ld.c
===
--- cfe/trunk/test/Driver/fuse-ld.c
+++ cfe/trunk/test/Driver/fuse-ld.c
@@ -1,4 +1,10 @@
 // RUN: %clang %s -### \
+// RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
+
+
+// RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
 // CHECK-FREEBSD-LD: ld
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
+StringRef UseLinker = A->getValue();
 
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 return "";


Index: cfe/trunk/test/Driver/fuse-ld.c
===
--- cfe/trunk/test/Driver/fuse-ld.c
+++ cfe/trunk/test/Driver/fuse-ld.c
@@ -1,4 +1,10 @@
 // RUN: %clang %s -### \
+// RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
+
+
+// RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
 // CHECK-FREEBSD-LD: ld
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
+StringRef UseLinker = A->getValue();
 
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
 return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262996 - Accept absolute paths in the -fuse-ld option.

2016-03-08 Thread Peter Zotov via cfe-commits
Author: whitequark
Date: Tue Mar  8 23:18:16 2016
New Revision: 262996

URL: http://llvm.org/viewvc/llvm-project?rev=262996=rev
Log:
Accept absolute paths in the -fuse-ld option.

This patch extends the -fuse-ld option to accept a full path to an executable
and use it verbatim to invoke the linker. There are generally two reasons
to desire this.

The first reason relates to the sad truth is that Clang is retargetable,
Binutils are not.

While any Clang from a binary distribution is sufficient to compile code
for a wide range of architectures and prefixed BFD linkers (e.g.
installed as /usr/bin/arm-none-linux-gnueabi-ld) as well as cross-compiled
libc's (for non-bare-metal targets) are widely available, including on all
Debian derivatives, it is impossible to use them together because
the -fuse-ld= option allows to specify neither a linker prefix nor
a full path to one.

The second reason is linker development, both when porting existing linkers
to new architectures and when working on a new linker such as LLD.

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/fuse-ld.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=262996=262995=262996=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Mar  8 23:18:16 2016
@@ -342,19 +342,26 @@ std::string ToolChain::GetProgramPath(co
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
+StringRef UseLinker = A->getValue();
 
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
 
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
 
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 return "";

Modified: cfe/trunk/test/Driver/fuse-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuse-ld.c?rev=262996=262995=262996=diff
==
--- cfe/trunk/test/Driver/fuse-ld.c (original)
+++ cfe/trunk/test/Driver/fuse-ld.c Tue Mar  8 23:18:16 2016
@@ -1,4 +1,10 @@
 // RUN: %clang %s -### \
+// RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
+
+
+// RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
 // CHECK-FREEBSD-LD: ld


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


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-08 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.

-eric


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



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


[PATCH] D17979: [OPENMP] Add regression test for codegen of distribute pragma for NVPTX

2016-03-08 Thread Carlo Bertolli via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, fraggamuffin, kkwli0.
carlo.bertolli added subscribers: sfantao, arpith-jacob, caomhin, cfe-commits.
carlo.bertolli set the repository for this revision to rL LLVM.

The support for distribute pragma is the same on host and NVPTX. However, the 
generated code looks different from a interface perspective (e.g. parameters to 
offloading function have different type on host and NVPTX). I added a 
regression test that checks for the distinct NVPTX generated code.

Repository:
  rL LLVM

http://reviews.llvm.org/D17979

Files:
  test/OpenMP/nvptx_distribute_codegen.cpp

Index: test/OpenMP/nvptx_distribute_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_distribute_codegen.cpp
@@ -0,0 +1,233 @@
+// Test device codegen.
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RXUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RXUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+void without_schedule_clause(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute
+  for (int i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+// CHECK:  define void @__omp_offloading_{{.+}}without_schedule_clause{{.+}}(float* [[APTR:%.+]], float* [[BPTR:%.+]], float* [[CPTR:%.+]], float* [[DPTR:%.+]])
+// skip address vars allocation
+// CHECK:  {{%.+}} = alloca {{.+}},
+// CHECK:  {{%.+}} = alloca {{.+}},
+// CHECK:  {{%.+}} = alloca {{.+}},
+// CHECK:  {{%.+}} = alloca {{.+}},
+// CHECK:  [[IV:%.+iv]] = alloca i32,
+// CHECK:  [[LB:%.+lb]] = alloca i32,
+// CHECK:  [[UB:%.+ub]] = alloca i32,
+// CHECK:  [[ST:%.+stride]] = alloca i32,
+// CHECK:  [[LAST:%.+last]] = alloca i32,
+// CHECK:  [[I:%.+]] = alloca i32,
+// CHECK:  [[GBL_TIDV:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* [[DEF_LOC_0]])
+// CHECK-DAG:  store i32 0, i32* [[LB]]
+// CHECK-DAG:  store i32 4571423, i32* [[UB]]
+// CHECK-DAG:  store i32 1, i32* [[ST]]
+// CHECK-DAG:  store i32 0, i32* [[LAST]]
+// CHECK:  call void @__kmpc_for_static_init_{{.+}}(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TIDV]], i32 92, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 1)
+// CHECK-DAG:  [[UBV0:%.+]] = load i32, i32* [[UB]]
+// CHECK-DAG:  [[USWITCH:%.+]] = icmp sgt i32 [[UBV0]], 4571423
+// CHECK:  br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
+// CHECK-DAG:  [[BBCT]]:
+// CHECK-DAG:  br label %[[BBCE:.+]]
+// CHECK-DAG:  [[BBCF]]:
+// CHECK-DAG:  [[UBV1:%.+]] = load i32, i32* [[UB]]
+// CHECK-DAG:  br label %[[BBCE]]
+// CHECK:  [[BBCE]]:
+// CHECK:  [[SELUB:%.+]] = phi i32 [ 4571423, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
+// CHECK:  store i32 [[SELUB]], i32* [[UB]]
+// CHECK:  [[LBV0:%.+]] = load i32, i32* [[LB]]
+// CHECK:  store i32 [[LBV0]], i32* [[IV]]
+// CHECK:  br label %[[BBINNFOR:.+]]
+// CHECK:  [[BBINNFOR]]:
+// CHECK:  [[IVVAL0:%.+]] = load i32, i32* [[IV]]
+// CHECK:  [[UBV2:%.+]] = load i32, i32* [[UB]]
+// CHECK:  [[IVLEUB:%.+]] = icmp sle i32 [[IVVAL0]], [[UBV2]]
+// CHECK:  br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
+// CHECK:  [[BBINNBODY]]:
+// CHECK:  {{.+}} = load i32, i32* [[IV]]
+// ... loop body ...
+// CHECK:  br label %[[BBBODYCONT:.+]]
+// CHECK:  [[BBBODYCONT]]:
+// CHECK:  br label %[[BBINNINC:.+]]
+// CHECK:  [[BBINNINC]]:
+// CHECK:  [[IVVAL1:%.+]] = load i32, i32* [[IV]]
+// CHECK:  [[IVINC:%.+]] = add nsw i32 [[IVVAL1]], 1
+// CHECK:  store i32 [[IVINC]], i32* [[IV]]
+// CHECK:  br label %[[BBINNFOR]]
+// CHECK:  [[BBINNEND]]:
+// CHECK:  br label %[[LPEXIT:.+]]
+// CHECK:  [[LPEXIT]]:
+// CHECK:  call void @__kmpc_for_static_fini(%ident_t* [[DEF_LOC_0]], i32 [[GBL_TIDV]])
+// CHECK:  ret void
+
+
+void static_not_chunked(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute dist_schedule(static)
+  for (int 

Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-08 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping.


http://reviews.llvm.org/D17815



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


r262991 - [index] Add a message for the assertion, NFC.

2016-03-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Mar  8 20:53:12 2016
New Revision: 262991

URL: http://llvm.org/viewvc/llvm-project?rev=262991=rev
Log:
[index] Add a message for the assertion, NFC.

Modified:
cfe/trunk/lib/Index/IndexingContext.cpp

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=262991=262990=262991=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Tue Mar  8 20:53:12 2016
@@ -299,7 +299,8 @@ bool IndexingContext::handleDeclOccurren
 Parent = getCanonicalDecl(Parent);
   assert(!Parent || !Parent->isImplicit() ||
  isa(Parent) ||
- isa(Parent) || isa(Parent));
+ isa(Parent) || isa(Parent) &&
+ "unexpected implicit parent!");
 
   SmallVector FinalRelations;
   FinalRelations.reserve(Relations.size()+1);


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


Re: r262984 - [index] Fix assertion hit when indexing re-declarations of built-in functions.

2016-03-08 Thread Ben Langmuir via cfe-commits

> On Mar 8, 2016, at 6:12 PM, Argyrios Kyrtzidis via cfe-commits 
>  wrote:
> 
> Author: akirtzidis
> Date: Tue Mar  8 20:12:40 2016
> New Revision: 262984
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262984=rev
> Log:
> [index] Fix assertion hit when indexing re-declarations of built-in functions.
> 
> Modified:
>cfe/trunk/lib/Index/IndexingContext.cpp
>cfe/trunk/test/Index/Core/index-source.m
> 
> Modified: cfe/trunk/lib/Index/IndexingContext.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=262984=262983=262984=diff
> ==
> --- cfe/trunk/lib/Index/IndexingContext.cpp (original)
> +++ cfe/trunk/lib/Index/IndexingContext.cpp Tue Mar  8 20:12:40 2016
> @@ -298,6 +298,7 @@ bool IndexingContext::handleDeclOccurren
>   if (Parent)
> Parent = getCanonicalDecl(Parent);
>   assert(!Parent || !Parent->isImplicit() ||
> + isa(Parent) ||

What is this assertion trying to cover?  Can we add a message or comment?

>  isa(Parent) || isa(Parent));
> 
>   SmallVector FinalRelations;
> 
> Modified: cfe/trunk/test/Index/Core/index-source.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=262984=262983=262984=diff
> ==
> --- cfe/trunk/test/Index/Core/index-source.m (original)
> +++ cfe/trunk/test/Index/Core/index-source.m Tue Mar  8 20:12:40 2016
> @@ -65,3 +65,8 @@ enum {
>   // CHECK-NEXT: RelChild |  | c:@Ea@One
>   Two,
> };
> +
> +// CHECK: [[@LINE+1]]:13 | typedef/C | jmp_buf | c:index-source.m@T@jmp_buf 
> |  | Def | rel: 0
> +typedef int jmp_buf[(18)];
> +// CHECK: [[@LINE+1]]:19 | typedef/C | jmp_buf | c:index-source.m@T@jmp_buf 
> |  | Ref | rel: 0
> +extern int setjmp(jmp_buf);
> 
> 
> ___
> 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


r262984 - [index] Fix assertion hit when indexing re-declarations of built-in functions.

2016-03-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Mar  8 20:12:40 2016
New Revision: 262984

URL: http://llvm.org/viewvc/llvm-project?rev=262984=rev
Log:
[index] Fix assertion hit when indexing re-declarations of built-in functions.

Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=262984=262983=262984=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Tue Mar  8 20:12:40 2016
@@ -298,6 +298,7 @@ bool IndexingContext::handleDeclOccurren
   if (Parent)
 Parent = getCanonicalDecl(Parent);
   assert(!Parent || !Parent->isImplicit() ||
+ isa(Parent) ||
  isa(Parent) || isa(Parent));
 
   SmallVector FinalRelations;

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=262984=262983=262984=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Tue Mar  8 20:12:40 2016
@@ -65,3 +65,8 @@ enum {
   // CHECK-NEXT: RelChild |  | c:@Ea@One
   Two,
 };
+
+// CHECK: [[@LINE+1]]:13 | typedef/C | jmp_buf | c:index-source.m@T@jmp_buf | 
 | Def | rel: 0
+typedef int jmp_buf[(18)];
+// CHECK: [[@LINE+1]]:19 | typedef/C | jmp_buf | c:index-source.m@T@jmp_buf | 
 | Ref | rel: 0
+extern int setjmp(jmp_buf);


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


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-08 Thread whitequark via cfe-commits
whitequark updated this revision to Diff 50097.
whitequark added a comment.

Added a test


Repository:
  rL LLVM

http://reviews.llvm.org/D17952

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/fuse-ld.c

Index: cfe/trunk/test/Driver/fuse-ld.c
===
--- cfe/trunk/test/Driver/fuse-ld.c
+++ cfe/trunk/test/Driver/fuse-ld.c
@@ -1,4 +1,10 @@
 // RUN: %clang %s -### \
+// RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
+
+
+// RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
 // CHECK-FREEBSD-LD: ld
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 return "";


Index: cfe/trunk/test/Driver/fuse-ld.c
===
--- cfe/trunk/test/Driver/fuse-ld.c
+++ cfe/trunk/test/Driver/fuse-ld.c
@@ -1,4 +1,10 @@
 // RUN: %clang %s -### \
+// RUN: -fuse-ld=/usr/local/bin/or1k-linux-ld 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
+// CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
+
+
+// RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
 // CHECK-FREEBSD-LD: ld
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
 return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17976: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-08 Thread Roman Levenstein via cfe-commits
Forgot to add the mailing list when I created a patch.Begin forwarded message:From: Roman Levenstein Subject: [PATCH] D17976: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-endDate: March 8, 2016 at 5:17:02 PM PSTTo: rlevenst...@apple.com, juer...@apple.comCc: amara.emer...@arm.comReply-To: reviews+d17976+public+93264263cdbda...@reviews.llvm.orgswiftix created this revision.swiftix added a reviewer: ributzka.Herald added a subscriber: aemerson.Till now, preserve_mostcc/preserve_allcc calling convention attributes were only available at the LLVM IR level. This patch adds attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.The code was mostly written by Juergen Ributzka. I just added support for the AArch64 target.http://reviews.llvm.org/D17976Files:  include/clang-c/Index.h  include/clang/AST/Type.h  include/clang/Basic/Attr.td  include/clang/Basic/Specifiers.h  lib/AST/ItaniumMangle.cpp  lib/AST/Type.cpp  lib/AST/TypePrinter.cpp  lib/Basic/Targets.cpp  lib/CodeGen/CGCall.cpp  lib/Sema/SemaDeclAttr.cpp  lib/Sema/SemaType.cpp  test/CodeGen/preserve_all.c  test/CodeGen/preserve_most.c  tools/libclang/CXType.cppIndex: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -534,6 +534,8 @@
   TCALLINGCONV(AAPCS_VFP);
   TCALLINGCONV(IntelOclBicc);
   TCALLINGCONV(Swift);
+  TCALLINGCONV(PreserveMost);
+  TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_SpirKernel: return CXCallingConv_Unexposed;
   break;
Index: test/CodeGen/preserve_most.c
===
--- test/CodeGen/preserve_most.c
+++ test/CodeGen/preserve_most.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s | FileCheck %s
+
+// Check that the preserve_most calling convention attribute at the source level
+// is lowered to the corresponding calling convention attrribute at the LLVM IR
+// level.
+void foo() __attribute__((preserve_most)) {
+  // CHECK-LABEL: define preserve_mostcc void @foo()
+}
+
Index: test/CodeGen/preserve_all.c
===
--- test/CodeGen/preserve_all.c
+++ test/CodeGen/preserve_all.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s | FileCheck %s
+
+// Check that the preserve_most calling convention attribute at the source level
+// is lowered to the corresponding calling convention attrribute at the LLVM IR
+// level.
+void foo() __attribute__((preserve_all)) {
+  // CHECK-LABEL: define preserve_allcc void @foo()
+}
+
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -112,7 +112,9 @@
 case AttributeList::AT_MSABI: \
 case AttributeList::AT_SysVABI: \
 case AttributeList::AT_Pcs: \
-case AttributeList::AT_IntelOclBicc
+case AttributeList::AT_IntelOclBicc: \
+case AttributeList::AT_PreserveMost: \
+case AttributeList::AT_PreserveAll
 
 // Function type attributes.
 #define FUNCTION_TYPE_ATTRS_CASELIST \
@@ -4639,6 +4641,10 @@
 return AttributeList::AT_MSABI;
   case AttributedType::attr_sysv_abi:
 return AttributeList::AT_SysVABI;
+  case AttributedType::attr_preserve_most:
+return AttributeList::AT_PreserveMost;
+  case AttributedType::attr_preserve_all:
+return AttributeList::AT_PreserveAll;
   case AttributedType::attr_ptr32:
 return AttributeList::AT_Ptr32;
   case AttributedType::attr_ptr64:
@@ -5974,6 +5980,10 @@
 return AttributedType::attr_ms_abi;
   case AttributeList::AT_SysVABI:
 return AttributedType::attr_sysv_abi;
+  case AttributeList::AT_PreserveMost:
+return AttributedType::attr_preserve_most;
+  case AttributeList::AT_PreserveAll:
+return AttributedType::attr_preserve_all;
   }
   llvm_unreachable("unexpected attribute kind!");
 }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3777,7 +3777,14 @@
IntelOclBiccAttr(Attr.getRange(), S.Context,
 Attr.getAttributeSpellingListIndex()));
 return;
-
+  case AttributeList::AT_PreserveMost:
+D->addAttr(::new (S.Context) PreserveMostAttr(
+Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+return;
+  case AttributeList::AT_PreserveAll:
+D->addAttr(::new (S.Context) PreserveAllAttr(
+Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+return;
   default:
 

r262971 - Readd testcase accidentally removed in r262888.

2016-03-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar  8 18:12:38 2016
New Revision: 262971

URL: http://llvm.org/viewvc/llvm-project?rev=262971=rev
Log:
Readd testcase accidentally removed in r262888.

Modified:
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp?rev=262971=262970=262971=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp Tue Mar  8 
18:12:38 2016
@@ -6,3 +6,5 @@ struct [[nodiscard("Wrong")]] S3 {}; //
 
 [[nodiscard]] int f();
 enum [[nodiscard]] E {};
+
+namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only 
applies to functions, methods, enums, and classes}}


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


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-03-08 Thread Saleem Abdulrasool via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Sorry about the delay with this change.  Thanks for removing the parameter.  I 
think that this is fine as is.  Do you have commit rights, or should I commit 
this on your behalf?


http://reviews.llvm.org/D15469



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


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-08 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Needs a testcase, but otherwise should be fine.


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



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


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-08 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs added a comment.

Testcases?


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



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


r262966 - Fix crash in access check for aggregate initialization of base classes. It's

2016-03-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar  8 17:17:35 2016
New Revision: 262966

URL: http://llvm.org/viewvc/llvm-project?rev=262966=rev
Log:
Fix crash in access check for aggregate initialization of base classes. It's
not obvious how to access-check these, so pick a conservative rule until we get
feedback from CWG.

Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/SemaCXX/aggregate-initialization.cpp

Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=262966=262965=262966=diff
==
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Tue Mar  8 17:17:35 2016
@@ -1670,8 +1670,12 @@ Sema::AccessResult Sema::CheckConstructo
   // Initializing a base sub-object is an instance method call on an
   // object of the derived class.  Otherwise, we have an instance method
   // call on an object of the constructed type.
+  //
+  // FIXME: If we have a parent, we're initializing the base class subobject
+  // in aggregate initialization. It's not clear whether the object class
+  // should be the base class or the derived class in that case.
   CXXRecordDecl *ObjectClass;
-  if (Entity.getKind() == InitializedEntity::EK_Base) {
+  if (Entity.getKind() == InitializedEntity::EK_Base && !Entity.getParent()) {
 ObjectClass = cast(CurContext)->getParent();
   } else {
 ObjectClass = NamingClass;

Modified: cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/aggregate-initialization.cpp?rev=262966=262965=262966=diff
==
--- cfe/trunk/test/SemaCXX/aggregate-initialization.cpp (original)
+++ cfe/trunk/test/SemaCXX/aggregate-initialization.cpp Tue Mar  8 17:17:35 2016
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s 
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s 
 
 // Verify that using an initializer list for a non-aggregate looks for
 // constructors..
@@ -11,7 +13,7 @@ struct NonAggr1 { // expected-note 2 {{c
 };
 
 struct Base { };
-struct NonAggr2 : public Base { // expected-note 3 {{candidate constructor}}
+struct NonAggr2 : public Base { // expected-note 0-3 {{candidate constructor}}
   int m;
 };
 
@@ -25,9 +27,15 @@ struct NonAggr4 { // expected-note 3 {{c
 };
 
 NonAggr1 na1 = { 17 }; // expected-error{{no matching constructor for 
initialization of 'NonAggr1'}}
-NonAggr2 na2 = { 17 }; // expected-error{{no matching constructor for 
initialization of 'NonAggr2'}}
+NonAggr2 na2 = { 17 };
 NonAggr3 na3 = { 17 }; // expected-error{{no matching constructor for 
initialization of 'NonAggr3'}}
 NonAggr4 na4 = { 17 }; // expected-error{{no matching constructor for 
initialization of 'NonAggr4'}}
+#if __cplusplus <= 201402L
+// expected-error@-4{{no matching constructor for initialization of 
'NonAggr2'}}
+#else
+// expected-error@-6{{requires explicit braces}}
+NonAggr2 na2b = { {}, 17 }; // ok
+#endif
 
 // PR5817
 typedef int type[][2];
@@ -82,3 +90,59 @@ public:
 };
 
 AggAgg aggagg = { 1, 2, 3, 4 };
+
+namespace diff_cpp14_dcl_init_aggr_example {
+  struct derived;
+  struct base {
+friend struct derived;
+  private:
+base();
+  };
+  struct derived : base {};
+
+  derived d1{};
+#if __cplusplus > 201402L
+  // expected-error@-2 {{private}}
+  // expected-note@-7 {{here}}
+#endif
+  derived d2;
+}
+
+namespace ProtectedBaseCtor {
+  // FIXME: It's unclear whether f() and g() should be valid in C++1z. What is
+  // the object expression in a constructor call -- the base class subobject or
+  // the complete object?
+  struct A {
+  protected:
+A();
+  };
+
+  struct B : public A {
+friend B f();
+friend B g();
+friend B h();
+  };
+
+  B f() { return {}; }
+#if __cplusplus > 201402L
+  // expected-error@-2 {{protected default constructor}}
+  // expected-note@-12 {{here}}
+#endif
+
+  B g() { return {{}}; }
+#if __cplusplus <= 201402L
+  // expected-error@-2 {{no matching constructor}}
+  // expected-note@-15 3{{candidate}}
+#else
+  // expected-error@-5 {{protected default constructor}}
+  // expected-note@-21 {{here}}
+#endif
+
+  B h() { return {A{}}; }
+#if __cplusplus <= 201402L
+  // expected-error@-2 {{no matching constructor}}
+  // expected-note@-24 3{{candidate}}
+#endif
+  // expected-error@-5 {{protected constructor}}
+  // expected-note@-30 {{here}}
+}


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


r262965 - Fix -Werror build.

2016-03-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar  8 17:16:16 2016
New Revision: 262965

URL: http://llvm.org/viewvc/llvm-project?rev=262965=rev
Log:
Fix -Werror build.

Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=262965=262964=262965=diff
==
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue Mar  8 17:16:16 2016
@@ -1344,7 +1344,7 @@ static CharUnits GetNumNonZeroBytesInIni
   
   unsigned ILEElement = 0;
   if (auto *CXXRD = dyn_cast(SD))
-for (auto  : CXXRD->bases())
+while (ILEElement != CXXRD->getNumBases())
   NumNonZeroBytes +=
   GetNumNonZeroBytesInInit(ILE->getInit(ILEElement++), CGF);
   for (const auto *Field : SD->fields()) {


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


r262964 - AArch64: remove tests of intrinsics completely duplicated elsewhere.

2016-03-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Mar  8 17:10:58 2016
New Revision: 262964

URL: http://llvm.org/viewvc/llvm-project?rev=262964=rev
Log:
AArch64: remove tests of intrinsics completely duplicated elsewhere.

Removed:
cfe/trunk/test/CodeGen/arm64_neon_high_half.c
cfe/trunk/test/CodeGen/arm64_vCMP.c
cfe/trunk/test/CodeGen/arm64_vLdStNum_lane.c
cfe/trunk/test/CodeGen/arm64_vMaxMin.c
cfe/trunk/test/CodeGen/arm64_vadd.c
cfe/trunk/test/CodeGen/arm64_vca.c
cfe/trunk/test/CodeGen/arm64_vcvtfp.c
cfe/trunk/test/CodeGen/arm64_vecCmpBr.c
cfe/trunk/test/CodeGen/arm64_vext.c
cfe/trunk/test/CodeGen/arm64_vfma.c
cfe/trunk/test/CodeGen/arm64_vneg.c
cfe/trunk/test/CodeGen/arm64_vqmov.c
cfe/trunk/test/CodeGen/arm64_vrecps.c
cfe/trunk/test/CodeGen/arm64_vshift.c
cfe/trunk/test/CodeGen/arm64_vsli.c
cfe/trunk/test/CodeGen/arm64_vsri.c
cfe/trunk/test/CodeGen/arm64_vtst.c

Removed: cfe/trunk/test/CodeGen/arm64_neon_high_half.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64_neon_high_half.c?rev=262963=auto
==
--- cfe/trunk/test/CodeGen/arm64_neon_high_half.c (original)
+++ cfe/trunk/test/CodeGen/arm64_neon_high_half.c (removed)
@@ -1,559 +0,0 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-feature +neon 
-ffreestanding -Os -S -o - %s | FileCheck %s
-// REQUIRES: aarch64-registered-target
-
-#include 
-
-int16x8_t test_vaddw_high_s8(int16x8_t lhs, int8x16_t rhs) {
-  // CHECK: saddw2.8h
-  return vaddw_high_s8(lhs, rhs);
-}
-
-int32x4_t test_vaddw_high_s16(int32x4_t lhs, int16x8_t rhs) {
-  // CHECK: saddw2.4s
-  return vaddw_high_s16(lhs, rhs);
-}
-
-int64x2_t test_vaddw_high_s32(int64x2_t lhs, int32x4_t rhs) {
-  // CHECK: saddw2.2d
-  return vaddw_high_s32(lhs, rhs);
-}
-
-uint16x8_t test_vaddw_high_u8(uint16x8_t lhs, uint8x16_t rhs) {
-  // CHECK: uaddw2.8h
-  return vaddw_high_u8(lhs, rhs);
-}
-
-uint32x4_t test_vaddw_high_u16(uint32x4_t lhs, uint16x8_t rhs) {
-  // CHECK: uaddw2.4s
-  return vaddw_high_u16(lhs, rhs);
-}
-
-uint64x2_t test_vaddw_high_u32(uint64x2_t lhs, uint32x4_t rhs) {
-  // CHECK: uaddw2.2d
-  return vaddw_high_u32(lhs, rhs);
-}
-
-int16x8_t test_vsubw_high_s8(int16x8_t lhs, int8x16_t rhs) {
-  // CHECK: ssubw2.8h
-  return vsubw_high_s8(lhs, rhs);
-}
-
-int32x4_t test_vsubw_high_s16(int32x4_t lhs, int16x8_t rhs) {
-  // CHECK: ssubw2.4s
-  return vsubw_high_s16(lhs, rhs);
-}
-
-int64x2_t test_vsubw_high_s32(int64x2_t lhs, int32x4_t rhs) {
-  // CHECK: ssubw2.2d
-  return vsubw_high_s32(lhs, rhs);
-}
-
-uint16x8_t test_vsubw_high_u8(uint16x8_t lhs, uint8x16_t rhs) {
-  // CHECK: usubw2.8h
-  return vsubw_high_u8(lhs, rhs);
-}
-
-uint32x4_t test_vsubw_high_u16(uint32x4_t lhs, uint16x8_t rhs) {
-  // CHECK: usubw2.4s
-  return vsubw_high_u16(lhs, rhs);
-}
-
-uint64x2_t test_vsubw_high_u32(uint64x2_t lhs, uint32x4_t rhs) {
-  // CHECK: usubw2.2d
-  return vsubw_high_u32(lhs, rhs);
-}
-
-int16x8_t test_vabdl_high_s8(int8x16_t lhs, int8x16_t rhs) {
-  // CHECK: sabdl2.8h
-  return vabdl_high_s8(lhs, rhs);
-}
-
-int32x4_t test_vabdl_high_s16(int16x8_t lhs, int16x8_t rhs) {
-  // CHECK: sabdl2.4s
-  return vabdl_high_s16(lhs, rhs);
-}
-
-int64x2_t test_vabdl_high_s32(int32x4_t lhs, int32x4_t rhs) {
-  // CHECK: sabdl2.2d
-  return vabdl_high_s32(lhs, rhs);
-}
-
-uint16x8_t test_vabdl_high_u8(uint8x16_t lhs, uint8x16_t rhs) {
-  // CHECK: uabdl2.8h
-  return vabdl_high_u8(lhs, rhs);
-}
-
-uint32x4_t test_vabdl_high_u16(uint16x8_t lhs, uint16x8_t rhs) {
-  // CHECK: uabdl2.4s
-  return vabdl_high_u16(lhs, rhs);
-}
-
-uint64x2_t test_vabdl_high_u32(uint32x4_t lhs, uint32x4_t rhs) {
-  // CHECK: uabdl2.2d
-  return vabdl_high_u32(lhs, rhs);
-}
-
-int16x8_t test_vabal_high_s8(int16x8_t accum, int8x16_t lhs, int8x16_t rhs) {
-  // CHECK: sabal2.8h
-  return vabal_high_s8(accum, lhs, rhs);
-}
-
-int32x4_t test_vabal_high_s16(int32x4_t accum, int16x8_t lhs, int16x8_t rhs) {
-  // CHECK: sabal2.4s
-  return vabal_high_s16(accum, lhs, rhs);
-}
-
-int64x2_t test_vabal_high_s32(int64x2_t accum, int32x4_t lhs, int32x4_t rhs) {
-  // CHECK: sabal2.2d
-  return vabal_high_s32(accum, lhs, rhs);
-}
-
-uint16x8_t test_vabal_high_u8(uint16x8_t accum, uint8x16_t lhs, uint8x16_t 
rhs) {
-  // CHECK: uabal2.8h
-  return vabal_high_u8(accum, lhs, rhs);
-}
-
-uint32x4_t test_vabal_high_u16(uint32x4_t accum, uint16x8_t lhs, uint16x8_t 
rhs) {
-  // CHECK: uabal2.4s
-  return vabal_high_u16(accum, lhs, rhs);
-}
-
-uint64x2_t test_vabal_high_u32(uint64x2_t accum, uint32x4_t lhs, uint32x4_t 
rhs) {
-  // CHECK: uabal2.2d
-  return vabal_high_u32(accum, lhs, rhs);
-}
-
-int32x4_t test_vqdmlal_high_s16(int32x4_t accum, int16x8_t lhs, int16x8_t rhs) 
{
-  // CHECK: sqdmlal2.4s
-  return vqdmlal_high_s16(accum, lhs, rhs);
-}
-
-int64x2_t test_vqdmlal_high_s32(int64x2_t accum, int32x4_t lhs, int32x4_t rhs) 
{
-  // CHECK: sqdmlal2.2d
-  return vqdmlal_high_s32(accum, lhs, 

Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-08 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.

Attribute side of things LGTM, but I don't have the expertise to comment on the 
OpenCL functionality itself.


http://reviews.llvm.org/D17764



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


r262963 - P0017R1: In C++1z, an aggregate class can have (public non-virtual) base classes; these are initialized as if they were data members.

2016-03-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar  8 16:17:41 2016
New Revision: 262963

URL: http://llvm.org/viewvc/llvm-project?rev=262963=rev
Log:
P0017R1: In C++1z, an aggregate class can have (public non-virtual) base 
classes; these are initialized as if they were data members.

Added:
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp
  - copied, changed from r262877, 
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp
Removed:
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
Modified:
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=262963=262962=262963=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Tue Mar  8 16:17:41 2016
@@ -284,9 +284,10 @@ public:
 
 
   /// \brief Create the initialization entity for a base class subobject.
-  static InitializedEntity InitializeBase(ASTContext ,
-  const CXXBaseSpecifier *Base,
-  bool IsInheritedVirtualBase);
+  static InitializedEntity
+  InitializeBase(ASTContext , const CXXBaseSpecifier *Base,
+ bool IsInheritedVirtualBase,
+ const InitializedEntity *Parent = nullptr);
 
   /// \brief Create the initialization entity for a delegated constructor.
   static InitializedEntity InitializeDelegation(QualType Type) {

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=262963=262962=262963=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Mar  8 16:17:41 2016
@@ -141,9 +141,11 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
 C.Deallocate(data().getBases());
 
   if (NumBases) {
-// C++ [dcl.init.aggr]p1:
-//   An aggregate is [...] a class with [...] no base classes [...].
-data().Aggregate = false;
+if (!C.getLangOpts().CPlusPlus1z) {
+  // C++ [dcl.init.aggr]p1:
+  //   An aggregate is [...] a class with [...] no base classes [...].
+  data().Aggregate = false;
+}
 
 // C++ [class]p4:
 //   A POD-struct is an aggregate class...
@@ -188,6 +190,11 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
   data().HasNoNonEmptyBases = false;
 }
 
+// C++1z [dcl.init.agg]p1:
+//   An aggregate is a class with [...] no private or protected base 
classes
+if (Base->getAccessSpecifier() != AS_public)
+  data().Aggregate = false;
+
 // C++ [class.virtual]p1:
 //   A class that declares or inherits a virtual function is called a 
 //   polymorphic class.
@@ -218,6 +225,10 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
 if (CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl())
   if (!VBaseDecl->hasCopyConstructorWithConstParam())
 data().ImplicitCopyConstructorHasConstParam = false;
+
+// C++1z [dcl.init.agg]p1:
+//   An aggregate is a class with [...] no virtual base classes
+data().Aggregate = false;
   }
 }
 
@@ -226,11 +237,15 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
   if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
 VBases.push_back(Base);
 
-  // C++0x [meta.unary.prop] is_empty:
+  // C++11 [meta.unary.prop] is_empty:
   //T is a class type, but not a union type, with ... no virtual base
   //classes
   data().Empty = false;
 
+  // C++1z [dcl.init.agg]p1:
+  //   An aggregate is a class with [...] no virtual base classes
+  data().Aggregate = false;
+
   // C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25:
   //   A [default constructor, copy/move constructor, or copy/move 
assignment
   //   operator for a class X] is trivial [...] if:
@@ -732,7 +747,7 @@ void CXXRecordDecl::addedMember(Decl *D)
   //   An aggregate is a [...] class with [...] no
   //   brace-or-equal-initializers for non-static data members.
   //
-  // This rule was removed in C++1y.
+  // This rule was removed in C++14.
   if (!getASTContext().getLangOpts().CPlusPlus14)
 data().Aggregate = false;
 

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 

Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-08 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD marked an inline comment as done.
kzhuravl-AMD added a comment.

http://reviews.llvm.org/D17764



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


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-08 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD updated this revision to Diff 50067.
kzhuravl-AMD added a comment.

Aaron's Review Comments


http://reviews.llvm.org/D17764

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/amdgpu-tools-attrs-opts-precedence.cl
  test/CodeGenOpenCL/amdgpu-tools-attrs.cl
  test/CodeGenOpenCL/amdgpu-tools-opts.cl
  test/SemaOpenCL/amdgpu-tools-attrs.cl

Index: test/SemaOpenCL/amdgpu-tools-attrs.cl
===
--- /dev/null
+++ test/SemaOpenCL/amdgpu-tools-attrs.cl
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple amdgcn--amdhsa -verify -fsyntax-only %s
+
+// Check attributes with non kernel function
+__attribute__((amdgpu_tools_insert_nops)) void not_kernel0() {} // expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel functions}}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8))) void not_kernel1() {} // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute only applies to kernel functions}}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4))) void not_kernel2() {} // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute only applies to kernel functions}}
+typedef __attribute__((amdgpu_tools_insert_nops)) struct foo0_s { // expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo0_t;
+typedef __attribute__((amdgpu_tools_num_reserved_vgpr(8))) struct foo1_s { // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo1_t;
+typedef __attribute__((amdgpu_tools_num_reserved_sgpr(4))) struct foo2_s { // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo2_t;
+
+// Check non integer attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr("ABC"))) kernel void foo3() {} // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute requires an integer constant}}
+__attribute__((amdgpu_tools_num_reserved_sgpr("DEF"))) kernel void foo4() {} // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute requires an integer constant}}
+
+// Check large attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296))) kernel void foo5() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo6() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296), amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo7() {} // expected-error 2 {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+
+// Check valid attributes.
+__attribute__((amdgpu_tools_insert_nops)) kernel void foo8() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8))) kernel void foo9() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) kernel void foo10() {}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4))) kernel void foo11() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) kernel void foo12() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo13() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo14() {}
+// Make sure 0 VGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0))) kernel void foo15() {}
+// Make sure 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_sgpr(0))) kernel void foo16() {}
+// Make sure 0 VGPRs and 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0), amdgpu_tools_num_reserved_sgpr(0))) kernel void foo17() {}
+// Make sure kernel keyword can go before __attribute__ keyword.
+kernel __attribute__((amdgpu_tools_insert_nops)) void foo18() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8))) void foo19() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) void foo20() {}
+kernel __attribute__((amdgpu_tools_num_reserved_sgpr(4))) void foo21() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) void foo22() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo23() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo24() {}
Index: 

r262960 - Silence duplicate diagnostics because parsing of a standards-based attribute triggers parsing diagnostics that may also be picked up during semantic analysis.

2016-03-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar  8 15:31:32 2016
New Revision: 262960

URL: http://llvm.org/viewvc/llvm-project?rev=262960=rev
Log:
Silence duplicate diagnostics because parsing of a standards-based attribute 
triggers parsing diagnostics that may also be picked up during semantic 
analysis.

Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/Parser/cxx0x-attributes.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=262960=262959=262960=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Mar  8 15:31:32 2016
@@ -3695,6 +3695,7 @@ bool Parser::ParseCXX11AttributeArgs(Ide
 // The attribute was allowed to have arguments, but none were provided
 // even though the attribute parsed successfully. This is an error.
 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
+Attr->setInvalid(true);
   } else if (!Attr->getMaxArgs()) {
 // The attribute parsed successfully, but was not allowed to have any
 // arguments. It doesn't matter whether any were provided -- the
@@ -3702,6 +3703,7 @@ bool Parser::ParseCXX11AttributeArgs(Ide
 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
 << AttrName
 << FixItHint::CreateRemoval(SourceRange(LParenLoc, *EndLoc));
+Attr->setInvalid(true);
   }
 }
   }

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp?rev=262960=auto
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp Tue Mar  8 
15:31:32 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s
+
+struct [[nodiscard]] S1 {}; // ok
+struct [[nodiscard nodiscard]] S2 {}; // expected-error {{attribute 
'nodiscard' cannot appear multiple times in an attribute specifier}}
+struct [[nodiscard("Wrong")]] S3 {}; // expected-error {{'nodiscard' cannot 
have an argument list}}
+
+[[nodiscard]] int f();
+enum [[nodiscard]] E {};

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=262960=262959=262960=diff
==
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Tue Mar  8 15:31:32 2016
@@ -336,7 +336,6 @@ namespace {
   // expected-warning@-1 {{use of the 'deprecated' attribute is a C++14 
extension}}
   [[deprecated()]] void foo();
   // expected-error@-1 {{parentheses must be omitted if 'deprecated' 
attribute's argument list is empty}}
-  // expected-warning@-2 {{use of the 'deprecated' attribute is a C++14 
extension}}
   [[gnu::deprecated()]] void quux();
 }
 


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


Re: r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-08 Thread Nico Weber via cfe-commits
On Tue, Mar 8, 2016 at 2:10 PM, Richard Smith  wrote:

> On Tue, Mar 8, 2016 at 11:04 AM, Nico Weber  wrote:
> > On Tue, Mar 8, 2016 at 1:49 PM, Richard Smith 
> wrote:
> >>
> >> On Tue, Mar 8, 2016 at 9:05 AM, Nico Weber  wrote:
> >> > This causes clang to warn on
> >> >
> >> >   default: assert (false); HB_FALLTHROUGH;
> >>
> >> What follows this? (A case label?) What warning is being produced?
> >
> >
> > A case label. Full snippet:
> >
> https://code.google.com/p/chromium/codesearch#chromium/src/third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc=142
> >
> > Full warning (from
> >
> https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac%20%28dbg%29/builds/4497/steps/compile/logs/stdio
> ):
> >
> > ../../third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc:142:30:
> error:
> > fallthrough annotation in unreachable code
> [-Werror,-Wimplicit-fallthrough]
> > default: assert (false); HB_FALLTHROUGH;
> >  ^
> > ../../third_party/harfbuzz-ng/src/hb-private.hh:140:26: note: expanded
> from
> > macro 'HB_FALLTHROUGH'
> > #  define HB_FALLTHROUGH [[clang::fallthrough]]
> >
> > As far as I know, we don't opt in to -Wimplicit-fallthrough (and I don't
> see
> > a flag on the commandline of the failing compile; also available at the
> > above link.)
>
> OK, I see what's going wrong. Half of -Wimplicit-fallthrough is off by
> default, half of it is on by default. We used to do the CFG-based
> analysis only if the warning was enabled (because otherwise it would
> never produce any messages), and this change makes us also do the
> analysis when the warning is disabled but there are [[fallthrough]];
> statements in the function (it promotes the "misplaced
> [[fallthrough]];" diagnostic from warning to error, so we need the
> analysis if the attribute is present). This change should have had no
> impact on -Wimplicit-fallthrough (either the warning was disabled so
> no diagnostics are produced before and after, or the warning was
> enabled so the same diagnostics are produced before and after), but
> apparently when we ask "is this warning enabled?" and the warning
> group contains multiple diagnostics, we don't check them all...
>
> There's an easy fix for clang: warn_fallthrough_attr_unreachable
> should be marked DefaultIgnore.


Sounds good. Are you doing that? Want me to do that?


> (Though that chromium code would still
> produce diagnostics -- with or without this change -- if you build
> with -Wimplicit-fallthrough and -DNDEBUG, so maybe you do need a
> different macro for that case regardless.)
>
> >> > The fallthrough needs to be there for release builds, but now it must
> >> > not be
> >> > there for debug builds. I suppose this means projects now need an
> >> > UNREACHED_CASE macro that expands to assert(false) in debug and to
> >> > fallthrough in release (with clang; and to something else with other
> >> > compilers)?
> >> >
> >> > On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits
> >> >  wrote:
> >> >>
> >> >> Author: rsmith
> >> >> Date: Mon Mar  7 18:32:55 2016
> >> >> New Revision: 262881
> >> >>
> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=262881=rev
> >> >> Log:
> >> >> P0188R1: add support for standard [[fallthrough]] attribute. This is
> >> >> almost
> >> >> exactly the same as clang's existing [[clang::fallthrough]]
> attribute,
> >> >> which
> >> >> has been updated to have the same semantics. The one significant
> >> >> difference
> >> >> is that [[fallthrough]] is ill-formed if it's not used immediately
> >> >> before
> >> >> a
> >> >> switch label (even when -Wimplicit-fallthrough is disabled). To
> support
> >> >> that,
> >> >> we now build a CFG of any function that uses a '[[fallthrough]];'
> >> >> statement
> >> >> to check.
> >> >>
> >> >> In passing, fix some bugs with our support for statement attributes
> --
> >> >> in
> >> >> particular, diagnose their use on declarations, rather than
> asserting.
> >> >>
> >> >> Modified:
> >> >> cfe/trunk/include/clang/AST/Attr.h
> >> >> cfe/trunk/include/clang/Basic/Attr.td
> >> >> cfe/trunk/include/clang/Basic/AttrDocs.td
> >> >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >> >> cfe/trunk/include/clang/Sema/AttributeList.h
> >> >> cfe/trunk/include/clang/Sema/ScopeInfo.h
> >> >> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> >> >> cfe/trunk/lib/Sema/AttributeList.cpp
> >> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> >> cfe/trunk/lib/Sema/SemaStmtAttr.cpp
> >> >> cfe/trunk/test/Analysis/cxx11-crashes.cpp
> >> >> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
> >> >> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
> >> >> cfe/trunk/test/Parser/cxx0x-attributes.cpp
> >> >> cfe/trunk/test/SemaCXX/for-range-examples.cpp
> >> >> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
> >> >>

Re: r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-08 Thread Richard Smith via cfe-commits
On Tue, Mar 8, 2016 at 11:04 AM, Nico Weber  wrote:
> On Tue, Mar 8, 2016 at 1:49 PM, Richard Smith  wrote:
>>
>> On Tue, Mar 8, 2016 at 9:05 AM, Nico Weber  wrote:
>> > This causes clang to warn on
>> >
>> >   default: assert (false); HB_FALLTHROUGH;
>>
>> What follows this? (A case label?) What warning is being produced?
>
>
> A case label. Full snippet:
> https://code.google.com/p/chromium/codesearch#chromium/src/third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc=142
>
> Full warning (from
> https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac%20%28dbg%29/builds/4497/steps/compile/logs/stdio):
>
> ../../third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc:142:30: error:
> fallthrough annotation in unreachable code [-Werror,-Wimplicit-fallthrough]
> default: assert (false); HB_FALLTHROUGH;
>  ^
> ../../third_party/harfbuzz-ng/src/hb-private.hh:140:26: note: expanded from
> macro 'HB_FALLTHROUGH'
> #  define HB_FALLTHROUGH [[clang::fallthrough]]
>
> As far as I know, we don't opt in to -Wimplicit-fallthrough (and I don't see
> a flag on the commandline of the failing compile; also available at the
> above link.)

OK, I see what's going wrong. Half of -Wimplicit-fallthrough is off by
default, half of it is on by default. We used to do the CFG-based
analysis only if the warning was enabled (because otherwise it would
never produce any messages), and this change makes us also do the
analysis when the warning is disabled but there are [[fallthrough]];
statements in the function (it promotes the "misplaced
[[fallthrough]];" diagnostic from warning to error, so we need the
analysis if the attribute is present). This change should have had no
impact on -Wimplicit-fallthrough (either the warning was disabled so
no diagnostics are produced before and after, or the warning was
enabled so the same diagnostics are produced before and after), but
apparently when we ask "is this warning enabled?" and the warning
group contains multiple diagnostics, we don't check them all...

There's an easy fix for clang: warn_fallthrough_attr_unreachable
should be marked DefaultIgnore. (Though that chromium code would still
produce diagnostics -- with or without this change -- if you build
with -Wimplicit-fallthrough and -DNDEBUG, so maybe you do need a
different macro for that case regardless.)

>> > The fallthrough needs to be there for release builds, but now it must
>> > not be
>> > there for debug builds. I suppose this means projects now need an
>> > UNREACHED_CASE macro that expands to assert(false) in debug and to
>> > fallthrough in release (with clang; and to something else with other
>> > compilers)?
>> >
>> > On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits
>> >  wrote:
>> >>
>> >> Author: rsmith
>> >> Date: Mon Mar  7 18:32:55 2016
>> >> New Revision: 262881
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=262881=rev
>> >> Log:
>> >> P0188R1: add support for standard [[fallthrough]] attribute. This is
>> >> almost
>> >> exactly the same as clang's existing [[clang::fallthrough]] attribute,
>> >> which
>> >> has been updated to have the same semantics. The one significant
>> >> difference
>> >> is that [[fallthrough]] is ill-formed if it's not used immediately
>> >> before
>> >> a
>> >> switch label (even when -Wimplicit-fallthrough is disabled). To support
>> >> that,
>> >> we now build a CFG of any function that uses a '[[fallthrough]];'
>> >> statement
>> >> to check.
>> >>
>> >> In passing, fix some bugs with our support for statement attributes --
>> >> in
>> >> particular, diagnose their use on declarations, rather than asserting.
>> >>
>> >> Modified:
>> >> cfe/trunk/include/clang/AST/Attr.h
>> >> cfe/trunk/include/clang/Basic/Attr.td
>> >> cfe/trunk/include/clang/Basic/AttrDocs.td
>> >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> >> cfe/trunk/include/clang/Sema/AttributeList.h
>> >> cfe/trunk/include/clang/Sema/ScopeInfo.h
>> >> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
>> >> cfe/trunk/lib/Sema/AttributeList.cpp
>> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >> cfe/trunk/lib/Sema/SemaStmtAttr.cpp
>> >> cfe/trunk/test/Analysis/cxx11-crashes.cpp
>> >> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
>> >> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
>> >> cfe/trunk/test/Parser/cxx0x-attributes.cpp
>> >> cfe/trunk/test/SemaCXX/for-range-examples.cpp
>> >> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
>> >> cfe/trunk/test/SemaCXX/nodiscard.cpp
>> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
>> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp
>> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
>> >> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>> >> cfe/trunk/www/cxx_status.html
>> >>
>> >> 

Re: r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-08 Thread Nico Weber via cfe-commits
On Tue, Mar 8, 2016 at 1:49 PM, Richard Smith  wrote:

> On Tue, Mar 8, 2016 at 9:05 AM, Nico Weber  wrote:
> > This causes clang to warn on
> >
> >   default: assert (false); HB_FALLTHROUGH;
>
> What follows this? (A case label?) What warning is being produced?
>

A case label. Full snippet:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc=142

Full warning (from
https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac%20%28dbg%29/builds/4497/steps/compile/logs/stdio
):

../../third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc:142:30:
error: fallthrough annotation in unreachable code
[-Werror,-Wimplicit-fallthrough]
default: assert (false); HB_FALLTHROUGH;
 ^
../../third_party/harfbuzz-ng/src/hb-private.hh:140:26: note: expanded from
macro 'HB_FALLTHROUGH'
#  define HB_FALLTHROUGH [[clang::fallthrough]]

As far as I know, we don't opt in to -Wimplicit-fallthrough (and I don't
see a flag on the commandline of the failing compile; also available at the
above link.)

>
> > The fallthrough needs to be there for release builds, but now it must
> not be
> > there for debug builds. I suppose this means projects now need an
> > UNREACHED_CASE macro that expands to assert(false) in debug and to
> > fallthrough in release (with clang; and to something else with other
> > compilers)?
> >
> > On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits
> >  wrote:
> >>
> >> Author: rsmith
> >> Date: Mon Mar  7 18:32:55 2016
> >> New Revision: 262881
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=262881=rev
> >> Log:
> >> P0188R1: add support for standard [[fallthrough]] attribute. This is
> >> almost
> >> exactly the same as clang's existing [[clang::fallthrough]] attribute,
> >> which
> >> has been updated to have the same semantics. The one significant
> >> difference
> >> is that [[fallthrough]] is ill-formed if it's not used immediately
> before
> >> a
> >> switch label (even when -Wimplicit-fallthrough is disabled). To support
> >> that,
> >> we now build a CFG of any function that uses a '[[fallthrough]];'
> >> statement
> >> to check.
> >>
> >> In passing, fix some bugs with our support for statement attributes --
> in
> >> particular, diagnose their use on declarations, rather than asserting.
> >>
> >> Modified:
> >> cfe/trunk/include/clang/AST/Attr.h
> >> cfe/trunk/include/clang/Basic/Attr.td
> >> cfe/trunk/include/clang/Basic/AttrDocs.td
> >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >> cfe/trunk/include/clang/Sema/AttributeList.h
> >> cfe/trunk/include/clang/Sema/ScopeInfo.h
> >> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> >> cfe/trunk/lib/Sema/AttributeList.cpp
> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> cfe/trunk/lib/Sema/SemaStmtAttr.cpp
> >> cfe/trunk/test/Analysis/cxx11-crashes.cpp
> >> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
> >> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
> >> cfe/trunk/test/Parser/cxx0x-attributes.cpp
> >> cfe/trunk/test/SemaCXX/for-range-examples.cpp
> >> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
> >> cfe/trunk/test/SemaCXX/nodiscard.cpp
> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp
> >> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
> >> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> >> cfe/trunk/www/cxx_status.html
> >>
> >> Modified: cfe/trunk/include/clang/AST/Attr.h
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881=262880=262881=diff
> >>
> >>
> ==
> >> --- cfe/trunk/include/clang/AST/Attr.h (original)
> >> +++ cfe/trunk/include/clang/AST/Attr.h Mon Mar  7 18:32:55 2016
> >> @@ -118,6 +118,19 @@ public:
> >>bool duplicatesAllowed() const { return DuplicatesAllowed; }
> >>  };
> >>
> >> +class StmtAttr : public Attr {
> >> +protected:
> >> +  StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
> >> +  bool IsLateParsed, bool DuplicatesAllowed)
> >> +  : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed)
> >> {}
> >> +
> >> +public:
> >> +  static bool classof(const Attr *A) {
> >> +return A->getKind() >= attr::FirstStmtAttr &&
> >> +   A->getKind() <= attr::LastStmtAttr;
> >> +  }
> >> +};
> >> +
> >>  class InheritableAttr : public Attr {
> >>  protected:
> >>InheritableAttr(attr::Kind AK, SourceRange R, unsigned
> >> SpellingListIndex,
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Attr.td
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881=262880=262881=diff
> >>
> >>
> 

Re: r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-08 Thread Richard Smith via cfe-commits
On Tue, Mar 8, 2016 at 9:05 AM, Nico Weber  wrote:
> This causes clang to warn on
>
>   default: assert (false); HB_FALLTHROUGH;

What follows this? (A case label?) What warning is being produced?

> The fallthrough needs to be there for release builds, but now it must not be
> there for debug builds. I suppose this means projects now need an
> UNREACHED_CASE macro that expands to assert(false) in debug and to
> fallthrough in release (with clang; and to something else with other
> compilers)?
>
> On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Mon Mar  7 18:32:55 2016
>> New Revision: 262881
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262881=rev
>> Log:
>> P0188R1: add support for standard [[fallthrough]] attribute. This is
>> almost
>> exactly the same as clang's existing [[clang::fallthrough]] attribute,
>> which
>> has been updated to have the same semantics. The one significant
>> difference
>> is that [[fallthrough]] is ill-formed if it's not used immediately before
>> a
>> switch label (even when -Wimplicit-fallthrough is disabled). To support
>> that,
>> we now build a CFG of any function that uses a '[[fallthrough]];'
>> statement
>> to check.
>>
>> In passing, fix some bugs with our support for statement attributes -- in
>> particular, diagnose their use on declarations, rather than asserting.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Attr.h
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Basic/AttrDocs.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/AttributeList.h
>> cfe/trunk/include/clang/Sema/ScopeInfo.h
>> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
>> cfe/trunk/lib/Sema/AttributeList.cpp
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/lib/Sema/SemaStmtAttr.cpp
>> cfe/trunk/test/Analysis/cxx11-crashes.cpp
>> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
>> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
>> cfe/trunk/test/Parser/cxx0x-attributes.cpp
>> cfe/trunk/test/SemaCXX/for-range-examples.cpp
>> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
>> cfe/trunk/test/SemaCXX/nodiscard.cpp
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
>> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>> cfe/trunk/www/cxx_status.html
>>
>> Modified: cfe/trunk/include/clang/AST/Attr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881=262880=262881=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Attr.h (original)
>> +++ cfe/trunk/include/clang/AST/Attr.h Mon Mar  7 18:32:55 2016
>> @@ -118,6 +118,19 @@ public:
>>bool duplicatesAllowed() const { return DuplicatesAllowed; }
>>  };
>>
>> +class StmtAttr : public Attr {
>> +protected:
>> +  StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
>> +  bool IsLateParsed, bool DuplicatesAllowed)
>> +  : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed)
>> {}
>> +
>> +public:
>> +  static bool classof(const Attr *A) {
>> +return A->getKind() >= attr::FirstStmtAttr &&
>> +   A->getKind() <= attr::LastStmtAttr;
>> +  }
>> +};
>> +
>>  class InheritableAttr : public Attr {
>>  protected:
>>InheritableAttr(attr::Kind AK, SourceRange R, unsigned
>> SpellingListIndex,
>>
>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881=262880=262881=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> +++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 18:32:55 2016
>> @@ -311,6 +311,9 @@ class TypeAttr : Attr {
>>let ASTNode = 0;
>>  }
>>
>> +/// A stmt attribute is not processed on a declaration or a type.
>> +class StmtAttr : Attr;
>> +
>>  /// An inheritable attribute is inherited by later redeclarations.
>>  class InheritableAttr : Attr;
>>
>> @@ -738,8 +741,9 @@ def ExtVectorType : Attr {
>>let Documentation = [Undocumented];
>>  }
>>
>> -def FallThrough : Attr {
>> -  let Spellings = [CXX11<"clang", "fallthrough">];
>> +def FallThrough : StmtAttr {
>> +  let Spellings = [CXX11<"", "fallthrough", 201503>,
>> +   CXX11<"clang", "fallthrough">];
>>  //  let Subjects = [NullStmt];
>>let Documentation = [FallthroughDocs];
>>  }
>>
>> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262881=262880=262881=diff
>>
>> 

Re: [PATCH] D17947: [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

2016-03-08 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 50055.
beanz added a comment.

Updates based on Anna's polite and restrained feedback that didn't include the 
appropriate comment "Why don't you fix your TODO?" (I did fix it this time).


http://reviews.llvm.org/D17947

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/darwin-ld.c

Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 
-fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> 
%t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -353,34 +353,8 @@
   ArgStringList ) const {
   if (!needsProfileRT(Args)) return;
 
-  // TODO: Clean this up once autoconf is gone
-  SmallString<128> P(getDriver().ResourceDir);
-  llvm::sys::path::append(P, "lib", "darwin");
-  const char *Library = "libclang_rt.profile_osx.a";
-
-  // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
- : "libclang_rt.profile_watchos.a";
-  } else if (isTargetTvOS()) {
-Library = "libclang_rt.profile_tvos.a";
-  } else if (isTargetTvOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
- : "libclang_rt.profile_tvos.a";
-  } else if (isTargetIPhoneOS()) {
-Library = "libclang_rt.profile_ios.a";
-  } else if (isTargetIOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
- : "libclang_rt.profile_ios.a";
-  } else {
-assert(isTargetMacOS() && "unexpected non MacOS platform");
-  }
-  AddLinkRuntimeLib(Args, CmdArgs, Library,
+  AddLinkRuntimeLib(Args, CmdArgs, (Twine("libclang_rt.profile_") +
+   getOSLibraryNameSuffix() + ".a").str(),
 /*AlwaysLink*/ true);
 }
 


Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -353,34 +353,8 @@
   ArgStringList ) const {
   if (!needsProfileRT(Args)) return;
 
-  // TODO: Clean this up once autoconf is gone
-  SmallString<128> P(getDriver().ResourceDir);
-  llvm::sys::path::append(P, "lib", "darwin");
-  const char *Library = "libclang_rt.profile_osx.a";
-
-  // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
- : "libclang_rt.profile_watchos.a";
-  } else if (isTargetTvOS()) {
-Library = "libclang_rt.profile_tvos.a";
-  } else if (isTargetTvOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
- : "libclang_rt.profile_tvos.a";
-  } else if (isTargetIPhoneOS()) {
-Library = "libclang_rt.profile_ios.a";
-  } else if (isTargetIOSSimulator()) {
-   

Re: [PATCH] D17893: Sema: Add semantic analysis for the C++ ABI stability attributes and whitelist.

2016-03-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Missing some attribute-related tests like attaching the attribute to something 
other than a record, or passing arguments to the attribute.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8332
@@ +8331,3 @@
+  "base %0 uses the stable ABI">;
+def note_unstable_abi_base : Note<
+  "base %0 uses the unstable ABI">;

It would be good to combine these into one Note using %select.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8336
@@ +8335,3 @@
+  "stable ABI specified by attribute">;
+def note_unstable_abi_attr : Note<
+  "unstable ABI specified by attribute">;

Same for these.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8345
@@ +8344,3 @@
+def note_add_unstable_abi_attr : Note<
+  "add attribute clang::unstable_abi or clang::stable_abi to silence this 
warning">;
+

Should this also be a %select, or can you really add either attribute to 
silence the warning?


Comment at: lib/Sema/SemaDeclCXX.cpp:4896
@@ +4895,3 @@
+
+  // No need to do this for non-dynamic classes.
+  if (!Record->isDynamicClass())

Since the attributes do nothing for a non-dynamic class, should the user get a 
warning if the place the attribute on one (so they know it does nothing)?


http://reviews.llvm.org/D17893



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


[PATCH] D17963: [OPENMP] Codegen for teams directive for NVPTX

2016-03-08 Thread Carlo Bertolli via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, fraggamuffin, kkwli0.
carlo.bertolli added subscribers: sfantao, arpith-jacob, caomhin, cfe-commits.
carlo.bertolli set the repository for this revision to rL LLVM.
Herald added a subscriber: jholewinski.

This patch implements the teams directive for the NVPTX backend. It is 
different from the host code generation path as it:

- Does not call kmpc_fork_teams. All necessary teams and threads are started 
upon touching the target region, when launching a CUDA kernel, and their 
execution is coordinated through sequential and parallel regions within the 
target region.

- Does not call kmpc_push_num_teams even if a num_teams of thread_limit clause 
is present. Setting the number of teams and the thread limit is implemented by 
the nvptx-related runtime.

Please note that I am now passing a Clang Expr * to emitPushNumTeams instead of 
the originally chosen llvm::Value * type. The reason for that is that I want to 
avoid emitting expressions for num_teams and thread_limit if they are not 
needed in the target region.

Repository:
  rL LLVM

http://reviews.llvm.org/D17963

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_teams_codegen.cpp

Index: test/OpenMP/nvptx_teams_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_teams_codegen.cpp
@@ -0,0 +1,116 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#ifdef CK1
+
+template 
+int tmain(T argc) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return 0;
+}
+
+int main (int argc, char **argv) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return tmain(argv);
+}
+
+// only nvptx side: do not outline teams region and do not call fork_teams
+// CK1:  define {{.*}}void @{{[^,]+}}(i{{.+}} [[ARGC:%.+]])
+// CK1:  [[ARGCADDR:%.+]] = alloca i{{[0-9]+}},
+// CK1:  store i{{[0-9]+}} [[ARGC]], i{{[0-9]+}}* [[ARGCADDR]],
+// CK1-64: [[CONV:%.+]] = bitcast i64* [[ARGCADDR]] to i32*
+// CK1-64: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[CONV]],
+// CK1-32: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[ARGCADDR]],
+// CK1-NOT: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(
+// CK1:  ret void
+// CK1-NEXT: }
+
+// target region in template
+// CK1: define {{.*}}void @{{[^,]+}}(i{{.+}}***{{.+}} [[ARGC:%.+]])
+// CK1: [[ARGCADDR:%.+]] = alloca i{{.+}}***,
+// CK1: store i{{.+}}*** [[ARGC]], i{{.+}} [[ARGCADDR]]
+// CK1: [[ARGCADDR_REF:%.+]] = load i{{.+}}***, i{{.+}} [[ARGCADDR]],
+// CK1: store i{{[0-9]+}}** null, i{{[0-9]+}}*** [[ARGCADDR_REF]],
+// CK1-NOT: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(
+// CK1:  ret void
+// CK1-NEXT: }
+
+
+#endif // CK1
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32
+// expected-no-diagnostics
+#ifdef CK2
+
+template 
+int tmain(T argc) {
+  int a = 10;
+  int b = 5;
+#pragma omp target
+#pragma omp teams num_teams(a) thread_limit(b)
+  {
+  argc = 0;
+  }
+  return 0;
+}
+
+int main (int argc, char **argv) {
+  int a = 20;
+  int b = 5;
+#pragma omp target
+#pragma omp teams num_teams(a) thread_limit(b)
+  {
+  argc = 0;
+  }
+  

Re: [PATCH] D17959: Make it possible for AST plugins to enable themselves by default

2016-03-08 Thread John Brawn via cfe-commits
john.brawn added a comment.

Looking at http://reviews.llvm.org/D15729 I //think// there's no conflict 
between what this patch is doing and what that patch is doing. If a plugin 
returns AddBeforeMainAction or AddAfterMainAction then when ASTUnit in libclang 
loads that plugin it should get automatically added in 
FrontendAction::CreateWrappedASTConsumer, which is what I would expect should 
happen. There's a question of whether lines 199-210 of 
ExecuteCompilerInvocation.cpp should get moved into the 
CompilerInstance::loadPlugins function that http://reviews.llvm.org/D15729 adds 
and I think the answer there is no - looking at ASTUnit it doesn't seem to use 
getFrontendOpts().ProgramAction at all, so there's no point setting it based on 
a plugin.


Repository:
  rL LLVM

http://reviews.llvm.org/D17959



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-03-08 Thread Alexander Droste via cfe-commits
Alexander_Droste added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:160
@@ -153,1 +159,3 @@
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };

dcoughlin wrote:
> Alexander_Droste wrote:
> > dcoughlin wrote:
> > > I'm not sure that 'getVariableName()' conveys what this function does. 
> > > The returned name is not always the name of a variable. How do you intend 
> > > to use this method? How is it different than than printPretty()? Is it 
> > > for debugging purposes? If so, then perhaps 'getDebugDescription()'? Is 
> > > it for presentation to the user? Then perhaps 'getDescriptiveName()'?
> > > The returned name is not always the name of a variable.
> > In which cases doesn't this function return the name? Isn't the worst case 
> > when `printPretty` can't be called and the string is empty?
> > 
> > The function is intended to return the variable name and collects index 
> > variable names / `ConcreteInt`s along the way if the passed region is an 
> > `ElementRegion`. So `printPretty` is called on the 'top' region of an array 
> > at the end of this function. If the passed region is no `ElementRegion` the 
> > functionality is identical to `printPretty`. 
> > 
> > The main motivation to write this function was to include specific indices 
> > in a diagnostic if obtainable, like presented in the MPI-Checker testfile  
> > http://reviews.llvm.org/D12761#3c51dfcf.
> > E.g. `Request 'sendReq1[1][7][9]' has no matching nonblocking call.` My 
> > intent was not to use the function for debugging purposes.
> > 
> > So should we use `getDescriptiveName` or maybe sth. like 
> > `getVariableNameWithIndices`?.
> Can the string ever be something like 'a.f[0][1]' (i.e., with a field name)? 
> Or is it always 'a[0][1]'? If the first is possible I would suggest 
> `getDescriptiveName` -- if not, then `getVariableNameWithIndices` seems fine.
Yes, the string includes the name of the struct.  But this is not due to the 
while loop in this function but how `printPretty` is defined for `FieldRegion`. 
 In case of a `FieldRegion` `printPretty` is called for the super-region first 
before the field declation name gets appended. 
```
void FieldRegion::printPrettyAsExpr(raw_ostream ) const {
  assert(canPrintPrettyAsExpr());
  superRegion->printPrettyAsExpr(os);
  os << "." << getDecl()->getName();
}
```
I'll go with `getDescriptiveName`.


http://reviews.llvm.org/D16044



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


Re: [Diffusion] rL244063: Add missing atomic libcall support.

2016-03-08 Thread Dimitry Andric via cfe-commits
dim resigned from this audit.

Users:
  jyknight (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  compnerd (Auditor)
  majnemer (Auditor)
  rsmith (Auditor)
  dim (Auditor)

http://reviews.llvm.org/rL244063



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


Re: [Diffusion] rL244063: Add missing atomic libcall support.

2016-03-08 Thread Dimitry Andric via cfe-commits
dim accepted this commit.

Users:
  jyknight (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  compnerd (Auditor)
  majnemer (Auditor)
  rsmith (Auditor)
  dim (Auditor)

http://reviews.llvm.org/rL244063



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


Re: [PATCH] D17941: add fix-its for format-security warnings

2016-03-08 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  I don't have a lot of authority over this code, so you may want to get a 
separate LGTM from someone else.


http://reviews.llvm.org/D17941



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


Re: [PATCH] D17941: add fix-its for format-security warnings

2016-03-08 Thread Bob Wilson via cfe-commits
bob.wilson added a comment.

In http://reviews.llvm.org/D17941#369698, @bcraig wrote:

> What about wprintf?  Do we currently warn for wprintf(str)?  If so, then the 
> fixit probably needs to involve L"%ls".


Darwin does not mark wprintf functions with an attribute. Linux (at least the 
version I checked) has an attribute that is commented out, but it uses a 
distinct "__wprintf__" format type. Clang does not currently support that 
format type. If that is added in the future, you are right that the fix-it will 
need to be different.


http://reviews.llvm.org/D17941



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


Re: r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-08 Thread Nico Weber via cfe-commits
This causes clang to warn on

  default: assert (false); HB_FALLTHROUGH;

The fallthrough needs to be there for release builds, but now it must not
be there for debug builds. I suppose this means projects now need an
UNREACHED_CASE macro that expands to assert(false) in debug and to
fallthrough in release (with clang; and to something else with other
compilers)?

On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Mar  7 18:32:55 2016
> New Revision: 262881
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262881=rev
> Log:
> P0188R1: add support for standard [[fallthrough]] attribute. This is almost
> exactly the same as clang's existing [[clang::fallthrough]] attribute,
> which
> has been updated to have the same semantics. The one significant difference
> is that [[fallthrough]] is ill-formed if it's not used immediately before a
> switch label (even when -Wimplicit-fallthrough is disabled). To support
> that,
> we now build a CFG of any function that uses a '[[fallthrough]];' statement
> to check.
>
> In passing, fix some bugs with our support for statement attributes -- in
> particular, diagnose their use on declarations, rather than asserting.
>
> Modified:
> cfe/trunk/include/clang/AST/Attr.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/include/clang/Sema/ScopeInfo.h
> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> cfe/trunk/lib/Sema/AttributeList.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaStmtAttr.cpp
> cfe/trunk/test/Analysis/cxx11-crashes.cpp
> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
> cfe/trunk/test/Parser/cxx0x-attributes.cpp
> cfe/trunk/test/SemaCXX/for-range-examples.cpp
> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
> cfe/trunk/test/SemaCXX/nodiscard.cpp
> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp
> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> cfe/trunk/www/cxx_status.html
>
> Modified: cfe/trunk/include/clang/AST/Attr.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881=262880=262881=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Mon Mar  7 18:32:55 2016
> @@ -118,6 +118,19 @@ public:
>bool duplicatesAllowed() const { return DuplicatesAllowed; }
>  };
>
> +class StmtAttr : public Attr {
> +protected:
> +  StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
> +  bool IsLateParsed, bool DuplicatesAllowed)
> +  : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed) {}
> +
> +public:
> +  static bool classof(const Attr *A) {
> +return A->getKind() >= attr::FirstStmtAttr &&
> +   A->getKind() <= attr::LastStmtAttr;
> +  }
> +};
> +
>  class InheritableAttr : public Attr {
>  protected:
>InheritableAttr(attr::Kind AK, SourceRange R, unsigned
> SpellingListIndex,
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881=262880=262881=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 18:32:55 2016
> @@ -311,6 +311,9 @@ class TypeAttr : Attr {
>let ASTNode = 0;
>  }
>
> +/// A stmt attribute is not processed on a declaration or a type.
> +class StmtAttr : Attr;
> +
>  /// An inheritable attribute is inherited by later redeclarations.
>  class InheritableAttr : Attr;
>
> @@ -738,8 +741,9 @@ def ExtVectorType : Attr {
>let Documentation = [Undocumented];
>  }
>
> -def FallThrough : Attr {
> -  let Spellings = [CXX11<"clang", "fallthrough">];
> +def FallThrough : StmtAttr {
> +  let Spellings = [CXX11<"", "fallthrough", 201503>,
> +   CXX11<"clang", "fallthrough">];
>  //  let Subjects = [NullStmt];
>let Documentation = [FallthroughDocs];
>  }
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262881=262880=262881=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar  7 18:32:55 2016
> @@ -756,9 +756,10 @@ potentially-evaluated discarded-value ex
>
>  def FallthroughDocs : Documentation {
>let Category = 

r262938 - Turning on the /bigobj flag for two more files that will not link with MSVC 2015 Win64 Debug due to the section limit.

2016-03-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar  8 10:34:37 2016
New Revision: 262938

URL: http://llvm.org/viewvc/llvm-project?rev=262938=rev
Log:
Turning on the /bigobj flag for two more files that will not link with MSVC 
2015 Win64 Debug due to the section limit.

Modified:
cfe/trunk/unittests/ASTMatchers/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/unittests/ASTMatchers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/CMakeLists.txt?rev=262938=262937=262938=diff
==
--- cfe/trunk/unittests/ASTMatchers/CMakeLists.txt (original)
+++ cfe/trunk/unittests/ASTMatchers/CMakeLists.txt Tue Mar  8 10:34:37 2016
@@ -2,6 +2,12 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+# By default MSVC has a 2^16 limit on the number of sections in an object file,
+# and this needs more than that.
+if (MSVC)
+  set_source_files_properties(ASTMatchersTest.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
+endif()
+
 add_clang_unittest(ASTMatchersTests
   ASTMatchersTest.cpp)
 

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=262938=262937=262938=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Tue Mar  8 10:34:37 2016
@@ -3,6 +3,12 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+# By default MSVC has a 2^16 limit on the number of sections in an object file,
+# and this needs more than that.
+if (MSVC)
+  set_source_files_properties(RecursiveASTVisitorTestExprVisitor.cpp 
PROPERTIES COMPILE_FLAGS /bigobj)
+endif()
+
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp


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


Re: [Diffusion] rL244063: Add missing atomic libcall support.

2016-03-08 Thread James Y Knight via cfe-commits
jyknight accepted this commit.
jyknight added a comment.

This issue was resolved; hopefully this will inform Phab of that.


Users:
  jyknight (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  compnerd (Auditor)
  majnemer (Auditor)
  rsmith (Auditor)

http://reviews.llvm.org/rL244063



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


r262933 - Add Visual Studio native visualizers for several Clang types

2016-03-08 Thread Mike Spertus via cfe-commits
Author: mps
Date: Tue Mar  8 10:14:23 2016
New Revision: 262933

URL: http://llvm.org/viewvc/llvm-project?rev=262933=rev
Log:
Add Visual Studio native visualizers for several Clang types

This is one of a series of changes to improve the MSVC visualization of Clang 
types.
This one focuses on Record and SubstTemplateTypeParmType meaning that, for 
example,
a TemplateArgumentLoc no longer displays incomprehensibly in the locals window 
as

  {Argument={DeclArg={Kind=1 QT=0x033acb00 D=0x {DeclType=???}}...

but instead much more usefully as

  Type template parameter: SubstTemplateTypeParm: {Identifier (("T"))} => 
Record, {Identifier (("A"))}

Additional types and improvements will be made in subsequent commits


Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=262933=262932=262933=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Tue Mar  8 10:14:23 2016
@@ -1,18 +1,81 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010;>
   
-Builtin 
Type={(clang::BuiltinType::Kind)BuiltinTypeBits.Kind}
-Modified 
Type={((clang::AttributedType*)this)->ModifiedType} 
Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-Type 
Class={(clang::Type::TypeClass)TypeBits.TC}
+{(clang::Type::TypeClass)TypeBits.TC, en}
+Builtin 
Type={*(clang::BuiltinType *)this}
+Modified 
Type={((clang::AttributedType*)this)->ModifiedType} 
Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
+{*(clang::SubstTemplateTypeParmType
 *)this}
+{*(clang::RecordType 
*)this}
+{(clang::Type::TypeClass)TypeBits.TC, en}
+
+  (clang::Type::TypeClass)TypeBits.TC
+  TypeBits
+  CanonicalType
+  *(clang::BuiltinType 
*)this
+  (clang::SubstTemplateTypeParmType
 *)this
+  (clang::RecordType 
*)this
+
+  
+  
+{*decl}
+
+  decl
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType 
*)this}
+
+  *(clang::TagType *)this
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} = 
{CanonicalType}
+
+  *(clang::Type *)this, view(BaseOnly)
+  *Replaced
+
+  
+  
+{*TTPDecl}
   
   
-{((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  
clang::TypeAlignmentInBits) - 1)))-BaseType}
+
+{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType}
+
+  *((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType
+
+  
+  
+{Argument}
+
+  Argument
+
+  
+  
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} 
template parameter: {*(clang::QualType *)TypeOrValue.V}
+
+  *(clang::QualType 
*)TypeOrValue.V
+  
+
+  
+  
+{(clang::BuiltinType::Kind)BuiltinTypeBits.Kind, 
en}
+
+  (clang::BuiltinType::Kind)BuiltinTypeBits.Kind
+
+  
+  
+{Name}
+  
+  
+{(clang::TemplateDecl 
*)((Template.Storage.Val.Val.Value  2)  2)}
+{Template.Storage}
   
   
 ({((llvm::StringMapEntryclang::IdentifierInfo 
**)Entry)+1,s})
@@ -32,14 +95,14 @@ or create a symbolic link so it updates
   *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
   *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
   (clang::DeclarationNameExtra::ExtraKind)((clang::DeclarationNameExtra
 *)(Ptr  ~PtrMask))-ExtraKindOrNumArgs
-
-  
-  
-{(clang::tok::TokenKind)Kind}
-{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
-  
-  
-[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
+
+  
+  
+{(clang::tok::TokenKind)Kind,en}
+{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
+  
+  
+[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
   
   
 {Name,s}
@@ -65,4 +128,10 @@ or create a symbolic link so it updates
   ParmVarDeclBits
 
   
+  
+{($T1 *)Ptr
+
+  ($T1 *)Ptr
+
+  
 


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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-03-08 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

I still cannot build project with your changes, now compiler cannot find symbol 
`hasSubStmt`. When committing the change please make sure that all 
prerequisites are committed and unit tests run successfully.

I would recommend you to take tests from http://reviews.llvm.org/D14224 for 
literals. They check imported values as well, not only syntax structure. It is 
however only a recommendation.

There is no tests for `InjectedClassNameType`, `TemplateTypeParmType`, 
`GCCAsmStmt`, `VAArgExpr` and `CXXBoolLiteralExpr`. Probably these nodes may be 
moved to next code change?

Provided that the aforementioned nodes get tests of are moved to another 
change, the patch looks good for me. I do not have authority to approve patches 
for commit, you need to ask someone with proper rights for the approval.

Thank you!



Comment at: lib/AST/ASTImporter.cpp:1827-1828
@@ +1826,4 @@
+
+  // FIXME: ASTContext::getInjectedClassNameType is not suitable for AST 
reading
+  // See comments in its definition for details
+  // return Importer.getToContext().getInjectedClassNameType(D, InjType);

Definition of `ASTContext::getInjectedClassNameType` does not contain comments 
that would explain why it is unsuitable, so this comment is confusing. Probably 
you wanted to reference `ASTReader::readTypeRecord`, it contains similar 
statement.


Comment at: lib/AST/ASTImporter.cpp:4379
@@ +4378,3 @@
+
+  // Resolve possible cyclic import
+  if (Decl *AlreadyImported = Importer.GetAlreadyImportedOrNull(D))

Comments should be proper English sentences. In this case ending period is 
missed.


Comment at: lib/AST/ASTImporter.cpp:4730
@@ +4729,3 @@
+  SmallVector Names;
+  for (unsigned i = 0, e = S->getNumOutputs(); i != e; i++) {
+IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(i));

According to LLVM coding style ([[ 
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
 ]]) variable names 'should be camel case, and start with an upper case 
letter', so `i` -> `I`, `e` -> `E`.


Comment at: unittests/AST/ASTImporterTest.cpp:117
@@ +116,3 @@
+   hasType(
+ asString("const char [4]");
+  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",

Disadvantage of using matchers, apart of complexity, is that they check only 
syntax structure. This test does not check if imported literal has proper value.


Repository:
  rL LLVM

http://reviews.llvm.org/D14286



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


[libcxx] r262932 - Remove a couple tabs that crept in

2016-03-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar  8 09:45:06 2016
New Revision: 262932

URL: http://llvm.org/viewvc/llvm-project?rev=262932=rev
Log:
Remove a couple tabs that crept in

Modified:

libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp?rev=262932=262931=262932=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
 Tue Mar  8 09:45:06 2016
@@ -67,12 +67,12 @@ int main()
 }
 #endif
 #if TEST_STD_VER > 14
-   {
+{
 typedef std::string S;
 S s1(""); test_nonconst(s1);
 S s2("abcde");test_nonconst(s2);
 S s3("abcdefghij");   test_nonconst(s3);
 S s4("abcdefghijklmnopqrst"); test_nonconst(s4);
-   }
+}
 #endif
 }


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


[libcxx] r262931 - Implement P0272R1: Give 'std::string' a non-const '.data()' member function

2016-03-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar  8 09:44:30 2016
New Revision: 262931

URL: http://llvm.org/viewvc/llvm-project?rev=262931=rev
Log:
Implement P0272R1: Give 'std::string' a non-const '.data()' member function

Modified:
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=262931=262930=262931=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Tue Mar  8 09:44:30 2016
@@ -225,6 +225,7 @@ public:
 
 const value_type* c_str() const noexcept;
 const value_type* data() const noexcept;
+  value_type* data()   noexcept;   // C++17
 
 allocator_type get_allocator() const noexcept;
 
@@ -1659,6 +1660,10 @@ public:
 const value_type* c_str() const _NOEXCEPT {return data();}
 _LIBCPP_INLINE_VISIBILITY
 const value_type* data() const _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
+#if _LIBCPP_STD_VER > 14
+_LIBCPP_INLINE_VISIBILITY
+value_type* data() _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
+#endif
 
 _LIBCPP_INLINE_VISIBILITY
 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp?rev=262931=262930=262931=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
 Tue Mar  8 09:44:30 2016
@@ -10,15 +10,17 @@
 // 
 
 // const charT* data() const;
+//   charT* data();   // C++17
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 template 
 void
-test(const S& s)
+test_const(const S& s)
 {
 typedef typename S::traits_type T;
 const typename S::value_type* str = s.data();
@@ -31,22 +33,46 @@ test(const S& s)
 assert(T::eq(str[0], typename S::value_type()));
 }
 
+template 
+void
+test_nonconst(S& s)
+{
+typedef typename S::traits_type T;
+typename S::value_type* str = s.data();
+if (s.size() > 0)
+{
+assert(T::compare(str, [0], s.size()) == 0);
+assert(T::eq(str[s.size()], typename S::value_type()));
+}
+else
+assert(T::eq(str[0], typename S::value_type()));
+}
+
 int main()
 {
 {
 typedef std::string S;
-test(S(""));
-test(S("abcde"));
-test(S("abcdefghij"));
-test(S("abcdefghijklmnopqrst"));
+test_const(S(""));
+test_const(S("abcde"));
+test_const(S("abcdefghij"));
+test_const(S("abcdefghijklmnopqrst"));
 }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
 {
 typedef std::basic_string S;
-test(S(""));
-test(S("abcde"));
-test(S("abcdefghij"));
-test(S("abcdefghijklmnopqrst"));
+test_const(S(""));
+test_const(S("abcde"));
+test_const(S("abcdefghij"));
+test_const(S("abcdefghijklmnopqrst"));
 }
 #endif
+#if TEST_STD_VER > 14
+   {
+typedef std::string S;
+S s1(""); test_nonconst(s1);
+S s2("abcde");test_nonconst(s2);
+S s3("abcdefghij");   test_nonconst(s3);
+S s4("abcdefghijklmnopqrst"); test_nonconst(s4);
+   }
+#endif
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=262931=262930=262931=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Mar  8 09:44:30 2016
@@ -91,7 +91,7 @@
http://wg21.link/P0154R1;>P0154R1LWGconstexpr 
std::hardware_{constructive,destructive}_interference_sizeJacksonville
http://wg21.link/P0030R1;>P0030R1LWGProposal to 
Introduce a 3-Argument Overload to 
std::hypotJacksonville
http://wg21.link/P0031R0;>P0031R0LWGA Proposal to 
Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range 
AccessJacksonville
-   http://wg21.link/P0272R1;>P0272R1LWGGive 
std::string a non-const .data() member 
functionJacksonville
+   http://wg21.link/P0272R1;>P0272R1LWGGive 
std::string a non-const .data() member 
functionJacksonvilleComplete3.9
http://wg21.link/P0077R2;>P0077R2LWGis_callable,
 the missing INVOKE related 
traitJacksonville
 
   


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D17959: Make it possible for AST plugins to enable themselves by default

2016-03-08 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: bkramer.
klimek added a comment.

+benjamin, who has done work in the area


Repository:
  rL LLVM

http://reviews.llvm.org/D17959



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


[libcxx] r262928 - Implement P0253R1: Fixing a design mistake in the searchers interface.

2016-03-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar  8 09:12:52 2016
New Revision: 262928

URL: http://llvm.org/viewvc/llvm-project?rev=262928=rev
Log:
Implement P0253R1: Fixing a design mistake in the searchers interface.

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/experimental/algorithm
libcxx/trunk/include/experimental/functional
libcxx/trunk/include/string
libcxx/trunk/test/std/experimental/algorithms/alg.search/search.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp

libcxx/trunk/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=262928=262927=262928=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Mar  8 09:12:52 2016
@@ -1421,20 +1421,20 @@ is_permutation(_ForwardIterator1 __first
 // search
 
 template 
-_ForwardIterator1
+pair<_ForwardIterator1, _ForwardIterator1>
 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
  _ForwardIterator2 __first2, _ForwardIterator2 __last2, 
_BinaryPredicate __pred,
  forward_iterator_tag, forward_iterator_tag)
 {
 if (__first2 == __last2)
-return __first1;  // Everything matches an empty sequence
+return make_pair(__first1, __first1);  // Everything matches an empty 
sequence
 while (true)
 {
 // Find first element in sequence 1 that matchs *__first2, with a 
mininum of loop checks
 while (true)
 {
 if (__first1 == __last1)  // return __last1 if no element matches 
*__first2
-return __last1;
+return make_pair(__last1, __last1);
 if (__pred(*__first1, *__first2))
 break;
 ++__first1;
@@ -1445,9 +1445,9 @@ __search(_ForwardIterator1 __first1, _Fo
 while (true)
 {
 if (++__m2 == __last2)  // If pattern exhausted, __first1 is the 
answer (works for 1 element pattern)
-return __first1;
+return make_pair(__first1, __m1);
 if (++__m1 == __last1)  // Otherwise if source exhaused, pattern 
not found
-return __last1;
+return make_pair(__last1, __last1);
 if (!__pred(*__m1, *__m2))  // if there is a mismatch, restart 
with a new __first1
 {
 ++__first1;
@@ -1458,20 +1458,21 @@ __search(_ForwardIterator1 __first1, _Fo
 }
 
 template 
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
+_LIBCPP_CONSTEXPR_AFTER_CXX11 
+pair<_RandomAccessIterator1, _RandomAccessIterator1>
 __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
-   _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, 
_BinaryPredicate __pred,
+ _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, 
_BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag)
 {
-typedef typename 
std::iterator_traits<_RandomAccessIterator1>::difference_type _D1;
-typedef typename 
std::iterator_traits<_RandomAccessIterator2>::difference_type _D2;
+typedef typename iterator_traits<_RandomAccessIterator1>::difference_type 
_D1;
+typedef typename iterator_traits<_RandomAccessIterator2>::difference_type 
_D2;
 // Take advantage of knowing source and pattern lengths.  Stop short when 
source is smaller than pattern
-_D2 __len2 = __last2 - __first2;
+const _D2 __len2 = __last2 - __first2;
 if (__len2 == 0)
-return __first1;
-_D1 __len1 = __last1 - __first1;
+return make_pair(__first1, __first1);
+const _D1 __len1 = __last1 - __first1;
 if (__len1 < __len2)
-return __last1;
+return make_pair(__last1, __last1);
 const _RandomAccessIterator1 __s = __last1 - (__len2 - 1);  // Start of 
pattern match can't go beyond here
 while (true)

Re: [PATCH] D17955: [OpenCL] Fix pipe builtin bugs

2016-03-08 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Tests missing!


http://reviews.llvm.org/D17955



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


[PATCH] D17959: Make it possible for AST plugins to enable themselves by default

2016-03-08 Thread John Brawn via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: klimek, kfunk, milianw, rsmith.
john.brawn added a subscriber: cfe-commits.
john.brawn set the repository for this revision to rL LLVM.

Currently when an AST plugin is loaded it must then be enabled by passing 
-plugin pluginname or -add-plugin pluginname to the -cc1 command line. This 
patch adds a method to PluginASTAction which allows it to declare that the 
action happens before, instead of, or after the main AST action, plus the 
relevant changes to make the plugin action happen at that time automatically.

Note: patch was written before I noticed D15729, and probably needs adjusting 
to work with that.

Repository:
  rL LLVM

http://reviews.llvm.org/D17959

Files:
  docs/ClangPlugins.rst
  examples/AnnotateFunctions/AnnotateFunctions.cpp
  examples/AnnotateFunctions/CMakeLists.txt
  examples/CMakeLists.txt
  include/clang/Frontend/FrontendAction.h
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendAction.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/Frontend/plugin-annotate-functions.c

Index: test/Frontend/plugin-annotate-functions.c
===
--- /dev/null
+++ test/Frontend/plugin-annotate-functions.c
@@ -0,0 +1,7 @@
+// RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -S %s -o - | FileCheck %s
+// REQUIRES: plugins, examples
+
+// CHECK: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
+// CHECK: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
+void fn1() { }
+void fn2() { }
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -66,7 +66,9 @@
  it != ie; ++it) {
   if (it->getName() == CI.getFrontendOpts().ActionName) {
 std::unique_ptr P(it->instantiate());
-if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs))
+if ((P->getActionType() != PluginASTAction::ReplaceAction &&
+ P->getActionType() != PluginASTAction::Cmdline) ||
+!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()]))
   return nullptr;
 return std::move(P);
   }
@@ -194,6 +196,18 @@
 << Path << Error;
   }
 
+  // Check if any of the loaded plugins replaces the main AST action
+  for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
+ie = FrontendPluginRegistry::end();
+   it != ie; ++it) {
+std::unique_ptr P(it->instantiate());
+if (P->getActionType() == PluginASTAction::ReplaceAction) {
+  Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
+  Clang->getFrontendOpts().ActionName = it->getName();
+  break;
+}
+  }
+
   // Honor -mllvm.
   //
   // FIXME: Remove this, one day.
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -141,28 +141,46 @@
   if (!Consumer)
 return nullptr;
 
-  if (CI.getFrontendOpts().AddPluginActions.size() == 0)
+  // If there are no registered plugins we don't need to wrap the consumer
+  if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
 return Consumer;
 
-  // Make sure the non-plugin consumer is first, so that plugins can't
-  // modifiy the AST.
+  // Collect the list of plugins that go before the main action (in Consumers)
+  // or after it (in AfterConsumers)
   std::vector Consumers;
-  Consumers.push_back(std::move(Consumer));
-
-  for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size();
-   i != e; ++i) { 
-// This is O(|plugins| * |add_plugins|), but since both numbers are
-// way below 50 in practice, that's ok.
-for (FrontendPluginRegistry::iterator
-it = FrontendPluginRegistry::begin(),
-ie = FrontendPluginRegistry::end();
-it != ie; ++it) {
-  if (it->getName() != CI.getFrontendOpts().AddPluginActions[i])
-continue;
-  std::unique_ptr P = it->instantiate();
-  if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i]))
-Consumers.push_back(P->CreateASTConsumer(CI, InFile));
+  std::vector AfterConsumers;
+  for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
+ie = FrontendPluginRegistry::end();
+   it != ie; ++it) {
+std::unique_ptr P = it->instantiate();
+PluginASTAction::ActionType ActionType = P->getActionType();
+if (ActionType == PluginASTAction::Cmdline) {
+  // This is O(|plugins| * |add_plugins|), but since both numbers are
+  // way below 50 in practice, that's ok.
+  

Re: [PATCH] D17955: [OpenCL] Fix piep builtin bug

2016-03-08 Thread Mats Petersson via cfe-commits
MatsPetersson added a subscriber: MatsPetersson.
MatsPetersson added a comment.

Obvious typo in title. Pipe, not piep.


http://reviews.llvm.org/D17955



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


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-08 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. thank you!


http://reviews.llvm.org/D17908



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


[PATCH] D17955: [OpenCL] Fix piep builtin bug

2016-03-08 Thread Xiuli PAN via cfe-commits
pxli168 created this revision.
pxli168 added reviewers: Anastasia, yaxunl.
pxli168 added subscribers: cfe-commits, pekka.jaaskelainen.

1. Diag should be output if types are not the same.
2. Should compare using canonical type.
3. Refine the diag to be more clear.

http://reviews.llvm.org/D17955

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -323,10 +323,12 @@
   const PointerType *ArgTy = ArgIdx->getType()->getAs();
   // The Idx argument should be a pointer and the type of the pointer and
   // the type of pipe element should also be the same.
-  if (!ArgTy || S.Context.hasSameType(EltTy, ArgTy->getPointeeType())) {
+  if (!ArgTy ||
+  !S.Context.hasSameType(
+  EltTy, ArgTy->getPointeeType()->getCanonicalTypeInternal())) {
 S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
 << Call->getDirectCallee() << S.Context.getPointerType(EltTy)
-<< ArgIdx->getSourceRange();
+<< ArgIdx->getType() << ArgIdx->getSourceRange();
 return true;
   }
   return false;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7753,7 +7753,7 @@
 def err_opencl_builtin_pipe_arg_num : Error<
   "invalid number of arguments to function: %0">;
 def err_opencl_builtin_pipe_invalid_arg : Error<
-  "invalid argument type to function %0 (expecting %1)">;
+  "invalid argument type to function %0 (expecting %1 having %2)">;
 def err_opencl_builtin_pipe_invalid_access_modifier : Error<
   "invalid pipe access modifier (expecting %0)">;
 


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -323,10 +323,12 @@
   const PointerType *ArgTy = ArgIdx->getType()->getAs();
   // The Idx argument should be a pointer and the type of the pointer and
   // the type of pipe element should also be the same.
-  if (!ArgTy || S.Context.hasSameType(EltTy, ArgTy->getPointeeType())) {
+  if (!ArgTy ||
+  !S.Context.hasSameType(
+  EltTy, ArgTy->getPointeeType()->getCanonicalTypeInternal())) {
 S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
 << Call->getDirectCallee() << S.Context.getPointerType(EltTy)
-<< ArgIdx->getSourceRange();
+<< ArgIdx->getType() << ArgIdx->getSourceRange();
 return true;
   }
   return false;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7753,7 +7753,7 @@
 def err_opencl_builtin_pipe_arg_num : Error<
   "invalid number of arguments to function: %0">;
 def err_opencl_builtin_pipe_invalid_arg : Error<
-  "invalid argument type to function %0 (expecting %1)">;
+  "invalid argument type to function %0 (expecting %1 having %2)">;
 def err_opencl_builtin_pipe_invalid_access_modifier : Error<
   "invalid pipe access modifier (expecting %0)">;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 50032.
danielmarjamaki added a comment.

Updated documentation


http://reviews.llvm.org/D15332

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/NonConstParameterCheck.cpp
  clang-tidy/readability/NonConstParameterCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-non-const-parameter.rst
  test/clang-tidy/readability-non-const-parameter.cpp

Index: test/clang-tidy/readability-non-const-parameter.cpp
===
--- test/clang-tidy/readability-non-const-parameter.cpp
+++ test/clang-tidy/readability-non-const-parameter.cpp
@@ -0,0 +1,231 @@
+// RUN: %check_clang_tidy %s readability-non-const-parameter %t
+
+// Currently the checker only warns about pointer arguments.
+//
+// It can be defined both that the data is const and that the pointer is const,
+// the checker only checks if the data can be const-specified.
+//
+// It does not warn about pointers to records or function pointers.
+
+// Some external function where first argument is nonconst and second is const.
+char *strcpy1(char *dest, const char *src);
+unsigned my_strcpy(char *buf, const char *s);
+unsigned my_strlen(const char *buf);
+
+// CHECK-MESSAGES: :[[@LINE+1]]:29: warning: parameter 'last' can be const [readability-non-const-parameter]
+void warn1(int *first, int *last) {
+  // CHECK-FIXES: {{^}}void warn1(int *first, const int *last) {{{$}}
+  *first = 0;
+  if (first < last) {
+  } // <- last can be const
+}
+
+// TODO: warning should be written here
+void warn2(char *p) {
+  char buf[10];
+  strcpy1(buf, p);
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [readability-non-const-parameter]
+void assign1(int *p) {
+  // CHECK-FIXES: {{^}}void assign1(const int *p) {{{$}}
+  const int *q;
+  q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const [readability-non-const-parameter]
+void assign2(int *p) {
+  // CHECK-FIXES: {{^}}void assign2(const int *p) {{{$}}
+  const int *q;
+  q = p + 1;
+}
+
+void assign3(int *p) {
+  *p = 0;
+}
+
+void assign4(int *p) {
+  *p += 2;
+}
+
+void assign5(char *p) {
+  p[0] = 0;
+}
+
+void assign6(int *p) {
+  int *q;
+  q = p++;
+}
+
+void assign7(char *p) {
+  char *a, *b;
+  a = b = p;
+}
+
+void assign8(char *a, char *b) {
+  char *x;
+  x = (a ? a : b);
+}
+
+void assign9(unsigned char *str, const unsigned int i) {
+  unsigned char *p;
+  for (p = str + i; *p;) {
+  }
+}
+
+void assign10(int *buf) {
+  int i, *p;
+  for (i = 0, p = buf; i < 10; i++, p++) {
+*p = 1;
+  }
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [readability-non-const-parameter]
+void init1(int *p) {
+  // CHECK-FIXES: {{^}}void init1(const int *p) {{{$}}
+  const int *q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const [readability-non-const-parameter]
+void init2(int *p) {
+  // CHECK-FIXES: {{^}}void init2(const int *p) {{{$}}
+  const int *q = p + 1;
+}
+
+void init3(int *p) {
+  int *q = p;
+}
+
+void init4(float *p) {
+  int *q = (int *)p;
+}
+
+void init5(int *p) {
+  int *i = p ? p : 0;
+}
+
+void init6(int *p) {
+  int *a[] = {p, p, 0};
+}
+
+void init7(int *p, int x) {
+  for (int *q = p + x - 1; 0; q++)
+;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const [readability-non-const-parameter]
+int return1(int *p) {
+  // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [readability-non-const-parameter]
+const int *return2(int *p) {
+  // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const [readability-non-const-parameter]
+const int *return3(int *p) {
+  // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const [readability-non-const-parameter]
+const char *return4(char *p) {
+  // CHECK-FIXES: {{^}}const char *return4(const char *p) {{{$}}
+  return p ? p : "";
+}
+
+char *return5(char *s) {
+  return s;
+}
+
+char *return6(char *s) {
+  return s + 1;
+}
+
+char *return7(char *a, char *b) {
+  return a ? a : b;
+}
+
+char return8(int *p) {
+  return ++(*p);
+}
+
+void dontwarn1(int *p) {
+  ++(*p);
+}
+
+void dontwarn2(int *p) {
+  (*p)++;
+}
+
+int dontwarn3(_Atomic(int) * p) {
+  return *p;
+}
+
+void callFunction1(char *p) {
+  strcpy1(p, "abc");
+}
+
+void callFunction2(char *p) {
+  strcpy1([0], "abc");
+}
+
+void callFunction3(char *p) {
+  strcpy1(p + 2, "abc");
+}
+
+char *callFunction4(char *p) {
+  return strcpy1(p, "abc");
+}
+
+unsigned callFunction5(char *buf) {
+  unsigned len = my_strlen(buf);
+  return len + my_strcpy(buf, "abc");
+}
+
+void f6(int **p);
+void 

r262922 - Bump libclang API version after r262318

2016-03-08 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Mar  8 04:34:23 2016
New Revision: 262922

URL: http://llvm.org/viewvc/llvm-project?rev=262922=rev
Log:
Bump libclang API version after r262318

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=262922=262921=262922=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Mar  8 04:34:23 2016
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 33
+#define CINDEX_VERSION_MINOR 34
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \


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


r262921 - Sema: Methods in unavailable classes are unavailable

2016-03-08 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Mar  8 04:28:52 2016
New Revision: 262921

URL: http://llvm.org/viewvc/llvm-project?rev=262921=rev
Log:
Sema: Methods in unavailable classes are unavailable

Similar to the template cases in r262050, when a C++ method in an
unavailable struct/class calls unavailable API, don't diagnose an error.
I.e., this case was failing:

void foo() __attribute__((unavailable));
struct __attribute__((unavailable)) A {
  void bar() { foo(); }
};

Since A is unavailable, A::bar is allowed to call foo.  However, we were
emitting a diagnostic here.  This commit checks up the context chain
from A::bar, in a manner inspired by SemaDeclAttr.cpp:isDeclUnavailable.

I expected to find other related issues but failed to trigger them:

- I wondered if DeclBase::getAvailability should check for
  `TemplateDecl` instead of `FunctionTemplateDecl`, but I couldn't find
  a way to trigger this.  I left behind a few extra tests to make sure
  we don't regress.

- I wondered if Sema::isFunctionConsideredUnavailable should be
  symmetric, checking up the context chain of the callee (this commit
  only checks up the context chain of the caller).  However, I couldn't
  think of a testcase that didn't require first referencing the
  unavailable type; this, we already diagnose.

rdar://problem/25030656

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/attr-unavailable.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=262921=262920=262921=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Mar  8 04:28:52 2016
@@ -1150,7 +1150,16 @@ bool Sema::IsOverload(FunctionDecl *New,
 /// \returns true if \arg FD is unavailable and current context is inside
 /// an available function, false otherwise.
 bool Sema::isFunctionConsideredUnavailable(FunctionDecl *FD) {
-  return FD->isUnavailable() && !cast(CurContext)->isUnavailable();
+  if (!FD->isUnavailable())
+return false;
+
+  // Walk up the context of the caller.
+  Decl *C = cast(CurContext);
+  do {
+if (C->isUnavailable())
+  return false;
+  } while ((C = cast_or_null(C->getDeclContext(;
+  return true;
 }
 
 /// \brief Tries a user-defined conversion from From to ToType.

Modified: cfe/trunk/test/SemaCXX/attr-unavailable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-unavailable.cpp?rev=262921=262920=262921=diff
==
--- cfe/trunk/test/SemaCXX/attr-unavailable.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-unavailable.cpp Tue Mar  8 04:28:52 2016
@@ -116,3 +116,26 @@ void calls_unavail_templated() {
 void unavail_calls_unavail_templated() __attribute__((unavailable)) {
   unavail_templated(5);
 }
+
+void unavailable() __attribute((unavailable)); // \
+   expected-note 4{{candidate function has been explicitly made 
unavailable}}
+struct AvailableStruct {
+  void calls_unavailable() { unavailable(); } // \
+  expected-error{{call to unavailable function 'unavailable'}}
+  template  void calls_unavailable() { unavailable(); } // \
+  expected-error{{call to unavailable function 'unavailable'}}
+};
+template  struct AvailableStructTemplated {
+  void calls_unavailable() { unavailable(); } // \
+  expected-error{{call to unavailable function 'unavailable'}}
+  template  void calls_unavailable() { unavailable(); } // \
+  expected-error{{call to unavailable function 'unavailable'}}
+};
+struct __attribute__((unavailable)) UnavailableStruct {
+  void calls_unavailable() { unavailable(); }
+  template  void calls_unavailable() { unavailable(); }
+};
+template  struct __attribute__((unavailable)) 
UnavailableStructTemplated {
+  void calls_unavailable() { unavailable(); }
+  template  void calls_unavailable() { unavailable(); }
+};


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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-08 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:3
@@ +2,3 @@
+
+// Currently the checker only warns about pointer arguments.
+//

LegalizeAdulthood wrote:
> danielmarjamaki wrote:
> > LegalizeAdulthood wrote:
> > > How hard is it to extend it to references?
> > > 
> > > Certainly the confusion about what is const is easier to resolve in the 
> > > case of references because the references themselves are immutable.
> > If a "int &" reference parameter is not written then probably it's better 
> > to pass it by value than making it const. I would prefer that unless it has 
> > to use "int &" to comply with some interface.
> > 
> > I realize that the same can be said about pointers. If there is a "int *p" 
> > and you just read the value that p points at .. maybe sometimes it would be 
> > preferable to pass it by value.
> I thought the point of this check was to identify stuff passed by 
> reference/pointer that could instead be passed by const reference/pointer.
> 
> Passing a read-only number type (`short`, `char`, `int`, `float`, `double`, 
> etc.) parameter by pointer or by reference/pointer is a code smell, but this 
> check isn't trying to identify that situation.
> 
> I'm more interested in things like:
> 
> ```
> void foo(std::string );
> ```
> 
> becoming
> 
> ```
> void foo(const std::string );
> ```
> 
> when `s` is treated as a read-only value within the implementation of `foo`.
I agree pointers and references are related from user perspective.

But technically I think we can't reuse the same markCanNotBeConst code.

This expression "p += 2" does not prevent that *p is const. But "r += 2" would 
prevent that the reference r is const.

> I'm more interested in things like:

Yes that would be interesting. However I only warn about number types right 
now. As my last example in the rst file shows I don't warn for non-constant 
struct pointers for a reason.

Imho, I would like to have a warning when the data is modified even though *p 
is const. Like this:

  struct S { int *a; int *b; };
  int f3(const struct S * const p) {
*(p->a) = 0; // <- I would like to have warning here
  }

Also dealing with C++ is not my priority. I write this check so I can use it on 
C code.



http://reviews.llvm.org/D15332



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


Re: [PATCH] D17226: libclang python bindings: Fix for bug 26394

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev accepted this revision.
skalinichev added a comment.
This revision is now accepted and ready to land.

Yes, I've seen that python tests segfaulted too, never had time to investigate 
it though.

LGTM, great work!


Repository:
  rL LLVM

http://reviews.llvm.org/D17226



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


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Generally looks pretty good to me. Maybe it's worth to factor out duplicating 
code, but I guess it's not so important.

Also the index-file.cpp test failing for me:
test/Index/index-file.cpp:57:11: error: expected string not found in input
// CHECK: [indexDeclaration]: kind: c++-instance-method | name: foo | {{.*}} 
(deleted) | loc: 36:8

@jbcoe, can you take a look?


http://reviews.llvm.org/D15469



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


Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-08 Thread Sergey Kalinichev via cfe-commits
skalinichev updated the summary for this revision.
skalinichev added reviewers: milianw, kfunk.
skalinichev updated this revision to Diff 50027.
skalinichev added a comment.

Ok, after some more testing I found out that elaborated types can have cv 
specifiers attached, but after using ET->getNamedType() we lose that 
information. So obviously the previous solution was wrong. Therefore I'm 
falling back to the original idea here once again: exposing the elaborated 
type. Also extending tests to account for the found bug.


http://reviews.llvm.org/D11797

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/print-type.c
  test/Index/print-type.cpp
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -212,6 +212,7 @@
 clang_getLocation
 clang_getLocationForOffset
 clang_getModuleForFile
+clang_getNamedTypeUnderlyingElaboratedType
 clang_getNullCursor
 clang_getNullLocation
 clang_getNullRange
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -91,6 +91,7 @@
 TKCASE(Vector);
 TKCASE(MemberPointer);
 TKCASE(Auto);
+TKCASE(Elaborated);
 default:
   return CXType_Unexposed;
   }
@@ -491,6 +492,7 @@
 TKIND(Vector);
 TKIND(MemberPointer);
 TKIND(Auto);
+TKIND(Elaborated);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -985,4 +987,14 @@
   return 0;
 }
 
+CXType clang_getNamedTypeUnderlyingElaboratedType(CXType CT){
+  QualType T = GetQualType(CT);
+  const Type *TP = T.getTypePtrOrNull();
+
+  if (TP && TP->getTypeClass() == Type::Elaborated)
+return MakeCXType(cast(TP)->getNamedType(), GetTU(CT));
+
+  return MakeCXType(QualType(), GetTU(CT));
+}
+
 } // end: extern "C"
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0]
@@ -127,6 +127,10 @@
 // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2]
 // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type (const NS::Type)] [typekind=FunctionProto] [canonicaltype=NS::Type (NS::Type)] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [args= [const NS::Type] [Elaborated]] [isPOD=0]
+// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0]
+// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1]
+// CHECK: ParmDecl=t:51:81 (Definition) [type=const NS::Type] [typekind=Elaborated] const [canonicaltype=const NS::Type] [canonicaltypekind=Record] [isPOD=1]
 // CHECK: VarDecl=autoI:53:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:54:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
Index: test/Index/print-type.c
===
--- test/Index/print-type.c
+++ test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: