Re: [PATCH] D18565: Implement an "I'm dtrace, please retain all debug types" option.

2016-03-29 Thread David Blaikie via cfe-commits
On Tue, Mar 29, 2016 at 12:03 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> > On Mar 29, 2016, at 12:00 PM, Joerg Sonnenberger <
> jo...@britannica.bec.de> wrote:
> >
> > On Tue, Mar 29, 2016 at 06:47:24PM +, Adrian Prantl via cfe-commits
> wrote:
> >> This code in this patch listens to the driver option -gfull, and lowers
> it to the new cc1 option -debug-retain-types (1).
> >> When -debug-retain-types is present, CGDebugInfo will retain every(2)
> type it creates.
> >
> > Is there a good reason for calling it -gfull? I would find something
> > -gall-types or -gretain-all-types to make a lot more sense. This should
> > be orthogonal to other options like providing only line tables?
>
> My thinking was this:
> The driver already supports -gfull, but it doesn’t do anything.
> This patch can be considered a first step towards making -gfull behave as
> expected.
> Eventually it should emit debug info for *all* types.
>

Seems somewhat problematic to half implement it, though. (admittedly we're
just silently ignoring it right now)

& is 'real' -gfull what dtrace really wants? (seems it isn't - since
clang's never really implemented it?)

Emitting all types referenced by used (even if later optimized away) code
seems like the thing? -greferenced? or maybe a -f flag? Not sure.


>
> > Joerg
> >
> > PS: Slightly related side question, do we have any tools for extracting
> > a given list of types for retaining? Either by name or global variable
> > expression.
>
> Extract them from where? Can you give an example?
>
> -- adrian
> ___
> 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] D17955: [OpenCL] Fix pipe builtin bugs

2016-03-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264825: [OpenCL] Fix pipe builtin bugs (authored by pxl).

Changed prior to commit:
  http://reviews.llvm.org/D17955?vs=51629=52021#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17955

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7776,7 +7776,7 @@
 def err_opencl_builtin_pipe_arg_num : Error<
   "invalid number of arguments to function: %0">;
 def err_opencl_builtin_pipe_invalid_arg : Error<
-  "invalid argument type to function %0 (expecting %1)">;
+  "invalid argument type to function %0 (expecting %1 having %2)">;
 def err_opencl_builtin_pipe_invalid_access_modifier : Error<
   "invalid pipe access modifier (expecting %0)">;
 
Index: cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -5,46 +5,56 @@
   reserve_id_t rid;
 
   // read/write_pipe
+  read_pipe(p, );
+  read_pipe(p, ptr);
   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 *')}}
+  read_pipe(p, rid, tmp, ptr);
+  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t' having 'int')}}
+  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int' having 'reserve_id_t')}}
+  read_pipe(p, tmp);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'int *' having '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')}}
+  reserve_read_pipe(p, tmp);
+  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function 'reserve_read_pipe' (expecting 'unsigned int' having '__global 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(p, rid);
   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')}}
+  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function 'work_group_commit_read_pipe' (expecting 'reserve_id_t' having 'int')}}
   sub_group_commit_write_pipe(p, tmp);// expected-error{{invalid 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(p, );
+  write_pipe(p, ptr);
   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 *')}}
+  write_pipe(p, rid, tmp, ptr);
+  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t' having 'int')}}
+  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int' having 'reserve_id_t')}}
+  write_pipe(p, tmp);   // expected-error 

r264825 - [OpenCL] Fix pipe builtin bugs

2016-03-29 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Tue Mar 29 23:46:32 2016
New Revision: 264825

URL: http://llvm.org/viewvc/llvm-project?rev=264825=rev
Log:
[OpenCL] Fix pipe builtin bugs

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

Reviewers: yaxunl, Anastasia

Subscribers: MatsPetersson, pekka.jaaskelainen, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=264825=264824=264825=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 29 23:46:32 
2016
@@ -7776,7 +7776,7 @@ def err_opencl_builtin_pipe_first_arg :
 def err_opencl_builtin_pipe_arg_num : Error<
   "invalid number of arguments to function: %0">;
 def err_opencl_builtin_pipe_invalid_arg : Error<
