Re: [PATCH] D16079: [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 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.

-eric


http://reviews.llvm.org/D16079



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


Re: [PATCH] D16078: Add an Action* member to InputInfo.

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

Sure. Seems reasonable.

-eric


http://reviews.llvm.org/D16078



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


Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Eric Christopher via cfe-commits
echristo added a comment.

One question inline, one nit, and one more question here: You've got a couple 
of checks inline for null names/architectures, where do you expect those to 
come from and can you test for them? Or, another question, is if they're 
multiple architectures shouldn't we be able to see all of the actions that 
arise from each gpu?

Or I'm missing something, either way an explanation is good. :)

-eric



Comment at: lib/Driver/Driver.cpp:1880
@@ +1879,3 @@
+// retrieve the Input's GPU arch.
+II.setAction(A);
+return II;

Weren't you just adding it as part of the InputInfo constructor in 16078?


Comment at: lib/Driver/ToolChains.cpp:4261
@@ -4255,2 +4260,3 @@
 
-  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ), BoundArch);
+  if (BoundArch) {
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ), 
BoundArch);

Nit: No braces around single lines.


http://reviews.llvm.org/D16082



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


Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257407: Move ownership of Action objects into Compilation. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D15911?vs=44379=44566#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15911

Files:
  cfe/trunk/include/clang/Driver/Action.h
  cfe/trunk/include/clang/Driver/Compilation.h
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Action.cpp
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/lib/Driver/Driver.cpp

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1049,19 +1049,15 @@
   << types::getTypeName(Act->getType());
 
 ActionList Inputs;
-for (unsigned i = 0, e = Archs.size(); i != e; ++i) {
-  Inputs.push_back(
-  new BindArchAction(std::unique_ptr(Act), Archs[i]));
-  if (i != 0)
-Inputs.back()->setOwnsInputs(false);
-}
+for (unsigned i = 0, e = Archs.size(); i != e; ++i)
+  Inputs.push_back(C.MakeAction(Act, Archs[i]));
 
 // Lipo if necessary, we do it this way because we need to set the arch flag
 // so that -Xarch_ gets overwritten.
 if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing)
   Actions.append(Inputs.begin(), Inputs.end());
 else
-  Actions.push_back(new LipoJobAction(Inputs, Act->getType()));
+  Actions.push_back(C.MakeAction(Inputs, Act->getType()));
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
@@ -1077,15 +1073,16 @@
 ActionList Inputs;
 Inputs.push_back(Actions.back());
 Actions.pop_back();
-Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM));
+Actions.push_back(
+C.MakeAction(Inputs, types::TY_dSYM));
   }
 
   // Verify the debug info output.
   if (Args.hasArg(options::OPT_verify_debug_info)) {
-std::unique_ptr VerifyInput(Actions.back());
+Action* LastAction = Actions.back();
 Actions.pop_back();
-Actions.push_back(new VerifyDebugInfoJobAction(std::move(VerifyInput),
-   types::TY_Nothing));
+Actions.push_back(C.MakeAction(
+LastAction, types::TY_Nothing));
   }
 }
   }
@@ -1283,16 +1280,15 @@
 // Actions and /p Current is released. Otherwise the function creates
 // and returns a new CudaHostAction which wraps /p Current and device
 // side actions.
-static std::unique_ptr
-buildCudaActions(Compilation , DerivedArgList , const Arg *InputArg,
- std::unique_ptr HostAction, ActionList ) {
+static Action *buildCudaActions(Compilation , DerivedArgList ,
+const Arg *InputArg, Action *HostAction,
+ActionList ) {
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return C.MakeAction(HostAction, ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1347,26 +1343,25 @@
 }
 
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-  Actions.push_back(new CudaDeviceAction(
-  std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-  /* AtTopLevel */ true));
+  Actions.push_back(C.MakeAction(CudaDeviceActions[I],
+   GpuArchList[I],
+   /* AtTopLevel */ true));
 // Kill host action in case of device-only compilation.
 if (DeviceOnlyCompilation)
-  HostAction.reset(nullptr);
+  return nullptr;
 return HostAction;
   }
 
   // Outputs of device actions during complete CUDA compilation get created
   // with AtTopLevel=false and become inputs for the host action.
   ActionList DeviceActions;
   for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-DeviceActions.push_back(new CudaDeviceAction(
-std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-/* AtTopLevel */ false));
+DeviceActions.push_back(
+C.MakeAction(CudaDeviceActions[I], GpuArchList[I],
+   /* AtTopLevel */ false));
   // Return a new host action that incorporates original host action and all
   // device actions.
-  return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  return C.MakeAction(HostAction, DeviceActions);
 }
 
 void Driver::BuildActions(Compilation , const ToolChain ,
@@ -1474,7 +1469,7 @@
  

Re: [PATCH] D16079: [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 Thread Eric Christopher via cfe-commits
echristo added a comment.

Yep it's fine. Thanks!

-eric


http://reviews.llvm.org/D16079



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


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-11 Thread Rafael Espíndola via cfe-commits
On 8 January 2016 at 19:50, Duncan P. N. Exon Smith via cfe-commits
 wrote:
> [re-send to lists.llvm.org]
> [necromancy]
>
> This is causing some strangeness for users of libc++ headers that
> ship dylibs and build with -fno-rtti and -fvisibility=hidden.
>
> Strangely, -fno-rtti does *not* imply -fno-exceptions; the type info
> needed for exceptions is generated on-the-fly.  This means that each
> translation unit generates a linkonce_odr copy of the std::exception
> type info -- weird, but kind of reasonable?

Will gcc produce a copy too? It seems really strange to produce
different linkages for -frtti and -fno-rtti -fexcptions.

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


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-11 Thread Rafael Espíndola via cfe-commits
> I'm not sure about GCC.  Note that there is no linkage for -frtti,
> since the type info is deferred to the TU with the vtable.

Yes, that is what I mean. It is odd that -frtti changes us from "this
is not available anywhere, use linkonce_odr" to "it is available
elsewhere, use an external declaration".

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


Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D16082#324138, @tra wrote:

> Make sure it works with -save-temps and -fintegrated-as/-fno-integrated-as. 
> They tend to throw wrenches into pipeline construction.


Thanks.  All of them worked except -fintegrated-as, which was causing us not to 
invoke ptxas.  Fixed, and added a test.



Comment at: lib/Driver/Driver.cpp:1380
@@ +1379,3 @@
+  C.MakeAction(DeviceActions, types::TY_CUDA_FATBIN),
+  /* GpuArchName = */ nullptr,
+  /* AtTopLevel = */ false);

tra wrote:
> So, you're treating GpuArchName==nullptr as a special case of DeviceAction 
> for fatbin?
> Perhaps it warrants its own CudaDeviceLinkAction?
It's a special case either way, but there are enough places that look for a 
CudaDeviceAction that I *think* this special case is cleaner than having a 
bunch of if (CudaDeviceAction || CudaDeviceLinkAction)s floating around.


Comment at: lib/Driver/Driver.cpp:1620-1625
@@ -1602,3 +1619,8 @@
   case phases::Assemble:
-return C.MakeAction(Input, types::TY_Object);
+// Assembling generates an object file, except when we're assembling CUDA,
+// in which case we get a cubin file.
+return C.MakeAction(
+std::move(Input), TC.getTriple().getOS() == llvm::Triple::CUDA
+  ? types::TY_CUDA_CUBIN
+  : types::TY_Object);
   }

tra wrote:
> cubin *is* an ELF object file. Do we really need a new type here or can we 
> get by with TY_Object?
Got rid of the extra type.  Note that this means that our intermediate objs 
will be named foo.o instead of foo.cubin, which isn't optimal, but I agree that 
it's simpler without the extra type.


Comment at: lib/Driver/Driver.cpp:1880
@@ +1879,3 @@
+// retrieve the Input's GPU arch.
+II.setAction(A);
+return II;

echristo wrote:
> Weren't you just adding it as part of the InputInfo constructor in 16078?
Yes, but we're doing something slightly different here.  Suppose you have a 
CudaDeviceAction --> BackendAction.  What do you want the InputInfo's Action to 
be?  Without this change, it's the BackendAction.  But we really want it to be 
the CudaDeviceAction.  Thus this line.

I updated the comment in an attempt to clarify.


Comment at: lib/Driver/ToolChains.cpp:4230
@@ -4224,3 +4229,3 @@
   // Skip this argument unless the architecture matches BoundArch
-  if (A->getValue(0) != StringRef(BoundArch))
+  if (!BoundArch || A->getValue(0) != StringRef(BoundArch))
 continue;

tra wrote:
> You may as well move it out of the loop and return early if BoundArch is 
> nullptr.
Tried this and discovered it's actually subtly different in a way that, 
thankfully, affects one of the tests I added.

if (!BoundArch) continue applies only if 
A->getOption().matches(options::OPT_Xarch__).  So we can't hoist it into an 
early return.


Comment at: lib/Driver/Tools.cpp:10677-10678
@@ +10676,4 @@
+std::string Arch = A->getGpuArchName();
+// We need to name pass an Arch of the form "sm_XX" for cubin files and
+// "compute_XX" for ptx.  CudaDeviceAction's getGpuArchName() is guaranteed
+// to match "sm_XX".

tra wrote:
> First line does not parse.
> 
> In general compute_XX does not necessarily match sm_XX.
> [[ http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#ptxas-options | 
> ptxas options ]] says that 
> 
> > Allowed values for this option: compute_20, compute_30, compute_35, 
> > compute_50, compute_52; and sm_20, sm_21, sm_30, sm_32, sm_35, sm_50 and 
> > sm_52
> 
> Note that there's no compute_21, compute_32. You'll need sm_XX -> compute_YY 
> map.
> 
> 
Oh goodness, how awful.  Thank you for catching that.  Fixed.


http://reviews.llvm.org/D16082



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


Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44584.
jlebar marked 8 inline comments as done.
jlebar added a comment.

Address tra, echristo's review comments.


http://reviews.llvm.org/D16082

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  include/clang/Driver/Types.def
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Driver/Types.cpp
  test/Driver/Inputs/CUDA/usr/local/cuda/bin/.keep
  test/Driver/cuda-external-tools.cu
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -39,13 +39,6 @@
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Verify that with -S we compile host and device sides to assembly and
-// incorporate device code into the host side.
-// RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
-
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
@@ -61,7 +54,7 @@
 // RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
 // RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix INCLUDES-DEVICE2 -check-prefix NOLINK %s
+// RUN:-check-prefix NOLINK %s
 
 // Verify that device-side results are passed to the correct tool when
 // -save-temps is used.
@@ -92,10 +85,16 @@
 // DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE-SAME: "-fcuda-is-device"
 // DEVICE-SM35-SAME: "-target-cpu" "sm_35"
-// DEVICE-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
+// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
 // DEVICE-NOSAVE-SAME: "-x" "cuda"
 // DEVICE-SAVE-SAME: "-x" "ir"
 
+// Match the call to ptxas (which assembles PTX to SASS).
+// DEVICE:ptxas
+// DEVICE-SM35-DAG: "--gpu-name" "sm_35"
+// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
+// DEVICE-DAG: "[[PTXFILE]]"
+
 // Match another device-side compilation.
 // DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -108,6 +107,11 @@
 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // NODEVICE-SAME-NOT: "-fcuda-is-device"
 
+// INCLUDES-DEVICE:fatbinary
+// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
+
 // Match host-side preprocessor job with -save-temps.
 // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
 // HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
@@ -121,8 +125,7 @@
 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // HOST-NOSAVE-SAME: "-x" "cuda"
 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
-// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
-// INCLUDES-DEVICE2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
+// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
 
 // Match external assembler that uses compilation output.
 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Index: test/Driver/cuda-external-tools.cu
===
--- /dev/null
+++ test/Driver/cuda-external-tools.cu
@@ -0,0 +1,70 @@
+// Tests that ptxas and fatbinary are correctly during CUDA compilation.
+//
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Regular compile with -O2.
+// RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 %s
+
+// Regular compile without -O.  This should result in us passing -O0 to ptxas.
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+
+// Regular compile targeting sm_35.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
+
+// 32-bit compile.
+// RUN: %clang -### -target x86_32-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH32 -check-prefix SM20 %s
+
+// Compile with -fintegrated-as.  This should still cause us to invoke ptxas.
+// RUN: %clang -### -target x86_64-linux-gnu -fintegrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+
+// Check -Xcuda-ptxas and -Xcuda-fatbinary
+// RUN: %clang -### -target x86_64-linux-gnu -c -Xcuda-ptxas 

Re: [PATCH] D9600: Add scan-build python implementation

2016-01-11 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.

Laszlo,

I am very excited about having the new and much improved scan-build in tree! It 
will serve as a solid foundation for moving forward.

Thank you for all your hard work!
Anna.


http://reviews.llvm.org/D9600



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


RE: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-11 Thread Robinson, Paul via cfe-commits
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Duncan P. N. Exon Smith via cfe-commits
> Sent: Monday, January 11, 2016 4:21 PM
> To: Rafael Espíndola
> Cc: Marshall Clow; CFE Commits
> Subject: Re: [libcxx] r196411 - Give all members of exception types
> default visibility. Lack of this is causing some illegal code relocations
> rare and hard to reproduce cases.
> 
> 
> > On 2016-Jan-11, at 15:57, Rafael Espíndola 
> wrote:
> >
> >> I'm not sure about GCC.  Note that there is no linkage for -frtti,
> >> since the type info is deferred to the TU with the vtable.
> >
> > Yes, that is what I mean. It is odd that -frtti changes us from "this
> > is not available anywhere, use linkonce_odr" to "it is available
> > elsewhere, use an external declaration".
> 
> Yes, I agree, it's weird (although the transition is in the other
> direction, really, since there's no such flag as -frtti, just -fno-rtti).

Drive-by comment:
Actually there is -frtti, it's just not defined next to -fno-rtti in
Options.td for some reason.

> -fexceptions -fno-rtti is a weird combination to begin with though.

Yup. So weird that PS4 goes to the trouble of forbidding it... that
doesn't help here, unfortunately.
--paulr

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


Re: [PATCH] D15208: Patch for inline abort code generation

2016-01-11 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

Sorry for delay.



Comment at: lib/CodeGen/CGExpr.cpp:2543
@@ +2542,3 @@
+  // RE: Bug: 25682
+  if(!CGM.getCodeGenOpts().MergeTraps || 
!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+// If we aren't merging traps, set the function to not be optimized as some

This condition is somewhat hard to parse. Consider inverting it:
  // Collapse all trap calls to one per function if we're optimizing, and 
  if (TrapBB && CGM.getCodeGenOpts().OptimizationLevel && 
CGM.getCodeGenOpts().MergeTraps) {
Builder.CreateCondBr(Checked, Cont, TrapBB);
  } else {
 //...
  }


Comment at: lib/CodeGen/CGExpr.cpp:2557
@@ +2556,3 @@
+  // This closely mirrors what is done to avoid function merging
+  // in the address sanitizer. The trap function is not set
+  // to not return as there is an unreachable instruction

Nit: AddressSanitizer, or ASan.


Comment at: lib/CodeGen/CGExpr.cpp:2558
@@ +2557,3 @@
+  // in the address sanitizer. The trap function is not set
+  // to not return as there is an unreachable instruction
+  // generated at the end of the block.

What's wrong with marking trap function as noreturn anyway? unreachable 
instruction is, well, supposed to be unreachable.


Comment at: lib/CodeGen/CGExpr.cpp:2560
@@ +2559,3 @@
+  // generated at the end of the block.
+  EmitTrapCall(llvm::Intrinsic::trap);
+  llvm::InlineAsm *EmptyAsm = 
llvm::InlineAsm::get(llvm::FunctionType::get(Builder.getVoidTy(), false),

This can also be hoisted from branches.


Repository:
  rL LLVM

http://reviews.llvm.org/D15208



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


Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44585.
jlebar added a comment.

Update to latest set of architectures, according to ptxas --help from cuda 7.5.


http://reviews.llvm.org/D16097

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  test/Driver/cuda-bad-arch.cu

Index: test/Driver/cuda-bad-arch.cu
===
--- test/Driver/cuda-bad-arch.cu
+++ test/Driver/cuda-bad-arch.cu
@@ -5,28 +5,16 @@
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_19 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
 
 // BAD: error: Unsupported CUDA gpu architecture
 
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix OK %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 
\
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -50,6 +50,24 @@
 BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
 : Action(BindArchClass, Input), ArchName(_ArchName) {}
 
+// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual
+// compute arch, e.g. "compute_20".  Returns null if the input arch is null or
+// doesn't match an existing arch.
+static const char* GpuArchToComputeName(const char *ArchName) {
+  if (!ArchName)
+return nullptr;
+  llvm::StringRef A(ArchName);
+  if (A == "sm_20" || A == "sm_21") return "compute_20";
+  if (A == "sm_30") return "compute_30";
+  if (A == "sm_32") return "compute_32";
+  if (A == "sm_35") return "compute_35";
+  if (A == "sm_37") return "compute_37";
+  if (A == "sm_50") return "compute_50";
+  if (A == "sm_52") return "compute_52";
+  if (A == "sm_53") return "compute_53";
+  return nullptr;
+}
+
 void CudaDeviceAction::anchor() {}
 
 CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName,
@@ -59,9 +77,12 @@
   assert(IsValidGpuArchName(GpuArchName));
 }
 
+const char *CudaDeviceAction::getComputeArchName() const {
+  return GpuArchToComputeName(GpuArchName);
+}
+
 bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) {
-  static llvm::Regex RE("^sm_[0-9]+$");
-  return RE.match(ArchName);
+  return GpuArchToComputeName(ArchName.data()) != nullptr;
 }
 
 void CudaHostAction::anchor() {}
Index: include/clang/Driver/Action.h
===
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -146,6 +146,10 @@
   CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel);
 
   const char *getGpuArchName() const { return GpuArchName; }
+
+  /// Gets the compute_XX that corresponds to getGpuArchName().
+  const char *getComputeArchName() const;
+
   bool isAtTopLevel() const { return AtTopLevel; }
 
   static bool IsValidGpuArchName(llvm::StringRef ArchName);


Index: test/Driver/cuda-bad-arch.cu
===
--- test/Driver/cuda-bad-arch.cu
+++ test/Driver/cuda-bad-arch.cu
@@ -5,28 +5,16 @@
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix BAD %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu 

Re: [PATCH] D16041: Change vfs::FileSystem to be managed with std::shared_ptr

2016-01-11 Thread Owen Anderson via cfe-commits

> On Jan 11, 2016, at 2:13 PM, Benjamin Kramer  wrote:
> 
> On Mon, Jan 11, 2016 at 8:08 PM, Owen Anderson  > wrote:
>> 
>>> On Jan 11, 2016, at 8:25 AM, David Blaikie  wrote:
>>> 
>>> 
>>> 
>>> On Sun, Jan 10, 2016 at 11:42 PM, Owen Anderson via cfe-commits 
>>>  wrote:
>>> resistor created this revision.
>>> resistor added reviewers: chandlerc, bkramer, klimek.
>>> resistor added a subscriber: cfe-commits.
>>> resistor set the repository for this revision to rL LLVM.
>>> Herald added a subscriber: klimek.
>>> 
>>> Managing it with IntrusiveRefCntPtr caused the virtual destructor not to be 
>>> called properly.
>>> 
>>> Regardless of the broader discussion on this patch, I'm confused by why 
>>> this ^ would be the case. What is it that IntrusiveRefCntPtr is doing 
>>> that's causing problems with destruction? (& I'm all for changing this to 
>>> non-intrusive smart pointers over intrusive ones anyway, but I'd still like 
>>> to understand the extra motivation here)
>>> 
>> 
>> ThreadSafeRefCountedBase, which classes must inherit from in order to use 
>> IntrusiveRefCntPtr, does not handle virtual destructors properly.  For the 
>> non-thread safe version, there is RefCountBaseVPTR which solves this 
>> problem.  An alternative solution would have been to add a corresponding 
>> ThreadSafeRefCountedBaseVPTR, but IMO at that point one might as well use 
>> shared_ptr since it’s 90% of the way there.
> 
> I find this surprising. ThreadSafeRefCountedBase calls
> "delete static_cast(this)". As FileSystem has a
> virtual dtor, polymorphic deletion should just work. Am I missing
> something?

I’m not an expert on this stuff, but I’ll refer you to the difference between 
RefCountedBase and RefCountedBaseVPTR, and point out that 
ThreadSafeRefCountedBase is like the former rather than the latter.

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


r257406 - clang-format: [JS] Teach clang-format about "export interface".

2016-01-11 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 11 16:57:40 2016
New Revision: 257406

URL: http://llvm.org/viewvc/llvm-project?rev=257406=rev
Log:
clang-format: [JS] Teach clang-format about "export interface".

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=257406=257405=257406=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jan 11 16:57:40 2016
@@ -1810,7 +1810,8 @@ void UnwrappedLineParser::parseJavaScrip
   }
 
   if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum,
- Keywords.kw_let, Keywords.kw_var))
+ Keywords.kw_interface, Keywords.kw_let,
+ Keywords.kw_var))
 return; // Fall through to parsing the corresponding structure.
 
   while (!eof() && FormatTok->isNot(tok::semi)) {

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257406=257405=257406=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 11 16:57:40 2016
@@ -900,6 +900,10 @@ TEST_F(FormatTestJS, Modules) {
"];");
   verifyFormat("export default [];");
   verifyFormat("export default () => {};");
+  verifyFormat("export interface Foo { foo: number; }\n"
+   "export class Bar {\n"
+   "  blah(): string { return this.blah; };\n"
+   "}");
 }
 
 TEST_F(FormatTestJS, TemplateStrings) {


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


Re: [libcxx] [PATCH] unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-11 Thread Duncan P. N. Exon Smith via cfe-commits
ping

> On 2016-Jan-04, at 12:37, Duncan P. N. Exon Smith  
> wrote:
> 
> ping
> 
>> On 2015-Dec-17, at 13:56, Duncan P. N. Exon Smith  
>> wrote:
>> 
>> 
>>> On 2015-Dec-16, at 14:42, Duncan P. N. Exon Smith  
>>> wrote:
>>> 
>>> This is a follow-up to r239666: "Fix PR12999 - unordered_set::insert
>>> calls operator new when no insert occurs".  That fix didn't apply to
>>> `unordered_map` because unordered_map::value_type gets packed inside:
>>> --
>>> union __value_type {
>>> pair __nc;   // Only C++11 or higher.
>>> pair __cc; // Always.
>>> // Constructors...
>>> };
>>> --
>>> and the underlying __hash_table only knows about __value_type.
>> 
>> Sorry for the quick ping, but I realized this morning that my approach
>> was still leaving mallocs on the table.
>> 
>> I've attached a new patch that handles more cases.
>> 
>> This patch should avoid unnecessary mallocs whenever the caller passes
>> in a pair such that T is trivially convertible to key_type.
>> 
>> Since __hash_table's value_type is really *never* a pair (for
>> unordered_map, it's a union of two pairs) the static dispatch is all in
>> unordered_map.  It's doing this:
>> - If the argument isn't a pair<>, alloc.
>> - If argument.first can be referenced as const key_type&, don't alloc.
>> - If argument.first can be trivially converted to key_type, don't
>>   alloc.
>> - Else alloc.
>> 
>> In the pre-C++11 world the caller has already converted to
>> unordered_map::value_type.  We can always avoid the alloc.
>> 
>> To support all of this:
>> - In C++03, __unordered_map_equal and __unordered_map_hasher need to
>>   handle unordered_map::value_type.
>> - In C++03, __hash_table::__insert_unique_value() now takes its
>>   argument by template.
>> - In C++11, __hash_table::__insert_unique_value() is now a one-liner
>>   that forwards to __insert_unique_key_value() for the real work.
>> - The versions of __hash_table::__construct_node() that take a
>>   pre-computed hash have been renamed to __construct_node_hash(), and
>>   these versions use perfect forwarding.
>> 
>> Most of the following still apply:
>> 
>>> This is one of my first patches for libc++, and I'm not sure of a few
>>> things:
>>> - Did I successfully match the coding style?  (I'm kind of lost
>>>  without clang-format TBH.)
>>> - Should I separate the change to __construct_node_hash() into a
>>>  separate prep commit?  (I would if this were LLVM, but I'm not sure
>>>  if the common practice is different for libc++.)
>>> - Most of the overloads I added to __unordered_map_hasher and
>>>  __unordered_map_equal aren't actually used by
>>>  __hash_table::__insert_unique_value().  Should I omit the unused
>>>  ones?  (Again, for LLVM I would have omitted them.)
>> 
>> (For the updated patch, I went with the LLVM approach of only adding
>> the used API.  It seems more appropriate in this case.)
>> 
>>> After this I'll fix the same performance issue in std::map (and I
>>> assume std::set?).
> 
> <0001-unordered_map-Avoid-unnecessary-mallocs-when-no-i-v2.patch>

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


