Re: Preventing several replacements on a macro call.

2015-09-10 Thread Ted Kremenek via cfe-commits
+ Argyrios

Hi Angel,

I believe Argyrios is the original author of the code in question, as this 
looks related to the Objective-C “modernizer” migrator he wrote a while back.  
This code started life on our internal development branch at Apple related to 
an Xcode feature we were doing, and I did the work on pushing it back to open 
source trunk.  Argyrios is the best one to answer your technical question here.

Ted

> On Sep 9, 2015, at 6:05 AM, Angel Garcia  wrote:
> 
> +cfe-commits
> 
> On Tue, Sep 8, 2015 at 6:56 PM, Angel Garcia  > wrote:
> Hi Ted,
> 
> I was working on a clang-tidy check, and today I discovered that it was 
> unable to do several replacements in different arguments of the same macro 
> call. At first, I thought it was a bug, and trying to figure out why this was 
> happening, I found that the replacements were rejected in 
> lib/Edit/EditedSource.cpp:46, where there is a comment that says "Trying to 
> write in a macro argument input that has already been written for another 
> argument of the same macro". This comment means that this changes are 
> rejected on purpose.
> 
> At the commit history, I saw that you had commited 
>  this code (that's why I am asking you). Do 
> you think that there is a way around this? I don't really understand why 
> there is a particular case for the macros here, and understanding it would 
> help me to decide whether I should give up on trying to make this work, or 
> try to find a "better" solution.
> 
> Thanks and sorry for the inconvenience,
> Angel
> 

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


Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-09-10 Thread Charles Davis via cfe-commits
cdavis5x updated this revision to Diff 34415.
cdavis5x added a comment.

- Rebase onto http://reviews.llvm.org/rL247238.
- Run `clang-format` on this patch.
- Push `va_arg` emission down into the `ABIInfo` hierarchy.

I threaded the `IsMS` parameter from the `VAArgExpr` through the
`EmitVAArg` methods. I'm not entirely happy about this design; I'm open
to suggestions. One thing this does help, though, is supporting this
on other architectures (ARM, maybe?).


http://reviews.llvm.org/D1623

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Expr.h
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDiagnostic.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/ABIInfo.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGen/ms_abi.c
  test/PCH/Inputs/va_arg.h
  test/PCH/va_arg.c
  test/PCH/va_arg.cpp
  test/PCH/va_arg.h
  test/Sema/varargs-win64.c
  test/Sema/varargs-x86-32.c
  test/Sema/varargs-x86-64.c
  test/SemaTemplate/instantiate-expr-3.cpp

Index: test/SemaTemplate/instantiate-expr-3.cpp
===
--- test/SemaTemplate/instantiate-expr-3.cpp
+++ test/SemaTemplate/instantiate-expr-3.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
 
 // -
 // Imaginary literals
@@ -108,12 +108,41 @@
 struct VaArg1 {
   void f(int n, ...) {
 VaList va;
-__builtin_va_start(va, n); // expected-error{{int}}
+__builtin_va_start(va, n); // expected-error{{int}} expected-error{{char *}}
 for (int i = 0; i != n; ++i)
   (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
-__builtin_va_end(va); // expected-error{{int}}
+__builtin_va_end(va);  // expected-error{{int}} expected-error{{char *}}
   }
 };
 
 template struct VaArg1<__builtin_va_list, int>;
+template struct VaArg1<__builtin_ms_va_list, int>; // expected-note{{instantiation}}
 template struct VaArg1; // expected-note{{instantiation}}
+
+template 
+struct VaArg2 {
+  void __attribute__((ms_abi)) f(int n, ...) {
+__builtin_ms_va_list va;
+__builtin_ms_va_start(va, n);
+for (int i = 0; i != n; ++i)
+  (void)__builtin_va_arg(va, ArgType);
+__builtin_ms_va_end(va);
+  }
+};
+
+template struct VaArg2;
+
+template 
+struct VaArg3 {
+  void __attribute__((ms_abi)) f(int n, ...) {
+VaList va;
+__builtin_ms_va_start(va, n); // expected-error{{int}} expected-error{{__va_list_tag}}
+for (int i = 0; i != n; ++i)
+  (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
+__builtin_ms_va_end(va);   // expected-error{{int}} expected-error{{__va_list_tag}}
+  }
+};
+
+template struct VaArg3<__builtin_ms_va_list, int>;
+template struct VaArg3<__builtin_va_list, int>; // expected-note{{instantiation}}
+template struct VaArg3;   // expected-note{{instantiation}}
Index: test/Sema/varargs-x86-64.c
===
--- test/Sema/varargs-x86-64.c
+++ test/Sema/varargs-x86-64.c
@@ -6,3 +6,77 @@
   (void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
 }
 
+void f2(int a, ...) {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a); // expected-error {{'__builtin_ms_va_start' used in System V ABI function}}
+}
+
+void __attribute__((ms_abi)) g1(int a) {
+  __builtin_ms_va_list ap;
+
+  __builtin_ms_va_start(ap, a, a); // expected-error {{too many arguments to function}}
+  __builtin_ms_va_start(ap, a);// expected-error {{'va_start' used in function with fixed args}}
+}
+
+void __attribute__((ms_abi)) g2(int a, int b, ...) {
+  __builtin_ms_va_list ap;
+
+  __builtin_ms_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
+  __builtin_ms_va_start(ap, a);  // expected-warning {{second parameter of 'va_start' not last named argument}}
+  __builtin_ms_va_start(ap, b);
+}
+
+void __attribute__((ms_abi)) g3(float a, ...) {
+  __builtin_ms_va_list ap;
+
+  __builtin_ms_va_start(ap, a);
+  __builtin_ms_va_start(ap, (a));
+}
+
+void __attribute__((ms_abi)) g5() {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, ap); // expected-error {{'va_start' used in function wi

r247248 - [MS ABI] Select a pointer to member representation more often

2015-09-10 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Sep 10 02:20:05 2015
New Revision: 247248

URL: http://llvm.org/viewvc/llvm-project?rev=247248&view=rev
Log:
[MS ABI] Select a pointer to member representation more often

Given a reference to a pointer to member whose class's inheritance model
is unspecified, make sure we come up with an inheritance model in
plausible places.  One place we were missing involved LValue to RValue
conversion, another involved unary type traits.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=247248&r1=247247&r2=247248&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Sep 10 02:20:05 2015
@@ -677,6 +677,10 @@ ExprResult Sema::DefaultLvalueConversion
   if (T.hasQualifiers())
 T = T.getUnqualifiedType();
 
+  if (T->isMemberPointerType() &&
+  Context.getTargetInfo().getCXXABI().isMicrosoft())
+RequireCompleteType(E->getExprLoc(), T, 0);
+
   UpdateMarkingForLValueToRValue(E);
   
   // Loading a __weak object implicitly retains the value, so we need a 
cleanup to 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=247248&r1=247247&r2=247248&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Sep 10 02:20:05 2015
@@ -4507,6 +4507,8 @@ QualType Sema::CheckPointerToMemberOpera
   << OpSpelling << RHSType << RHS.get()->getSourceRange();
 return QualType();
   }
+  //if (Context.getTargetInfo().getCXXABI().isMicrosoft())
+  //  RequireCompleteType(Loc, QualType(MemPtr, 0), 0);
 
   QualType Class(MemPtr->getClass(), 0);
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=247248&r1=247247&r2=247248&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Sep 10 02:20:05 2015
@@ -6253,9 +6253,13 @@ bool Sema::RequireCompleteExprType(Expr
   QualType T = E->getType();
 
   // Fast path the case where the type is already complete.
-  if (!T->isIncompleteType())
+  if (!T->isIncompleteType()) {
+if (T->isMemberPointerType() &&
+Context.getTargetInfo().getCXXABI().isMicrosoft())
+  RequireCompleteType(E->getExprLoc(), T, 0);
 // FIXME: The definition might not be visible.
 return false;
+  }
 
   // Incomplete array types may be completed by the initializer attached to
   // their definitions. For static data members of class templates and for

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247248&r1=247247&r2=247248&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Thu Sep 10 
02:20:05 2015
@@ -752,3 +752,19 @@ void f(int S::*&p) {}
 // CHECK-LABEL: define void @"\01?f@PR24703@@YAXAAPQS@1@H@Z"(
 }
 
+namespace ReferenceToMPTWithIncompleteClass {
+struct S;
+struct J;
+struct K;
+extern K *k;
+
+// CHECK-LABEL: @"\01?f@ReferenceToMPTWithIncompleteClass@@YAIAAPQS@1@H@Z"(
+// CHECK: ret i32 12
+unsigned f(int S::*&p) { return sizeof p; }
+
+// CHECK-LABEL: @"\01?g@ReferenceToMPTWithIncompleteClass@@YA_NAAPQJ@1@H0@Z"(
+bool g(int J::*&p, int J::*&q) { return p == q; }
+
+// CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1@H@Z"(
+int h(int K::*&p) { return k->*p; }
+}


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


Re: [PATCH] D10414: Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option

2015-09-10 Thread James Molloy via cfe-commits
jmolloy added a subscriber: jmolloy.
jmolloy added a comment.

Hi Akira,

I'm sorry to be contrary (and I missed the discussion on Tuesday because I was 
away on vacation) but I think there *is* a usecase for -mno-restrict-it to 
work, and I would hate to see it broken.

Non-restricted IT blocks are indeed deprecated for ARMv8 in the ARMARM. But 
there are circumstances where you may still want to emit them - the biggest 
example being you're compiling for a CPU microarchitecture that you *know* 
doesn't have a performance penalty on non-restricted IT blocks. Restricted IT 
blocks can pessimize code quite badly in some circumstances, and allowing 
people to turn it off for their target if needed is very important, IMO.

Cheers,

James


http://reviews.llvm.org/D10414



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


Re: [Diffusion] rL247251: [OPENMP] Outlined function for parallel and other regions with list of…

2015-09-10 Thread NAKAMURA Takumi via cfe-commits
chapuni added subscribers: cfe-commits, chapuni.
chapuni added a comment.

See also; http://bb.pgr.jp/builders/clang-i686-cygwin-RA-centos6/builds/20524


/cfe/trunk/test/OpenMP/parallel_codegen.cpp:99 Seems it is incompatible to 
32-bit targets, for example, i686-linux, i686-cygwin.

  define internal void @.omp_outlined..1(i32* noalias %.global_tid., i32* 
noalias %.bound_tid., i8*** dereferenceable(4) %argc) #1 personality i8* 
bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {

Users:
  ABataev (Author)

http://reviews.llvm.org/rL247251



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


Re: PATCH: Expose the 'file' that is associated with a compile database command

2015-09-10 Thread Manuel Klimek via cfe-commits
@@ -179,11 +185,13 @@ public:
   /// \param Directory The base directory used in the
FixedCompilationDatabase.
   static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
const char *const
*Argv,
-   Twine Directory =
".");
+   Twine Directory =
".",
+   Twine File =
Twine());

A fixed compilation database returns the same command lines for all files,
thus having a file in the function seems strange.

What exactly is the use case? So far, the compilation database has been
designed for 2 use cases:
1. for a file, get the compile commands; the user already knows the file,
no need to get the file
2. get all compile commands; for that, we have the getAllFiles() method, so
a user can get all known files (for compilation databases that support
that), and then get the compile command line.

Thoughts?
/Manuel

On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis 
wrote:

> Hi,
>
> The attached patch exposes the ‘file’ entry in a compilation database
> command, via the CompileCommand structure.
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2015-09-10 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Ok, so just for my understanding: the nested name specifier in the changed 
tests canonicaltype is *not* the user-written type (thus, what the elaborated 
type would get us), but the full nested name specifier of the canonical type?


http://reviews.llvm.org/D11797



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


Re: [Diffusion] rL247251: [OPENMP] Outlined function for parallel and other regions with list of…

2015-09-10 Thread Bataev, Alexey via cfe-commits

Yes, I know. Fixing it right now. Will be fixed in few minutes, thanks.

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

10.09.2015 11:46, NAKAMURA Takumi пишет:

chapuni added subscribers: cfe-commits, chapuni.
chapuni added a comment.

See also; http://bb.pgr.jp/builders/clang-i686-cygwin-RA-centos6/builds/20524