-  "invalid argument type to function %0 (expecting %1)">;
+  "invalid argument type to function %0 (expecting %1 having %2)">;
 def err_opencl_builtin_pipe_invalid_access_modifier : Error<
   "invalid pipe access modifier (expecting %0)">;
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=264825=264824=264825=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 29 23:46:32 2016
@@ -325,10 +325,12 @@ static bool checkOpenCLPipePacketType(Se
   const PointerType *ArgTy = ArgIdx->getType()->getAs();
   // The Idx argument should be a pointer and the type of the pointer and
   // the type of pipe element should also be the same.
-  if (!ArgTy || S.Context.hasSameType(EltTy, ArgTy->getPointeeType())) {
+  if (!ArgTy ||
+  !S.Context.hasSameType(
+  EltTy, ArgTy->getPointeeType()->getCanonicalTypeInternal())) {
 S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
 << Call->getDirectCallee() << S.Context.getPointerType(EltTy)
-<< ArgIdx->getSourceRange();
+<< ArgIdx->getType() << ArgIdx->getSourceRange();
 return true;
   }
   return false;
@@ -361,7 +363,7 @@ static bool SemaBuiltinRWPipe(Sema , C
 if (!Call->getArg(1)->getType()->isReserveIDT()) {
   S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
   << Call->getDirectCallee() << S.Context.OCLReserveIDTy
-  << Call->getArg(1)->getSourceRange();
+  << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
   return true;
 }
 
@@ -371,7 +373,7 @@ static bool SemaBuiltinRWPipe(Sema , C
 !Arg2->getType()->isUnsignedIntegerType()) {
   S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
   << Call->getDirectCallee() << S.Context.UnsignedIntTy
-  << Arg2->getSourceRange();
+  << Arg2->getType() << Arg2->getSourceRange();
   return true;
 }
 
@@ -405,7 +407,7 @@ static bool SemaBuiltinReserveRWPipe(Sem
   !Call->getArg(1)->getType()->isUnsignedIntegerType()) {
 S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
 << Call->getDirectCallee() << S.Context.UnsignedIntTy
-<< Call->getArg(1)->getSourceRange();
+<< Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
 return true;
   }
 
@@ -428,7 +430,7 @@ static bool SemaBuiltinCommitRWPipe(Sema
   if (!Call->getArg(1)->getType()->isReserveIDT()) {
 S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
 << Call->getDirectCallee() << S.Context.OCLReserveIDTy
-<< Call->getArg(1)->getSourceRange();
+<< Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
 return true;
   }
 

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl?rev=264825=264824=264825=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl Tue Mar 29 23:46:32 
2016
@@ -5,22 +5,27 @@ void test1(read_only pipe int p, global
   reserve_id_t rid;
 
   // read/write_pipe
+  read_pipe(p, );
+  read_pipe(p, ptr);
   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 

Re: [PATCH] D18110: [OpenMP] Fix SEMA bug in the capture of global variables in template functions.

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


Comment at: lib/Sema/SemaOpenMP.cpp:816-822
@@ -801,6 +815,9 @@
+
+  // A DSA refers to this captured region if the parent contexts match.
+  auto *ParentContext = RSI->TheCapturedDecl->getParent();
   for (auto I = Stack.rbegin(), EE = Stack.rend(); I != EE; ++I)
-if (I->CurScope == S)
+if (I->ParentDeclContext == ParentContext)
   return I->Directive;
   return OMPD_unknown;
 }
 

Actually, I think, we need to rework the whole IsOpenMPCapturedByRef() 
function. I'm not sure that it is even required. It looks like some 
optimization hack in the frontend. I'm against any not-necessary optimizations 
in frontend. If scalar value is a firstprivate, it must be handled in codegen, 
not by handling it by copy.


http://reviews.llvm.org/D18110



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


Re: [PATCH] D18474: [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets

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


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4257
@@ +4256,3 @@
+hasEnclosingOpenMPDirective(const Stmt *Body) {
+  const SK *S = nullptr;
+  // keep iterating until we find an LF or not an SK or a nullptr

You don't need `SK`, because `body_front()` member function exists only in 
`CompoundStmt`.


Repository:
  rL LLVM

http://reviews.llvm.org/D18474



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


Re: [PATCH] D18470: [OPENMP] Remove unnecessary code generation of firstprivate clause for target directive in nvptx

2016-03-29 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Update patch to the latest version. It is not allowed to override CodeGen 
sequemces in runtime. They must be universal and all must be defined in 
CGStmtOpenMP.cpp only


Repository:
  rL LLVM

http://reviews.llvm.org/D18470



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


Re: [PATCH] D18286: [OPENMP] private and firstprivate clauses of teams code generation for nvptx

2016-03-29 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Thinking more about this patch I think it is a right solution to override void 
`llvm::Value *emitParallelOrTeamsOutlinedFunction()` and `void emitTeamsCall()` 
for `CGOpenMPRuntimeNVPTX` class:

  llvm::Value *CGOpenMPRuntimeNVPTX::emitParallelOrTeamsOutlinedFunction() {
llvm::Value *OutlinedFn = 
CGOpenMPRuntime::emitParallelOrTeamsOutlinedFunction();
cast(OutlinedFn)->addFnAttr(llvm::Attribute::AlwaysInline);
return OutlinedFn;
  }

  void CGOpenMPRuntimeNVPTX::emitTeamsCall() {
if (!CGF.HaveInsertPoint())
  return;
  
CodeGenFunction::RunCleanupsScope Scope(CGF);
Address ZeroAddr =
  CGF.CreateTempAlloca(CGF.Int32Ty, CharUnits::fromQuantity(4),
   /*Name*/ ".zero.addr");
CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
llvm::SmallVector OutlinedFnArgs;
OutlinedFnArgs.push_back(ZeroAddr.getPointer());
OutlinedFnArgs.push_back(ZeroAddr.getPointer());
OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
CGF.EmitCallOrInvoke(OutlinedFn, OutlinedFnArgs);
  }

Also, please update patch to the latest revision


Repository:
  rL LLVM

http://reviews.llvm.org/D18286



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


r264813 - [Driver] Quote clang full version in dwarf producer when invoking cc1as

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 29 19:25:57 2016
New Revision: 264813

URL: http://llvm.org/viewvc/llvm-project?rev=264813=rev
Log:
[Driver] Quote clang full version in dwarf producer when invoking cc1as

Convenience to allow easy copy-n-paste from clang -v output when
reproducing cc1as comandline.

rdar://problem/23959295

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Misc/cc1as-asm.s

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=264813=264812=264813=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Mar 29 19:25:57 2016
@@ -6226,7 +6226,8 @@ void ClangAs::ConstructJob(Compilation &
 // Set the AT_producer to the clang version when using the integrated
 // assembler on assembly source files.
 CmdArgs.push_back("-dwarf-debug-producer");
-CmdArgs.push_back(Args.MakeArgString(getClangFullVersion()));
+std::string QuotedClangVersion("'" + getClangFullVersion() + "'");
+CmdArgs.push_back(Args.MakeArgString(QuotedClangVersion));
 
 // And pass along -I options
 Args.AddAllArgs(CmdArgs, options::OPT_I);

Modified: cfe/trunk/test/Misc/cc1as-asm.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-asm.s?rev=264813=264812=264813=diff
==
--- cfe/trunk/test/Misc/cc1as-asm.s (original)
+++ cfe/trunk/test/Misc/cc1as-asm.s Tue Mar 29 19:25:57 2016
@@ -1,3 +1,5 @@
 // Run cc1as asm output path just to make sure it works
 // REQUIRES: x86-registered-target
 // RUN: %clang -cc1as -triple x86_64-apple-macosx10.10.0 -filetype asm %s -o 
/dev/null
+// Test that cc1as is able to consume a quoted clang full version
+// RUN: %clang -cc1as -triple x86_64-apple-macosx10.10.0 -dwarf-debug-producer 
'clang dummy version' -filetype asm %s -o /dev/null


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


Re: [PATCH] D18539: [CUDA] Add math forward declares.

2016-03-29 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

One nit. LGTM otherwise.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:1
@@ +1,2 @@
+/*=== __clang_cuda_cmath.h - Device-side CUDA cmath support ===
+ *

This should be updated.


http://reviews.llvm.org/D18539



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


Re: r264071 - StaticAnalyzer: Avoid an unintentional copy

2016-03-29 Thread Justin Bogner via cfe-commits
David Blaikie  writes:
> On Tue, Mar 22, 2016 at 10:50 AM, Justin Bogner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: bogner
>> Date: Tue Mar 22 12:50:05 2016
>> New Revision: 264071
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=264071=rev
>> Log:
>> StaticAnalyzer: Avoid an unintentional copy
>>
>
> Just to be clear - it sounds like a copy happens here regardless. It's just
> best to be explicit so readers aren't confused about that. (sounds like the
> iterator produces results by value (probably non-standard for an iterator
> to do that, but probably not uncommon) & so taking a reference to it does
> reference lifetime extension, etc) Now we're being explicit aobut the
> pointer being copied, rather than implying that we refer to a pointer kept
> inside the sequence/container.

Right. The copy was actually only of the pointer here, so my commit
message was kind of confusing. It should've been more like "Use a
`FieldDecl *` rather than a `FieldDecl *&`".

>
>>
>> The range here isn't over references, so using `auto &` here incites a
>> copy. Switching to `auto *` would do, but we might as well list an
>> explicit type for clarity.
>>
>> Found by -Wrange-loop-analysis.
>>
>> Modified:
>> cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=264071=264070=264071=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Tue Mar 22
>> 12:50:05 2016
>> @@ -168,7 +168,7 @@ public:
>>  const ASTRecordLayout ) {
>>  CharUnits PaddingSum;
>>  CharUnits Offset =
>> ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
>> -for (const auto  : RD->fields()) {
>> +for (const FieldDecl *FD : RD->fields()) {
>>// This checker only cares about the padded size of the
>>// field, and not the data size. If the field is a record
>>// with tail padding, then we won't put that number in our
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18585: [CrashReproducer] Add a module map callback for added headers

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added a reviewer: benlangmuir.
bruno added a subscriber: cfe-commits.



The current ModuleDependencyCollector has a AST listener to collect
header files present in loaded modules, but this isn't enough to collect
all headers needed in the crash reproducer. One of the reasons is that
the AST writer doesn't write symbolic link header paths in the pcm modules,
this makes the listeners on the reader only able to collect the real files.

Since the module maps could contain submodules that use headers which
are symbolic links, not collecting those forbid the reproducer scripts
to regen the modules.

For instance:

usr/include/module.map:
  ...
  module pthread {
header "pthread.h"
export *

module impl {
  header "pthread_impl.h"
  export *
}
  }
  ...

usr/include/pthread/pthread_impl.h
usr/include/pthread_impl.h -> pthread/pthread_impl.h

The AST dump for the module above:

   blob data = 'pthread_impl.h'
   blob data = 
'//usr/include/pthread/pthread_impl.h'

Note that we don't have "usr/include/pthread_impl.h" which is requested
by the module.map in case we want to reconstruct the module in the
reproducer. The reason the original symbolic link path isn't used is
because the headers are kept by name and requested through the
FileManager, which unique files and returns the real path only.

To fix that, add a callback to be invoked everytime a header is added
while parsing module maps and hook that up to the module dependecy
collector. This callback is only registered when generating the
reproducer.

http://reviews.llvm.org/D18585

Files:
  include/clang/Frontend/Utils.h
  include/clang/Lex/ModuleMap.h
  lib/Frontend/ModuleDependencyCollector.cpp
  lib/Lex/ModuleMap.cpp
  test/Modules/Inputs/crash-recovery/usr/include/module.map
  test/Modules/Inputs/crash-recovery/usr/include/pthread.h
  test/Modules/Inputs/crash-recovery/usr/include/pthread/pthread_impl.h
  test/Modules/Inputs/crash-recovery/usr/include/pthread_impl.h
  test/Modules/crash-vfs-path-symlink-topheader.m

Index: test/Modules/crash-vfs-path-symlink-topheader.m
===
--- /dev/null
+++ test/Modules/crash-vfs-path-symlink-topheader.m
@@ -0,0 +1,50 @@
+// REQUIRES: crash-recovery, shell
+
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
+// XFAIL: mingw32
+
+// Test clang can collect symbolic link headers used in modules.
+// crash reproducer if there's a symbolic link header file used in a module.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/i %t/m %t %t/sysroot
+// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: rm -f %t/i/usr/include/pthread_impl.h
+// RUN: ln -s pthread/pthread_impl.h %t/i/usr/include/pthread_impl.h
+
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
+
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
+// RUN: find %t/crash-vfs-*.cache/vfs | \
+// RUN:   grep "usr/include/pthread_impl.h" | count 1
+
+#include "usr/include/stdio.h"
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+
+// CHECKSRC: @import cstd.stdio;
+
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: "-fsyntax-only"
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-isysroot" "{{[^"]*}}/sysroot/"
+// CHECKSH-NOT: "-fmodules-cache-path="
+// CHECKSH: "crash-vfs-{{[^ ]*}}.m"
+// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
+
+// CHECKYAML: 'type': 'directory',
+// CHECKYAML: 'name': "",
+// CHECKYAML-NEXT: 'contents': [
+// CHECKYAML-NEXT:   {
+// CHECKYAML-NEXT: 'type': 'file',
+// CHECKYAML-NEXT: 'name': "pthread_impl.h",
+// CHECKYAML-NEXT: 'external-contents': "/{{.*}}/i/usr/include/pthread_impl.h"
+// CHECKYAML-NEXT:   },
Index: test/Modules/Inputs/crash-recovery/usr/include/pthread_impl.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-recovery/usr/include/pthread_impl.h
@@ -0,0 +1 @@
+#define _PTHREAD_MUTEX_SIG_init   0x32AAABA7
Index: test/Modules/Inputs/crash-recovery/usr/include/pthread/pthread_impl.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-recovery/usr/include/pthread/pthread_impl.h
@@ -0,0 +1 @@
+#define _PTHREAD_MUTEX_SIG_init   0x32AAABA7
Index: test/Modules/Inputs/crash-recovery/usr/include/pthread.h

r264808 - [CrashReproducer] Cleanup and move functionality around in ModuleDependencyCollector. NFC

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 29 18:47:40 2016
New Revision: 264808

URL: http://llvm.org/viewvc/llvm-project?rev=264808=rev
Log:
[CrashReproducer] Cleanup and move functionality around in 
ModuleDependencyCollector. NFC

- Make ModuleDependencyCollector use the DependencyCollector interface
- Move some methods from ModuleDependencyListener to ModuleDependencyCollector
in order to share common functionality with other future possible
callbacks.

Modified:
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=264808=264807=264808=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Tue Mar 29 18:47:40 2016
@@ -73,12 +73,12 @@ void DoPrintPreprocessedInput(Preprocess
 /// An interface for collecting the dependencies of a compilation. Users should
 /// use \c attachToPreprocessor and \c attachToASTReader to get all of the
 /// dependencies.
-// FIXME: Migrate DependencyFileGen, DependencyGraphGen, ModuleDepCollectory to
-// use this interface.
+/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this
+/// interface.
 class DependencyCollector {
 public:
   void attachToPreprocessor(Preprocessor );
-  void attachToASTReader(ASTReader );
+  virtual void attachToASTReader(ASTReader );
   llvm::ArrayRef getDependencies() const { return Dependencies; }
 
   /// Called when a new file is seen. Return true if \p Filename should be 
added
@@ -118,25 +118,29 @@ public:
 
 /// Collects the dependencies for imported modules into a directory.  Users
 /// should attach to the AST reader whenever a module is loaded.
-class ModuleDependencyCollector {
+class ModuleDependencyCollector : public DependencyCollector {
   std::string DestDir;
-  bool HasErrors;
+  bool HasErrors = false;
   llvm::StringSet<> Seen;
   vfs::YAMLVFSWriter VFSWriter;
 
+  llvm::StringMap SymLinkMap;
+
+  bool getRealPath(StringRef SrcPath, SmallVectorImpl );
+  std::error_code copyToRoot(StringRef Src);
 public:
   StringRef getDest() { return DestDir; }
   bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void setHasErrors() { HasErrors = true; }
+  void addFile(StringRef Filename);
   void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }
 
-  void attachToASTReader(ASTReader );
+  void attachToASTReader(ASTReader ) override;
+
   void writeFileMap();
   bool hasErrors() { return HasErrors; }
-  ModuleDependencyCollector(std::string DestDir)
-  : DestDir(DestDir), HasErrors(false) {}
+  ModuleDependencyCollector(std::string DestDir) : DestDir(DestDir) {}
   ~ModuleDependencyCollector() { writeFileMap(); }
 };
 

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=264808=264807=264808=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Mar 29 18:47:40 2016
@@ -349,14 +349,18 @@ void CompilerInstance::createPreprocesso
 AttachDependencyGraphGen(*PP, DepOpts.DOTOutputFile,
  getHeaderSearchOpts().Sysroot);
 
-  for (auto  : DependencyCollectors)
-Listener->attachToPreprocessor(*PP);
-
   // If we don't have a collector, but we are collecting module dependencies,
   // then we're the top level compiler instance and need to create one.
-  if (!ModuleDepCollector && !DepOpts.ModuleDependencyOutputDir.empty())
+  if (!ModuleDepCollector && !DepOpts.ModuleDependencyOutputDir.empty()) {
 ModuleDepCollector = std::make_shared(
 DepOpts.ModuleDependencyOutputDir);
+  }
+
+  if (ModuleDepCollector)
+addDependencyCollector(ModuleDepCollector);
+
+  for (auto  : DependencyCollectors)
+Listener->attachToPreprocessor(*PP);
 
   // Handle generating header include information, if requested.
   if (DepOpts.ShowHeaderIncludes)
@@ -1319,8 +1323,6 @@ void CompilerInstance::createModuleManag
 
 if (TheDependencyFileGenerator)
   TheDependencyFileGenerator->AttachToASTReader(*ModuleManager);
-if (ModuleDepCollector)
-  ModuleDepCollector->attachToASTReader(*ModuleManager);
 for (auto  : DependencyCollectors)
   Listener->attachToASTReader(*ModuleManager);
   }

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=264808=264807=264808=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ 

Re: [PATCH] D18540: [Sema] Note when we've actually encountered a failure in ExprConstant, and take that into account when looking up objects.

2016-03-29 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/Expr.h:541-546
@@ -540,1 +540,8 @@
 
+/// \brief Whether the evaluation was unable to reduce a construct to a
+/// value.
+///
+/// For example, in foo(bar, baz, qux), if evaluating bar fails, we may
+/// try to evaluate baz and qux anyway.
+bool HasFailure;
+

I don't think this provides enough guarantees to be useful as part of the 
external `EvalStatus` results. Can you sink this into `EvalInfo`? 
Alternatively, can you merge this with `HasSideEffects`? I don't think we need 
to maintain a distinction between the two different ways we can get an 
evaluation result after skipping a subexpression.


http://reviews.llvm.org/D18540



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


Re: [PATCH] D18073: Add memory allocating functions

2016-03-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> > Also, we should not duplicate all of our tests. Instead, we should add a 
> > single test per added API checking that it is modeling the operation we 
> > think it 

> 

> >  should model.

> 

> 

> So should I dump the _dbg versions from the tests?


No but do not duplicate all of the tests. Please, add a single test per API you 
are adding.


http://reviews.llvm.org/D18073



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


Re: [PATCH] D17253: Cleanup of analyzer scripts as suggested by pychecker and pep8

2016-03-29 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Once tested, this can land.


http://reviews.llvm.org/D17253



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


Re: [PATCH] D18210: [analyzer] Fix an assertion fail in hash generation.

2016-03-29 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D18210



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-03-29 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please add information about this check in docs/ReleaseNotes.rst.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D18533: Fixing PR26558: the adc builtins do not require the adx target attribute

2016-03-29 Thread Yunzhong Gao via cfe-commits
ygao added a comment.

> Yep, only the ADCX instruction needs adx. This LGTM, but please just

>  remove "-target-feature +adx" from the run line instead of adding a

>  second run line.


Thanks, Justin.
Committed r264801 and updated the test as you suggested.


Repository:
  rL LLVM

http://reviews.llvm.org/D18533



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


Re: [PATCH] D18533: Fixing PR26558: the adc builtins do not require the adx target attribute

2016-03-29 Thread Yunzhong Gao via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264801: Fixing PR26558: remove the adx target attribute 
requirement from adc builtins. (authored by ygao).

Changed prior to commit:
  http://reviews.llvm.org/D18533?vs=51857=52000#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18533

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/test/CodeGen/adc-builtins.c

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -690,10 +690,10 @@
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "adx")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "")
 
 // RDSEED
 TARGET_BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "", "rdseed")
Index: cfe/trunk/test/CodeGen/adc-builtins.c
===
--- cfe/trunk/test/CodeGen/adc-builtins.c
+++ cfe/trunk/test/CodeGen/adc-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +adx 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
 
 #define __MM_MALLOC_H
 


Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -690,10 +690,10 @@
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "adx")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "")
 
 // RDSEED
 TARGET_BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "", "rdseed")
Index: cfe/trunk/test/CodeGen/adc-builtins.c
===
--- cfe/trunk/test/CodeGen/adc-builtins.c
+++ cfe/trunk/test/CodeGen/adc-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +adx -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
 
 #define __MM_MALLOC_H
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r264801 - Fixing PR26558: remove the adx target attribute requirement from adc builtins.

2016-03-29 Thread Yunzhong Gao via cfe-commits
Author: ygao
Date: Tue Mar 29 17:59:20 2016
New Revision: 264801

URL: http://llvm.org/viewvc/llvm-project?rev=264801=rev
Log:
Fixing PR26558: remove the adx target attribute requirement from adc builtins.

The addcarry and subborrow variants of the builtins do not require the adx
target attribute; only the addcarryx variants require them.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/test/CodeGen/adc-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=264801=264800=264801=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Mar 29 17:59:20 2016
@@ -690,10 +690,10 @@ TARGET_BUILTIN(__builtin_ia32_xsaves64,
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "adx")
-TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "adx")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "")
+TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "")
 
 // RDSEED
 TARGET_BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "", "rdseed")

Modified: cfe/trunk/test/CodeGen/adc-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/adc-builtins.c?rev=264801=264800=264801=diff
==
--- cfe/trunk/test/CodeGen/adc-builtins.c (original)
+++ cfe/trunk/test/CodeGen/adc-builtins.c Tue Mar 29 17:59:20 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +adx 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
 
 #define __MM_MALLOC_H
 


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


Re: [PATCH] D18533: Fixing PR26558: the adc builtins do not require the adx target attribute

2016-03-29 Thread Justin Bogner via cfe-commits
Yunzhong Gao  writes:
> ygao created this revision.
> ygao added subscribers: craig.topper, bogner, cfe-commits.
>
> Hi,
> The addcarry and subborrow variants of the builtins do not require the
> adx target attribute. Only the addcarryx variants require them.
> This patch attempts to remove the target attribute requirements from
> these builtins, and also to update the test (run the same test without
> adx and make sure nothing breaks).
> Could you review?

Yep, only the ADCX instruction needs adx. This LGTM, but please just
remove "-target-feature +adx" from the run line instead of adding a
second run line.

> Many thanks,
> - Gao
>
> http://reviews.llvm.org/D18533
>
> Files:
>   include/clang/Basic/BuiltinsX86.def
>   test/CodeGen/adc-builtins.c
>
> Index: test/CodeGen/adc-builtins.c
> ===
> --- test/CodeGen/adc-builtins.c
> +++ test/CodeGen/adc-builtins.c
> @@ -1,4 +1,5 @@
>  // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +adx 
> -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
> FileCheck %s
>  
>  #define __MM_MALLOC_H
>  
> Index: include/clang/Basic/BuiltinsX86.def
> ===
> --- include/clang/Basic/BuiltinsX86.def
> +++ include/clang/Basic/BuiltinsX86.def
> @@ -690,10 +690,10 @@
>  // ADX
>  TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
>  TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "adx")
> +TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "")
>  
>  // RDSEED
>  TARGET_BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "", "rdseed")
>
>
> Index: test/CodeGen/adc-builtins.c
> ===
> --- test/CodeGen/adc-builtins.c
> +++ test/CodeGen/adc-builtins.c
> @@ -1,4 +1,5 @@
>  // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +adx 
> -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
> FileCheck %s
>  
>  #define __MM_MALLOC_H
>  
> Index: include/clang/Basic/BuiltinsX86.def
> ===
> --- include/clang/Basic/BuiltinsX86.def
> +++ include/clang/Basic/BuiltinsX86.def
> @@ -690,10 +690,10 @@
>  // ADX
>  TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
>  TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "adx")
> -TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "adx")
> +TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "", "")
> +TARGET_BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "", "")
>  
>  // RDSEED
>  TARGET_BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "", "rdseed")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18582: [Clang-tidy] Update release notes with list of checks added since 3.8

2016-03-29 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, LegalizeAdulthood, aaron.ballman, 
sbenza, etienne.bergeron.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

Descriptions of checks were extracted from documentations. If style is wrong, 
will be good idea if native English speaker will fix both release notes and 
documentation.

I also mentioned fix of crash on compile database with relative paths.

Repository:
  rL LLVM

http://reviews.llvm.org/D18582

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -63,11 +63,82 @@
 explain them more clearly, and provide more accurate fix-its for the issues
 identified.  The improvements since the 3.8 release include:
 
+- New ``cert-env33-c`` check
+
+  This check flags calls to ``system()``, ``popen()``, and ``_popen()``, which
+  execute a command processor.
+
+- New ``cert-flp30-c`` check
+
+  This check flags ``for`` loops where the induction expression has a floating-
+  point type.
+
+- New ``cppcoreguidelines-pro-type-member-init`` check
+
+  The check flags user-defined constructor definitions that do not initialize
+  all builtin and pointer fields which leaves their memory in an undefined
+  state.
+
+- New ``misc-dangling-handle`` check
+
+  This check detects dangling references in value handlers like
+  `std::experimental::string_view`.
+
+- New ``misc-forward-declaration-namespace`` check
+
+  This check checks if an unused forward declaration is in a wrong namespace.
+
+- New ``misc-misplaced-widening-cast`` check
+
+  This check warns when there is a explicit redundant cast of a calculation
+  result to a bigger type.
+
+- New ``misc-suspicious-semicolon`` check
+
+  This check finds most instances of stray semicolons that unexpectedly alter
+  the meaning of the code.
+
+- New ``modernize-deprecated-headers`` check
+
+  This check replaces C standard library headers with their C++ alternatives.
+
 - New ``modernize-raw-string-literal`` check
 
   This check selectively replaces string literals containing escaped
   characters with raw string literals.
 
+- New ``performance-faster-string-find`` check
+
+  Optimize calls to std::string::find() and friends when the needle passed is a
+  single character string literal.
+
+- New ``performance-implicit-cast-in-loop`` check
+
+  This check warns about range-based loop with loop variable of const ref type
+  where the type of the variable does not match the one returned by the
+  iterator.
+
+- New ``performance-unnecessary-value-param`` check
+
+  This check flags value parameter declarations of expensive to copy types that
+  are copied for each invocation but it would suffice to pass them by const
+  reference.
+
+- New ``readability-redundant-control-flow`` check
+
+  This check looks for procedures (functions returning no value) with `return`
+  statements at the end of the function.  Such `return` statements are
+  redundant.
+
+- New ``readability-redundant-string-init`` check
+
+  This check finds unnecessary string initializations.
+
+Fixed bugs:
+
+  Crash when ``clang-tidy`` runs on compile database with relative source files
+  paths.
+
 Improvements to ``modularize``
 ^^
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -63,11 +63,82 @@
 explain them more clearly, and provide more accurate fix-its for the issues
 identified.  The improvements since the 3.8 release include:
 
+- New ``cert-env33-c`` check
+
+  This check flags calls to ``system()``, ``popen()``, and ``_popen()``, which
+  execute a command processor.
+
+- New ``cert-flp30-c`` check
+
+  This check flags ``for`` loops where the induction expression has a floating-
+  point type.
+
+- New ``cppcoreguidelines-pro-type-member-init`` check
+
+  The check flags user-defined constructor definitions that do not initialize
+  all builtin and pointer fields which leaves their memory in an undefined
+  state.
+
+- New ``misc-dangling-handle`` check
+
+  This check detects dangling references in value handlers like
+  `std::experimental::string_view`.
+
+- New ``misc-forward-declaration-namespace`` check
+
+  This check checks if an unused forward declaration is in a wrong namespace.
+
+- New ``misc-misplaced-widening-cast`` check
+
+  This check warns when there is a explicit redundant cast of a calculation
+  result to a bigger type.
+
+- New ``misc-suspicious-semicolon`` check
+
+  This check finds most instances of stray semicolons that unexpectedly alter
+  the meaning of the code.
+
+- New ``modernize-deprecated-headers`` check
+
+  This check replaces C standard library headers with their C++ alternatives.
+
 - New ``modernize-raw-string-literal`` check
 
   This check 

Re: [PATCH] D18557: [Clang][ARM] __va_list declaration is not saved in ASTContext causing compilation error or crash

2016-03-29 Thread Richard Smith via cfe-commits
rsmith added a comment.

Thanks, the change itself LGTM, but please add your testcase, perhaps to 
test/PCH/__va_list_tag.c


Repository:
  rL LLVM

http://reviews.llvm.org/D18557



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


Re: r264783 - [PGO] Move the instrumentation point closer to the value site.

2016-03-29 Thread Artem Belevich via cfe-commits
Thanks for the quick fix. The test works on x86_64-unknown-linux-gnu now.

--Artem

On Tue, Mar 29, 2016 at 3:24 PM, Betul Buyukkurt 
wrote:

> Hi Artem,
>
>
>
> I’ve uploaded a patch to remove the alignment.
>
>
>
> Thanks,
>
> -Betul
>
>
>
> *From:* Artem Belevich [mailto:t...@google.com]
> *Sent:* Tuesday, March 29, 2016 3:15 PM
> *To:* Betul Buyukkurt 
> *Cc:* cfe-commits 
> *Subject:* Re: r264783 - [PGO] Move the instrumentation point closer to
> the value site.
>
>
>
> Hi,
>
>
>
> FYI, cxx-indirect-call.cpp test fails on platforms with different
> alignment. It may help to either use specific target or change your
> patterns to accommodate other targets.
>
>
>
> --Artem
>
>
>
>  TEST 'Clang :: Profile/cxx-indirect-call.cpp' FAILED
> 
>
> Script:
>
> --
>
> /usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/clang
> --driver-mode=g++
>  /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp -o -
> -emit-llvm -S -fprofile-instr-generate -mllvm -enable-value-profiling
> -fexceptions -target x86_64-unknown-linux-gnu |
> /usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/FileCheck
> /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp
>
> --
>
> Exit Code: 1
>
>
>
> Command Output (stderr):
>
> --
>
> /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp:8:11: error:
> expected string not found in input
>
> // CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
>
>   ^
>
> :1:1: note: scanning from here
>
> ; ModuleID =
> '/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp'
>
> ^
>
> :27:2: note: possible intended match here
>
>  %11 = load void ()*, void ()** @foo, align 8
>
>  ^
>
>
>
> --
>
>
>
>
>
>
>
> On Tue, Mar 29, 2016 at 1:44 PM, Betul Buyukkurt via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: betulb
> Date: Tue Mar 29 15:44:09 2016
> New Revision: 264783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264783=rev
> Log:
> [PGO] Move the instrumentation point closer to the value site.
>
> For terminator instructions, the value profiling instrumentation
> happens in a basic block other than where the value site resides.
> This CR moves the instrumentation point prior to the value site.
> Mostly NFC.
>
>
> Added:
> cfe/trunk/test/Profile/cxx-indirect-call.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> cfe/trunk/test/Profile/c-indirect-call.c
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783=264782=264783=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Mar 29 15:44:09 2016
> @@ -757,10 +757,10 @@ void CodeGenPGO::valueProfile(CGBuilderT
>
>bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
>if (InstrumentValueSites && RegionCounterMap) {
> -llvm::LLVMContext  = CGM.getLLVMContext();
> -auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
> +auto BuilderInsertPoint = Builder.saveIP();
> +Builder.SetInsertPoint(ValueSite);
>  llvm::Value *Args[5] = {
> -llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
> +llvm::ConstantExpr::getBitCast(FuncNameVar,
> Builder.getInt8PtrTy()),
>  Builder.getInt64(FunctionHash),
>  Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
>  Builder.getInt32(ValueKind),
> @@ -768,6 +768,7 @@ void CodeGenPGO::valueProfile(CGBuilderT
>  };
>  Builder.CreateCall(
>  CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
> +Builder.restoreIP(BuilderInsertPoint);
>  return;
>}
>
>
> Modified: cfe/trunk/test/Profile/c-indirect-call.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783=264782=264783=diff
>
> ==
> --- cfe/trunk/test/Profile/c-indirect-call.c (original)
> +++ cfe/trunk/test/Profile/c-indirect-call.c Tue Mar 29 15:44:09 2016
> @@ -1,13 +1,14 @@
> -// Check the data structures emitted by instrumentation.
> +// Check the value profiling instrinsics emitted by instrumentation.
> +
>  // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name
> c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm
> -enable-value-profiling | FileCheck %s
>
>  void (*foo)(void);
>
>  int main(void) {
>  // CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
> -// CHECK-NEXT:  call void [[REG1]]()
>  // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
>  // CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]],
> i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
> +// CHECK-NEXT:  call void [[REG1]]()
>foo();
>  

RE: r264783 - [PGO] Move the instrumentation point closer to the value site.

2016-03-29 Thread Betul Buyukkurt via cfe-commits
Hi Artem, 

 

I’ve uploaded a patch to remove the alignment. 

 

Thanks,

-Betul

 

From: Artem Belevich [mailto:t...@google.com] 
Sent: Tuesday, March 29, 2016 3:15 PM
To: Betul Buyukkurt 
Cc: cfe-commits 
Subject: Re: r264783 - [PGO] Move the instrumentation point closer to the value 
site.

 

Hi,

 

FYI, cxx-indirect-call.cpp test fails on platforms with different alignment. It 
may help to either use specific target or change your patterns to accommodate 
other targets.

 

--Artem

 

 TEST 'Clang :: Profile/cxx-indirect-call.cpp' FAILED 


Script:

--

/usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/clang 
--driver-mode=g++  
/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp -o - -emit-llvm 
-S -fprofile-instr-generate -mllvm -enable-value-profiling -fexceptions -target 
x86_64-unknown-linux-gnu | 
/usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/FileCheck 
/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp

--

Exit Code: 1

 

Command Output (stderr):

--

/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp:8:11: error: 
expected string not found in input

// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4

  ^

:1:1: note: scanning from here

; ModuleID = '/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp'

^

:27:2: note: possible intended match here

 %11 = load void ()*, void ()** @foo, align 8

 ^

 

--

 

 

 

On Tue, Mar 29, 2016 at 1:44 PM, Betul Buyukkurt via cfe-commits 
 > wrote:

Author: betulb
Date: Tue Mar 29 15:44:09 2016
New Revision: 264783

URL: http://llvm.org/viewvc/llvm-project?rev=264783 
 =rev
Log:
[PGO] Move the instrumentation point closer to the value site.

For terminator instructions, the value profiling instrumentation
happens in a basic block other than where the value site resides.
This CR moves the instrumentation point prior to the value site.
Mostly NFC.


Added:
cfe/trunk/test/Profile/cxx-indirect-call.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/test/Profile/c-indirect-call.c

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783
 

 =264782=264783=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Mar 29 15:44:09 2016
@@ -757,10 +757,10 @@ void CodeGenPGO::valueProfile(CGBuilderT

   bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
   if (InstrumentValueSites && RegionCounterMap) {
-llvm::LLVMContext  = CGM.getLLVMContext();
-auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
+auto BuilderInsertPoint = Builder.saveIP();
+Builder.SetInsertPoint(ValueSite);
 llvm::Value *Args[5] = {
-llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
 Builder.getInt64(FunctionHash),
 Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
 Builder.getInt32(ValueKind),
@@ -768,6 +768,7 @@ void CodeGenPGO::valueProfile(CGBuilderT
 };
 Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
+Builder.restoreIP(BuilderInsertPoint);
 return;
   }


Modified: cfe/trunk/test/Profile/c-indirect-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783
 

 =264782=264783=diff
==
--- cfe/trunk/test/Profile/c-indirect-call.c (original)
+++ cfe/trunk/test/Profile/c-indirect-call.c Tue Mar 29 15:44:09 2016
@@ -1,13 +1,14 @@
-// Check the data structures emitted by instrumentation.
+// Check the value profiling instrinsics emitted by instrumentation.
+
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling | FileCheck %s

 void (*foo)(void);

 int main(void) {
 // CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
-// CHECK-NEXT:  call void [[REG1]]()
 // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
 // CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT:  call void [[REG1]]()
   foo();
   return 0;
 }

Added: cfe/trunk/test/Profile/cxx-indirect-call.cpp
URL: 

r264795 - [PGO] Test case fix for r264783

2016-03-29 Thread Betul Buyukkurt via cfe-commits
Author: betulb
Date: Tue Mar 29 17:17:52 2016
New Revision: 264795

URL: http://llvm.org/viewvc/llvm-project?rev=264795=rev
Log:
[PGO] Test case fix for r264783 


Modified:
cfe/trunk/test/Profile/cxx-indirect-call.cpp

Modified: cfe/trunk/test/Profile/cxx-indirect-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=264795=264794=264795=diff
==
--- cfe/trunk/test/Profile/cxx-indirect-call.cpp (original)
+++ cfe/trunk/test/Profile/cxx-indirect-call.cpp Tue Mar 29 17:17:52 2016
@@ -5,7 +5,7 @@
 void (*foo) (void);
 
 int main(int argc, const char *argv[]) {
-// CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
+// CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo
 // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
 // CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({{.*}}* @__profd_main to i8*), i32 0)
 // CHECK-NEXT:  invoke void [[REG1]]()


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


Re: r264783 - [PGO] Move the instrumentation point closer to the value site.

2016-03-29 Thread Artem Belevich via cfe-commits
Hi,

FYI, cxx-indirect-call.cpp test fails on platforms with different
alignment. It may help to either use specific target or change your
patterns to accommodate other targets.

--Artem

 TEST 'Clang :: Profile/cxx-indirect-call.cpp' FAILED

Script:
--
/usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/clang
--driver-mode=g++
 /work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp -o -
-emit-llvm -S -fprofile-instr-generate -mllvm -enable-value-profiling
-fexceptions -target x86_64-unknown-linux-gnu |
/usr/local/google/home/tra/work/llvm/build/gpu/release/./bin/FileCheck
/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp
--
Exit Code: 1

Command Output (stderr):
--
/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp:8:11: error:
expected string not found in input
// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
  ^
:1:1: note: scanning from here
; ModuleID = '/work/tra/llvm/tools/clang/test/Profile/cxx-indirect-call.cpp'
^
:27:2: note: possible intended match here
 %11 = load void ()*, void ()** @foo, align 8
 ^

--



On Tue, Mar 29, 2016 at 1:44 PM, Betul Buyukkurt via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: betulb
> Date: Tue Mar 29 15:44:09 2016
> New Revision: 264783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264783=rev
> Log:
> [PGO] Move the instrumentation point closer to the value site.
>
> For terminator instructions, the value profiling instrumentation
> happens in a basic block other than where the value site resides.
> This CR moves the instrumentation point prior to the value site.
> Mostly NFC.
>
>
> Added:
> cfe/trunk/test/Profile/cxx-indirect-call.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> cfe/trunk/test/Profile/c-indirect-call.c
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783=264782=264783=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Mar 29 15:44:09 2016
> @@ -757,10 +757,10 @@ void CodeGenPGO::valueProfile(CGBuilderT
>
>bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
>if (InstrumentValueSites && RegionCounterMap) {
> -llvm::LLVMContext  = CGM.getLLVMContext();
> -auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
> +auto BuilderInsertPoint = Builder.saveIP();
> +Builder.SetInsertPoint(ValueSite);
>  llvm::Value *Args[5] = {
> -llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
> +llvm::ConstantExpr::getBitCast(FuncNameVar,
> Builder.getInt8PtrTy()),
>  Builder.getInt64(FunctionHash),
>  Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
>  Builder.getInt32(ValueKind),
> @@ -768,6 +768,7 @@ void CodeGenPGO::valueProfile(CGBuilderT
>  };
>  Builder.CreateCall(
>  CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
> +Builder.restoreIP(BuilderInsertPoint);
>  return;
>}
>
>
> Modified: cfe/trunk/test/Profile/c-indirect-call.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783=264782=264783=diff
>
> ==
> --- cfe/trunk/test/Profile/c-indirect-call.c (original)
> +++ cfe/trunk/test/Profile/c-indirect-call.c Tue Mar 29 15:44:09 2016
> @@ -1,13 +1,14 @@
> -// Check the data structures emitted by instrumentation.
> +// Check the value profiling instrinsics emitted by instrumentation.
> +
>  // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name
> c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm
> -enable-value-profiling | FileCheck %s
>
>  void (*foo)(void);
>
>  int main(void) {
>  // CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
> -// CHECK-NEXT:  call void [[REG1]]()
>  // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
>  // CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]],
> i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
> +// CHECK-NEXT:  call void [[REG1]]()
>foo();
>return 0;
>  }
>
> Added: cfe/trunk/test/Profile/cxx-indirect-call.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=264783=auto
>
> ==
> --- cfe/trunk/test/Profile/cxx-indirect-call.cpp (added)
> +++ cfe/trunk/test/Profile/cxx-indirect-call.cpp Tue Mar 29 15:44:09 2016
> @@ -0,0 +1,21 @@
> +// Check the value profiling instrinsics emitted by instrumentation.
> +
> +// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -mllvm
> -enable-value-profiling -fexceptions -target %itanium_abi_triple |
> FileCheck %s
> +
> +void (*foo) (void);
> +
> 

Re: [PATCH] D18539: [CUDA] Add math forward declares.

2016-03-29 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51988.
jlebar added a comment.

Fix typo in wrapper header.  (How did this ever work??)


http://reviews.llvm.org/D18539

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/__clang_cuda_runtime_wrapper.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -42,6 +42,9 @@
 
 #if defined(__CUDA__) && defined(__clang__)
 
+// Include some forward declares that must come before cmath.
+#include <__clang_cuda_runtime_wrapper.h>
+
 // Include some standard headers to avoid CUDA headers including them
 // while some required macros (like __THROW) are in a weird state.
 #include 
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- /dev/null
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -0,0 +1,191 @@
+/*=== __clang_cuda_cmath.h - Device-side CUDA cmath support ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
+#define __CLANG__CUDA_MATH_FORWARD_DECLARES_H__
+#ifndef __CUDA__
+#error "This file is for CUDA compilation only."
+#endif
+
+// This file forward-declares of some math functions we (or the CUDA headers)
+// will define later.  We need to do this, and do it before cmath is included,
+// because the standard library may have constexpr math functions.  In the
+// absence of a prior __device__ decl, those constexpr functions may become
+// implicitly host+device.  host+device functions can't be overloaded, so that
+// would preclude the use of our own __device__ overloads for these functions.
+
+#pragma push_macro("__DEVICE__")
+#define __DEVICE__ \
+  static __inline__ __attribute__((always_inline)) __attribute__((device))
+
+__DEVICE__ int abs(int);
+__DEVICE__ double acos(double);
+__DEVICE__ float acosh(float);
+__DEVICE__ double acosh(double);
+__DEVICE__ double asin(double);
+__DEVICE__ float asinh(float);
+__DEVICE__ double asinh(double);
+__DEVICE__ double atan(double);
+__DEVICE__ double atan2(double, double);
+__DEVICE__ float atanh(float);
+__DEVICE__ double atanh(double);
+__DEVICE__ float cbrt(float);
+__DEVICE__ double cbrt(double);
+__DEVICE__ double ceil(double);
+__DEVICE__ float copysign(float, float);
+__DEVICE__ double copysign(double, double);
+__DEVICE__ double cos(double);
+__DEVICE__ double cosh(double);
+__DEVICE__ float erf(float);
+__DEVICE__ double erf(double);
+__DEVICE__ float erfc(float);
+__DEVICE__ double erfc(double);
+__DEVICE__ double exp(double);
+__DEVICE__ float exp2(float);
+__DEVICE__ double exp2(double);
+__DEVICE__ float expm1(float);
+__DEVICE__ double expm1(double);
+__DEVICE__ double fabs(double);
+__DEVICE__ float fdim(float, float);
+__DEVICE__ double fdim(double, double);
+__DEVICE__ double floor(double);
+__DEVICE__ float fma(float, float, float);
+__DEVICE__ double fma(double, double, double);
+__DEVICE__ float fmax(float, float);
+__DEVICE__ double fmax(double, double);
+__DEVICE__ float fmin(float, float);
+__DEVICE__ double fmin(double, double);
+__DEVICE__ double fmod(double, double);
+__DEVICE__ double frexp(double, int *);
+__DEVICE__ float hypot(float, float);
+__DEVICE__ double hypot(double, double);
+__DEVICE__ int ilogb(float);
+__DEVICE__ int ilogb(double);
+__DEVICE__ long labs(long);
+__DEVICE__ double ldexp(double, int);
+__DEVICE__ float lgamma(float);
+__DEVICE__ double lgamma(double);
+__DEVICE__ long long llabs(long long);
+__DEVICE__ long long llrint(float);
+__DEVICE__ long long llrint(double);
+__DEVICE__ double log(double);
+__DEVICE__ double log10(double);
+__DEVICE__ 

r264788 - [Sema] Attempt [3] to fix tests for utf-8 invalid format string specifiers

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 29 16:30:58 2016
New Revision: 264788

URL: http://llvm.org/viewvc/llvm-project?rev=264788=rev
Log:
[Sema] Attempt [3] to fix tests for utf-8 invalid format string specifiers

Make the tests darwin only. The bots complaining already output UTF-8
invalid specifiers, test the output as we expect on darwin systems.

Modified:
cfe/trunk/test/SemaObjC/format-strings-utf8.m

Modified: cfe/trunk/test/SemaObjC/format-strings-utf8.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-utf8.m?rev=264788=264787=264788=diff
==
--- cfe/trunk/test/SemaObjC/format-strings-utf8.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-utf8.m Tue Mar 29 16:30:58 2016
@@ -1,3 +1,4 @@
+// REQUIRES: system-darwin
 // RUN: rm -f %t.log
 // RUN: env RC_DEBUG_OPTIONS=1 \
 // RUN: CC_LOG_DIAGNOSTICS=1 CC_LOG_DIAGNOSTICS_FILE=%t.log \


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


r264787 - Enable the SafeStack sanitizer on CloudABI by default.

2016-03-29 Thread Ed Schouten via cfe-commits
Author: ed
Date: Tue Mar 29 16:13:53 2016
New Revision: 264787

URL: http://llvm.org/viewvc/llvm-project?rev=264787=rev
Log:
Enable the SafeStack sanitizer on CloudABI by default.

Over the last month we've been testing SafeStack extensively. As far as
we know, it works perfectly fine. That why I'd like to see us having
this enabled by default for CloudABI.

This change introduces a getDefaultSanitizers() function that toolchains
can use to specify which sanitizers are enabled by default. Once all
flags are processed, only flags that had no -fno-sanitize overrides are
enabled.

Extend the thests for CloudABI to test both the default case and the
case in which we want to explicitly disable SafeStack.

Reviewed by:eugenis, pcc
Differential Revision:  http://reviews.llvm.org/D18505

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/cloudabi.c
cfe/trunk/test/Driver/cloudabi.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=264787=264786=264787=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Mar 29 16:13:53 2016
@@ -419,6 +419,9 @@ public:
 
   /// \brief Return sanitizers which are available in this toolchain.
   virtual SanitizerMask getSupportedSanitizers() const;
+
+  /// \brief Return sanitizers which are enabled by default.
+  virtual SanitizerMask getDefaultSanitizers() const { return 0; }
 };
 
 } // end namespace driver

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=264787=264786=264787=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue Mar 29 16:13:53 2016
@@ -268,6 +268,9 @@ SanitizerArgs::SanitizerArgs(const ToolC
 }
   }
 
+  // Enable toolchain specific default sanitizers if not explicitly disabled.
+  Kinds |= TC.getDefaultSanitizers() & ~AllRemove;
+
   // We disable the vptr sanitizer if it was enabled by group expansion but 
RTTI
   // is disabled.
   if ((Kinds & Vptr) &&

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=264787=264786=264787=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Mar 29 16:13:53 2016
@@ -2988,6 +2988,10 @@ SanitizerMask CloudABI::getSupportedSani
   return Res;
 }
 
+SanitizerMask CloudABI::getDefaultSanitizers() const {
+  return SanitizerKind::SafeStack;
+}
+
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
 OpenBSD::OpenBSD(const Driver , const llvm::Triple ,

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=264787=264786=264787=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Mar 29 16:13:53 2016
@@ -620,6 +620,7 @@ public:
   bool isPIEDefault() const override { return false; }
 
   SanitizerMask getSupportedSanitizers() const override;
+  SanitizerMask getDefaultSanitizers() const override;
 
 protected:
   Tool *buildLinker() const override;

Modified: cfe/trunk/test/Driver/cloudabi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cloudabi.c?rev=264787=264786=264787=diff
==
--- cfe/trunk/test/Driver/cloudabi.c (original)
+++ cfe/trunk/test/Driver/cloudabi.c Tue Mar 29 16:13:53 2016
@@ -1,3 +1,8 @@
-// RUN: %clang %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s
-// CHECK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} 
"-ffunction-sections" "-fdata-sections"
-// CHECK: "-Bstatic" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" 
"crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o"
+// RUN: %clang %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s 
-check-prefix=SAFESTACK
+// SAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} 
"-ffunction-sections" "-fdata-sections" {{.*}} "-fsanitize=safe-stack"
+// SAFESTACK: "-Bstatic" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" 
"crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o"
+
+// RUN: %clang %s -### -target x86_64-unknown-cloudabi 
-fno-sanitize=safe-stack 2>&1 | FileCheck %s -check-prefix=NOSAFESTACK
+// NOSAFESTACK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} 
"-ffunction-sections" 

Re: [PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

2016-03-29 Thread Manman Ren via cfe-commits
manmanren added a comment.

Cheers,
Manman



Comment at: lib/Sema/SemaType.cpp:1569
@@ +1568,3 @@
+// Mark them as invalid.
+attr.setInvalid();
+  }

rjmccall wrote:
> It's not generally a good idea to set things as invalid if you're just 
> emitting a warning.  It might be different for parsed AttributeList objects, 
> but... I'm not sure about that.
Here we mark the AttributeList as invalid so when we call processTypeAttrs 
later, we will ignore these attributes, instead of creating AttributedType 
based on DependentTy for omitted block return type.


Comment at: lib/Sema/SemaType.cpp:1609
@@ +1608,3 @@
+// Warn if we see type qualifiers for omitted return type on a block 
literal.
+if (TypeQuals && isOmittedBlockReturnType(declarator)) {
+  diagnoseAndRemoveTypeQualifiers(S, DS, TypeQuals, Result,

rjmccall wrote:
> Checking TypeQuals again here is redundant.
You are right, I was following the code below this.


Comment at: lib/Sema/SemaType.cpp:1611
@@ +1610,3 @@
+  diagnoseAndRemoveTypeQualifiers(S, DS, TypeQuals, Result,
+  DeclSpec::TQ_const | DeclSpec::TQ_volatile | DeclSpec::TQ_atomic,
+  diag::warn_block_literal_qualifiers_on_omitted_return_type);

rjmccall wrote:
> You're missing at least TQ_restrict.  But why make this an enumerated list at 
> all?
I was trying to reuse diagnoseAndRemoveTypeQualifiers and didn't notice that it 
does not cover all the qualifiers.
I will rewrite this to not use diagnoseAndRemoveTypeQualifiers.


http://reviews.llvm.org/D18567



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


[PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-03-29 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: alexfh.
hintonda added a subscriber: cfe-commits.

This checker allows users to replace deprecated throw()
specifications with noexcept.

It also allows users to replace an arbitrary list of macros with
either noexcept or a user defined macro -- which is useful when
supporting older compilers.

http://reviews.llvm.org/D18575

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

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.CandidateStrings, value: 'NOTHROW,,,'}]}" \
+// RUN:   -- -std=c++11
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo': replacing noexcept specification 'throw()' with 'noexcept' [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar': replacing noexcept specification 'throw()' with 'noexcept' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept {}
+
+#define NOTHROW throw()
+void foobar() NOTHROW {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foobar': replacing noexcept specification 'NOTHROW' with 'noexcept' [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept {}
Index: test/clang-tidy/modernize-use-noexcept-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept-macro.cpp
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.CandidateStrings, value: ' NOTHROW , , ,'}, \
+// RUN:{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
+// RUN:   -- -std=c++11
+
+#define NOEXCEPT noexcept
+
+void foo() noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo': replacing noexcept specification 'noexcept(true)' with 'NOEXCEPT' [modernize-use-noexcept]
+// CHECK-FIXES: void foo() NOEXCEPT;
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar': replacing noexcept specification 'throw()' with 'NOEXCEPT' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() NOEXCEPT {}
+
+#define NOTHROW throw()
+void foobar() NOTHROW {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foobar': replacing noexcept specification 'NOTHROW' with 'NOEXCEPT' [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() NOEXCEPT {}
Index: docs/clang-tidy/checks/modernize-use-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-noexcept.rst
@@ -0,0 +1,51 @@
+.. title:: clang-tidy - modernize-use-noexcept
+
+modernize-use-noexcept
+==
+
+The check converts exception specifications, e.g., throw(), to either
+noexcept, or a user defined macro.
+
+Example
+---
+
+.. code-block:: c++
+
+  void foo() throw();
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() noexcept;
+
+
+User defined macros
+---
+
+By default this check will only replace the ``throw()`` and
+``noexcept(true)`` with ``noexcept``.  However, the user can use
+:option:``CandidateStrings" to specify a comma-separated list of macro
+names that will be transformed along with ``throw()`` and
+``noexcept(true)``.
+
+Users can also use :option:``ReplacementString`` to specify a macro to
+use instead of ``noexcept``.  This is useful when maintaining source
+code that must compile on older compilers that don't support the
+``noexcept`` keyword.
+
+Example
+^^^
+
+.. code-block:: c++
+
+  void foo() NOTHROW {}
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() NOEXCEPT {}
+
+if the ``CandidateStrings`` option is set to ``NOTHROW``, and the
+``ReplacementString`` option is set to ``NOEXCEPT``.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -83,6 +83,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-default
+   modernize-use-noexcept
modernize-use-nullptr
modernize-use-override
performance-faster-string-find
Index: clang-tidy/modernize/UseNoexceptCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/UseNoexceptCheck.h
@@ -0,0 +1,49 @@
+//===--- UseNoexceptCheck.h - 

r264783 - [PGO] Move the instrumentation point closer to the value site.

2016-03-29 Thread Betul Buyukkurt via cfe-commits
Author: betulb
Date: Tue Mar 29 15:44:09 2016
New Revision: 264783

URL: http://llvm.org/viewvc/llvm-project?rev=264783=rev
Log:
[PGO] Move the instrumentation point closer to the value site.

For terminator instructions, the value profiling instrumentation
happens in a basic block other than where the value site resides.
This CR moves the instrumentation point prior to the value site.
Mostly NFC.


Added:
cfe/trunk/test/Profile/cxx-indirect-call.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
cfe/trunk/test/Profile/c-indirect-call.c

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=264783=264782=264783=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Mar 29 15:44:09 2016
@@ -757,10 +757,10 @@ void CodeGenPGO::valueProfile(CGBuilderT
 
   bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
   if (InstrumentValueSites && RegionCounterMap) {
-llvm::LLVMContext  = CGM.getLLVMContext();
-auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
+auto BuilderInsertPoint = Builder.saveIP();
+Builder.SetInsertPoint(ValueSite);
 llvm::Value *Args[5] = {
-llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
 Builder.getInt64(FunctionHash),
 Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
 Builder.getInt32(ValueKind),
@@ -768,6 +768,7 @@ void CodeGenPGO::valueProfile(CGBuilderT
 };
 Builder.CreateCall(
 CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
+Builder.restoreIP(BuilderInsertPoint);
 return;
   }
 

Modified: cfe/trunk/test/Profile/c-indirect-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-indirect-call.c?rev=264783=264782=264783=diff
==
--- cfe/trunk/test/Profile/c-indirect-call.c (original)
+++ cfe/trunk/test/Profile/c-indirect-call.c Tue Mar 29 15:44:09 2016
@@ -1,13 +1,14 @@
-// Check the data structures emitted by instrumentation.
+// Check the value profiling instrinsics emitted by instrumentation.
+
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling | FileCheck %s
 
 void (*foo)(void);
 
 int main(void) {
 // CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
-// CHECK-NEXT:  call void [[REG1]]()
 // CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
 // CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT:  call void [[REG1]]()
   foo();
   return 0;
 }

Added: cfe/trunk/test/Profile/cxx-indirect-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=264783=auto
==
--- cfe/trunk/test/Profile/cxx-indirect-call.cpp (added)
+++ cfe/trunk/test/Profile/cxx-indirect-call.cpp Tue Mar 29 15:44:09 2016
@@ -0,0 +1,21 @@
+// Check the value profiling instrinsics emitted by instrumentation.
+
+// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -mllvm 
-enable-value-profiling -fexceptions -target %itanium_abi_triple | FileCheck %s
+
+void (*foo) (void);
+
+int main(int argc, const char *argv[]) {
+// CHECK:  [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
+// CHECK-NEXT:  [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
+// CHECK-NEXT:  call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* 
bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT:  invoke void [[REG1]]()
+  try {
+foo();
+  } catch (int) {}
+  return 0;
+}
+
+// CHECK: declare void @__llvm_profile_instrument_target(i64, i8*, i32)
+
+
+


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


Re: [PATCH] D17861: [OpenCL] Accept __attribute__((nosvm))

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

LGTM, thank you!


http://reviews.llvm.org/D17861



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


Re: [PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

2016-03-29 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaType.cpp:1569
@@ +1568,3 @@
+// Mark them as invalid.
+attr.setInvalid();
+  }

It's not generally a good idea to set things as invalid if you're just emitting 
a warning.  It might be different for parsed AttributeList objects, but... I'm 
not sure about that.


Comment at: lib/Sema/SemaType.cpp:1609
@@ +1608,3 @@
+// Warn if we see type qualifiers for omitted return type on a block 
literal.
+if (TypeQuals && isOmittedBlockReturnType(declarator)) {
+  diagnoseAndRemoveTypeQualifiers(S, DS, TypeQuals, Result,

Checking TypeQuals again here is redundant.


Comment at: lib/Sema/SemaType.cpp:1611
@@ +1610,3 @@
+  diagnoseAndRemoveTypeQualifiers(S, DS, TypeQuals, Result,
+  DeclSpec::TQ_const | DeclSpec::TQ_volatile | DeclSpec::TQ_atomic,
+  diag::warn_block_literal_qualifiers_on_omitted_return_type);

You're missing at least TQ_restrict.  But why make this an enumerated list at 
all?


http://reviews.llvm.org/D18567



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


Re: [PATCH] D18457: [clang-tidy] Add a new checker to detect missing comma in initializer list.

2016-03-29 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:42
@@ +41,3 @@
+  const auto *ConcatenatedLiteral = Result.Nodes.getNodeAs("str");
+  if (InitializerList && ConcatenatedLiteral) {
+// Skip small arrays as they often generate false-positive.

alexfh wrote:
> An early return would be better here.
moved to an assert.
It should never be false.


http://reviews.llvm.org/D18457



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


Re: [PATCH] D18457: [clang-tidy] Add a new checker to detect missing comma in initializer list.

2016-03-29 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51969.
etienneb marked 5 inline comments as done.
etienneb added a comment.

address alexfh@ comments.


http://reviews.llvm.org/D18457

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
  clang-tidy/misc/SuspiciousMissingCommaCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  test/clang-tidy/misc-suspicious-missing-comma.cpp

Index: test/clang-tidy/misc-suspicious-missing-comma.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-missing-comma.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s misc-suspicious-missing-comma %t
+
+const char* Cartoons[] = {
+  "Bugs Bunny",
+  "Homer Simpson",
+  "Mickey Mouse",
+  "Bart Simpson",
+  "Charlie Brown"  // There is a missing comma here.
+  "Fred Flintstone",
+  "Popeye",
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: suspicious string literal, probably missing a comma [misc-suspicious-missing-comma]
+
+const wchar_t* Colors[] = {
+  L"Red", L"Yellow", L"Blue", L"Green", L"Purple", L"Rose", L"White", L"Black"
+};
+
+// The following array should not trigger any warnings.
+const char* HttpCommands[] = {
+  "GET / HTTP/1.0\r\n"
+  "\r\n",
+
+  "GET /index.html HTTP/1.0\r\n"
+  "\r\n",
+
+  "GET /favicon.ico HTTP/1.0\r\n"
+  "header: dummy"
+  "\r\n",
+};
+
+// This array is too small to trigger a warning.
+const char* SmallArray[] = {
+  "a" "b", "c"
+};
Index: docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - misc-suspicious-missing-comma
+
+misc-suspicious-missing-comma
+=
+
+String literals placed side-by-side are concatenated at translation phase 6
+(after the preprocessor). This feature is used to represent long string
+literal on multiple lines.
+
+For instance, these declarations are equivalent:
+  const char* A[] = "This is a test";
+  const char* B[] = "This" " is a "
+"test";
+
+A common mistake done by programmers is to forget a comma between two string
+literals in an array initializer list.
+
+  const char* Test[] = {
+"line 1",
+"line 2" // Missing comma!
+"line 3",
+"line 4",
+"line 5"
+  };
+
+The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
+won't generate warnings at compile time.
+
+This checker may warn incorrectly on cases like:
+
+  const char* SupportedFormat[] = {
+"Error %s",
+"Code " PRIu64,   // May warn here.
+"Warning %s",
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -65,6 +65,7 @@
misc-sizeof-container
misc-static-assert
misc-string-integer-assignment
+   misc-suspicious-missing-comma
misc-suspicious-semicolon
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
Index: clang-tidy/misc/SuspiciousMissingCommaCheck.h
===
--- /dev/null
+++ clang-tidy/misc/SuspiciousMissingCommaCheck.h
@@ -0,0 +1,39 @@
+//===--- SuspiciousMissingCommaCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_MISSING_COMMA_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_MISSING_COMMA_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// This check finds string literals which are probably concatenated accidentally.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-missing-comma.html
+class SuspiciousMissingCommaCheck : public ClangTidyCheck {
+public:
+  SuspiciousMissingCommaCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;  
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  const unsigned SizeThreshold;
+  const unsigned RatioThreshold;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SUSPICIOUS_MISSING_COMMA_H
Index: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
@@ -0,0 +1,80 @@

Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-29 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Ping. Tom, are you OK with this fix?


http://reviews.llvm.org/D17552



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


Re: [PATCH] D17861: [OpenCL] Accept __attribute__((nosvm))

2016-03-29 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 51967.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Revised as Aaron suggested.


http://reviews.llvm.org/D17861

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/SemaOpenCL/nosvm.cl

Index: test/SemaOpenCL/nosvm.cl
===
--- /dev/null
+++ test/SemaOpenCL/nosvm.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -x c -D NOCL %s
+
+#ifndef NOCL
+kernel void f(__attribute__((nosvm)) global int* a);
+#ifndef CL20
+// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+#else
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+#endif
+__attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
+
+#else
+void f(__attribute__((nosvm)) int* a); // expected-warning {{'nosvm' attribute ignored}}
+#endif
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -221,7 +221,7 @@
 
   if (S.getLangOpts().OpenCLVersion < 200) {
 S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version)
-<< A.getName() << "2.0";
+<< A.getName() << "2.0" << 1;
 return nullptr;
   }
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5206,6 +5206,15 @@
 D->addAttr(Internal);
 }
 
+static void handleOpenCLNoSVMAttr(Sema , Decl *D, const AttributeList ) {
+  if (S.LangOpts.OpenCLVersion != 200)
+S.Diag(Attr.getLoc(), diag::err_attribute_requires_opencl_version)
+<< Attr.getName() << "2.0" << 0;
+  else
+S.Diag(Attr.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
+<< Attr.getName() << "2.0";
+}
+
 /// Handles semantic checking for features that are common to all attributes,
 /// such as checking whether a parameter was properly specified, or the correct
 /// number of arguments were passed, etc.
@@ -5698,6 +5707,9 @@
   case AttributeList::AT_SwiftIndirectResult:
 handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftIndirectResult);
 break;
+  case AttributeList::AT_OpenCLNoSVM:
+handleOpenCLNoSVMAttr(S, D, Attr);
+break;
   case AttributeList::AT_InternalLinkage:
 handleInternalLinkageAttr(S, D, Attr);
 break;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2129,7 +2129,7 @@
 def err_attribute_requires_positive_integer : Error<
   "%0 attribute requires a positive integral compile time constant expression">;
 def err_attribute_requires_opencl_version : Error<
-  "%0 attribute requires OpenCL version %1 or above">;
+  "%0 attribute requires OpenCL version %1%select{| or above}2">;
 def warn_unsupported_target_attribute
 : Warning<"Ignoring unsupported '%0' in the target attribute string">,
 InGroup;
@@ -7769,6 +7769,9 @@
   "pointer to type %0 is invalid in OpenCL">;
 def err_opencl_type_can_only_be_used_as_function_parameter : Error <
   "type %0 can only be used as a function parameter in OpenCL">;
+def warn_opencl_attr_deprecated_ignored : Warning <
+  "%0 attribute is deprecated and ignored in OpenCL version %1">,
+  InGroup;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1745,6 +1745,17 @@
   }];
 }
 
+def OpenCLNoSVMDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+OpenCL 2.0 supports the optional ``__attribute__((nosvm))`` qualifier for
+pointer variable. It informs the compiler that the pointer does not refer
+to a shared virtual memory region. See OpenCL v2.0 s6.7.2 for details.
+
+Since it is not widely used and has been removed from OpenCL 2.1, it is ignored
+by Clang.
+  }];
+}
 def NullabilityDocs : DocumentationCategory<"Nullability Attributes"> {
   let Content = [{
 Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, 

r264774 - clang-cl: Silently ignore /d2FastFail flag.

2016-03-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Mar 29 14:41:02 2016
New Revision: 264774

URL: http://llvm.org/viewvc/llvm-project?rev=264774=rev
Log:
clang-cl: Silently ignore /d2FastFail flag.

It's some debugging flag for cl.exe related to how it writes crash dumps.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=264774=264773=264774=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Mar 29 14:41:02 2016
@@ -270,6 +270,7 @@ def _SLASH_Fp : CLJoined<"Fp">,
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
 def _SLASH_bigobj : CLIgnoredFlag<"bigobj">;
 def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">;
+def _SLASH_d2FastFail : CLIgnoredFlag<"d2FastFail">;
 def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
 def _SLASH_Fd : CLIgnoredJoined<"Fd">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=264774=264773=264774=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Mar 29 14:41:02 2016
@@ -247,6 +247,7 @@
 // RUN:/bigobj \
 // RUN:/cgthreads4 \
 // RUN:/cgthreads8 \
+// RUN:/d2FastFail \
 // RUN:/d2Zi+ \
 // RUN:/errorReport:foo \
 // RUN:/FC \


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


Re: [PATCH] D18457: [clang-tidy] Add a new checker to detect missing comma in initializer list.

2016-03-29 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:42
@@ +41,3 @@
+  const auto *ConcatenatedLiteral = Result.Nodes.getNodeAs("str");
+  if (InitializerList && ConcatenatedLiteral) {
+// Skip small arrays as they often generate false-positive.

An early return would be better here.


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:45
@@ +44,3 @@
+unsigned int Size = InitializerList->getNumInits();
+if (Size < 5)
+  return;

Should this threshold be an option (or at least a named constant)?


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:52
@@ +51,3 @@
+  const Expr* Child = InitializerList->getInit(i)->IgnoreImpCasts();
+  if (const StringLiteral* Literal = dyn_cast(Child)) {
+if (Literal->getNumConcatenated() > 1)

`const auto *Literal = ...`


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:60
@@ +59,3 @@
+// The current threshold is set to less than 1/5 of the string literals.
+if ((5 * Count)/Size > 1)
+  return;

Should this threshold be an option (or at least a named constant)?


Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:63
@@ +62,3 @@
+
+diag(ConcatenatedLiteral->getLocStart(), "Suspicious string literal. 
Probably missing a comma.");
+  }

No capitalization and trailing periods, please.

Please also clang-format this file.


http://reviews.llvm.org/D18457



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


Re: [PATCH] D18565: Implement an "I'm dtrace, please retain all debug types" option.

2016-03-29 Thread Adrian Prantl via cfe-commits

> On Mar 29, 2016, at 12:00 PM, Joerg Sonnenberger  
> wrote:
> 
> On Tue, Mar 29, 2016 at 06:47:24PM +, Adrian Prantl via cfe-commits wrote:
>> This code in this patch listens to the driver option -gfull, and lowers it 
>> to the new cc1 option -debug-retain-types (1).
>> When -debug-retain-types is present, CGDebugInfo will retain every(2) type 
>> it creates.
> 
> Is there a good reason for calling it -gfull? I would find something
> -gall-types or -gretain-all-types to make a lot more sense. This should
> be orthogonal to other options like providing only line tables?

My thinking was this:
The driver already supports -gfull, but it doesn’t do anything.
This patch can be considered a first step towards making -gfull behave as 
expected.
Eventually it should emit debug info for *all* types.

> Joerg
> 
> PS: Slightly related side question, do we have any tools for extracting
> a given list of types for retaining? Either by name or global variable
> expression.

Extract them from where? Can you give an example?

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


Re: [PATCH] D18565: Implement an "I'm dtrace, please retain all debug types" option.

2016-03-29 Thread Joerg Sonnenberger via cfe-commits
On Tue, Mar 29, 2016 at 06:47:24PM +, Adrian Prantl via cfe-commits wrote:
> This code in this patch listens to the driver option -gfull, and lowers it to 
> the new cc1 option -debug-retain-types (1).
> When -debug-retain-types is present, CGDebugInfo will retain every(2) type it 
> creates.

Is there a good reason for calling it -gfull? I would find something
-gall-types or -gretain-all-types to make a lot more sense. This should
be orthogonal to other options like providing only line tables?

Joerg

PS: Slightly related side question, do we have any tools for extracting
a given list of types for retaining? Either by name or global variable
expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18380: [CUDA] Make unattributed constexpr functions (usually) implicitly host+device.

2016-03-29 Thread Artem Belevich via cfe-commits
tra added a comment.

LGTM.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18475: [clang-tidy] Add more detection rules for redundant c_str calls.

2016-03-29 Thread Etienne Bergeron via cfe-commits
etienneb marked an inline comment as done.
etienneb added a comment.

I'll to try to make a better way to describe redundant cases (as proposed by 
sbenza@) with an array.
I like the array based approach, it's lean and clean.

I'll try to make a prototype of the generic overloaded functions matcher and 
I'll look at the ratio of false-positive.
It may be gated under a configuration to avoid reporting these false-positives.

Afterward, we can take decision of what/how should this be integrated.


http://reviews.llvm.org/D18475



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


[PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

2016-03-29 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: rjmccall, Anastasia.
manmanren added a subscriber: cfe-commits.

A simple example will crash at IRGen:
void (^simpleBlock)() = ^ _Nonnull {
  return;
};

The Return type for the block will be AttributedType of a DependentTy and it 
will not be resolved. We will get a crash at IRGen.
The fix is to warn when we have type attributes or qualifiers with omitted 
return type. The type attributes and qualifiers will be ignored.
This breaks test/SemaOpenCL/invalid-block.cl where it uses "^const(){}".
"int (^const bl3)() = ^const(){};" should emit error since we are converting 
between incompatible block pointer types, the block literal's return type 
should be void. 

http://reviews.llvm.org/D18567

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaType.cpp
  test/SemaObjC/block-omitted-return-type.m
  test/SemaOpenCL/invalid-block.cl

Index: test/SemaObjC/block-omitted-return-type.m
===
--- /dev/null
+++ test/SemaObjC/block-omitted-return-type.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -fblocks -verify -fsyntax-only
+
+@interface NSObject
+@end
+
+@interface Test : NSObject
+- (void)test;
+@end
+
+@implementation Test
+- (void)test
+{
+  void (^simpleBlock)() = ^ _Nonnull { //expected-warning {{attribute '_Nonnull' ignored, because it cannot be applied to omitted return type}}
+return;
+  };
+  void (^simpleBlock2)() = ^ _Nonnull void { //expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'void'}}
+return;
+  };
+  void (^simpleBlock3)() = ^ _Nonnull (void) {  //expected-warning {{attribute '_Nonnull' ignored, because it cannot be applied to omitted return type}}
+return;
+  };
+
+  void (^simpleBlock4)() = ^ const { //expected-warning {{'const' qualifier on omitted return type '' has no effect}}
+return;
+  };
+  void (^simpleBlock5)() = ^ const void { //expected-error {{incompatible block pointer types initializing 'void (^)()' with an expression of type 'const void (^)(void)'}}
+return;
+  };
+  void (^simpleBlock6)() = ^ const (void) { //expected-warning {{'const' qualifier on omitted return type '' has no effect}}
+return;
+  };
+}
+@end
Index: test/SemaOpenCL/invalid-block.cl
===
--- test/SemaOpenCL/invalid-block.cl
+++ test/SemaOpenCL/invalid-block.cl
@@ -6,14 +6,14 @@
 void f1() {
   int (^bl1)() = ^() {}; // expected-error{{invalid block variable declaration - must be const qualified}}
   int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
-  int (^const bl3)() = ^const(){
+  int (^const bl3)() = ^(){ // expected-error{{incompatible block pointer types initializing 'int (^const)()' with an expression of type 'void (^)(void)'}}
   };
 }
 
 // A block with extern storage class is not allowed.
-extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+extern int (^const bl)() = ^(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
 void f2() {
-  extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+  extern int (^const bl)() = ^(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
 }
 
 // A block cannot be the return value of a function.
@@ -36,15 +36,15 @@
 // A block can't be used to declare an array
 typedef int (^const bl1_t)(int);
 void f5(int i) {
-  bl1_t bl1 = ^const(int i) {return 1;};
-  bl1_t bl2 = ^const(int i) {return 2;};
+  bl1_t bl1 = ^(int i) {return 1;};
+  bl1_t bl2 = ^(int i) {return 2;};
   bl1_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl1_t' (aka 'int (^const)(int)') type is invalid in OpenCL}}
   int tmp = i ? bl1(i)  // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
   : bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
 }
 
 void f6(bl1_t * bl_ptr) {
-  bl1_t bl = ^const(int i) {return 1;};
+  bl1_t bl = ^(int i) {return 1;};
   bl1_t *p =  // expected-error {{invalid argument type 'bl1_t' (aka 'int (^const)(int)') to unary expression}}
   bl = *bl_ptr;  // expected-error {{dereferencing pointer of type '__generic bl1_t *' (aka 'int (^const __generic *)(int)') is not allowed in OpenCL}}
 }
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1552,6 +1552,25 @@
 break;
   }
 
+  // Warn if we see type attributes for omitted return type on a block literal.
+  if (isOmittedBlockReturnType(declarator)) {
+if (auto *attrs = DS.getAttributes().getList()) {
+  while (attrs) {

[PATCH] D18565: Implement an "I'm dtrace, please retain all debug types" option.

2016-03-29 Thread Adrian Prantl via cfe-commits
aprantl created this revision.
aprantl added reviewers: dblaikie, dexonsmith.
aprantl added a subscriber: cfe-commits.
aprantl set the repository for this revision to rL LLVM.

As noted in the review thread for http://reviews.llvm.org/D18477 on 
llvm-commits, DWARF consumers such as dtrace's ctfconvert expect debug info for 
types to survive even if the underlying code that references those types has 
been optimized away.
This patch moves this logic from the backend, where it used to be 
unconditionally executed, into clang. For more info on this functionality check 
out DwarfDebug::collectDeadVariables(), added in r107027.

This code in this patch listens to the driver option -gfull, and lowers it to 
the new cc1 option -debug-retain-types (1).
When -debug-retain-types is present, CGDebugInfo will retain every(2) type it 
creates.

Implementation notes:
  1. I decided not use -fno-eliminate-unused-debug-symbols for consistency with 
our other cc1 debug options.
  2. I’m minimizing the set of retained types by only retaining top-level types.


Repository:
  rL LLVM

http://reviews.llvm.org/D18565

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/debug-info-retain-types.c
  test/Driver/debug-options.c

Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -109,6 +109,12 @@
 // RUN: %clang -### -gmodules %s 2>&1 \
 // RUN:| FileCheck -check-prefix=GEXTREFS %s
 //
+// RUN: %clang -### -S %s -gfull 2>&1 \
+// RUN: | FileCheck --check-prefix=RETAIN %s
+//
+// RUN: %clang -### -S %s -g 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_RETAIN %s
+//
 // G: "-cc1"
 // G: "-debug-info-kind=limited"
 //
@@ -169,7 +175,8 @@
 // NOCI-NOT: "-dwarf-column-info"
 //
 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
-
+// RETAIN: "-debug-info-retain-types"
+// NO_RETAIN-NOT: "-debug-info-retain-types"
 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
 // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
 // RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
Index: test/CodeGen/debug-info-retain-types.c
===
--- /dev/null
+++ test/CodeGen/debug-info-retain-types.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fblocks -emit-llvm -o - %s \
+// RUN:   -debug-info-kind=standalone -debug-info-retain-types | FileCheck %s
+// RUN: %clang_cc1 -fblocks -emit-llvm -o - %s \
+// RUN:   -debug-info-kind=standalone -debug-info-retain-types \
+// RUN: | FileCheck %s --check-prefix=CHECK-MIN
+// RUN: %clang_cc1 -fblocks -emit-llvm -o - %s \
+// RUN:   -debug-info-kind=standalone | FileCheck %s --check-prefix=NORETAIN
+// NORETAIN-NOT: !DICompileUnit{{.*}}retainedTypes
+
+// CHECK-DAG: !DICompileUnit({{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+
+// Function type.
+// CHECK-DAG: !DISubprogram(name: "foo", {{.*}}type: ![[FNTY:[0-9]+]]
+static int foo(int i) { return i; }
+
+// Global variable.
+// CHECK-DAG: !DIGlobalVariable(name: "g", {{.*}}type: ![[GLOBTY:[0-9]+]]
+
+// Block capture.
+// CHECK-DAG: !DILocalVariable(name: "d", {{.*}}type: ![[BLOCKTY:[0-9]+]]
+
+// Local variable.
+// CHECK-DAG: !DILocalVariable(name: "xyz", {{.*}}type: ![[VARTY:[0-9]+]]
+static void bar() {
+  struct X { int a; int b; } xyz;
+}
+
+float g;
+int g1;
+
+void baz() {
+  double d;
+  void (^blockptr)(void) = ^(void) {
+foo(0);
+bar();
+  };
+}
+
+// CHECK-DAG: ![[RETAINED]] = {{.*}}![[FNTY]],{{.*}}![[BLOCKTY]],{{.*}}![[GLOBTY]],{{.*}}![[VARTY]]
+
+
+// CHECK-MIN: !DICompileUnit({{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
+// CHECK-MIN: ![[RETAINED]] = !{![[A:.*]], ![[B:.*]], ![[C:.*]], ![[D:.*]], ![[E:.*]],
+// CHECK-MIN-NOT: ![[A]] = !DIBasicType(name: "int"
+// CHECK-MIN-NOT: ![[B]] = !DIBasicType(name: "int"
+// CHECK-MIN-NOT: ![[C]] = !DIBasicType(name: "int"
+// CHECK-MIN-NOT: ![[D]] = !DIBasicType(name: "int"
+// CHECK-MIN-NOT: ![[E]] = !DIBasicType(name: "int"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -486,6 +486,7 @@
   Args.getAllArgValues(OPT_fwhole_program_vtables_blacklist_EQ);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
+  Opts.RetainAllDebugTypes = Args.hasArg(OPT_debug_info_retain_types);
   Opts.DebugExplicitImport = Triple.isPS4CPU(); 
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
Index: lib/Driver/Tools.cpp

r264765 - [Sema] Attempt to fix tests for utf-8 invalid format string specifiers

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 29 13:38:44 2016
New Revision: 264765

URL: http://llvm.org/viewvc/llvm-project?rev=264765=rev
Log:
[Sema] Attempt to fix tests for utf-8 invalid format string specifiers

Followup from r264752.

Attempt to appease buildbots:
 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/2882
 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/2619

Added:
cfe/trunk/test/SemaObjC/format-strings-utf8.m
Modified:
cfe/trunk/test/Sema/format-strings-scanf.c
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/SemaObjC/format-strings-objc.m

Modified: cfe/trunk/test/Sema/format-strings-scanf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-scanf.c?rev=264765=264764=264765=diff
==
--- cfe/trunk/test/Sema/format-strings-scanf.c (original)
+++ cfe/trunk/test/Sema/format-strings-scanf.c Tue Mar 29 13:38:44 2016
@@ -183,11 +183,3 @@ void check_conditional_literal(char *s,
   scanf(i ? "%d" : "%d", i, s); // expected-warning{{data argument not used}}
   scanf(i ? "%s" : "%d", s); // expected-warning{{format specifies type 'int 
*'}}
 }
-
-void testInvalidNoPrintable(int *a) {
-  scanf("%\u25B9", a); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
-  scanf("%\xE2\x96\xB9", a); // expected-warning {{invalid conversion 
specifier '\u25b9'}}
-  scanf("%\U00010348", a); // expected-warning {{invalid conversion specifier 
'\U00010348'}}
-  scanf("%\xF0\x90\x8D\x88", a); // expected-warning {{invalid conversion 
specifier '\U00010348'}}
-  scanf("%\xe2", a); // expected-warning {{invalid conversion specifier 
'\xe2'}}
-}

Modified: cfe/trunk/test/Sema/format-strings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=264765=264764=264765=diff
==
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Tue Mar 29 13:38:44 2016
@@ -642,14 +642,6 @@ void test_qualifiers(volatile int *vip,
   printf("%n", (cip_t)0); // expected-warning{{format specifies type 'int *' 
but the argument has type 'cip_t' (aka 'const int *')}}
 }
 
-void testInvalidNoPrintable() {
-  printf("%\u25B9"); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
-  printf("%\xE2\x96\xB9"); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
-  printf("%\U00010348"); // expected-warning {{invalid conversion specifier 
'\U00010348'}}
-  printf("%\xF0\x90\x8D\x88"); // expected-warning {{invalid conversion 
specifier '\U00010348'}}
-  printf("%\xe2"); // expected-warning {{invalid conversion specifier '\xe2'}}
-}
-
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #pragma GCC diagnostic warning "-Wformat-security"
 // 

Modified: cfe/trunk/test/SemaObjC/format-strings-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc.m?rev=264765=264764=264765=diff
==
--- cfe/trunk/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m Tue Mar 29 13:38:44 2016
@@ -264,12 +264,3 @@ void testObjCModifierFlags() {
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object 
format flags cannot be used with 's' conversion specifier}}
 }
-
-// Test Objective-C invalid no printable specifiers
-void testObjcInvalidNoPrintable(int *a) {
-  NSLog(@"%\u25B9"); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
-  NSLog(@"%\xE2\x96\xB9"); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
-  NSLog(@"%\U00010348"); // expected-warning {{invalid conversion specifier 
'\U00010348'}}
-  NSLog(@"%\xF0\x90\x8D\x88"); // expected-warning {{invalid conversion 
specifier '\U00010348'}}
-  NSLog(@"%\xe2"); // expected-warning {{input conversion stopped}} 
expected-warning {{invalid conversion specifier '\xe2'}}
-}

Added: cfe/trunk/test/SemaObjC/format-strings-utf8.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-utf8.m?rev=264765=auto
==
--- cfe/trunk/test/SemaObjC/format-strings-utf8.m (added)
+++ cfe/trunk/test/SemaObjC/format-strings-utf8.m Tue Mar 29 13:38:44 2016
@@ -0,0 +1,27 @@
+// REQUIRES: shell
+// RUN: env -i LC_ALL=C \
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral 
-fsyntax-only -verify -Wno-objc-root-class %s
+
+#include 
+int printf(const char *restrict, ...);
+int scanf(const char * restrict, ...);
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+
+void testInvalidNoPrintable(int *a) {
+  printf("%\u25B9"); // expected-warning {{invalid conversion specifier 
'\u25b9'}}
+  printf("%\xE2\x96\xB9"); // expected-warning {{invalid 

Re: r264745 - Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
Hi Teresa,

Thanks a lot! I have patched the error.

Thanks,
Eric

On Tue, Mar 29, 2016 at 8:08 PM Teresa Johnson  wrote:

> Hi Eric,
>
> I'm getting a build error:
>
> In file included from
> /usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/lib/Tooling/Refactoring.cpp:21:
> /usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Tooling/Refactoring.h:32:1:
> error: class 'FormatStyle' was previously declared as a struct
> [-Werror,-Wmismatched-tags]
> class FormatStyle;
> ^
> /usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Format/Format.h:43:8:
> note: previous use is here
> struct FormatStyle {
>^
> /usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Tooling/Refactoring.h:32:1:
> note: did you mean struct here?
> class FormatStyle;
> ^
> struct
> 1 error generated.
> ninja: build stopped: subcommand failed.
>
>
> Looks like you added the "class FormatStyle" in Refactoring.h, looks like
> this should be a struct instead.
>
> Thanks,
> Teresa
>
> On Tue, Mar 29, 2016 at 9:31 AM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ioeric
>> Date: Tue Mar 29 11:31:53 2016
>> New Revision: 264745
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=264745=rev
>> Log:
>> Added formatAndApplyAllReplacements that works on multiple files in
>> libTooling.
>>
>> Summary:
>> formatAndApplyAllReplacements takes a set of Replacements, applies them
>> on a
>> Rewriter, and reformats the changed code.
>>
>> Reviewers: klimek, djasper
>>
>> Subscribers: ioeric, klimek, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D17852
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/SourceManager.h
>> cfe/trunk/include/clang/Format/Format.h
>> cfe/trunk/include/clang/Tooling/Core/Replacement.h
>> cfe/trunk/include/clang/Tooling/Refactoring.h
>> cfe/trunk/lib/Format/Format.cpp
>> cfe/trunk/lib/Tooling/CMakeLists.txt
>> cfe/trunk/lib/Tooling/Core/Replacement.cpp
>> cfe/trunk/lib/Tooling/Refactoring.cpp
>> cfe/trunk/unittests/Format/FormatTest.cpp
>> cfe/trunk/unittests/Tooling/CMakeLists.txt
>> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/SourceManager.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=264745=264744=264745=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
>> +++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Mar 29 11:31:53 2016
>> @@ -797,6 +797,15 @@ public:
>>  IncludeLoc, FileCharacter, LoadedID,
>> LoadedOffset);
>>}
>>
>> +  /// \brief Get the FileID for \p SourceFile if it exists. Otherwise,
>> create a
>> +  /// new FileID for the \p SourceFile.
>> +  FileID getOrCreateFileID(const FileEntry *SourceFile,
>> +   SrcMgr::CharacteristicKind FileCharacter) {
>> +FileID ID = translateFile(SourceFile);
>> +return ID.isValid() ? ID : createFileID(SourceFile, SourceLocation(),
>> +FileCharacter);
>> +  }
>> +
>>/// \brief Return a new SourceLocation that encodes the
>>/// fact that a token from SpellingLoc should actually be referenced
>> from
>>/// ExpansionLoc, and that it represents the expansion of a macro
>> argument
>>
>> Modified: cfe/trunk/include/clang/Format/Format.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=264745=264744=264745=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Format/Format.h (original)
>> +++ cfe/trunk/include/clang/Format/Format.h Tue Mar 29 11:31:53 2016
>> @@ -766,22 +766,6 @@ tooling::Replacements formatReplacements
>>   const tooling::Replacements
>> ,
>>   const FormatStyle );
>>
>> -/// \brief In addition to applying all replacements in \p Replaces to \p
>> Code,
>> -/// this function also reformats the changed code after applying
>> replacements.
>> -///
>> -/// \pre Replacements must be for the same file and conflict-free.
>> -///
>> -/// Replacement applications happen independently of the success of
>> -/// other applications.
>> -///
>> -/// \returns the changed code with all replacements applied and
>> formatted, if
>> -/// successful. An empty string otherwise.
>> -///
>> -/// See also "include/clang/Tooling/Core/Replacements.h".
>> -std::string applyAllReplacementsAndFormat(StringRef Code,
>> -  const tooling::Replacements
>> ,
>> -  const FormatStyle );
>> -
>>  /// \brief Reformats the given \p Ranges in the file \p ID.
>>  ///
>>  /// Each range is extended on either end to its next bigger logic 

r264760 - Removed class FormatStyle, which is a struct, forward declaration from Refactoring.h to avoid compilation error.

2016-03-29 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Mar 29 13:17:11 2016
New Revision: 264760

URL: http://llvm.org/viewvc/llvm-project?rev=264760=rev
Log:
Removed class FormatStyle, which is a struct, forward declaration from 
Refactoring.h to avoid compilation error.

Modified:
cfe/trunk/include/clang/Tooling/Refactoring.h

Modified: cfe/trunk/include/clang/Tooling/Refactoring.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring.h?rev=264760=264759=264760=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring.h Tue Mar 29 13:17:11 2016
@@ -27,12 +27,6 @@ namespace clang {
 
 class Rewriter;
 
-namespace format {
-
-class FormatStyle;
-
-} // namespace format
-
 namespace tooling {
 
 /// \brief A tool to run refactorings.


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


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

2016-03-29 Thread Sean Callanan via cfe-commits
spyffe requested changes to this revision.
spyffe added a comment.
This revision now requires changes to proceed.

Overall this is a great improvement and I look forward to taking advantage of 
this patch in LLDB!

I had one specific nit about `NullPtrTy`, and one more general comment about 
your infrastructure that imports multiple things – it seems like we can 
collaborate and create some combination of `ImportArray` and your code to 
handle all cases.  Particularly you handle the cases where the array doesn't 
have to be  allocated inside `getToContext()` – my code doesn't handle that at 
all.

Thanks for working on this.



Comment at: lib/AST/ASTImporter.cpp:35
@@ +34,3 @@
+void ImportMultipleItems(IIter Ibegin, IIter Iend, OIter Obegin) {
+  ASTImporter  = Importer;
+  std::transform(Ibegin, Iend, Obegin,

I recently added a function, `ImportArray`, that does something similar.  Could 
it be adapted to your needs?


Comment at: lib/AST/ASTImporter.cpp:5462
@@ +5461,3 @@
+  ASTContext  = Importer.getToContext();
+  return new(ToCtx) CXXNullPtrLiteralExpr(ToCtx.NullPtrTy,
+  Importer.Import(E->getLocation()));

I'm worried about using `NullPtrTy` here directly, because the type may have 
been coerced to a `typedef` or something like that.  The fact that the 
constructor takes a type argument suggests that the type is not implicit – I'd 
feel much more comfortable just importing the type.


Comment at: lib/AST/ASTImporter.cpp:5466
@@ +5465,3 @@
+
+Expr *ASTNodeImporter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
+  ASTContext  = Importer.getToContext();

I recently committed `VisitCXXBoolLiteralExpr`.  Sorry to step on your toes!


Comment at: lib/AST/ASTImporter.cpp:5878
@@ -5346,1 +5877,3 @@
 
+Expr *ASTNodeImporter::VisitCXXThisExpr(CXXThisExpr *E) {
+  QualType T = Importer.Import(E->getType());

Sorry again!  I recently committed `VisitCXXThisExpr`


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

This is a good point; if you use LLDB to test this (e.g., lldb's 
`test/testcases/expression_command/top-level`) then you can verify that these 
imported entities make it all the way to generated machine code and work as 
expected.

Ideally there would be a mode in Clang that parses the input file, makes a 
translation unit out of it, imports everything from that translation unit into 
another translation unit, and then `CodeGen`s the second translation unit.  
That is something I'd like to hook up when I get some time.  I've also talked 
to Doug Gregor and he suggested that perhaps .pch files can be abused for this 
purpose, repurposing some of the functionality in the `ASTMerge` tests (though 
those don't do `CodeGen`).


http://reviews.llvm.org/D14286



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


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-29 Thread Samuel Benzaquen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264759: [clang-tidy] Add check to detect dangling references 
in value handlers. (authored by sbenza).

Changed prior to commit:
  http://reviews.llvm.org/D17811?vs=51684=51956#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17811

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-dangling-handle.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-dangling-handle.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.h
@@ -0,0 +1,43 @@
+//===--- DanglingHandleCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Detect dangling references in value handlers like
+/// std::experimental::string_view.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-dangling-handle.html
+class DanglingHandleCheck : public ClangTidyCheck {
+public:
+  DanglingHandleCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
+
+private:
+  void registerMatchersForVariables(ast_matchers::MatchFinder *Finder);
+  void registerMatchersForReturn(ast_matchers::MatchFinder *Finder);
+
+  const std::vector HandleClasses;
+  const ast_matchers::internal::Matcher IsAHandle;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DANGLING_HANDLE_H
Index: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
@@ -0,0 +1,185 @@
+//===--- DanglingHandleCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DanglingHandleCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+static const char HandleClassesDelimiter[] = ";";
+
+std::vector parseClasses(StringRef Option) {
+  SmallVector Classes;
+  Option.split(Classes, HandleClassesDelimiter);
+  std::vector Result;
+  for (StringRef  : Classes) {
+Class = Class.trim();
+if (!Class.empty())
+  Result.push_back(Class);
+  }
+  return Result;
+}
+
+ast_matchers::internal::BindableMatcher handleFrom(
+ast_matchers::internal::Matcher IsAHandle,
+ast_matchers::internal::Matcher Arg) {
+  return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+  hasArgument(0, Arg));
+}
+
+ast_matchers::internal::Matcher handleFromTemporaryValue(
+ast_matchers::internal::Matcher IsAHandle) {
+  // If a ternary operator returns a temporary value, then both branches hold a
+  // temporary value. If one of them is not a temporary then it must be copied
+  // into one to satisfy the type of the operator.
+  const auto TemporaryTernary =
+  conditionalOperator(hasTrueExpression(cxxBindTemporaryExpr()),
+  hasFalseExpression(cxxBindTemporaryExpr()));
+
+  return handleFrom(IsAHandle, anyOf(cxxBindTemporaryExpr(), TemporaryTernary));
+}
+
+ast_matchers::internal::Matcher isASequence() {
+  return hasAnyName("::std::deque", "::std::forward_list", "::std::list",
+"::std::vector");
+}
+
+ast_matchers::internal::Matcher isASet() {
+  return hasAnyName("::std::set", "::std::multiset", "::std::unordered_set",
+

Re: r264745 - Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Teresa Johnson via cfe-commits
Hi Eric,

I'm getting a build error:

In file included from
/usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/lib/Tooling/Refactoring.cpp:21:
/usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Tooling/Refactoring.h:32:1:
error: class 'FormatStyle' was previously declared as a struct
[-Werror,-Wmismatched-tags]
class FormatStyle;
^
/usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Format/Format.h:43:8:
note: previous use is here
struct FormatStyle {
   ^
/usr/local/google/home/tejohnson/llvm/llvm_16/tools/clang/include/clang/Tooling/Refactoring.h:32:1:
note: did you mean struct here?
class FormatStyle;
^
struct
1 error generated.
ninja: build stopped: subcommand failed.


Looks like you added the "class FormatStyle" in Refactoring.h, looks like
this should be a struct instead.

Thanks,
Teresa

On Tue, Mar 29, 2016 at 9:31 AM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Tue Mar 29 11:31:53 2016
> New Revision: 264745
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264745=rev
> Log:
> Added formatAndApplyAllReplacements that works on multiple files in
> libTooling.
>
> Summary:
> formatAndApplyAllReplacements takes a set of Replacements, applies them on
> a
> Rewriter, and reformats the changed code.
>
> Reviewers: klimek, djasper
>
> Subscribers: ioeric, klimek, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D17852
>
> Modified:
> cfe/trunk/include/clang/Basic/SourceManager.h
> cfe/trunk/include/clang/Format/Format.h
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/include/clang/Tooling/Refactoring.h
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/lib/Tooling/CMakeLists.txt
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/lib/Tooling/Refactoring.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
> cfe/trunk/unittests/Tooling/CMakeLists.txt
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Basic/SourceManager.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=264745=264744=264745=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
> +++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Mar 29 11:31:53 2016
> @@ -797,6 +797,15 @@ public:
>  IncludeLoc, FileCharacter, LoadedID,
> LoadedOffset);
>}
>
> +  /// \brief Get the FileID for \p SourceFile if it exists. Otherwise,
> create a
> +  /// new FileID for the \p SourceFile.
> +  FileID getOrCreateFileID(const FileEntry *SourceFile,
> +   SrcMgr::CharacteristicKind FileCharacter) {
> +FileID ID = translateFile(SourceFile);
> +return ID.isValid() ? ID : createFileID(SourceFile, SourceLocation(),
> +FileCharacter);
> +  }
> +
>/// \brief Return a new SourceLocation that encodes the
>/// fact that a token from SpellingLoc should actually be referenced
> from
>/// ExpansionLoc, and that it represents the expansion of a macro
> argument
>
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=264745=264744=264745=diff
>
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Tue Mar 29 11:31:53 2016
> @@ -766,22 +766,6 @@ tooling::Replacements formatReplacements
>   const tooling::Replacements
> ,
>   const FormatStyle );
>
> -/// \brief In addition to applying all replacements in \p Replaces to \p
> Code,
> -/// this function also reformats the changed code after applying
> replacements.
> -///
> -/// \pre Replacements must be for the same file and conflict-free.
> -///
> -/// Replacement applications happen independently of the success of
> -/// other applications.
> -///
> -/// \returns the changed code with all replacements applied and
> formatted, if
> -/// successful. An empty string otherwise.
> -///
> -/// See also "include/clang/Tooling/Core/Replacements.h".
> -std::string applyAllReplacementsAndFormat(StringRef Code,
> -  const tooling::Replacements
> ,
> -  const FormatStyle );
> -
>  /// \brief Reformats the given \p Ranges in the file \p ID.
>  ///
>  /// Each range is extended on either end to its next bigger logic unit,
> i.e.
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=264745=264744=264745=diff
>
> ==
> --- 

[clang-tools-extra] r264759 - [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-29 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Tue Mar 29 13:02:26 2016
New Revision: 264759

URL: http://llvm.org/viewvc/llvm-project?rev=264759=rev
Log:
[clang-tidy] Add check to detect dangling references in value handlers.

Summary:
Add check misc-dangling-handle to detect dangling references in value
handlers like std::experimental::string_view.
It provides a configuration option to specify other handle types that
should also be checked.

Right now it detects:
 - Construction from temporaries.
 - Assignment from temporaries.
 - Return statements from temporaries or locals.
 - Insertion into containers from temporaries.

Reviewers: alexfh

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-dangling-handle.rst
clang-tools-extra/trunk/test/clang-tidy/misc-dangling-handle.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=264759=264758=264759=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Mar 29 13:02:26 
2016
@@ -5,6 +5,7 @@ add_clang_library(clangTidyMiscModule
   AssertSideEffectCheck.cpp
   AssignOperatorSignatureCheck.cpp
   BoolPointerImplicitConversionCheck.cpp
+  DanglingHandleCheck.cpp
   DefinitionsInHeadersCheck.cpp
   ForwardDeclarationNamespaceCheck.cpp
   InaccurateEraseCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp?rev=264759=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp Tue Mar 29 
13:02:26 2016
@@ -0,0 +1,185 @@
+//===--- DanglingHandleCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DanglingHandleCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+static const char HandleClassesDelimiter[] = ";";
+
+std::vector parseClasses(StringRef Option) {
+  SmallVector Classes;
+  Option.split(Classes, HandleClassesDelimiter);
+  std::vector Result;
+  for (StringRef  : Classes) {
+Class = Class.trim();
+if (!Class.empty())
+  Result.push_back(Class);
+  }
+  return Result;
+}
+
+ast_matchers::internal::BindableMatcher handleFrom(
+ast_matchers::internal::Matcher IsAHandle,
+ast_matchers::internal::Matcher Arg) {
+  return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+  hasArgument(0, Arg));
+}
+
+ast_matchers::internal::Matcher handleFromTemporaryValue(
+ast_matchers::internal::Matcher IsAHandle) {
+  // If a ternary operator returns a temporary value, then both branches hold a
+  // temporary value. If one of them is not a temporary then it must be copied
+  // into one to satisfy the type of the operator.
+  const auto TemporaryTernary =
+  conditionalOperator(hasTrueExpression(cxxBindTemporaryExpr()),
+  hasFalseExpression(cxxBindTemporaryExpr()));
+
+  return handleFrom(IsAHandle, anyOf(cxxBindTemporaryExpr(), 
TemporaryTernary));
+}
+
+ast_matchers::internal::Matcher isASequence() {
+  return hasAnyName("::std::deque", "::std::forward_list", "::std::list",
+"::std::vector");
+}
+
+ast_matchers::internal::Matcher isASet() {
+  return hasAnyName("::std::set", "::std::multiset", "::std::unordered_set",
+"::std::unordered_multiset");
+}
+
+ast_matchers::internal::Matcher isAMap() {
+  return hasAnyName("::std::map", "::std::multimap", "::std::unordered_map",
+"::std::unordered_multimap");
+}
+
+ast_matchers::internal::BindableMatcher
+makeContainerMatcher(ast_matchers::internal::Matcher IsAHandle) {
+  // This matcher could be expanded to detect:
+  //  - Constructors: eg. vector(3, string("A"));
+  //  - emplace*(): This requires a different logic to determine that
+  //the 

r264757 - [Order Files] Fix order file usage

2016-03-29 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 29 12:51:08 2016
New Revision: 264757

URL: http://llvm.org/viewvc/llvm-project?rev=264757=rev
Log:
[Order Files] Fix order file usage

The CMake EXISTS operator needs to have the variable expanded. Not expanding 
this was causing the if statement to always be false, which made it impossible 
to pass linker order files in.

Modified:
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=264757=264756=264757=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Tue Mar 29 12:51:08 2016
@@ -87,7 +87,7 @@ if (APPLE)
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
-if(CLANG_ORDER_FILE AND EXISTS CLANG_ORDER_FILE)
+if(CLANG_ORDER_FILE AND EXISTS ${CLANG_ORDER_FILE})
   target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
 endif()
 


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


Re: [PATCH] D18408: readability check for const params in declarations

2016-03-29 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 51954.
fowles marked 2 inline comments as done.
fowles added a comment.

- review comments
- rename variables and remove MSVC compat issues


http://reviews.llvm.org/D18408

Files:
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tidy/readability/AvoidConstParamsInDecls.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
  test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s readability-avoid-const-params-in-decls %t
+
+using alias_type = bool;
+using alias_const_type = const bool;
+
+
+void F1(const int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
+// CHECK-FIXES: void F1(int i);
+
+void F2(const int *const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F2(const int * i);
+
+void F3(int const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F3(int i);
+
+void F4(alias_type const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F4(alias_type i);
+
+void F5(const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// CHECK-FIXES: void F5(int);
+
+void F6(const int *const);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// BUG(b/27584482): void F6(const int *);  should be produced
+
+void F7(int, const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: parameter 2 is const-qualified
+// CHECK-FIXES: void F7(int, int);
+
+void F8(const int, const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: parameter 2 is const-qualified
+// CHECK-FIXES: void F8(int, int);
+
+void F9(const int long_name);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'long_name'
+// CHECK-FIXES: void F9(int long_name);
+
+void F10(const int *const *const long_name);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'long_name'
+// CHECK-FIXES: void F10(const int *const * long_name);
+
+
+struct Foo {
+  Foo(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
+  // CHECK-FIXES: Foo(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+
+// Do not match on definitions
+void NF1(const int i) {}
+void NF2(const int *const i) {}
+void NF3(int const i) {}
+void NF4(alias_type const i) {}
+void NF5(const int) {}
+void NF6(const int *const) {}
+void NF7(int, const int) {}
+void NF8(const int, const int) {}
+
+// Do not match on other stuff
+void NF(const alias_type& i);
+void NF(const int );
+void NF(const int *i);
+void NF(alias_const_type i);
+void NF(const alias_type&);
+void NF(const int&);
+void NF(const int*);
+void NF(const int* const*);
+void NF(alias_const_type);
Index: docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - readability-avoid-const-params-in-decls
+
+readability-avoid-const-params-in-decls
+===
+
+Checks whether a function declaration has parameters that are top level const.
+
+`const` values in declarations do not affect the signature of a function, so
+they should not be put there.  For example:
+
+Examples:
+
+.. code:: c++
+
+  void f(const string);   // Bad: const is top level.
+  void f(const string&);  // Good: const is not top level.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -89,8 +89,9 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
-   performance-unnecessary-value-param
performance-unnecessary-copy-initialization
+   performance-unnecessary-value-param
+   readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
readability-else-after-return
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ 

Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI

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

ping @danalbert, @mclow.lists


http://reviews.llvm.org/D17416



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


Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi

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

ping


http://reviews.llvm.org/D16545



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


Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

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

ping


http://reviews.llvm.org/D16544



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


Re: [PATCH] D18296: [Sema] Handle UTF-8 invalid format string specifiers

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Thanks Richard. Applied your last comments and committed in r264752


http://reviews.llvm.org/D18296



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


r264752 - [Sema] Handle UTF-8 invalid format string specifiers

2016-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 29 12:35:02 2016
New Revision: 264752

URL: http://llvm.org/viewvc/llvm-project?rev=264752=rev
Log:
[Sema] Handle UTF-8 invalid format string specifiers

Improve invalid format string specifier handling by printing out
invalid specifiers characters with \x, \u and \U. Previously clang
would print gargabe whenever the character is unprintable.

Example, before:
  NSLog(@"%\u25B9"); => warning: invalid conversion specifier ' 
[-Wformat-invalid-specifier]
after:
  NSLog(@"%\u25B9"); => warning: invalid conversion specifier '\u25b9' 
[-Wformat-invalid-specifier]

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

rdar://problem/24672159

Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/FormatStringParsing.h
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Analysis/ScanfFormatString.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings-scanf.c
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/SemaObjC/format-strings-objc.m

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=264752=264751=264752=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Tue Mar 29 
12:35:02 2016
@@ -210,6 +210,7 @@ public:
   unsigned getLength() const {
 return EndScanList ? EndScanList - Position : 1;
   }
+  void setEndScanList(const char *pos) { EndScanList = pos; }
 
   bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) ||
 kind == FreeBSDrArg || kind == FreeBSDyArg; }
@@ -413,11 +414,6 @@ public:
   bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
   bool isDoubleArg() const { return kind >= DoubleArgBeg &&
 kind <= DoubleArgEnd; }
-  unsigned getLength() const {
-  // Conversion specifiers currently only are represented by
-  // single characters, but we be flexible.
-return 1;
-  }
 
   static bool classof(const analyze_format_string::ConversionSpecifier *CS) {
 return CS->isPrintfKind();
@@ -546,8 +542,6 @@ public:
   ScanfConversionSpecifier(const char *pos, Kind k)
 : ConversionSpecifier(false, pos, k) {}
 
-  void setEndScanList(const char *pos) { EndScanList = pos; }
-
   static bool classof(const analyze_format_string::ConversionSpecifier *CS) {
 return !CS->isPrintfKind();
   }

Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=264752=264751=264752=diff
==
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Tue Mar 29 12:35:02 2016
@@ -15,6 +15,7 @@
 #include "FormatStringParsing.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/ConvertUTF.h"
 
 using clang::analyze_format_string::ArgType;
 using clang::analyze_format_string::FormatStringHandler;
@@ -260,6 +261,28 @@ clang::analyze_format_string::ParseLengt
   return true;
 }
 
+bool clang::analyze_format_string::ParseUTF8InvalidSpecifier(
+const char *SpecifierBegin, const char *FmtStrEnd, unsigned ) {
+  if (SpecifierBegin + 1 >= FmtStrEnd)
+return false;
+
+  const UTF8 *SB = reinterpret_cast(SpecifierBegin + 1);
+  const UTF8 *SE = reinterpret_cast(FmtStrEnd);
+  const char FirstByte = *SB;
+
+  // If the invalid specifier is a multibyte UTF-8 string, return the
+  // total length accordingly so that the conversion specifier can be
+  // properly updated to reflect a complete UTF-8 specifier.
+  unsigned NumBytes = getNumBytesForUTF8(FirstByte);
+  if (NumBytes == 1)
+return false;
+  if (SB + NumBytes > SE)
+return false;
+
+  Len = NumBytes + 1;
+  return true;
+}
+
 
//===--===//
 // Methods on ArgType.
 
//===--===//

Modified: cfe/trunk/lib/Analysis/FormatStringParsing.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatStringParsing.h?rev=264752=264751=264752=diff
==
--- cfe/trunk/lib/Analysis/FormatStringParsing.h (original)
+++ cfe/trunk/lib/Analysis/FormatStringParsing.h Tue Mar 29 12:35:02 2016
@@ -46,7 +46,13 @@ bool ParseArgPosition(FormatStringHandle
 /// FormatSpecifier& argument, and false otherwise.
 bool ParseLengthModifier(FormatSpecifier , const char *, const char *E,
  const LangOptions , bool IsScanf = false);
-  
+
+/// Returns true if the invalid 

Re: [PATCH] D18475: [clang-tidy] Add more detection rules for redundant c_str calls.

2016-03-29 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

In http://reviews.llvm.org/D18475#385789, @alexfh wrote:

> Looks good to me. Adding Samuel, since he has done a lot of similar stuff by 
> now and might have good ideas on improving this and making this more general.


There are two things I've done before that might apply here.
First, you can move the function+arg into data and just loop through it to make 
the matchers.
Eg:

  struct Case {
StringRef Func;
unsigned Arg;
  };
  const Case Cases[] = {...};
  for (Case C : Cases) {
Finder->addMatcher(...);
  }

This reduces the amount of code duplication.

Another thing I've done is to find matching overloads dynamically instead of 
hardcoding the list of functions.
The idea is that you match something like 
`callExpr(hasAnyArgument(StringCStrCallExpr))` and then you figure out if that 
function has a matching overload that takes `const string&` on that specific 
argument.
This is flexible, but might give false positives.


http://reviews.llvm.org/D18475



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

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

Regarding half types since there is inconsistency in both headers (commented in 
CL1.2), should we just enable the extension cl_khr_fp16 in the header and then 
have the overloads with half there with all the other types? They shouldn't be 
visible to custom code unless the same extension is enabled in the compiled cl 
file because half type itself won't be allowed without enabling it.

What about OpenCL 1.1 header? Ideally it would be nice to have them in too!

Is there any chance we could factor out the common bits into separate files to 
avoid large code repetition? I would imagine it should be quite doable as libs 
of each standard contain incremental changes.

Do you plan integrating it into the Clang driver too by automatic inclusion 
since it's not done with normal #include?



Comment at: lib/Headers/opencl-12.h:585
@@ +584,3 @@
+double16 const_func __attribute__((overloadable)) cbrt(double16);
+//half const_func __attribute__((overloadable)) cbrt(half);
+//half2 const_func __attribute__((overloadable)) cbrt(half2);

Why commented code here?


Comment at: lib/Headers/opencl-20.h:4150
@@ +4149,3 @@
+ */
+#define as_char(x) __builtin_astype((x), char)
+#define as_char2(x) __builtin_astype((x), char2)

I think we should have a normal declaration of these BIFs, because otherwise 
this won't appear as a symbol anywhere and would prevent for example error 
reporting with the original OpenCL function name.

An implementation of the builtin function can just call the Clang builtin 
__builtin_astype in its definition. This is also more general approach in case 
some implementations will decide to do something else here. 


Comment at: lib/Headers/opencl-20.h:9866
@@ +9865,3 @@
+
+// TODO: fast_normalize(half)?
+

There is a TODO here!


Comment at: lib/Headers/opencl-20.h:11213
@@ +11212,3 @@
+#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
+#define CLK_NULL_RESERVE_ID 
(__builtin_astype(((void*)(~PIPE_RESERVE_ID_VALID_BIT)), reserve_id_t))
+bool __attribute__((overloadable)) is_valid_reserve_id(reserve_id_t 
reserve_id);

This doesn't come directly from Spec.


Comment at: lib/Headers/opencl-20.h:11222
@@ +11221,3 @@
+#define MAX_WORK_DIM3
+typedef struct {
+unsigned int workDimension;

This isn't defined by Spec but it seems sensible to define it this way.

However, there is a conflict here as ndrange_t is already added as a Clang 
builtin type:
https://llvm.org/svn/llvm-project/cfe/trunk@247676
 and it is compiled to opaque type in IR. However, considering that we can have 
local variables and returns of this type, we might remove it from Clang type 
then and add it here in a header.

Any thoughts?


Comment at: lib/Headers/opencl-20.h:11251
@@ +11250,3 @@
+int __attribute__((overloadable))
+enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags,
+   const ndrange_t ndrange, void (^block)(local void *, ...),

I think I would prefer to add an enqueue kernel as a Clang builtin because it 
requires custom check of type of variadic arguments as well as block arguments.


Comment at: lib/Headers/opencl-20.h:11263
@@ +11262,3 @@
+uint __attribute__((overloadable)) get_kernel_work_group_size(void 
(^block)(void));
+uint __attribute__((overloadable)) get_kernel_work_group_size(void 
(^block)(local void *, ...));
+uint __attribute__((overloadable)) 
get_kernel_preferred_work_group_size_multiple(void (^block)(void));

Also here we need a special check of parameters to block, and therefore it 
should be added as a Clang builtin.


Comment at: lib/Headers/opencl-20.h:11572
@@ +11571,3 @@
+
+#define ATOMIC_VAR_INIT(x) (x)
+

I think this should be target specific?


Comment at: lib/Headers/opencl-20.h:11605
@@ +11604,3 @@
+
+#define atomic_init_prototype(TYPE) \
+atomic_init_prototype_addrspace(TYPE, generic)

Could you change atomic_init_prototype to upper case letters to match the style?

The same below.

Also it seems like some BIFs are declared with macros and some not. Any system 
there?


Comment at: lib/Headers/opencl-20.h:11886
@@ +11885,3 @@
+
+__global  void* __attribute__((overloadable)) to_global(void*);
+__local   void* __attribute__((overloadable)) to_local(void*);

This isn't correct prototype according to Spec though. It should take any 
pointer type and not a void*.

This approach will introduce extra type conversions and might lead to loss of 
type information.


Comment at: lib/Headers/opencl-20.h:13851
@@ +13850,3 @@
+/**
+ * Use the coordinate (x, y) to do an element lookup in
+ * in the mip-level specified by lod in the

Also there seems to be inconsistency in documentation.



Re: [PATCH] D18475: [clang-tidy] Add more detection rules for redundant c_str calls.

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

Looks good to me. Adding Samuel, since he has done a lot of similar stuff by 
now and might have good ideas on improving this and making this more general.


http://reviews.llvm.org/D18475



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


r264745 - Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Mar 29 11:31:53 2016
New Revision: 264745

URL: http://llvm.org/viewvc/llvm-project?rev=264745=rev
Log:
Added formatAndApplyAllReplacements that works on multiple files in libTooling.

Summary:
formatAndApplyAllReplacements takes a set of Replacements, applies them on a
Rewriter, and reformats the changed code.

Reviewers: klimek, djasper

Subscribers: ioeric, klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/include/clang/Tooling/Refactoring.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/CMakeLists.txt
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/lib/Tooling/Refactoring.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Tooling/CMakeLists.txt
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=264745=264744=264745=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Mar 29 11:31:53 2016
@@ -797,6 +797,15 @@ public:
 IncludeLoc, FileCharacter, LoadedID, LoadedOffset);
   }
 
+  /// \brief Get the FileID for \p SourceFile if it exists. Otherwise, create a
+  /// new FileID for the \p SourceFile.
+  FileID getOrCreateFileID(const FileEntry *SourceFile,
+   SrcMgr::CharacteristicKind FileCharacter) {
+FileID ID = translateFile(SourceFile);
+return ID.isValid() ? ID : createFileID(SourceFile, SourceLocation(),
+FileCharacter);
+  }
+
   /// \brief Return a new SourceLocation that encodes the
   /// fact that a token from SpellingLoc should actually be referenced from
   /// ExpansionLoc, and that it represents the expansion of a macro argument

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=264745=264744=264745=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Tue Mar 29 11:31:53 2016
@@ -766,22 +766,6 @@ tooling::Replacements formatReplacements
  const tooling::Replacements ,
  const FormatStyle );
 
-/// \brief In addition to applying all replacements in \p Replaces to \p Code,
-/// this function also reformats the changed code after applying replacements.
-///
-/// \pre Replacements must be for the same file and conflict-free.
-///
-/// Replacement applications happen independently of the success of
-/// other applications.
-///
-/// \returns the changed code with all replacements applied and formatted, if
-/// successful. An empty string otherwise.
-///
-/// See also "include/clang/Tooling/Core/Replacements.h".
-std::string applyAllReplacementsAndFormat(StringRef Code,
-  const tooling::Replacements 
,
-  const FormatStyle );
-
 /// \brief Reformats the given \p Ranges in the file \p ID.
 ///
 /// Each range is extended on either end to its next bigger logic unit, i.e.

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=264745=264744=264745=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Tue Mar 29 11:31:53 2016
@@ -22,6 +22,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringRef.h"
+#include 
 #include 
 #include 
 #include 
@@ -220,12 +221,16 @@ bool applyAllReplacements(const std::vec
 /// replacements cannot be applied, this returns an empty \c string.
 std::string applyAllReplacements(StringRef Code, const Replacements );
 
-/// \brief Calculate the ranges in a single file that are affected by the
+/// \brief Calculates the ranges in a single file that are affected by the
 /// Replacements.
 ///
 /// \pre Replacements must be for the same file.
-std::vector
-calculateChangedRangesInFile(const tooling::Replacements );
+std::vector calculateChangedRanges(const Replacements );
+
+/// \brief Groups a random set of replacements by file path. Replacements
+/// related to the same file entry are put into the same vector.
+std::map
+groupReplacementsByFile(const Replacements );
 
 /// \brief Merges two sets of replacements with 

Re: [PATCH] D18408: readability check for const params in declarations

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

Looks good with one nit. Thank you for the new check!

Do you need me to submit the patch for you?



Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:24
@@ +23,3 @@
+  if (Param.getIdentifier() != nullptr)
+return {Param.getLocStart(), Param.getLocEnd().getLocWithOffset(-1)};
+  return Param.getSourceRange();

I suspect this will fail to build in MSVC 2013, since it doesn't support 
uniform initialization. But it might be just initializer lists that it doesn't 
support. We can try.


Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:32
@@ +31,3 @@
+void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
+  const auto const_param_decl =
+  parmVarDecl(hasType(qualType(isConstQualified(.bind("param");

"Variable names should be nouns (as they represent state). The name should be 
camel case, and start with an upper case letter (e.g. Leader or Boats)."
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


http://reviews.llvm.org/D18408



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264745: Added formatAndApplyAllReplacements that works on 
multiple files in libTooling. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D17852?vs=51936=51939#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17852

Files:
  cfe/trunk/include/clang/Basic/SourceManager.h
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/include/clang/Tooling/Core/Replacement.h
  cfe/trunk/include/clang/Tooling/Refactoring.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Tooling/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/Replacement.cpp
  cfe/trunk/lib/Tooling/Refactoring.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Tooling/CMakeLists.txt
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,39 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(
+  Replaces, Context.Rewrite, "{BasedOnStyle: LLVM, ColumnLimit: 20}"));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +460,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: cfe/trunk/unittests/Tooling/CMakeLists.txt
===
--- cfe/trunk/unittests/Tooling/CMakeLists.txt
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt
@@ -30,6 +30,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11270,7 +11270,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -766,22 +766,6 @@
  const tooling::Replacements ,
  const FormatStyle );
 
-/// \brief In addition to applying all replacements in \p Replaces to \p Code,
-/// this function also reformats the changed code after applying replacements.
-///
-/// \pre Replacements must be for the same file and conflict-free.
-///
-/// Replacement applications happen independently of the success of
-/// other 

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51936.
ioeric added a comment.

- Minor changes.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,39 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(
+  Replaces, Context.Rewrite, "{BasedOnStyle: LLVM, ColumnLimit: 20}"));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +460,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -30,6 +30,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11234,7 +11234,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -61,5 +62,29 @@
   return Rewrite.overwriteChangedFiles() ? 1 : 0;
 }
 
+bool formatAndApplyAllReplacements(const Replacements ,
+   Rewriter , StringRef Style) {
+  SourceManager  = Rewrite.getSourceMgr();
+  FileManager  = SM.getFileManager();
+
+  auto FileToReplaces = groupReplacementsByFile(Replaces);
+
+  bool Result = true;
+  for (auto  : FileToReplaces) {
+const std::string FilePath = FileAndReplaces.first;
+auto  = FileAndReplaces.second;
+
+const FileEntry *Entry = Files.getFile(FilePath);
+FileID ID = SM.getOrCreateFileID(Entry, SrcMgr::C_User);
+StringRef Code = 

r264740 - [CUDA] Make CUDA description strings in langopts into noun phrases. NFC

2016-03-29 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Mar 29 11:24:20 2016
New Revision: 264740

URL: http://llvm.org/viewvc/llvm-project?rev=264740=rev
Log:
[CUDA] Make CUDA description strings in langopts into noun phrases.  NFC

rsmith quoth in D18380:

> This should be a noun phrase -- this string appears in contexts like
> "support for %0 is enabled" -- so this should be "treating
> unattributed [...]".

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=264740=264739=264740=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Mar 29 11:24:20 2016
@@ -170,8 +170,8 @@ LANGOPT(OpenMP, 1, 0, "OpenM
 LANGOPT(OpenMPUseTLS  , 1, 0, "Use TLS for threadprivates or runtime 
calls")
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target 
device")
 
-LANGOPT(CUDAIsDevice  , 1, 0, "Compiling for CUDA device")
-LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "Allow variadic functions in CUDA 
device code")
+LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")
+LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "allowing variadic functions in CUDA 
device code")
 
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for 
C++'s new operators")
 LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions")


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


r264739 - [CUDA] Remove three obsolete CUDA cc1 flags.

2016-03-29 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Mar 29 11:24:16 2016
New Revision: 264739

URL: http://llvm.org/viewvc/llvm-project?rev=264739=rev
Log:
[CUDA] Remove three obsolete CUDA cc1 flags.

Summary:
* -fcuda-target-overloads

  Previously unconditionally set to true by the driver.  Necessary for
  correct functioning of the compiler -- our CUDA headers wrapper won't
  compile without this.

* -fcuda-disable-target-call-checks

  Previously unconditionally set to true by the driver.  Necessary to
  compile almost any external CUDA code -- almost all libraries assume
  that host+device code can call host or device functions.

* -fcuda-allow-host-calls-from-host-device

  No effect when target overloading is enabled.

Reviewers: tra

Subscribers: rsmith, cfe-commits

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

Removed:
cfe/trunk/test/SemaCUDA/function-target-disabled-check.cu
cfe/trunk/test/SemaCUDA/function-target-hd.cu
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CodeGenCUDA/function-overload.cu
cfe/trunk/test/CodeGenCUDA/host-device-calls-host.cu
cfe/trunk/test/SemaCUDA/builtins.cu
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/implicit-intrinsic.cu
cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu
cfe/trunk/test/SemaCUDA/method-target.cu

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=264739=264738=264739=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Mar 29 11:24:16 2016
@@ -171,9 +171,6 @@ LANGOPT(OpenMPUseTLS  , 1, 0, "Use T
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target 
device")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "Compiling for CUDA device")
-LANGOPT(CUDAAllowHostCallsFromHostDevice, 1, 0, "Allow host device functions 
to call host functions")
-LANGOPT(CUDADisableTargetCallChecks, 1, 0, "Disable checks for call targets 
(host, device, etc.)")
-LANGOPT(CUDATargetOverloads, 1, 0, "Enable function overloads based on CUDA 
target attributes")
 LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "Allow variadic functions in CUDA 
device code")
 
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for 
C++'s new operators")

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=264739=264738=264739=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Mar 29 11:24:16 2016
@@ -687,16 +687,8 @@ def cl_denorms_are_zero : Flag<["-"], "c
 
 def fcuda_is_device : Flag<["-"], "fcuda-is-device">,
   HelpText<"Generate code for CUDA device">;
-def fcuda_allow_host_calls_from_host_device : Flag<["-"],
-"fcuda-allow-host-calls-from-host-device">,
-  HelpText<"Allow host device functions to call host functions">;
-def fcuda_disable_target_call_checks : Flag<["-"],
-"fcuda-disable-target-call-checks">,
-  HelpText<"Disable all cross-target (host, device, etc.) call checks in 
CUDA">;
 def fcuda_include_gpubinary : Separate<["-"], "fcuda-include-gpubinary">,
   HelpText<"Incorporate CUDA device-side binary into host object file.">;
-def fcuda_target_overloads : Flag<["-"], "fcuda-target-overloads">,
-  HelpText<"Enable function overloads based on CUDA target attributes.">;
 def fcuda_allow_variadic_functions : Flag<["-"], 
"fcuda-allow-variadic-functions">,
   HelpText<"Allow variadic functions in CUDA device code.">;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=264739=264738=264739=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 29 11:24:16 2016
@@ -8892,7 +8892,11 @@ public:
   CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller,
 const FunctionDecl *Callee);
 
-  bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee);
+  /// Determines whether Caller may invoke Callee, based on their CUDA
+  /// host/device attributes.  Returns true if the call is not allowed.
+  bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee) 
{
+return 

r264741 - [CUDA] Fix order of overloading preferences in comment.

2016-03-29 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Mar 29 11:24:22 2016
New Revision: 264741

URL: http://llvm.org/viewvc/llvm-project?rev=264741=rev
Log:
[CUDA] Fix order of overloading preferences in comment.

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

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=264741=264740=264741=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Mar 29 11:24:22 2016
@@ -68,7 +68,7 @@ Sema::CUDAFunctionTarget Sema::IdentifyC
 // Ph - preference in host mode
 // Pd - preference in device mode
 // H  - handled in (x)
-// Preferences: N:native, HD:host-device, SS:same side, WS:wrong side, 
--:never.
+// Preferences: N:native, SS:same side, HD:host-device, WS:wrong side, 
--:never.
 //
 // | F  | T  | Ph  | Pd  |  H  |
 // |++-+-+-+


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


r264742 - [CUDA] Add missing #undef __DEVICE__ to CUDA shim header.

2016-03-29 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Mar 29 11:24:23 2016
New Revision: 264742

URL: http://llvm.org/viewvc/llvm-project?rev=264742=rev
Log:
[CUDA] Add missing #undef __DEVICE__ to CUDA shim header.

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=264742=264741=264742=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Tue Mar 29 11:24:23 2016
@@ -194,4 +194,6 @@ using ::trunc;
 
 } // namespace std
 
+#undef __DEVICE__
+
 #endif


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


Re: [PATCH] D17142: SystemZ: Check required features when handling builtins

2016-03-29 Thread Ulrich Weigand via cfe-commits
uweigand added a comment.

> This patch has been reworked, and aims to specify which features systemz 
> builtins require. The way of doing this has been taken from the X86 Target 
> (with a '#define TARGET_BUILTIN')

> 

> If a builtin is used by the programmer for a target that does not include a 
> required feature, the FE will abort early with an error message.

>  This includes vector and transactional memory builtins.


Ah, very nice.

> Three new tests: One for z13, which pass, and two for the generic target, 
> which are supposed to fail (therefore I put them in separate files). The 
> correct error messages are generated by clang, and recognized by Filecheck, 
> but the tests are still reported as failing. I am not sure what to do to get 
> around this, and would appreciate a hint on this. I tried expected-error{{}}, 
> but that did not work.


In order to use expected-error, you have to build with -verify.  See e.g. 
tools/clang/test/CodeGen/target-builtin-error.c


http://reviews.llvm.org/D17142



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

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

Looks good.



Comment at: include/clang/Tooling/Refactoring.h:93
@@ +92,3 @@
+///
+/// See also "clang/Tooling/Core/Replacements.h".
+bool formatAndApplyAllReplacements(const Replacements ,

See also for what? Maybe just remove?


Comment at: include/clang/Tooling/Refactoring.h:95
@@ +94,3 @@
+bool formatAndApplyAllReplacements(const Replacements ,
+   Rewriter , StringRef Style);
+

Maybe Style should default to "file".


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51933.
ioeric added a comment.

- Change the Style parameter of formatAndApplyReplacements from FormatStyle to 
be a Style name string.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,39 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(
+  Replaces, Context.Rewrite, "{BasedOnStyle: LLVM, ColumnLimit: 20}"));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +460,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -30,6 +30,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11234,7 +11234,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -61,5 +62,29 @@
   return Rewrite.overwriteChangedFiles() ? 1 : 0;
 }
 
+bool formatAndApplyAllReplacements(const Replacements ,
+   Rewriter , StringRef Style) {
+  SourceManager  = Rewrite.getSourceMgr();
+  FileManager  = SM.getFileManager();
+
+  auto FileToReplaces = groupReplacementsByFile(Replaces);
+
+  bool Result = true;
+  for (auto  : FileToReplaces) {
+const std::string FilePath = FileAndReplaces.first;
+auto  = FileAndReplaces.second;
+
+const FileEntry *Entry = Files.getFile(FilePath);
+ 

Re: [PATCH] D12192: Add clang support for AAP

2016-03-29 Thread Edward Jones via cfe-commits
edward-jones updated this revision to Diff 51932.
edward-jones added a comment.

This rolls AAP forward to top-of-tree.


http://reviews.llvm.org/D12192

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Headers/float.h

Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -79,7 +79,14 @@
 /* Characteristics of floating point types, C99 5.2.4.2.2 */
 
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#define FLT_ROUNDS (__builtin_flt_rounds())
+
+/* __builtin_flt_rounds is not supported by AAP, and the rounding mode cannot
+   be changed anyway so we just default to 'to nearest' */
+#ifdef __AAP__
+  #define FLT_ROUNDS 1
+#else
+  #define FLT_ROUNDS (__builtin_flt_rounds())
+#endif
 #define FLT_RADIX __FLT_RADIX__
 
 #define FLT_MANT_DIG __FLT_MANT_DIG__
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -60,6 +60,8 @@
const InputInfoList ,
const ToolChain *AuxToolChain) const;
 
+  void AddAAPTargetArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const;
   void AddAArch64TargetArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
   void AddARMTargetArgs(const llvm::Triple ,
@@ -940,6 +942,34 @@
 
 }  // end namespace NVPTX
 
+namespace AAP {
+  class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
+  public:
+Assemble(const ToolChain ) : Tool("AAP::Assemble", "aap-as", TC)
+{}
+
+bool hasIntegratedCPP() const override { return false; }
+void ConstructJob(Compilation , const JobAction ,
+  const InputInfo ,
+  const InputInfoList ,
+  const llvm::opt::ArgList ,
+  const char *LinkingOutput) const override;
+  };
+  class LLVM_LIBRARY_VISIBILITY Link : public Tool {
+  public:
+Link(const ToolChain ) : Tool("AAP::Link", "aap-ld", TC)
+{}
+
+bool hasIntegratedCPP() const override { return false; }
+bool isLinkJob() const override { return true; }
+void ConstructJob(Compilation , const JobAction ,
+  const InputInfo ,
+  const InputInfoList ,
+  const llvm::opt::ArgList ,
+  const char *LinkingOutput) const override;
+  };
+} // end namespace AAP
+
 } // end namespace tools
 } // end namespace driver
 } // end namespace clang
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2178,6 +2178,11 @@
   }
 }
 
+void Clang::AddAAPTargetArgs(const ArgList ,
+ ArgStringList ) const {
+  return;
+}
+
 void Clang::AddWebAssemblyTargetArgs(const ArgList ,
  ArgStringList ) const {
   // Default to "hidden" visibility.
@@ -3029,8 +3034,10 @@
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::aap:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
+// AAP never wants frame pointers
 return false;
   default:
 break;
@@ -4172,6 +4179,10 @@
   default:
 break;
 
+  case llvm::Triple::aap:
+AddAAPTargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
@@ -11016,3 +11027,71 @@
   const char *Exec = Args.MakeArgString(TC.GetProgramPath("fatbinary"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
+
+void AAP::Assemble::ConstructJob(Compilation , const JobAction ,
+ const InputInfo ,
+ const InputInfoList ,
+ const ArgList ,
+ const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  // Add input assembly files to command line
+  for (InputInfoList::const_iterator it = Inputs.begin(), ie = Inputs.end();
+   it != ie;
+   ++it) {
+const InputInfo  = *it;
+CmdArgs.push_back(II.getFilename());
+  }
+
+  const char *Exec =
+Args.MakeArgString(getToolChain().GetProgramPath("aap-as"));
+
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+}
+
+void AAP::Link::ConstructJob(Compilation , const JobAction ,
+ const InputInfo ,
+ const InputInfoList ,
+ const ArgList ,
+ const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  // Add crt0 and libc
+  const toolchains::AAP& ToolChain =
+static_cast(getToolChain());
+  const Driver  = 

Re: [PATCH] D18253: [AMDGPU] Switch linker to amdphdrs + update test

2016-03-29 Thread Konstantin Zhuravlyov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264737: [AMDGPU] Switch linker to amdphdrs + update test 
(authored by kzhuravl).

Changed prior to commit:
  http://reviews.llvm.org/D18253?vs=50975=51930#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18253

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/amdgpu-toolchain.c

Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: ld.lld{{.*}}
+// AS_LINK: amdphdrs{{.*}}
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -242,7 +242,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6751,7 +6751,6 @@
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
-  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
   CmdArgs, Inputs));


Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: ld.lld{{.*}}
+// AS_LINK: amdphdrs{{.*}}
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -242,7 +242,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6751,7 +6751,6 @@
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
-  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
   CmdArgs, Inputs));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r264737 - [AMDGPU] Switch linker to amdphdrs + update test

2016-03-29 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Tue Mar 29 10:54:09 2016
New Revision: 264737

URL: http://llvm.org/viewvc/llvm-project?rev=264737=rev
Log:
[AMDGPU] Switch linker to amdphdrs + update test

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=264737=264736=264737=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Mar 29 10:54:09 2016
@@ -6751,7 +6751,6 @@ void amdgpu::Linker::ConstructJob(Compil
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
-  CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
   CmdArgs, Inputs));

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=264737=264736=264737=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Tue Mar 29 10:54:09 2016
@@ -242,7 +242,7 @@ namespace amdgpu {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "amdphdrs", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=264737=264736=264737=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Tue Mar 29 10:54:09 2016
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: ld.lld{{.*}}
+// AS_LINK: amdphdrs{{.*}}


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


Re: [PATCH] D18408: readability check for const params in declarations

2016-03-29 Thread Matt Kulukundis via cfe-commits
fowles added a comment.

ping?


http://reviews.llvm.org/D18408



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


Re: [PATCH] D18475: [clang-tidy] Add more detection rules for redundant c_str calls.

2016-03-29 Thread Etienne Bergeron via cfe-commits
etienneb marked an inline comment as done.
etienneb added a comment.

thanks, aaron.ballman@.



Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:129
@@ +128,3 @@
+  // Detect: 'dst += str.c_str()'  ->  'dst += str'
+  // Detect: 's == str.c_str()'  ->  's == str'
+  Finder->addMatcher(

aaron.ballman wrote:
> I think this comment is incorrect, you want assignment, not equality.
copy-paste! Good catch.


http://reviews.llvm.org/D18475



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


Re: [PATCH] D18475: [clang-tidy] Add more detection rules for redundant c_str calls.

2016-03-29 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51927.
etienneb added a comment.

fix invalid comment.


http://reviews.llvm.org/D18475

Files:
  clang-tidy/readability/RedundantStringCStrCheck.cpp
  test/clang-tidy/readability-redundant-string-cstr.cpp

Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -1,22 +1,60 @@
-// RUN: %check_clang_tidy %s readability-redundant-string-cstr %t -- -- -target x86_64-unknown -std=c++11
+// RUN: %check_clang_tidy %s readability-redundant-string-cstr %t -- -- -std=c++11
+
+typedef unsigned __INT16_TYPE__ char16;
+typedef unsigned __INT32_TYPE__ char32;
+typedef __SIZE_TYPE__ size;
 
 namespace std {
 template 
 class allocator {};
 template 
 class char_traits {};
 template 
 struct basic_string {
+  typedef basic_string _Type;
   basic_string();
   basic_string(const C *p, const A  = A());
+
   const C *c_str() const;
+
+  _Type& append(const C *s);
+  _Type& append(const C *s, size n);
+  _Type& assign(const C *s);
+  _Type& assign(const C *s, size n);
+
+  int compare(const _Type&) const;
+  int compare(const C* s) const;
+  int compare(size pos, size len, const _Type&) const;
+  int compare(size pos, size len, const C* s) const;
+
+  size find(const _Type& str, size pos = 0) const;
+  size find(const C* s, size pos = 0) const;
+  size find(const C* s, size pos, size n) const;
+
+  _Type& insert(size pos, const _Type& str);
+  _Type& insert(size pos, const C* s);
+  _Type& insert(size pos, const C* s, size n);
+
+  _Type& operator+=(const _Type& str);
+  _Type& operator+=(const C* s);
+  _Type& operator=(const _Type& str);
+  _Type& operator=(const C* s);
 };
+
 typedef basic_string string;
 typedef basic_string wstring;
-typedef basic_string u16string;
-typedef basic_string u32string;
+typedef basic_string u16string;
+typedef basic_string u32string;
 }
 
+std::string operator+(const std::string&, const std::string&);
+std::string operator+(const std::string&, const char*);
+std::string operator+(const char*, const std::string&);
+
+bool operator==(const std::string&, const std::string&);
+bool operator==(const std::string&, const char*);
+bool operator==(const char*, const std::string&);
+
 namespace llvm {
 struct StringRef {
   StringRef(const char *p);
@@ -51,6 +89,80 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(*ptr);{{$}}
 }
+void f5(const std::string ) {
+  std::string tmp;
+  tmp.append(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp.append(s);{{$}}
+  tmp.assign(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp.assign(s);{{$}}
+
+  if (tmp.compare(s.c_str()) == 0) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp.compare(s) == 0) return;{{$}}
+
+  if (tmp.compare(1, 2, s.c_str()) == 0) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp.compare(1, 2, s) == 0) return;{{$}}
+
+  if (tmp.find(s.c_str()) == 0) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp.find(s) == 0) return;{{$}}
+
+  if (tmp.find(s.c_str(), 2) == 0) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp.find(s, 2) == 0) return;{{$}}
+
+  if (tmp.find(s.c_str(), 2) == 0) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp.find(s, 2) == 0) return;{{$}}
+
+  tmp.insert(1, s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp.insert(1, s);{{$}}
+
+  tmp = s.c_str();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp = s;{{$}}
+
+  tmp += s.c_str();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp += s;{{$}}
+
+  if (tmp == s.c_str()) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}if (tmp == s) return;{{$}}
+
+  tmp = s + s.c_str();
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp = s + s;{{$}}
+
+  tmp = s.c_str() + s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}tmp = s + s;{{$}}
+}
+void f6(const std::string ) {
+  

Re: [PATCH] D18396: Clang-tidy:modernize-use-override. Fix for __declspec attributes and const=0 without spacse

2016-03-29 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: test/clang-tidy/modernize-use-override-ms.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t
+

I *think* this run line may require -fms-extensions in order to compile under 
non-MSVC-built versions of clang because of the __declspec.


http://reviews.llvm.org/D18396



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Tooling/Refactoring.h:91
@@ +90,3 @@
+   Rewriter ,
+   const format::FormatStyle );
+