r257408 - Make Driver::BuildJobsForAction return an InputInfo, instead of using an outparam.

2016-01-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Jan 11 17:09:32 2016
New Revision: 257408

URL: http://llvm.org/viewvc/llvm-project?rev=257408=rev
Log:
Make Driver::BuildJobsForAction return an InputInfo, instead of using an 
outparam.

Summary: Explicit is better than implicit.

Reviewers: echristo

Subscribers: llvm-commits

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

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=257408=257407=257408=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Jan 11 17:09:32 2016
@@ -380,15 +380,11 @@ public:
Action *Input) const;
 
   /// BuildJobsForAction - Construct the jobs to perform for the
-  /// action \p A.
-  void BuildJobsForAction(Compilation ,
-  const Action *A,
-  const ToolChain *TC,
-  const char *BoundArch,
-  bool AtTopLevel,
-  bool MultipleArchs,
-  const char *LinkingOutput,
-  InputInfo ) const;
+  /// action \p A and return an InputInfo for the result of running \p A.
+  InputInfo BuildJobsForAction(Compilation , const Action *A,
+   const ToolChain *TC, const char *BoundArch,
+   bool AtTopLevel, bool MultipleArchs,
+   const char *LinkingOutput) const;
 
   /// Returns the default name for linked images (e.g., "a.out").
   const char *getDefaultImageName() const;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257408=257407=257408=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jan 11 17:09:32 2016
@@ -1643,12 +1643,11 @@ void Driver::BuildJobs(Compilation ) c
 LinkingOutput = getDefaultImageName();
 }
 
-InputInfo II;
 BuildJobsForAction(C, A, (),
/*BoundArch*/ nullptr,
/*AtTopLevel*/ true,
/*MultipleArchs*/ ArchNames.size() > 1,
-   /*LinkingOutput*/ LinkingOutput, II);
+   /*LinkingOutput*/ LinkingOutput);
   }
 
   // If the user passed -Qunused-arguments or there were errors, don't warn
@@ -1776,21 +1775,19 @@ static const Tool *selectToolForJob(Comp
   return ToolForJob;
 }
 