/cfe/trunk/test/OpenMP/parallel_codegen.cpp:99 Seems it is incompatible to 
32-bit targets, for example, i686-linux, i686-cygwin.

   define internal void @.omp_outlined..1(i32* noalias %.global_tid., i32* 
noalias %.bound_tid., i8*** dereferenceable(4) %argc) #1 personality i8* 
bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {

Users:
   ABataev (Author)

http://reviews.llvm.org/rL247251





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


Re: [Diffusion] rL247251: [OPENMP] Outlined function for parallel and other regions with list of…

2015-09-10 Thread Alexey Bataev via cfe-commits
ABataev added a subscriber: ABataev.
ABataev added a comment.

Yes, I know. Fixing it right now. Will be fixed in few minutes, thanks.

Best regards,

Alexey Bataev
=

Software Engineer
Intel Compiler Team

10.09.2015 11:46, NAKAMURA Takumi пишет:

> chapuni added subscribers: cfe-commits, chapuni.

>  chapuni added a comment.

> 

> See also; http://bb.pgr.jp/builders/clang-i686-cygwin-RA-centos6/builds/20524

> 

> /cfe/trunk/test/OpenMP/parallel_codegen.cpp:99 Seems it is incompatible to 
> 32-bit targets, for example, i686-linux, i686-cygwin.

> 

>   define internal void @.omp_outlined..1(i32* noalias %.global_tid., i32* 
> noalias %.bound_tid., i8*** dereferenceable(4) %argc) #1 personality i8* 
> bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {

> 

> Users:

> 

>   ABataev (Author)

> 

> http://reviews.llvm.org/rL247251



Users:
  ABataev (Author)

http://reviews.llvm.org/rL247251



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


Re: [PATCH] D12732: Add a deprecation notice to the clang-modernize documentation.

2015-09-10 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D12732



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


r247255 - [OPENMP] Fix test incompatibility with 32-bit platforms

2015-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 10 04:06:59 2015
New Revision: 247255

URL: http://llvm.org/viewvc/llvm-project?rev=247255&view=rev
Log:
[OPENMP] Fix test incompatibility with 32-bit platforms

Modified:
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=247255&r1=247254&r2=247255&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Thu Sep 10 04:06:59 2015
@@ -96,7 +96,7 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-NEXT:  ret i32 0
 // CHECK-DEBUG-NEXT:  }
 
-// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable(8) %argc)
+// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc)
 // CHECK:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
 // CHECK-NEXT:  [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // CHECK-NEXT:  [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]
@@ -106,7 +106,7 @@ int main (int argc, char **argv) {
 // CHECK:   call {{.*}}void @{{.+terminate.*|abort}}(
 // CHECK-NEXT:  unreachable
 // CHECK-NEXT:  }
-// CHECK-DEBUG:   define internal void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable(8) %argc)
+// CHECK-DEBUG:   define internal void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc)
 // CHECK-DEBUG:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
 // CHECK-DEBUG:  [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // CHECK-DEBUG-NEXT:  [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]


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


Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:458
@@ -438,2 +457,3 @@
 // variable.
 for (const auto &I : Usages) {
+  std::string ReplaceText;

I'd call that 'Usage' here, as it's not an iterator.


Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:460-465
@@ -441,1 +459,8 @@
+  std::string ReplaceText;
+  if (I.Expression) {
+ReplaceText = I.IsArrow ? VarName + "." : VarName;
+  } else {
+// Lambda capture: IsArrow means that the index is captured by value.
+ReplaceText = I.IsArrow ? "&" + VarName : VarName;
+  }
   TUInfo->getReplacedVars().insert(std::make_pair(TheLoop, IndexVar));

We need to document the members of Usage better: It seems unclear why the 
'else' part goes into a lambda capture, or why in the if() path adding a '.' 
will ever help. Examples would help in comments here, I think.


Comment at: clang-tidy/modernize/LoopConvertUtils.cpp:765-766
@@ -764,2 +764,4 @@
   // exactly one usage.
-  addUsage(Usage(nullptr, false, C->getLocation()));
+  // We are using the 'IsArrow' field of Usage to store if we have to add
+  // a '&' to capture the element by reference.
+  addUsage(

This needs to be a comment at the IsArrow field of Usage.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:504
@@ -502,1 +503,3 @@
 
+void constPseudo() {
+  int sum = 0;

why Pseudo?


http://reviews.llvm.org/D12734



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


[clang-tools-extra] r247258 - Add a deprecation notice to the clang-modernize documentation.

2015-09-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep 10 04:42:01 2015
New Revision: 247258

URL: http://llvm.org/viewvc/llvm-project?rev=247258&view=rev
Log:
Add a deprecation notice to the clang-modernize documentation.

Summary:
Add a deprecation notice to the clang-modernize documentation. Remove
the reference to the external JIRA tracker.

Reviewers: revane, klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/docs/clang-modernize.rst

Modified: clang-tools-extra/trunk/docs/clang-modernize.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-modernize.rst?rev=247258&r1=247257&r2=247258&view=diff
==
--- clang-tools-extra/trunk/docs/clang-modernize.rst (original)
+++ clang-tools-extra/trunk/docs/clang-modernize.rst Thu Sep 10 04:42:01 2015
@@ -1,5 +1,14 @@
 .. index:: clang-modernize
 
+.. note::
+
+   **Deprecation**
+
+   As of September 2015 all :program:`clang-modernize` transforms have been
+   ported to :doc:`clang-tidy/index`. :program:`clang-modernize` is deprecated
+   and is going to be removed soon.
+
+
 ==
 Clang C++ Modernizer User's Manual
 ==
@@ -81,34 +90,6 @@ situation you are dealing with.
 .. _Building LLVM with CMake: http://llvm.org/docs/CMake.html
 .. _Clang Tools Documentation: http://clang.llvm.org/docs/ClangTools.html
 
-Getting Involved
-
-
-If you find a bug
-
-.. raw:: html
-
-  
-  https://cpp11-migrate.atlassian.net/s/en_USpfg3b3-1988229788/6095/34/1.4.0-m2/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?collectorId=50813874";>
-  window.ATL_JQ_PAGE_PROPS =  {
-"triggerFunction": function(showCollectorDialog) {
-  //Requries that jQuery is available! 
-  jQuery("#logbug").click(function(e) {
-e.preventDefault();
-showCollectorDialog();
-  });
-}};
-  
-
-Bugs and feature development of the Modernizer are tracked at
-http://cpp11-migrate.atlassian.net. If you want to get involved the front page
-shows a list of outstanding issues or you can browse around the project to get
-familiar. To take on issues or contribute feature requests and/or bug reports
-you need to sign up for an account from the `log in page`_. An account also
-lets you sign up for notifications on issues or vote for unassigned issues to
-be completed.
-
-.. _log in page: https://cpp11-migrate.atlassian.net/login
 
 .. _transforms:
 


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


Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 34422.
angelgarcia marked 4 inline comments as done.
angelgarcia added a comment.

Document Usage's fields and other comments.


http://reviews.llvm.org/D12734

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -290,7 +290,6 @@
 dependent v;
 dependent *pv;
 
-transparent> cv;
 int Sum = 0;
 
 // Checks for the Index start and end:
@@ -473,3 +472,41 @@
 }
 
 } // namespace NegativeMultiEndCall
+
+namespace NoUsages {
+
+const int N = 6;
+int arr[N] = {1, 2, 3, 4, 5, 6};
+S s;
+dependent v;
+int Count = 0;
+
+void foo();
+
+void f() {
+  for (int I = 0; I < N; ++I) {}
+  for (int I = 0; I < N; ++I)
+printf("Hello world\n");
+  for (int I = 0; I < N; ++I)
+++Count;
+  for (int I = 0; I < N; ++I)
+foo();
+
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I) {}
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+printf("Hello world\n");
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+++Count;
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+foo();
+
+  for (int I = 0; I < v.size(); ++I) {}
+  for (int I = 0; I < v.size(); ++I)
+printf("Hello world\n");
+  for (int I = 0; I < v.size(); ++I)
+++Count;
+  for (int I = 0; I < v.size(); ++I)
+foo();
+}
+
+} // namespace NoUsages
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -14,10 +14,9 @@
 int b = arr[i][a];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : arr) {
+  // CHECK-FIXES: for (auto & elem : arr)
   // CHECK-FIXES-NEXT: int a = 0;
   // CHECK-FIXES-NEXT: int b = elem[a];
-  // CHECK-FIXES-NEXT: }
 
   for (int j = 0; j < M; ++j) {
 int a = 0;
@@ -121,16 +120,16 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: if (alias) {
+  // CHECK-FIXES-NEXT: if (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 while (int alias = IntArr[i]) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: while (alias) {
+  // CHECK-FIXES-NEXT: while (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 switch (int alias = IntArr[i]) {
@@ -140,32 +139,32 @@
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: switch (alias) {
+  // CHECK-FIXES-NEXT: switch (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (int alias = IntArr[i]; alias < N; ++alias) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (; alias < N; ++alias) {
+  // CHECK-FIXES-NEXT: for (; alias < N; ++alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (unsigned j = 0; int alias = IntArr[i]; ++j) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j) {
+  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j)
 
   struct IntRef { IntRef(const int& i); };
   for (int i = 0; i < N; ++i) {
 IntRef Int(IntArr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : IntArr) {
+  // CHECK-FIXES: for (auto & elem : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(elem);
 }
 
@@ -288,7 +287,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto & DEFs_it : DEFs)
-  // CHECK-FIXES-NEXT: if (DEFs_it == DEF) {
+  // CHECK-FIXES-NEXT: if (DEFs_it == DEF)
   // CHECK-FIXES-NEXT: printf("I found %d\n", DEFs_it);
 }
 
@@ -315,8 +314,8 @@
   T Vals;
   // Using the name "Val", although it is the name of an existing struct, is
   // safe in this loop since it will only exist within this scope.
-  for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; ++it) {
-  }
+  for (T::iterato

r247260 - [OPENMP] Propagate alignment from original variables to the private copies.

2015-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 10 04:48:30 2015
New Revision: 247260

URL: http://llvm.org/viewvc/llvm-project?rev=247260&view=rev
Log:
[OPENMP] Propagate alignment from original variables to the private copies.
Currently private copies of captured variables have default alignment. Patch 
makes private variables to have same alignment as original variables.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_private_codegen.cpp
cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=247260&r1=247259&r2=247260&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 10 04:48:30 2015
@@ -452,12 +452,17 @@ bool DSAStackTy::isOpenMPLocal(VarDecl *
 
 /// \brief Build a variable declaration for OpenMP loop iteration variable.
 static VarDecl *buildVarDecl(Sema &SemaRef, SourceLocation Loc, QualType Type,
- StringRef Name) {
+ StringRef Name, const AttrVec *Attrs = nullptr) {
   DeclContext *DC = SemaRef.CurContext;
   IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name);
   TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
   VarDecl *Decl =
   VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type, TInfo, SC_None);
+  if (Attrs) {
+for (specific_attr_iterator I(Attrs->begin()), 
E(Attrs->end());
+ I != E; ++I)
+  Decl->addAttr(*I);
+  }
   Decl->setImplicit();
   return Decl;
 }
@@ -723,9 +728,9 @@ void Sema::EndOpenMPDSABlock(Stmt *CurDi
 // by the address of the new private variable in CodeGen. This new
 // variable is not added to IdResolver, so the code in the OpenMP
 // region uses original variable for proper diagnostics.
-auto *VDPrivate =
-buildVarDecl(*this, DE->getExprLoc(), 
Type.getUnqualifiedType(),
- VD->getName());
+auto *VDPrivate = buildVarDecl(
+*this, DE->getExprLoc(), Type.getUnqualifiedType(),
+VD->getName(), VD->hasAttrs() ? &VD->getAttrs() : nullptr);
 ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
 if (VDPrivate->isInvalidDecl())
   continue;
@@ -2732,6 +2737,8 @@ public:
 NewVD->setPreviousDeclInSameBlockScope(
 VD->isPreviousDeclInSameBlockScope());
 VD->getDeclContext()->addHiddenDecl(NewVD);
+if (VD->hasAttrs())
+  NewVD->setAttrs(VD->getAttrs());
 transformedLocalDecl(VD, NewVD);
 return NewVD;
   }
@@ -2911,7 +2918,9 @@ Expr *OpenMPIterationSpaceChecker::Build
 Expr *OpenMPIterationSpaceChecker::BuildPrivateCounterVar() const {
   if (Var && !Var->isInvalidDecl()) {
 auto Type = Var->getType().getNonReferenceType();
-auto *PrivateVar = buildVarDecl(SemaRef, DefaultLoc, Type, Var->getName());
+auto *PrivateVar =
+buildVarDecl(SemaRef, DefaultLoc, Type, Var->getName(),
+ Var->hasAttrs() ? &Var->getAttrs() : nullptr);
 if (PrivateVar->isInvalidDecl())
   return nullptr;
 return buildDeclRefExpr(SemaRef, PrivateVar, Type, DefaultLoc);
@@ -5658,7 +5667,8 @@ OMPClause *Sema::ActOnOpenMPPrivateClaus
 // IdResolver, so the code in the OpenMP region uses original variable for
 // proper diagnostics.
 Type = Type.getUnqualifiedType();
-auto VDPrivate = buildVarDecl(*this, DE->getExprLoc(), Type, 
VD->getName());
+auto VDPrivate = buildVarDecl(*this, DE->getExprLoc(), Type, VD->getName(),
+  VD->hasAttrs() ? &VD->getAttrs() : nullptr);
 ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
 if (VDPrivate->isInvalidDecl())
   continue;
@@ -5861,7 +5871,8 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
 }
 
 Type = Type.getUnqualifiedType();
-auto VDPrivate = buildVarDecl(*this, ELoc, Type, VD->getName());
+auto VDPrivate = buildVarDecl(*this, ELoc, Type, VD->getName(),
+  VD->hasAttrs() ? &VD->getAttrs() : nullptr);
 // Generate helper private variable and initialize it with the value of the
 // original variable. The address of the original variable is replaced by
 // the address of the new private variable in the CodeGen. This new 
variable
@@ -6017,11 +6028,13 @@ OMPClause *Sema::ActOnOpenMPLastprivateC
 //  operator for the class type.
 Type = Context.getBaseElementType(Type).getNonReferenceType();
 auto *SrcVD = buildVarDecl(*this, DE->getLocStart(),
-   Type.getU

Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-tidy/modernize/LoopConvertUtils.cpp:765-766
@@ -764,2 +764,4 @@
   // exactly one usage.
-  addUsage(Usage(nullptr, false, C->getLocation()));
+  // We are using the 'IsArrow' field of Usage to store if we have to add
+  // a '&' to capture the element by reference.
+  addUsage(

I think when the comment is on the Usage member, it's fine to delete it here, 
as it'll only get out of sync.


Comment at: clang-tidy/modernize/LoopConvertUtils.h:203-206
@@ -200,2 +202,6 @@
   const Expr *Expression;
+  // Indicates whether this is an access to a member through the arrow operator
+  // on pointers or iterators. In case of lambda captures, it indicates whether
+  // the capture was done by value.
   bool IsArrow;
+  // Range that covers this usage.

I think this now really needs a different name, or we should put it into an 
enum if we can't find a good bool name that fits both the lambda capture and 
member expression case.


http://reviews.llvm.org/D12734



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


[clang-tools-extra] r247261 - [clang-tidy] Add inconsistent declaration parameter name check

2015-09-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep 10 05:07:11 2015
New Revision: 247261

URL: http://llvm.org/viewvc/llvm-project?rev=247261&view=rev
Log:
[clang-tidy] Add inconsistent declaration parameter name check

This is first of series of patches, porting code from my project colobot-lint,
as I mentioned recently in cfe-dev mailing list.

This patch adds a new check in readability module:
readability-inconsistent-declaration-parameter-name. I also added appropriate
testcases and documentation.

I chose readability module, as it seems it is the best place for it.

I think I followed the rules of LLVM coding guideline, but I may have missed
something, as I usually use other code formatting style.

http://reviews.llvm.org/D12462

Patch by Piotr Dziwinski!

Added:

clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp

clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst

clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=247261&r1=247260&r2=247261&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Thu Sep 10 
05:07:11 2015
@@ -6,6 +6,7 @@ add_clang_library(clangTidyReadabilityMo
   ElseAfterReturnCheck.cpp
   FunctionSizeCheck.cpp
   IdentifierNamingCheck.cpp
+  InconsistentDeclarationParameterNameCheck.cpp
   NamedParameterCheck.cpp
   NamespaceCommentCheck.cpp
   ReadabilityTidyModule.cpp

Added: 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp?rev=247261&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
 Thu Sep 10 05:07:11 2015
@@ -0,0 +1,336 @@
+//===--- InconsistentDeclarationParameterNameCheck.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 "InconsistentDeclarationParameterNameCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+using namespace ast_matchers;
+
+namespace {
+
+AST_MATCHER(FunctionDecl, hasOtherDeclarations) {
+  auto It = Node.redecls_begin();
+  auto EndIt = Node.redecls_end();
+
+  if (It == EndIt)
+return false;
+
+  ++It;
+  return It != EndIt;
+}
+
+struct DifferingParamInfo {
+  DifferingParamInfo(StringRef SourceName, StringRef OtherName,
+ SourceRange OtherNameRange, bool GenerateFixItHint)
+  : SourceName(SourceName), OtherName(OtherName),
+OtherNameRange(OtherNameRange), GenerateFixItHint(GenerateFixItHint) {}
+
+  StringRef SourceName;
+  StringRef OtherName;
+  SourceRange OtherNameRange;
+  bool GenerateFixItHint;
+};
+
+using DifferingParamsContainer = llvm::SmallVector;
+
+struct InconsistentDeclarationInfo {
+  InconsistentDeclarationInfo(SourceLocation DeclarationLocation,
+  DifferingParamsContainer &&DifferingParams)
+  : DeclarationLocation(DeclarationLocation),
+DifferingParams(std::move(DifferingParams)) {}
+
+  SourceLocation DeclarationLocation;
+  DifferingParamsContainer DifferingParams;
+};
+
+using InconsistentDeclarationsContainer =
+llvm::SmallVector;
+
+bool checkIfFixItHintIsApplicable(
+const FunctionDecl *ParameterSourceDeclaration,
+const ParmVarDecl *SourceParam, const FunctionDecl *OriginalDeclaration) {
+  // Assumptions with regard to function declarations/definition:
+  //  * If both function declaration and definition are seen, assume that
+  //  definition is most up-to-date, and use it to generate replacements.
+  //  * If only function declarations are seen, there is no easy way to tell
+  //  which is up-to-date and which is not, so don't do anything.
+  // TODO: This ma

Re: [PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh closed this revision.
alexfh added a comment.

Committed revision 247261.

Thank you again for the new awesome check!


http://reviews.llvm.org/D12462



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


Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 34427.
angelgarcia added a comment.

Replace the IsArrow field of Usage with an enum.


http://reviews.llvm.org/D12734

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -290,7 +290,6 @@
 dependent v;
 dependent *pv;
 
-transparent> cv;
 int Sum = 0;
 
 // Checks for the Index start and end:
@@ -473,3 +472,41 @@
 }
 
 } // namespace NegativeMultiEndCall
+
+namespace NoUsages {
+
+const int N = 6;
+int arr[N] = {1, 2, 3, 4, 5, 6};
+S s;
+dependent v;
+int Count = 0;
+
+void foo();
+
+void f() {
+  for (int I = 0; I < N; ++I) {}
+  for (int I = 0; I < N; ++I)
+printf("Hello world\n");
+  for (int I = 0; I < N; ++I)
+++Count;
+  for (int I = 0; I < N; ++I)
+foo();
+
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I) {}
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+printf("Hello world\n");
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+++Count;
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+foo();
+
+  for (int I = 0; I < v.size(); ++I) {}
+  for (int I = 0; I < v.size(); ++I)
+printf("Hello world\n");
+  for (int I = 0; I < v.size(); ++I)
+++Count;
+  for (int I = 0; I < v.size(); ++I)
+foo();
+}
+
+} // namespace NoUsages
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -14,10 +14,9 @@
 int b = arr[i][a];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : arr) {
+  // CHECK-FIXES: for (auto & elem : arr)
   // CHECK-FIXES-NEXT: int a = 0;
   // CHECK-FIXES-NEXT: int b = elem[a];
-  // CHECK-FIXES-NEXT: }
 
   for (int j = 0; j < M; ++j) {
 int a = 0;
@@ -121,16 +120,16 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: if (alias) {
+  // CHECK-FIXES-NEXT: if (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 while (int alias = IntArr[i]) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: while (alias) {
+  // CHECK-FIXES-NEXT: while (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 switch (int alias = IntArr[i]) {
@@ -140,32 +139,32 @@
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: switch (alias) {
+  // CHECK-FIXES-NEXT: switch (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (int alias = IntArr[i]; alias < N; ++alias) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (; alias < N; ++alias) {
+  // CHECK-FIXES-NEXT: for (; alias < N; ++alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (unsigned j = 0; int alias = IntArr[i]; ++j) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j) {
+  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j)
 
   struct IntRef { IntRef(const int& i); };
   for (int i = 0; i < N; ++i) {
 IntRef Int(IntArr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : IntArr) {
+  // CHECK-FIXES: for (auto & elem : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(elem);
 }
 
@@ -288,7 +287,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto & DEFs_it : DEFs)
-  // CHECK-FIXES-NEXT: if (DEFs_it == DEF) {
+  // CHECK-FIXES-NEXT: if (DEFs_it == DEF)
   // CHECK-FIXES-NEXT: printf("I found %d\n", DEFs_it);
 }
 
@@ -315,8 +314,8 @@
   T Vals;
   // Using the name "Val", although it is the name of an existing struct, is
   // safe in this loop since it will only exist within this scope.
-  for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; ++it) {
-  }
+  for (T::iterator it = Vals.begin(), e = Vals.end(); it !

[clang-tools-extra] r247266 - [clang-tidy] Renamed tests files to be closer to the check names.

2015-09-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep 10 05:58:38 2015
New Revision: 247266

URL: http://llvm.org/viewvc/llvm-project?rev=247266&view=rev
Log:
[clang-tidy] Renamed tests files to be closer to the check names.


Added:
clang-tools-extra/trunk/test/clang-tidy/google-build-explicit-make-pair.cpp
  - copied unchanged from r247265, 
clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp

clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp
  - copied unchanged from r247265, 
clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp

clang-tools-extra/trunk/test/clang-tidy/google-runtime-memset-zero-length.cpp
  - copied unchanged from r247265, 
clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp
Removed:
clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp
clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp
clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp

Removed: clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp?rev=247265&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-make-pair.cpp 
(removed)
@@ -1,51 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s google-build-explicit-make-pair %t
-
-namespace std {
-template 
-struct pair {
-  pair(T1 x, T2 y) {}
-};
-
-template 
-pair make_pair(T1 x, T2 y) {
-  return pair(x, y);
-}
-}
-
-template 
-void templ(T a, T b) {
-  std::make_pair(a, b);
-  std::make_pair(1, 2);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit 
template arguments from make_pair
-// CHECK-FIXES: std::make_pair(1, 2)
-}
-
-template 
-int t();
-
-void test(int i) {
-  std::make_pair(i, i);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, omit 
template arguments from make_pair
-// CHECK-FIXES: std::make_pair(i, i)
-
-  std::make_pair(i, i);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair 
directly
-// CHECK-FIXES: std::pair(i, i)
-
-  std::make_pair(i, i);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: for C++11-compatibility, use pair 
directly
-// CHECK-FIXES: std::pair(i, i)
-
-#define M std::make_pair(i, i);
-M
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: for C++11-compatibility, use pair 
directly
-// Can't fix in macros.
-// CHECK-FIXES: #define M std::make_pair(i, i);
-// CHECK-FIXES-NEXT: M
-
-  templ(i, i);
-  templ(1U, 2U);
-
-  std::make_pair(i, 1); // no-warning
-  std::make_pair(t, 1);
-}

Removed: 
clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp?rev=247265&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-member-string-references.cpp 
(removed)
@@ -1,49 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s 
google-runtime-member-string-references %t
-
-namespace std {
-template
-  class basic_string {};
-
-typedef basic_string string;
-}
-
-class string {};
-
-
-struct A {
-  const std::string &s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are 
dangerous. It is much better to use alternatives, such as pointers or simple 
constants. [google-runtime-member-string-references]
-};
-
-struct B {
-  std::string &s;
-};
-
-struct C {
-  const std::string s;
-};
-
-template 
-struct D {
-  D();
-  const T &s;
-  const std::string &s2;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are 
dangerous.
-};
-
-D d;
-
-struct AA {
-  const string &s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: const string& members are 
dangerous.
-};
-
-struct BB {
-  string &s;
-};
-
-struct CC {
-  const string s;
-};
-
-D dd;

Removed: clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp?rev=247265&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-memset-zero-length.cpp 
(removed)
@@ -1,60 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s google-runtime-memset %t
-
-void *memset(void *, int, __SIZE_TYPE__);
-
-namespace std {
-  using ::memset;
-}
-
-template 
-void memtmpl() {
-  memset(0, sizeof(int), i);
-  memset(0, sizeof(T), sizeof(T));
-  memset(0, sizeof(T), 0);
-// CHECK-MESSAGES: :

Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:468-470
@@ +467,5 @@
+// are VarDecl). If the index is captured by value, add '&' to capture
+// by reference instead.
+ReplaceText =
+Usage.Kind == Usage::UK_CaptureByCopy ? "&" + VarName : VarName;
+  }

Isn't it the other way round?


Comment at: clang-tidy/modernize/LoopConvertUtils.h:200-205
@@ -199,1 +199,8 @@
 struct Usage {
+  enum UsageKind {
+UK_Default,
+UK_MemberThroughArrow,
+UK_CaptureByCopy,
+UK_CaptureByRef
+  };
+  // The expression that is going to be converted. Null in case of lambda

Please comment the enumerators. Do we need default? Is that always a member 
expression or sometimes also something else?


http://reviews.llvm.org/D12734



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


r247268 - [OPENMP] Fix test incompatibility with Windows codegen.

2015-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 10 06:09:46 2015
New Revision: 247268

URL: http://llvm.org/viewvc/llvm-project?rev=247268&view=rev
Log:
[OPENMP] Fix test incompatibility with Windows codegen.

Modified:
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=247268&r1=247267&r2=247268&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Thu Sep 10 06:09:46 2015
@@ -54,7 +54,7 @@ int main (int argc, char **argv) {
 // CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) 
[[ARGC_ADDR:%[^)]+]])
 // CHECK-SAME:   #[[FN_ATTRS:[0-9]+]]
 // CHECK:   store i32* [[ARGC_ADDR]], i32** [[ARGC_PTR_ADDR:%.+]],
-// CHECK-NEXT:  [[ARGC_REF:%.+]] = load i32*, i32** [[ARGC_PTR_ADDR]]
+// CHECK:   [[ARGC_REF:%.+]] = load i32*, i32** [[ARGC_PTR_ADDR]]
 // CHECK-NEXT:  [[ARGC:%.+]] = load i32, i32* [[ARGC_REF]]
 // CHECK-NEXT:  invoke {{.*}}void [[FOO:@.+foo.+]](i32{{[ ]?[a-z]*}} [[ARGC]])
 // CHECK:   call {{.+}} @__kmpc_cancel_barrier(


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


r247270 - [OPENMP] Fix test incompatibility with Windows.

2015-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 10 06:31:04 2015
New Revision: 247270

URL: http://llvm.org/viewvc/llvm-project?rev=247270&view=rev
Log:
[OPENMP] Fix test incompatibility with Windows.

Modified:
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=247270&r1=247269&r2=247270&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Thu Sep 10 06:31:04 2015
@@ -98,7 +98,7 @@ int main (int argc, char **argv) {
 
 // CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc)
 // CHECK:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
-// CHECK-NEXT:  [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
+// CHECK:   [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // CHECK-NEXT:  [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]
 // CHECK-NEXT:  invoke {{.*}}void [[FOO1:@.+foo.+]](i8** [[ARGC]])
 // CHECK:   call {{.+}} @__kmpc_cancel_barrier(
@@ -108,7 +108,7 @@ int main (int argc, char **argv) {
 // CHECK-NEXT:  }
 // CHECK-DEBUG:   define internal void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc)
 // CHECK-DEBUG:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
-// CHECK-DEBUG:  [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
+// CHECK-DEBUG:   [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // CHECK-DEBUG-NEXT:  [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]
 // CHECK-DEBUG-NEXT:  invoke void [[FOO1:@.+foo.+]](i8** [[ARGC]])
 // CHECK-DEBUG:   call {{.+}} @__kmpc_cancel_barrier(


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


Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-10 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 34423.
NoQ added a comment.

Make the tests easier to understand.


http://reviews.llvm.org/D12725

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-arith.c

Index: test/Analysis/ptr-arith.c
===
--- test/Analysis/ptr-arith.c
+++ test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval(&points[i].x < &points[i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }


Index: test/Analysis/ptr-arith.c
===
--- test/Analysis/ptr-arith.c
+++ test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval(&points[i].x < &points[i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-10 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Thanks, fixed :)


http://reviews.llvm.org/D12725



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


Re: [PATCH] D12734: Another patch for modernize-loop-convert.

2015-09-10 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 34428.
angelgarcia added a comment.

Comment the enumerators.

> Do we need default?


I think so. We need to set the cases that do not fall in any of these 
categories to something, and I think that using one of the other three as the 
default kind would be confusing. But maybe there is a better name than just 
UK_Default. Any ideas?


http://reviews.llvm.org/D12734

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/Inputs/modernize-loop-convert/structures.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -290,7 +290,6 @@
 dependent v;
 dependent *pv;
 
-transparent> cv;
 int Sum = 0;
 
 // Checks for the Index start and end:
@@ -473,3 +472,41 @@
 }
 
 } // namespace NegativeMultiEndCall
+
+namespace NoUsages {
+
+const int N = 6;
+int arr[N] = {1, 2, 3, 4, 5, 6};
+S s;
+dependent v;
+int Count = 0;
+
+void foo();
+
+void f() {
+  for (int I = 0; I < N; ++I) {}
+  for (int I = 0; I < N; ++I)
+printf("Hello world\n");
+  for (int I = 0; I < N; ++I)
+++Count;
+  for (int I = 0; I < N; ++I)
+foo();
+
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I) {}
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+printf("Hello world\n");
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+++Count;
+  for (S::iterator I = s.begin(), E = s.end(); I != E; ++I)
+foo();
+
+  for (int I = 0; I < v.size(); ++I) {}
+  for (int I = 0; I < v.size(); ++I)
+printf("Hello world\n");
+  for (int I = 0; I < v.size(); ++I)
+++Count;
+  for (int I = 0; I < v.size(); ++I)
+foo();
+}
+
+} // namespace NoUsages
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -14,10 +14,9 @@
 int b = arr[i][a];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : arr) {
+  // CHECK-FIXES: for (auto & elem : arr)
   // CHECK-FIXES-NEXT: int a = 0;
   // CHECK-FIXES-NEXT: int b = elem[a];
-  // CHECK-FIXES-NEXT: }
 
   for (int j = 0; j < M; ++j) {
 int a = 0;
@@ -121,16 +120,16 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: if (alias) {
+  // CHECK-FIXES-NEXT: if (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 while (int alias = IntArr[i]) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: while (alias) {
+  // CHECK-FIXES-NEXT: while (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 switch (int alias = IntArr[i]) {
@@ -140,32 +139,32 @@
   }
   // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: switch (alias) {
+  // CHECK-FIXES-NEXT: switch (alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (int alias = IntArr[i]; alias < N; ++alias) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (; alias < N; ++alias) {
+  // CHECK-FIXES-NEXT: for (; alias < N; ++alias)
 
   for (unsigned i = 0; i < N; ++i) {
 for (unsigned j = 0; int alias = IntArr[i]; ++j) {
   sideEffect(alias);
 }
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto alias : IntArr)
-  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j) {
+  // CHECK-FIXES-NEXT: for (unsigned j = 0; alias; ++j)
 
   struct IntRef { IntRef(const int& i); };
   for (int i = 0; i < N; ++i) {
 IntRef Int(IntArr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : IntArr) {
+  // CHECK-FIXES: for (auto & elem : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(elem);
 }
 
@@ -288,7 +287,7 @@
   }
   // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (auto & DEFs_it : DEFs)
-  // CHECK-FIXES-NEXT: if (DEFs_it == DEF) {
+  // CHECK-FIXES-NEXT: if (DEFs_it == DEF)
   // CHECK-FIXES-NEXT: printf("I found %d\n", DEFs_it);
 }
 
@@ -315,8 +314,8 @@
   T Vals;
   // Using the name "Val", alt

r247273 - [OPENMP] Generate threadprivates as TLS variables by default.

2015-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 10 07:06:58 2015
New Revision: 247273

URL: http://llvm.org/viewvc/llvm-project?rev=247273&view=rev
Log:
[OPENMP] Generate threadprivates as TLS variables by default.
If target supports TLS all threadprivates are generated as TLS. If target does 
not support TLS, use runtime calls for proper codegen of threadprivate 
variables.

Added:
cfe/trunk/test/OpenMP/driver.c   (with props)
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=247273&r1=247272&r2=247273&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 10 07:06:58 2015
@@ -4205,10 +4205,7 @@ void Clang::ConstructJob(Compilation &C,
   // given, decide a default based on the target. Otherwise rely on the
   // options and pass the right information to the frontend.
   if (!Args.hasFlag(options::OPT_fopenmp_use_tls,
-options::OPT_fnoopenmp_use_tls,
-getToolChain().getArch() == llvm::Triple::ppc ||
-getToolChain().getArch() == llvm::Triple::ppc64 ||
-getToolChain().getArch() == llvm::Triple::ppc64le))
+options::OPT_fnoopenmp_use_tls, /*Default=*/true))
 CmdArgs.push_back("-fnoopenmp-use-tls");
   break;
 default:

Added: cfe/trunk/test/OpenMP/driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=247273&view=auto
==
--- cfe/trunk/test/OpenMP/driver.c (added)
+++ cfe/trunk/test/OpenMP/driver.c Thu Sep 10 07:06:58 2015
@@ -0,0 +1,10 @@
+// Test that by default -fnoopenmp-use-tls is passed to frontend.
+//
+// RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck 
--check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT-NOT: -fnoopenmp-use-tls
+//
+// RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp -fnoopenmp-use-tls | 
FileCheck --check-prefix=CHECK-NO-TLS %s
+// CHECK-NO-TLS: -cc1
+// CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
+//

Propchange: cfe/trunk/test/OpenMP/driver.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/OpenMP/driver.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/OpenMP/driver.c
--
svn:mime-type = text/plain


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


D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2015-09-10 Thread Evgeny Astigeevich via cfe-commits
Ping.
Could anyone review the patch?

Kind regards,
Evgeny Astigeevich

-Original Message-
From: Evgeny Astigeevich [mailto:evgeny.astigeev...@arm.com]
Sent: 08 September 2015 11:00
To: Evgeny Astigeevich
Cc: cfe-commits@lists.llvm.org
Subject: [PATCH] D12689: [libc++][static linking] std streams are not 
initialized prior to their use in static object constructors

eastig created this revision.
eastig added a subscriber: cfe-commits.

When an executable (e.g. for bare metal environment) is statically linked  with 
libc++ the following code might not work as expected:

```
#include 

class Foo {
public:
  Foo(int n) {
std::cout << "Hello World - " << n << std::endl;
  }
};

Foo f(5);

int main() {
  return 0;
}
```
The program hangs or crashes because 'std::cout' is not initialized before 'Foo 
f(5)'.

The standard says:

> 27.3 Standard iostream objects
> Header  synopsis
> (2) ... The objects are constructed, and the associations are
> established at some time prior to or during first time an object of
> class basic_ios::Init is constructed, and in any case before 
> the body of main begins execution [264]. The objects are not destroyed during 
> program execution [265].
>

And footnote 265 says:

> Constructors and destructors for static objects can access these
> objects to read input from stdin or write output to stdout or stderr.

The similar issue was raised more than year ago. A patch was proposed but not 
committed. See discussion of it here:

[[ 
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130304/075363.html 
| initial patch ]] [[ 
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130325/077130.html 
| review, suggestion for #ifdef ]]

The proposed patch caused initialization/deinitialization of the std streams as 
many times as the static Init objects were created.
The current patch fixes this issue. A number of uses is counted by means of 
__shared_count. It is used instead of a 'int' variable because it is 
thread-safe. The standard allows multi-threaded initialization of static 
objects from different compilation modules.



http://reviews.llvm.org/D12689

Files:
  include/ios
  src/iostream.cpp


-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No:  2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No:  2548782
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247277 - AVX-512: Changed nidx parameter in extractf64/32 intrinsic from i8 to i32 according to the Intel Spec

2015-09-10 Thread Igor Breger via cfe-commits
Author: ibreger
Date: Thu Sep 10 07:55:54 2015
New Revision: 247277

URL: http://llvm.org/viewvc/llvm-project?rev=247277&view=rev
Log:
AVX-512: Changed nidx parameter in extractf64/32 intrinsic from i8 to i32 
according to the Intel Spec

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

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=247277&r1=247276&r2=247277&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Sep 10 07:55:54 2015
@@ -1032,8 +1032,8 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var
 TARGET_BUILTIN(__builtin_ia32_vpermt2varpd512_mask, "V8dV8LLiV8dV8dUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_alignq512_mask, "V8LLiV8LLiV8LLiIiV8LLiUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_alignd512_mask, "V16iV16iV16iIiV16iUs", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIcV4dUc", "", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIcV4fUc", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIiV4dUc", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIiV4fUc", "", 
"avx512f")
 
 TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8dvC*V8iUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*UsIi", "", "avx512f")


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


[clang-tools-extra] r247282 - [clang-tidy] add_new_check.py improvements: add doc file, refer it from .h

2015-09-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep 10 08:56:39 2015
New Revision: 247282

URL: http://llvm.org/viewvc/llvm-project?rev=247282&view=rev
Log:
[clang-tidy] add_new_check.py improvements: add doc file, refer it from .h

+ some console logging and minor cleanups.

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=247282&r1=247281&r2=247282&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Thu Sep 10 08:56:39 2015
@@ -19,9 +19,7 @@ import sys
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
   with open(filename, 'r') as f:
-lines = f.read().split('\n')
-  # .split with separator returns one more element. Ignore it.
-  lines = lines[:-1]
+lines = f.readlines()
 
   cpp_file = check_name_camel + '.cpp'
 
@@ -30,24 +28,27 @@ def adapt_cmake(module_path, check_name_
 if line.strip() == cpp_file:
   return False
 
+  print('Updating %s...' % filename)
   with open(filename, 'w') as f:
 cpp_found = False
 file_added = False
 for line in lines:
-  cpp_line = line.endswith('.cpp')
+  cpp_line = line.strip().endswith('.cpp')
   if (not file_added) and (cpp_line or cpp_found):
 cpp_found = True
 if (line.strip() > cpp_file) or (not cpp_line):
   f.write('  ' + cpp_file + '\n')
   file_added = True
-  f.write(line + '\n')
+  f.write(line)
 
   return True
 
 
 # Adds a header for the new check.
 def write_header(module_path, module, check_name, check_name_camel):
+  check_name_dashes = module + '-' + check_name
   filename = os.path.join(module_path, check_name_camel) + '.h'
+  print('Creating %s...' % filename)
   with open(filename, 'w') as f:
 header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() +
 '_' + check_name.upper().replace('-', '_') + '_H')
@@ -73,6 +74,10 @@ def write_header(module_path, module, ch
 namespace clang {
 namespace tidy {
 
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/%(check_name_dashes)s.html
 class %(check_name)s : public ClangTidyCheck {
 public:
   %(check_name)s(StringRef Name, ClangTidyContext *Context)
@@ -87,12 +92,14 @@ public:
 #endif // %(header_guard)s
 
 """ % {'header_guard': header_guard,
-   'check_name': check_name_camel})
+   'check_name': check_name_camel,
+   'check_name_dashes': check_name_dashes})
 
 
 # Adds the implementation of the new check.
 def write_implementation(module_path, check_name_camel):
   filename = os.path.join(module_path, check_name_camel) + '.cpp'
+  print('Creating %s...' % filename)
   with open(filename, 'w') as f:
 f.write('//===--- ')
 f.write(os.path.basename(filename))
@@ -142,10 +149,9 @@ void %(check_name)s::check(const MatchFi
 def adapt_module(module_path, module, check_name, check_name_camel):
   filename = os.path.join(module_path, module.capitalize() + 'TidyModule.cpp')
   with open(filename, 'r') as f:
-lines = f.read().split('\n')
-  # .split with separator returns one more element. Ignore it.
-  lines = lines[:-1]
+lines = f.readlines()
 
+  print('Updating %s...' % filename)
   with open(filename, 'w') as f:
 header_added = False
 header_found = False
@@ -174,14 +180,16 @@ def adapt_module(module_path, module, ch
   if match and match.group(1) > check_name_camel:
 check_added = True
 f.write(check_decl)
-  f.write(line + '\n')
+  f.write(line)
 
 
 # Adds a test for the check.
 def write_test(module_path, module, check_name):
   check_name_dashes = module + '-' + check_name
-  filename = os.path.join(module_path, '../../test/clang-tidy',
-  check_name_dashes + '.cpp')
+  filename = os.path.normpath(
+  os.path.join(module_path, '../../test/clang-tidy',
+   check_name_dashes + '.cpp'))
+  print('Creating %s...' % filename)
   with open(filename, 'w') as f:
 f.write(
 """// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t
@@ -200,6 +208,42 @@ void f();
 void awesome_f2();
 """ % {"check_name_dashes" : check_name_dashes})
 
+# Recreates the list of checks in the docs/clang-tidy/checks directory.
+def update_checks_list(module_path):
+  filename = os.path.normpath(
+  os.path.join(module_path, '../../docs/clang-tidy/checks/list.rst'))
+  with open(filename, 'r') as f:
+lines = f.readlines()
+
+  checks = map(lambda s: '   ' + s.replace('.rst', '\n'),
+   filter(lambda s: s.endswith('.rst') and s != 'list.rst',
+  os.listdir('docs/clang-tidy/checks')))
+  checks.sort(

[PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added a reviewer: djasper.
alexfh added a subscriber: cfe-commits.

sizeof(some_std_string) is likely to be an error. This check finds this
pattern and suggests using .size() instead.

http://reviews.llvm.org/D12759

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SizeofContainerCheck.cpp
  clang-tidy/misc/SizeofContainerCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-sizeof-container.rst
  test/clang-tidy/misc-sizeof-container.cpp

Index: test/clang-tidy/misc-sizeof-container.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-sizeof-container.cpp
@@ -0,0 +1,42 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t
+
+namespace std {
+template 
+class basic_string {};
+
+template 
+basic_string operator+(const basic_string &, const T *);
+
+typedef basic_string string;
+
+template 
+class vector {};
+}
+
+class string {};
+
+void f() {
+  string s1;
+  std::string s2;
+  std::vector v;
+
+  int a = 42 + sizeof(s1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container. Did you mean .size()? [misc-sizeof-container]
+// CHECK-FIXES: int a = 42 + s1.size();
+  a = 123 * sizeof(s2);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 123 * s2.size();
+  a = 45 + sizeof(s2 + "asdf");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 45 + (s2 + "asdf").size();
+  a = sizeof(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = v.size();
+
+  a = sizeof(a);
+  a = sizeof(int);
+  a = sizeof(std::string);
+  a = sizeof(std::vector);
+
+  (void)a;
+}
Index: docs/clang-tidy/checks/misc-sizeof-container.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-sizeof-container.rst
@@ -0,0 +1,17 @@
+misc-sizeof-container
+=
+
+The check finds usages of ``sizeof`` on expressions of STL container types. Most
+likely the user wanted to use ``.size()`` instead.
+
+Currently only ``std::string`` and ``std::vector`` are supported.
+
+Examples:
+
+.. code:: c++
+
+  std::string s;
+  int a = 47 + sizeof(s); // warning: sizeof() doesn't return the size of the container. Did you mean .size()?
+  // The suggested fix is: int a = 47 + s.size();
+
+  int b = sizeof(std::string); // no warning, probably intended.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -31,6 +31,7 @@
misc-macro-repeated-side-effects
misc-move-constructor-init
misc-noexcept-move-constructor
+   misc-sizeof-container
misc-static-assert
misc-swapped-arguments
misc-undelegated-constructor
@@ -54,4 +55,4 @@
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
-   readability-simplify-boolean-expr
\ No newline at end of file
+   readability-simplify-boolean-expr
Index: clang-tidy/misc/SizeofContainerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.h
@@ -0,0 +1,35 @@
+//===--- SizeofContainerCheck.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_SIZEOF_CONTAINER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Find usages of sizeof on expressions of STL container types. Most likely the
+/// user wanted to use `.size()` instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-sizeof-container.html
+class SizeofContainerCheck : public ClangTidyCheck {
+public:
+  SizeofContainerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
Index: clang-tidy/misc/SizeofContainerCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.cpp
@@ -0,0 +1,76 @@
+//===--- SizeofContainerCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler

Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 34441.
alexfh added a comment.

Ignore template instantiations.


http://reviews.llvm.org/D12759

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SizeofContainerCheck.cpp
  clang-tidy/misc/SizeofContainerCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-sizeof-container.rst
  test/clang-tidy/misc-sizeof-container.cpp

Index: test/clang-tidy/misc-sizeof-container.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-sizeof-container.cpp
@@ -0,0 +1,51 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t
+
+namespace std {
+template 
+class basic_string {};
+
+template 
+basic_string operator+(const basic_string &, const T *);
+
+typedef basic_string string;
+
+template 
+class vector {};
+}
+
+class string {};
+
+template
+void g(T t) {
+  (void)sizeof(t);
+}
+
+void f() {
+  string s1;
+  std::string s2;
+  std::vector v;
+
+  int a = 42 + sizeof(s1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container. Did you mean .size()? [misc-sizeof-container]
+// CHECK-FIXES: int a = 42 + s1.size();
+  a = 123 * sizeof(s2);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 123 * s2.size();
+  a = 45 + sizeof(s2 + "asdf");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 45 + (s2 + "asdf").size();
+  a = sizeof(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = v.size();
+
+  a = sizeof(a);
+  a = sizeof(int);
+  a = sizeof(std::string);
+  a = sizeof(std::vector);
+
+  g(s1);
+  g(s2);
+  g(v);
+
+  (void)a;
+}
Index: docs/clang-tidy/checks/misc-sizeof-container.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-sizeof-container.rst
@@ -0,0 +1,17 @@
+misc-sizeof-container
+=
+
+The check finds usages of ``sizeof`` on expressions of STL container types. Most
+likely the user wanted to use ``.size()`` instead.
+
+Currently only ``std::string`` and ``std::vector`` are supported.
+
+Examples:
+
+.. code:: c++
+
+  std::string s;
+  int a = 47 + sizeof(s); // warning: sizeof() doesn't return the size of the container. Did you mean .size()?
+  // The suggested fix is: int a = 47 + s.size();
+
+  int b = sizeof(std::string); // no warning, probably intended.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -31,6 +31,7 @@
misc-macro-repeated-side-effects
misc-move-constructor-init
misc-noexcept-move-constructor
+   misc-sizeof-container
misc-static-assert
misc-swapped-arguments
misc-undelegated-constructor
@@ -54,4 +55,4 @@
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
-   readability-simplify-boolean-expr
\ No newline at end of file
+   readability-simplify-boolean-expr
Index: clang-tidy/misc/SizeofContainerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.h
@@ -0,0 +1,35 @@
+//===--- SizeofContainerCheck.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_SIZEOF_CONTAINER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Find usages of sizeof on expressions of STL container types. Most likely the
+/// user wanted to use `.size()` instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-sizeof-container.html
+class SizeofContainerCheck : public ClangTidyCheck {
+public:
+  SizeofContainerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
Index: clang-tidy/misc/SizeofContainerCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.cpp
@@ -0,0 +1,77 @@
+//===--- SizeofContainerCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is d

Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

Great idea for a checker! Some comments below.



Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:36
@@ +35,3 @@
+  Finder->addMatcher(
+  expr(sizeOfExpr(
+   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(

Do you need the expr() matcher?


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:38
@@ +37,3 @@
+   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(
+   matchesName("std::(basic_string|vector)|::string")
+  .bind("sizeof"),

I think that this should be checking for more than just basic_string and 
vector. Why not other containers? For instance, anything that exposes a member 
function with a size() function seems like it would be reasonable.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:48
@@ +47,3 @@
+  SourceLocation SizeOfLoc = SizeOf->getLocStart();
+  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the "
+  "container. Did you mean .size()?");

I think the period should be replaced with a semicolon (it's not a sentence, so 
the period is also wrong). e.g. (with some wording tweaks),

"sizeof() does not return the size of the container; did you mean to call 
size()?"

Also, is this actually emitting the diagnostic? If so, a comment would be good 
explaining why the early return for macros is located where it is, so no one 
does a drive-by "fix."


http://reviews.llvm.org/D12759



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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 34446.
alexfh added a comment.

Match a broader set of containers. Updated diagnostic message. Added tests.


http://reviews.llvm.org/D12759

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SizeofContainerCheck.cpp
  clang-tidy/misc/SizeofContainerCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-sizeof-container.rst
  test/clang-tidy/misc-sizeof-container.cpp

Index: test/clang-tidy/misc-sizeof-container.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-sizeof-container.cpp
@@ -0,0 +1,78 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t
+
+namespace std {
+
+typedef unsigned int size_t;
+
+template 
+struct basic_string {
+  size_t size() const;
+};
+
+template 
+basic_string operator+(const basic_string &, const T *);
+
+typedef basic_string string;
+
+template 
+struct vector {
+  size_t size() const;
+};
+
+class fake_container1 {
+  size_t size() const; // non-public
+};
+
+struct fake_container2 {
+  size_t size(); // non-const
+};
+
+}
+
+struct string {
+  std::size_t size() const;
+};
+
+template
+void g(T t) {
+  (void)sizeof(t);
+}
+
+void f() {
+  string s1;
+  std::string s2;
+  std::vector v;
+
+  int a = 42 + sizeof(s1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container; did you mean .size()? [misc-sizeof-container]
+// CHECK-FIXES: int a = 42 + s1.size();
+  a = 123 * sizeof(s2);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 123 * s2.size();
+  a = 45 + sizeof(s2 + "asdf");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 45 + (s2 + "asdf").size();
+  a = sizeof(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = v.size();
+  a = sizeof(std::vector{});
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = std::vector{}.size();
+
+  a = sizeof(a);
+  a = sizeof(int);
+  a = sizeof(std::string);
+  a = sizeof(std::vector);
+
+  g(s1);
+  g(s2);
+  g(v);
+
+  std::fake_container1 f1;
+  std::fake_container2 f2;
+
+  a = sizeof(f1);
+  a = sizeof(f2);
+
+  (void)a;
+}
Index: docs/clang-tidy/checks/misc-sizeof-container.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-sizeof-container.rst
@@ -0,0 +1,17 @@
+misc-sizeof-container
+=
+
+The check finds usages of ``sizeof`` on expressions of STL container types. Most
+likely the user wanted to use ``.size()`` instead.
+
+Currently only ``std::string`` and ``std::vector`` are supported.
+
+Examples:
+
+.. code:: c++
+
+  std::string s;
+  int a = 47 + sizeof(s); // warning: sizeof() doesn't return the size of the container. Did you mean .size()?
+  // The suggested fix is: int a = 47 + s.size();
+
+  int b = sizeof(std::string); // no warning, probably intended.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -31,6 +31,7 @@
misc-macro-repeated-side-effects
misc-move-constructor-init
misc-noexcept-move-constructor
+   misc-sizeof-container
misc-static-assert
misc-swapped-arguments
misc-undelegated-constructor
@@ -54,4 +55,4 @@
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
-   readability-simplify-boolean-expr
\ No newline at end of file
+   readability-simplify-boolean-expr
Index: clang-tidy/misc/SizeofContainerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.h
@@ -0,0 +1,35 @@
+//===--- SizeofContainerCheck.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_SIZEOF_CONTAINER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Find usages of sizeof on expressions of STL container types. Most likely the
+/// user wanted to use `.size()` instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-sizeof-container.html
+class SizeofContainerCheck : public ClangTidyCheck {
+public:
+  SizeofContainerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void ch

Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh marked 3 inline comments as done.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:37
@@ +36,3 @@
+  expr(unless(isInTemplateInstantiation()),
+   sizeOfExpr(
+   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(

Yes, I do. `sizeOfExpr().bind("...")` doesn't compile for some reason.

```
tools/clang/tools/extra/clang-tidy/misc/SizeofContainerCheck.cpp:24:35: error: 
no member named 'bind' in 'clang::ast_matchers::internal::Matcher'
  .bind("expr"))).bind("sizeof"),
  ~~~ ^
```


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:39
@@ +38,3 @@
+   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(
+   matchesName("std::(basic_string|vector)|::string")
+  .bind("sizeof"),

I'd like to limit this to the STL containers first. So "any recordDecl named 
std::.* with a .size() method" might work.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:49
@@ +48,3 @@
+  SourceLocation SizeOfLoc = SizeOf->getLocStart();
+  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the "
+  "container. Did you mean .size()?");

1. Done.
2. It's actually emitting the diagnostic. And I thought that the comment on 
line 52 below explains what happens in enough detail (`// Don't generate fixes 
for macros.`). If something is still unclear, can you explain what exactly?


http://reviews.llvm.org/D12759



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


r247286 - Properly close documentation /code blocks with /endcode.

2015-09-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Sep 10 10:13:22 2015
New Revision: 247286

URL: http://llvm.org/viewvc/llvm-project?rev=247286&view=rev
Log:
Properly close documentation /code blocks with /endcode.

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

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=247286&r1=247285&r2=247286&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Sep 10 10:13:22 2015
@@ -1870,7 +1870,7 @@ AST_MATCHER_P_OVERLOAD(CXXRecordDecl, is
 /// \code
 ///   class A { void func(); };
 ///   class B { void member(); };
-/// \code
+/// \endcode
 ///
 /// \c recordDecl(hasMethod(hasName("func"))) matches the declaration of \c A
 /// but not \c B.
@@ -2319,7 +2319,7 @@ AST_MATCHER_P(QualType, references, inte
 ///   typedef int &int_ref;
 ///   int a;
 ///   int_ref b = a;
-/// \code
+/// \endcode
 ///
 /// \c varDecl(hasType(qualType(referenceType()) will not match the
 /// declaration of b but \c
@@ -3090,6 +3090,7 @@ AST_MATCHER_P(UnaryOperator, hasUnaryOpe
 /// \code
 /// class URL { URL(string); };
 /// URL url = "a string";
+/// \endcode
 AST_MATCHER_P(CastExpr, hasSourceExpression,
   internal::Matcher, InnerMatcher) {
   const Expr* const SubExpression = Node.getSubExpr();
@@ -3854,7 +3855,7 @@ AST_TYPE_MATCHER(TypedefType, typedefTyp
 ///
 ///   template class C;  // A
 ///   C var;// B
-/// \code
+/// \endcode
 ///
 /// \c templateSpecializationType() matches the type of the explicit
 /// instantiation in \c A and the type of the variable declaration in \c B.
@@ -3879,7 +3880,7 @@ AST_TYPE_MATCHER(UnaryTransformType, una
 ///
 ///   C c;
 ///   S s;
-/// \code
+/// \endcode
 ///
 /// \c recordType() matches the type of the variable declarations of both \c c
 /// and \c s.
@@ -3899,7 +3900,7 @@ AST_TYPE_MATCHER(RecordType, recordType)
 ///
 ///   class C c;
 ///   N::M::D d;
-/// \code
+/// \endcode
 ///
 /// \c elaboratedType() matches the type of the variable declarations of both
 /// \c c and \c d.
@@ -3916,7 +3917,7 @@ AST_TYPE_MATCHER(ElaboratedType, elabora
 /// }
 ///   }
 ///   N::M::D d;
-/// \code
+/// \endcode
 ///
 /// \c elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"
 /// matches the type of the variable declaration of \c d.
@@ -3938,7 +3939,7 @@ AST_MATCHER_P(ElaboratedType, hasQualifi
 /// }
 ///   }
 ///   N::M::D d;
-/// \code
+/// \endcode
 ///
 /// \c elaboratedType(namesType(recordType(
 /// hasDeclaration(namedDecl(hasName("D")) matches the type of the variable
@@ -3957,7 +3958,7 @@ AST_MATCHER_P(ElaboratedType, namesType,
 ///   void F(T t) {
 /// int i = 1 + t;
 ///   }
-/// \code
+/// \endcode
 ///
 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
 AST_TYPE_MATCHER(SubstTemplateTypeParmType, substTemplateTypeParmType);
@@ -3972,7 +3973,7 @@ AST_TYPE_MATCHER(SubstTemplateTypeParmTy
 ///   class D {};
 /// }
 ///   }
-/// \code
+/// \endcode
 ///
 /// \c recordDecl(hasDeclContext(namedDecl(hasName("M" matches the
 /// declaration of \c class \c D.


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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
On Thu, Sep 10, 2015 at 10:54 AM, Alexander Kornienko  wrote:
> alexfh marked 3 inline comments as done.
>
> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:37
> @@ +36,3 @@
> +  expr(unless(isInTemplateInstantiation()),
> +   sizeOfExpr(
> +   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(
> 
> Yes, I do. `sizeOfExpr().bind("...")` doesn't compile for some reason.
>
> ```
> tools/clang/tools/extra/clang-tidy/misc/SizeofContainerCheck.cpp:24:35: 
> error: no member named 'bind' in 
> 'clang::ast_matchers::internal::Matcher'
>   .bind("expr"))).bind("sizeof"),
>   ~~~ ^
> ```

That's kind of strange, but okay!

> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:39
> @@ +38,3 @@
> +   has(expr(hasType(hasCanonicalType(hasDeclaration(recordDecl(
> +   matchesName("std::(basic_string|vector)|::string")
> +  .bind("sizeof"),
> 
> I'd like to limit this to the STL containers first. So "any recordDecl named 
> std::.* with a .size() method" might work.

Sounds reasonable to me.

> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:49
> @@ +48,3 @@
> +  SourceLocation SizeOfLoc = SizeOf->getLocStart();
> +  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the "
> +  "container. Did you mean .size()?");
> 
> 1. Done.
> 2. It's actually emitting the diagnostic. And I thought that the comment on 
> line 52 below explains what happens in enough detail (`// Don't generate 
> fixes for macros.`). If something is still unclear, can you explain what 
> exactly?

It's not intuitive that creating the local variable actually emits the
diagnostic, so it seems like you would be able to hoist the early
return up above the local declaration when in fact that would remove
the diagnostic entirely. The comment about generating fixes suggests
an additional diagnostic, at least to me.

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


Re: [PATCH] D10414: Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option

2015-09-10 Thread Jim Grosbach via cfe-commits

> On Sep 10, 2015, at 1:24 AM, James Molloy  wrote:
> 
> jmolloy added a subscriber: jmolloy.
> jmolloy added a comment.
> 
> Hi Akira,
> 
> I'm sorry to be contrary (and I missed the discussion on Tuesday because I 
> was away on vacation) but I think there *is* a usecase for -mno-restrict-it 
> to work, and I would hate to see it broken.
> 
> Non-restricted IT blocks are indeed deprecated for ARMv8 in the ARMARM. But 
> there are circumstances where you may still want to emit them - the biggest 
> example being you're compiling for a CPU microarchitecture that you *know* 
> doesn't have a performance penalty on non-restricted IT blocks. Restricted IT 
> blocks can pessimize code quite badly in some circumstances, and allowing 
> people to turn it off for their target if needed is very important, IMO.

If such microarchitectures exist, shouldn’t they be represented properly as a 
CPU in the backend and get the right setting by default?




> 
> Cheers,
> 
> James
> 
> 
> http://reviews.llvm.org/D10414
> 
> 
> 

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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I noticed a few more things, but mostly nitpicky at this point.



Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:22
@@ +21,3 @@
+bool needsParens(const Expr *E) {
+  E = E->IgnoreImpCasts();
+  if (isa(E) || isa(E))

Should we also ignore parens for when people do crazy things, like 
sizeofsome_string+other_string?


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:25
@@ +24,3 @@
+return true;
+  if (const auto *Op = dyn_cast(E)) {
+return Op->getNumArgs() == 2 && Op->getOperator() != OO_Call &&

I missed this earlier, but what about other 2-arg overloaded operators, like 
placement operator new & operator delete, or operator delete with size (and 
array forms)?


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:38
@@ +37,3 @@
+   sizeOfExpr(has(expr(hasType(hasCanonicalType(hasDeclaration(
+   recordDecl(matchesName("^(::std::|::string)"),
+  hasMethod(methodDecl(hasName("size"), isPublic(),

Why is "|::string" needed?


http://reviews.llvm.org/D12759



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


Re: [PATCH] D11834: s/NDEBUG/LLVM_NDEBUG/ in most places to match the same LLVM change.

2015-09-10 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

Ping.


http://reviews.llvm.org/D11834



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


Re: [PATCH] D10414: Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option

2015-09-10 Thread Jim Grosbach via cfe-commits
grosbach added a comment.

In http://reviews.llvm.org/D10414#243056, @jmolloy wrote:

> Non-restricted IT blocks are indeed deprecated for ARMv8 in the ARMARM. But 
> there are circumstances where you may still want to emit them - the biggest 
> example being you're compiling for a CPU microarchitecture that you *know* 
> doesn't have a performance penalty on non-restricted IT blocks. Restricted IT 
> blocks can pessimize code quite badly in some circumstances, and allowing 
> people to turn it off for their target if needed is very important, IMO.


Bother, email response isn't showing up in Phab. Reposting here so there's a 
record. Sorry for the duplication on-list.

If such microarchitectures exist, shouldn’t they be represented properly as a 
CPU in the backend and get the right setting by default?


http://reviews.llvm.org/D10414



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


Re: [PATCH] D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2015-09-10 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

I think a better approach would be to use `__attribute__((init_priority(101)))` 
on Linux and `#pragma init_seg(lib)` on Windows to ensure that libc++'s 
iostream initializer runs earlier.


http://reviews.llvm.org/D12689



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


Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-09-10 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/CGCall.cpp:3598
@@ -3599,1 +3597,3 @@
+Address CodeGenFunction::EmitVAArg(Address VAListAddr, QualType Ty, bool IsMS) 
{
+  return CGM.getTypes().getABIInfo().EmitVAArg(*this, VAListAddr, Ty, IsMS);
 }

I think keeping the va_arg logic in TargetInfo.cpp is good, but we don't need 
to thread IsMS through every EmitVAArg override. Instead, we can do something 
like this here:
  if (IsMS)
return CGM.getTypes().getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty);
  return CGM.getTypes().getABIInfo().EmitVAArg(*this, VAListAddr, Ty);


http://reviews.llvm.org/D1623



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


Re: [PATCH] D10414: Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option

2015-09-10 Thread James Molloy via cfe-commits
jmolloy added a comment.

Hi Jim,

In an ideal world, yes. However there's no guarantee that all ARM implementors 
will (a) be able to commit to LLVM or (b) use ToT. Perhaps they're building a 
project that uses clang, or a specific version of clang, and this tuning option 
makes things go faster on their architecture.

I'm not arguing about the defaults, just about the breakage of -mno-restrict-it.

Cheers,

James


http://reviews.llvm.org/D10414



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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 34451.
alexfh marked 3 inline comments as done.
alexfh added a comment.

Don't complain on the ARRAYSIZE() pattern (where
sizeof(container) is used as a denominator).


http://reviews.llvm.org/D12759

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SizeofContainerCheck.cpp
  clang-tidy/misc/SizeofContainerCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-sizeof-container.rst
  test/clang-tidy/misc-sizeof-container.cpp

Index: test/clang-tidy/misc-sizeof-container.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-sizeof-container.cpp
@@ -0,0 +1,92 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-sizeof-container %t
+
+namespace std {
+
+typedef unsigned int size_t;
+
+template 
+struct basic_string {
+  size_t size() const;
+};
+
+template 
+basic_string operator+(const basic_string &, const T *);
+
+typedef basic_string string;
+
+template 
+struct vector {
+  size_t size() const;
+};
+
+class fake_container1 {
+  size_t size() const; // non-public
+};
+
+struct fake_container2 {
+  size_t size(); // non-const
+};
+
+}
+
+using std::size_t;
+
+#define ARRAYSIZE(a) \
+  ((sizeof(a) / sizeof(*(a))) / static_cast(!(sizeof(a) % sizeof(*(a)
+
+#define ARRAYSIZE2(a) \
+  (((sizeof(a)) / (sizeof(*(a / static_cast(!((sizeof(a)) % (sizeof(*(a))
+
+struct string {
+  std::size_t size() const;
+};
+
+template
+void g(T t) {
+  (void)sizeof(t);
+}
+
+void f() {
+  string s1;
+  std::string s2;
+  std::vector v;
+
+  int a = 42 + sizeof(s1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: sizeof() doesn't return the size of the container; did you mean .size()? [misc-sizeof-container]
+// CHECK-FIXES: int a = 42 + s1.size();
+  a = 123 * sizeof(s2);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 123 * s2.size();
+  a = 45 + sizeof(s2 + "asdf");
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = 45 + (s2 + "asdf").size();
+  a = sizeof(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = v.size();
+  a = sizeof(std::vector{});
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: sizeof() doesn't return the size
+// CHECK-FIXES: a = std::vector{}.size();
+
+  a = sizeof(a);
+  a = sizeof(int);
+  a = sizeof(std::string);
+  a = sizeof(std::vector);
+
+  g(s1);
+  g(s2);
+  g(v);
+
+  std::fake_container1 f1;
+  std::fake_container2 f2;
+
+  a = sizeof(f1);
+  a = sizeof(f2);
+
+
+  std::string arr[3];
+  a = ARRAYSIZE(arr);
+  a = ARRAYSIZE2(arr);
+  a = sizeof(arr) / sizeof(arr[0]);
+
+  (void)a;
+}
Index: docs/clang-tidy/checks/misc-sizeof-container.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-sizeof-container.rst
@@ -0,0 +1,17 @@
+misc-sizeof-container
+=
+
+The check finds usages of ``sizeof`` on expressions of STL container types. Most
+likely the user wanted to use ``.size()`` instead.
+
+Currently only ``std::string`` and ``std::vector`` are supported.
+
+Examples:
+
+.. code:: c++
+
+  std::string s;
+  int a = 47 + sizeof(s); // warning: sizeof() doesn't return the size of the container. Did you mean .size()?
+  // The suggested fix is: int a = 47 + s.size();
+
+  int b = sizeof(std::string); // no warning, probably intended.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -31,6 +31,7 @@
misc-macro-repeated-side-effects
misc-move-constructor-init
misc-noexcept-move-constructor
+   misc-sizeof-container
misc-static-assert
misc-swapped-arguments
misc-undelegated-constructor
@@ -54,4 +55,4 @@
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
-   readability-simplify-boolean-expr
\ No newline at end of file
+   readability-simplify-boolean-expr
Index: clang-tidy/misc/SizeofContainerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/SizeofContainerCheck.h
@@ -0,0 +1,35 @@
+//===--- SizeofContainerCheck.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_SIZEOF_CONTAINER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SIZEOF_CONTAINER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Find usages of sizeof on expressions of STL container types. Most likely the
+/// user wanted to

Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread Mehdi Amini via cfe-commits

> On Sep 9, 2015, at 7:06 PM, David Blaikie  wrote:
> 
> 
> 
> On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: mehdi_amini
> Date: Wed Sep  9 20:46:39 2015
> New Revision: 247233
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev 
> 
> Log:
> EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
> 
> This reapply a variant commit r247179 after post-commit review from
> D.Blaikie.
> Hopefully I got it right this time: lifetime of initializer list ends
> as with any expression, which make invalid the pattern:
> 
> ArrayRef Arr = { 1, 2, 3, 4};
> 
> Just like StringRef, ArrayRef shouldn't be used to initialize local
> variable but only as function argument.
> 
> Looks pretty reasonable - I'll mention it again, just in case: removing the 
> named variables and just putting the init lists directly in the call might be 
> as (or more) readable - might be worth giving it a go & running it through 
> clang-format to see what you think.

Here is an example, let me know what do you think:

  {
RecordData::value_type Record[] = {METADATA, VERSION_MAJOR, VERSION_MINOR,
   CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
   !isysroot.empty(), IncludeTimestamps,
   ASTHasCompilerErrors};
Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
  getClangFullRepositoryVersion());
  }
  Stream.EmitRecordWithBlob(
  MetadataAbbrevCode,
  (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR, CLANG_VERSION_MAJOR,
   CLANG_VERSION_MINOR, !isysroot.empty(), IncludeTimestamps,
   ASTHasCompilerErrors},
  getClangFullRepositoryVersion());

Thanks,

— 
Mehdi






> 
> - Dave
>  
> 
> From: Mehdi Amini mailto:mehdi.am...@apple.com>>
> 
> Modified:
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
> 
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9 20:46:39 2015
> @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
>  public:
>typedef SmallVector RecordData;
>typedef SmallVectorImpl RecordDataImpl;
> +  typedef ArrayRef RecordDataRef;
> 
>friend class ASTDeclWriter;
>friend class ASTStmtWriter;
> @@ -756,7 +757,7 @@ public:
>void AddPath(StringRef Path, RecordDataImpl &Record);
> 
>/// \brief Emit the current record with the given path as a blob.
> -  void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
> +  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
>StringRef Path);
> 
>/// \brief Add a version tuple to the given record
> 
> Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=247233&r1=247232&r2=247233&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
> +++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Wed Sep  9 
> 20:46:39 2015
> @@ -51,6 +51,7 @@ public:
> 
>  typedef SmallVector RecordData;
>  typedef SmallVectorImpl RecordDataImpl;
> +typedef ArrayRef RecordDataRef;
> 
>  class SDiagsWriter;
> 
> @@ -393,13 +394,9 @@ unsigned SDiagsWriter::getEmitFile(const
> 
>// Lazily generate the record for the file.
>entry = State->Files.size();
> -  RecordData Record;
> -  Record.push_back(RECORD_FILENAME);
> -  Record.push_back(entry);
> -  Record.push_back(0); // For legacy.
> -  Record.push_back(0); // For legacy.
>StringRef Name(FileName);
> -  Record.push_back(Name.size());
> +  RecordData::value_type Record[] = {RECORD_FILENAME, entry, 0 /* For legacy 
> */,
> + 0 /* For legacy */, Name.size()};
>State->Stream.EmitRecordWithBlob(State->Abbrevs.get(RECORD_FILENAME), 
> Record,
> Name);
> 
> @@ -531,14 +528,11 @@ void SDiagsWriter::EmitBlockInfoBlock()
> 
>  void SDiagsWriter::EmitMetaBlock(

Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 9:00 AM, Mehdi Amini  wrote:

>
> On Sep 9, 2015, at 7:06 PM, David Blaikie  wrote:
>
>
>
> On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: mehdi_amini
>> Date: Wed Sep  9 20:46:39 2015
>> New Revision: 247233
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev
>> Log:
>> EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
>>
>> This reapply a variant commit r247179 after post-commit review from
>> D.Blaikie.
>> Hopefully I got it right this time: lifetime of initializer list ends
>> as with any expression, which make invalid the pattern:
>>
>> ArrayRef Arr = { 1, 2, 3, 4};
>>
>> Just like StringRef, ArrayRef shouldn't be used to initialize local
>> variable but only as function argument.
>>
>
> Looks pretty reasonable - I'll mention it again, just in case: removing
> the named variables and just putting the init lists directly in the call
> might be as (or more) readable - might be worth giving it a go & running it
> through clang-format to see what you think.
>
>
> Here is an example, let me know what do you think:
>
>   {
> RecordData::value_type Record[] = {METADATA, VERSION_MAJOR,
> VERSION_MINOR,
>CLANG_VERSION_MAJOR,
> CLANG_VERSION_MINOR,
>!isysroot.empty(),
> IncludeTimestamps,
>ASTHasCompilerErrors};
> Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
>   getClangFullRepositoryVersion());
>   }
>   Stream.EmitRecordWithBlob(
>   MetadataAbbrevCode,
>   (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR,
> CLANG_VERSION_MAJOR,
>

Why the cast (uint64_t[])? I'm vaguely surprised that even compiles... ?

I would imagine it'd be passed as an init list, then turned into an
ArrayRef from there... but I guess not?


>CLANG_VERSION_MINOR, !isysroot.empty(),
> IncludeTimestamps,
>ASTHasCompilerErrors},
>   getClangFullRepositoryVersion());
>
> Thanks,
>
> —
> Mehdi
>
>
>
>
>
>
>
> - Dave
>
>
>>
>> From: Mehdi Amini 
>>
>> Modified:
>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>> cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9 20:46:39
>> 2015
>> @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
>>  public:
>>typedef SmallVector RecordData;
>>typedef SmallVectorImpl RecordDataImpl;
>> +  typedef ArrayRef RecordDataRef;
>>
>>friend class ASTDeclWriter;
>>friend class ASTStmtWriter;
>> @@ -756,7 +757,7 @@ public:
>>void AddPath(StringRef Path, RecordDataImpl &Record);
>>
>>/// \brief Emit the current record with the given path as a blob.
>> -  void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
>> +  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
>>StringRef Path);
>>
>>/// \brief Add a version tuple to the given record
>>
>> Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=247233&r1=247232&r2=247233&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
>> +++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Wed Sep  9
>> 20:46:39 2015
>> @@ -51,6 +51,7 @@ public:
>>
>>  typedef SmallVector RecordData;
>>  typedef SmallVectorImpl RecordDataImpl;
>> +typedef ArrayRef RecordDataRef;
>>
>>  class SDiagsWriter;
>>
>> @@ -393,13 +394,9 @@ unsigned SDiagsWriter::getEmitFile(const
>>
>>// Lazily generate the record for the file.
>>entry = State->Files.size();
>> -  RecordData Record;
>> -  Record.push_back(RECORD_FILENAME);
>> -  Record.push_back(entry);
>> -  Record.push_back(0); // For legacy.
>> -  Record.push_back(0); // For legacy.
>>StringRef Name(FileName);
>> -  Record.push_back(Name.size());
>> +  RecordData::value_type Record[] = {RECORD_FILENAME, entry, 0 /* For
>> legacy */,
>> + 0 /* For legacy */, Name.size()};
>>State->Stream.EmitRecordWithBlob(State->Abbrevs.get(RECORD_FILENAME),
>> Record,
>> Name);
>>
>> @@ -531,14 +528,11 @@ void SDiagsWriter::EmitBlockInfoBlock()
>>
>>  void SDiagsWriter::EmitMetaBlock() {

Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: ruiu.
rnk added a comment.

FYI @ruiu is moving this code to LLVM in http://reviews.llvm.org/D12604.



Comment at: lib/Driver/MSVCToolChain.cpp:328-340
@@ +327,15 @@
+  llvm::sys::path::append(libPath, "Lib", ucrtVersion, "ucrt");
+  switch (getArch()) {
+  case llvm::Triple::x86:
+llvm::sys::path::append(libPath, "x86");
+break;
+  case llvm::Triple::x86_64:
+llvm::sys::path::append(libPath, "x64");
+break;
+  case llvm::Triple::arm:
+llvm::sys::path::append(libPath, "arm");
+break;
+  default:
+return false;
+  }
+

Refactor this into a helper like `StringRef 
getWindowsSDKArch(llvm::Triple::Arch)` and share it with 
`getWindowsSDKLibraryPath`.


Comment at: lib/Driver/Tools.cpp:8956-8959
@@ -8955,1 +8955,6 @@
 
+std::string UniversalCRTLibPath;
+if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+   UniversalCRTLibPath.c_str()));
+

Does this have to be conditional on the version of the CRT in use? If I install 
VS 2013 and the ucrt and am trying to use the 2013 CRT, this will put both on 
the libpath. Is that a problem?


http://reviews.llvm.org/D12695



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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
alexfh marked 5 inline comments as done.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:23
@@ +22,3 @@
+  E = E->IgnoreImpCasts();
+  if (isa(E) || isa(E))
+return true;

I don't think we need to remove anything beyond the most external pair of 
parentheses.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:26
@@ +25,3 @@
+  if (const auto *Op = dyn_cast(E)) {
+return Op->getNumArgs() == 2 && Op->getOperator() != OO_Call &&
+   Op->getOperator() != OO_Subscript;

Do you have an example of an expression that will break when a `.size()` is 
appended to it? Note, that it should be an expression of a class type.


Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:39
@@ +38,3 @@
+recordDecl(matchesName("^(::std::|::string)"),
+   hasMethod(methodDecl(hasName("size"), 
isPublic(),
+isConst()))

Needed for code bases that use a std::string-like string class defined in the 
global namespace. Maybe we need a configuration option for custom container 
regexps. But this will likely be a follow up.


http://reviews.llvm.org/D12759



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


Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread Mehdi Amini via cfe-commits

> On Sep 10, 2015, at 9:02 AM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Sep 10, 2015 at 9:00 AM, Mehdi Amini  > wrote:
> 
>> On Sep 9, 2015, at 7:06 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: mehdi_amini
>> Date: Wed Sep  9 20:46:39 2015
>> New Revision: 247233
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev 
>> 
>> Log:
>> EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
>> 
>> This reapply a variant commit r247179 after post-commit review from
>> D.Blaikie.
>> Hopefully I got it right this time: lifetime of initializer list ends
>> as with any expression, which make invalid the pattern:
>> 
>> ArrayRef Arr = { 1, 2, 3, 4};
>> 
>> Just like StringRef, ArrayRef shouldn't be used to initialize local
>> variable but only as function argument.
>> 
>> Looks pretty reasonable - I'll mention it again, just in case: removing the 
>> named variables and just putting the init lists directly in the call might 
>> be as (or more) readable - might be worth giving it a go & running it 
>> through clang-format to see what you think.
> 
> Here is an example, let me know what do you think:
> 
>   {
> RecordData::value_type Record[] = {METADATA, VERSION_MAJOR, VERSION_MINOR,
>CLANG_VERSION_MAJOR, 
> CLANG_VERSION_MINOR,
>!isysroot.empty(), IncludeTimestamps,
>ASTHasCompilerErrors};
> Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
>   getClangFullRepositoryVersion());
>   }
>   Stream.EmitRecordWithBlob(
>   MetadataAbbrevCode,
>   (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR, 
> CLANG_VERSION_MAJOR,
> 
> Why the cast (uint64_t[])? I'm vaguely surprised that even compiles... ?
> 
> I would imagine it'd be passed as an init list, then turned into an ArrayRef 
> from there... but I guess not?


Might be more clear with the callee:

  template 
  void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
  StringRef Blob) {
EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
  }

The template can’t be deduced without the cast.

— 
Mehdi






>  
>CLANG_VERSION_MINOR, !isysroot.empty(), IncludeTimestamps,
>ASTHasCompilerErrors},
>   getClangFullRepositoryVersion());
> 
> Thanks,
> 
> — 
> Mehdi
> 
> 
> 
> 
> 
> 
>> 
>> - Dave
>>  
>> 
>> From: Mehdi Amini mailto:mehdi.am...@apple.com>>
>> 
>> Modified:
>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>> cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
>> 
>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9 20:46:39 
>> 2015
>> @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
>>  public:
>>typedef SmallVector RecordData;
>>typedef SmallVectorImpl RecordDataImpl;
>> +  typedef ArrayRef RecordDataRef;
>> 
>>friend class ASTDeclWriter;
>>friend class ASTStmtWriter;
>> @@ -756,7 +757,7 @@ public:
>>void AddPath(StringRef Path, RecordDataImpl &Record);
>> 
>>/// \brief Emit the current record with the given path as a blob.
>> -  void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
>> +  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
>>StringRef Path);
>> 
>>/// \brief Add a version tuple to the given record
>> 
>> Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=247233&r1=247232&r2=247233&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
>> +++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Wed Sep  9 
>> 20:46:39 2015
>> @@ -51,6 +51,7 @@ public:
>> 
>>  typedef SmallVector RecordData;
>>  typedef SmallVectorImpl RecordDataImpl;
>> +typedef ArrayRef RecordD

Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Alexander Kornienko via cfe-commits
On Thu, Sep 10, 2015 at 5:22 PM, Aaron Ballman 
wrote:

> > 
> > Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:49
> > @@ +48,3 @@
> > +  SourceLocation SizeOfLoc = SizeOf->getLocStart();
> > +  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the "
> > +  "container. Did you mean .size()?");
> > 
> > 1. Done.
> > 2. It's actually emitting the diagnostic. And I thought that the comment
> on line 52 below explains what happens in enough detail (`// Don't generate
> fixes for macros.`). If something is still unclear, can you explain what
> exactly?
>
> It's not intuitive that creating the local variable actually emits the
> diagnostic, so it seems like you would be able to hoist the early
> return up above the local declaration when in fact that would remove
> the diagnostic entirely. The comment about generating fixes suggests
> an additional diagnostic, at least to me.
>

This side effect of the diag() method is one of the core things in the
clang-tidy API for checks. The same pattern is used with other Diag/diag
methods in clang that produce various DiagnosticBuilders, and so far I
didn't see problems with it being misleading. So it shouldn't need a
comment at each usage, imho. May be a comment at the method definition
needs to cover this aspect as well, if it doesn't.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 9:07 AM, Mehdi Amini  wrote:

>
> On Sep 10, 2015, at 9:02 AM, David Blaikie  wrote:
>
>
>
> On Thu, Sep 10, 2015 at 9:00 AM, Mehdi Amini 
> wrote:
>
>>
>> On Sep 9, 2015, at 7:06 PM, David Blaikie  wrote:
>>
>>
>>
>> On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: mehdi_amini
>>> Date: Wed Sep  9 20:46:39 2015
>>> New Revision: 247233
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev
>>> Log:
>>> EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
>>>
>>> This reapply a variant commit r247179 after post-commit review from
>>> D.Blaikie.
>>> Hopefully I got it right this time: lifetime of initializer list ends
>>> as with any expression, which make invalid the pattern:
>>>
>>> ArrayRef Arr = { 1, 2, 3, 4};
>>>
>>> Just like StringRef, ArrayRef shouldn't be used to initialize local
>>> variable but only as function argument.
>>>
>>
>> Looks pretty reasonable - I'll mention it again, just in case: removing
>> the named variables and just putting the init lists directly in the call
>> might be as (or more) readable - might be worth giving it a go & running it
>> through clang-format to see what you think.
>>
>>
>> Here is an example, let me know what do you think:
>>
>>   {
>> RecordData::value_type Record[] = {METADATA, VERSION_MAJOR,
>> VERSION_MINOR,
>>CLANG_VERSION_MAJOR,
>> CLANG_VERSION_MINOR,
>>!isysroot.empty(),
>> IncludeTimestamps,
>>ASTHasCompilerErrors};
>> Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
>>   getClangFullRepositoryVersion());
>>   }
>>   Stream.EmitRecordWithBlob(
>>   MetadataAbbrevCode,
>>   (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR,
>> CLANG_VERSION_MAJOR,
>>
>
> Why the cast (uint64_t[])? I'm vaguely surprised that even compiles... ?
>
> I would imagine it'd be passed as an init list, then turned into an
> ArrayRef from there... but I guess not?
>
>
>
> Might be more clear with the callee:
>
>   template 
>   void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
>   StringRef Blob) {
> EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
>   }
>
> The template can’t be deduced without the cast.
>

Yeah, curious though. Another hole in perfect forwarding I suppose (not
that this ^ is perfect forwarding, but even with perfect forwarding it
doesn't cope well)

Yeah, the cast is rather unfortunate. Hrm.

Ah well - probably just as good to leave it as-is for now. If someone has a
flash of inspiration later & figures out a way to make it better, so be it.


>
> —
> Mehdi
>
>
>
>
>
>
>
>
>>CLANG_VERSION_MINOR, !isysroot.empty(),
>> IncludeTimestamps,
>>ASTHasCompilerErrors},
>>   getClangFullRepositoryVersion());
>>
>> Thanks,
>>
>> —
>> Mehdi
>>
>>
>>
>>
>>
>>
>>
>> - Dave
>>
>>
>>>
>>> From: Mehdi Amini 
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>>> cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
>>> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9
>>> 20:46:39 2015
>>> @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
>>>  public:
>>>typedef SmallVector RecordData;
>>>typedef SmallVectorImpl RecordDataImpl;
>>> +  typedef ArrayRef RecordDataRef;
>>>
>>>friend class ASTDeclWriter;
>>>friend class ASTStmtWriter;
>>> @@ -756,7 +757,7 @@ public:
>>>void AddPath(StringRef Path, RecordDataImpl &Record);
>>>
>>>/// \brief Emit the current record with the given path as a blob.
>>> -  void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
>>> +  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
>>>StringRef Path);
>>>
>>>/// \brief Add a version tuple to the given record
>>>
>>> Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=247233&r1=247232&r2=247233&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Wed Sep  9
>>> 20:46:39 2015
>>> @@ -51,6 +51,7 @@ public:
>>>
>>>  typedef Smal

Re: [PATCH] D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2015-09-10 Thread Evgeny Astigeevich via cfe-commits
eastig added a comment.

In http://reviews.llvm.org/D12689#243295, @rnk wrote:

> I think a better approach would be to use 
> `__attribute__((init_priority(101)))` on Linux and `#pragma init_seg(lib)` on 
> Windows to ensure that libc++'s iostream initializer runs earlier.


Thank you for advice.

I found this discussion of init_priority: Clarification of attribute 
init_priority
https://gcc.gnu.org/ml/gcc-help/2011-05/msg00220.html

It looks like it is not reliable method 
(https://gcc.gnu.org/ml/gcc-help/2011-05/msg00221.html):

> Note that although the documentation doesn't seem to mention it, the

>  init_priority attribute only works correctly when using the GNU linker

>  or gold.


Gcc libc++ does not use it.


http://reviews.llvm.org/D12689



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


[PATCH] D12767: [Static Analyzer] Properly clean up the dynamic type information for dead regions.

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, jordan_rose, krememek.
xazax.hun added a subscriber: cfe-commits.

This patch is intended to clean up the dynamic type information for regions 
that are dead. The behavior should not change.

In the a future patch it might be beneficial to factor out getDynamicTypeInfo 
and setDynamicTypeInfo from program state into free functions. This way the API 
of ProgramState could remain minimal.

http://reviews.llvm.org/D12767

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp

Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
@@ -752,12 +753,6 @@
   return Tainted;
 }
 
-/// The GDM component containing the dynamic type info. This is a map from a
-/// symbol to its most likely type.
-REGISTER_TRAIT_WITH_PROGRAMSTATE(DynamicTypeMap,
- CLANG_ENTO_PROGRAMSTATE_MAP(const MemRegion *,
- DynamicTypeInfo))
-
 DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
   Reg = Reg->StripCasts();
 
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 
@@ -27,6 +28,7 @@
 class DynamicTypePropagation:
 public Checker< check::PreCall,
 check::PostCall,
+check::DeadSymbols,
 check::PostStmt,
 check::PostStmt > {
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE,
@@ -40,9 +42,23 @@
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostStmt(const ImplicitCastExpr *CastE, CheckerContext &C) const;
   void checkPostStmt(const CXXNewExpr *NewE, CheckerContext &C) const;
+  void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
 };
 }
 
+void DynamicTypePropagation::checkDeadSymbols(SymbolReaper &SR,
+  CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  DynamicTypeMapImpl TypeMap = State->get();
+  for (DynamicTypeMapImpl::iterator I = TypeMap.begin(), E = TypeMap.end();
+   I != E; ++I) {
+if (!SR.isLiveRegion(I->first)) {
+  State = State->remove(I->first);
+}
+  }
+  C.addTransition(State);
+}
+
 static void recordFixedType(const MemRegion *Region, const CXXMethodDecl *MD,
 CheckerContext &C) {
   assert(Region);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
===
--- /dev/null
+++ include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
@@ -0,0 +1,41 @@
+//== DynamicTypeMap.h - Dynamic type map --- -*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file provides APIs for tracking dynamic type information.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICTYPEMAP_H
+#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "llvm/ADT/ImmutableMap.h"
+
+namespace clang {
+namespace ento {
+
+/// The GDM component containing the dynamic type info. This is a map from a
+/// symbol to its most likely type.

Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D12381#241709, @xazax.hun wrote:

> There are several fallouts from this review, so I decided to split this patch 
> up the following way:
>
> 1. I created a patch to incorporate the result of this review into 
> ObjCGenericsChecker: http://reviews.llvm.org/D12701
> 2. I will created a separate patch to purge the dynamic type information from 
> the GDM for dead symbols.


The second patch is available here: http://reviews.llvm.org/D12767

> 3. Once the former two patch is accepted I will rebase this patch on the top 
> of those, so this will only contain minimal changes required for the merge.



http://reviews.llvm.org/D12381



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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
On Thu, Sep 10, 2015 at 12:04 PM, Alexander Kornienko  wrote:
> alexfh marked 5 inline comments as done.
>
> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:23
> @@ +22,3 @@
> +  E = E->IgnoreImpCasts();
> +  if (isa(E) || isa(E))
> +return true;
> 
> I don't think we need to remove anything beyond the most external pair of 
> parentheses.

That's true; the extra parens would just remain as they are, we
wouldn't need to add more.

>
> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:26
> @@ +25,3 @@
> +  if (const auto *Op = dyn_cast(E)) {
> +return Op->getNumArgs() == 2 && Op->getOperator() != OO_Call &&
> +   Op->getOperator() != OO_Subscript;
> 
> Do you have an example of an expression that will break when a `.size()` is 
> appended to it? Note, that it should be an expression of a class type.

Nope, everything I can think of is already covered it seems.

>
> 
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:39
> @@ +38,3 @@
> +recordDecl(matchesName("^(::std::|::string)"),
> +   hasMethod(methodDecl(hasName("size"), 
> isPublic(),
> +isConst()))
> 
> Needed for code bases that use a std::string-like string class defined in the 
> global namespace. Maybe we need a configuration option for custom container 
> regexps. But this will likely be a follow up.

Follow-up makes sense to me. Perhaps the option can simply be
"anything with a size() member function" vs "only STL containers".

Thanks, with that, LGTM!

~Aaron

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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
On Thu, Sep 10, 2015 at 12:14 PM, Alexander Kornienko  wrote:
> On Thu, Sep 10, 2015 at 5:22 PM, Aaron Ballman 
> wrote:
>>
>> > 
>> > Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:49
>> > @@ +48,3 @@
>> > +  SourceLocation SizeOfLoc = SizeOf->getLocStart();
>> > +  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the
>> > "
>> > +  "container. Did you mean .size()?");
>> > 
>> > 1. Done.
>> > 2. It's actually emitting the diagnostic. And I thought that the comment
>> > on line 52 below explains what happens in enough detail (`// Don't generate
>> > fixes for macros.`). If something is still unclear, can you explain what
>> > exactly?
>>
>> It's not intuitive that creating the local variable actually emits the
>> diagnostic, so it seems like you would be able to hoist the early
>> return up above the local declaration when in fact that would remove
>> the diagnostic entirely. The comment about generating fixes suggests
>> an additional diagnostic, at least to me.
>
>
> This side effect of the diag() method is one of the core things in the
> clang-tidy API for checks. The same pattern is used with other Diag/diag
> methods in clang that produce various DiagnosticBuilders, and so far I
> didn't see problems with it being misleading. So it shouldn't need a comment
> at each usage, imho. May be a comment at the method definition needs to
> cover this aspect as well, if it doesn't.

Yeah, I think what threw me off was the local variable declaration
more than the diag function call. In hindsight, this behavior makes
sense. We'll chalk it up to an education issue on my part, with no
changes needed.

Thanks!

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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-10 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D12759



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


[clang-tools-extra] r247297 - [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stl

2015-09-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Sep 10 11:37:46 2015
New Revision: 247297

URL: http://llvm.org/viewvc/llvm-project?rev=247297&view=rev
Log:
[clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stl
containers.

Summary:
sizeof(some_std_string) is likely to be an error. This check finds this
pattern and suggests using .size() instead.

Reviewers: djasper, klimek, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-sizeof-container.rst
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.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=247297&r1=247296&r2=247297&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Sep 10 11:37:46 
2015
@@ -12,6 +12,7 @@ add_clang_library(clangTidyMiscModule
   MiscTidyModule.cpp
   MoveConstructorInitCheck.cpp
   NoexceptMoveConstructorCheck.cpp
+  SizeofContainerCheck.cpp
   StaticAssertCheck.cpp
   SwappedArgumentsCheck.cpp
   UndelegatedConstructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=247297&r1=247296&r2=247297&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Thu Sep 10 
11:37:46 2015
@@ -20,6 +20,7 @@
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MoveConstructorInitCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
+#include "SizeofContainerCheck.h"
 #include "StaticAssertCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "UndelegatedConstructor.h"
@@ -54,6 +55,8 @@ public:
 "misc-move-constructor-init");
 CheckFactories.registerCheck(
 "misc-noexcept-move-constructor");
+CheckFactories.registerCheck(
+"misc-sizeof-container");
 CheckFactories.registerCheck(
 "misc-static-assert");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp?rev=247297&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp Thu Sep 10 
11:37:46 2015
@@ -0,0 +1,83 @@
+//===--- SizeofContainerCheck.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 "SizeofContainerCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+namespace {
+
+bool needsParens(const Expr *E) {
+  E = E->IgnoreImpCasts();
+  if (isa(E) || isa(E))
+return true;
+  if (const auto *Op = dyn_cast(E)) {
+return Op->getNumArgs() == 2 && Op->getOperator() != OO_Call &&
+   Op->getOperator() != OO_Subscript;
+  }
+  return false;
+}
+
+} // anonymous namespace
+
+void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  expr(unless(isInTemplateInstantiation()),
+   expr(sizeOfExpr(has(expr(hasType(hasCanonicalType(hasDeclaration(
+recordDecl(matchesName("^(::std::|::string)"),
+   hasMethod(methodDecl(hasName("size"), 
isPublic(),
+isConst()))
+   .bind("sizeof"),
+   // Ignore ARRAYSIZE() pattern.
+   unless(hasAncestor(binaryOperator(
+   anyOf(hasOperatorName("/"), hasOperatorName("%")),
+   hasLHS(ignoringParenCasts(sizeOfExpr(expr(,
+   hasRHS(ignoringParenCasts(equalsBoundNode("sizeof"))),
+  this);
+}
+
+void SizeofContainerCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *SizeOf =
+  Result.Nodes.getNodeAs("sizeof");

r247302 - Re-commit r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"

2015-09-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Sep 10 12:07:54 2015
New Revision: 247302

URL: http://llvm.org/viewvc/llvm-project?rev=247302&view=rev
Log:
Re-commit r247218: "Fix Clang-tidy misc-use-override warnings, other minor 
fixes"

This never broke the build; it was the LLVM side, r247216, that caused problems.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=247302&r1=247301&r2=247302&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Sep 10 12:07:54 2015
@@ -30,6 +30,7 @@
 #include "llvm/Support/TargetParser.h"
 #include 
 #include 
+
 using namespace clang;
 
 
//===--===//
@@ -739,7 +740,7 @@ namespace {
 template 
 class WebAssemblyOSTargetInfo : public OSTargetInfo {
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
-MacroBuilder &Builder) const override final {
+MacroBuilder &Builder) const final {
 // A common platform macro.
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
@@ -749,7 +750,7 @@ class WebAssemblyOSTargetInfo : public O
   }
 
   // As an optimization, group static init code together in a section.
-  const char *getStaticInitSectionSpecifier() const override final {
+  const char *getStaticInitSectionSpecifier() const final {
 return ".text.__startup";
   }
 
@@ -7011,13 +7012,13 @@ private:
   Features["simd128"] = true;
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
-  bool hasFeature(StringRef Feature) const override final {
+  bool hasFeature(StringRef Feature) const final {
 return llvm::StringSwitch(Feature)
 .Case("simd128", SIMDLevel >= SIMD128)
 .Default(false);
   }
   bool handleTargetFeatures(std::vector &Features,
-DiagnosticsEngine &Diags) override final {
+DiagnosticsEngine &Diags) final {
 for (const auto &Feature : Features) {
   if (Feature == "+simd128") {
 SIMDLevel = std::max(SIMDLevel, SIMD128);
@@ -7034,7 +7035,7 @@ private:
 }
 return true;
   }
-  bool setCPU(const std::string &Name) override final {
+  bool setCPU(const std::string &Name) final {
 return llvm::StringSwitch(Name)
   .Case("mvp",   true)
   .Case("bleeding-edge", true)
@@ -7042,32 +7043,32 @@ private:
   .Default(false);
   }
   void getTargetBuiltins(const Builtin::Info *&Records,
- unsigned &NumRecords) const override final {
+ unsigned &NumRecords) const final {
 Records = BuiltinInfo;
 NumRecords = clang::WebAssembly::LastTSBuiltin - Builtin::FirstTSBuiltin;
   }
-  BuiltinVaListKind getBuiltinVaListKind() const override final {
+  BuiltinVaListKind getBuiltinVaListKind() const final {
 // TODO: Implement va_list properly.
 return VoidPtrBuiltinVaList;
   }
   void getGCCRegNames(const char *const *&Names,
-  unsigned &NumNames) const override final {
+  unsigned &NumNames) const final {
 Names = nullptr;
 NumNames = 0;
   }
   void getGCCRegAliases(const GCCRegAlias *&Aliases,
-unsigned &NumAliases) const override final {
+unsigned &NumAliases) const final {
 Aliases = nullptr;
 NumAliases = 0;
   }
   bool
   validateAsmConstraint(const char *&Name,
-TargetInfo::ConstraintInfo &Info) const override final 
{
+TargetInfo::ConstraintInfo &Info) const final {
 return false;
   }
-  const char *getClobbers() const override final { return ""; }
-  bool isCLZForZeroUndef() const override final { return false; }
-  bool hasInt128Type() const override final { return true; }
+  const char *getClobbers() const final { return ""; }
+  bool isCLZForZeroUndef() const final { return false; }
+  bool hasInt128Type() const final { return true; }
 };
 
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247302&r1=247301&r2=247302&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Sep 10 12:07:54 2015
@@ -59,7 +59,7 @@ public:
   virtual const VarDecl *getThreadIDVariable() const = 0;
 
   

Re: [PATCH] D12741: [Clang] Fix Clang-tidy misc-use-override warnings, other minor fixes

2015-09-10 Thread Hans Wennborg via cfe-commits
hans added a comment.

Re-committed in r247302.


Repository:
  rL LLVM

http://reviews.llvm.org/D12741



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


r247303 - Debug Info: Remove an unnecessary debug type visitor.

2015-09-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Sep 10 12:13:31 2015
New Revision: 247303

URL: http://llvm.org/viewvc/llvm-project?rev=247303&view=rev
Log:
Debug Info: Remove an unnecessary debug type visitor.
Thanks to dblaikie for spotting this.

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=247303&r1=247302&r2=247303&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Sep 10 
12:13:31 2015
@@ -70,13 +70,6 @@ class PCHContainerGenerator : public AST
   return true;
 }
 
-bool VisitValueDecl(ValueDecl *D) {
-  QualType QualTy = D->getType();
-  if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
-DI.getOrCreateStandaloneType(QualTy, D->getLocation());
-  return true;
-}
-
 bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
   QualType QualTy(D->getTypeForDecl(), 0);
   if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=247303&r1=247302&r2=247303&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Thu Sep 10 12:13:31 2015
@@ -7,10 +7,12 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -g 
-fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES 
-fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm 
-debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
 @import DebugCXX;
@@ -30,12 +32,11 @@
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template >"
 // CHECK-SAME: identifier: 
"_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
-// CHECK: !DICompositeType(tag: DW_TAG_class_type,
-// CHECK-SAME: name: "Template >"
-// CHECK-SAME: identifier: 
"_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
 // no mangled name here yet.
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
 // no mangled name here yet.
+
+// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl"


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


Re: [PATCH] D12619: [Static Analyzer] Minor cleanups for the nullability checker.

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 34458.
xazax.hun added a comment.

- Updated to latest trunk
- Reworded the diagnostic messages


http://reviews.llvm.org/D12619

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -58,12 +58,12 @@
 /// the nullability of the receiver or the nullability of the return type of the
 /// method, depending on which is more nullable. Contradicted is considered to
 /// be the most nullable, to avoid false positive results.
-static Nullability getMostNullable(Nullability Lhs, Nullability Rhs) {
+Nullability getMostNullable(Nullability Lhs, Nullability Rhs) {
   return static_cast(
   std::min(static_cast(Lhs), static_cast(Rhs)));
 }
 
-static const char *getNullabilityString(Nullability Nullab) {
+const char *getNullabilityString(Nullability Nullab) {
   switch (Nullab) {
   case Nullability::Contradicted:
 return "contradicted";
@@ -74,7 +74,7 @@
   case Nullability::Nonnull:
 return "nonnull";
   }
-  assert(false);
+  llvm_unreachable("Unexpected enumeration.");
   return "";
 }
 
@@ -89,19 +89,17 @@
   NullablePassedToNonnull
 };
 
-const char *ErrorMessages[] = {"Null pointer is assigned to a pointer which "
-   "has _Nonnull type",
-   "Null pointer is passed to a parameter which is "
-   "marked as _Nonnull",
-   "Null pointer is returned from a function that "
-   "has _Nonnull return type",
-   "Nullable pointer is assigned to a pointer "
-   "which has _Nonnull type",
-   "Nullable pointer is returned from a function "
-   "that has _Nonnull return type",
-   "Nullable pointer is dereferenced",
-   "Nullable pointer is passed to a parameter "
-   "which is marked as _Nonnull"};
+const char *const ErrorMessages[] = {
+"Null is assigned to a pointer which is expected to have non-null value",
+"Null passed to a callee that requires a non-null argument",
+"Null is returned from a function that is expected to return a non-null "
+"value",
+"Nullable pointer is assigned to a pointer which is expected to have "
+"non-null value",
+"Nullable pointer is returned from a function that is expected to return a "
+"non-null value",
+"Nullable pointer is dereferenced",
+"Nullable pointer is passed to a calle that requires a non-null argument"};
 
 class NullabilityChecker
 : public Checker,
@@ -176,7 +174,6 @@
 if (!BT)
   BT.reset(new BugType(this, "Nullability", "Memory error"));
 const char *Msg = ErrorMessages[static_cast(Error)];
-assert(Msg);
 std::unique_ptr R(new BugReport(*BT, Msg, N));
 if (Region) {
   R->markInteresting(Region);
@@ -262,7 +259,7 @@
   if (CheckSuperRegion) {
 if (auto FieldReg = Region->getAs())
   return dyn_cast(FieldReg->getSuperRegion());
-else if (auto ElementReg = Region->getAs())
+if (auto ElementReg = Region->getAs())
   return dyn_cast(ElementReg->getSuperRegion());
   }
 
@@ -272,12 +269,12 @@
 PathDiagnosticPiece *NullabilityChecker::NullabilityBugVisitor::VisitNode(
 const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC,
 BugReport &BR) {
-  ProgramStateRef state = N->getState();
-  ProgramStateRef statePrev = PrevN->getState();
+  ProgramStateRef State = N->getState();
+  ProgramStateRef StatePrev = PrevN->getState();
 
-  const NullabilityState *TrackedNullab = state->get(Region);
+  const NullabilityState *TrackedNullab = State->get(Region);
   const NullabilityState *TrackedNullabPrev =
-  statePrev->get(Region);
+  StatePrev->get(Region);
   if (!TrackedNullab)
 return nullptr;
 
@@ -645,34 +642,31 @@
 
 static Nullability getReceiverNullability(const ObjCMethodCall &M,
   ProgramStateRef State) {
-  Nullability RetNullability = Nullability::Unspecified;
   if (M.isReceiverSelfOrSuper()) {
 // For super and super class receivers we assume that the receiver is
 // nonnull.
-RetNullability = Nullability::Nonnull;
-  } else {
-// Otherwise look up nullability in the state.
-SVal Receiver = M.getReceiverSVal();
-auto ValueRegionSVal = Receiver.getAs();
-if (ValueRegionSVal) {
-  const MemRegion *SelfRegion = ValueRegionSVal->getRegion();
-  assert(SelfRegion);
-
-  const NullabilityState *TrackedSelfNullability =
-  State->get(SelfRegion);
-  if (TrackedSelfNullability) {
-RetNullability = TrackedSelfNullability->getValue();

Re: r247303 - Debug Info: Remove an unnecessary debug type visitor.

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 10:13 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Sep 10 12:13:31 2015
> New Revision: 247303
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247303&view=rev
> Log:
> Debug Info: Remove an unnecessary debug type visitor.
> Thanks to dblaikie for spotting this.
>
> Modified:
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=247303&r1=247302&r2=247303&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Sep 10
> 12:13:31 2015
> @@ -70,13 +70,6 @@ class PCHContainerGenerator : public AST
>return true;
>  }
>
> -bool VisitValueDecl(ValueDecl *D) {
> -  QualType QualTy = D->getType();
> -  if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
> -DI.getOrCreateStandaloneType(QualTy, D->getLocation());
> -  return true;
> -}
> -
>  bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
>QualType QualTy(D->getTypeForDecl(), 0);
>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=247303&r1=247302&r2=247303&view=diff
>
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Thu Sep 10 12:13:31 2015
> @@ -7,10 +7,12 @@
>  // RUN: rm -rf %t
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
> -std=c++11 -g -fmodules -fmodule-format=obj -fimplicit-module-maps
> -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll
> -mllvm -debug-only=pchcontainer &>%t-mod.ll
>  // RUN: cat %t-mod.ll | FileCheck %s
> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>
>  // PCH:
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11
> -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h
> -mllvm -debug-only=pchcontainer &>%t-pch.ll
>  // RUN: cat %t-pch.ll | FileCheck %s
> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>
>  #ifdef MODULES
>  @import DebugCXX;
> @@ -30,12 +32,11 @@
>  // CHECK: !DICompositeType(tag: DW_TAG_class_type,
>  // CHECK-SAME: name: "Template
> >"
>  // CHECK-SAME: identifier:
> "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
> -// CHECK: !DICompositeType(tag: DW_TAG_class_type,
> -// CHECK-SAME: name: "Template >"
> -// CHECK-SAME: identifier:
> "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
>  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>  // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
>  // no mangled name here yet.
>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>  // no mangled name here yet.
> +
> +// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl"
>

Rather than using a separate check - maybe do the same sort of thing we do
for DWARF testing, CHECK-NOT between each DICompositeType, to ensure we
only get the types we intended? (including a CHECK-NOT at the end to ensure
there aren't any trailing ones)

But also: How does the current implementation avoid emitting this type? I
thought it visited all the type decls, even those not immediately in the
module? (you mentioned that was something that you were planning to address
in a future patch) Is that not the case? Is this now sufficient to only
emit the decls immediately in this module?


>
>
> ___
> 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: r247303 - Debug Info: Remove an unnecessary debug type visitor.

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 10:18 AM, David Blaikie  wrote:

>
>
> On Thu, Sep 10, 2015 at 10:13 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Thu Sep 10 12:13:31 2015
>> New Revision: 247303
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247303&view=rev
>> Log:
>> Debug Info: Remove an unnecessary debug type visitor.
>> Thanks to dblaikie for spotting this.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=247303&r1=247302&r2=247303&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Sep 10
>> 12:13:31 2015
>> @@ -70,13 +70,6 @@ class PCHContainerGenerator : public AST
>>return true;
>>  }
>>
>> -bool VisitValueDecl(ValueDecl *D) {
>> -  QualType QualTy = D->getType();
>> -  if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>> -DI.getOrCreateStandaloneType(QualTy, D->getLocation());
>> -  return true;
>> -}
>> -
>>  bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
>>QualType QualTy(D->getTypeForDecl(), 0);
>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>
>> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=247303&r1=247302&r2=247303&view=diff
>>
>> ==
>> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
>> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Thu Sep 10 12:13:31 2015
>> @@ -7,10 +7,12 @@
>>  // RUN: rm -rf %t
>>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
>> -std=c++11 -g -fmodules -fmodule-format=obj -fimplicit-module-maps
>> -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll
>> -mllvm -debug-only=pchcontainer &>%t-mod.ll
>>  // RUN: cat %t-mod.ll | FileCheck %s
>> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>>
>>  // PCH:
>>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11
>> -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h
>> -mllvm -debug-only=pchcontainer &>%t-pch.ll
>>  // RUN: cat %t-pch.ll | FileCheck %s
>> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>>
>>  #ifdef MODULES
>>  @import DebugCXX;
>> @@ -30,12 +32,11 @@
>>  // CHECK: !DICompositeType(tag: DW_TAG_class_type,
>>  // CHECK-SAME: name: "Template> DebugCXX::traits >"
>>  // CHECK-SAME: identifier:
>> "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
>> -// CHECK: !DICompositeType(tag: DW_TAG_class_type,
>> -// CHECK-SAME: name: "Template
>> >"
>> -// CHECK-SAME: identifier:
>> "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
>>  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>>  // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
>>  // no mangled name here yet.
>>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>>  // no mangled name here yet.
>> +
>> +// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl"
>>
>
> Rather than using a separate check - maybe do the same sort of thing we do
> for DWARF testing, CHECK-NOT between each DICompositeType, to ensure we
> only get the types we intended? (including a CHECK-NOT at the end to ensure
> there aren't any trailing ones)
>
> But also: How does the current implementation avoid emitting this type? I
> thought it visited all the type decls, even those not immediately in the
> module? (you mentioned that was something that you were planning to address
> in a future patch) Is that not the case? Is this now sufficient to only
> emit the decls immediately in this module?
>

(Oh, I guess what might be missing is types referenced from /types/ in this
module - types referenced from variable decls only are addressed by this
patch, but you still don't want to include a full definition of std::vector
just because a type derives from it, has a member of it, etc)


>
>
>>
>>
>> ___
>> 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: r247303 - Debug Info: Remove an unnecessary debug type visitor.

2015-09-10 Thread Adrian Prantl via cfe-commits

> On Sep 10, 2015, at 10:19 AM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Sep 10, 2015 at 10:18 AM, David Blaikie  > wrote:
> 
> 
> On Thu, Sep 10, 2015 at 10:13 AM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Sep 10 12:13:31 2015
> New Revision: 247303
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=247303&view=rev 
> 
> Log:
> Debug Info: Remove an unnecessary debug type visitor.
> Thanks to dblaikie for spotting this.
> 
> Modified:
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=247303&r1=247302&r2=247303&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Sep 10 
> 12:13:31 2015
> @@ -70,13 +70,6 @@ class PCHContainerGenerator : public AST
>return true;
>  }
> 
> -bool VisitValueDecl(ValueDecl *D) {
> -  QualType QualTy = D->getType();
> -  if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
> -DI.getOrCreateStandaloneType(QualTy, D->getLocation());
> -  return true;
> -}
> -
>  bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
>QualType QualTy(D->getTypeForDecl(), 0);
>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
> 
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=247303&r1=247302&r2=247303&view=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Thu Sep 10 12:13:31 2015
> @@ -7,10 +7,12 @@
>  // RUN: rm -rf %t
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
> -g -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES 
> -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm 
> -debug-only=pchcontainer &>%t-mod.ll
>  // RUN: cat %t-mod.ll | FileCheck %s
> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
> 
>  // PCH:
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
> -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
> -debug-only=pchcontainer &>%t-pch.ll
>  // RUN: cat %t-pch.ll | FileCheck %s
> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
> 
>  #ifdef MODULES
>  @import DebugCXX;
> @@ -30,12 +32,11 @@
>  // CHECK: !DICompositeType(tag: DW_TAG_class_type,
>  // CHECK-SAME: name: "Template >"
>  // CHECK-SAME: identifier: 
> "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
> -// CHECK: !DICompositeType(tag: DW_TAG_class_type,
> -// CHECK-SAME: name: "Template >"
> -// CHECK-SAME: identifier: 
> "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
>  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>  // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
>  // no mangled name here yet.
>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>  // no mangled name here yet.
> +
> +// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl"
> 
> Rather than using a separate check - maybe do the same sort of thing we do 
> for DWARF testing, CHECK-NOT between each DICompositeType, to ensure we only 
> get the types we intended? (including a CHECK-NOT at the end to ensure there 
> aren't any trailing ones)
> 
> But also: How does the current implementation avoid emitting this type? I 
> thought it visited all the type decls, even those not immediately in the 
> module? (you mentioned that was something that you were planning to address 
> in a future patch) Is that not the case? Is this now sufficient to only emit 
> the decls immediately in this module?

It transitively emits all types that are showing up in a type declaration in 
the module. This type is only instantiated inside a variable declaration.

> (Oh, I guess what might be missing is types referenced from /types/ in this 
> module - types referenced from variable decls only are addressed by this 
> patch, but you still don't want to include a full definition of std::vector 
> just because a type derives from it, has a

r247307 - [CUDA] Allow trivial constructors as initializer for __shared__ variables.

2015-09-10 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Sep 10 12:26:58 2015
New Revision: 247307

URL: http://llvm.org/viewvc/llvm-project?rev=247307&view=rev
Log:
[CUDA] Allow trivial constructors as initializer for __shared__ variables.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCUDA/address-spaces.cu

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=247307&r1=247306&r2=247307&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Sep 10 12:26:58 2015
@@ -2165,8 +2165,10 @@ void CodeGenModule::EmitGlobalVarDefinit
   if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice
   && D->hasAttr()) {
 if (InitExpr) {
-  Error(D->getLocation(),
-"__shared__ variable cannot have an initialization.");
+  const auto *C = dyn_cast(InitExpr);
+  if (C == nullptr || !C->getConstructor()->hasTrivialBody())
+Error(D->getLocation(),
+  "__shared__ variable cannot have an initialization.");
 }
 Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
   } else if (!InitExpr) {

Modified: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/address-spaces.cu?rev=247307&r1=247306&r2=247307&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu Thu Sep 10 12:26:58 2015
@@ -25,6 +25,8 @@ struct MyStruct {
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @b = addrspace(3) global float undef
+// CHECK: @c = addrspace(3) global %struct.c undef
+// CHECK  @d = addrspace(3) global %struct.d undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)
@@ -117,3 +119,15 @@ __device__ int construct_shared_struct()
   return t.getData();
 // CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* 
addrspacecast (%struct.StructWithCtor addrspace(3)* 
@_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
 }
+
+// Make sure we allow __shared__ structures with default or empty constructors.
+struct c {
+  int i;
+};
+__shared__ struct c c;
+
+struct d {
+  int i;
+  d() {}
+};
+__shared__ struct d d;


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


Re: [PATCH] D12739: [CUDA] Allow trivial constructors as initializer for __shared__ variables.

2015-09-10 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247307: [CUDA] Allow trivial constructors as initializer for 
__shared__ variables. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D12739?vs=34372&id=34460#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12739

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCUDA/address-spaces.cu

Index: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
===
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu
@@ -25,6 +25,8 @@
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @b = addrspace(3) global float undef
+// CHECK: @c = addrspace(3) global %struct.c undef
+// CHECK  @d = addrspace(3) global %struct.d undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)
@@ -117,3 +119,15 @@
   return t.getData();
 // CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* 
addrspacecast (%struct.StructWithCtor addrspace(3)* 
@_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
 }
+
+// Make sure we allow __shared__ structures with default or empty constructors.
+struct c {
+  int i;
+};
+__shared__ struct c c;
+
+struct d {
+  int i;
+  d() {}
+};
+__shared__ struct d d;
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2165,8 +2165,10 @@
   if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice
   && D->hasAttr()) {
 if (InitExpr) {
-  Error(D->getLocation(),
-"__shared__ variable cannot have an initialization.");
+  const auto *C = dyn_cast(InitExpr);
+  if (C == nullptr || !C->getConstructor()->hasTrivialBody())
+Error(D->getLocation(),
+  "__shared__ variable cannot have an initialization.");
 }
 Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
   } else if (!InitExpr) {


Index: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
===
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu
@@ -25,6 +25,8 @@
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @b = addrspace(3) global float undef
+// CHECK: @c = addrspace(3) global %struct.c undef
+// CHECK  @d = addrspace(3) global %struct.d undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)
@@ -117,3 +119,15 @@
   return t.getData();
 // CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
 }
+
+// Make sure we allow __shared__ structures with default or empty constructors.
+struct c {
+  int i;
+};
+__shared__ struct c c;
+
+struct d {
+  int i;
+  d() {}
+};
+__shared__ struct d d;
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2165,8 +2165,10 @@
   if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice
   && D->hasAttr()) {
 if (InitExpr) {
-  Error(D->getLocation(),
-"__shared__ variable cannot have an initialization.");
+  const auto *C = dyn_cast(InitExpr);
+  if (C == nullptr || !C->getConstructor()->hasTrivialBody())
+Error(D->getLocation(),
+  "__shared__ variable cannot have an initialization.");
 }
 Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
   } else if (!InitExpr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r247303 - Debug Info: Remove an unnecessary debug type visitor.

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 10:25 AM, Adrian Prantl  wrote:

>
> On Sep 10, 2015, at 10:19 AM, David Blaikie  wrote:
>
>
>
> On Thu, Sep 10, 2015 at 10:18 AM, David Blaikie 
> wrote:
>
>>
>>
>> On Thu, Sep 10, 2015 at 10:13 AM, Adrian Prantl via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: adrian
>>> Date: Thu Sep 10 12:13:31 2015
>>> New Revision: 247303
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=247303&view=rev
>>> Log:
>>> Debug Info: Remove an unnecessary debug type visitor.
>>> Thanks to dblaikie for spotting this.
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=247303&r1=247302&r2=247303&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Sep
>>> 10 12:13:31 2015
>>> @@ -70,13 +70,6 @@ class PCHContainerGenerator : public AST
>>>return true;
>>>  }
>>>
>>> -bool VisitValueDecl(ValueDecl *D) {
>>> -  QualType QualTy = D->getType();
>>> -  if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>> -DI.getOrCreateStandaloneType(QualTy, D->getLocation());
>>> -  return true;
>>> -}
>>> -
>>>  bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
>>>QualType QualTy(D->getTypeForDecl(), 0);
>>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>>
>>> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=247303&r1=247302&r2=247303&view=diff
>>>
>>> ==
>>> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
>>> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Thu Sep 10 12:13:31 2015
>>> @@ -7,10 +7,12 @@
>>>  // RUN: rm -rf %t
>>>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
>>> -std=c++11 -g -fmodules -fmodule-format=obj -fimplicit-module-maps
>>> -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll
>>> -mllvm -debug-only=pchcontainer &>%t-mod.ll
>>>  // RUN: cat %t-mod.ll | FileCheck %s
>>> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>>>
>>>  // PCH:
>>>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11
>>> -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h
>>> -mllvm -debug-only=pchcontainer &>%t-pch.ll
>>>  // RUN: cat %t-pch.ll | FileCheck %s
>>> +// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>>>
>>>  #ifdef MODULES
>>>  @import DebugCXX;
>>> @@ -30,12 +32,11 @@
>>>  // CHECK: !DICompositeType(tag: DW_TAG_class_type,
>>>  // CHECK-SAME: name: "Template>> DebugCXX::traits >"
>>>  // CHECK-SAME: identifier:
>>> "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
>>> -// CHECK: !DICompositeType(tag: DW_TAG_class_type,
>>> -// CHECK-SAME: name: "Template
>>> >"
>>> -// CHECK-SAME: identifier:
>>> "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
>>>  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>>>  // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>>>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
>>>  // no mangled name here yet.
>>>  // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>>>  // no mangled name here yet.
>>> +
>>> +// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl"
>>>
>>
>> Rather than using a separate check - maybe do the same sort of thing we
>> do for DWARF testing, CHECK-NOT between each DICompositeType, to ensure we
>> only get the types we intended? (including a CHECK-NOT at the end to ensure
>> there aren't any trailing ones)
>>
>> But also: How does the current implementation avoid emitting this type? I
>> thought it visited all the type decls, even those not immediately in the
>> module? (you mentioned that was something that you were planning to address
>> in a future patch) Is that not the case? Is this now sufficient to only
>> emit the decls immediately in this module?
>>
>
> It transitively emits all types that are showing up in a type declaration
> in the module. This type is only instantiated inside a variable declaration.
>
> (Oh, I guess what might be missing is types referenced from /types/ in
> this module - types referenced from variable decls only are addressed by
> this patch, but you still don't want to include a full definition of
> std::vector just because a type derives from it, has a member of it, etc)
>
>
> Unless there is a typedef for that instantiation of std::vector in a
> module I don’t see a way of avo

Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Igor Kudrin via cfe-commits
ikudrin updated this revision to Diff 34462.
ikudrin added a comment.

- Extracted a function to convert an architecture type to a library subfolder 
name.
- Added a method to check if we should use Universal CRT depending on the 
chosen version of Visual Studio.


http://reviews.llvm.org/D12695

Files:
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8953,6 +8953,13 @@
   Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
 }
 
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+ UniversalCRTLibPath.c_str()));
+}
+
 std::string WindowsSdkLibPath;
 if (MSVC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
   CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -840,6 +840,11 @@
 
   bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
   bool getWindowsSDKLibraryPath(std::string &path) const;
+  /// \brief Check if Universal CRT should be used if available
+  bool useUniversalCRT() const;
+  bool getUniversalCRTSdkDir(std::string &path,
+std::string &ucrtVersion) const;
+  bool getUniversalCRTLibraryPath(std::string &path) const;
   bool getVisualStudioInstallDir(std::string &path) const;
   bool getVisualStudioBinariesFolder(const char *clangProgramPath,
  std::string &path) const;
Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -205,6 +205,21 @@
 #endif // USE_WIN32
 }
 
+// Convert LLVM's ArchType
+// to the corresponding name of Windows SDK libraries subfolder
+static StringRef getWindowsSDKArch(llvm::Triple::ArchType arch) {
+  switch (arch) {
+  case llvm::Triple::x86:
+return "x86";
+  case llvm::Triple::x86_64:
+return "x64";
+  case llvm::Triple::arm:
+return "arm";
+  default:
+return "";
+  }
+}
+
 /// \brief Get Windows SDK installation directory.
 bool MSVCToolChain::getWindowsSDKDir(std::string &path, int &major,
  int &minor) const {
@@ -263,22 +278,77 @@
 if (!found)
   return false;
 
-llvm::sys::path::append(libPath, "um");
-switch (getArch()) {
-case llvm::Triple::x86:
-  llvm::sys::path::append(libPath, "x86");
-  break;
-case llvm::Triple::x86_64:
-  llvm::sys::path::append(libPath, "x64");
-  break;
-case llvm::Triple::arm:
-  llvm::sys::path::append(libPath, "arm");
-  break;
-default:
+const StringRef archName = getWindowsSDKArch(getArch());
+if (archName.empty())
   return false;
-}
+llvm::sys::path::append(libPath, "um", archName);
+  }
+
+  path = libPath.str();
+  return true;
+}
+
+// Check if the Include path of a chosen version of Visual Studio contains
+// specific header files. If not, they are probably shipped with Universal CRT.
+bool clang::driver::toolchains::MSVCToolChain::useUniversalCRT() const
+{
+  std::string VSDir;
+  if (!getVisualStudioInstallDir(VSDir))
+return false;
+
+  llvm::SmallString<128> testPath(VSDir);
+  llvm::sys::path::append(testPath, "VC\\include\\stdlib.h");
+
+  return !llvm::sys::fs::exists(testPath);
+}
+
+bool MSVCToolChain::getUniversalCRTSdkDir(std::string &path,
+  std::string &ucrtVersion) const
+{
+  // vcvarsqueryregistry.bat for Visual Studio 2015 queries the registry
+  // for the specific key "KitsRoot10". So do we.
+  if (!getSystemRegistryString(
+"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
+"KitsRoot10", path, nullptr))
+return false;
+
+  ucrtVersion.clear();
+
+  // Find the most recent version of Universal CRT.
+  // vcvarsqueryregistry.bat sorts entries in the include directory by names and
+  // uses the last one of the list.
+  // So we compare entry names lexicographically to find the greatest one.
+  std::error_code ec;
+  llvm::SmallString<128> includePath(path);
+  llvm::sys::path::append(includePath, "Include");
+  for (llvm::sys::fs::directory_iterator dirIt(includePath, ec), dirEnd;
+  dirIt != dirEnd && !ec; dirIt.increment(ec)) {
+if (!llvm::sys::fs::is_directory(dirIt->path()))
+  continue;
+StringRef name = llvm::sys::path::filename(dirIt->path());
+if (name > ucrtVersion)
+  ucrtVersion = name;
   }
 
+  return !ucrtVersion.empty();
+}
+
+bool MSVCToolChain::getUniversalCRTLibraryPath(std::string &path) const
+{

Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Igor Kudrin via cfe-commits
ikudrin updated this revision to Diff 34465.
ikudrin marked an inline comment as done.
ikudrin added a comment.

Just added more context to the patch.


http://reviews.llvm.org/D12695

Files:
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8953,6 +8953,13 @@
   Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
 }
 
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+ UniversalCRTLibPath.c_str()));
+}
+
 std::string WindowsSdkLibPath;
 if (MSVC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
   CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -840,6 +840,11 @@
 
   bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
   bool getWindowsSDKLibraryPath(std::string &path) const;
+  /// \brief Check if Universal CRT should be used if available
+  bool useUniversalCRT() const;
+  bool getUniversalCRTSdkDir(std::string &path,
+std::string &ucrtVersion) const;
+  bool getUniversalCRTLibraryPath(std::string &path) const;
   bool getVisualStudioInstallDir(std::string &path) const;
   bool getVisualStudioBinariesFolder(const char *clangProgramPath,
  std::string &path) const;
Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -205,6 +205,21 @@
 #endif // USE_WIN32
 }
 
+// Convert LLVM's ArchType
+// to the corresponding name of Windows SDK libraries subfolder
+static StringRef getWindowsSDKArch(llvm::Triple::ArchType arch) {
+  switch (arch) {
+  case llvm::Triple::x86:
+return "x86";
+  case llvm::Triple::x86_64:
+return "x64";
+  case llvm::Triple::arm:
+return "arm";
+  default:
+return "";
+  }
+}
+
 /// \brief Get Windows SDK installation directory.
 bool MSVCToolChain::getWindowsSDKDir(std::string &path, int &major,
  int &minor) const {
@@ -263,22 +278,77 @@
 if (!found)
   return false;
 
-llvm::sys::path::append(libPath, "um");
-switch (getArch()) {
-case llvm::Triple::x86:
-  llvm::sys::path::append(libPath, "x86");
-  break;
-case llvm::Triple::x86_64:
-  llvm::sys::path::append(libPath, "x64");
-  break;
-case llvm::Triple::arm:
-  llvm::sys::path::append(libPath, "arm");
-  break;
-default:
+const StringRef archName = getWindowsSDKArch(getArch());
+if (archName.empty())
   return false;
-}
+llvm::sys::path::append(libPath, "um", archName);
+  }
+
+  path = libPath.str();
+  return true;
+}
+
+// Check if the Include path of a chosen version of Visual Studio contains
+// specific header files. If not, they are probably shipped with Universal CRT.
+bool clang::driver::toolchains::MSVCToolChain::useUniversalCRT() const
+{
+  std::string VSDir;
+  if (!getVisualStudioInstallDir(VSDir))
+return false;
+
+  llvm::SmallString<128> testPath(VSDir);
+  llvm::sys::path::append(testPath, "VC\\include\\stdlib.h");
+
+  return !llvm::sys::fs::exists(testPath);
+}
+
+bool MSVCToolChain::getUniversalCRTSdkDir(std::string &path,
+  std::string &ucrtVersion) const
+{
+  // vcvarsqueryregistry.bat for Visual Studio 2015 queries the registry
+  // for the specific key "KitsRoot10". So do we.
+  if (!getSystemRegistryString(
+"SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
+"KitsRoot10", path, nullptr))
+return false;
+
+  ucrtVersion.clear();
+
+  // Find the most recent version of Universal CRT.
+  // vcvarsqueryregistry.bat sorts entries in the include directory by names and
+  // uses the last one of the list.
+  // So we compare entry names lexicographically to find the greatest one.
+  std::error_code ec;
+  llvm::SmallString<128> includePath(path);
+  llvm::sys::path::append(includePath, "Include");
+  for (llvm::sys::fs::directory_iterator dirIt(includePath, ec), dirEnd;
+  dirIt != dirEnd && !ec; dirIt.increment(ec)) {
+if (!llvm::sys::fs::is_directory(dirIt->path()))
+  continue;
+StringRef name = llvm::sys::path::filename(dirIt->path());
+if (name > ucrtVersion)
+  ucrtVersion = name;
   }
 
+  return !ucrtVersion.empty();
+}
+
+bool MSVCToolChain::getUniversalCRTLibraryPath(std::string &path) const
+{
+  std::string universalCRTSdkPath;
+  std::string ucrtVersion;
+
+  path.clear();
+  if (!getUniversalCRTSdkDir

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

2015-09-10 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

AFAIUI the canonical type could never be an elaborated type, but just type 
could.

And yes before we used nested name specifier from the type name as written in 
the source code (a.k.a. ElaboratedType), now we use nested name specifier of 
the type that the elaborated type refers to.


http://reviews.llvm.org/D11797



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


[PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, xazax.hun.
dcoughlin added a subscriber: cfe-commits.

Update the static analyzer buildbot script to set -isysroot to the OS X SDK 
path when analyzing preprocessed files.

http://reviews.llvm.org/D12769

Files:
  utils/analyzer/SATestBuild.py

Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -52,7 +52,7 @@
 import time
 import plistlib
 import argparse
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
 
 #--
 # Helper functions.
@@ -255,14 +255,31 @@
 return True
 return False
 
+# Get the path to the SDK for the given SDK name. Returns None if
+# the path cannot be determined.
+def getSDKPath(SDKName):
+if which("xcrun") is None:
+return None
+
+Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
+return check_output(Cmd, shell=True).rstrip()
+
 # Run analysis on a set of preprocessed files.
 def runAnalyzePreprocessed(Dir, SBOutputDir, Mode):
 if os.path.exists(os.path.join(Dir, BuildScript)):
 print "Error: The preprocessed files project should not contain %s" % \
BuildScript
 raise Exception()
 
-CmdPrefix = Clang + " -cc1 -analyze -analyzer-output=plist -w "
+CmdPrefix = Clang + " "
+
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")
+if SDKPath is not None:
+  CmdPrefix += "-cc1 -isysroot " + SDKPath + " "
+
+CmdPrefix += "-analyze -analyzer-output=plist -w "
 CmdPrefix += "-analyzer-checker=" + Checkers +" -fcxx-exceptions -fblocks "
 
 if (Mode == 2) :


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -52,7 +52,7 @@
 import time
 import plistlib
 import argparse
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
 
 #--
 # Helper functions.
@@ -255,14 +255,31 @@
 return True
 return False
 
+# Get the path to the SDK for the given SDK name. Returns None if
+# the path cannot be determined.
+def getSDKPath(SDKName):
+if which("xcrun") is None:
+return None
+
+Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
+return check_output(Cmd, shell=True).rstrip()
+
 # Run analysis on a set of preprocessed files.
 def runAnalyzePreprocessed(Dir, SBOutputDir, Mode):
 if os.path.exists(os.path.join(Dir, BuildScript)):
 print "Error: The preprocessed files project should not contain %s" % \
BuildScript
 raise Exception()
 
-CmdPrefix = Clang + " -cc1 -analyze -analyzer-output=plist -w "
+CmdPrefix = Clang + " "
+
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")
+if SDKPath is not None:
+  CmdPrefix += "-cc1 -isysroot " + SDKPath + " "
+
+CmdPrefix += "-analyze -analyzer-output=plist -w "
 CmdPrefix += "-analyzer-checker=" + Checkers +" -fcxx-exceptions -fblocks "
 
 if (Mode == 2) :
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Igor Kudrin via cfe-commits
ikudrin marked an inline comment as done.
ikudrin added a comment.

In http://reviews.llvm.org/D12695#243320, @rnk wrote:

> FYI @ruiu is moving this code to LLVM in http://reviews.llvm.org/D12604.


Thanks. I think I'll move my changes to the new place when he's finished.


http://reviews.llvm.org/D12695



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


Re: [PATCH] D11664: [CUDA] Implemented additional processing steps needed to link with CUDA libdevice bitcode.

2015-09-10 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 34467.
tra added a comment.

Removed unneeded #includes.


http://reviews.llvm.org/D11664

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/CodeGenAction.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCUDA/Inputs/device-code.ll
  test/CodeGenCUDA/link-device-bitcode.cu

Index: test/CodeGenCUDA/link-device-bitcode.cu
===
--- /dev/null
+++ test/CodeGenCUDA/link-device-bitcode.cu
@@ -0,0 +1,56 @@
+// Test for linking with CUDA's libdevice as outlined in
+// http://llvm.org/docs/NVPTXUsage.html#linking-with-libdevice
+//
+// REQUIRES: nvptx-registered-target
+//
+// Prepare bitcode file to link with
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -emit-llvm-bc -o %t.bc \
+// RUN:%S/Inputs/device-code.ll
+//
+// Make sure function in device-code gets linked in and internalized.
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -fcuda-uses-libdevice -emit-llvm \
+// RUN:-disable-llvm-passes -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-IR
+//
+// Make sure function in device-code gets linked but is not internalized
+// without -fcuda-uses-libdevice
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -emit-llvm \
+// RUN:-disable-llvm-passes -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-IR-NLD
+//
+// Make sure NVVMReflect pass is enabled in NVPTX back-end.
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -fcuda-uses-libdevice -S -o /dev/null %s \
+// RUN:-backend-option -debug-pass=Structure 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-REFLECT
+
+#include "Inputs/cuda.h"
+
+__device__ float device_mul_or_add(float a, float b);
+extern "C" __device__ double __nv_sin(double x);
+extern "C" __device__ double __nv_exp(double x);
+
+// CHECK-IR-LABEL: define void @_Z26should_not_be_internalizedPf(
+// CHECK-PTX-LABEL: .visible .func _Z26should_not_be_internalizedPf(
+__device__ void should_not_be_internalized(float *data) {}
+
+// Make sure kernel call has not been internalized.
+// CHECK-IR-LABEL: define void @_Z6kernelPfS_
+// CHECK-PTX-LABEL: .visible .entry _Z6kernelPfS_(
+__global__ __attribute__((used)) void kernel(float *out, float *in) {
+  *out = device_mul_or_add(in[0], in[1]);
+  *out += __nv_exp(__nv_sin(*out));
+  should_not_be_internalized(out);
+}
+
+// Make sure device_mul_or_add() is present in IR, is internal and
+// calls __nvvm_reflect().
+// CHECK-IR-LABEL: define internal float @_Z17device_mul_or_addff(
+// CHECK-IR-NLD-LABEL: define float @_Z17device_mul_or_addff(
+// CHECK-IR: call i32 @__nvvm_reflect
+// CHECK-IR: ret float
+
+// Verify that NVVMReflect pass is among the passes run by NVPTX back-end.
+// CHECK-REFLECT: Replace occurrences of __nvvm_reflect() calls with 0/1
Index: test/CodeGenCUDA/Inputs/device-code.ll
===
--- /dev/null
+++ test/CodeGenCUDA/Inputs/device-code.ll
@@ -0,0 +1,38 @@
+; Simple bit of IR to mimic CUDA's libdevice. We want to be
+; able to link with it and we need to make sure all __nvvm_reflect
+; calls are eliminated by the time PTX has been produced.
+
+target triple = "nvptx-unknown-cuda"
+
+declare i32 @__nvvm_reflect(i8*)
+
+@"$str" = private addrspace(1) constant [8 x i8] c"USE_MUL\00"
+
+define void @unused_subfunc(float %a) {
+   ret void
+}
+
+define void @used_subfunc(float %a) {
+   ret void
+}
+
+define float @_Z17device_mul_or_addff(float %a, float %b) {
+  %reflect = call i32 @__nvvm_reflect(i8* addrspacecast (i8 addrspace(1)* getelementptr inbounds ([8 x i8], [8 x i8] addrspace(1)* @"$str", i32 0, i32 0) to i8*))
+  %cmp = icmp ne i32 %reflect, 0
+  br i1 %cmp, label %use_mul, label %use_add
+
+use_mul:
+  %ret1 = fmul float %a, %b
+  br label %exit
+
+use_add:
+  %ret2 = fadd float %a, %b
+  br label %exit
+
+exit:
+  %ret = phi float [%ret1, %use_mul], [%ret2, %use_add]
+
+  call void @used_subfunc(float %ret)
+
+  ret float %ret
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1406,6 +1406,9 @@
   if (Args.hasArg(OPT_fcuda_is_device))
 Opts.CUDAIsDevice = 1;
 
+  if (Args.hasArg(OPT_fcuda_uses_libdevice))
+Opts.CUDAUsesLibDevice = 1;
+
   if (Args.hasArg(OPT_fcuda_allow_host_calls_from_host_device))
 Opts.CUDAAllowHostCallsFromHostDevice = 1;
 
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -159,7 +159,12 @@
   if (LinkModule) {
 if (Linker::LinkModules(
 M, LinkModule.get(),
-[=](const Diagnosti

Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: utils/analyzer/SATestBuild.py:277
@@ +276,3 @@
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")

I think it might be better to check if the host os is OS X. This way one might 
be able to check preprocessed files on other linux.


http://reviews.llvm.org/D12769



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


Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

- on other OS-es like linux.


http://reviews.llvm.org/D12769



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


Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Reid Kleckner via cfe-commits
rnk added a comment.

There's a bunch of whitespace issues that clang-format can resolve. We also 
have the convention that variables are StudlyCaps, which isn't followed in a 
few places.

Do you need someone to commit this for you? If so, I can patch this in, test it 
manually, and deal with the style stuff if you deal with the VSDir part.



Comment at: lib/Driver/MSVCToolChain.cpp:293
@@ +292,3 @@
+// specific header files. If not, they are probably shipped with Universal CRT.
+bool clang::driver::toolchains::MSVCToolChain::useUniversalCRT() const
+{

This should really take VSDir as a parameter instead of recomputing it, since 
all the callers are already computing it.


http://reviews.llvm.org/D12695



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


Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: utils/analyzer/SATestBuild.py:277
@@ +276,3 @@
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")

xazax.hun wrote:
> I think it might be better to check if the host os is OS X. This way one 
> might be able to check preprocessed files on other linux.
The patch checks for the existence of xcrun in the path and doesn't set 
-isysroot if that is not present, so this should continue to work on Linux and 
cygwin.


http://reviews.llvm.org/D12769



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


Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: utils/analyzer/SATestBuild.py:277
@@ +276,3 @@
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")

dcoughlin wrote:
> xazax.hun wrote:
> > I think it might be better to check if the host os is OS X. This way one 
> > might be able to check preprocessed files on other linux.
> The patch checks for the existence of xcrun in the path and doesn't set 
> -isysroot if that is not present, so this should continue to work on Linux 
> and cygwin.
I see, however -cc1 option is only used when the SDKPath is not None. Is this 
intended?


http://reviews.llvm.org/D12769



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


Re: [PATCH] D11664: [CUDA] Implemented additional processing steps needed to link with CUDA libdevice bitcode.

2015-09-10 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247317: [CUDA] Postprocess bitcode linked in during 
device-side CUDA compilation. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D11664?vs=34467&id=34470#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11664

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
  cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1406,6 +1406,9 @@
   if (Args.hasArg(OPT_fcuda_is_device))
 Opts.CUDAIsDevice = 1;
 
+  if (Args.hasArg(OPT_fcuda_uses_libdevice))
+Opts.CUDAUsesLibDevice = 1;
+
   if (Args.hasArg(OPT_fcuda_allow_host_calls_from_host_device))
 Opts.CUDAAllowHostCallsFromHostDevice = 1;
 
Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -159,7 +159,12 @@
   if (LinkModule) {
 if (Linker::LinkModules(
 M, LinkModule.get(),
-[=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); }))
+[=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); },
+(LangOpts.CUDA && LangOpts.CUDAIsDevice &&
+ LangOpts.CUDAUsesLibDevice)
+? (Linker::Flags::LinkOnlyNeeded |
+   Linker::Flags::InternalizeLinkedSymbols)
+: Linker::Flags::None))
   return;
   }
 
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -659,6 +659,8 @@
   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_uses_libdevice : Flag<["-"], "fcuda-uses-libdevice">,
+  HelpText<"Selectively link and internalize bitcode.">;
 
 } // let Flags = [CC1Option]
 
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -166,6 +166,7 @@
 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(CUDAUsesLibDevice , 1, 0, "Selectively link and internalize bitcode.")
 
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for C++'s new operators")
 LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions")
Index: cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
===
--- cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
+++ cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
@@ -0,0 +1,38 @@
+; Simple bit of IR to mimic CUDA's libdevice. We want to be
+; able to link with it and we need to make sure all __nvvm_reflect
+; calls are eliminated by the time PTX has been produced.
+
+target triple = "nvptx-unknown-cuda"
+
+declare i32 @__nvvm_reflect(i8*)
+
+@"$str" = private addrspace(1) constant [8 x i8] c"USE_MUL\00"
+
+define void @unused_subfunc(float %a) {
+   ret void
+}
+
+define void @used_subfunc(float %a) {
+   ret void
+}
+
+define float @_Z17device_mul_or_addff(float %a, float %b) {
+  %reflect = call i32 @__nvvm_reflect(i8* addrspacecast (i8 addrspace(1)* getelementptr inbounds ([8 x i8], [8 x i8] addrspace(1)* @"$str", i32 0, i32 0) to i8*))
+  %cmp = icmp ne i32 %reflect, 0
+  br i1 %cmp, label %use_mul, label %use_add
+
+use_mul:
+  %ret1 = fmul float %a, %b
+  br label %exit
+
+use_add:
+  %ret2 = fadd float %a, %b
+  br label %exit
+
+exit:
+  %ret = phi float [%ret1, %use_mul], [%ret2, %use_add]
+
+  call void @used_subfunc(float %ret)
+
+  ret float %ret
+}
Index: cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
===
--- cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
+++ cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
@@ -0,0 +1,56 @@
+// Test for linking with CUDA's libdevice as outlined in
+// http://llvm.org/docs/NVPTXUsage.html#linking-with-libdevice
+//
+// REQUIRES: nvptx-registered-target
+//
+// Prepare

r247317 - [CUDA] Postprocess bitcode linked in during device-side CUDA compilation.

2015-09-10 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Sep 10 13:24:23 2015
New Revision: 247317

URL: http://llvm.org/viewvc/llvm-project?rev=247317&view=rev
Log:
[CUDA] Postprocess bitcode linked in during device-side CUDA compilation.

Link in and internalize the symbols we need from supplied bitcode library.

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

Added:
cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=247317&r1=247316&r2=247317&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Sep 10 13:24:23 2015
@@ -166,6 +166,7 @@ LANGOPT(OpenMPUseTLS  , 1, 0, "Use T
 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(CUDAUsesLibDevice , 1, 0, "Selectively link and internalize bitcode.")
 
 LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for 
C++'s new operators")
 LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions")

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=247317&r1=247316&r2=247317&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Sep 10 13:24:23 2015
@@ -659,6 +659,8 @@ def fcuda_disable_target_call_checks : F
   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_uses_libdevice : Flag<["-"], "fcuda-uses-libdevice">,
+  HelpText<"Selectively link and internalize bitcode.">;
 
 } // let Flags = [CC1Option]
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=247317&r1=247316&r2=247317&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Sep 10 13:24:23 2015
@@ -159,7 +159,12 @@ namespace clang {
   if (LinkModule) {
 if (Linker::LinkModules(
 M, LinkModule.get(),
-[=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); 
}))
+[=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); },
+(LangOpts.CUDA && LangOpts.CUDAIsDevice &&
+ LangOpts.CUDAUsesLibDevice)
+? (Linker::Flags::LinkOnlyNeeded |
+   Linker::Flags::InternalizeLinkedSymbols)
+: Linker::Flags::None))
   return;
   }
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=247317&r1=247316&r2=247317&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Sep 10 13:24:23 2015
@@ -1406,6 +1406,9 @@ static void ParseLangArgs(LangOptions &O
   if (Args.hasArg(OPT_fcuda_is_device))
 Opts.CUDAIsDevice = 1;
 
+  if (Args.hasArg(OPT_fcuda_uses_libdevice))
+Opts.CUDAUsesLibDevice = 1;
+
   if (Args.hasArg(OPT_fcuda_allow_host_calls_from_host_device))
 Opts.CUDAAllowHostCallsFromHostDevice = 1;
 

Added: cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll?rev=247317&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll (added)
+++ cfe/trunk/test/CodeGenCUDA/Inputs/device-code.ll Thu Sep 10 13:24:23 2015
@@ -0,0 +1,38 @@
+; Simple bit of IR to mimic CUDA's libdevice. We want to be
+; able to link with it and we need to make sure all __nvvm_reflect
+; calls are eliminated by the time PTX has been produced.
+
+target triple = "nvptx-unknown-cuda"
+
+declare i32 @__nvvm_reflect(i8*)
+
+@"$str" = private addrspace(1) constant [8 x i8] c"USE_MUL\00"
+
+define void @unused_subfunc(float %a) {
+   ret void
+}
+
+

Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: utils/analyzer/SATestBuild.py:277
@@ +276,3 @@
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")

xazax.hun wrote:
> dcoughlin wrote:
> > xazax.hun wrote:
> > > I think it might be better to check if the host os is OS X. This way one 
> > > might be able to check preprocessed files on other linux.
> > The patch checks for the existence of xcrun in the path and doesn't set 
> > -isysroot if that is not present, so this should continue to work on Linux 
> > and cygwin.
> I see, however -cc1 option is only used when the SDKPath is not None. Is this 
> intended?
No, you're right -- that is not intended.


http://reviews.llvm.org/D12769



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


Re: [PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

2015-09-10 Thread Devin Coughlin via cfe-commits
dcoughlin updated this revision to Diff 34471.
dcoughlin added a comment.

Pass -cc1 to clang even when SDK path is not found.


http://reviews.llvm.org/D12769

Files:
  utils/analyzer/SATestBuild.py

Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -52,7 +52,7 @@
 import time
 import plistlib
 import argparse
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
 
 #--
 # Helper functions.
@@ -255,14 +255,31 @@
 return True
 return False
 
+# Get the path to the SDK for the given SDK name. Returns None if
+# the path cannot be determined.
+def getSDKPath(SDKName):
+if which("xcrun") is None:
+return None
+
+Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
+return check_output(Cmd, shell=True).rstrip()
+
 # Run analysis on a set of preprocessed files.
 def runAnalyzePreprocessed(Dir, SBOutputDir, Mode):
 if os.path.exists(os.path.join(Dir, BuildScript)):
 print "Error: The preprocessed files project should not contain %s" % \
BuildScript
 raise Exception()
 
-CmdPrefix = Clang + " -cc1 -analyze -analyzer-output=plist -w "
+CmdPrefix = Clang + " -cc1 "
+
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")
+if SDKPath is not None:
+  CmdPrefix += "-isysroot " + SDKPath + " "
+
+CmdPrefix += "-analyze -analyzer-output=plist -w "
 CmdPrefix += "-analyzer-checker=" + Checkers +" -fcxx-exceptions -fblocks "
 
 if (Mode == 2) :


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -52,7 +52,7 @@
 import time
 import plistlib
 import argparse
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
 
 #--
 # Helper functions.
@@ -255,14 +255,31 @@
 return True
 return False
 
+# Get the path to the SDK for the given SDK name. Returns None if
+# the path cannot be determined.
+def getSDKPath(SDKName):
+if which("xcrun") is None:
+return None
+
+Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
+return check_output(Cmd, shell=True).rstrip()
+
 # Run analysis on a set of preprocessed files.
 def runAnalyzePreprocessed(Dir, SBOutputDir, Mode):
 if os.path.exists(os.path.join(Dir, BuildScript)):
 print "Error: The preprocessed files project should not contain %s" % \
BuildScript
 raise Exception()
 
-CmdPrefix = Clang + " -cc1 -analyze -analyzer-output=plist -w "
+CmdPrefix = Clang + " -cc1 "
+
+# For now, we assume the preprocessed files should be analyzed
+# with the OS X SDK.
+SDKPath = getSDKPath("macosx")
+if SDKPath is not None:
+  CmdPrefix += "-isysroot " + SDKPath + " "
+
+CmdPrefix += "-analyze -analyzer-output=plist -w "
 CmdPrefix += "-analyzer-checker=" + Checkers +" -fcxx-exceptions -fblocks "
 
 if (Mode == 2) :
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: PATCH: Expose the 'file' that is associated with a compile database command

2015-09-10 Thread Argyrios Kyrtzidis via cfe-commits

> On Sep 10, 2015, at 1:48 AM, Manuel Klimek  wrote:
> 
> @@ -179,11 +185,13 @@ public:
>/// \param Directory The base directory used in the 
> FixedCompilationDatabase.
>static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
> const char *const 
> *Argv,
> -   Twine Directory = 
> ".");
> +   Twine Directory = ".",
> +   Twine File = Twine());
>  
> A fixed compilation database returns the same command lines for all files, 
> thus having a file in the function seems strange.

Ah ok, thanks for clarifying.

> 
> What exactly is the use case? So far, the compilation database has been 
> designed for 2 use cases:
> 1. for a file, get the compile commands; the user already knows the file, no 
> need to get the file
> 2. get all compile commands; for that, we have the getAllFiles() method, so a 
> user can get all known files (for compilation databases that support that), 
> and then get the compile command line.

It’s #2, I want to get all compile commands. But it seems really strange to me 
that the ‘file’ starts as a property of the compile command in the json file 
but then it gets dropped and I need to do work to re-associate the files with 
the compile commands again.
I need to get a list of all the files and then for each one do a lookup to get 
the associated commands. I then have to maintain this association myself, 
passing a command along with its file separately or the structure that keeps 
track of the association.

It seems simpler to me to include the file that was associated with the command 
(if the compilation database supports that) along with the command, is there a 
downside I’m missing ?

> 
> Thoughts?
> /Manuel
> 
> On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis  > wrote:
> Hi,
> 
> The attached patch exposes the ‘file’ entry in a compilation database 
> command, via the CompileCommand structure.
> 

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


Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

In http://reviews.llvm.org/D12695#243552, @rnk wrote:

> There's a bunch of whitespace issues that clang-format can resolve.


Thanks! I'll reformat it.

> We also have the convention that variables are StudlyCaps, which isn't 
> followed in a few places.


I've tried to follow the style of the source file. Do you think I should force 
this rule here?

> Do you need someone to commit this for you? If so, I can patch this in, test 
> it manually, and deal with the style stuff if you deal with the VSDir part.


I'd really appreciate it. I'll prepare a new version in a few minutes.


http://reviews.llvm.org/D12695



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


Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread Richard Smith via cfe-commits
On Thu, Sep 10, 2015 at 9:13 AM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On Thu, Sep 10, 2015 at 9:07 AM, Mehdi Amini 
> wrote:
>
>>
>> On Sep 10, 2015, at 9:02 AM, David Blaikie  wrote:
>>
>>
>>
>> On Thu, Sep 10, 2015 at 9:00 AM, Mehdi Amini 
>> wrote:
>>
>>>
>>> On Sep 9, 2015, at 7:06 PM, David Blaikie  wrote:
>>>
>>>
>>>
>>> On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: mehdi_amini
 Date: Wed Sep  9 20:46:39 2015
 New Revision: 247233

 URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev
 Log:
 EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

 This reapply a variant commit r247179 after post-commit review from
 D.Blaikie.
 Hopefully I got it right this time: lifetime of initializer list ends
 as with any expression, which make invalid the pattern:

 ArrayRef Arr = { 1, 2, 3, 4};

 Just like StringRef, ArrayRef shouldn't be used to initialize local
 variable but only as function argument.

>>>
>>> Looks pretty reasonable - I'll mention it again, just in case: removing
>>> the named variables and just putting the init lists directly in the call
>>> might be as (or more) readable - might be worth giving it a go & running it
>>> through clang-format to see what you think.
>>>
>>>
>>> Here is an example, let me know what do you think:
>>>
>>>   {
>>> RecordData::value_type Record[] = {METADATA, VERSION_MAJOR,
>>> VERSION_MINOR,
>>>CLANG_VERSION_MAJOR,
>>> CLANG_VERSION_MINOR,
>>>!isysroot.empty(),
>>> IncludeTimestamps,
>>>ASTHasCompilerErrors};
>>> Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
>>>   getClangFullRepositoryVersion());
>>>   }
>>>   Stream.EmitRecordWithBlob(
>>>   MetadataAbbrevCode,
>>>   (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR,
>>> CLANG_VERSION_MAJOR,
>>>
>>
>> Why the cast (uint64_t[])? I'm vaguely surprised that even compiles... ?
>>
>> This is a GNU extension (C99 compound literals in C++). It won't compile
on MSVC.

> I would imagine it'd be passed as an init list, then turned into an
>> ArrayRef from there... but I guess not?
>>
>>
>>
>> Might be more clear with the callee:
>>
>>   template 
>>   void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
>>   StringRef Blob) {
>> EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
>>   }
>>
>> The template can’t be deduced without the cast.
>>
>
> Yeah, curious though. Another hole in perfect forwarding I suppose (not
> that this ^ is perfect forwarding, but even with perfect forwarding it
> doesn't cope well)
>
> Yeah, the cast is rather unfortunate. Hrm.
>
> Ah well - probably just as good to leave it as-is for now. If someone has
> a flash of inspiration later & figures out a way to make it better, so be
> it.
>

The way to handle this is to add another EmitRecord overload that takes a
std::initializer_list.


>> —
>> Mehdi
>>
>>
>>
>>
>>
>>
>>
>>
>>>CLANG_VERSION_MINOR, !isysroot.empty(),
>>> IncludeTimestamps,
>>>ASTHasCompilerErrors},
>>>   getClangFullRepositoryVersion());
>>>
>>> Thanks,
>>>
>>> —
>>> Mehdi
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> - Dave
>>>
>>>

 From: Mehdi Amini 

 Modified:
 cfe/trunk/include/clang/Serialization/ASTWriter.h
 cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

 Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff

 ==
 --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
 +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9
 20:46:39 2015
 @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
  public:
typedef SmallVector RecordData;
typedef SmallVectorImpl RecordDataImpl;
 +  typedef ArrayRef RecordDataRef;

friend class ASTDeclWriter;
friend class ASTStmtWriter;
 @@ -756,7 +757,7 @@ public:
void AddPath(StringRef Path, RecordDataImpl &Record);

/// \brief Emit the current record with the given path as a blob.
 -  void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
 +  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
StringRef Path);

/// \brief Add a version tuple to the given record

 Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.c

r247318 - [SEH] Use catchret in the new EH IR like we do for C++

2015-09-10 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 10 13:39:41 2015
New Revision: 247318

URL: http://llvm.org/viewvc/llvm-project?rev=247318&view=rev
Log:
[SEH] Use catchret in the new EH IR like we do for C++

Also add tests for SEH with the new IRGen.

Added:
cfe/trunk/test/CodeGen/exceptions-seh-new.c
  - copied, changed from r247317, cfe/trunk/test/CodeGen/exceptions-seh.c
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGen/exceptions-seh.c

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=247318&r1=247317&r2=247318&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Sep 10 13:39:41 2015
@@ -1807,7 +1807,7 @@ void CodeGenFunction::EnterSEHTryStmt(co
   HelperCGF.GenerateSEHFilterFunction(*this, *Except);
   llvm::Constant *OpaqueFunc =
   llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy);
-  CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except"));
+  CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret"));
 }
 
 void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
@@ -1848,6 +1848,18 @@ void CodeGenFunction::ExitSEHTryStmt(con
 
   EmitBlockAfterUses(ExceptBB);
 
+  if (CGM.getCodeGenOpts().NewMSEH) {
+// __except blocks don't get outlined into funclets, so immediately do a
+// catchret.
+llvm::BasicBlock *CatchPadBB = ExceptBB->getSinglePredecessor();
+assert(CatchPadBB && "only ExceptBB pred should be catchpad");
+llvm::CatchPadInst *CPI =
+cast(CatchPadBB->getFirstNonPHI());
+ExceptBB = createBasicBlock("__except");
+Builder.CreateCatchRet(CPI, ExceptBB);
+EmitBlock(ExceptBB);
+  }
+
   // On Win64, the exception pointer is the exception code. Copy it to the 
slot.
   if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
 llvm::Value *Code =

Copied: cfe/trunk/test/CodeGen/exceptions-seh-new.c (from r247317, 
cfe/trunk/test/CodeGen/exceptions-seh.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-new.c?p2=cfe/trunk/test/CodeGen/exceptions-seh-new.c&p1=cfe/trunk/test/CodeGen/exceptions-seh.c&r1=247317&r2=247318&rev=247318&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-new.c Thu Sep 10 13:39:41 2015
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - \
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -fnew-ms-eh 
-emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X64
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -fnew-ms-eh 
-emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X86
 
 void try_body(int numerator, int denominator, int *myres) {
@@ -23,36 +23,27 @@ int safe_div(int numerator, int denomina
   return success;
 }
 
-// X64-LABEL: define i32 @safe_div(i32 %numerator, i32 %denominator, i32* 
%res) {{.*}} personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
-// X64: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
-// X64:   to label %{{.*}} unwind label %[[lpad:[^ ]*]]
-//
-// X64: [[lpad]]
-// X64: landingpad { i8*, i32 }
-// X64-NEXT: catch i8* null
-// X64-NOT: br i1
-// X64: br label %[[except:[^ ]*]]
-// X64: [[except]]
-// X64: store i32 -42, i32* %[[success:[^ ]*]]
-//
-// X64: %[[res:[^ ]*]] = load i32, i32* %[[success]]
-// X64: ret i32 %[[res]]
-
-// X86-LABEL: define i32 @safe_div(i32 %numerator, i32 %denominator, i32* 
%res) {{.*}} personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
-// X86: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
-// X86:   to label %{{.*}} unwind label %[[lpad:[^ ]*]]
-//
-// X86: [[lpad]]
-// X86: landingpad { i8*, i32 }
-// X86-NEXT: catch i8* bitcast (i32 ()* @"\01?filt$0@0@safe_div@@" to i8*)
-// X86-NOT: br i1
-// X86: br label %[[except:[^ ]*]]
-// X86: [[except]]
-// X86: store i32 -42, i32* %[[success:[^ ]*]]
+// CHECK-LABEL: define i32 @safe_div(i32 %numerator, i32 %denominator, i32* 
%res)
+// X64-SAME:  personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
+// X86-SAME:  personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
+// CHECK: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
+// CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
+//
+// CHECK: [[catchpad]]
+// X64: %[[padtoken:[^ ]*]] = catchpad [i8* null] to label %[[exceptret:[^ 
]*]] unwind label
+// X86: %[[padtoken:[^ ]*]] = catchpad [i8* bitcast (i32 ()* 
@"\01?filt$0@0@safe_div@@" to i8*)] to la

r247319 - Add a getDeclContextDescriptor() helper function to CGDebugInfo. (NFC)

2015-09-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Sep 10 13:39:45 2015
New Revision: 247319

URL: http://llvm.org/viewvc/llvm-project?rev=247319&view=rev
Log:
Add a getDeclContextDescriptor() helper function to CGDebugInfo. (NFC)

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247319&r1=247318&r2=247319&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 10 13:39:45 2015
@@ -147,9 +147,14 @@ void CGDebugInfo::setLocation(SourceLoca
   }
 }
 
-llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context) {
+llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
+  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
+}
+
+llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
+ llvm::DIScope *Default) {
   if (!Context)
-return TheCU;
+return Default;
 
   auto I = RegionMap.find(Context);
   if (I != RegionMap.end()) {
@@ -165,7 +170,7 @@ llvm::DIScope *CGDebugInfo::getContextDe
 if (!RDecl->isDependentType())
   return getOrCreateType(CGM.getContext().getTypeDeclType(RDecl),
  getOrCreateMainFile());
-  return TheCU;
+  return Default;
 }
 
 StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) {
@@ -770,7 +775,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   SourceLocation Loc = AliasDecl->getLocation();
   return DBuilder.createTypedef(
   Src, internString(OS.str()), getOrCreateFile(Loc), getLineNumber(Loc),
-  getContextDescriptor(cast(AliasDecl->getDeclContext(;
+  getDeclContextDescriptor(AliasDecl));
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
@@ -783,7 +788,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getContextDescriptor(cast(Ty->getDecl()->getDeclContext(;
+  getDeclContextDescriptor(Ty->getDecl()));
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1510,8 +1515,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   llvm::DIType *T = cast_or_null(getTypeOrNull(QualType(Ty, 0)));
   if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
 if (!T)
-  T = getOrCreateRecordFwdDecl(
-  Ty, getContextDescriptor(cast(RD->getDeclContext(;
+  T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
 return T;
   }
 
@@ -1939,8 +1943,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
   // If this is just a forward declaration, construct an appropriately
   // marked node and just return it.
   if (!ED->getDefinition()) {
-llvm::DIScope *EDContext =
-getContextDescriptor(cast(ED->getDeclContext()));
+llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 unsigned Line = getLineNumber(ED->getLocation());
 StringRef EDName = ED->getName();
@@ -1980,8 +1983,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext =
-  getContextDescriptor(cast(ED->getDeclContext()));
+  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
   llvm::DIType *ClassTy =
   ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2228,8 +2230,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
   unsigned Line = getLineNumber(RD->getLocation());
   StringRef RDName = getClassName(RD);
 
-  llvm::DIScope *RDContext =
-  getContextDescriptor(cast(RD->getDeclContext()));
+  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
 
   // If we ended up creating the type during the context chain construction,
   // just return that.
@@ -2326,7 +2327,7 @@ void CGDebugInfo::collectFunctionDeclPro
   FDContext = getOrCreateNameSpace(NSDecl);
 else if (const RecordDecl *RDecl =
  dyn_cast_or_null(FD->getDeclContext()))
-  FDContext = getContextDescriptor(cast(RDecl));
+  FDContext = getContextDescriptor(RDecl, TheCU);
 // Collect template parameters.
 TParamsArray = CollectFunctionTemplateParams(FD, Unit);
   }
@@ -2374,7 +2375,7 @@ void CGDebugInfo::collectVarDeclProps(co
   // outside the class by putting it in the global scope.
   if (DC->isRecord())
 DC = CGM.getContext().getTranslationUnitDecl();
-  VDContext = getContextDescriptor(dyn_cast(DC));
+  VDContext = getContextDescriptor(cast(DC), TheCU);
 }
 
 llvm::DISubprogram *
@@ -2460,7 +2461,7 @

Re: r247233 - EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)

2015-09-10 Thread David Blaikie via cfe-commits
On Thu, Sep 10, 2015 at 11:39 AM, Richard Smith 
wrote:

> On Thu, Sep 10, 2015 at 9:13 AM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>>
>> On Thu, Sep 10, 2015 at 9:07 AM, Mehdi Amini 
>> wrote:
>>
>>>
>>> On Sep 10, 2015, at 9:02 AM, David Blaikie  wrote:
>>>
>>>
>>>
>>> On Thu, Sep 10, 2015 at 9:00 AM, Mehdi Amini 
>>> wrote:
>>>

 On Sep 9, 2015, at 7:06 PM, David Blaikie  wrote:



 On Wed, Sep 9, 2015 at 6:46 PM, Mehdi Amini via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Wed Sep  9 20:46:39 2015
> New Revision: 247233
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247233&view=rev
> Log:
> EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)
>
> This reapply a variant commit r247179 after post-commit review from
> D.Blaikie.
> Hopefully I got it right this time: lifetime of initializer list ends
> as with any expression, which make invalid the pattern:
>
> ArrayRef Arr = { 1, 2, 3, 4};
>
> Just like StringRef, ArrayRef shouldn't be used to initialize local
> variable but only as function argument.
>

 Looks pretty reasonable - I'll mention it again, just in case: removing
 the named variables and just putting the init lists directly in the call
 might be as (or more) readable - might be worth giving it a go & running it
 through clang-format to see what you think.


 Here is an example, let me know what do you think:

   {
 RecordData::value_type Record[] = {METADATA, VERSION_MAJOR,
 VERSION_MINOR,
CLANG_VERSION_MAJOR,
 CLANG_VERSION_MINOR,
!isysroot.empty(),
 IncludeTimestamps,
ASTHasCompilerErrors};
 Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
   getClangFullRepositoryVersion());
   }
   Stream.EmitRecordWithBlob(
   MetadataAbbrevCode,
   (uint64_t[]){METADATA, VERSION_MAJOR, VERSION_MINOR,
 CLANG_VERSION_MAJOR,

>>>
>>> Why the cast (uint64_t[])? I'm vaguely surprised that even compiles... ?
>>>
>>> This is a GNU extension (C99 compound literals in C++). It won't compile
> on MSVC.
>

Ah, good to know - thanks for the catch.


> I would imagine it'd be passed as an init list, then turned into an
>>> ArrayRef from there... but I guess not?
>>>
>>>
>>>
>>> Might be more clear with the callee:
>>>
>>>   template 
>>>   void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals,
>>>   StringRef Blob) {
>>> EmitRecordWithAbbrevImpl(Abbrev, makeArrayRef(Vals), Blob, None);
>>>   }
>>>
>>> The template can’t be deduced without the cast.
>>>
>>
>> Yeah, curious though. Another hole in perfect forwarding I suppose (not
>> that this ^ is perfect forwarding, but even with perfect forwarding it
>> doesn't cope well)
>>
>> Yeah, the cast is rather unfortunate. Hrm.
>>
>> Ah well - probably just as good to leave it as-is for now. If someone has
>> a flash of inspiration later & figures out a way to make it better, so be
>> it.
>>
>
> The way to handle this is to add another EmitRecord overload that takes a
> std::initializer_list.
>

Except the integer types aren't known - which has been one of the wrinkles
with this whole code (or at least the template is trying to allow arrays of
different integer types - but perhaps that's not important for the init
list/literal case?)


>
>
>>> —
>>> Mehdi
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
CLANG_VERSION_MINOR, !isysroot.empty(),
 IncludeTimestamps,
ASTHasCompilerErrors},
   getClangFullRepositoryVersion());

 Thanks,

 —
 Mehdi







 - Dave


>
> From: Mehdi Amini 
>
> Modified:
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247233&r1=247232&r2=247233&view=diff
>
> ==
> --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep  9
> 20:46:39 2015
> @@ -84,6 +84,7 @@ class ASTWriter : public ASTDeserializat
>  public:
>typedef SmallVector RecordData;
>typedef SmallVectorImpl RecordDataImpl;
> +  typedef ArrayRef RecordDataRef;
>
>friend class ASTDeclWriter;
>friend class ASTStmt

Re: [PATCH] D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2015-09-10 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

Can we instead fix this in Clang by ensuring that libc++ is put at the right 
position in the static link order so that its initializers run first? libc++'s 
avoidance of running iostreams init code from every translation unit is a 
significant startup performance feature, and we shouldn't abandon it unless we 
really have to.


http://reviews.llvm.org/D12689



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


Re: Preventing several replacements on a macro call.

2015-09-10 Thread Argyrios Kyrtzidis via cfe-commits
Hi Angel,

This part of the code is conservative because it is not clear if accepting the 
change in all the different places where the macro argument is expanded is 
acceptable or not.
For a contrived example, let’s say you have this macro definition:

#define MY_MAC(x) foo(x) + bar(x)

and you use it like this:

int a = MY_MAC(b);

which expands to this:

int a = foo(b) + bar(b);

Now suppose you want to find all places where “foo(b)” is used and change it to 
“foo(b.c)”. You walk the AST and find “foo(b)” from the macro expansion and you 
change ‘b’ to ‘b.c’. This change will apply to the macro argument:

int a = MY_MAC(b.c);

But this now expands like this:

int a = foo(b.c) + bar(b.c)

And you unintentionally also changed the ‘bar’ call.


Now, ideally we would keep track of all such changes and if you tried to change 
the ‘b’ in both “foo(b)” and “bar(b)” we would automatically accept it; but 
this is a bit complicated.
In the meantime we could add a ‘knob' to control this behavior. We could have a 
field in Commit object that you set to true to indicate that it is ok to accept 
a change in a macro argument that expands in multiple places, and also for 
convenience add such a knob to EditedSource object for accepting in all commits 
without needing to set it for each commit separately.

What do you think ?

> On Sep 9, 2015, at 6:05 AM, Angel Garcia via cfe-commits 
>  wrote:
> 
> +cfe-commits
> 
> On Tue, Sep 8, 2015 at 6:56 PM, Angel Garcia  > wrote:
> Hi Ted,
> 
> I was working on a clang-tidy check, and today I discovered that it was 
> unable to do several replacements in different arguments of the same macro 
> call. At first, I thought it was a bug, and trying to figure out why this was 
> happening, I found that the replacements were rejected in 
> lib/Edit/EditedSource.cpp:46, where there is a comment that says "Trying to 
> write in a macro argument input that has already been written for another 
> argument of the same macro". This comment means that this changes are 
> rejected on purpose.
> 
> At the commit history, I saw that you had commited 
>  this code (that's why I am asking you). Do 
> you think that there is a way around this? I don't really understand why 
> there is a particular case for the macros here, and understanding it would 
> help me to decide whether I should give up on trying to make this work, or 
> try to find a "better" solution.
> 
> Thanks and sorry for the inconvenience,
> Angel
> 
> ___
> 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] D11815: Pass subtarget feature "force-align-stack"

2015-09-10 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

OK, thanks. I'll go ahead and commit this patch and the llvm-side patch.


http://reviews.llvm.org/D11815



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


r247324 - Driver: Support cfi-icall on all OSs when targeting x86/x86_64.

2015-09-10 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu Sep 10 14:18:05 2015
New Revision: 247324

URL: http://llvm.org/viewvc/llvm-project?rev=247324&view=rev
Log:
Driver: Support cfi-icall on all OSs when targeting x86/x86_64.

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=247324&r1=247323&r2=247324&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Sep 10 14:18:05 2015
@@ -493,8 +493,12 @@ bool ToolChain::AddFastMathRuntimeIfAvai
 
 SanitizerMask ToolChain::getSupportedSanitizers() const {
   // Return sanitizers which don't require runtime support and are not
-  // platform or architecture-dependent.
+  // platform dependent.
   using namespace SanitizerKind;
-  return (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) | CFICastStrict |
- UnsignedIntegerOverflow | LocalBounds;
+  SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
+  CFICastStrict | UnsignedIntegerOverflow | LocalBounds;
+  if (getTriple().getArch() == llvm::Triple::x86 ||
+  getTriple().getArch() == llvm::Triple::x86_64)
+Res |= CFIICall;
+  return Res;
 }

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=247324&r1=247323&r2=247324&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Sep 10 14:18:05 2015
@@ -3764,7 +3764,6 @@ SanitizerMask Linux::getSupportedSanitiz
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;
   if (IsX86 || IsX86_64) {
-Res |= SanitizerKind::CFIICall;
 Res |= SanitizerKind::Function;
 Res |= SanitizerKind::SafeStack;
   }

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=247324&r1=247323&r2=247324&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Thu Sep 10 14:18:05 2015
@@ -230,6 +230,7 @@
 // CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 
'i386-pc-openbsd'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -flto -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=cfi -flto -c %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-CFI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-derived-cast -flto -c 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-DCAST
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi-unrelated-cast -flto -c 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-UCAST
 // RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-nvcall -c %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NVCALL


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


Re: Preventing several replacements on a macro call.

2015-09-10 Thread Angel Garcia via cfe-commits
Hi Argyrios,

Thank you for your answer. I think that it is pretty clear that we don't
really want to allow changes like the one in your example. But my problem
is almost the opposite. I have something like this:

#define MY_MAC(x,y) doSomething(x, y);

which is used in this way:

MY_MAC(var1, var1);

and I want to replace all usages of "var1" to another thing, "var2". Each
of the arguments of the macro is used only once, so it should be safe to
replace each of them independently and obtain

MY_MAC(var2, var2);

But right now what I would obtain is

MY_MAC(var2, );

They look like different cases to me, even though the threshold is not very
clear. Maybe there is a way to allow this transformation, but still
disallow yours. Or do you think that this isn't safe? I started working on
this hardly a month ago, so I am not totally aware of the risks of these
things.

Angel



On Thu, Sep 10, 2015 at 9:01 PM, Argyrios Kyrtzidis 
wrote:

> Hi Angel,
>
> This part of the code is conservative because it is not clear if accepting
> the change in all the different places where the macro argument is expanded
> is acceptable or not.
> For a contrived example, let’s say you have this macro definition:
>
> #define MY_MAC(x) foo(x) + bar(x)
>
> and you use it like this:
>
> int a = MY_MAC(b);
>
> which expands to this:
>
> int a = foo(b) + bar(b);
>
> Now suppose you want to find all places where “foo(b)” is used and change
> it to “foo(b.c)”. You walk the AST and find “foo(b)” from the macro
> expansion and you change ‘b’ to ‘b.c’. This change will apply to the macro
> argument:
>
> int a = MY_MAC(b.c);
>
> But this now expands like this:
>
> int a = foo(b.c) + bar(b.c)
>
> And you unintentionally also changed the ‘bar’ call.
>
>
> Now, ideally we would keep track of all such changes and if you tried to
> change the ‘b’ in both “foo(b)” and “bar(b)” we would automatically accept
> it; but this is a bit complicated.
> In the meantime we could add a ‘knob' to control this behavior. We could
> have a field in Commit object that you set to true to indicate that it is
> ok to accept a change in a macro argument that expands in multiple places,
> and also for convenience add such a knob to EditedSource object for
> accepting in all commits without needing to set it for each commit
> separately.
>
> What do you think ?
>
> On Sep 9, 2015, at 6:05 AM, Angel Garcia via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> +cfe-commits
>
> On Tue, Sep 8, 2015 at 6:56 PM, Angel Garcia 
> wrote:
>
>> Hi Ted,
>>
>> I was working on a clang-tidy check, and today I discovered that it was
>> unable to do several replacements in different arguments of the same macro
>> call. At first, I thought it was a bug, and trying to figure out why this
>> was happening, I found that the replacements were rejected in
>> *lib/Edit/EditedSource.cpp:46*, where there is a comment that says
>> "Trying to write in a macro argument input that has already been written
>> for another argument of the same macro". This comment means that this
>> changes are rejected on purpose.
>>
>> At the commit history, I saw that you had commited
>>  this code (that's why I am asking
>> you). Do you think that there is a way around this? I don't really
>> understand why there is a particular case for the macros here, and
>> understanding it would help me to decide whether I should give up on trying
>> to make this work, or try to find a "better" solution.
>>
>> Thanks and sorry for the inconvenience,
>> Angel
>>
>
> ___
> 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] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Igor Kudrin via cfe-commits
ikudrin updated this revision to Diff 34475.
ikudrin added a comment.

- Fixed formatting issues.
- Normalized VariableNames.
- Reworked the useUniversalCRT method to receive a path of Visual Studio.


http://reviews.llvm.org/D12695

Files:
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8951,6 +8951,13 @@
   }
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+
+  if (MSVC.useUniversalCRT(VisualStudioDir)) {
+std::string UniversalCRTLibPath;
+if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+   UniversalCRTLibPath.c_str()));
+  }
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -840,6 +840,10 @@
 
   bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
   bool getWindowsSDKLibraryPath(std::string &path) const;
+  /// \brief Check if Universal CRT should be used if available
+  bool useUniversalCRT(std::string &visualStudioDir) const;
+  bool getUniversalCRTSdkDir(std::string &path, std::string &ucrtVersion) const;
+  bool getUniversalCRTLibraryPath(std::string &path) const;
   bool getVisualStudioInstallDir(std::string &path) const;
   bool getVisualStudioBinariesFolder(const char *clangProgramPath,
  std::string &path) const;
Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -205,6 +205,21 @@
 #endif // USE_WIN32
 }
 
+// Convert LLVM's ArchType
+// to the corresponding name of Windows SDK libraries subfolder
+static StringRef getWindowsSDKArch(llvm::Triple::ArchType Arch) {
+  switch (Arch) {
+  case llvm::Triple::x86:
+return "x86";
+  case llvm::Triple::x86_64:
+return "x64";
+  case llvm::Triple::arm:
+return "arm";
+  default:
+return "";
+  }
+}
+
 /// \brief Get Windows SDK installation directory.
 bool MSVCToolChain::getWindowsSDKDir(std::string &path, int &major,
  int &minor) const {
@@ -263,26 +278,75 @@
 if (!found)
   return false;
 
-llvm::sys::path::append(libPath, "um");
-switch (getArch()) {
-case llvm::Triple::x86:
-  llvm::sys::path::append(libPath, "x86");
-  break;
-case llvm::Triple::x86_64:
-  llvm::sys::path::append(libPath, "x64");
-  break;
-case llvm::Triple::arm:
-  llvm::sys::path::append(libPath, "arm");
-  break;
-default:
+const StringRef archName = getWindowsSDKArch(getArch());
+if (archName.empty())
   return false;
-}
+llvm::sys::path::append(libPath, "um", archName);
   }
 
   path = libPath.str();
   return true;
 }
 
+// Check if the Include path of a specified version of Visual Studio contains
+// specific header files. If not, they are probably shipped with Universal CRT.
+bool clang::driver::toolchains::MSVCToolChain::useUniversalCRT(
+std::string &VisualStudioDir) const {
+  llvm::SmallString<128> TestPath(VisualStudioDir);
+  llvm::sys::path::append(TestPath, "VC\\include\\stdlib.h");
+
+  return !llvm::sys::fs::exists(TestPath);
+}
+
+bool MSVCToolChain::getUniversalCRTSdkDir(std::string &Path,
+  std::string &UCRTVersion) const {
+  // vcvarsqueryregistry.bat for Visual Studio 2015 queries the registry
+  // for the specific key "KitsRoot10". So do we.
+  if (!getSystemRegistryString(
+  "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10",
+  Path, nullptr))
+return false;
+
+  UCRTVersion.clear();
+
+  // Find the most recent version of Universal CRT.
+  // vcvarsqueryregistry.bat sorts entries in the include directory by names and
+  // uses the last one of the list.
+  // So we compare entry names lexicographically to find the greatest one.
+  std::error_code EC;
+  llvm::SmallString<128> IncludePath(Path);
+  llvm::sys::path::append(IncludePath, "Include");
+  for (llvm::sys::fs::directory_iterator DirIt(IncludePath, EC), DirEnd;
+   DirIt != DirEnd && !EC; DirIt.increment(EC)) {
+if (!llvm::sys::fs::is_directory(DirIt->path()))
+  continue;
+StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
+if (CandidateName > UCRTVersion)
+  UCRTVersion = CandidateName;
+  }
+
+  return !UCRTVersion.empty();
+}
+
+bool MSVCToolChain::getUniversalCRTLibraryPath(std::string &Path) const {
+  std::string UniversalCRTSdkPath;
+  std::string UCRTVersion;
+
+  Path.clear();
+  if (!getUniversalCRTSdkDir(UniversalCRTSdkPath,

Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 8 inline comments as done.
andreybokhanko added a comment.

http://reviews.llvm.org/D12402



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


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 34477.
andreybokhanko added a comment.

Reid,

Sorry for delayed reply. All your comments are fixed (it turned out that usage 
of DefaultCC instead of ToCC is the root of all evil; after I fixed this, all 
other problems went away).

Patch updated; please re-review.

Andrey


http://reviews.llvm.org/D12402

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/SemaCXX/decl-microsoft-call-conv.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2269,8 +2269,11 @@
 
   // Adjust the default free function calling convention to the default method
   // calling convention.
+  bool IsCtorOrDtor =
+  (Entity.getNameKind() == DeclarationName::CXXConstructorName) ||
+  (Entity.getNameKind() == DeclarationName::CXXDestructorName);
   if (T->isFunctionType())
-adjustMemberFunctionCC(T, /*IsStatic=*/false);
+adjustMemberFunctionCC(T, /*IsStatic=*/false, IsCtorOrDtor, Loc);
 
   return Context.getMemberPointerType(T, Class.getTypePtr());
 }
@@ -5842,25 +5845,43 @@
   return false;
 }
 
-void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic) {
+void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor,
+  SourceLocation Loc) {
   FunctionTypeUnwrapper Unwrapped(*this, T);
   const FunctionType *FT = Unwrapped.get();
   bool IsVariadic = (isa(FT) &&
  cast(FT)->isVariadic());
-
-  // Only adjust types with the default convention.  For example, on Windows we
-  // should adjust a __cdecl type to __thiscall for instance methods, and a
-  // __thiscall type to __cdecl for static methods.
   CallingConv CurCC = FT->getCallConv();
-  CallingConv FromCC =
-  Context.getDefaultCallingConvention(IsVariadic, IsStatic);
   CallingConv ToCC = Context.getDefaultCallingConvention(IsVariadic, !IsStatic);
-  if (CurCC != FromCC || FromCC == ToCC)
-return;
 
-  if (hasExplicitCallingConv(T))
+  if (CurCC == ToCC)
 return;
 
+  // MS compiler ignores explicit calling convention attributes on structors. We
+  // should do the same.
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() && IsCtorOrDtor) {
+// Issue a warning on ignored calling convention -- except of __stdcall.
+// Again, this is what MS compiler does.
+if (CurCC != CC_X86StdCall)
+  Diag(Loc, diag::warn_cconv_structors)
+  << FunctionType::getNameForCallConv(CurCC);
+  // Default adjustment.
+  } else {
+// Only adjust types with the default convention.  For example, on Windows
+// we should adjust a __cdecl type to __thiscall for instance methods, and a
+// __thiscall type to __cdecl for static methods.
+CallingConv DefaultCC =
+Context.getDefaultCallingConvention(IsVariadic, IsStatic);
+
+if (!IsCtorOrDtor) {
+  if (CurCC != DefaultCC || DefaultCC == ToCC)
+return;
+
+  if (hasExplicitCallingConv(T))
+return;
+}
+  }
+
   FT = Context.adjustFunctionType(FT, FT->getExtInfo().withCallingConv(ToCC));
   QualType Wrapped = Unwrapped.wrap(*this, FT);
   T = Context.getAdjustedType(T, Wrapped);
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -351,6 +351,11 @@
   getName().OperatorFunctionId.Operator));
 }
 
+bool Declarator::isCtorOrDtor() {
+  return (getName().getKind() == UnqualifiedId::IK_ConstructorName) ||
+ (getName().getKind() == UnqualifiedId::IK_DestructorName);
+}
+
 bool DeclSpec::hasTagDefinition() const {
   if (!TypeSpecOwned)
 return false;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7244,7 +7244,8 @@
   << DeclSpec::getSpecifierName(TSCS);
 
   if (D.isFirstDeclarationOfMember())
-adjustMemberFunctionCC(R, D.isStaticMember());
+adjustMemberFunctionCC(R, D.isStaticMember(), D.isCtorOrDtor(),
+   D.getIdentifierLoc());
 
   bool isFriend = false;
   FunctionTemplateDecl *FunctionTemplate = nullptr;
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -2208,6 +2208,9 @@
   /// redeclaration time if the decl is static.
   bool isStaticMember();
 
+  /// Returns true if this declares a constructor or a destructor.
+  bool isCtorOrDtor();
+
   void setRedeclaration(bool Val) { Redeclaration = Val; }
   bool isRedeclaration() const { return Redeclaration; }
 };
Index: include/clang/Sema/Sema.h

r247327 - Move sel-address.mm from test/CodeGenCXX to test/SemaObjCXX, it's not a codegen test.

2015-09-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Sep 10 14:35:31 2015
New Revision: 247327

URL: http://llvm.org/viewvc/llvm-project?rev=247327&view=rev
Log:
Move sel-address.mm from test/CodeGenCXX to test/SemaObjCXX, it's not a codegen 
test.

Added:
cfe/trunk/test/SemaObjCXX/sel-address.mm
  - copied, changed from r247293, cfe/trunk/test/CodeGenCXX/sel-address.mm
Removed:
cfe/trunk/test/CodeGenCXX/sel-address.mm

Removed: cfe/trunk/test/CodeGenCXX/sel-address.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sel-address.mm?rev=247326&view=auto
==
--- cfe/trunk/test/CodeGenCXX/sel-address.mm (original)
+++ cfe/trunk/test/CodeGenCXX/sel-address.mm (removed)
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 %s -verify -emit-llvm -o %t
-// pr7390
-
-void f(const SEL& v2) {}
-void g() {
-  f(@selector(dealloc));
-
-  SEL s = @selector(dealloc);
- SEL* ps = &s;
-
- @selector(dealloc) = s;  // expected-error {{expression is not assignable}}
-
- SEL* ps2 = &@selector(dealloc);
-}

Copied: cfe/trunk/test/SemaObjCXX/sel-address.mm (from r247293, 
cfe/trunk/test/CodeGenCXX/sel-address.mm)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/sel-address.mm?p2=cfe/trunk/test/SemaObjCXX/sel-address.mm&p1=cfe/trunk/test/CodeGenCXX/sel-address.mm&r1=247293&r2=247327&rev=247327&view=diff
==
--- cfe/trunk/test/CodeGenCXX/sel-address.mm (original)
+++ cfe/trunk/test/SemaObjCXX/sel-address.mm Thu Sep 10 14:35:31 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -emit-llvm -o %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 // pr7390
 
 void f(const SEL& v2) {}
@@ -6,9 +6,9 @@ void g() {
   f(@selector(dealloc));
 
   SEL s = @selector(dealloc);
- SEL* ps = &s;
+  SEL* ps = &s;
 
- @selector(dealloc) = s;  // expected-error {{expression is not assignable}}
+  @selector(dealloc) = s;  // expected-error {{expression is not assignable}}
 
- SEL* ps2 = &@selector(dealloc);
+  SEL* ps2 = &@selector(dealloc);
 }


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


Re: [PATCH] D12695: [Driver] Use UniversalCRT on Windows if available

2015-09-10 Thread Rui Ueyama via cfe-commits
ruiu added a comment.

I'm sorry about leave http://reviews.llvm.org/D12604 hanging. I didn't notice 
that it got a new review message. Don't mind my patch -- please just submit 
when you got LGTM


http://reviews.llvm.org/D12695



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


  1   2   >