ioeric wrote:
> djasper wrote:
> > Do you have a use case where we'd want to call this with a fixed style? 
> > Otherwise, I'd just remove this function for now.
> If the .clang-format doesn't exist, it can only fall back to one default 
> style, which is LLVM now. Shouldn't users have the flexibility to specify 
> other styles if there is no .clang-format file?   
I am not sure, but I usually like to keep interfaces small until we have actual 
use cases. It is very hard to foresee in what ways this can possibly be used. 
An alternative might be to hand in the style as a string which is similar to 
what clang-format takes on the command line. Then people can supply "file", 
"Google", ... and we can hand that to getStyle().


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Eric Liu via cfe-commits
ioeric marked an inline comment as done.


Comment at: include/clang/Tooling/Refactoring.h:91
@@ +90,3 @@
+   Rewriter ,
+   const format::FormatStyle );
+

djasper wrote:
> Do you have a use case where we'd want to call this with a fixed style? 
> Otherwise, I'd just remove this function for now.
If the .clang-format doesn't exist, it can only fall back to one default style, 
which is LLVM now. Shouldn't users have the flexibility to specify other styles 
if there is no .clang-format file?   


http://reviews.llvm.org/D17852



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


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

2016-03-29 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


http://reviews.llvm.org/D17955



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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

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