-void Driver::BuildJobsForAction(Compilation , const Action *A,
-const ToolChain *TC, const char *BoundArch,
-bool AtTopLevel, bool MultipleArchs,
-const char *LinkingOutput,
-InputInfo ) const {
+InputInfo Driver::BuildJobsForAction(Compilation , const Action *A,
+ const ToolChain *TC, const char 
*BoundArch,
+ bool AtTopLevel, bool MultipleArchs,
+ const char *LinkingOutput) const {
   llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
 
   InputInfoList CudaDeviceInputInfos;
   if (const CudaHostAction *CHA = dyn_cast(A)) {
-InputInfo II;
 // Append outputs of device jobs to the input list.
 for (const Action *DA : CHA->getDeviceActions()) {
-  BuildJobsForAction(C, DA, TC, nullptr, AtTopLevel,
- /*MultipleArchs*/ false, LinkingOutput, II);
-  CudaDeviceInputInfos.push_back(II);
+  CudaDeviceInputInfos.push_back(
+  BuildJobsForAction(C, DA, TC, nullptr, AtTopLevel,
+ /*MultipleArchs*/ false, LinkingOutput));
 }
 // Override current action with a real host compile action and continue
 // processing it.
@@ -1804,11 +1801,9 @@ void Driver::BuildJobsForAction(Compilat
 Input.claim();
 if (Input.getOption().matches(options::OPT_INPUT)) {
   const char *Name = Input.getValue();
-  Result = InputInfo(Name, A->getType(), Name);
-} else {
-  Result = InputInfo(, A->getType(), "");
+  return InputInfo(Name, A->getType(), Name);
 }
-return;
+return InputInfo(, A->getType(), "");
   }
 
   if (const BindArchAction *BAA = dyn_cast(A)) {
@@ -1822,19 +1817,17 @@ void Driver::BuildJobsForAction(Compilat
 else
   TC = ();
 
-BuildJobsForAction(C, *BAA->begin(), TC, ArchName, AtTopLevel,
-   MultipleArchs, LinkingOutput, Result);
-return;
+return BuildJobsForAction(C, *BAA->begin(), TC, ArchName, AtTopLevel,
+  MultipleArchs, 

Re: [PATCH] D15624: Add iOS/watchOS/tvOS support for ASan (clang part)

2016-01-11 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

Sorry, lost track of this.



Comment at: lib/Driver/ToolChains.cpp:368
@@ +367,3 @@
+  StringRef OS = "";
+  if (isTargetMacOS())
+OS = "osx";

zaks.anna wrote:
> samsonov wrote:
> > Wait, this looks horrible. Can we teach toolchain to give us OS name?
> These are not OS names; they are prefixes we use to name the library. I 
> believe "appletvsimulator" would be a platform name, which is too long to 
> append to the dylib name.
> 
> I could factor this out into a separate function, but there are no other 
> immediate users. Not sure if the profiler library could be refactored to use 
> it, logic there seems more complicated.
Then we can name it as getOSLibraryNamePrefix() or smth. like that. I worry 
that this logic would hardly be discoverable inside `AddLinkSanitizerLibArgs` 
if it's going to be reused somewhere (which is likely).


http://reviews.llvm.org/D15624



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


r257392 - PR26087: Use nonstandard MSVC extension for VS2015 as well.

2016-01-11 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Mon Jan 11 16:00:22 2016
New Revision: 257392

URL: http://llvm.org/viewvc/llvm-project?rev=257392=rev
Log:
PR26087: Use nonstandard MSVC extension for VS2015 as well.

In r256564, I had conditioned the workaround in has_getDecl to only be
used for MSVC before the 2015 release, believing that 2015 could handle
the standard code. But, that was incorrect.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=257392=257391=257392=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Jan 11 
16:00:22 2016
@@ -560,10 +560,10 @@ bool matchesFirstInPointerRange(const Ma
 
 // Metafunction to determine if type T has a member called
 // getDecl.
-#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__clang__)
-// For old versions of MSVC, we use a weird nonstandard __if_exists
-// statement, since before MSVC2015, it was not standards-conformant
-// enough to compile the usual code below.
+#if defined(_MSC_VER) && !defined(__clang__)
+// For MSVC, we use a weird nonstandard __if_exists statement, as it
+// is not standards-conformant enough to properly compile the standard
+// code below. (At least up through MSVC 2015 require this workaround)
 template  struct has_getDecl {
   __if_exists(T::getDecl) {
 enum { value = 1 };


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


Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-11 Thread Eric Christopher via cfe-commits
echristo added a comment.

So, how are you getting to the point where you're trying to create the same 
action twice?

-eric


http://reviews.llvm.org/D15960



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


Re: [PATCH] D16079: [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44564.
jlebar added a comment.

Add missing change to DiagnosticDriverKinds.td.


http://reviews.llvm.org/D16079

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  test/Driver/cuda-bad-arch.cu

Index: test/Driver/cuda-bad-arch.cu
===
--- /dev/null
+++ test/Driver/cuda-bad-arch.cu
@@ -0,0 +1,34 @@
+// Checks errors generated by passing a bad value for --cuda-gpu-arch.
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+
+// BAD: error: Unsupported CUDA gpu architecture
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+
+// OK-NOT: error: Unsupported CUDA gpu architecture
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,8 +1297,12 @@
 if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
   continue;
 A->claim();
-if (GpuArchNames.insert(A->getValue()).second)
-  GpuArchList.push_back(A->getValue());
+
+const auto& Arch = A->getValue();
+if (!CudaDeviceAction::IsValidGpuArchName(Arch))
+  C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) << Arch;
+else if (GpuArchNames.insert(Arch).second)
+  GpuArchList.push_back(Arch);
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -9,6 +9,7 @@
 
 #include "clang/Driver/Action.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Regex.h"
 #include 
 using namespace clang::driver;
 using namespace llvm::opt;
@@ -54,7 +55,14 @@
 CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName,
bool AtTopLevel)
 : Action(CudaDeviceClass, Input), GpuArchName(ArchName),
-  AtTopLevel(AtTopLevel) {}
+  AtTopLevel(AtTopLevel) {
+  assert(IsValidGpuArchName(GpuArchName));
+}
+
+bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) {
+  static llvm::Regex RE("^sm_[0-9]+$");
+  return RE.match(ArchName);
+}
 
 void CudaHostAction::anchor() {}
 
Index: include/clang/Driver/Action.h
===
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -15,6 +15,9 @@
 #include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
+
+class StringRef;
+
 namespace opt {
   class Arg;
 }
@@ -133,7 +136,7 @@
 
 class CudaDeviceAction : public Action {
   virtual void anchor();
-  /// GPU architecture to bind -- e.g 'sm_35'.
+  /// GPU architecture to bind.  Always of the form /sm_\d+/.
   const char *GpuArchName;
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
@@ -145,6 +148,8 @@
   const char *getGpuArchName() const { return GpuArchName; }
   bool isAtTopLevel() const { return AtTopLevel; }
 
+  static bool IsValidGpuArchName(llvm::StringRef ArchName);
+
   static bool classof(const Action *A) {
 return A->getKind() == CudaDeviceClass;
   }
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -22,6 +22,7 @@
 def 

Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).

2016-01-11 Thread Philip Reames via cfe-commits
reames added a comment.

Neither Sanjoy or I are qualified to review a clang patch.  You'll need to find 
clang reviewers.

Also, before this gets exposed through Clang, we really should 
formalize/document the attribute.   In practice, it implies the lack of a 
safepoint poll site inside the called function.  Annoyingly, it's not an 
inferable property since we don't represent the possible insertion of a poll in 
the IR.

Hm.  This makes me wonder... We've moved to a model of inserting safepoints 
(specifically for deopt info) early, and then rewriting late in our tree.  
We're not even using the PlaceSafepoints pass any more.  It's been left mostly 
for other users.  Would it maybe make sense to fully retire PlaceSafepoints and 
migrate over to a scheme where safepoints sites are explicit from the 
beginning?  This would allow us to infer "gc-leaf" from FunctionAttrs...

(This high level discussion should probably move to llvm-dev.  I can start it 
if you'd like, otherwise post something and I'll reply.)


http://reviews.llvm.org/D15998



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


Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D15960#324162, @echristo wrote:

> So, how are you getting to the point where you're trying to create the same 
> action twice?
>
> -eric


In the new CUDA world, we have the following graph, which I hope will render 
properly:

  foo.cu --> foo.s (PTX) --> foo.cubin --> foo.fatbin
 └---┙

That is, foo.s is an input to foo.cubin *and* an input to foo.fatbin.

The Driver stores each Action's inputs.  So starting from the fatbin, we look 
at its two inputs, and try to create jobs for them.  Fine.  Then we look at the 
input to the cubin.  That's foo.s, which we already visited.


http://reviews.llvm.org/D15960



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


Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D15960#324162, @echristo wrote:

> So, how are you getting to the point where you're trying to create the same 
> action twice?
>
> -eric


In the new CUDA world, we have the following graph, which I hope will render 
properly:

  foo.cu --> foo.s (PTX) --> foo.cubin --> foo.fatbin
 └---┙

That is, foo.s is an input to foo.cubin *and* an input to foo.fatbin.

The Driver stores each Action's inputs.  So starting from the fatbin, we look 
at its two inputs, and try to create jobs for them.  Fine.  Then we look at the 
input to the cubin.  That's foo.s, which we already visited.


http://reviews.llvm.org/D15960



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


r257413 - [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Jan 11 17:27:13 2016
New Revision: 257413

URL: http://llvm.org/viewvc/llvm-project?rev=257413=rev
Log:
[CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

Reviewers: tra

Subscribers: cfe-commits, jhen, echristo

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

Added:
cfe/trunk/test/Driver/cuda-bad-arch.cu
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=257413=257412=257413=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jan 11 17:27:13 
2016
@@ -22,6 +22,7 @@ def err_drv_unknown_stdin_type_clang_cl
 def err_drv_unknown_language : Error<"language not recognized: '%0'">;
 def err_drv_invalid_arch_name : Error<
   "invalid arch name '%0'">;
+def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=257413=257412=257413=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Mon Jan 11 17:27:13 2016
@@ -15,6 +15,9 @@
 #include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
+
+class StringRef;
+
 namespace opt {
   class Arg;
 }
@@ -133,7 +136,7 @@ public:
 
 class CudaDeviceAction : public Action {
   virtual void anchor();
-  /// GPU architecture to bind -- e.g 'sm_35'.
+  /// GPU architecture to bind.  Always of the form /sm_\d+/.
   const char *GpuArchName;
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
@@ -145,6 +148,8 @@ public:
   const char *getGpuArchName() const { return GpuArchName; }
   bool isAtTopLevel() const { return AtTopLevel; }
 
+  static bool IsValidGpuArchName(llvm::StringRef ArchName);
+
   static bool classof(const Action *A) {
 return A->getKind() == CudaDeviceClass;
   }

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=257413=257412=257413=diff
==
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Mon Jan 11 17:27:13 2016
@@ -9,6 +9,7 @@
 
 #include "clang/Driver/Action.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Regex.h"
 #include 
 using namespace clang::driver;
 using namespace llvm::opt;
@@ -54,7 +55,14 @@ void CudaDeviceAction::anchor() {}
 CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName,
bool AtTopLevel)
 : Action(CudaDeviceClass, Input), GpuArchName(ArchName),
-  AtTopLevel(AtTopLevel) {}
+  AtTopLevel(AtTopLevel) {
+  assert(IsValidGpuArchName(GpuArchName));
+}
+
+bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) {
+  static llvm::Regex RE("^sm_[0-9]+$");
+  return RE.match(ArchName);
+}
 
 void CudaHostAction::anchor() {}
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257413=257412=257413=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jan 11 17:27:13 2016
@@ -1297,8 +1297,12 @@ static Action *buildCudaActions(Compilat
 if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
   continue;
 A->claim();
-if (GpuArchNames.insert(A->getValue()).second)
-  GpuArchList.push_back(A->getValue());
+
+const auto& Arch = A->getValue();
+if (!CudaDeviceAction::IsValidGpuArchName(Arch))
+  C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) << Arch;
+else if (GpuArchNames.insert(Arch).second)
+  GpuArchList.push_back(Arch);
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.

Added: cfe/trunk/test/Driver/cuda-bad-arch.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bad-arch.cu?rev=257413=auto
==
--- cfe/trunk/test/Driver/cuda-bad-arch.cu (added)
+++ cfe/trunk/test/Driver/cuda-bad-arch.cu Mon Jan 11 17:27:13 2016
@@ -0,0 +1,34 @@
+// Checks errors generated by passing a bad 

Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).

2016-01-11 Thread David Majnemer via cfe-commits
majnemer added subscribers: aaron.ballman, majnemer.
majnemer added a comment.

This change looks fine modulo the documentation issue.



Comment at: include/clang/Basic/Attr.td:2177
@@ +2176,3 @@
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}

@aaron.ballman prefers that all attributes we add have some documentation.  
This documentation would live in AttrDocs.td.


http://reviews.llvm.org/D15998



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


Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

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

LGTM. Thanks for doing this :)

-eric


http://reviews.llvm.org/D15911



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


Re: [PATCH] D15314: Fix a bug in unavailable checking

2016-01-11 Thread Manman Ren via cfe-commits
manmanren added a comment.

Ping :]


http://reviews.llvm.org/D15314



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


r257407 - Move ownership of Action objects into Compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Jan 11 17:07:27 2016
New Revision: 257407

URL: http://llvm.org/viewvc/llvm-project?rev=257407=rev
Log:
Move ownership of Action objects into Compilation.

Summary:
This makes constructing Action graphs which are DAGs much simpler.  It
also just simplifies in general the ownership semantics of Actions.

Depends on D15910.

Reviewers: echristo

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=257407=257406=257407=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Mon Jan 11 17:07:27 2016
@@ -32,6 +32,9 @@ namespace driver {
 /// single primary output, at least in terms of controlling the
 /// compilation. Actions can produce auxiliary files, but can only
 /// produce a single output to feed into subsequent actions.
+///
+/// Actions are usually owned by a Compilation, which creates new
+/// actions via MakeAction().
 class Action {
 public:
   typedef ActionList::size_type size_type;
@@ -70,27 +73,20 @@ private:
 
   ActionList Inputs;
 
-  unsigned OwnsInputs : 1;
-
 protected:
-  Action(ActionClass Kind, types::ID Type)
-: Kind(Kind), Type(Type), OwnsInputs(true)  {}
-  Action(ActionClass Kind, std::unique_ptr Input, types::ID Type)
-  : Kind(Kind), Type(Type), Inputs(1, Input.release()), OwnsInputs(true) {
-  }
-  Action(ActionClass Kind, std::unique_ptr Input)
-  : Kind(Kind), Type(Input->getType()), Inputs(1, Input.release()),
-OwnsInputs(true) {}
+  Action(ActionClass Kind, types::ID Type) : Action(Kind, ActionList(), Type) 
{}
+  Action(ActionClass Kind, Action *Input, types::ID Type)
+  : Action(Kind, ActionList({Input}), Type) {}
+  Action(ActionClass Kind, Action *Input)
+  : Action(Kind, ActionList({Input}), Input->getType()) {}
   Action(ActionClass Kind, const ActionList , types::ID Type)
-: Kind(Kind), Type(Type), Inputs(Inputs), OwnsInputs(true) {}
+  : Kind(Kind), Type(Type), Inputs(Inputs) {}
+
 public:
   virtual ~Action();
 
   const char *getClassName() const { return Action::getClassName(getKind()); }
 
-  bool getOwnsInputs() { return OwnsInputs; }
-  void setOwnsInputs(bool Value) { OwnsInputs = Value; }
-
   ActionClass getKind() const { return Kind; }
   types::ID getType() const { return Type; }
 
@@ -126,7 +122,7 @@ class BindArchAction : public Action {
   const char *ArchName;
 
 public:
-  BindArchAction(std::unique_ptr Input, const char *ArchName);
+  BindArchAction(Action *Input, const char *ArchName);
 
   const char *getArchName() const { return ArchName; }
 
@@ -144,8 +140,7 @@ class CudaDeviceAction : public Action {
   bool AtTopLevel;
 
 public:
-  CudaDeviceAction(std::unique_ptr Input, const char *ArchName,
-   bool AtTopLevel);
+  CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel);
 
   const char *getGpuArchName() const { return GpuArchName; }
   bool isAtTopLevel() const { return AtTopLevel; }
@@ -160,9 +155,7 @@ class CudaHostAction : public Action {
   ActionList DeviceActions;
 
 public:
-  CudaHostAction(std::unique_ptr Input,
- const ActionList );
-  ~CudaHostAction() override;
+  CudaHostAction(Action *Input, const ActionList );
 
   const ActionList () const { return DeviceActions; }
 
@@ -172,7 +165,7 @@ public:
 class JobAction : public Action {
   virtual void anchor();
 protected:
-  JobAction(ActionClass Kind, std::unique_ptr Input, types::ID Type);
+  JobAction(ActionClass Kind, Action *Input, types::ID Type);
   JobAction(ActionClass Kind, const ActionList , types::ID Type);
 
 public:
@@ -185,7 +178,7 @@ public:
 class PreprocessJobAction : public JobAction {
   void anchor() override;
 public:
-  PreprocessJobAction(std::unique_ptr Input, types::ID OutputType);
+  PreprocessJobAction(Action *Input, types::ID OutputType);
 
   static bool classof(const Action *A) {
 return A->getKind() == PreprocessJobClass;
@@ -195,7 +188,7 @@ public:
 class PrecompileJobAction : public JobAction {
   void anchor() override;
 public:
-  PrecompileJobAction(std::unique_ptr Input, types::ID OutputType);
+  PrecompileJobAction(Action *Input, types::ID OutputType);
 
   static bool classof(const Action *A) {
 return A->getKind() == PrecompileJobClass;
@@ -205,7 +198,7 @@ public:
 class AnalyzeJobAction : public JobAction {
   void anchor() override;
 public:
-  AnalyzeJobAction(std::unique_ptr Input, types::ID OutputType);
+  AnalyzeJobAction(Action *Input, types::ID OutputType);
 
   static 

[PATCH] D16094: Debugger tuning via gold plugin

2016-01-11 Thread Paul Robinson via cfe-commits
probinson created this revision.
probinson added a reviewer: echristo.
probinson added a subscriber: cfe-commits.
Herald added a subscriber: joker.eph.

LTO via the gold plugin needs to be told about debugger tuning.

http://reviews.llvm.org/D16094

Files:
  lib/Driver/Tools.cpp
  test/Driver/lto.c

Index: test/Driver/lto.c
===
--- test/Driver/lto.c
+++ test/Driver/lto.c
@@ -49,3 +49,12 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+
+// -flto passes along an explicit debugger tuning argument.
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
+// RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-TUNING < %t %s
+//
+// CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
+// CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1817,6 +1817,17 @@
 
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
+
+  // If an explicit debugger tuning argument appeared, pass it along.
+  if (Arg *A = Args.getLastArg(options::OPT_gTune_Group,
+   options::OPT_ggdbN_Group)) {
+if (A->getOption().matches(options::OPT_glldb))
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=lldb");
+else if (A->getOption().matches(options::OPT_gsce))
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=sce");
+else
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=gdb");
+  }
 }
 
 /// This is a helper function for validating the optional refinement step


Index: test/Driver/lto.c
===
--- test/Driver/lto.c
+++ test/Driver/lto.c
@@ -49,3 +49,12 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+
+// -flto passes along an explicit debugger tuning argument.
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
+// RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-TUNING < %t %s
+//
+// CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
+// CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1817,6 +1817,17 @@
 
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
+
+  // If an explicit debugger tuning argument appeared, pass it along.
+  if (Arg *A = Args.getLastArg(options::OPT_gTune_Group,
+   options::OPT_ggdbN_Group)) {
+if (A->getOption().matches(options::OPT_glldb))
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=lldb");
+else if (A->getOption().matches(options::OPT_gsce))
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=sce");
+else
+  CmdArgs.push_back("-plugin-opt=-debugger-tune=gdb");
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16056: [Gold] Pass -mllvm options to the gold plugin

2016-01-11 Thread Rafael Espíndola via cfe-commits
Maybe. I would like a second opinion on this one. The potential issue
I see is that we are using compiler options during linking. Normally
they are just ignored. Is it surprising if LTO starts using them?

Cheers,
Rafael


On 11 January 2016 at 06:47, James Molloy  wrote:
> jmolloy created this revision.
> jmolloy added a reviewer: rafael.
> jmolloy added a subscriber: cfe-commits.
> jmolloy set the repository for this revision to rL LLVM.
> Herald added a subscriber: joker.eph.
>
> The gold plugin can take LLVM options, but the syntax is confusing: 
> -Wl,-plugin-opt= or -Xlinker -plugin-opt=.
>
> Instead, pass -mllvm options through to Gold so the obvious syntax works.
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16056
>
> Files:
>   lib/Driver/Tools.cpp
>   test/Driver/gold-lto.c
>
> Index: test/Driver/gold-lto.c
> ===
> --- test/Driver/gold-lto.c
> +++ test/Driver/gold-lto.c
> @@ -16,11 +16,14 @@
>  // CHECK-X86-64-COREI7: "-plugin-opt=foo"
>  //
>  // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
> -// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
> +// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 -mllvm -bar=baz \
> +// RUN: -mllvm -test-option \
>  // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
>  // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
>  // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
>  // CHECK-ARM-V7A: "-plugin-opt=O0"
> +// CHECK-ARM-V7A: "-plugin-opt=-bar=baz"
> +// CHECK-ARM-V7A: "-plugin-opt=-test-option"
>  // CHECK-ARM-V7A: "-plugin-opt=foo"
>  //
>  // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -1817,6 +1817,12 @@
>
>if (IsThinLTO)
>  CmdArgs.push_back("-plugin-opt=thinlto");
> +
> +  // Claim and pass through -mllvm options to the Gold plugin.
> +  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
> +A->claim();
> +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + 
> A->getValue(0)));
> +  }
>  }
>
>  /// This is a helper function for validating the optional refinement step
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r257422 - Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the right place.

2016-01-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 11 18:38:04 2016
New Revision: 257422

URL: http://llvm.org/viewvc/llvm-project?rev=257422=rev
Log:
Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the right 
place.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257422=257421=257422=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan 11 18:38:04 2016
@@ -433,6 +433,11 @@ namespace std {
 #define _LIBCPP_HAS_NO_ASAN
 #endif
 
+// Allow for build-time disabling of unsigned integer sanitization
+#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute((no_sanitize("unsigned-integer-overflow")))
+#endif 
+
 #elif defined(__GNUC__)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -597,11 +602,6 @@ namespace std {
 
 #define _LIBCPP_HAS_NO_ASAN
 
-// Allow for build-time disabling of unsigned integer sanitization
-#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
-#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute((no_sanitize("unsigned integer")))
-#endif 
-
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
 #ifndef _LIBCPP_HAS_NO_NOEXCEPT


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


Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Artem Belevich via cfe-commits
tra added a comment.

Make sure it works with -save-temps and -fintegrated-as/-fno-integrated-as. 
They tend to throw wrenches into pipeline construction.



Comment at: lib/Driver/Driver.cpp:1380
@@ +1379,3 @@
+  C.MakeAction(DeviceActions, types::TY_CUDA_FATBIN),
+  /* GpuArchName = */ nullptr,
+  /* AtTopLevel = */ false);

So, you're treating GpuArchName==nullptr as a special case of DeviceAction for 
fatbin?
Perhaps it warrants its own CudaDeviceLinkAction?


Comment at: lib/Driver/Driver.cpp:1620-1625
@@ -1602,3 +1619,8 @@
   case phases::Assemble:
-return C.MakeAction(Input, types::TY_Object);
+// Assembling generates an object file, except when we're assembling CUDA,
+// in which case we get a cubin file.
+return C.MakeAction(
+std::move(Input), TC.getTriple().getOS() == llvm::Triple::CUDA
+  ? types::TY_CUDA_CUBIN
+  : types::TY_Object);
   }

cubin *is* an ELF object file. Do we really need a new type here or can we get 
by with TY_Object?


Comment at: lib/Driver/ToolChains.cpp:4193
@@ +4192,3 @@
+: Linux(D, Triple, Args) {
+  if (CudaInstallation.isValid()) {
+getProgramPaths().push_back(CudaInstallation.getBinPath());

unneeded {} here and in few more places throughout the patch.


Comment at: lib/Driver/ToolChains.cpp:4230
@@ -4224,3 +4229,3 @@
   // Skip this argument unless the architecture matches BoundArch
-  if (A->getValue(0) != StringRef(BoundArch))
+  if (!BoundArch || A->getValue(0) != StringRef(BoundArch))
 continue;

You may as well move it out of the loop and return early if BoundArch is 
nullptr.


Comment at: lib/Driver/Tools.cpp:10621-10625
@@ +10620,7 @@
+  ArgStringList CmdArgs;
+  if (TC.getTriple().isArch64Bit()) {
+CmdArgs.push_back("-m64");
+  } else {
+CmdArgs.push_back("-m32");
+  }
+

CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");

or, even

ArgStringList CmdArgs = {TC.getTriple().isArch64Bit() ? "-m64" : "-m32"};

Same in Linker::ConstructJob below.


Comment at: lib/Driver/Tools.cpp:10677-10678
@@ +10676,4 @@
+std::string Arch = A->getGpuArchName();
+// We need to name pass an Arch of the form "sm_XX" for cubin files and
+// "compute_XX" for ptx.  CudaDeviceAction's getGpuArchName() is guaranteed
+// to match "sm_XX".

First line does not parse.

In general compute_XX does not necessarily match sm_XX.
[[ http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#ptxas-options | ptxas 
options ]] says that 

> Allowed values for this option: compute_20, compute_30, compute_35, 
> compute_50, compute_52; and sm_20, sm_21, sm_30, sm_32, sm_35, sm_50 and sm_52

Note that there's no compute_21, compute_32. You'll need sm_XX -> compute_YY 
map.




Comment at: lib/Driver/Tools.h:923
@@ +922,3 @@
+
+// Runs fatbinary, which is sort of a linker for NVPTX.
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {

Please add more details about what fatbin does.
".. which combines GPU object files and, optionally, PTX assembly into a single 
output file."


http://reviews.llvm.org/D16082



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


r257403 - When a tag is declared in prototype scope in C, if we've decided that it

2016-01-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan 11 16:41:53 2016
New Revision: 257403

URL: http://llvm.org/viewvc/llvm-project?rev=257403=rev
Log:
When a tag is declared in prototype scope in C, if we've decided that it
redeclares an existing tag but are creating a new declaration anyway (because
it has attributes or changes the visibility of the name), don't warn that it
won't be visible outside the current scope. That's not true.

Also narrow down the set of cases where we create these extra declarations when
building modules; previously, all tag declarations but the first in a module
header would get this treatment if -fmodules-local-submodule-visibility. (This
isn't a functional change, but we try to avoid creating these extra
declarations whenever we can.)

Added:
cfe/trunk/test/Modules/tag-injection.c
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/decl-in-prototype.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=257403=257402=257403=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 11 16:41:53 2016
@@ -12316,7 +12316,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
 } else if (TUK == TUK_Reference &&
(PrevTagDecl->getFriendObjectKind() ==
 Decl::FOK_Undeclared ||
-getOwningModule(PrevDecl) !=
+PP.getModuleContainingLocation(
+PrevDecl->getLocation()) !=
 PP.getModuleContainingLocation(KWLoc)) &&
SS.isEmpty()) {
   // This declaration is a reference to an existing entity, but
@@ -12326,8 +12327,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // the declaration would have meant the same thing if no prior
   // declaration were found, that is, if it was found in the same
   // scope where we would have injected a declaration.
-  if (!getTagInjectionContext(CurContext)
-   ->getRedeclContext()
+  if (!getTagInjectionContext(CurContext)->getRedeclContext()

->Equals(PrevDecl->getDeclContext()->getRedeclContext()))
 return PrevTagDecl;
   // This is in the injected scope, create a new declaration in
@@ -12634,7 +12634,7 @@ CreateNewDecl:
 << Name;
 Invalid = true;
   }
-} else {
+} else if (!PrevDecl) {
   Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New);
 }
 DeclsInPrototypeScope.push_back(New);

Added: cfe/trunk/test/Modules/tag-injection.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.c?rev=257403=auto
==
--- cfe/trunk/test/Modules/tag-injection.c (added)
+++ cfe/trunk/test/Modules/tag-injection.c Mon Jan 11 16:41:53 2016
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'struct a;' > %t/a.h
+// RUN: echo 'struct b {}; void foo(struct b*);' > %t/b.h
+// RUN: echo 'module X { module a { header "a.h" } module b { header "b.h" } 
}' > %t/x.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t 
-fmodule-map-file=%t/x.modulemap %s -I%t -verify
+
+#include "a.h"
+
+void f(struct a *p);
+
+// FIXME: We should warn that 'b' will not be visible outside of this function,
+// but we merge this 'b' with X.b's 'b' because we don't yet implement C's
+// "compatible types" rule.
+void g(struct b *p);
+
+struct b b; // expected-error {{definition of 'b' must be imported from module 
'X.b' before it is required}}
+// expected-note@b.h:1 {{here}}

Modified: cfe/trunk/test/Sema/decl-in-prototype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-in-prototype.c?rev=257403=257402=257403=diff
==
--- cfe/trunk/test/Sema/decl-in-prototype.c (original)
+++ cfe/trunk/test/Sema/decl-in-prototype.c Mon Jan 11 16:41:53 2016
@@ -35,3 +35,6 @@ void f6(struct z {int b;} c) { // expect
 void pr19018_1 (enum e19018 { qq } x); // expected-warning{{declaration of 
'enum e19018' will not be visible outside of this function}}
 enum e19018 qq; //expected-error{{tentative definition has type 'enum e19018' 
that is never completed}} \
 //expected-note{{forward declaration of 'enum e19018'}}
+
+// Only warn once, even if we create two declarations.
+void f(struct q *, struct __attribute__((aligned(4))) q *); // 
expected-warning {{will not be visible outside}}


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


Re: [PATCH] D16065: Fix infinite recursion for invalid declaration

2016-01-11 Thread Kostya Serebryany via cfe-commits
kcc accepted this revision.
kcc added a reviewer: kcc.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM, and thanks!


http://reviews.llvm.org/D16065



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


Re: [PATCH] D16079: [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Oops, I added the new error to the generated file in my objdir, rather than in 
the source tree.  It worked fine until I rebuilt...

Eric, please have a look at the change to DiagnosticDriverKinds.td.


http://reviews.llvm.org/D16079



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


Re: [PATCH] D16078: Add an Action* member to InputInfo.

2016-01-11 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257411: Add an Action* member to InputInfo. (authored by 
jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16078?vs=44539=44568#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16078

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/InputInfo.h
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Driver/InputInfo.h
===
--- cfe/trunk/lib/Driver/InputInfo.h
+++ cfe/trunk/lib/Driver/InputInfo.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
 #define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
 
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Types.h"
 #include "llvm/Option/Arg.h"
 #include 
@@ -38,29 +39,47 @@
 const llvm::opt::Arg *InputArg;
   } Data;
   Class Kind;
+  const Action* Act;
   types::ID Type;
   const char *BaseInput;
 
+  static types::ID GetActionType(const Action *A) {
+return A != nullptr ? A->getType() : types::TY_Nothing;
+  }
+
 public:
-  InputInfo() {}
-  InputInfo(types::ID _Type, const char *_BaseInput)
-: Kind(Nothing), Type(_Type), BaseInput(_BaseInput) {
+  InputInfo() : InputInfo(nullptr, nullptr) {}
+  InputInfo(const Action *A, const char *_BaseInput)
+  : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {}
+
+  InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput)
+  : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+Data.Filename = _Filename;
   }
-  InputInfo(const char *_Filename, types::ID _Type, const char *_BaseInput)
-: Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
+  InputInfo(const Action *A, const char *_Filename, const char *_BaseInput)
+  : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
 Data.Filename = _Filename;
   }
-  InputInfo(const llvm::opt::Arg *_InputArg, types::ID _Type,
+
+  InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg,
+const char *_BaseInput)
+  : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+Data.InputArg = _InputArg;
+  }
+  InputInfo(const Action *A, const llvm::opt::Arg *_InputArg,
 const char *_BaseInput)
-  : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
+  : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
 Data.InputArg = _InputArg;
   }
 
   bool isNothing() const { return Kind == Nothing; }
   bool isFilename() const { return Kind == Filename; }
   bool isInputArg() const { return Kind == InputArg; }
   types::ID getType() const { return Type; }
   const char *getBaseInput() const { return BaseInput; }
+  /// The action for which this InputInfo was created.  May be null.
+  const Action *getAction() const { return Act; }
+  void setAction(const Action *A) { Act = A; }
 
   const char *getFilename() const {
 assert(isFilename() && "Invalid accessor.");
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2980,7 +2980,7 @@
   ExtractArgs.push_back(OutFile);
 
   const char *Exec = Args.MakeArgString(TC.GetProgramPath("objcopy"));
-  InputInfo II(Output.getFilename(), types::TY_Object, Output.getFilename());
+  InputInfo II(types::TY_Object, Output.getFilename(), Output.getFilename());
 
   // First extract the dwo sections.
   C.addCommand(llvm::make_unique(JA, T, Exec, ExtractArgs, II));
@@ -8987,7 +8987,7 @@
const char *LinkingOutput) const {
   const toolchains::NaClToolChain  =
   static_cast(getToolChain());
-  InputInfo NaClMacros(ToolChain.GetNaClArmMacrosPath(), types::TY_PP_Asm,
+  InputInfo NaClMacros(types::TY_PP_Asm, ToolChain.GetNaClArmMacrosPath(),
"nacl-arm-macros.s");
   InputInfoList NewInputs;
   NewInputs.push_back(NaClMacros);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1801,9 +1801,9 @@
 Input.claim();
 if (Input.getOption().matches(options::OPT_INPUT)) {
   const char *Name = Input.getValue();
-  return InputInfo(Name, A->getType(), Name);
+  return InputInfo(A, Name, /* BaseInput = */ Name);
 }
-return InputInfo(, A->getType(), "");
+return InputInfo(A, , /* BaseInput = */ "");
   }
 
   if (const BindArchAction *BAA = dyn_cast(A)) {
@@ -1877,11 +1877,11 @@
   // Determine the place to write output to, if any.
   InputInfo Result;
   if (JA->getType() == types::TY_Nothing)
-Result = InputInfo(A->getType(), BaseInput);
+Result = InputInfo(A, BaseInput);
   else
-Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
-  AtTopLevel, MultipleArchs),
-  

Buildbot numbers for week of 1/03/2016 - 1/09/2016

2016-01-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 1/03/2016 - 01/09/2016.

Thanks

Galina



Number of commits by project:

 project   |   commits
---+---
 llvm  |   266
 cfe   |97
 lld   |62
 lldb  |58
 compiler-rt   |29
 libcxx| 8
 polly | 6
 clang-tools-extra | 5
 openmp| 2
---+---
   533


Number of completed builds, failed builds and average build time for
successful builds per active builder:

 buildername   | completed  |
failed | time
---+++
 clang-aarch64-lnt | 54
|  2 | 02:36:37
 clang-atom-d525-fedora| 17
|  1 | 09:03:38
 clang-atom-d525-fedora-rel| 79
|  3 | 01:37:57
 clang-bpf-build   |300
| 21 | 00:02:48
 clang-cmake-aarch64-42vma |266
| 31 | 00:17:00
 clang-cmake-aarch64-full  | 41
|  6 | 03:43:23
 clang-cmake-aarch64-quick |204
|  6 | 00:25:57
 clang-cmake-armv7-a15 |195
| 13 | 00:27:16
 clang-cmake-armv7-a15-full|155
|  7 | 00:43:02
 clang-cmake-armv7-a15-selfhost| 36
|  2 | 04:08:42
 clang-cmake-armv7-a15-selfhost-neon   | 27
|  3 | 05:16:31
 clang-cmake-mips  | 99
|  9 | 01:18:31
 clang-cmake-mipsel|  5
|  1 | 08:20:58
 clang-cmake-thumbv7-a15   |211
|  9 | 00:22:11
 clang-cmake-thumbv7-a15-full-sh   | 23
|  2 | 06:24:30
 clang-hexagon-elf |247
| 13 | 00:15:42
 clang-native-aarch64-full | 14
|  3 | 08:49:58
 clang-native-arm-lnt  | 79
|  1 | 01:09:54
 clang-native-arm-lnt-perf | 16
|  2 | 10:00:51
 clang-ppc64-elf-linux | 96
| 13 | 01:20:07
 clang-ppc64-elf-linux2|198
| 26 | 00:27:25
 clang-sphinx-docs |119
|  2 | 00:00:25
 clang-x64-ninja-win7  |264
|262 | 00:34:37
 clang-x86-win2008-selfhost|222
|220 | 01:10:17
 clang-x86_64-darwin13-cross-arm   |233
|  1 | 00:19:58
 clang-x86_64-darwin13-cross-mingw32   |222
|  2 | 00:23:31
 clang-x86_64-debian-fast  |150
|  4 | 00:11:57
 clang-x86_64-linux-abi-test   |304
|  2 | 00:09:50
 clang-x86_64-linux-selfhost-modules   |287
|194 | 00:15:44
 clang-x86_64-ubuntu-gdb-75|142
|  9 | 00:43:18
 libcxx-libcxxabi-arm-linux|  7
|  1 | 01:09:27
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian   |  5
|| 00:09:48
 libcxx-libcxxabi-x86_64-linux-debian  |  5
|  2 | 00:10:36
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions |  6
|  1 | 00:10:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan |  8
|  7 |
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03|  6
|| 00:06:51
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11|  8
|| 00:06:46
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14|  8
|| 00:07:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z|  8
|| 00:07:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan |  7
|  7 |
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan |  7
|| 00:14:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-unstable-abi |  7
|| 00:08:28
 libcxx-sphinx-docs|  7
|| 00:00:16
 libomp-clang-x86_64-linux-debian  |  2
|  2 |
 

r257411 - Add an Action* member to InputInfo.

2016-01-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Jan 11 17:15:21 2016
New Revision: 257411

URL: http://llvm.org/viewvc/llvm-project?rev=257411=rev
Log:
Add an Action* member to InputInfo.

Summary:
The CUDA toolchain needs to know which Actions created which InputInfos,
because it needs to attach GPU archs to the various InputInfos.

Reviewers: echristo

Subscribers: jfb, dschuff, jhen, tra, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/InputInfo.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257411=257410=257411=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jan 11 17:15:21 2016
@@ -1801,9 +1801,9 @@ InputInfo Driver::BuildJobsForAction(Com
 Input.claim();
 if (Input.getOption().matches(options::OPT_INPUT)) {
   const char *Name = Input.getValue();
-  return InputInfo(Name, A->getType(), Name);
+  return InputInfo(A, Name, /* BaseInput = */ Name);
 }
-return InputInfo(, A->getType(), "");
+return InputInfo(A, , /* BaseInput = */ "");
   }
 
   if (const BindArchAction *BAA = dyn_cast(A)) {
@@ -1877,11 +1877,11 @@ InputInfo Driver::BuildJobsForAction(Com
   // Determine the place to write output to, if any.
   InputInfo Result;
   if (JA->getType() == types::TY_Nothing)
-Result = InputInfo(A->getType(), BaseInput);
+Result = InputInfo(A, BaseInput);
   else
-Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
-  AtTopLevel, MultipleArchs),
-   A->getType(), BaseInput);
+Result = InputInfo(A, GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
+ AtTopLevel, MultipleArchs),
+   BaseInput);
 
   if (CCCPrintBindings && !CCGenDiagnostics) {
 llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'

Modified: cfe/trunk/lib/Driver/InputInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/InputInfo.h?rev=257411=257410=257411=diff
==
--- cfe/trunk/lib/Driver/InputInfo.h (original)
+++ cfe/trunk/lib/Driver/InputInfo.h Mon Jan 11 17:15:21 2016
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
 #define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
 
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Types.h"
 #include "llvm/Option/Arg.h"
 #include 
@@ -38,21 +39,36 @@ class InputInfo {
 const llvm::opt::Arg *InputArg;
   } Data;
   Class Kind;
+  const Action* Act;
   types::ID Type;
   const char *BaseInput;
 
+  static types::ID GetActionType(const Action *A) {
+return A != nullptr ? A->getType() : types::TY_Nothing;
+  }
+
 public:
-  InputInfo() {}
-  InputInfo(types::ID _Type, const char *_BaseInput)
-: Kind(Nothing), Type(_Type), BaseInput(_BaseInput) {
+  InputInfo() : InputInfo(nullptr, nullptr) {}
+  InputInfo(const Action *A, const char *_BaseInput)
+  : Kind(Nothing), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {}
+
+  InputInfo(types::ID _Type, const char *_Filename, const char *_BaseInput)
+  : Kind(Filename), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+Data.Filename = _Filename;
   }
-  InputInfo(const char *_Filename, types::ID _Type, const char *_BaseInput)
-: Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
+  InputInfo(const Action *A, const char *_Filename, const char *_BaseInput)
+  : Kind(Filename), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
 Data.Filename = _Filename;
   }
-  InputInfo(const llvm::opt::Arg *_InputArg, types::ID _Type,
+
+  InputInfo(types::ID _Type, const llvm::opt::Arg *_InputArg,
+const char *_BaseInput)
+  : Kind(InputArg), Act(nullptr), Type(_Type), BaseInput(_BaseInput) {
+Data.InputArg = _InputArg;
+  }
+  InputInfo(const Action *A, const llvm::opt::Arg *_InputArg,
 const char *_BaseInput)
-  : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
+  : Kind(InputArg), Act(A), Type(GetActionType(A)), BaseInput(_BaseInput) {
 Data.InputArg = _InputArg;
   }
 
@@ -61,6 +77,9 @@ public:
   bool isInputArg() const { return Kind == InputArg; }
   types::ID getType() const { return Type; }
   const char *getBaseInput() const { return BaseInput; }
+  /// The action for which this InputInfo was created.  May be null.
+  const Action *getAction() const { return Act; }
+  void setAction(const Action *A) { Act = A; }
 
   const char *getFilename() const {
 assert(isFilename() && "Invalid accessor.");

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257411=257410=257411=diff

Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-11 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jan-11, at 15:40, Rafael Espíndola  wrote:
> 
> On 8 January 2016 at 19:50, Duncan P. N. Exon Smith via cfe-commits
>  wrote:
>> [re-send to lists.llvm.org]
>> [necromancy]
>> 
>> This is causing some strangeness for users of libc++ headers that
>> ship dylibs and build with -fno-rtti and -fvisibility=hidden.
>> 
>> Strangely, -fno-rtti does *not* imply -fno-exceptions; the type info
>> needed for exceptions is generated on-the-fly.  This means that each
>> translation unit generates a linkonce_odr copy of the std::exception
>> type info -- weird, but kind of reasonable?
> 
> Will gcc produce a copy too? It seems really strange to produce
> different linkages for -frtti and -fno-rtti -fexcptions.

I'm not sure about GCC.  Note that there is no linkage for -frtti,
since the type info is deferred to the TU with the vtable.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-11 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jan-11, at 15:57, Rafael Espíndola  wrote:
> 
>> I'm not sure about GCC.  Note that there is no linkage for -frtti,
>> since the type info is deferred to the TU with the vtable.
> 
> Yes, that is what I mean. It is odd that -frtti changes us from "this
> is not available anywhere, use linkonce_odr" to "it is available
> elsewhere, use an external declaration".

Yes, I agree, it's weird (although the transition is in the other
direction, really, since there's no such flag as -frtti, just -fno-rtti).
-fexceptions -fno-rtti is a weird combination to begin with though.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44586.
jlebar added a comment.

Add test checking that sm_XX gets translated to compute_YY correctly.


http://reviews.llvm.org/D16082

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  include/clang/Driver/Types.def
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Driver/Types.cpp
  test/Driver/Inputs/CUDA/usr/local/cuda/bin/.keep
  test/Driver/cuda-arch-translation.cu
  test/Driver/cuda-external-tools.cu
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -39,13 +39,6 @@
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Verify that with -S we compile host and device sides to assembly and
-// incorporate device code into the host side.
-// RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
-
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
@@ -61,7 +54,7 @@
 // RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
 // RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix INCLUDES-DEVICE2 -check-prefix NOLINK %s
+// RUN:-check-prefix NOLINK %s
 
 // Verify that device-side results are passed to the correct tool when
 // -save-temps is used.
@@ -92,10 +85,16 @@
 // DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE-SAME: "-fcuda-is-device"
 // DEVICE-SM35-SAME: "-target-cpu" "sm_35"
-// DEVICE-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
+// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
 // DEVICE-NOSAVE-SAME: "-x" "cuda"
 // DEVICE-SAVE-SAME: "-x" "ir"
 
+// Match the call to ptxas (which assembles PTX to SASS).
+// DEVICE:ptxas
+// DEVICE-SM35-DAG: "--gpu-name" "sm_35"
+// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
+// DEVICE-DAG: "[[PTXFILE]]"
+
 // Match another device-side compilation.
 // DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -108,6 +107,11 @@
 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // NODEVICE-SAME-NOT: "-fcuda-is-device"
 
+// INCLUDES-DEVICE:fatbinary
+// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
+
 // Match host-side preprocessor job with -save-temps.
 // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
 // HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
@@ -121,8 +125,7 @@
 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // HOST-NOSAVE-SAME: "-x" "cuda"
 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
-// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
-// INCLUDES-DEVICE2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
+// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
 
 // Match external assembler that uses compilation output.
 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Index: test/Driver/cuda-external-tools.cu
===
--- /dev/null
+++ test/Driver/cuda-external-tools.cu
@@ -0,0 +1,70 @@
+// Tests that ptxas and fatbinary are correctly during CUDA compilation.
+//
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Regular compile with -O2.
+// RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 %s
+
+// Regular compile without -O.  This should result in us passing -O0 to ptxas.
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+
+// Regular compile targeting sm_35.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
+
+// 32-bit compile.
+// RUN: %clang -### -target x86_32-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH32 -check-prefix SM20 %s
+
+// Compile with -fintegrated-as.  This should still cause us to invoke ptxas.
+// RUN: %clang -### -target x86_64-linux-gnu -fintegrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+
+// Check -Xcuda-ptxas and -Xcuda-fatbinary
+// RUN: %clang -### -target 

Re: [PATCH] D16041: Change vfs::FileSystem to be managed with std::shared_ptr

2016-01-11 Thread Benjamin Kramer via cfe-commits
On Mon, Jan 11, 2016 at 8:08 PM, Owen Anderson  wrote:
>
>> On Jan 11, 2016, at 8:25 AM, David Blaikie  wrote:
>>
>>
>>
>> On Sun, Jan 10, 2016 at 11:42 PM, Owen Anderson via cfe-commits 
>>  wrote:
>> resistor created this revision.
>> resistor added reviewers: chandlerc, bkramer, klimek.
>> resistor added a subscriber: cfe-commits.
>> resistor set the repository for this revision to rL LLVM.
>> Herald added a subscriber: klimek.
>>
>> Managing it with IntrusiveRefCntPtr caused the virtual destructor not to be 
>> called properly.
>>
>> Regardless of the broader discussion on this patch, I'm confused by why this 
>> ^ would be the case. What is it that IntrusiveRefCntPtr is doing that's 
>> causing problems with destruction? (& I'm all for changing this to 
>> non-intrusive smart pointers over intrusive ones anyway, but I'd still like 
>> to understand the extra motivation here)
>>
>
> ThreadSafeRefCountedBase, which classes must inherit from in order to use 
> IntrusiveRefCntPtr, does not handle virtual destructors properly.  For the 
> non-thread safe version, there is RefCountBaseVPTR which solves this problem. 
>  An alternative solution would have been to add a corresponding 
> ThreadSafeRefCountedBaseVPTR, but IMO at that point one might as well use 
> shared_ptr since it’s 90% of the way there.

I find this surprising. ThreadSafeRefCountedBase calls
"delete static_cast(this)". As FileSystem has a
virtual dtor, polymorphic deletion should just work. Am I missing
something?

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


[PATCH] D16087: Add some overview doxygen comments to lib/Format.

2016-01-11 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: djasper.
thakis added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

It always takes me a while to understand how clang-format's pieces fit together 
-- hopefully this will save me some time the next time I need it.

http://reviews.llvm.org/D16087

Files:
  lib/Format/ContinuationIndenter.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.h
  lib/Format/UnwrappedLineFormatter.h
  lib/Format/UnwrappedLineParser.h

Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -58,6 +58,8 @@
 
 class FormatTokenSource;
 
+/// \brief Takes a sequence of tokens, and splits it into chunks of tokens
+/// that would be a single line each if there was no column limit.
 class UnwrappedLineParser {
 public:
   UnwrappedLineParser(const FormatStyle ,
Index: lib/Format/UnwrappedLineFormatter.h
===
--- lib/Format/UnwrappedLineFormatter.h
+++ lib/Format/UnwrappedLineFormatter.h
@@ -28,6 +28,9 @@
 class ContinuationIndenter;
 class WhitespaceManager;
 
+/// \brief Responsible for taking a list of logical lines, and for producing
+/// a set of whitespace adjustments to turn them into physical lines so
+/// that each physical line is below a column limit.
 class UnwrappedLineFormatter {
 public:
   UnwrappedLineFormatter(ContinuationIndenter *Indenter,
Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -36,6 +36,7 @@
   LT_VirtualFunctionDecl
 };
 
+/// \brief Stores additional information for an \c UnwrappedLine.
 class AnnotatedLine {
 public:
   AnnotatedLine(const UnwrappedLine )
@@ -148,7 +149,11 @@
   // FIXME: Can/should this be done in the UnwrappedLineParser?
   void setCommentLineLevels(SmallVectorImpl );
 
+  /// \brief Compute metadata of \c AnnotatedLine itself, like \c LineType.
   void annotate(AnnotatedLine );
+
+  /// \brief For all the tokens in \c Line, compute if a line break is
+  /// needed for that token, and similar information.
   void calculateFormattingInformation(AnnotatedLine );
 
 private:
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -107,8 +107,8 @@
 class TokenRole;
 class AnnotatedLine;
 
-/// \brief A wrapper around a \c Token storing information about the
-/// whitespace characters preceding it.
+/// \brief A wrapper around a \c Token storing additional information useful
+/// for formatting.
 struct FormatToken {
   FormatToken() {}
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -758,6 +758,7 @@
 
 namespace {
 
+/// \brief Responsible for splitting up a file into \c FormatTokens.
 class FormatTokenLexer {
 public:
   FormatTokenLexer(SourceManager , FileID ID, FormatStyle ,
@@ -1417,6 +1418,15 @@
   }
 }
 
+/// \brief Responsible for taking a file and producing whitespace adjustments
+/// to reformat the file according to a desired style.
+///
+/// The pipeline used by \c Formatter:
+/// -# A \c FormatTokenLexer splits the file into raw tokens
+/// -# A \c UnwrappedLineParser converts those into logical lines
+/// -# A \c TokenAnnotator computes metadata for the tokens in each line
+/// -# A \c UnwrappedLineFormatter then produces whitespace adjustments
+///which result in the desired logical lines
 class Formatter : public UnwrappedLineConsumer {
 public:
   Formatter(const FormatStyle , SourceManager , FileID ID,
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -32,6 +32,8 @@
 struct ParenState;
 class WhitespaceManager;
 
+/// \brief Helper class for breaking a logical line into multiple physical
+/// lines.  Manages moving state from one physical line to the next.
 class ContinuationIndenter {
 public:
   /// \brief Constructs a \c ContinuationIndenter to format \p Line starting in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: echristo, jhen, cfe-commits.

This is used by D16082 when it invokes fatbinary.

http://reviews.llvm.org/D16097

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  test/Driver/cuda-bad-arch.cu

Index: test/Driver/cuda-bad-arch.cu
===
--- test/Driver/cuda-bad-arch.cu
+++ test/Driver/cuda-bad-arch.cu
@@ -5,28 +5,16 @@
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 
2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 
\
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_19 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
 
 // BAD: error: Unsupported CUDA gpu architecture
 
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix OK %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 
\
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -50,6 +50,21 @@
 BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
 : Action(BindArchClass, Input), ArchName(_ArchName) {}
 
+// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual
+// compute arch, e.g. "compute_20".  Returns null if the input arch is null or
+// doesn't match an existing arch.
+static const char* GpuArchToComputeName(const char *ArchName) {
+  if (!ArchName)
+return nullptr;
+  llvm::StringRef A(ArchName);
+  if (A == "sm_20" || A == "sm_21") return "compute_20";
+  if (A == "sm_30" || A == "sm_32") return "compute_30";
+  if (A == "sm_35") return "compute_35";
+  if (A == "sm_50") return "compute_50";
+  if (A == "sm_52") return "compute_52";
+  return nullptr;
+}
+
 void CudaDeviceAction::anchor() {}
 
 CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName,
@@ -59,9 +74,12 @@
   assert(IsValidGpuArchName(GpuArchName));
 }
 
+const char *CudaDeviceAction::getComputeArchName() const {
+  return GpuArchToComputeName(GpuArchName);
+}
+
 bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) {
-  static llvm::Regex RE("^sm_[0-9]+$");
-  return RE.match(ArchName);
+  return GpuArchToComputeName(ArchName.data()) != nullptr;
 }
 
 void CudaHostAction::anchor() {}
Index: include/clang/Driver/Action.h
===
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -146,6 +146,10 @@
   CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel);
 
   const char *getGpuArchName() const { return GpuArchName; }
+
+  /// Gets the compute_XX that corresponds to getGpuArchName().
+  const char *getComputeArchName() const;
+
   bool isAtTopLevel() const { return AtTopLevel; }
 
   static bool IsValidGpuArchName(llvm::StringRef ArchName);


Index: test/Driver/cuda-bad-arch.cu
===
--- test/Driver/cuda-bad-arch.cu
+++ test/Driver/cuda-bad-arch.cu
@@ -5,28 +5,16 @@
 
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix BAD %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix BAD %s
-// RUN: %clang -### -target 

Re: [PATCH] D16056: [Gold] Pass -mllvm options to the gold plugin

2016-01-11 Thread Mehdi Amini via cfe-commits
I’d fear the same thing. On our platform you have to use explicitly -Wl,-mllvm  
(or -Xlinker -plugin-opt).

— 
Mehdi


> On Jan 11, 2016, at 4:11 PM, Rafael Espíndola  
> wrote:
> 
> Maybe. I would like a second opinion on this one. The potential issue
> I see is that we are using compiler options during linking. Normally
> they are just ignored. Is it surprising if LTO starts using them?
> 
> Cheers,
> Rafael
> 
> 
> On 11 January 2016 at 06:47, James Molloy  wrote:
>> jmolloy created this revision.
>> jmolloy added a reviewer: rafael.
>> jmolloy added a subscriber: cfe-commits.
>> jmolloy set the repository for this revision to rL LLVM.
>> Herald added a subscriber: joker.eph.
>> 
>> The gold plugin can take LLVM options, but the syntax is confusing: 
>> -Wl,-plugin-opt= or -Xlinker -plugin-opt=.
>> 
>> Instead, pass -mllvm options through to Gold so the obvious syntax works.
>> 
>> Repository:
>>  rL LLVM
>> 
>> http://reviews.llvm.org/D16056
>> 
>> Files:
>>  lib/Driver/Tools.cpp
>>  test/Driver/gold-lto.c
>> 
>> Index: test/Driver/gold-lto.c
>> ===
>> --- test/Driver/gold-lto.c
>> +++ test/Driver/gold-lto.c
>> @@ -16,11 +16,14 @@
>> // CHECK-X86-64-COREI7: "-plugin-opt=foo"
>> //
>> // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
>> -// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
>> +// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 -mllvm -bar=baz \
>> +// RUN: -mllvm -test-option \
>> // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
>> // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
>> // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
>> // CHECK-ARM-V7A: "-plugin-opt=O0"
>> +// CHECK-ARM-V7A: "-plugin-opt=-bar=baz"
>> +// CHECK-ARM-V7A: "-plugin-opt=-test-option"
>> // CHECK-ARM-V7A: "-plugin-opt=foo"
>> //
>> // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
>> Index: lib/Driver/Tools.cpp
>> ===
>> --- lib/Driver/Tools.cpp
>> +++ lib/Driver/Tools.cpp
>> @@ -1817,6 +1817,12 @@
>> 
>>   if (IsThinLTO)
>> CmdArgs.push_back("-plugin-opt=thinlto");
>> +
>> +  // Claim and pass through -mllvm options to the Gold plugin.
>> +  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
>> +A->claim();
>> +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + 
>> A->getValue(0)));
>> +  }
>> }
>> 
>> /// This is a helper function for validating the optional refinement step
>> 
>> 

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


r257318 - AnalysisConsumer: use canonical decl for both lookup and store of

2016-01-11 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Mon Jan 11 03:38:48 2016
New Revision: 257318

URL: http://llvm.org/viewvc/llvm-project?rev=257318=rev
Log:
AnalysisConsumer: use canonical decl for both lookup and store of
visited decls.

Due to redeclarations, the function may have different declarations used
in CallExpr and in the definition. However, we need to use a unique
declaration for both store and lookup in VisitedCallees. This patch
fixes issues with analysis in topological order. A simple test is
included.

Patch by Alex Sidorin!

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

Added:
cfe/trunk/test/Analysis/inlining/analysis-order.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=257318=257317=257318=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Mon Jan 11 
03:38:48 2016
@@ -496,10 +496,11 @@ void AnalysisConsumer::HandleDeclsCallGr
(Mgr->options.InliningMode == All ? nullptr : ));
 
 // Add the visited callees to the global visited set.
-for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
-   E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
-}
+for (const Decl *Callee : VisitedCallees)
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(Callee) ? Callee
+ : Callee->getCanonicalDecl());
 VisitedAsTopLevel.insert(D);
   }
 }

Added: cfe/trunk/test/Analysis/inlining/analysis-order.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/analysis-order.c?rev=257318=auto
==
--- cfe/trunk/test/Analysis/inlining/analysis-order.c (added)
+++ cfe/trunk/test/Analysis/inlining/analysis-order.c Mon Jan 11 03:38:48 2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions 
-analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2


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


[PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 created this revision.
pxli168 added reviewers: Anastasia, pekka.jaaskelainen.
pxli168 added subscribers: bader, cfe-commits.

Add Sema checks for opencl 2.0 new features: Block, pipe, atomic etc. Also fix 
some old Sema check like pointer to image.
This patch is based on bader's patch in SPIRV-1.0 branch. 

http://reviews.llvm.org/D16047

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-decl.cl

Index: test/SemaOpenCL/invalid-decl.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-decl.cl
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 %s 
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+#define ATOMIC_VAR_INIT 
+int; // expected-error {{declaration does not declare anything}}
+
+void test1(){
+  myfun(); // expected-error {{implicit declaration of function 'myfun' is invalid in OpenCL}}
+}
+
+void test2(image1d_t *i){} // expected-error {{pointer to image is invalid in OpenCL}}
+
+void test3() {
+  pipe int p; // expected-error {{pipe can only be used as a function parameter}}
+  image1d_t i; // expected-error {{image can only be used as a function parameter}}
+}
+
+void kernel test4() {
+  atomic_int guide = ATOMIC_VAR_INIT(42); // expected-error {{initialization of atomic variables is restricted to variables in global address space in opencl}}
+}
Index: test/SemaOpenCL/invalid-block.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-block.cl
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s
+
+int (^BlkVariadic)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed}}
+  return 0;
+};
+
+typedef int (^BlkInt)(int);
+void f1(int i) {
+  BlkInt B1 = ^int(int I) {return 1;};
+  BlkInt B2 = ^int(int I) {return 2;};
+  BlkInt Arr[] = {B1, B2}; // expected-error {{array of block is invalid in OpenCL}}
+  int tmp = i ? B1(i)  // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+  : B2(i); // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+}
+
+void f2(BlkInt *BlockPtr) {
+  BlkInt B = ^int(int I) {return 1;};
+  BlkInt *P =  // expected-error {{invalid argument type 'BlkInt' (aka 'int (^)(int)') to unary expression}}
+  B = *BlockPtr;  // expected-error {{dereferencing pointer of type '__generic BlkInt *' (aka 'int (^__generic *)(int)') is not allowed}}
+}
+
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -35,6 +35,3 @@
   fnc4smp(glb_smp);
 // CHECK: call {{.*}}void @fnc4smp(i32
 }
-
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {}
-// CHECK-LABEL: @{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2176,6 +2176,14 @@
 Diag(Loc, diag::warn_vla_used);
   }
 
+  // OpenCL v2.0 s6.12.5 -- The following Blocks features are currently not
+  // supported in OpenCL C: Arrays of Blocks.
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 &&
+  Context.getBaseElementType(T)->isBlockPointerType()) {
+Diag(Loc, diag::err_opencl_invalid_block_array);
+return QualType();
+  }
+
   return T;
 }
 
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6135,6 +6135,22 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0 s6.13.1.1 -- This macro can only be used to initialize atomic
+  // objects that are declared in program scope in the global address space.
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 &&
+  Entity.getType()->isAtomicType()) {
+Qualifiers TyQualifiers = Entity.getType().getQualifiers();
+bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
+   TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+if (!HasGlobalAS && Entity.getKind() == InitializedEntity::EK_Variable &&
+Args.size() > 0) {
+  const Expr *Init = Args[0];
+  S.Diag(Init->getLocStart(), diag::err_opencl_atomic_init_addressspace)
+  << SourceRange(Entity.getDecl()->getLocStart(), Init->getLocEnd());
+  return ExprError();
+}
+  }
+
   // Diagnose cases where we initialize a pointer to an array temporary, and the
   // pointer obviously outlives the temporary.
   if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
Index: 

r257325 - clang-format: Slightly row back on r257257.

2016-01-11 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 11 05:01:05 2016
New Revision: 257325

URL: http://llvm.org/viewvc/llvm-project?rev=257325=rev
Log:
clang-format: Slightly row back on r257257.

r257257 change the way clang-format enforces line breaks after a
templated type has been line-wrapped. This was to fix an incorrect line
break if BinPackParameters is set to false. However, it also leads to
an unwanted line break in a different case. Thus, for now, only do this
when BinPackParameters is false. This isn't ideal yet, but helps us
until we have a better solution.

With BinPackParameters:
Before:
  void fff(aaa aa);

After:
  void fff(
  aaa
  aa);

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=257325=257324=257325=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jan 11 05:01:05 2016
@@ -151,7 +151,11 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
-Previous.NestingLevel == 1) ||
+// FIXME: This is a temporary workaround for the case where 
clang-format
+// sets BreakBeforeParameter to avoid bin packing and this creates a
+// completely unnecessary line break after a template type that isn't
+// line-wrapped.
+(Previous.NestingLevel == 1 || Style.BinPackParameters)) ||
(Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
 Previous.isNot(tok::question)) ||
(!Style.BreakBeforeTernaryOperators &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257325=257324=257325=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 11 05:01:05 2016
@@ -4062,10 +4062,23 @@ TEST_F(FormatTest, FormatsDeclarationsOn
"   int ,\n"
"   int aaa) {}",
NoBinPacking);
+
   NoBinPacking.AllowAllParametersOfDeclarationOnNextLine = false;
   verifyFormat("void aa(,\n"
"vector bbb);",
NoBinPacking);
+  // FIXME: This behavior difference is probably not wanted. However, currently
+  // we cannot distinguish BreakBeforeParameter being set because of the 
wrapped
+  // template arguments from BreakBeforeParameter being set because of the
+  // one-per-line formatting.
+  verifyFormat(
+  "void fff(aaa aa);",
+  NoBinPacking);
+  verifyFormat(
+  "void fff(\n"
+  "aaa\n"
+  "aa);");
 }
 
 TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {


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


Re: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2016-01-11 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

John and Richard,

I would like to proceed with this patch one way or another. If this patch 
cannot be accepted in upstream, I'll discard it. On the other hand I'm ready to 
improve this patch further if it is OK in principle but needs more work. Please 
let me know how you would like to proceed?

  Thanks,
  Dmitry


http://reviews.llvm.org/D14980



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


Re: [PATCH] D15888: [Analyzer] Change the default SA checkers for PS4

2016-01-11 Thread Yury Gribov via cfe-commits
ygribov added a subscriber: ygribov.
ygribov added a comment.

What's the problem with Vfork though?


http://reviews.llvm.org/D15888



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


Re: [PATCH] D15410: AnalysisConsumer: use canonical decl for both lookup and store of visited decls

2016-01-11 Thread Yury Gribov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257318: AnalysisConsumer: use canonical decl for both lookup 
and store of (authored by ygribov).

Changed prior to commit:
  http://reviews.llvm.org/D15410?vs=43726=6#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15410

Files:
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Analysis/inlining/analysis-order.c

Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -496,10 +496,11 @@
(Mgr->options.InliningMode == All ? nullptr : ));
 
 // Add the visited callees to the global visited set.
-for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
-   E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
-}
+for (const Decl *Callee : VisitedCallees)
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(Callee) ? Callee
+ : Callee->getCanonicalDecl());
 VisitedAsTopLevel.insert(D);
   }
 }
Index: cfe/trunk/test/Analysis/inlining/analysis-order.c
===
--- cfe/trunk/test/Analysis/inlining/analysis-order.c
+++ cfe/trunk/test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions 
-analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2


Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -496,10 +496,11 @@
(Mgr->options.InliningMode == All ? nullptr : ));
 
 // Add the visited callees to the global visited set.
-for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
-   E = VisitedCallees.end(); I != E; ++I) {
-Visited.insert(*I);
-}
+for (const Decl *Callee : VisitedCallees)
+  // Decls from CallGraph are already canonical. But Decls coming from
+  // CallExprs may be not. We should canonicalize them manually.
+  Visited.insert(isa(Callee) ? Callee
+ : Callee->getCanonicalDecl());
 VisitedAsTopLevel.insert(D);
   }
 }
Index: cfe/trunk/test/Analysis/inlining/analysis-order.c
===
--- cfe/trunk/test/Analysis/inlining/analysis-order.c
+++ cfe/trunk/test/Analysis/inlining/analysis-order.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Do not analyze test1() again because it was inlined
+void test1();
+
+void test2() {
+  test1();
+}
+
+void test1() {
+}
+
+// CHECK: analysis-order.c test2
+// CHECK-NEXT: analysis-order.c test1
+// CHECK-NEXT: analysis-order.c test2
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-01-11 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 9.
kfunk added a comment.

Update, add (non-working) test

Just uploading my WIP patch, now that the branching comes close. I added a 
test, unfortunately it doesn't do what I expect.
Please see the FIXME.

Didn't have the time to investigate yet, so any hints welcome!


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance ,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set 
+  Visitor(const std::set )
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema  = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine  = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;

Re: [PATCH] D12901: [Static Analyzer] Assertion "System is over constrained" after truncating 64 bits integers to 32 bits. (PR25078)

2016-01-11 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D12901#320680, @zaks.anna wrote:

> > This patch also fixes a bug in 'RangeSet::pin' causing single value ranges 
> > to not be considered conventionally ordered.
>
>
> Can that fix be submitted as a separate patch? Is there a test for it?


Yes I will look at creating a separate review for it.
Tests at lines 81, 111, 131 fail without the fix to RangeSet::pin.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:351
@@ -351,1 +350,3 @@
   }