LG, apart from small comments mentioned here.



Comment at: lib/AST/ASTContext.cpp:7613
@@ +7612,3 @@
+if (getLangOpts().OpenCL) {
+  if (LHS.getUnqualifiedType() != RHS.getUnqualifiedType() ||
+  LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers())

> Here if unqualified types are different 

I think this check is redundant considering that we make check of canonical 
types equivalence in line 7605. Also it doesn't really have anything to do with 
any OpenCL specific rule. Therefore I would remove this check and just merge 
with lines 7623 - 7624 as much as possible.

> or CVS qualifiers are different, the two types cannot be merged

The same is already being checked in line 7623. Could we merge with that code?




Comment at: lib/Sema/SemaExpr.cpp:6171
@@ +6170,3 @@
+  //  (b) AS overlap => generate addrspacecast
+  //  (c) As don't overlap => give an error
+  // 2. if LHS and RHS types don't match:

As -> AS


Comment at: lib/Sema/SemaExpr.cpp:6186
@@ +6185,3 @@
+  // spaces is disallowed.
+  // OpenCL v2.0 s6.5.6 - Clause 6.5.15 Conditional operator, add another
+  // constraint paragraph: If the second and third operands are pointers

Could you remove "Conditional operator, add another constraint paragraph: "


Comment at: lib/Sema/SemaExpr.cpp:6190
@@ +6189,3 @@
+  unsigned ResultAddrSpace;
+  if (lhQual.isAddressSpaceSupersetOf(rhQual)) {
+ResultAddrSpace = lhQual.getAddressSpace();

Could you add a comment referring to the case from 1(a-c)&2(a-c) you are 
handling here!


Comment at: lib/Sema/SemaExpr.cpp:6229
@@ +6228,3 @@
+  else {
+auto ResultAddrSpace = ResultTy.getQualifiers().getAddressSpace();
+LHSCastKind = lhQual.getAddressSpace() == ResultAddrSpace

The same here - could you add a comment explaining the case from 1(a-c)&2(a-c) 
being handled!


Comment at: test/CodeGenOpenCL/address-spaces-conversions.cl:1
@@ -1,2 +1,2 @@
 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 
-ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s
 

Cool, thanks! Could you insert a link to the new review here if possible.


Comment at: test/CodeGenOpenCL/address-spaces-conversions.cl:37
@@ -22,1 +36,2 @@
+  // CHECK: %{{[0-9]+}} = addrspacecast float addrspace(1)* %{{[0-9]+}} to i8 
addrspace(4)*
 }

Could we also add case 1a and 2a to test that we don't affect standard cases.


Comment at: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl:231
@@ +230,3 @@
+  AS int *var_cond;
+  generic int *arg_gen;
+  global int *arg_glob;

arg_gen -> var_gen
arg_glob -> var_glob



Comment at: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl:262
@@ +261,3 @@
+  void *var_void_gen;
+  global char *arg_glob_ch;
+  var_void_gen = 0 ? var_cond : arg_glob_ch;

I think you should change all arg to var in the name as it mean argument, but 
it's just a variable now.


Comment at: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl:276
@@ +275,3 @@
+  constant char *arg_const_ch;
+  var_void_const = 0 ? var_cond : arg_const_ch;
+#ifndef CONSTANT

btw, what happens if we assign into non void* var? Do we get another error?


http://reviews.llvm.org/D17412



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


Re: [PATCH] D17142: SystemZ: Check required features when handling builtins

2016-03-29 Thread Jonas Paulsson via cfe-commits
jonpa retitled this revision from "SystemZ: Check that argument -fzvector is 
only given for -z13" to "SystemZ: Check required features when handling 
builtins".
jonpa updated the summary for this revision.
jonpa updated this revision to Diff 51910.
jonpa added a comment.

This patch has been reworked, and aims to specify which features systemz 
builtins require. The way of doing this has been taken from the X86 Target 
(with a '#define TARGET_BUILTIN')

If a builtin is used by the programmer for a target that does not include a 
required feature, the FE will abort early with an error message.
This includes vector and transactional memory builtins.

Three new tests: One for z13, which pass, and two for the generic target, which 
are supposed to fail (therefore I put them in separate files). The correct 
error messages are generated by clang, and recognized by Filecheck, but the 
tests are still reported as failing. I am not sure what to do to get around 
this, and would appreciate a hint on this. I tried expected-error{{}}, but that 
did not work.


http://reviews.llvm.org/D17142

Files:
  include/clang/Basic/BuiltinsSystemZ.def
  lib/Basic/Targets.cpp
  test/CodeGen/builtins-systemz-generic0.c
  test/CodeGen/builtins-systemz-generic1.c
  test/CodeGen/builtins-systemz-tbegin.c

Index: test/CodeGen/builtins-systemz-tbegin.c
===
--- /dev/null
+++ test/CodeGen/builtins-systemz-tbegin.c
@@ -0,0 +1,9 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -triple s390x-ibm-linux -Wall -Wno-unused -Werror \
+// RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s
+
+void f1() {
+// CHECK-NOT: call i32 @llvm.s390.tbegin
+  __builtin_tbegin ((void *)0); // expected-error{{error: '__builtin_tbegin' needs target feature transactional-execution}}
+}
+
Index: test/CodeGen/builtins-systemz-generic1.c
===
--- /dev/null
+++ test/CodeGen/builtins-systemz-generic1.c
@@ -0,0 +1,10 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -triple s390x-ibm-linux -Wall -Wno-unused -Werror \
+// RUN: -emit-llvm %s -o - 2>&1 | FileCheck --check-prefix=CHECK-GENERIC %s
+
+void f1() {
+// CHECK-LABEL: f1
+// CHECK-GENERIC: error: '__builtin_tbegin' needs target feature transactional-execution
+  __builtin_tbegin ((void *)0);
+}
+
Index: test/CodeGen/builtins-systemz-generic0.c
===
--- /dev/null
+++ test/CodeGen/builtins-systemz-generic0.c
@@ -0,0 +1,12 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -triple s390x-ibm-linux -Wall -Wno-unused -Werror \
+// RUN: -emit-llvm %s -o - 2>&1 | FileCheck --check-prefix=CHECK-GENERIC %s
+
+typedef __attribute__((vector_size(16))) char v16i8;
+
+v16i8 f0(v16i8 a, v16i8 b) {
+// CHECK-LABEL: f0
+// CHECK-GENERIC: error: '__builtin_s390_vaq' needs target feature vector
+  v16i8 tmp = __builtin_s390_vaq(a, b);
+  return tmp;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6383,6 +6383,8 @@
 const Builtin::Info SystemZTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE },
 #include "clang/Basic/BuiltinsSystemZ.def"
 };
 
Index: include/clang/Basic/BuiltinsSystemZ.def
===
--- include/clang/Basic/BuiltinsSystemZ.def
+++ include/clang/Basic/BuiltinsSystemZ.def
@@ -14,239 +14,244 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // Transactional-memory intrinsics
-BUILTIN(__builtin_tbegin, "iv*", "j")
-BUILTIN(__builtin_tbegin_nofloat, "iv*", "j")
-BUILTIN(__builtin_tbeginc, "v", "nj")
-BUILTIN(__builtin_tabort, "vi", "r")
-BUILTIN(__builtin_tend, "i", "n")
-BUILTIN(__builtin_tx_nesting_depth, "i", "nc")
-BUILTIN(__builtin_tx_assist, "vi", "n")
-BUILTIN(__builtin_non_tx_store, "vULi*ULi", "")
+TARGET_BUILTIN(__builtin_tbegin, "iv*", "j", "transactional-execution")
+TARGET_BUILTIN(__builtin_tbegin_nofloat, "iv*", "j", "transactional-execution")
+TARGET_BUILTIN(__builtin_tbeginc, "v", "nj", "transactional-execution")
+TARGET_BUILTIN(__builtin_tabort, "vi", "r", "transactional-execution")
+TARGET_BUILTIN(__builtin_tend, "i", "n", "transactional-execution")
+TARGET_BUILTIN(__builtin_tx_nesting_depth, "i", "nc", "transactional-execution")
+TARGET_BUILTIN(__builtin_tx_assist, "vi", "n", "transactional-execution")
+TARGET_BUILTIN(__builtin_non_tx_store, "vULi*ULi", "", "transactional-execution")
 
 // Vector intrinsics.
 

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-29 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Tooling/Refactoring.h:91
@@ +90,3 @@
+   Rewriter ,
+   const format::FormatStyle );
+