+  case CK_IntegralCast: {
+// Delegate to SValBuilder to process.

zaks.anna wrote:
> SValBuilder::evalCast and SimpleSValBuilder::evalCastFromNonLoc perform a lot 
> of special casing. I am not sure we are not loosing anything if we bypass 
> them. For example, there is special handling of Booleans. We might want to 
> add this smarter handling of the integral conversions inside 
> SimpleSValBuilder::evalCastFromNonLoc, where you see the comment starting 
> with "If the types are the same or both are integers, ignore the cast."
Yes I initially looked at making the change in 'evalCastFromNonLoc' but the 
problem is that the change requires access to the ProgramState, so to avoid 
changing the interface of evalCast (used in around 50 places) I made the change 
here.
Looking at evalCast it does not seem to add any special handling to casts of 
type 'CK_IntegralCast' before calling 'evalCastFromNonLoc'?
Booleans casts should be associated with another type of cast than 
'CK_IntegralCast' and the new 'evalIntegralCast' will call 'evalCast' if it 
does not detect a truncation so it should be ok, what do you think?


http://reviews.llvm.org/D12901



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


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:4934
@@ +4933,3 @@
+const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
+if (AccessAttr->isReadWrite()) {
+  if (DeclTy->isPipeType() ||

Anastasia wrote:
> In the case of failure, where would destructor of AccessAttr be called?
> 
> Could we invoke it before exiting? Or alternatively it's possible to check an 
> access kind based on string matching from Attr getName() and create 
> AccessAttr later on success.
Nice catch, I think I will try if getName() can handle this, or I think maybe I 
need a destructor.



Comment at: lib/Sema/SemaDeclAttr.cpp:5694
@@ +5693,3 @@
+// attribute and may cause the same attribute to be added twice
+if (const ParmVarDecl *PDecl = llvm::dyn_cast(D)) {
+  if (PDecl->getType().getCanonicalType().getTypePtr()->isPipeType())

Anastasia wrote:
> So where would the attribute check happen? I don't think the comment is very 
> clear.
Maybe I don't make my self claer.

The pipe decl like
```
SomeFn(read_only pipe int p)
```
It will process read_only twice which is not expected, this will make attr add 
twice.

I will make the comment clearer to understand.



Comment at: test/SemaOpenCL/invalid-kernel-attrs.cl:31
@@ -30,3 +30,3 @@
   int __kernel x; // expected-error {{'__kernel' attribute only applies to 
functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to 
parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only 
applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only 
applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only 
applies to parameters}}

Anastasia wrote:
> Strangely, I don't see this diagnostic being added in this patch.
As you can see, the read_only used to use with int. Now we check the type, so 
int could not used for this test more. Just change the in to image1d_t to keep 
the old test case work.


http://reviews.llvm.org/D16040



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


Re: [PATCH] D15791: Disable generating movt on FreeBSD

2016-01-11 Thread Davide Italiano via cfe-commits
davide closed this revision.
davide added a comment.

Close, this went in a while ago.


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:5733
@@ +5732,3 @@
+
+#if 0
+

pekka.jaaskelainen wrote:
> Is this intentionally included in the patch? 
My mistake, just want to check if this works. But find it is handled by 
something else.


Comment at: lib/Sema/SemaDecl.cpp:6759
@@ +6758,3 @@
+
+#if 0
+  // OpenCL v2.0 s6.9.b

pekka.jaaskelainen wrote:
> Ditto. Better not commit disabled code in the repository.
Removed


Comment at: lib/Sema/SemaExpr.cpp:6295
@@ +6294,3 @@
+  // OpenCL v2.0 s6.12.5 -- To support these behaviors, additional
+  // restrictions28 in addition to the above feature restrictions are: Blocks
+  // cannot be used as expressions of the ternary selection operator (?:).

pekka.jaaskelainen wrote:
> -28
Fixed


Comment at: lib/Sema/SemaExpr.cpp:6298
@@ +6297,3 @@
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+if (checkBlockType(*this, LHS.get()) | checkBlockType(*this, RHS.get()))
+  return QualType();

pekka.jaaskelainen wrote:
> ||
Intend to do this in order to get both err diag for both LHS and RHS.


http://reviews.llvm.org/D16047



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


Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 44599.
pxli168 added a comment.

Remove some unused codes and add inline comment.


http://reviews.llvm.org/D16047

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-decl.cl

Index: test/SemaOpenCL/invalid-decl.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-decl.cl
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 %s 
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+#define ATOMIC_VAR_INIT 
+int; // expected-error {{declaration does not declare anything}}
+
+void test1(){
+  myfun(); // expected-error {{implicit declaration of function 'myfun' is invalid in OpenCL}}
+}
+
+void test2(image1d_t *i){} // expected-error {{pointer to image is invalid in OpenCL}}
+
+void test3() {
+  pipe int p; // expected-error {{pipe can only be used as a function parameter}}
+  image1d_t i; // expected-error {{image can only be used as a function parameter}}
+}
+
+void kernel test4() {
+  atomic_int guide = ATOMIC_VAR_INIT(42); // expected-error {{initialization of atomic variables is restricted to variables in global address space in opencl}}
+}
Index: test/SemaOpenCL/invalid-block.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-block.cl
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s
+
+int (^BlkVariadic)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed}}
+  return 0;
+};
+
+typedef int (^BlkInt)(int);
+void f1(int i) {
+  BlkInt B1 = ^int(int I) {return 1;};
+  BlkInt B2 = ^int(int I) {return 2;};
+  BlkInt Arr[] = {B1, B2}; // expected-error {{array of block is invalid in OpenCL}}
+  int tmp = i ? B1(i)  // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+  : B2(i); // expected-error {{blocks cannot be used as expressions in ternary expressions}}
+}
+
+void f2(BlkInt *BlockPtr) {
+  BlkInt B = ^int(int I) {return 1;};
+  BlkInt *P =  // expected-error {{invalid argument type 'BlkInt' (aka 'int (^)(int)') to unary expression}}
+  B = *BlockPtr;  // expected-error {{dereferencing pointer of type '__generic BlkInt *' (aka 'int (^__generic *)(int)') is not allowed}}
+}
+
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -35,6 +35,3 @@
   fnc4smp(glb_smp);
 // CHECK: call {{.*}}void @fnc4smp(i32
 }
-
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {}
-// CHECK-LABEL: @{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2176,6 +2176,14 @@
 Diag(Loc, diag::warn_vla_used);
   }
 
+  // OpenCL v2.0 s6.12.5 - The following Blocks features are currently not
+  // supported in OpenCL C: Arrays of Blocks.
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 &&
+  Context.getBaseElementType(T)->isBlockPointerType()) {
+Diag(Loc, diag::err_opencl_invalid_block_array);
+return QualType();
+  }
+
   return T;
 }
 
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6135,6 +6135,22 @@
   << Init->getSourceRange();
   }
 
+  // OpenCL v2.0 s6.13.1.1 - This macro can only be used to initialize atomic
+  // objects that are declared in program scope in the global address space.
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 &&
+  Entity.getType()->isAtomicType()) {
+Qualifiers TyQualifiers = Entity.getType().getQualifiers();
+bool HasGlobalAS = TyQualifiers.hasAddressSpace() &&
+   TyQualifiers.getAddressSpace() == LangAS::opencl_global;
+if (!HasGlobalAS && Entity.getKind() == InitializedEntity::EK_Variable &&
+Args.size() > 0) {
+  const Expr *Init = Args[0];
+  S.Diag(Init->getLocStart(), diag::err_opencl_atomic_init_addressspace)
+  << SourceRange(Entity.getDecl()->getLocStart(), Init->getLocEnd());
+  return ExprError();
+}
+  }
+
   // Diagnose cases where we initialize a pointer to an array temporary, and the
   // pointer obviously outlives the temporary.
   if (Args.size() == 1 && Args[0]->getType()->isArrayType() &&
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6230,6 +6230,18 @@
   return 

Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.

2016-01-11 Thread Adrian Zgorzałek via cfe-commits
adek05 updated this revision to Diff 44598.
adek05 added a comment.

Adding testcases in unittest/AST/SourceLocationTest.cpp as suggested by 
@aaronballman

Interestingly, without my change tests for function declarations pass. Only 
member functions fail:

  tools/clang/unittests/AST/ASTTests
  ...
  [--] 2 tests from FunctionDecl
  [ RUN  ] FunctionDecl.FunctionDeclWithThrowSpecification
  [   OK ] FunctionDecl.FunctionDeclWithThrowSpecification (17 ms)
  [ RUN  ] FunctionDecl.FunctionDeclWithNoExceptSpecification
  [   OK ] FunctionDecl.FunctionDeclWithNoExceptSpecification (10 ms)
  [--] 2 tests from FunctionDecl (27 ms total)
  
  [--] 2 tests from CXXMethodDecl
  [ RUN  ] CXXMethodDecl.CXXMethodDeclWithThrowSpecification
  /Users/adek/llvm-git/tools/clang/unittests/AST/SourceLocationTest.cpp:569: 
Failure
  Value of: Verifier.match( "class A {\n" "void f() throw();\n" "};\n", 
functionDecl())
Actual: false (Expected range <2:1-2:16>, found 
)
  Expected: true
  [  FAILED  ] CXXMethodDecl.CXXMethodDeclWithThrowSpecification (10 ms)
  [ RUN  ] CXXMethodDecl.CXXMethodDeclWithNoExceptSpecification
  /Users/adek/llvm-git/tools/clang/unittests/AST/SourceLocationTest.cpp:580: 
Failure
  Value of: Verifier.match( "class A {\n" "void f() noexcept(false);\n" "};\n", 
functionDecl(), Language::Lang_CXX11)
Actual: false (Expected range <2:1-2:24>, found 
)
  Expected: true
  [  FAILED  ] CXXMethodDecl.CXXMethodDeclWithNoExceptSpecification (10 ms)
  [--] 2 tests from CXXMethodDecl (20 ms total)

Not sure why would they take different codepaths, throw and noexcept are 
C++(11) specific. Is the code parsed as C++11 anyway for Verifiers?


http://reviews.llvm.org/D15443

Files:
  lib/Parse/ParseDeclCXX.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -542,5 +542,43 @@
   cxxConstructExpr(), Lang_OBJCXX));
 }
 
+TEST(FunctionDecl, FunctionDeclWithThrowSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 16);
+  EXPECT_TRUE(Verifier.match(
+  "void f() throw();\n",
+  functionDecl()));
+}
+
+TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 24);
+  EXPECT_TRUE(Verifier.match(
+  "void f() noexcept(false);\n",
+  functionDecl(),
+  Language::Lang_CXX11));
+}
+
+TEST(CXXMethodDecl, CXXMethodDeclWithThrowSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(2, 1, 2, 16);
+  EXPECT_TRUE(Verifier.match(
+  "class A {\n"
+  "void f() throw();\n"
+  "};\n",
+  functionDecl()));
+}
+
+TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(2, 1, 2, 24);
+  EXPECT_TRUE(Verifier.match(
+  "class A {\n"
+  "void f() noexcept(false);\n"
+  "};\n",
+  functionDecl(),
+  Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3358,7 +3358,8 @@
 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
  /*StopAtSemi=*/true,
  /*ConsumeFinalToken=*/true);
-SpecificationRange.setEnd(Tok.getLocation());
+SpecificationRange.setEnd(ExceptionSpecTokens->back().getLocation());
+
 return EST_Unparsed;
   }
   


Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -542,5 +542,43 @@
   cxxConstructExpr(), Lang_OBJCXX));
 }
 
+TEST(FunctionDecl, FunctionDeclWithThrowSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 16);
+  EXPECT_TRUE(Verifier.match(
+  "void f() throw();\n",
+  functionDecl()));
+}
+
+TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 24);
+  EXPECT_TRUE(Verifier.match(
+  "void f() noexcept(false);\n",
+  functionDecl(),
+  Language::Lang_CXX11));
+}
+
+TEST(CXXMethodDecl, CXXMethodDeclWithThrowSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(2, 1, 2, 16);
+  EXPECT_TRUE(Verifier.match(
+  "class A {\n"
+  "void f() throw();\n"
+  "};\n",
+  functionDecl()));
+}
+
+TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(2, 1, 2, 24);
+  EXPECT_TRUE(Verifier.match(
+  "class A {\n"
+  "void f() noexcept(false);\n"
+  "};\n",
+  functionDecl(),
+  Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end 

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

You need to add the code/tests for nesting of regions.



Comment at: include/clang-c/Index.h:2283
@@ +2282,3 @@
+   */
+  CXCursor_OMPTargetExitDataDirective= 262,
+

Target exit and target enter constructs must be implemented in different patches


Comment at: include/clang/AST/OpenMPClause.h:2745
@@ -2744,1 +2744,3 @@
+  /// \brief Is this an implicit map type or not.
+  bool MapTypeIsImplicit;
   /// \brief Location of the map type.

This also must be in a separate patch


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2665
@@ +2664,3 @@
+const OMPTargetEnterDataDirective ) {
+  llvm_unreachable("CodeGen for 'omp target enter data' is not supported.");
+}

Just ignore this pragma for now, no need to crash a compiler


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2670
@@ +2669,3 @@
+const OMPTargetExitDataDirective ) {
+  llvm_unreachable("CodeGen for 'omp target exit data' is not supported.");
+}

Just ignore this pragma for now, no need to crash a compiler


http://reviews.llvm.org/D15989



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


Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: include/clang/Basic/Builtins.def:1260
@@ +1259,3 @@
+
+LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)

Anastasia wrote:
> Ok, this way it means variable number of arg which isn't right either. But I 
> see some other builtins do the same.
> 
> I think a better approach would be to add pipe as a modifier and a way to 
> represent any gentype in builtins declarations here to be able to specify a 
> signature properly. Although it seems it won't be used for anything but 
> documentation purposes.
> 
> Also adding the overloaded variant for read/write_pipes explicitly might be a 
> good idea (similar to sync_fetch_and_add).
> 
> But I see that not all builtins follow this approach, so it's up to you.
I think this maybe OK for a def file, the parameter is strictly checked in 
Sema. 


Comment at: lib/CodeGen/CGBuiltin.cpp:2033
@@ +2032,3 @@
+  *Arg1 = EmitScalarExpr(E->getArg(1));
+llvm::Type *ReservedIDTy = ConvertType(getContext().OCLReserveIDTy);
+

pekka.jaaskelainen wrote:
> Anastasia wrote:
> > pekka.jaaskelainen wrote:
> > > Anastasia wrote:
> > > > Why do we need to modify user defined functions? Only builtins will 
> > > > have this extra parameter.
> > > > 
> > > > I think packet size would be useful for builtin implementation to know 
> > > > the number of bytes to be read/written. I don't see how to implement it 
> > > > correctly otherwise. As mentioned earlier relying on the metadata is 
> > > > not a conventional compilation approach and should be avoided if 
> > > > possible.
> > > The pipe struct can have the packet size in its header before the actual 
> > > ring buffer or whatever, which can be used as a fallback unless the 
> > > compiler can optimize it to a larger access. Correct implementation thus 
> > > doesn't require a "hidden parameter". Adding it as a compile time hidden 
> > > constant argument should help the optimizers, that's of course true, but 
> > > I don't think it's strictly required.
> > > 
> > > If you think having a special behavior for the built-ins calls isn't 
> > > problematic, then fine, I'm not having so strong opinion on this.
> > So where would this size be initialized/set? Note that host code might have 
> > different type sizes.
> > 
> > I am thinking that having a size parameter makes the generated function 
> > more generic since we lose information about the type here and recovering 
> > it might involve extra steps. I am currently not clear about how to do that.
> https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/clCreatePipe.html 
> sets the packet size in creation. We have a prototype implementation working 
> using that. But that generic software version uses a byte loop which is 
> painfully slow, which of course should be optimized to wide loads/stores 
> whenever possible.
> 
> If we want to optimize it, it means inlining the builtin call and then 
> deriving the size for the loop at the compile time after which it can be 
> vectorized (assuming the packet fifo is aligned). Where this size constant 
> comes from is the question under discussion -- you propose having it as an 
> additional hidden parameter to the calls and I propose a metadata. Yours 
> optimizes automatically but requires special casing (when calling a builtin, 
> not user function, add this magic parameter), mine requires a new 
> optimization that takes the MD in account and converts it to a constant after 
> inlining the built-in.
> 
> I'm open for both as I do not really know how much trouble the special casing 
> will bring and I appreciate that optimizations might just work, but in my 
> understanding the size info is strictly not required, but very useful for 
> optimization.
> I am thinking that having a size parameter makes the generated function more 
> generic since we lose information about the type here and recovering it might 
> involve extra steps. I am currently not clear about how to do that.

I know what Anastasia is worried about, but actually I should say that you can 
simply create a pass for the pipe function that get this information for the 
metadata, you can use MDNode to get these information pretty easy. That is what 
I am doing now.



Comment at: lib/Sema/SemaChecking.cpp:291
@@ +290,3 @@
+  bool isValid = true;
+  // TODO: For all pipe built-in read is for read_only?
+  bool ReadOnly = getFunctionName(Call).find("read") != StringRef::npos;

Anastasia wrote:
> I agree the spec doesn't require that checking but I think it's just being 
> imprecise in the description. If you are in doubt you can raise a bug with 
> Khronos to clarify. This might result in additional latency.
> 
> I think it makes sense though to check all of them.
I will keep it here then, and we can change it once the Khronos have some 
feeback.



Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 44601.
pxli168 added a comment.

Add negative tests to hint all paths in the Semacheck.


http://reviews.llvm.org/D15914

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/pipe_builtin.cl
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+void test1(read_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  read_pipe(tmp, p);// expected-error {{first argument to read_pipe must be a pipe type}}
+  read_pipe(p);   // expected-error {{invalid number of arguments to function: read_pipe}}
+  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting: 'reserve_id_t')}}
+  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting: 'unsigned int')}}
+  read_pipe(p, tmp);   // expected-error {{invalid argument type to function read_pipe (expecting: 'int *')}}
+  write_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+  write_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
+
+  // reserve_read/write_pipe
+  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_read_pipe (expecting: 'unsigned int')}}
+  work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_read_pipe must be a pipe type}}
+  sub_group_reserve_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}}
+
+  // commit_read/write_pipe
+  commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}}
+  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting: 'reserve_id_t')}}
+  sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}}
+}
+
+void test2(write_only pipe int p, global int* ptr){
+  int tmp;
+  reserve_id_t rid;
+
+  // read/write_pipe
+  write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}}
+  write_pipe(p);   // expected-error {{invalid number of arguments to function: write_pipe}}
+  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting: 'reserve_id_t')}}
+  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting: 'unsigned int')}}
+  write_pipe(p, tmp);   // expected-error {{invalid argument type to function write_pipe (expecting: 'int *')}}
+  read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+  read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
+
+  // reserve_read/write_pipe
+  reserve_write_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_write_pipe (expecting: 'unsigned int')}}
+  work_group_reserve_write_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_write_pipe must be a pipe type}}
+  sub_group_reserve_read_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting read_only)}}
+
+  // commit_read/write_pipe
+  commit_write_pipe(tmp, rid);// expected-error{{first argument to commit_write_pipe must be a pipe type}}
+  work_group_commit_write_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_write_pipe (expecting: 'reserve_id_t')}}
+  sub_group_commit_read_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting read_only)}}
+}
+
+void test3(){
+  int tmp;
+  get_pipe_num_packets(tmp);// expected-error {{first argument to get_pipe_num_packets must be a pipe type}}
+  get_pipe_max_packets(tmp);// expected-error {{first argument to get_pipe_max_packets must be a pipe type}}
+}
+
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %opencl.pipe_t = type opaque
+// CHECK: %opencl.reserve_id_t = type opaque
+
+void test1(read_only pipe int p, global int *ptr) {
+  // CHECK: call i32 @read_pipe_2(%opencl.pipe_t* %{{.*}}, i8 addrspace(4)* %{{.*}})
+  read_pipe(p, ptr);
+  // CHECK: call %opencl.reserve_id_t* @reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 

Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-01-11 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 44600.
pxli168 added a comment.

Fix destruct problem and fix style in inline comment.


http://reviews.llvm.org/D16040

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/Parser/opencl-image-access.cl
  test/SemaOpenCL/invalid-kernel-attrs.cl

Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -28,8 +28,8 @@
 
 void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
   int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only applies to parameters}}
 }
 
 kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
Index: test/Parser/opencl-image-access.cl
===
--- test/Parser/opencl-image-access.cl
+++ test/Parser/opencl-image-access.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -fsyntax-only
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0 -DCL20
 
 __kernel void f__ro(__read_only image2d_t a) { }
 
 __kernel void f__wo(__write_only image2d_t a) { }
 
+#if CL20
 __kernel void f__rw(__read_write image2d_t a) { }
-
+#endif
 
 __kernel void fro(read_only image2d_t a) { }
 
 __kernel void fwo(write_only image2d_t a) { }
 
+#if CL20
 __kernel void frw(read_write image2d_t a) { }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6217,6 +6217,17 @@
   CurType = S.Context.getVectorType(CurType, numElts, VecKind);
 }
 
+/// Handle OpenCL Access Qualifier Attribute
+static void HandleOpenCLAccessAttr(QualType , const AttributeList ,
+   Sema ) {
+  // OpenCL v2.0 s6.6: Access Qualifier can used only for image and pipe type
+  if (!(CurType->isImageType() || CurType->isPipeType())) {
+S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier);
+Attr.setInvalid();
+return;
+  }
+}
+
 static void processTypeAttrs(TypeProcessingState , QualType ,
  TypeAttrLocation TAL, AttributeList *attrs) {
   // Scan through and apply attributes to this type where it makes sense.  Some
@@ -6312,9 +6323,8 @@
VectorType::NeonPolyVector);
   attr.setUsedAsTypeAttr();
   break;
-case AttributeList::AT_OpenCLImageAccess:
-  // FIXME: there should be some type checking happening here, I would
-  // imagine, but the original handler's checking was entirely superfluous.
+case AttributeList::AT_OpenCLAccess:
+  HandleOpenCLAccessAttr(type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
   break;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4906,6 +4906,43 @@
   return false;
 }
 
+static void handleOpenCLAccessAttr(Sema , Decl *D,
+   const AttributeList ) {
+  if (D->isInvalidDecl())
+return;
+
+  // Check if there only one access qualifier
+  if (D->hasAttr()) {
+S.Diag(D->getLocation(), diag::err_opencl_multiple_access_qualifiers)
+<< D->getSourceRange();
+D->setInvalidDecl(true);
+return;
+  }
+
+  // OpenCL v2.0 s6.6: read_write can be used for image type The __read_write
+  // (or read_write)qualifier must be used with image object arguments of
+  // kernels and of user-defined functions to declare if the image object is
+  // being both read and written by the kernel
+  // OpenCL v2.0 s6.13.6: A kernel cannot read from and write to the same pipe
+  // object. Using the read_write (or __read_write) qualifier with the pipe
+  // qualifier is a compilation error.
+  if (const ParmVarDecl *PDecl = llvm::dyn_cast(D)) {
+const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
+if (Attr.getName()->getName().find("read_write") != StringRef::npos) {
+  if (DeclTy->isPipeType() ||
+  (S.getLangOpts().OpenCLVersion < 200 && DeclTy->isImageType())) {
+S.Diag(D->getLocation(), diag::err_opencl_invalid_read_write)
+<< PDecl->getType() << DeclTy->isImageType() << D->getSourceRange();
+D->setInvalidDecl(true);
+

Re: [PATCH] D16056: [Gold] Pass -mllvm options to the gold plugin

2016-01-11 Thread James Molloy via cfe-commits
Ok, I'll abandon this.

It wasn't meant to be contentious and this is a reasonable objection!

James



> On 12 Jan 2016, at 00:53, Mehdi Amini  wrote:
>
> I’d fear the same thing. On our platform you have to use explicitly 
> -Wl,-mllvm  (or -Xlinker -plugin-opt).
>
> —
> Mehdi
>
>
>> On Jan 11, 2016, at 4:11 PM, Rafael Espíndola  
>> wrote:
>>
>> Maybe. I would like a second opinion on this one. The potential issue
>> I see is that we are using compiler options during linking. Normally
>> they are just ignored. Is it surprising if LTO starts using them?
>>
>> Cheers,
>> Rafael
>>
>>
>>> On 11 January 2016 at 06:47, James Molloy  wrote:
>>> jmolloy created this revision.
>>> jmolloy added a reviewer: rafael.
>>> jmolloy added a subscriber: cfe-commits.
>>> jmolloy set the repository for this revision to rL LLVM.
>>> Herald added a subscriber: joker.eph.
>>>
>>> The gold plugin can take LLVM options, but the syntax is confusing: 
>>> -Wl,-plugin-opt= or -Xlinker -plugin-opt=.
>>>
>>> Instead, pass -mllvm options through to Gold so the obvious syntax works.
>>>
>>> Repository:
>>> rL LLVM
>>>
>>> http://reviews.llvm.org/D16056
>>>
>>> Files:
>>> lib/Driver/Tools.cpp
>>> test/Driver/gold-lto.c
>>>
>>> Index: test/Driver/gold-lto.c
>>> ===
>>> --- test/Driver/gold-lto.c
>>> +++ test/Driver/gold-lto.c
>>> @@ -16,11 +16,14 @@
>>> // CHECK-X86-64-COREI7: "-plugin-opt=foo"
>>> //
>>> // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
>>> -// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
>>> +// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 -mllvm -bar=baz \
>>> +// RUN: -mllvm -test-option \
>>> // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
>>> // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
>>> // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
>>> // CHECK-ARM-V7A: "-plugin-opt=O0"
>>> +// CHECK-ARM-V7A: "-plugin-opt=-bar=baz"
>>> +// CHECK-ARM-V7A: "-plugin-opt=-test-option"
>>> // CHECK-ARM-V7A: "-plugin-opt=foo"
>>> //
>>> // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
>>> Index: lib/Driver/Tools.cpp
>>> ===
>>> --- lib/Driver/Tools.cpp
>>> +++ lib/Driver/Tools.cpp
>>> @@ -1817,6 +1817,12 @@
>>>
>>>  if (IsThinLTO)
>>>CmdArgs.push_back("-plugin-opt=thinlto");
>>> +
>>> +  // Claim and pass through -mllvm options to the Gold plugin.
>>> +  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
>>> +A->claim();
>>> +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + 
>>> A->getValue(0)));
>>> +  }
>>> }
>>>
>>> /// This is a helper function for validating the optional refinement step
>
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

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


Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).

2016-01-11 Thread Manuel Jacob via cfe-commits
mjacob added a comment.

In http://reviews.llvm.org/D15998#324354, @reames wrote:

> Also, before this gets exposed through Clang, we really should 
> formalize/document the attribute.   In practice, it implies the lack of a 
> safepoint poll site inside the called function.  Annoyingly, it's not an 
> inferable property since we don't represent the possible insertion of a poll 
> in the IR.


That wouldn't work for my language since it doesn't use polls at all. Instead, 
a practical definition would be: "a statepoint will not be inserted if the call 
site or callee has this attribute".  My language backend currently relies on 
this, e.g. if calling printf (currently statepoints don't support vararg 
callees).

> Hm.  This makes me wonder... We've moved to a model of inserting safepoints 
> (specifically for deopt info) early, and then rewriting late in our tree.  
> We're not even using the PlaceSafepoints pass any more.  It's been left 
> mostly for other users.  Would it maybe make sense to fully retire 
> PlaceSafepoints and migrate over to a scheme where safepoints sites are 
> explicit from the beginning?  This would allow us to infer "gc-leaf" from 
> FunctionAttrs...


With explicit safepoints and the above-mentioned definition the gc-leaf-funtion 
attribute wouldn't be necessary at all, because then a function is a GC leaf if 
and only if no safepoint should be inserted when calling this function.

> (This high level discussion should probably move to llvm-dev.  I can start it 
> if you'd like, otherwise post something and I'll reply.)


I think it makes more sense if you start the discussion because I'm not 
familiar with your use cases (I only use a subset of safepoint functionality, 
e.g. no safepoint polls).


http://reviews.llvm.org/D15998



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-11 Thread Richard via cfe-commits
LegalizeAdulthood marked an inline comment as done.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994
@@ +4993,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

aaron.ballman wrote:
> Thank you for those examples! Given the following code:
> ```
> typedef int foo;
> typedef foo bar;
> 
> bar i;
> ```
> clang-query> match varDecl(hasType(asString("int")))
> 0 matches.
> clang-query> match varDecl(hasType(asString("foo")))
> 0 matches.
> clang-query> match varDecl(hasType(asString("bar")))
> 
> Match #1:
> 
> E:\Desktop\t.cpp:4:1: note: "root" binds here
> bar i;
> ^
> 1 match.
> 
> So hasType() looks at what the immediate type is for the declaration (which 
> we document, yay us!). Based on that, I don't think hasUnderlyingType() makes 
> sense -- you should modify hasType() to work on a TypedefNameDecl (not just a 
> TypedefDecl!) so that it looks at the immediate type of the type definition. 
> I would expect your tests then to result in:
> ```
> 1: typedef void (fn)(void);
> 2: typedef fn foo;
> 3: typedef int bar;
> 4: typedef int (f);
> 5: typedef int (fn2)(int);
> clang-query> match typedefDecl(hasType(asString("int")))
> 
> Match #1:
> 
> /tmp/a.cpp:3:1: note: "root" binds here
> typedef int bar;
> ^~~
> 
> Match #2:
> 
> /tmp/a.cpp:4:1: note: "root" binds here
> typedef int (f);
> ^~~
> 2 matches.
> clang-query> match typedefDecl(hasType(typedefType()))
> 
> Match #1:
> 
> /tmp/a.cpp:2:1: note: "root" binds here
> typedef fn foo;
> ^~
> 1 match.
> clang-query> match typedefDecl(hasType(parenType()))
> 
> Match #1:
> 
> /tmp/a.cpp:1:1: note: "root" binds here
> typedef void (fn)(void);
> ^~~
> 
> Match #2:
> 
> /tmp/a.cpp:4:1: note: "root" binds here
> typedef int (f);
> ^~~
> 
> Match #3:
> 
> /tmp/a.cpp:5:1: note: "root" binds here
> typedef int (fn2)(int);
> ^~
> 3 matches.
> clang-query> match typedefDecl(hasType(parenType(innerType(functionType()
> 
> Match #1:
> 
> /tmp/a.cpp:1:1: note: "root" binds here
> typedef void (fn)(void);
> ^~~
> 
> Match #2:
> 
> /tmp/a.cpp:5:1: note: "root" binds here
> typedef int (fn2)(int);
> ^~
> 2 matches.
> ```
> The end results are the same, so this is just changing the way the 
> information is surfaced to the user that is logically consistent. ValueDecls 
> have an immediate type, and so do TypedefDecls. By using TypedefNameDecl 
> instead of TypedefDecl, this also covers the case where hasType() is useful 
> for an alias-declaration. (We don't expose the matcher for that yet, but it 
> seems quite reasonable to add in the future, and it would be nice for hasType 
> to automatically work with that.)
> 
> You can implement this with a helper function to handle abstracting away the 
> call to getType() vs getUnderlyingType(), then updating the hasType() 
> matchers to use it. Something like:
> ```
> template 
> struct UnderlyingTypeGetter {
>   static QualType get(const Ty ) {
> return Node.getType();
>   }
> };
> 
> template <>
> QualType UnderlyingTypeGetter::get(const TypedefNameDecl 
> ) {
>   return Node.getUnderlyingType();
> }
> ```
> (Somewhere in ASTMatchersInternal.h most likely.)
> 
When I try to extend `hasType` to work on `TypedefDecl`, I get this error:

```
error: static assertion failed: right polymorphic conversion
 static_assert(TypeListContainsSuperOf::value,
```

...because `TypedefDecl` is derived from `NamedDecl` and the existing 
definition for `hasType` looks like this:

```
AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType,
   AST_POLYMORPHIC_SUPPORTED_TYPES(Expr,
   ValueDecl),
   internal::Matcher, InnerMatcher, 1) {
  return qualType(hasDeclaration(InnerMatcher))
  .matches(Node.getType(), Finder, Builder);
}
```

So I'll need some guidance on how to extend `hasType` to work for 
`TypedefNamedDecl` nodes.  I don't understand exactly what all these nasty 
macros do.  So far, I've simply made changes by imitation, but my approach 
didn't work this time.


http://reviews.llvm.org/D8149



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


r257451 - clang-format: [JS] Support exporting abstract classes.

2016-01-11 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jan 12 00:24:38 2016
New Revision: 257451

URL: http://llvm.org/viewvc/llvm-project?rev=257451=rev
Log:
clang-format: [JS] Support exporting abstract classes.

Before:
  export abstract class X {y: number;}
(and all sorts of other havoc in more complicated cases).

After:
  export abstract class X { y: number; }

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=257451=257450=257451=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Jan 12 00:24:38 2016
@@ -1809,6 +1809,10 @@ void UnwrappedLineParser::parseJavaScrip
 return;
   }
 
+  // Consume the "abstract" in "export abstract class".
+  if (FormatTok->is(Keywords.kw_abstract))
+nextToken();
+
   if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum,
  Keywords.kw_interface, Keywords.kw_let,
  Keywords.kw_var))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257451=257450=257451=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jan 12 00:24:38 2016
@@ -878,6 +878,7 @@ TEST_F(FormatTestJS, Modules) {
"  y: string;\n"
"}");
   verifyFormat("export class X { y: number; }");
+  verifyFormat("export abstract class X { y: number; }");
   verifyFormat("export default class X { y: number }");
   verifyFormat("export default function() {\n  return 1;\n}");
   verifyFormat("export var x = 12;");


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


[PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added reviewers: tra, echristo.
jlebar added subscribers: jhen, cfe-commits.

Previously we compiled CUDA device code to PTX assembly and embedded
that asm as text in our host binary.  Now we compile to PTX assembly and
then invoke ptxas to assemble the PTX into a cubin file.  We gather the
ptx and cubin files for each of our --cuda-gpu-archs and combine them
using fatbinary, and then embed that into the host binary.

Adds two new command-line flags, -Xcuda_ptxas and -Xcuda_fatbinary,
which pass args down to the external tools.

http://reviews.llvm.org/D16082

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Options.td
  include/clang/Driver/Types.def
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Driver/Types.cpp
  test/Driver/Inputs/CUDA/usr/local/cuda/bin/.keep
  test/Driver/cuda-external-tools.cu
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -54,7 +54,7 @@
 // RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
 // RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix INCLUDES-DEVICE2 -check-prefix NOLINK %s
+// RUN:-check-prefix NOLINK %s
 
 // Verify that device-side results are passed to the correct tool when
 // -save-temps is used.
@@ -85,10 +85,16 @@
 // DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE-SAME: "-fcuda-is-device"
 // DEVICE-SM35-SAME: "-target-cpu" "sm_35"
-// DEVICE-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
+// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
 // DEVICE-NOSAVE-SAME: "-x" "cuda"
 // DEVICE-SAVE-SAME: "-x" "ir"
 
+// Match the call to ptxas (which assembles PTX to SASS).
+// DEVICE:ptxas
+// DEVICE-SM35-DAG: "--gpu-name" "sm_35"
+// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
+// DEVICE-DAG: "[[PTXFILE]]"
+
 // Match another device-side compilation.
 // DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -101,6 +107,11 @@
 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // NODEVICE-SAME-NOT: "-fcuda-is-device"
 
+// INCLUDES-DEVICE:fatbinary
+// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
+// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
+
 // Match host-side preprocessor job with -save-temps.
 // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
 // HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
@@ -114,8 +125,7 @@
 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // HOST-NOSAVE-SAME: "-x" "cuda"
 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
-// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
-// INCLUDES-DEVICE2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
+// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
 
 // Match external assembler that uses compilation output.
 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Index: test/Driver/cuda-external-tools.cu
===
--- /dev/null
+++ test/Driver/cuda-external-tools.cu
@@ -0,0 +1,66 @@
+// Tests that ptxas and fatbinary are correctly during CUDA compilation.
+//
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Regular compile with -O2.
+// RUN: %clang -### -target x86_64-linux-gnu -O2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 %s
+
+// Regular compile without -O.  This should result in us passing -O0 to ptxas.
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
+
+// Regular compile targeting sm_35.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM35 %s
+
+// 32-bit compile.
+// RUN: %clang -### -target x86_32-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH32 -check-prefix SM20 %s
+
+// Check -Xcuda-ptxas and -Xcuda-fatbinary
+// RUN: %clang -### -target x86_64-linux-gnu -c -Xcuda-ptxas -foo1 \
+// RUN:   -Xcuda-fatbinary -bar1 -Xcuda-ptxas -foo2 -Xcuda-fatbinary -bar2 %s 2>&1 \
+// RUN: | FileCheck -check-prefix SM20 -check-prefix PTXAS-EXTRA \
+// RUN:   -check-prefix FATBINARY-EXTRA %s
+
+// Match clang job that produces PTX assembly.
+// CHECK: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// SM20: "-target-cpu" "sm_20"
+// SM35: "-target-cpu" "sm_35"
+// SM20: "-o" "[[PTXFILE:[^"]*]]"
+// SM35: "-o" "[[PTXFILE:[^"]*]]"
+
+// Match the call to ptxas (which assembles PTX to SASS).
+// CHECK:ptxas
+// ARCH64: "-m64"
+// 

[PATCH] D16081: [CUDA] Add test for compiling CUDA code with -S.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

http://reviews.llvm.org/D16081

Files:
  test/Driver/cuda-options.cu
  test/Driver/cuda-output-asm.cu

Index: test/Driver/cuda-output-asm.cu
===
--- /dev/null
+++ test/Driver/cuda-output-asm.cu
@@ -0,0 +1,29 @@
+// Tests CUDA compilation with -S.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix HOST -check-prefix SM20 %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-host-only -o foo.s %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix HOST %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 \
+// RUN:   --cuda-device-only -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 \
+// RUN:   --cuda-gpu-arch=sm_30 --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 -check-prefix SM30 %s
+
+// HOST-DAG: "-cc1" "-triple" "x86_64--linux-gnu"
+// SM20-DAG: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// SM20-same: "-target-cpu" "sm_20"
+// SM30-DAG: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// SM30-same: "-target-cpu" "sm_30"
+
+// RUN: %clang -### -S -target x86_64-linux-gnu -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
+// MULTIPLE-OUTPUT-FILES: error: cannot specify -o when generating multiple 
output files
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -39,13 +39,6 @@
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Verify that with -S we compile host and device sides to assembly and
-// incorporate device code into the host side.
-// RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
-
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \


Index: test/Driver/cuda-output-asm.cu
===
--- /dev/null
+++ test/Driver/cuda-output-asm.cu
@@ -0,0 +1,29 @@
+// Tests CUDA compilation with -S.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix HOST -check-prefix SM20 %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-host-only -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix HOST %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 \
+// RUN:   --cuda-device-only -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 \
+// RUN:   --cuda-gpu-arch=sm_30 --cuda-device-only %s 2>&1 \
+// RUN:   | FileCheck -check-prefix SM20 -check-prefix SM30 %s
+
+// HOST-DAG: "-cc1" "-triple" "x86_64--linux-gnu"
+// SM20-DAG: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// SM20-same: "-target-cpu" "sm_20"
+// SM30-DAG: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// SM30-same: "-target-cpu" "sm_30"
+
+// RUN: %clang -### -S -target x86_64-linux-gnu -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
+// RUN: %clang -### -S -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 -o foo.s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix MULTIPLE-OUTPUT-FILES %s
+// MULTIPLE-OUTPUT-FILES: error: cannot specify -o when generating multiple output files
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -39,13 +39,6 @@
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Verify that with -S we compile host and device sides to assembly and
-// incorporate device code into the host side.
-// RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
-
 // Verify that 

[PATCH] D16079: [CUDA] Reject values for --cuda-gpu-arch that are not of the form /sm_\d+/.

2016-01-11 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: echristo, jhen, cfe-commits.

http://reviews.llvm.org/D16079

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  test/Driver/cuda-bad-arch.cu

Index: test/Driver/cuda-bad-arch.cu
===
--- /dev/null
+++ test/Driver/cuda-bad-arch.cu
@@ -0,0 +1,34 @@
+// Checks errors generated by passing a bad value for --cuda-gpu-arch.
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD %s
+
+// BAD: error: Unsupported CUDA gpu architecture
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix OK %s
+
+// OK-NOT: error: Unsupported CUDA gpu architecture
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,8 +1297,12 @@
 if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
   continue;
 A->claim();
-if (GpuArchNames.insert(A->getValue()).second)
-  GpuArchList.push_back(A->getValue());
+
+const auto& Arch = A->getValue();
+if (!CudaDeviceAction::IsValidGpuArchName(Arch))
+  C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) << Arch;
+else if (GpuArchNames.insert(Arch).second)
+  GpuArchList.push_back(Arch);
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -9,6 +9,7 @@
 
 #include "clang/Driver/Action.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Regex.h"
 #include 
 using namespace clang::driver;
 using namespace llvm::opt;
@@ -54,7 +55,14 @@
 CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName,
bool AtTopLevel)
 : Action(CudaDeviceClass, Input), GpuArchName(ArchName),
-  AtTopLevel(AtTopLevel) {}
+  AtTopLevel(AtTopLevel) {
+  assert(IsValidGpuArchName(GpuArchName));
+}
+
+bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) {
+  static llvm::Regex RE("^sm_[0-9]+$");
+  return RE.match(ArchName);
+}
 
 void CudaHostAction::anchor() {}
 
Index: include/clang/Driver/Action.h
===
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -15,6 +15,9 @@
 #include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
+
+class StringRef;
+
 namespace opt {
   class Arg;
 }
@@ -133,7 +136,7 @@
 
 class CudaDeviceAction : public Action {
   virtual void anchor();
-  /// GPU architecture to bind -- e.g 'sm_35'.
+  /// GPU architecture to bind.  Always of the form /sm_\d+/.
   const char *GpuArchName;
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
@@ -145,6 +148,8 @@
   const char *getGpuArchName() const { return GpuArchName; }
   bool isAtTopLevel() const { return AtTopLevel; }
 
+  static bool IsValidGpuArchName(llvm::StringRef ArchName);
+
   static bool classof(const Action *A) {
 return A->getKind() == CudaDeviceClass;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test

2016-01-11 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

FOAD: Ball's in @mclow.lists's court, not mine. I don't feel comfortable 
signing off on this.


http://reviews.llvm.org/D15539



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-11 Thread Jason Henline via cfe-commits
jhen updated this revision to Diff 44538.
jhen added a comment.

- Handle unexpanded parameter packs

  The changes for instantiation dependence also fix a bug with unexpanded 
parameter packs, so add a unit test for unexpanded parameter packs as well.


http://reviews.llvm.org/D15858

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  lib/AST/Expr.cpp
  test/SemaCUDA/cxx11-kernel-call.cu
  test/SemaCUDA/kernel-call.cu

Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
 }
Index: test/SemaCUDA/cxx11-kernel-call.cu
===
--- /dev/null
+++ test/SemaCUDA/cxx11-kernel-call.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__global__ void k1() {}
+
+template void k1Wrapper() {
+  void (*f)() = [] { k1<<>>(); }; // expected-error {{initializer contains unexpanded parameter pack 'Dimensions'}}
+}
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1138,38 +1138,38 @@
 // Postfix Operators.
 //===--===//
 
-CallExpr::CallExpr(const ASTContext& C, StmtClass SC, Expr *fn,
-   unsigned NumPreArgs, ArrayRef args, QualType t,
+CallExpr::CallExpr(const ASTContext , StmtClass SC, Expr *fn,
+   ArrayRef preargs, ArrayRef args, QualType t,
ExprValueKind VK, SourceLocation rparenloc)
-  : Expr(SC, t, VK, OK_Ordinary,
- fn->isTypeDependent(),
- fn->isValueDependent(),
- fn->isInstantiationDependent(),
- fn->containsUnexpandedParameterPack()),
-NumArgs(args.size()) {
-
-  SubExprs = new (C) Stmt*[args.size()+PREARGS_START+NumPreArgs];
+: Expr(SC, t, VK, OK_Ordinary, fn->isTypeDependent(),
+   fn->isValueDependent(), fn->isInstantiationDependent(),
+   fn->containsUnexpandedParameterPack()),
+  NumArgs(args.size()) {
+
+  unsigned NumPreArgs = preargs.size();
+  SubExprs = new (C) Stmt *[args.size()+PREARGS_START+NumPreArgs];
   SubExprs[FN] = fn;
+  for (unsigned i = 0; i != NumPreArgs; ++i) {
+updateDependenciesFromArg(preargs[i]);
+SubExprs[i+PREARGS_START] = preargs[i];
+  }
   for (unsigned i = 0; i != args.size(); ++i) {
-if (args[i]->isTypeDependent())
-  ExprBits.TypeDependent = true;
-if (args[i]->isValueDependent())
-  ExprBits.ValueDependent = true;
-if (args[i]->isInstantiationDependent())
-  ExprBits.InstantiationDependent = true;
-if (args[i]->containsUnexpandedParameterPack())
-  ExprBits.ContainsUnexpandedParameterPack = true;
-
+updateDependenciesFromArg(args[i]);
 SubExprs[i+PREARGS_START+NumPreArgs] = args[i];
   }
 
   CallExprBits.NumPreArgs = NumPreArgs;
   RParenLoc = rparenloc;
 }
 
+CallExpr::CallExpr(const ASTContext , StmtClass SC, Expr *fn,
+   ArrayRef args, QualType t, ExprValueKind VK,
+   SourceLocation rparenloc)
+: CallExpr(C, SC, fn, ArrayRef(), args, t, VK, rparenloc) {}
+
 CallExpr::CallExpr(const ASTContext , Expr *fn, ArrayRef args,
QualType t, ExprValueKind VK, SourceLocation rparenloc)
-: CallExpr(C, CallExprClass, fn, /*NumPreArgs=*/0, args, t, VK, rparenloc) {
+: CallExpr(C, CallExprClass, fn, ArrayRef(), args, t, VK, rparenloc) {
 }
 
 CallExpr::CallExpr(const ASTContext , StmtClass SC, EmptyShell Empty)
@@ -1179,10 +1179,21 @@
EmptyShell Empty)
   : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {
   // FIXME: Why do we allocate this?
-  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs];
+  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs]();
   CallExprBits.NumPreArgs = NumPreArgs;
 }
 
+void CallExpr::updateDependenciesFromArg(Expr *Arg) {
+  if (Arg->isTypeDependent())
+ExprBits.TypeDependent = true;
+  if (Arg->isValueDependent())
+ExprBits.ValueDependent = true;
+  if (Arg->isInstantiationDependent())
+ExprBits.InstantiationDependent = true;
+  if (Arg->containsUnexpandedParameterPack())
+ExprBits.ContainsUnexpandedParameterPack = true;
+}
+
 Decl *CallExpr::getCalleeDecl() {
   Expr *CEE = getCallee()->IgnoreParenImpCasts();
 
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -66,8 +66,7 @@
   CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
   ArrayRef args, QualType t, ExprValueKind VK,
   

Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-11 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:312
@@ +311,3 @@
+  /// calls.
+  bool isCalled(const CallEvent , const CallDescription );
+

The API is a bit awkward. Maybe it would be better if we make this a member of 
CallEvent as you've suggested initially?


http://reviews.llvm.org/D15921



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


Re: [PATCH] D16062: [analyzer] Rename kind-enumeration values of SVal, SymExpr, MemRegion classes, for consistency.

2016-01-11 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Looks good to me. Thanks for making this more consistent!



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:102
@@ -103,1 +101,3 @@
+BEGIN_TYPED_REGIONS,
+FunctionTextRegionKind = BEGIN_TYPED_REGIONS,
 BlockTextRegionKind,

While we're at it, what do you think about renaming FunctionTextRegion and 
BlockTextRegion to FunctionCodeRegion and BlockCodeRegion, respectively? The 
term 'code' is less jargony than 'text' and we already refer to BlockTextRegion 
as a 'code region' in BlockDataRegion.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:195
@@ -194,2 +194,3 @@
 protected:
   friend class MemRegionManager;
+

Following up on Anna's question: does MemSpaceRegion need to be a friend of 
MemRegionManager now?


http://reviews.llvm.org/D16062



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


Re: r257357 - [Sema] Issue a warning for integer overflow in struct initializer

2016-01-11 Thread Joerg Sonnenberger via cfe-commits
On Mon, Jan 11, 2016 at 12:28:36PM -0800, Akira Hatanaka via cfe-commits wrote:
> It triggers in dead branches and so does an initialization of an integer 
> variable declared in a function.

I'm more interested in the case of global initialisers here. There is a
long standing history of not checking properly for dead branches, which
makes some code noisy for no good reason.

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


Re: r257357 - [Sema] Issue a warning for integer overflow in struct initializer

2016-01-11 Thread Akira Hatanaka via cfe-commits
It triggers in dead branches and so does an initialization of an integer 
variable declared in a function.

I’ll look into fixing it.

> On Jan 11, 2016, at 9:54 AM, Joerg Sonnenberger via cfe-commits 
>  wrote:
> 
> On Mon, Jan 11, 2016 at 05:22:01PM -, Akira Hatanaka via cfe-commits 
> wrote:
>> Author: ahatanak
>> Date: Mon Jan 11 11:22:01 2016
>> New Revision: 257357
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=257357=rev
>> Log:
>> [Sema] Issue a warning for integer overflow in struct initializer
>> 
>> Clang wasn't issuing a warning when compiling the following code:
>> 
>> struct s {
>>  unsigned x;
>> } s = {
>>  .x = 4 * 1024 * 1024 * 1024
>> };
> 
> Does this trigger in dead branches or not? Read: can you make sure it
> doesn't and add an appropiate case to the test, please?
> 
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 44472.
bkramer added a comment.

Why not both?


http://reviews.llvm.org/D16058

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1022,6 +1022,10 @@
"  lineWith(); // comment\n"
"  // at start\n"
"}"));
+  EXPECT_EQ("int xy; // a\n"
+"int z;  // b",
+format("int xy;// a\n"
+   "int z;//b"));
 
   verifyFormat("#define A  \\\n"
"  int i; /* i */   \\\n"
Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -109,7 +109,8 @@
unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
unsigned NewlinesBefore, StringRef PreviousLinePostfix,
StringRef CurrentLinePrefix, tok::TokenKind Kind,
-   bool ContinuesPPDirective, bool IsStartOfDeclName);
+   bool ContinuesPPDirective, bool IsStartOfDeclName,
+   bool IsInsideTrailingCommentToken);
 
 bool CreateReplacement;
 // Changes might be in the middle of a token, so we cannot just keep the