Do you have a use case where we'd want to call this with a fixed style? 
Otherwise, I'd just remove this function for now.


Comment at: include/clang/Tooling/Refactoring.h:93
@@ +92,3 @@
+
+/// \brief Groups \p Replaces by the file path and applies each group of
+/// Replacements on the related file in \p Rewriter. In addition to applying

Don't copy the comment for the function. It is bound to go out of sync and 
makes users wonder what the actual differences are. Put this function first and 
replace "Instead of .." with "This function use the filename stored in the 
replacements to determine the appropriate style.".

Then in the comment to the other just write: "/// Same as above but use fixed 
style \p Style."


http://reviews.llvm.org/D17852



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-03-29 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51906.
baloghadamsoftware added a comment.

Requested fixes done (not related to the changes).


http://reviews.llvm.org/D18265

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/misc/AssignOperatorCheck.cpp
  clang-tidy/misc/AssignOperatorCheck.h
  clang-tidy/misc/AssignOperatorSignatureCheck.cpp
  clang-tidy/misc/AssignOperatorSignatureCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-assign-operator-signature.rst
  docs/clang-tidy/checks/misc-assign-operator.rst
  test/clang-tidy/misc-assign-operator-signature.cpp
  test/clang-tidy/misc-assign-operator.cpp

Index: test/clang-tidy/misc-assign-operator.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-assign-operator.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s misc-assign-operator %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include 
+
+struct Good {
+  Good& operator=(const Good&);
+  Good& operator=(Good&&);
+
+  // Assign from other types is fine too.
+  Good& operator=(int);
+};
+
+struct AlsoGood {
+  // By value is also fine.
+  AlsoGood& operator=(AlsoGood);
+};
+
+struct BadReturnType {
+  void operator=(const BadReturnType&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturnType&' [misc-assign-operator]
+  const BadReturnType& operator=(BadReturnType&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+  void operator=(int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+};
+
+struct BadReturnType2 {
+  BadReturnType2&& operator=(const BadReturnType2&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+  int operator=(BadReturnType2&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+};
+
+struct BadArgument {
+  BadArgument& operator=(BadArgument&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
+  BadArgument& operator=(const BadArgument&&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr
+};
+
+struct BadModifier {
+  BadModifier& operator=(const BadModifier&) const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const'
+};
+
+struct Deleted {
+  // We don't check the return value of deleted operators.
+  void operator=(const Deleted&) = delete;
+  void operator=(Deleted&&) = delete;
+};
+
+class Private {
+  // We don't check the return value of private operators.
+  // Pre-C++11 way of disabling assignment.
+  void operator=(const Private &);
+};
+
+struct Virtual {
+  virtual Virtual& operator=(const Virtual &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'virtual'
+};
+
+class BadReturnStatement {
+  int n;
+
+public:
+  BadReturnStatement& operator=(const BadReturnStatement& rhs) {
+n = rhs.n;
+return *this;
+  }
+
+  BadReturnStatement& operator=(BadReturnStatement&& rhs) {
+n = std::move(rhs.n);
+return rhs;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
+  }
+
+  // Do not check if return type is different from ''
+  int operator=(int i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+n = i;
+return n;
+  }
+};
Index: test/clang-tidy/misc-assign-operator-signature.cpp
===
--- test/clang-tidy/misc-assign-operator-signature.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %check_clang_tidy %s misc-assign-operator-signature %t
-
-struct Good {
-  Good& operator=(const Good&);
-  Good& operator=(Good&&);
-
-  // Assign from other types is fine too.
-  Good& operator=(int);
-};
-
-struct AlsoGood {
-  // By value is also fine.
-  AlsoGood& operator=(AlsoGood);
-};
-
-struct BadReturn {
-  void operator=(const BadReturn&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturn&' [misc-assign-operator-signature]
-  const BadReturn& operator=(BadReturn&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-  void operator=(int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-struct BadReturn2 {
-  BadReturn2&& operator=(const BadReturn2&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-  int operator=(BadReturn2&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-
-struct BadArgument {
-  BadArgument& operator=(BadArgument&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
-  BadArgument& operator=(const BadArgument&&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should 

Re: [PATCH] D18396: Clang-tidy:modernize-use-override. Fix for __declspec attributes and const=0 without spacse

2016-03-29 Thread Robert Bolter via cfe-commits
Rob updated this revision to Diff 51904.
Rob added a comment.

Update to address review.
Clang-format applied and nit fixed.


http://reviews.llvm.org/D18396

Files:
  clang-tidy/modernize/UseOverrideCheck.cpp
  test/clang-tidy/modernize-use-override-ms.cpp
  test/clang-tidy/modernize-use-override.cpp

Index: test/clang-tidy/modernize-use-override.cpp
===
--- test/clang-tidy/modernize-use-override.cpp
+++ test/clang-tidy/modernize-use-override.cpp
@@ -21,6 +21,7 @@
   virtual void d2();
   virtual void e() = 0;
   virtual void f() = 0;
+  virtual void f2() const = 0;
   virtual void g() = 0;
 
   virtual void j() const;
@@ -74,7 +75,11 @@
 
   virtual void f()=0;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void f()override =0;
+  // CHECK-FIXES: {{^}}  void f() override =0;
+
+  virtual void f2() const=0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void f2() const override =0;
 
   virtual void g() ABSTRACT;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
Index: test/clang-tidy/modernize-use-override-ms.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-override-ms.cpp
@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t
+
+// This attribute type is inherited and precedes the declaration
+#define EXPORT __declspec(dllexport)
+
+class EXPORT ExpBaseMacro {
+  virtual void a();
+};
+
+class __declspec(dllexport) ExpBase {
+  virtual void a();
+};
+
+class BaseMacro {
+  virtual EXPORT void a();
+};
+
+class Base {
+  virtual __declspec(dllexport) void a();
+};
+
+
+class EXPORT ExpDerivedMacro : public ExpBaseMacro {
+  virtual void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
+  // CHECK-FIXES: {{^}}  void a() override;
+};
+
+class __declspec(dllexport) ExpDerived : public ExpBase {
+  virtual void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void a() override;
+};
+
+class DerivedMacro : public BaseMacro {
+  virtual EXPORT void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer using
+  // CHECK-FIXES: {{^}}  EXPORT void a() override;
+};
+
+class Derived : public Base {
+  virtual __declspec(dllexport) void a();
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: prefer using
+  // CHECK-FIXES: {{^}}  __declspec(dllexport) void a() override;
+};
Index: clang-tidy/modernize/UseOverrideCheck.cpp
===
--- clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tidy/modernize/UseOverrideCheck.cpp
@@ -95,9 +95,9 @@
: "'override' is";
 StringRef Correct = HasFinal ? "'final'" : "'override'";
 
-Message =
-(llvm::Twine(Redundant) +
- " redundant since the function is already declared " + Correct).str();
+Message = (llvm::Twine(Redundant) +
+   " redundant since the function is already declared " + Correct)
+  .str();
   }
 
   DiagnosticBuilder Diag = diag(Method->getLocation(), Message);
@@ -118,21 +118,24 @@
   if (!HasFinal && !HasOverride) {
 SourceLocation InsertLoc;
 StringRef ReplacementText = "override ";
+SourceLocation MethodLoc = Method->getLocation();
 
 for (Token T : Tokens) {
-  if (T.is(tok::kw___attribute)) {
+  if (T.is(tok::kw___attribute) &&
+  !Sources.isBeforeInTranslationUnit(T.getLocation(), MethodLoc)) {
 InsertLoc = T.getLocation();
 break;
   }
 }
 
 if (Method->hasAttrs()) {
   for (const clang::Attr *A : Method->getAttrs()) {
-if (!A->isImplicit()) {
+if (!A->isImplicit() && !A->isInherited()) {
   SourceLocation Loc =
   Sources.getExpansionLoc(A->getRange().getBegin());
-  if (!InsertLoc.isValid() ||
-  Sources.isBeforeInTranslationUnit(Loc, InsertLoc))
+  if ((!InsertLoc.isValid() ||
+   Sources.isBeforeInTranslationUnit(Loc, InsertLoc)) &&
+  !Sources.isBeforeInTranslationUnit(Loc, MethodLoc))
 InsertLoc = Loc;
 }
   }
@@ -163,6 +166,9 @@
 Tokens.back().is(tok::kw_delete)) &&
   GetText(Tokens[Tokens.size() - 2], Sources) == "=") {
 InsertLoc = Tokens[Tokens.size() - 2].getLocation();
+// Check if we need to insert a space.
+if ((Tokens[Tokens.size() - 2].getFlags() & Token::LeadingSpace) == 0)
+  ReplacementText = " override ";
   } else if (GetText(Tokens.back(), Sources) == "ABSTRACT") {
 InsertLoc = Tokens.back().getLocation();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-03-29 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

After applying replacements, redundant code like extra commas or empty 
namespaces
might be introduced. Fixer can detect and remove any redundant code introduced 
by replacements.
The current implementation only handles redundant commas.

http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11233,6 +11233,117 @@
 
 #endif // _MSC_VER
 
+class FixTest : public ::testing::Test {
+protected:
+  std::string fix(llvm::StringRef Code,
+  const std::vector ,
+  const FormatStyle  = getLLVMStyle()) {
+DEBUG(llvm::errs() << "---\n");
+DEBUG(llvm::errs() << Code << "\n\n");
+tooling::Replacements Replaces = format::fix(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+DEBUG(llvm::errs() << "\n" << Result << "\n\n");
+return Result;
+  }
+};
+
+TEST_F(FixTest, CtorInitializationSimpleRedundantComma) {
+  std::string Code = "class A {\nA() : , {} };";
+  std::string Expected = "class A {\nA()   {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(17, 0));
+  Ranges.push_back(tooling::Range(19, 0));
+  std::string Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1) {} };";
+  Ranges.clear();
+  Ranges.push_back(tooling::Range(23, 0));
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, CtorInitializationBracesInParens) {
+  std::string Code = "class A {\nA() : x({1}),, {} };";
+  std::string Expected = "class A {\nA() : x({1}) {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(24, 0));
+  Ranges.push_back(tooling::Range(26, 0));
+  std::string Result = fix(Code, Ranges);
+  DEBUG(llvm::errs() << "\n" << Result << "\n");
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, RedundantCommaNotInAffectedRanges) {
+  std::string Code =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  std::string Expected =
+  "class A {\nA() : x({1}), /* comment */, { int x = 0; } };";
+  // Set the affected range to be "int x = 0", which does not intercept the
+  // constructor initialization list.
+  std::vector Ranges(1, tooling::Range(42, 9));
+  std::string Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  Code = "class A {\nA() : x(1), {} };";
+  Expected = "class A {\nA() : x(1), {} };";
+  // No range. Fixer should do nothing.
+  Ranges.clear();
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, CtorInitializationCommentAroundCommas) {
+  // Remove redundant commas and comment between them.
+  std::string Code = "class A {\nA() : x({1}), /* comment */, {} };";
+  std::string Expected = "class A {\nA() : x({1})  {} };";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(25, 0));
+  Ranges.push_back(tooling::Range(40, 0));
+  std::string Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and comment.
+  Code = "class A {\nA() : x({1}), // comment\n{} };";
+  Expected = "class A {\nA() : x({1}) \n{} };";
+  Ranges = std::vector(1, tooling::Range(25, 0));
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma, but leave the comment.
+  Code = "class A {\nA() : x({1}), // comment\n , y(1),{} };";
+  Expected = "class A {\nA() : x({1}), // comment\n  y(1){} };";
+  Ranges = std::vector(1, tooling::Range(38, 0));
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and the comment before it.
+  Code = "class A {\nA() : x({1}), \n/* comment */, y(1),{} };";
+  Expected = "class A {\nA() : x({1}), \n y(1){} };";
+  Ranges = std::vector(1, tooling::Range(40, 0));
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+
+  // Remove trailing comma and the comment after it.
+  Code = "class A {\nA() : , // comment\n y(1),{} };";
+  Expected = "class A {\nA() :  \n y(1){} };";
+  Ranges = std::vector(1, tooling::Range(17, 0));
+  Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, SkipImbalancedParentheses) {
+  std::string Code = "class A {\nA() : x((),, {} };";
+  std::string Expected = "class A {\nA() : x((),, {} };";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = fix(Code, Ranges);
+  DEBUG(llvm::errs() << "\n" << Result << "\n");
+  EXPECT_EQ(Expected, Result);
+}
+
 class ReplacementTest : public ::testing::Test {
 protected:
   tooling::Replacement createReplacement(SourceLocation Start, 

Re: [PATCH] D18274: [clang-tidy] Add boost module

2016-03-29 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

I was planning to do so. Can you look at
http://reviews.llvm.org/D18136 ?


http://reviews.llvm.org/D18274



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


r264727 - Add additional Hi/Lo registers to Clang MipsTargetInfoBase

2016-03-29 Thread Hrvoje Varga via cfe-commits
Author: hvarga
Date: Tue Mar 29 07:46:16 2016
New Revision: 264727

URL: http://llvm.org/viewvc/llvm-project?rev=264727=rev
Log:
Add additional Hi/Lo registers to Clang MipsTargetInfoBase
Differential Revision: http://reviews.llvm.org/D17378

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/mips-inline-asm.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=264727=264726=264727=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 29 07:46:16 2016
@@ -6899,7 +6899,8 @@ public:
   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
   // Hi/lo and condition register names
   "hi",   "lo",   "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
-  "$fcc5","$fcc6","$fcc7",
+  "$fcc5","$fcc6","$fcc7","$ac1hi","$ac1lo","$ac2hi","$ac2lo",
+  "$ac3hi","$ac3lo",
   // MSA register names
   "$w0",  "$w1",  "$w2",  "$w3",  "$w4",  "$w5",  "$w6",  "$w7",
   "$w8",  "$w9",  "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",

Modified: cfe/trunk/test/CodeGen/mips-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-inline-asm.c?rev=264727=264726=264727=diff
==
--- cfe/trunk/test/CodeGen/mips-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/mips-inline-asm.c Tue Mar 29 07:46:16 2016
@@ -17,3 +17,15 @@ void R () {
   asm("lw $1, %0" :: "R"(data));
   // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
 }
+
+int additionalClobberedRegisters () {
+  int temp0;
+  asm volatile(
+"mfhi %[temp0], $ac1 \n\t"
+  : [temp0]"="(temp0)
+  :
+  : "memory", "t0", "t1", "$ac1hi", "$ac1lo", "$ac2hi", 
"$ac2lo", "$ac3hi", "$ac3lo"
+  );
+  return 0;
+  // CHECK: call i32 asm sideeffect "mfhi $0, $$ac1 \0A\09", 
"=,~{memory},~{$8},~{$9},~{$ac1hi},~{$ac1lo},~{$ac2hi},~{$ac2lo},~{$ac3hi},~{$ac3lo},~{$1}"
+}


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


Re: [PATCH] D17378: Add additional Hi/Lo registers to Clang MipsTargetInfoBase

2016-03-29 Thread Hrvoje Varga via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264727: Add additional Hi/Lo registers to Clang 
MipsTargetInfoBase (authored by hvarga).

Changed prior to commit:
  http://reviews.llvm.org/D17378?vs=48309=51893#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17378

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/mips-inline-asm.c

Index: cfe/trunk/test/CodeGen/mips-inline-asm.c
===
--- cfe/trunk/test/CodeGen/mips-inline-asm.c
+++ cfe/trunk/test/CodeGen/mips-inline-asm.c
@@ -17,3 +17,15 @@
   asm("lw $1, %0" :: "R"(data));
   // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
 }
+
+int additionalClobberedRegisters () {
+  int temp0;
+  asm volatile(
+"mfhi %[temp0], $ac1 \n\t"
+  : [temp0]"="(temp0)
+  :
+  : "memory", "t0", "t1", "$ac1hi", "$ac1lo", "$ac2hi", 
"$ac2lo", "$ac3hi", "$ac3lo"
+  );
+  return 0;
+  // CHECK: call i32 asm sideeffect "mfhi $0, $$ac1 \0A\09", 
"=,~{memory},~{$8},~{$9},~{$ac1hi},~{$ac1lo},~{$ac2hi},~{$ac2lo},~{$ac3hi},~{$ac3lo},~{$1}"
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6899,7 +6899,8 @@
   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
   // Hi/lo and condition register names
   "hi",   "lo",   "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
-  "$fcc5","$fcc6","$fcc7",
+  "$fcc5","$fcc6","$fcc7","$ac1hi","$ac1lo","$ac2hi","$ac2lo",
+  "$ac3hi","$ac3lo",
   // MSA register names
   "$w0",  "$w1",  "$w2",  "$w3",  "$w4",  "$w5",  "$w6",  "$w7",
   "$w8",  "$w9",  "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",


Index: cfe/trunk/test/CodeGen/mips-inline-asm.c
===
--- cfe/trunk/test/CodeGen/mips-inline-asm.c
+++ cfe/trunk/test/CodeGen/mips-inline-asm.c
@@ -17,3 +17,15 @@
   asm("lw $1, %0" :: "R"(data));
   // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
 }
+
+int additionalClobberedRegisters () {
+  int temp0;
+  asm volatile(
+"mfhi %[temp0], $ac1 \n\t"
+  : [temp0]"="(temp0)
+  :
+  : "memory", "t0", "t1", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
+  );
+  return 0;
+  // CHECK: call i32 asm sideeffect "mfhi $0, $$ac1 \0A\09", "=,~{memory},~{$8},~{$9},~{$ac1hi},~{$ac1lo},~{$ac2hi},~{$ac2lo},~{$ac3hi},~{$ac3lo},~{$1}"
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6899,7 +6899,8 @@
   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
   // Hi/lo and condition register names
   "hi",   "lo",   "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
-  "$fcc5","$fcc6","$fcc7",
+  "$fcc5","$fcc6","$fcc7","$ac1hi","$ac1lo","$ac2hi","$ac2lo",
+  "$ac3hi","$ac3lo",
   // MSA register names
   "$w0",  "$w1",  "$w2",  "$w3",  "$w4",  "$w5",  "$w6",  "$w7",
   "$w8",  "$w9",  "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18457: [clang-tidy] Add a new checker to detect missing comma in initializer list.

2016-03-29 Thread Dominik Szabó via cfe-commits
szdominik added a comment.

Hi!

I'm working on the same (or almost the same) checker as you, so maybe you'll 
find helpful my code.
I think your approach (or heuristics) is better than mine, but there are other 
options in this problem.
e.g.

- more precise location (where exactly is the missing comma)
- FixItHint for that
- think about what if the explicit array size is given (see below in my test)

Please, ask me if you have any question about my checker.

F1716939: misc-wrong-string-array-initialization.cpp 
 (test file)
F1716926: WrongStringArrayInitializationCheck.h 

F1716927: WrongStringArrayInitializationCheck.cpp 



http://reviews.llvm.org/D18457



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

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

In http://reviews.llvm.org/D18265#385300, @baloghadamsoftware wrote:

> Thank you for your comments, but they are not related to my changes. These 
> lines were present in the original file and I did not change them.


Ah, good to know (hard to tell context in Phab sometimes). Can you fix up the 
trivial changes, and leave the C++ core guideline behavior for now?


http://reviews.llvm.org/D18265



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


r264715 - [OPENMP 4.5] Allow data members in 'aligned' clause.

2016-03-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 29 05:59:56 2016
New Revision: 264715

URL: http://llvm.org/viewvc/llvm-project?rev=264715=rev
Log:
[OPENMP 4.5] Allow data members in 'aligned' clause.

OpenMP 4.5 allows privatization of data members OpenMP clauses. Patch
adds support for data members in 'aligned' clause.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/simd_ast_print.cpp
cfe/trunk/test/OpenMP/simd_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_aligned_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=264715=264714=264715=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Mar 29 05:59:56 2016
@@ -1745,7 +1745,7 @@ static DeclRefExpr *buildCapture(Sema 
 CD = buildCaptureDecl(S, D->getIdentifier(), CaptureExpr, WithInit,
   /*AsExpression=*/false);
   return buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
-  SourceLocation());
+  CaptureExpr->getExprLoc());
 }
 
 static ExprResult buildCapture(Sema , Expr *CaptureExpr, DeclRefExpr *) {
@@ -7727,10 +7727,10 @@ OMPClause *Sema::ActOnOpenMPSharedClause
 }
 
 DeclRefExpr *Ref = nullptr;
-if (!VD)
+if (!VD && IsOpenMPCapturedDecl(D))
   Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/true);
 DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_shared, Ref);
-Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);
+Vars.push_back((VD || !Ref) ? RefExpr->IgnoreParens() : Ref);
   }
 
   if (Vars.empty())
@@ -8692,53 +8692,55 @@ OMPClause *Sema::ActOnOpenMPAlignedClaus
 
   SmallVector Vars;
   for (auto  : VarList) {
-assert(RefExpr && "NULL expr in OpenMP aligned clause.");
-if (isa(RefExpr)) {
+assert(RefExpr && "NULL expr in OpenMP linear clause.");
+SourceLocation ELoc;
+SourceRange ERange;
+Expr *SimpleRefExpr = RefExpr;
+auto Res = getPrivateItem(*this, SimpleRefExpr, ELoc, ERange,
+  /*AllowArraySection=*/false);
+if (Res.second) {
   // It will be analyzed later.
   Vars.push_back(RefExpr);
-  continue;
 }
-
-SourceLocation ELoc = RefExpr->getExprLoc();
-// OpenMP [2.1, C/C++]
-//  A list item is a variable name.
-DeclRefExpr *DE = dyn_cast(RefExpr);
-if (!DE || !isa(DE->getDecl())) {
-  Diag(ELoc, diag::err_omp_expected_var_name_member_expr)
-  << 0 << RefExpr->getSourceRange();
+ValueDecl *D = Res.first;
+if (!D)
   continue;
-}
 
-VarDecl *VD = cast(DE->getDecl());
+QualType QType = D->getType();
+auto *VD = dyn_cast(D);
 
 // OpenMP  [2.8.1, simd construct, Restrictions]
 // The type of list items appearing in the aligned clause must be
 // array, pointer, reference to array, or reference to pointer.
-QualType QType = VD->getType();
 QType = 
QType.getNonReferenceType().getUnqualifiedType().getCanonicalType();
 const Type *Ty = QType.getTypePtrOrNull();
-if (!Ty || (!Ty->isDependentType() && !Ty->isArrayType() &&
-!Ty->isPointerType())) {
+if (!Ty || (!Ty->isArrayType() && !Ty->isPointerType())) {
   Diag(ELoc, diag::err_omp_aligned_expected_array_or_ptr)
-  << QType << getLangOpts().CPlusPlus << RefExpr->getSourceRange();
+  << QType << getLangOpts().CPlusPlus << ERange;
   bool IsDecl =
+  !VD ||
   VD->isThisDeclarationADefinition(Context) == 
VarDecl::DeclarationOnly;
-  Diag(VD->getLocation(),
+  Diag(D->getLocation(),
IsDecl ? diag::note_previous_decl : diag::note_defined_here)
-  << VD;
+  << D;
   continue;
 }
 
 // OpenMP  [2.8.1, simd construct, Restrictions]
 // A list-item cannot appear in more than one aligned clause.
-if (Expr *PrevRef = DSAStack->addUniqueAligned(VD, DE)) {
-  Diag(ELoc, diag::err_omp_aligned_twice) << RefExpr->getSourceRange();
+if (Expr *PrevRef = DSAStack->addUniqueAligned(D, SimpleRefExpr)) {
+  Diag(ELoc, diag::err_omp_aligned_twice) << ERange;
   Diag(PrevRef->getExprLoc(), diag::note_omp_explicit_dsa)
   << getOpenMPClauseName(OMPC_aligned);
   continue;
 }
 
-Vars.push_back(DE);
+DeclRefExpr *Ref = nullptr;
+if (!VD && IsOpenMPCapturedDecl(D))
+  Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/true);
+Vars.push_back(DefaultFunctionArrayConversion(
+   (VD || !Ref) ? RefExpr->IgnoreParens() : Ref)
+   .get());
   }
 
   // OpenMP [2.8.1, simd construct, Description]

Modified: 

r264714 - Visual Studio native visualization for TemplateParameterList and TemplateTypeParmDecl

2016-03-29 Thread Mike Spertus via cfe-commits
Author: mps
Date: Tue Mar 29 05:57:24 2016
New Revision: 264714

URL: http://llvm.org/viewvc/llvm-project?rev=264714=rev
Log:
Visual Studio native visualization for TemplateParameterList and 
TemplateTypeParmDecl

With this change, a TemplateParameterList will suggestively display in the 
locals window something like:
  


Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=264714=264713=264714=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Tue Mar 29 05:57:24 2016
@@ -112,6 +112,10 @@ For later versions of Visual Studio, no
   
 Destructor {{~{Name,view(cpp)}()}}
   
+  
+class {Name,view(cpp)}
+typename {Name,view(cpp)}
+  
   
 {Name,view(cpp)}
 {Name}
@@ -371,4 +375,25 @@ For later versions of Visual Studio, no
   ($T1 *)Ptr
 
   
+  
+
+{*((NamedDecl 
**)(this+1))[0],view(cpp)}{*this,view(parm1)}
+
+, {*((NamedDecl 
**)(this+1))[1],view(cpp)}{*this,view(parm2)}
+
+, {*((NamedDecl 
**)(this+1))[2],view(cpp)}{*this,view(parm3)}
+
+, {*((NamedDecl 
**)(this+1))[3],view(cpp)}{*this,view(parm4)}
+
+, {*((NamedDecl 
**)(this+1))[4],view(cpp)}{*this,view(parm5)}
+
+, /* Expand for more params 
*/
+{*this,view(parm0)}
+
+  
+NumParams
+  (NamedDecl **)(this+1)
+  
+
+  
 


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


r264710 - Visual Studio native visualizer for InjectedClassNameType

2016-03-29 Thread Mike Spertus via cfe-commits
Author: mps
Date: Tue Mar 29 04:24:45 2016
New Revision: 264710

URL: http://llvm.org/viewvc/llvm-project?rev=264710=rev
Log:
Visual Studio native visualizer for InjectedClassNameType

Also fixes some omissions for TemplateSpecializationType

Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=264710=264709=264710=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Tue Mar 29 04:24:45 2016
@@ -32,8 +32,10 @@ For later versions of Visual Studio, no
 {*(clang::RecordType *)this}
 {*(clang::RecordType *)this,view(cpp)}
 {*(clang::FunctionProtoType *)this}
+{*(clang::TemplateSpecializationType *)this}
+{*(clang::InjectedClassNameType *)this}
 {*this,view(poly)}
-{*this,view(cmn)}" 
+{*this,view(cmn)} 
 {*this,view(cmn)}  {{{*this,view(poly)}}}
 
   (clang::Type::TypeClass)TypeBits.TC
@@ -48,6 +50,8 @@ For later versions of Visual Studio, no
   (clang::SubstTemplateTypeParmType
 *)this
   (clang::RecordType 
*)this
   (clang::FunctionProtoType
 *)this
+  (clang::TemplateSpecializationType
 *)this
+  (clang::InjectedClassNameType
 *)this
 
   
   
@@ -182,6 +186,14 @@ For later versions of Visual Studio, no
   
 typename {*TTPDecl,view(cpp)}
   
+  
+{*Decl,view(cpp)}
+
+  Decl
+  InjectedType
+  *(clang::Type *)this, view(cmn)
+
+  
   
 
 {*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType,view(poly)}{*this,view(fastQuals)}


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


r264709 - [OPENMP] Remove extra code transformation.

2016-03-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 29 03:58:54 2016
New Revision: 264709

URL: http://llvm.org/viewvc/llvm-project?rev=264709=rev
Log:
[OPENMP] Remove extra code transformation.

For better support of some specific GNU extensions some extra
transformation of AST nodes were introduced. These transformations are
very hard to handle. The code is improved in handling of these
extensions by using captured expressions construct.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/distribute_codegen.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/simd_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=264709=264708=264709=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Mar 29 03:58:54 2016
@@ -312,21 +312,22 @@ class OMPLoopDirective : public OMPExecu
 CondOffset = 5,
 InitOffset = 6,
 IncOffset = 7,
+PreInitsOffset = 8,
 // The '...End' enumerators do not correspond to child expressions - they
 // specify the offset to the end (and start of the following counters/
 // updates/finals arrays).
-DefaultEnd = 8,
+DefaultEnd = 9,
 // The following 7 exprs are used by worksharing loops only.
-IsLastIterVariableOffset = 8,
-LowerBoundVariableOffset = 9,
-UpperBoundVariableOffset = 10,
-StrideVariableOffset = 11,
-EnsureUpperBoundOffset = 12,
-NextLowerBoundOffset = 13,
-NextUpperBoundOffset = 14,
+IsLastIterVariableOffset = 9,
+LowerBoundVariableOffset = 10,
+UpperBoundVariableOffset = 11,
+StrideVariableOffset = 12,
+EnsureUpperBoundOffset = 13,
+NextLowerBoundOffset = 14,
+NextUpperBoundOffset = 15,
 // Offset to the end (and start of the following counters/updates/finals
 // arrays) for worksharing loop directives.
-WorksharingEnd = 15,
+WorksharingEnd = 16,
   };
 
   /// \brief Get the counters storage.
@@ -422,6 +423,9 @@ protected:
   }
   void setInit(Expr *Init) { *std::next(child_begin(), InitOffset) = Init; }
   void setInc(Expr *Inc) { *std::next(child_begin(), IncOffset) = Inc; }
+  void setPreInits(Stmt *PreInits) {
+*std::next(child_begin(), PreInitsOffset) = PreInits;
+  }
   void setIsLastIterVariable(Expr *IL) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
@@ -521,6 +525,8 @@ public:
 SmallVector Updates;
 /// \brief Final loop counter values for GodeGen.
 SmallVector Finals;
+/// Init statement for all captured expressions.
+Stmt *PreInits;
 
 /// \brief Check if all the expressions are built (does not check the
 /// worksharing ones).
@@ -559,6 +565,7 @@ public:
 Updates[i] = nullptr;
 Finals[i] = nullptr;
   }
+  PreInits = nullptr;
 }
   };
 
@@ -593,6 +600,10 @@ public:
 return const_cast(
 reinterpret_cast(*std::next(child_begin(), IncOffset)));
   }
+  const Stmt *getPreInits() const {
+return *std::next(child_begin(), PreInitsOffset);
+  }
+  Stmt *getPreInits() { return *std::next(child_begin(), PreInitsOffset); }
   Expr *getIsLastIterVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
 isOpenMPTaskLoopDirective(getDirectiveKind()) ||

Modified: cfe/trunk/lib/AST/StmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=264709=264708=264709=diff
==
--- cfe/trunk/lib/AST/StmtOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/StmtOpenMP.cpp Tue Mar 29 03:58:54 2016
@@ -105,6 +105,7 @@ OMPSimdDirective::Create(const ASTContex
   Dir->setInits(Exprs.Inits);
   Dir->setUpdates(Exprs.Updates);
   Dir->setFinals(Exprs.Finals);
+  Dir->setPreInits(Exprs.PreInits);
   return Dir;
 }
 
@@ -153,6 +154,7 @@ OMPForDirective::Create(const ASTContext
   Dir->setInits(Exprs.Inits);
   Dir->setUpdates(Exprs.Updates);
   Dir->setFinals(Exprs.Finals);
+  Dir->setPreInits(Exprs.PreInits);
   Dir->setHasCancel(HasCancel);
   return Dir;
 }
@@ -202,6 +204,7 @@ OMPForSimdDirective::Create(const ASTCon
   

  1   2   >