@@ -139,6 +140,10 @@
 // comments. Uncompensated negative offset is truncated to 0.
 int Spaces;
 
+// If this change is inside of a line comment but not at the start of such a
+// comment.
+bool IsInsideTrailingCommentToken;
+
 // \c IsTrailingComment, \c TokenLength, \c PreviousEndOfTokenColumn and
 // \c EscapedNewlineColumn will be calculated in
 // \c calculateLineBreakInformation.
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -30,17 +30,19 @@
 unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
 unsigned NewlinesBefore, StringRef PreviousLinePostfix,
 StringRef CurrentLinePrefix, tok::TokenKind Kind, bool ContinuesPPDirective,
-bool IsStartOfDeclName)
+bool IsStartOfDeclName, bool IsInsideTrailingCommentToken)
 : CreateReplacement(CreateReplacement),
   OriginalWhitespaceRange(OriginalWhitespaceRange),
   StartOfTokenColumn(StartOfTokenColumn), NewlinesBefore(NewlinesBefore),
   PreviousLinePostfix(PreviousLinePostfix),
   CurrentLinePrefix(CurrentLinePrefix), Kind(Kind),
   ContinuesPPDirective(ContinuesPPDirective),
   IsStartOfDeclName(IsStartOfDeclName), IndentLevel(IndentLevel),
-  Spaces(Spaces), IsTrailingComment(false), TokenLength(0),
-  PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
-  StartOfBlockComment(nullptr), IndentationOffset(0) {}
+  Spaces(Spaces),
+  IsInsideTrailingCommentToken(IsTrailingCommentContinuation),
+  IsTrailingComment(false), TokenLength(0), PreviousEndOfTokenColumn(0),
+  EscapedNewlineColumn(0), StartOfBlockComment(nullptr),
+  IndentationOffset(0) {}
 
 void WhitespaceManager::reset() {
   Changes.clear();
@@ -58,7 +60,8 @@
   Change(/*CreateReplacement=*/true, Tok.WhitespaceRange, IndentLevel,
  Spaces, StartOfTokenColumn, Newlines, "", "", Tok.Tok.getKind(),
  InPPDirective && !Tok.IsFirst,
- Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+ Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+ /*IsInsideTrailingCommentToken=*/false));
 }
 
 void WhitespaceManager::addUntouchableToken(const FormatToken ,
@@ -69,7 +72,8 @@
   /*CreateReplacement=*/false, Tok.WhitespaceRange, /*IndentLevel=*/0,
   /*Spaces=*/0, Tok.OriginalColumn, Tok.NewlinesBefore, "", "",
   Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst,
-  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+  /*IsInsideTrailingCommentToken=*/false));
 }
 
 void WhitespaceManager::replaceWhitespaceInToken(
@@ -82,15 +86,11 @@
   Changes.push_back(Change(
   true, SourceRange(Start, Start.getLocWithOffset(ReplaceChars)),
   IndentLevel, Spaces, std::max(0, Spaces), Newlines, PreviousPostfix,
-  CurrentPrefix,
-  // If we don't add a newline this change doesn't start a comment. Thus,
-  // when we align line comments, we don't need to treat this change as one.
-  // FIXME: We still need to take this change in account to properly
-  // calculate the new length of the comment and to calculate the changes
-  // for which to do the alignment when aligning comments.
-  Tok.is(TT_LineComment) && Newlines > 0 ? tok::comment : 

[PATCH] D16062: [analyzer] Rename kind-enumeration values of SVal, SymExpr, MemRegion classes, for consistency.

2016-01-11 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

Based on discussion in D15448.

- For every sub-class `C`, its kind in the relevant enumeration is `CKind` (or 
`C##Kind` in preprocessor-ish terms), eg:
  `MemRegionKind` -> `MemRegionValKind`
  `RegionValueKind` -> `SymbolRegionValueKind`
  `CastSymbolKind` -> `SymbolCastKind`
  `SymIntKind` -> `SymIntExprKind`

- `MemSpaceRegion` is now an abstract base and no longer occupies 
`GenericMemSpaceRegionKind`. Instead, a new class, `CodeSpaceRegion`, is 
introduced for handling the unique use case for `MemSpaceRegion` as "the 
generic memory space" (when it represents a memory space that holds all 
executable code).

- `BEG_` prefixes in memory region kind ranges are renamed to `BEGIN_` for 
consisitency with symbol kind ranges (pro: not about begging, con: two extra 
characters to type).

http://reviews.llvm.org/D16062

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  lib/StaticAnalyzer/Core/MemRegion.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -115,22 +115,22 @@
   const SymExpr *SE = itr.pop_back_val();
 
   switch (SE->getKind()) {
-case SymExpr::RegionValueKind:
-case SymExpr::ConjuredKind:
-case SymExpr::DerivedKind:
-case SymExpr::ExtentKind:
-case SymExpr::MetadataKind:
+case SymExpr::SymbolRegionValueKind:
+case SymExpr::SymbolConjuredKind:
+case SymExpr::SymbolDerivedKind:
+case SymExpr::SymbolExtentKind:
+case SymExpr::SymbolMetadataKind:
   return;
-case SymExpr::CastSymbolKind:
+case SymExpr::SymbolCastKind:
   itr.push_back(cast(SE)->getOperand());
   return;
-case SymExpr::SymIntKind:
+case SymExpr::SymIntExprKind:
   itr.push_back(cast(SE)->getLHS());
   return;
-case SymExpr::IntSymKind:
+case SymExpr::IntSymExprKind:
   itr.push_back(cast(SE)->getRHS());
   return;
-case SymExpr::SymSymKind: {
+case SymExpr::SymSymExprKind: {
   const SymSymExpr *x = cast(SE);
   itr.push_back(x->getLHS());
   itr.push_back(x->getRHS());
@@ -458,35 +458,35 @@
   bool KnownLive;
 
   switch (sym->getKind()) {
-  case SymExpr::RegionValueKind:
+  case SymExpr::SymbolRegionValueKind:
 KnownLive = isLiveRegion(cast(sym)->getRegion());
 break;
-  case SymExpr::ConjuredKind:
+  case SymExpr::SymbolConjuredKind:
 KnownLive = false;
 break;
-  case SymExpr::DerivedKind:
+  case SymExpr::SymbolDerivedKind:
 KnownLive = isLive(cast(sym)->getParentSymbol());
 break;
-  case SymExpr::ExtentKind:
+  case SymExpr::SymbolExtentKind:
 KnownLive = isLiveRegion(cast(sym)->getRegion());
 break;
-  case SymExpr::MetadataKind:
+  case SymExpr::SymbolMetadataKind:
 KnownLive = MetadataInUse.count(sym) &&
 isLiveRegion(cast(sym)->getRegion());
 if (KnownLive)
   MetadataInUse.erase(sym);
 break;
-  case SymExpr::SymIntKind:
+  case SymExpr::SymIntExprKind:
 KnownLive = isLive(cast(sym)->getLHS());
 break;
-  case SymExpr::IntSymKind:
+  case SymExpr::IntSymExprKind:
 KnownLive = isLive(cast(sym)->getRHS());
 break;
-  case SymExpr::SymSymKind:
+  case SymExpr::SymSymExprKind:
 KnownLive = isLive(cast(sym)->getLHS()) &&
 isLive(cast(sym)->getRHS());
 break;
-  case SymExpr::CastSymbolKind:
+  case SymExpr::SymbolCastKind:
 KnownLive = isLive(cast(sym)->getOperand());
 break;
   }
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -100,7 +100,7 @@
   // Process region cast according to the kind of the region being cast.
   switch (R->getKind()) {
 case MemRegion::CXXThisRegionKind:
-case MemRegion::GenericMemSpaceRegionKind:
+case MemRegion::CodeSpaceRegionKind:
 case MemRegion::StackLocalsSpaceRegionKind:
 case MemRegion::StackArgumentsSpaceRegionKind:
 case MemRegion::HeapSpaceRegionKind:
@@ -393,7 +393,7 @@
   const MemRegion* BaseR = nullptr;
 
   switch (BaseL.getSubKind()) {
-  case loc::MemRegionKind:
+  case loc::MemRegionValKind:
 BaseR = BaseL.castAs().getRegion();
 break;
 
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -141,7 +141,7 @@
   

Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-11 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 44475.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Renamed the kinds for consistency (review http://reviews.llvm.org/D16062), this 
diff is updated to use the new naming convention. The 'kind' column gets 
removed from the def-files.


http://reviews.llvm.org/D15448

Files:
  docs/analyzer/DebugChecks.rst
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  test/Analysis/explain-svals.cpp

Index: test/Analysis/explain-svals.cpp
===
--- /dev/null
+++ test/Analysis/explain-svals.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s
+
+typedef unsigned long size_t;
+
+struct S {
+  struct S3 {
+int y[10];
+  };
+  struct S2 : S3 {
+int *x;
+  } s2[10];
+  int z;
+};
+
+
+void clang_analyzer_explain(int);
+void clang_analyzer_explain(void *);
+void clang_analyzer_explain(S);
+
+size_t clang_analyzer_getExtent(void *);
+
+size_t strlen(const char *);
+
+int conjure();
+S conjure_S();
+
+int glob;
+static int stat_glob;
+void *glob_ptr;
+
+// Test strings are regex'ed because we need to match exact string
+// rather than a substring.
+
+void test_1(int param, void *ptr) {
+  clang_analyzer_explain(); // expected-warning-re^pointer to global variable 'glob'$
+  clang_analyzer_explain(param); // expected-warning-re^argument 'param'$
+  clang_analyzer_explain(ptr); // expected-warning-re^argument 'ptr'$
+  if (param == 42)
+clang_analyzer_explain(param); // expected-warning-re^signed 32-bit integer '42'$
+}
+
+void test_2(char *ptr, int ext) {
+  clang_analyzer_explain((void *) "asdf"); // expected-warning-re^pointer to element of type 'char' with index 0 of string literal "asdf"$
+  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
+  clang_analyzer_explain(conjure()); // expected-warning-re^symbol of type 'int' conjured at statement 'conjure\(\)'$
+  clang_analyzer_explain(glob); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob'$
+  clang_analyzer_explain(glob_ptr); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$
+  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^extent of pointee of argument 'ptr'$
+  int *x = new int[ext];
+  clang_analyzer_explain(x); // expected-warning-re^pointer to element of type 'int' with index 0 of pointee of symbol of type 'int \*' conjured at statement 'new int \[ext\]'$
+  // Sic! What gets computed is the extent of the element-region.
+  clang_analyzer_explain(clang_analyzer_getExtent(x)); // expected-warning-re^signed 32-bit integer '4'$
+  delete[] x;
+}
+
+void test_3(S s) {
+  clang_analyzer_explain(); // expected-warning-re^pointer to parameter 's'$
+  clang_analyzer_explain(s.z); // expected-warning-re^initial value of field 'z' of parameter 's'$
+  clang_analyzer_explain([5].y[3]); // expected-warning-re^pointer to element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside element of type 'struct S::S2' with index 5 of field 's2' of parameter 's'$
+  if (!s.s2[7].x) {
+clang_analyzer_explain(s.s2[7].x); // expected-warning-re^concrete memory address '0'$
+// FIXME: we need to be explaining '1' rather than '0' here; not explainer bug.
+clang_analyzer_explain(s.s2[7].x + 1); // expected-warning-re^concrete memory address '0'$
+  }
+}
+
+void test_4(int x, int y) {
+  int z;
+  static int stat;
+  clang_analyzer_explain(x + 1); // expected-warning-re^\(argument 'x'\) \+ 1$
+  clang_analyzer_explain(1 + y); // expected-warning-re^\(argument 'y'\) \+ 1$
+  clang_analyzer_explain(x + y); // expected-warning-re^unknown value$
+  clang_analyzer_explain(z); // expected-warning-re^undefined value$
+  clang_analyzer_explain(); // expected-warning-re^pointer to local variable 'z'$
+  clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$
+  clang_analyzer_explain(); // expected-warning-re^pointer to static local variable 'stat'$
+  clang_analyzer_explain(stat_glob); // 

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

2016-01-11 Thread Alexander Droste via cfe-commits
Alexander_Droste marked 2 inline comments as done.


Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:643
@@ +642,3 @@
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);

You're right, 200 was a bit overambitious. I reduced it to 50.


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: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/WhitespaceManager.h:145
@@ +144,3 @@
+// comment.
+bool IsTrailingCommentContinuation;
+

klimek wrote:
> djasper wrote:
> > I find the term "continuation" a bit confusing here. How about something 
> > like "IsInsideToken"?
> "Token" sounds like it could be true for things outside comments. Perhaps 
> "InComment"?
So why not store the more generic information here? We already have the extra 
information whether this is a line comment or not stored in the token kind.


http://reviews.llvm.org/D16058



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


r257330 - clang-format: Fix overloading "operator, " definitions more thoroughly.

2016-01-11 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 11 06:55:33 2016
New Revision: 257330

URL: http://llvm.org/viewvc/llvm-project?rev=257330=rev
Log:
clang-format: Fix overloading "operator," definitions more thoroughly.

Before:
  aa operator,(a &
   aa) const;
After:
  aa operator,(
  a ) const;

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=257330=257329=257330=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 11 06:55:33 2016
@@ -119,7 +119,9 @@ private:
   }
 }
 
-if (Left->Previous &&
+if (Left->is(TT_OverloadedOperatorLParen)) {
+  Contexts.back().IsExpression = false;
+} else if (Left->Previous &&
 (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
  tok::kw_if, tok::kw_while, tok::l_paren,
  tok::comma) ||
@@ -132,9 +134,7 @@ private:
   // This is a parameter list of a lambda expression.
   Contexts.back().IsExpression = false;
 } else if (Line.InPPDirective &&
-   (!Left->Previous ||
-!Left->Previous->isOneOf(tok::identifier,
- TT_OverloadedOperator))) {
+   (!Left->Previous || !Left->Previous->is(tok::identifier))) {
   Contexts.back().IsExpression = true;
 } else if (Contexts[Contexts.size() - 2].CaretFound) {
   // This is the parameter list of an ObjC block.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257330=257329=257330=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 11 06:55:33 2016
@@ -5492,7 +5492,7 @@ TEST_F(FormatTest, UnderstandsOverloaded
   verifyFormat("template \n"
"AAA operator/(const AAA , BBB );");
   verifyFormat("aa operator,(\n"
-   "a) 
const;");
+   "a ) 
const;");
 
   verifyFormat(
   "ostream <<(ostream ,\n"


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


Re: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/WhitespaceManager.h:145
@@ +144,3 @@
+// comment.
+bool IsTrailingCommentContinuation;
+

djasper wrote:
> I find the term "continuation" a bit confusing here. How about something like 
> "IsInsideToken"?
"Token" sounds like it could be true for things outside comments. Perhaps 
"InComment"?


http://reviews.llvm.org/D16058



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


Re: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/WhitespaceManager.h:145
@@ +144,3 @@
+// comment.
+bool IsTrailingCommentContinuation;
+

I find the term "continuation" a bit confusing here. How about something like 
"IsInsideToken"?


http://reviews.llvm.org/D16058



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


r257327 - [WebAssembly] Fix a typo in a comment.

2016-01-11 Thread Dan Gohman via cfe-commits
Author: djg
Date: Mon Jan 11 05:49:44 2016
New Revision: 257327

URL: http://llvm.org/viewvc/llvm-project?rev=257327=rev
Log:
[WebAssembly] Fix a typo in a comment.

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257327=257326=257327=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Jan 11 05:49:44 2016
@@ -18,7 +18,7 @@
 // NO_DATA_SECTIONS-NOT: data-sections
 
 // Ditto, but ensure that a user -fvisibility=default disables the default
-// -fvisibilt=hidden.
+// -fvisibility=hidden.
 
 // RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
 // FVISIBILITY_DEFAULT-NOT: hidden


___
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-01-11 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 44476.
Alexander_Droste added a comment.

- reduced buffer size for variable name
- simplified `R->getAs()->getSuperRegion()` to 
`ER->getSuperRegion()`.


http://reviews.llvm.org/D16044

Files:
  tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Index: tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -187,6 +187,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -635,6 +635,45 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+llvm::APSInt IndexInArray =
+ER->getIndex().getAs()->getValue();
+
+llvm::SmallString<2> intValAsString;
+IndexInArray.toString(intValAsString);
+std::string idx{intValAsString.begin(), intValAsString.end()};
+
+ArrayIndices = "[" + idx + "]" + ArrayIndices;
+
+R = ER->getSuperRegion();
+  }
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName += os.str();
+  }
+
+  // Combine variable name with indices.
+  if (VariableName.size() && VariableName.back() == '\'') {
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  } else {
+VariableName += ArrayIndices;
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -187,6 +187,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -635,6 +635,45 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};
+
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const clang::ento::ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+llvm::APSInt IndexInArray =
+ER->getIndex().getAs()->getValue();
+
+llvm::SmallString<2> intValAsString;
+IndexInArray.toString(intValAsString);
+std::string idx{intValAsString.begin(), intValAsString.end()};
+
+ArrayIndices = "[" + idx + "]" + ArrayIndices;
+
+R = ER->getSuperRegion();
+  }
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName += os.str();
+  }
+
+  // Combine variable name with indices.
+  if (VariableName.size() && VariableName.back() == '\'') {
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  } 

Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-01-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Kelvin, thanks for the patch!
One more comment: what about nesting of regions? You need to add a 
corresponding code and tests



Comment at: include/clang/AST/OpenMPClause.h:3196
@@ -3195,1 +3195,3 @@
 
+/// \brief This represents clause 'from' in the '#pragma omp ...'
+/// directives.

New clauses must be added in separate patches after commit of the new directive.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2685
@@ +2684,3 @@
+const OMPTargetUpdateDirective ) {
+  llvm_unreachable("CodeGen for 'omp target update' is not supported yet.");
+}

Maybe just do not emit anything, to not crash a compiler.


Comment at: lib/Parse/ParseOpenMP.cpp:71-74
@@ -69,3 +70,6 @@
  !P.getPreprocessor().getSpelling(Tok).compare("point")) ||
-((i == 1) && 
!P.getPreprocessor().getSpelling(Tok).compare("data"));
+((i == 1) &&
+ !P.getPreprocessor().getSpelling(Tok).compare("data")) ||
+((i == 2) &&
+ !P.getPreprocessor().getSpelling(Tok).compare("update"));
   } else {

Probably, we need to add local enumeric for these constants (0, 1, 2 etc.) 


http://reviews.llvm.org/D15944



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


[PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: djasper.
bkramer added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

As soon as a comment had whitespace changes inside of the token, we
couldn't identify the whole comment as a trailing comment anymore and
alignment stopped working. Add a new boolean to Change for this special
case and fix trailing comment identification to use it.

Before this fix

int xy;  // a
int z;   //b

became

int xy;  // a
int z;  // b

with this patch we immediately get to:

int xy;  // a
int z;   // b

http://reviews.llvm.org/D16058

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1022,6 +1022,10 @@
"  lineWith(); // comment\n"
"  // at start\n"
"}"));
+  EXPECT_EQ("int xy; // a\n"
+"int z;  // b",
+format("int xy;// a\n"
+   "int z;//b"));
 
   verifyFormat("#define A  \\\n"
"  int i; /* i */   \\\n"
Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -109,7 +109,8 @@
unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
unsigned NewlinesBefore, StringRef PreviousLinePostfix,
StringRef CurrentLinePrefix, tok::TokenKind Kind,
-   bool ContinuesPPDirective, bool IsStartOfDeclName);
+   bool ContinuesPPDirective, bool IsStartOfDeclName,
+   bool IsTrailingCommentContinuation);
 
 bool CreateReplacement;
 // Changes might be in the middle of a token, so we cannot just keep the
@@ -139,6 +140,10 @@
 // comments. Uncompensated negative offset is truncated to 0.
 int Spaces;
 
+// If this change is inside of a line comment but not at the start of such a
+// comment.
+bool IsTrailingCommentContinuation;
+
 // \c IsTrailingComment, \c TokenLength, \c PreviousEndOfTokenColumn and
 // \c EscapedNewlineColumn will be calculated in
 // \c calculateLineBreakInformation.
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -30,17 +30,19 @@
 unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
 unsigned NewlinesBefore, StringRef PreviousLinePostfix,
 StringRef CurrentLinePrefix, tok::TokenKind Kind, bool ContinuesPPDirective,
-bool IsStartOfDeclName)
+bool IsStartOfDeclName, bool IsTrailingCommentContinuation)
 : CreateReplacement(CreateReplacement),
   OriginalWhitespaceRange(OriginalWhitespaceRange),
   StartOfTokenColumn(StartOfTokenColumn), NewlinesBefore(NewlinesBefore),
   PreviousLinePostfix(PreviousLinePostfix),
   CurrentLinePrefix(CurrentLinePrefix), Kind(Kind),
   ContinuesPPDirective(ContinuesPPDirective),
   IsStartOfDeclName(IsStartOfDeclName), IndentLevel(IndentLevel),
-  Spaces(Spaces), IsTrailingComment(false), TokenLength(0),
-  PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
-  StartOfBlockComment(nullptr), IndentationOffset(0) {}
+  Spaces(Spaces),
+  IsTrailingCommentContinuation(IsTrailingCommentContinuation),
+  IsTrailingComment(false), TokenLength(0), PreviousEndOfTokenColumn(0),
+  EscapedNewlineColumn(0), StartOfBlockComment(nullptr),
+  IndentationOffset(0) {}
 
 void WhitespaceManager::reset() {
   Changes.clear();
@@ -58,7 +60,8 @@
   Change(/*CreateReplacement=*/true, Tok.WhitespaceRange, IndentLevel,
  Spaces, StartOfTokenColumn, Newlines, "", "", Tok.Tok.getKind(),
  InPPDirective && !Tok.IsFirst,
- Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+ Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+ /*IsTrailingCommentContinuation=*/false));
 }
 
 void WhitespaceManager::addUntouchableToken(const FormatToken ,
@@ -69,7 +72,8 @@
   /*CreateReplacement=*/false, Tok.WhitespaceRange, /*IndentLevel=*/0,
   /*Spaces=*/0, Tok.OriginalColumn, Tok.NewlinesBefore, "", "",
   Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst,
-  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+  /*IsTrailingCommentContinuation=*/false));
 }
 
 void WhitespaceManager::replaceWhitespaceInToken(
@@ -82,15 +86,11 @@
   Changes.push_back(Change(
   true, SourceRange(Start, Start.getLocWithOffset(ReplaceChars)),
   IndentLevel, Spaces, std::max(0, Spaces), Newlines, 

Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2016-01-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Ping


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.

2016-01-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D15443#323043, @adek05 wrote:

> I think this won't work. If there is a problem with the expression inside 
> `throw` or `noexcept` specifier, it will be highlighted inside the parens, 
> never trying to actually access the end location of the function declaration.
>
> It would be enough if there is a warning/error which would highlight the 
> whole function declaration, because we could check whether it points at `;` 
> or the character in front of it, but I don't know about such warning and I 
> don't know how to smartly look for it.


I think the best way to proceed then is with a test in SourceLocationTest.cpp 
in the AST unit test suite.


http://reviews.llvm.org/D15443



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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-11 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A few minor comments.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:23
@@ +22,3 @@
+/// Finds out if the given method overrides some method.
+bool isOverrideMethod(const CXXMethodDecl *MD) {
+  return MD->size_overridden_methods() > 0 || MD->hasAttr();

Please mark this and other functions `static` to make them local to the 
translation unit.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:43
@@ +42,3 @@
+
+  // Check if return types are identical
+  if (Context->hasSameType(DerivedReturnTy, BaseReturnTy))

nit: Missing trailing period.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:68
@@ +67,3 @@
+  // The return types aren't either both pointers or references to a class 
type.
+  if (DTy.isNull()) {
+return false;

nit: No braces around one-line `if` bodies, please.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:90
@@ +89,3 @@
+// Check ambiguity.
+if (Paths.isAmbiguous(Context->getCanonicalType(BTy).getUnqualifiedType()))
+  return false;

I wonder whether `BTy.getCanonicalType().getUnqualifiedType()` will work here.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:99
@@ +98,3 @@
+for (const auto  : Paths) {
+  if (Path.Access == AS_public) {
+HasPublicAccess = true;

nit: No braces around one-line `if` bodies, please.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:188
@@ +187,3 @@
+  auto Iter = PossibleMap.find(Id);
+  if (Iter != PossibleMap.end()) {
+return Iter->second;

nit: No braces around one-line `if` bodies, please.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:203
@@ +202,3 @@
+  auto Iter = OverriddenMap.find(Key);
+  if (Iter != OverriddenMap.end()) {
+return Iter->second;

nit: No braces around one-line `if` bodies, please.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:258
@@ +257,3 @@
+ "'%0' has a similar name and the same "
+ "signature with virtual method '%1'. "
+ "Did you meant to override it?")

The diagnostic messages are not complete sentences. Please use a semicolon 
instead of the period and a lower-case letter after it. Also, s/signature 
with/signature as/ and s/meant/mean/. Overall it should be:
`method '%0' has a similar name and the same signature as method '%1'; did you 
mean to override it?`.


Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:15
@@ +14,3 @@
+  void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Derived::func2' has a similar 
name and the same signature with virtual method 'Base::func'. Did you meant to 
override it?
+

Please remove the `. Did you mean to override it?` part from all CHECK lines 
except for the first one to make the test file easier to read. Maybe even cut 
the static test in the middle:

  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Derived::func2' has {{.*}} 
'Base::func'


Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:42
@@ +41,3 @@
+class Child : Father, Mother {
+public:
+  Child();

Please mark the inheritance explicitly `private` then to avoid questions.


http://reviews.llvm.org/D15823



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2016-01-11 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 44492.
aaron.ballman added a comment.

Adding newlines to the end of some files, per feedback.


http://reviews.llvm.org/D15796

Files:
  docs/clang-tidy/checks/cert-dcl03-c.rst
  docs/clang-tidy/checks/cert-dcl54-cpp.rst
  docs/clang-tidy/checks/cert-dcl59-cpp.rst
  docs/clang-tidy/checks/cert-err61-cpp.rst
  docs/clang-tidy/checks/cert-fio38-c.rst
  docs/clang-tidy/checks/cert-oop11-cpp.rst
  docs/clang-tidy/checks/google-build-namespaces.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/misc-new-delete-overloads.rst
  docs/clang-tidy/checks/misc-non-copyable-objects.rst
  docs/clang-tidy/checks/misc-static-assert.rst
  docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
===
--- docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
+++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
@@ -3,6 +3,8 @@
 misc-throw-by-value-catch-by-reference
 ==
 
+"cert-err61-cpp" redirects here as an alias for this checker.
+
 Finds violations of the rule "Throw by value, catch by reference" presented for example in "C++ Coding Standards" by H. Sutter and A. Alexandrescu. This check also has the option to find violations of the rule "Throw anonymous temporaries" (https://www.securecoding.cert.org/confluence/display/cplusplus/ERR09-CPP.+Throw+anonymous+temporaries). The option is named "CheckThrowTemporaries" and it's on by default.
 
 Exceptions:
Index: docs/clang-tidy/checks/misc-static-assert.rst
===
--- docs/clang-tidy/checks/misc-static-assert.rst
+++ docs/clang-tidy/checks/misc-static-assert.rst
@@ -3,6 +3,7 @@
 misc-static-assert
 ==
 
+"cert-dcl03-c" redirects here as an alias for this checker.
 
 Replaces ``assert()`` with ``static_assert()`` if the condition is evaluatable
 at compile time.
Index: docs/clang-tidy/checks/misc-non-copyable-objects.rst
===
--- docs/clang-tidy/checks/misc-non-copyable-objects.rst
+++ docs/clang-tidy/checks/misc-non-copyable-objects.rst
@@ -3,6 +3,8 @@
 misc-non-copyable-objects
 =
 
+"cert-fio38-c" redirects here as an alias for this checker.
+
 The check flags dereferences and non-pointer declarations of objects that are
 not meant to be passed by value, such as C FILE objects or POSIX
 pthread_mutex_t objects.
Index: docs/clang-tidy/checks/misc-new-delete-overloads.rst
===
--- docs/clang-tidy/checks/misc-new-delete-overloads.rst
+++ docs/clang-tidy/checks/misc-new-delete-overloads.rst
@@ -3,6 +3,8 @@
 misc-new-delete-overloads
 =
 
+"cert-dcl54-cpp" redirects here as an alias for this checker.
+
 The check flags overloaded operator new() and operator delete() functions that
 do not have a corresponding free store function defined within the same scope.
 For instance, the check will flag a class implementation of a non-placement
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -3,6 +3,7 @@
 misc-move-constructor-init
 ==
 
+"cert-oop11-cpp" redirects here as an alias for this checker.
 
 The check flags user-defined move constructors that have a ctor-initializer
 initializing a member or base class through a copy constructor instead of a
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,9 +5,15 @@
 
 .. toctree::   
cert-dcl50-cpp
+   cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
+   cert-dcl59-cpp (redirects to google-build-namespaces) 
cert-err52-cpp
cert-err58-cpp
cert-err60-cpp
+   cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
+   cert-oop11-cpp (redirects to misc-move-constructor-init) 
+   cert-dcl03-c (redirects to misc-static-assert) 
+   cert-fio38-c (redirects to misc-non-copyable-objects) 
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/google-build-namespaces.rst
===
--- docs/clang-tidy/checks/google-build-namespaces.rst
+++ docs/clang-tidy/checks/google-build-namespaces.rst
@@ -3,6 +3,7 @@
 google-build-namespaces
 ===
 
+"cert-dcl59-cpp" redirects here as an alias for 

Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2016-01-11 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

http://reviews.llvm.org/D15796



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2016-01-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/cert-dcl54-cpp.rst:7
@@ +6,3 @@
+==
+
+The cert-dcl54-cpp checker is an alias, please see

This seems to do what we need (full file is here {F1298675}):

```
diff --git a/clang-tidy/add_new_check.py b/clang-tidy/add_new_check.py
index 6ecc89d..6000616 100755
--- a/clang-tidy/add_new_check.py
+++ b/clang-tidy/add_new_check.py
@@ -215,15 +215,25 @@ void awesome_f2();
 
 # Recreates the list of checks in the docs/clang-tidy/checks directory.
 def update_checks_list(module_path):
-  filename = os.path.normpath(
-  os.path.join(module_path, '../../docs/clang-tidy/checks/list.rst'))
+  docs_dir = os.path.join(module_path, '../../docs/clang-tidy/checks')
+  filename = os.path.normpath(os.path.join(docs_dir, 'list.rst'))
   with open(filename, 'r') as f:
 lines = f.readlines()
-
-  checks = map(lambda s: '   ' + s.replace('.rst', '\n'),
-   filter(lambda s: s.endswith('.rst') and s != 'list.rst',
-  os.listdir(os.path.join(module_path, 
'../../docs/clang-tidy/checks'
-  checks.sort()
+  doc_files = filter(
+  lambda s: s.endswith('.rst') and s != 'list.rst',
+  os.listdir(docs_dir))
+  doc_files.sort()
+
+  def format_link(doc_file):
+check_name = doc_file.replace('.rst', '')
+with open(os.path.join(docs_dir, doc_file), 'r') as doc:
+  match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*', 
doc.read())
+  if match:
+return '   %(check)s (redirects to %(target)s) <%(check)s>\n' % {
+'check' : check_name, 'target' : match.group(1) }
+  return '   %s\n' % check_name
+
+  checks = map(format_link, doc_files)
 
   print('Updating %s...' % filename)
   with open(filename, 'wb') as f:
```

Can you include this in the patch?


http://reviews.llvm.org/D15796



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


Re: [PATCH] D15796: [PATCH] clang-tidy documentation redirects

2016-01-11 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 44507.
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Adds the add_new_check.py changes from Alex, regenerates list.rst from the 
Python script.


http://reviews.llvm.org/D15796

Files:
  clang-tidy/add_new_check.py
  docs/clang-tidy/checks/cert-dcl03-c.rst
  docs/clang-tidy/checks/cert-dcl54-cpp.rst
  docs/clang-tidy/checks/cert-dcl59-cpp.rst
  docs/clang-tidy/checks/cert-err61-cpp.rst
  docs/clang-tidy/checks/cert-fio38-c.rst
  docs/clang-tidy/checks/cert-oop11-cpp.rst
  docs/clang-tidy/checks/google-build-namespaces.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/misc-new-delete-overloads.rst
  docs/clang-tidy/checks/misc-non-copyable-objects.rst
  docs/clang-tidy/checks/misc-static-assert.rst
  docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
===
--- docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
+++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
@@ -3,6 +3,8 @@
 misc-throw-by-value-catch-by-reference
 ==
 
+"cert-err61-cpp" redirects here as an alias for this checker.
+
 Finds violations of the rule "Throw by value, catch by reference" presented for example in "C++ Coding Standards" by H. Sutter and A. Alexandrescu. This check also has the option to find violations of the rule "Throw anonymous temporaries" (https://www.securecoding.cert.org/confluence/display/cplusplus/ERR09-CPP.+Throw+anonymous+temporaries). The option is named "CheckThrowTemporaries" and it's on by default.
 
 Exceptions:
Index: docs/clang-tidy/checks/misc-static-assert.rst
===
--- docs/clang-tidy/checks/misc-static-assert.rst
+++ docs/clang-tidy/checks/misc-static-assert.rst
@@ -3,6 +3,7 @@
 misc-static-assert
 ==
 
+"cert-dcl03-c" redirects here as an alias for this checker.
 
 Replaces ``assert()`` with ``static_assert()`` if the condition is evaluatable
 at compile time.
Index: docs/clang-tidy/checks/misc-non-copyable-objects.rst
===
--- docs/clang-tidy/checks/misc-non-copyable-objects.rst
+++ docs/clang-tidy/checks/misc-non-copyable-objects.rst
@@ -3,6 +3,8 @@
 misc-non-copyable-objects
 =
 
+"cert-fio38-c" redirects here as an alias for this checker.
+
 The check flags dereferences and non-pointer declarations of objects that are
 not meant to be passed by value, such as C FILE objects or POSIX
 pthread_mutex_t objects.
Index: docs/clang-tidy/checks/misc-new-delete-overloads.rst
===
--- docs/clang-tidy/checks/misc-new-delete-overloads.rst
+++ docs/clang-tidy/checks/misc-new-delete-overloads.rst
@@ -3,6 +3,8 @@
 misc-new-delete-overloads
 =
 
+"cert-dcl54-cpp" redirects here as an alias for this checker.
+
 The check flags overloaded operator new() and operator delete() functions that
 do not have a corresponding free store function defined within the same scope.
 For instance, the check will flag a class implementation of a non-placement
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -3,6 +3,7 @@
 misc-move-constructor-init
 ==
 
+"cert-oop11-cpp" redirects here as an alias for this checker.
 
 The check flags user-defined move constructors that have a ctor-initializer
 initializing a member or base class through a copy constructor instead of a
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,10 +4,16 @@
 =
 
 .. toctree::   
+   cert-dcl03-c (redirects to misc-static-assert) 
cert-dcl50-cpp
+   cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
+   cert-dcl59-cpp (redirects to google-build-namespaces) 
cert-err52-cpp
cert-err58-cpp
cert-err60-cpp
+   cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
+   cert-fio38-c (redirects to misc-non-copyable-objects) 
+   cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/google-build-namespaces.rst
===
--- docs/clang-tidy/checks/google-build-namespaces.rst
+++ 

Re: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

I think this looks good, but I'd also like Manuel to take a look.


http://reviews.llvm.org/D16058



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


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-01-11 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:4934
@@ +4933,3 @@
+const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
+if (AccessAttr->isReadWrite()) {
+  if (DeclTy->isPipeType() ||

In the case of failure, where would destructor of AccessAttr be called?

Could we invoke it before exiting? Or alternatively it's possible to check an 
access kind based on string matching from Attr getName() and create AccessAttr 
later on success.


Comment at: lib/Sema/SemaDeclAttr.cpp:5694
@@ +5693,3 @@
+// attribute and may cause the same attribute to be added twice
+if (const ParmVarDecl *PDecl = llvm::dyn_cast(D)) {
+  if (PDecl->getType().getCanonicalType().getTypePtr()->isPipeType())

So where would the attribute check happen? I don't think the comment is very 
clear.


Comment at: lib/Sema/SemaType.cpp:6223
@@ +6222,3 @@
+   Sema ) {
+  // OpenCL v2.0 s6.6 -- Access Qualifier can used only for image and pipe type
+  if (!(CurType->isImageType() || CurType->isPipeType())) {

remove one -


Comment at: test/SemaOpenCL/invalid-kernel-attrs.cl:31
@@ -30,3 +30,3 @@
   int __kernel x; // expected-error {{'__kernel' attribute only applies to 
functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to 
parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only 
applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only 
applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only 
applies to parameters}}

Strangely, I don't see this diagnostic being added in this patch.


http://reviews.llvm.org/D16040



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


Re: [PATCH] D15097: [Sema] Issue a warning for integer overflow in struct initializer

2016-01-11 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257357: [Sema] Issue a warning for integer overflow in 
struct initializer (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D15097?vs=41451=44521#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15097

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/integer-overflow.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -7853,6 +7853,10 @@
 void Sema::CheckForIntOverflow (Expr *E) {
   if (isa(E->IgnoreParenCasts()))
 E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+  else if (auto InitList = dyn_cast(E))
+for (Expr *E : InitList->inits())
+  if (isa(E->IgnoreParenCasts()))
+E->IgnoreParenCasts()->EvaluateForOverflow(Context);
 }
 
 namespace {
Index: cfe/trunk/test/Sema/integer-overflow.c
===
--- cfe/trunk/test/Sema/integer-overflow.c
+++ cfe/trunk/test/Sema/integer-overflow.c
@@ -145,3 +145,11 @@
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
+
+struct s {
+  unsigned x;
+  unsigned y;
+} s = {
+  .y = 5,
+  .x = 4 * 1024 * 1024 * 1024  // expected-warning {{overflow in expression; 
result is 0 with type 'int'}}
+};


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -7853,6 +7853,10 @@
 void Sema::CheckForIntOverflow (Expr *E) {
   if (isa(E->IgnoreParenCasts()))
 E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+  else if (auto InitList = dyn_cast(E))
+for (Expr *E : InitList->inits())
+  if (isa(E->IgnoreParenCasts()))
+E->IgnoreParenCasts()->EvaluateForOverflow(Context);
 }
 
 namespace {
Index: cfe/trunk/test/Sema/integer-overflow.c
===
--- cfe/trunk/test/Sema/integer-overflow.c
+++ cfe/trunk/test/Sema/integer-overflow.c
@@ -145,3 +145,11 @@
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
+
+struct s {
+  unsigned x;
+  unsigned y;
+} s = {
+  .y = 5,
+  .x = 4 * 1024 * 1024 * 1024  // expected-warning {{overflow in expression; result is 0 with type 'int'}}
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r257357 - [Sema] Issue a warning for integer overflow in struct initializer

2016-01-11 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Jan 11 11:22:01 2016
New Revision: 257357

URL: http://llvm.org/viewvc/llvm-project?rev=257357=rev
Log:
[Sema] Issue a warning for integer overflow in struct initializer

Clang wasn't issuing a warning when compiling the following code:

struct s {
  unsigned x;
} s = {
  .x = 4 * 1024 * 1024 * 1024
};

rdar://problem/23399683

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/integer-overflow.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=257357=257356=257357=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jan 11 11:22:01 2016
@@ -7853,6 +7853,10 @@ void Sema::CheckBoolLikeConversion(Expr
 void Sema::CheckForIntOverflow (Expr *E) {
   if (isa(E->IgnoreParenCasts()))
 E->IgnoreParenCasts()->EvaluateForOverflow(Context);
+  else if (auto InitList = dyn_cast(E))
+for (Expr *E : InitList->inits())
+  if (isa(E->IgnoreParenCasts()))
+E->IgnoreParenCasts()->EvaluateForOverflow(Context);
 }
 
 namespace {

Modified: cfe/trunk/test/Sema/integer-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=257357=257356=257357=diff
==
--- cfe/trunk/test/Sema/integer-overflow.c (original)
+++ cfe/trunk/test/Sema/integer-overflow.c Mon Jan 11 11:22:01 2016
@@ -145,3 +145,11 @@ uint64_t check_integer_overflows(int i)
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
 }
+
+struct s {
+  unsigned x;
+  unsigned y;
+} s = {
+  .y = 5,
+  .x = 4 * 1024 * 1024 * 1024  // expected-warning {{overflow in expression; 
result is 0 with type 'int'}}
+};


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


Re: [PATCH] D16058: [clang-format] Fix comment aligning when there are changes within the comment

2016-01-11 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 44513.
bkramer added a comment.

- Moved newline check into replaceWhitespaceInToken
- Removed duplicated TokenLength computation


http://reviews.llvm.org/D16058

Files:
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1022,6 +1022,15 @@
"  lineWith(); // comment\n"
"  // at start\n"
"}"));
+  EXPECT_EQ("int xy; // a\n"
+"int z;  // b",
+format("int xy;// a\n"
+   "int z;//b"));
+  EXPECT_EQ("int xy; // a\n"
+"int z; // bb",
+format("int xy;// a\n"
+   "int z;//bb",
+   getLLVMStyleWithColumns(12)));
 
   verifyFormat("#define A  \\\n"
"  int i; /* i */   \\\n"
Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -109,7 +109,8 @@
unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
unsigned NewlinesBefore, StringRef PreviousLinePostfix,
StringRef CurrentLinePrefix, tok::TokenKind Kind,
-   bool ContinuesPPDirective, bool IsStartOfDeclName);
+   bool ContinuesPPDirective, bool IsStartOfDeclName,
+   bool IsInsideTrailingCommentToken);
 
 bool CreateReplacement;
 // Changes might be in the middle of a token, so we cannot just keep the
@@ -139,6 +140,9 @@
 // comments. Uncompensated negative offset is truncated to 0.
 int Spaces;
 
+// If this change is inside of a token but not at the start of the token.
+bool IsInsideToken;
+
 // \c IsTrailingComment, \c TokenLength, \c PreviousEndOfTokenColumn and
 // \c EscapedNewlineColumn will be calculated in
 // \c calculateLineBreakInformation.
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -30,16 +30,16 @@
 unsigned IndentLevel, int Spaces, unsigned StartOfTokenColumn,
 unsigned NewlinesBefore, StringRef PreviousLinePostfix,
 StringRef CurrentLinePrefix, tok::TokenKind Kind, bool ContinuesPPDirective,
-bool IsStartOfDeclName)
+bool IsStartOfDeclName, bool IsInsideToken)
 : CreateReplacement(CreateReplacement),
   OriginalWhitespaceRange(OriginalWhitespaceRange),
   StartOfTokenColumn(StartOfTokenColumn), NewlinesBefore(NewlinesBefore),
   PreviousLinePostfix(PreviousLinePostfix),
   CurrentLinePrefix(CurrentLinePrefix), Kind(Kind),
   ContinuesPPDirective(ContinuesPPDirective),
   IsStartOfDeclName(IsStartOfDeclName), IndentLevel(IndentLevel),
-  Spaces(Spaces), IsTrailingComment(false), TokenLength(0),
-  PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
+  Spaces(Spaces), IsInsideToken(IsInsideToken), IsTrailingComment(false),
+  TokenLength(0), PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
   StartOfBlockComment(nullptr), IndentationOffset(0) {}
 
 void WhitespaceManager::reset() {
@@ -58,7 +58,8 @@
   Change(/*CreateReplacement=*/true, Tok.WhitespaceRange, IndentLevel,
  Spaces, StartOfTokenColumn, Newlines, "", "", Tok.Tok.getKind(),
  InPPDirective && !Tok.IsFirst,
- Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+ Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+ /*IsInsideToken=*/false));
 }
 
 void WhitespaceManager::addUntouchableToken(const FormatToken ,
@@ -69,7 +70,8 @@
   /*CreateReplacement=*/false, Tok.WhitespaceRange, /*IndentLevel=*/0,
   /*Spaces=*/0, Tok.OriginalColumn, Tok.NewlinesBefore, "", "",
   Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst,
-  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName)));
+  Tok.is(TT_StartOfName) || Tok.is(TT_FunctionDeclarationName),
+  /*IsInsideToken=*/false));
 }
 
 void WhitespaceManager::replaceWhitespaceInToken(
@@ -82,15 +84,10 @@
   Changes.push_back(Change(
   true, SourceRange(Start, Start.getLocWithOffset(ReplaceChars)),
   IndentLevel, Spaces, std::max(0, Spaces), Newlines, PreviousPostfix,
-  CurrentPrefix,
-  // If we don't add a newline this change doesn't start a comment. Thus,
-  // when we align line comments, we don't need to treat this change as one.
-  // FIXME: We still need to take this change in account to properly
-  // calculate the new length of the comment and to calculate the changes
-  // for which to do the alignment when aligning 

  1   2   >