[PATCH] D28218: Small optimizations for SourceManager::getFileID()

2017-01-12 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Ping?


https://reviews.llvm.org/D28218



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


LLVM buildmaster will be unavailable on 1/13/17

2017-01-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be offline on 1/13/17 hopefully for short time due
for replacing network hardware.
Thank you for understanding.

Thanks

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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:86
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
+

I don't know why the unevaluated context warning didn't work here.


https://reviews.llvm.org/D28467



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


r291881 - Another fix for r291850 because there are apparently targets which add

2017-01-12 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Jan 12 20:47:34 2017
New Revision: 291881

URL: http://llvm.org/viewvc/llvm-project?rev=291881=rev
Log:
Another fix for r291850 because there are apparently targets which add
"-mllvm" flags to the CC1 invocation (notably, Hexagon seems to hit
this).

Modified:
cfe/trunk/test/Driver/disable-llvm.c

Modified: cfe/trunk/test/Driver/disable-llvm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/disable-llvm.c?rev=291881=291880=291881=diff
==
--- cfe/trunk/test/Driver/disable-llvm.c (original)
+++ cfe/trunk/test/Driver/disable-llvm.c Thu Jan 12 20:47:34 2017
@@ -2,8 +2,8 @@
 // RUN: %clang -O2 -Xclang -disable-llvm-passes -### %s 2>&1 \
 // RUN: | FileCheck --check-prefix=DISABLED %s
 // DISABLED: -cc1
-// DISABLED-NOT: -mllvm
-// DISABLED: -disable-llvm-passes
+// DISABLED-NOT: "-mllvm" "-disable-llvm-passes"
+// DISABLED: "-disable-llvm-passes"
 //
 // We also support two alternative spellings for historical reasons.
 // RUN: %clang -O2 -Xclang -disable-llvm-optzns -### %s 2>&1 \
@@ -11,8 +11,8 @@
 // RUN: %clang -O2 -mllvm -disable-llvm-optzns -### %s 2>&1 \
 // RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s
 // DISABLED-LEGACY: -cc1
-// DISABLED-LEGACY-NOT: -mllvm
-// DISABLED-LEGACY: -disable-llvm-optzns
+// DISABLED-LEGACY-NOT: "-mllvm" "-disable-llvm-optzns"
+// DISABLED-LEGACY: "-disable-llvm-optzns"
 //
 // The main flag shouldn't be specially handled when used with '-mllvm'.
 // RUN: %clang -O2 -mllvm -disable-llvm-passes -### %s 2>&1 | FileCheck 
--check-prefix=MLLVM %s


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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D28588#644637, @danielcdh wrote:

> Looks like this is still breaking these buildbots:
>
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3216/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Athinlto_backend.ll
>
> I reverted the test change for now, and am thinking of how to reproduce/fix 
> the problem...


Aha - the test is missing "-target x86_64-unknown-linux-gnu". Probably because 
it was cloned from the one just above or below it, which are testing for other 
failures hit early on and didn't need it (they should probably have it as well 
to avoid confusion like this in the future though).


https://reviews.llvm.org/D28588



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


[PATCH] D28451: [AVR] Add support for the 'interrupt' and 'naked' attributes

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:488
+
+def AVRSignal : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [GNU<"signal">];

dylanmckay wrote:
> aaron.ballman wrote:
> > Does this attribute appertain to any specific subjects, or can you apply it 
> > to any declaration?
> It can be applied to function definitions only.
Then it should have a Subjects line like `AVRInterrupt` does.



Comment at: lib/CodeGen/TargetInfo.cpp:6898
+   CodeGen::CodeGenModule ) const override {
+const FunctionDecl *FD = dyn_cast_or_null(D);
+if (!FD) return;

You can use `const auto *` here.



Comment at: lib/Sema/SemaDeclAttr.cpp:5129
 
+static void handleAVRInterruptAttr(Sema , Decl *D,
+   const AttributeList ) {

You can remove this function.



Comment at: lib/Sema/SemaDeclAttr.cpp:5136
+
+static void handleAVRSignalAttr(Sema , Decl *D,
+const AttributeList ) {

...and this one.



Comment at: lib/Sema/SemaDeclAttr.cpp:5158
+  case llvm::Triple::avr:
+handleAVRInterruptAttr(S, D, Attr);
+break;

Just call `handleSimpleAttribute()` instead.



Comment at: lib/Sema/SemaDeclAttr.cpp:5721
+  case AttributeList::AT_AVRSignal:
+handleAVRSignalAttr(S, D, Attr);
+break;

...same here.



Comment at: test/CodeGen/avr/attributes/naked.c:4
+// CHECK: define void @foo() #0
+__attribute__((naked)) void foo(void) { }
+

dylanmckay wrote:
> aaron.ballman wrote:
> > This test seems unrelated as you didn't modify anything about the naked 
> > attribute?
> I didn't modify the naked attribute, but I did want to include a test for AVR.
This should probably be a separate commit then (and doesn't really need code 
review, since it's just adding a test and is otherwise NFC); just make sure the 
commit message explains why the test is beneficial to add.


https://reviews.llvm.org/D28451



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM; this is an awesome new diagnostic, thank you for working on it!




Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:26
+  auto explicit_initialized_value_used = [j = 1] { return j + 1; };
+  auto explicit_initialized_value_unused = [j = 1] {}; // 
expected-warning{{lambda capture 'j' is not used}}
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > Quuxplusone wrote:
> > > > Would this still produce a diagnostic if `decltype(j)` were something 
> > > > complicated like `lock_guard` or `string`? Presumably it should do the 
> > > > same thing, more or less, as the other -Wunused diagnostics, which I 
> > > > think is "don't warn if the constructor/destructor might actually do 
> > > > important work".
> > > I was planning to check for that; thanks for the reminder.
> > One more complex case:
> > ```
> > #include 
> > 
> > struct B {
> >   virtual ~B() = default;
> > };
> > 
> > struct D : B {};
> > 
> > struct C {
> >   B& get_d() const;
> >   C get_c() const;
> > };
> > 
> > void f() {
> >   C c1, c2;
> >   [c1, c2] {
> > (void)typeid(c1.get_d());
> > (void)typeid(c2.get_c());
> >   }();
> > }
> > ```
> > Hopefully this does not diagnose `c1` as being unused but still diagnoses 
> > `c2` as unused.
> These tests are run with `-nostdsysteminc`, so I ran it manually:
> ```
> aaron.cpp:17:21: warning: expression with side effects will be evaluated 
> despite being used as an operand to 'typeid'
>   [-Wpotentially-evaluated-expression]
> (void)typeid(c1.get_d());
> ^
> aaron.cpp:16:8: warning: lambda capture 'c2' is not required to be captured 
> for use in an unevaluated context [-Wunused-lambda-capture]
>   [c1, c2] {
>^
> 2 warnings generated.
> ```
Perfect!


https://reviews.llvm.org/D28467



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


r291880 - Implement DR1265 (wg21.link/cwg1265).

2017-01-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 12 20:22:01 2017
New Revision: 291880

URL: http://llvm.org/viewvc/llvm-project?rev=291880=rev
Log:
Implement DR1265 (wg21.link/cwg1265).

Diasllow a declaration using the 'auto' type specifier from using two different
meanings of it at once, or from declaring multiple functions with deduced
return types or introducing multiple trailing return types.

The standard does not technically disallow the multiple trailing return types
case if all the declarators declare variables (such as function pointers with
trailing return types), but we disallow that too, following the clear intent.

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
cfe/trunk/test/CXX/drs/dr12xx.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=291880=291879=291880=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Jan 12 20:22:01 2017
@@ -1867,6 +1867,11 @@ public:
   /// types, but not through decltype or typedefs.
   AutoType *getContainedAutoType() const;
 
+  /// Determine whether this type was written with a leading 'auto'
+  /// corresponding to a trailing return type (possibly for a nested
+  /// function type within a pointer to function type or similar).
+  bool hasAutoForTrailingReturnType() const;
+
   /// Member-template getAs'.  Look through sugar for
   /// an instance of \.   This scheme will eventually
   /// replace the specific getAs methods above.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291880=291879=291880=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 12 20:22:01 
2017
@@ -1900,6 +1900,10 @@ def err_auto_new_deduction_failure : Err
 def err_auto_different_deductions : Error<
   "'%select{auto|decltype(auto)|__auto_type}0' deduced as %1 in declaration "
   "of %2 and deduced as %3 in declaration of %4">;
+def err_auto_non_deduced_not_alone : Error<
+  "%select{function with deduced return type|"
+  "declaration with trailing return type}0 "
+  "must be the only declaration in its group">;
 def err_implied_std_initializer_list_not_found : Error<
   "cannot deduce type of initializer list because std::initializer_list was "
   "not found; include ">;

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=291880=291879=291880=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Jan 12 20:22:01 2017
@@ -1560,60 +1560,73 @@ TagDecl *Type::getAsTagDecl() const {
 
 namespace {
   class GetContainedAutoVisitor :
-public TypeVisitor {
+public TypeVisitor {
+bool Syntactic;
   public:
-using TypeVisitor::Visit;
-AutoType *Visit(QualType T) {
+GetContainedAutoVisitor(bool Syntactic = false) : Syntactic(Syntactic) {}
+
+using TypeVisitor::Visit;
+Type *Visit(QualType T) {
   if (T.isNull())
 return nullptr;
   return Visit(T.getTypePtr());
 }
 
 // The 'auto' type itself.
-AutoType *VisitAutoType(const AutoType *AT) {
+Type *VisitAutoType(const AutoType *AT) {
   return const_cast(AT);
 }
 
 // Only these types can contain the desired 'auto' type.
-AutoType *VisitPointerType(const PointerType *T) {
+Type *VisitPointerType(const PointerType *T) {
   return Visit(T->getPointeeType());
 }
-AutoType *VisitBlockPointerType(const BlockPointerType *T) {
+Type *VisitBlockPointerType(const BlockPointerType *T) {
   return Visit(T->getPointeeType());
 }
-AutoType *VisitReferenceType(const ReferenceType *T) {
+Type *VisitReferenceType(const ReferenceType *T) {
   return Visit(T->getPointeeTypeAsWritten());
 }
-AutoType *VisitMemberPointerType(const MemberPointerType *T) {
+Type *VisitMemberPointerType(const MemberPointerType *T) {
   return Visit(T->getPointeeType());
 }
-AutoType *VisitArrayType(const ArrayType *T) {
+Type *VisitArrayType(const ArrayType *T) {
   return Visit(T->getElementType());
 }
-AutoType *VisitDependentSizedExtVectorType(
+Type *VisitDependentSizedExtVectorType(
 

[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-12 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 84209.
xiangzhai added a comment.

Hi Anna,

Thanks for your review!

I process them (for example, g_malloc_n, take a different number of arguments) 
separately.

And I run the testcases for Analysis/malloc.c and Analysis/gmalloc.c

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D28348

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/gmalloc.c

Index: test/Analysis/gmalloc.c
===
--- test/Analysis/gmalloc.c
+++ test/Analysis/gmalloc.c
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+typedef void* gpointer;
+typedef const void* gconstpointer;
+typedef unsigned long gsize;
+typedef unsigned int guint;
+
+gpointer g_malloc(gsize n_bytes);
+gpointer g_malloc0(gsize n_bytes);
+gpointer g_realloc(gpointer mem, gsize n_bytes);
+gpointer g_try_malloc(gsize n_bytes);
+gpointer g_try_malloc0(gsize n_bytes);
+gpointer g_try_realloc(gpointer mem, gsize n_bytes);
+gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+void g_free(gpointer mem);
+gpointer g_memdup(gconstpointer mem, guint byte_size);
+
+static const gsize n_bytes = 1024;
+
+void f1() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g2); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g3);
+  g3 = g_memdup(g3, n_bytes); // expected-warning{{Use of memory after it is freed}}
+}
+
+void f3() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2); // expected-warning{{Potential leak of memory pointed to by 'g4'}}
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+}
+
+void f4() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+  g_free(g4);
+}
+
+void f5() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = 

Re: [PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via cfe-commits
On Thu, Jan 12, 2017 at 3:27 PM, Teresa Johnson via Phabricator <
revi...@reviews.llvm.org> wrote:

> tejohnson added a comment.
>
> In https://reviews.llvm.org/D28588#644489, @danielcdh wrote:
>
> > Thanks for the prompt response.
> >
> > But looks like several other tests also has "-mllvm
> -debug-pass=Structure" in their tests:
> >
> > tools/clang/test/CodeGen/pgo-instrumentation.c
> >  test/CodeGen/Generic/llc-start-stop.ll
> >
> > I just verified that if I cmake with -DCMAKE_BUILD_TYPE=Release, it
> still passes locally.
>
>
> Hmm, maybe that flavor of -debug output is enabled with NDEBUG then. I'm
> not really sure unfortunately.
>
> I don't even see an error message for the second one, do you? Just an
> error code.
>

>From the first buildbot failure (windows), looks like it's not just lack of
output, but also the compile command failed:

note: command had no output on stdout or stderr
error: command failed with exit status: 1

But it did not provide why it exits non-zero.

Dehao


>
> > Thanks,
> > Dehao
>
>
>
>
> https://reviews.llvm.org/D28588
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291879 - Add a necessary newline for diagnose_if documentation.

2017-01-12 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Jan 12 19:52:04 2017
New Revision: 291879

URL: http://llvm.org/viewvc/llvm-project?rev=291879=rev
Log:
Add a necessary newline for diagnose_if documentation.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=291879=291878=291879=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jan 12 19:52:04 2017
@@ -386,6 +386,7 @@ warnings or errors at compile-time if ca
 certain user-defined criteria. For example:
 
 .. code-block:: c
+
   void abs(int a)
 __attribute__((diagnose_if(a >= 0, "Redundant abs call", "warning")));
   void must_abs(int a)


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


Re: r291877 - [Sema] Restrict explicit instantation definition dllexport

2017-01-12 Thread Shoaib Meenai via cfe-commits
Requesting a merge to the 4.0 branch. This is a pretty small change, and it
fixes an assertion failure on Windows (see PR31608 for details).

On 1/12/17, 5:28 PM, "cfe-commits on behalf of Shoaib Meenai via cfe-commits" 
 
wrote:

Author: smeenai
Date: Thu Jan 12 19:28:34 2017
New Revision: 291877

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D291877-26view-3Drev=DgIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=UFJ7c0vMtAjKBdgoPzfL-28zDS1KWJTBHGfq_xGDm1s=f_XKXZU8x-ZpL2CZ0EhN86GlPYk_1RLL5eWxv3GY-pw=
 
Log:
[Sema] Restrict explicit instantation definition dllexport

In the case where the template class itself is already `dllexport`, the
implicit instantiation will have already emitted all members. When we
check the explicit instantiation definition, the `Specialization` will
have inherited the `dllexport` attribute, so we'll attempt to emit all
members for a second time, which causes an assertion failure. Restrict
the exporting to when the `dllexport` attribute is newly introduced by
the explicit instantiation definition.

Fixes PR31608.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D28590=DgIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=UFJ7c0vMtAjKBdgoPzfL-28zDS1KWJTBHGfq_xGDm1s=_S3zURGo2pjkoiqGSalH86SQhl0uez7FVTThjoUsDBM=
 

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Sema_SemaTemplate.cpp-3Frev-3D291877-26r1-3D291876-26r2-3D291877-26view-3Ddiff=DgIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=UFJ7c0vMtAjKBdgoPzfL-28zDS1KWJTBHGfq_xGDm1s=b0Jr4tQuZy47gIKQ8bfcMHR9cI1etlRhCEyIiB_FHUQ=
 

==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jan 12 19:28:34 2017
@@ -7789,6 +7789,7 @@ Sema::ActOnExplicitInstantiation(Scope *
   Specialization->setTemplateKeywordLoc(TemplateLoc);
   Specialization->setBraceRange(SourceRange());
 
+  bool PreviouslyDLLExported = Specialization->hasAttr();
   if (Attr)
 ProcessDeclAttributeList(S, Specialization, Attr);
 
@@ -7851,8 +7852,9 @@ Sema::ActOnExplicitInstantiation(Scope *
 
 // Fix a TSK_ImplicitInstantiation followed by a
 // TSK_ExplicitInstantiationDefinition
-if (Old_TSK == TSK_ImplicitInstantiation &&
-Specialization->hasAttr() &&
+bool NewlyDLLExported =
+!PreviouslyDLLExported && Specialization->hasAttr();
+if (Old_TSK == TSK_ImplicitInstantiation && NewlyDLLExported &&
 (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
  
Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
   // In the MS ABI, an explicit instantiation definition can add a dll

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGenCXX_dllexport.cpp-3Frev-3D291877-26r1-3D291876-26r2-3D291877-26view-3Ddiff=DgIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=UFJ7c0vMtAjKBdgoPzfL-28zDS1KWJTBHGfq_xGDm1s=flzgUkXiH3mW7lOEqDMPrQISbxAFlVVmkEaF4cimxk4=
 

==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Thu Jan 12 19:28:34 2017
@@ -732,13 +732,27 @@ USEMEMFUNC(ExplicitInstantiationDeclExpo
 // M32-DAG: define weak_odr dllexport x86_thiscallcc 
%struct.ExplicitInstantiationDeclExportedDefTemplate* 
@"\01??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv
 
-template  struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { void f() {} };
+template  struct 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate { virtual void 
f() {} };
+ImplicitInstantiationExportedExplicitInstantiationDefTemplate 
ImplicitInstantiationExportedExplicitInstantiationDefTemplateInstance;
+template struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate;

+USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefTemplate, 
f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExportedExplicitInstantiationDefTemplate@H@@UAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 

[PATCH] D28590: [Sema] Restrict explicit instantation definition dllexport

2017-01-12 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291877: [Sema] Restrict explicit instantation definition 
dllexport (authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D28590?vs=84062=84202#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28590

Files:
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CodeGenCXX/dllexport.cpp


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -7789,6 +7789,7 @@
   Specialization->setTemplateKeywordLoc(TemplateLoc);
   Specialization->setBraceRange(SourceRange());
 
+  bool PreviouslyDLLExported = Specialization->hasAttr();
   if (Attr)
 ProcessDeclAttributeList(S, Specialization, Attr);
 
@@ -7851,8 +7852,9 @@
 
 // Fix a TSK_ImplicitInstantiation followed by a
 // TSK_ExplicitInstantiationDefinition
-if (Old_TSK == TSK_ImplicitInstantiation &&
-Specialization->hasAttr() &&
+bool NewlyDLLExported =
+!PreviouslyDLLExported && Specialization->hasAttr();
+if (Old_TSK == TSK_ImplicitInstantiation && NewlyDLLExported &&
 (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
  Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
   // In the MS ABI, an explicit instantiation definition can add a dll
Index: cfe/trunk/test/CodeGenCXX/dllexport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp
@@ -732,13 +732,27 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc 
%struct.ExplicitInstantiationDeclExportedDefTemplate* 
@"\01??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv
 
-template  struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { void f() {} };
+template  struct 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate { virtual void 
f() {} };
+ImplicitInstantiationExportedExplicitInstantiationDefTemplate 
ImplicitInstantiationExportedExplicitInstantiationDefTemplateInstance;
+template struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate;
+USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefTemplate, 
f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExportedExplicitInstantiationDefTemplate@H@@UAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExportedExplicitInstantiationDefTemplateIiE1fEv
+
+template  struct __declspec(dllexport) 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { virtual void 
f() {} };
 ImplicitInstantiationExplicitInstantiationDefExportedTemplate 
ImplicitInstantiationExplicitInstantiationDefExportedTemplateInstance;
-template class __declspec(dllexport) 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate;
+template struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate;
 USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefExportedTemplate, 
f);
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@QAEXXZ"
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@UAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv
 
+template  struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate { virtual 
void f() {} };
+ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateInstance;
+template struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate;
+USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate,
 f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate@H@@UAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN69ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateIiE1fEv
+
 namespace { struct InternalLinkageType {}; }
 struct __declspec(dllexport) PR23308 {
   void f(InternalLinkageType*);


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -7789,6 +7789,7 @@
   Specialization->setTemplateKeywordLoc(TemplateLoc);
   Specialization->setBraceRange(SourceRange());
 
+  bool PreviouslyDLLExported = Specialization->hasAttr();
   if (Attr)
 

r291877 - [Sema] Restrict explicit instantation definition dllexport

2017-01-12 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jan 12 19:28:34 2017
New Revision: 291877

URL: http://llvm.org/viewvc/llvm-project?rev=291877=rev
Log:
[Sema] Restrict explicit instantation definition dllexport

In the case where the template class itself is already `dllexport`, the
implicit instantiation will have already emitted all members. When we
check the explicit instantiation definition, the `Specialization` will
have inherited the `dllexport` attribute, so we'll attempt to emit all
members for a second time, which causes an assertion failure. Restrict
the exporting to when the `dllexport` attribute is newly introduced by
the explicit instantiation definition.

Fixes PR31608.

Differential Revision: https://reviews.llvm.org/D28590

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=291877=291876=291877=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jan 12 19:28:34 2017
@@ -7789,6 +7789,7 @@ Sema::ActOnExplicitInstantiation(Scope *
   Specialization->setTemplateKeywordLoc(TemplateLoc);
   Specialization->setBraceRange(SourceRange());
 
+  bool PreviouslyDLLExported = Specialization->hasAttr();
   if (Attr)
 ProcessDeclAttributeList(S, Specialization, Attr);
 
@@ -7851,8 +7852,9 @@ Sema::ActOnExplicitInstantiation(Scope *
 
 // Fix a TSK_ImplicitInstantiation followed by a
 // TSK_ExplicitInstantiationDefinition
-if (Old_TSK == TSK_ImplicitInstantiation &&
-Specialization->hasAttr() &&
+bool NewlyDLLExported =
+!PreviouslyDLLExported && Specialization->hasAttr();
+if (Old_TSK == TSK_ImplicitInstantiation && NewlyDLLExported &&
 (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
  Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
   // In the MS ABI, an explicit instantiation definition can add a dll

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=291877=291876=291877=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Thu Jan 12 19:28:34 2017
@@ -732,13 +732,27 @@ USEMEMFUNC(ExplicitInstantiationDeclExpo
 // M32-DAG: define weak_odr dllexport x86_thiscallcc 
%struct.ExplicitInstantiationDeclExportedDefTemplate* 
@"\01??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv
 
-template  struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { void f() {} };
+template  struct 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate { virtual void 
f() {} };
+ImplicitInstantiationExportedExplicitInstantiationDefTemplate 
ImplicitInstantiationExportedExplicitInstantiationDefTemplateInstance;
+template struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefTemplate;
+USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefTemplate, 
f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExportedExplicitInstantiationDefTemplate@H@@UAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExportedExplicitInstantiationDefTemplateIiE1fEv
+
+template  struct __declspec(dllexport) 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { virtual void 
f() {} };
 ImplicitInstantiationExplicitInstantiationDefExportedTemplate 
ImplicitInstantiationExplicitInstantiationDefExportedTemplateInstance;
-template class __declspec(dllexport) 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate;
+template struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate;
 USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefExportedTemplate, 
f);
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@QAEXXZ"
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@UAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv
 
+template  struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate { virtual 
void f() {} };
+ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateInstance;
+template struct __declspec(dllexport) 
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate;

r291876 - [DOXYGEN] Documentation for the newly added x86 intrinsics.

2017-01-12 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Jan 12 19:14:08 2017
New Revision: 291876

URL: http://llvm.org/viewvc/llvm-project?rev=291876=rev
Log:
[DOXYGEN] Documentation for the newly added x86 intrinsics.

Added doxygen comments for the newly added intrinsics in avxintrin.h, namely 
_mm256_cvtsd_f64, _mm256_cvtsi256_si32 and _mm256_cvtss_f32 

Added doxygen comments for the new intrinsics in emmintrin.h, namely 
_mm_loadu_si64 and _mm_load_sd.

Explicit parameter names were added for _mm_clflush and _mm_setcsr 

The rest of the changes are editorial, removing trailing spaces at the end of 
the lines.

Differential Revision: https://reviews.llvm.org/D28503



Modified:
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/mmintrin.h
cfe/trunk/lib/Headers/pmmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=291876=291875=291876=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Thu Jan 12 19:14:08 2017
@@ -2184,12 +2184,32 @@ _mm256_cvttps_epi32(__m256 __a)
   return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
 }
 
+/// \brief Returns the first element of the input vector of [4 x double].
+///
+/// \headerfile 
+///
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
+///
+/// \param __a
+///A 256-bit vector of [4 x double].
+/// \returns A 64 bit double containing the first element of the input vector.
 static __inline double __DEFAULT_FN_ATTRS
 _mm256_cvtsd_f64(__m256d __a)
 {
  return __a[0];
 }
 
+/// \brief Returns the first element of the input vector of [8 x i32].
+///
+/// \headerfile 
+///
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32].
+/// \returns A 32 bit integer containing the first element of the input vector.
 static __inline int __DEFAULT_FN_ATTRS
 _mm256_cvtsi256_si32(__m256i __a)
 {
@@ -2197,6 +2217,16 @@ _mm256_cvtsi256_si32(__m256i __a)
  return __b[0];
 }
 
+/// \brief Returns the first element of the input vector of [8 x float].
+///
+/// \headerfile 
+///
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x float].
+/// \returns A 32 bit float containing the first element of the input vector.
 static __inline float __DEFAULT_FN_ATTRS
 _mm256_cvtss_f32(__m256 __a)
 {

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=291876=291875=291876=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Thu Jan 12 19:14:08 2017
@@ -1599,6 +1599,17 @@ _mm_loadu_pd(double const *__dp)
   return ((struct __loadu_pd*)__dp)->__v;
 }
 
+/// \brief Loads a 64-bit integer value to the low element of a 128-bit integer
+///vector and clears the upper element.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VMOVQ / MOVQ  instruction.
+///
+/// \param __dp
+///A pointer to a 64-bit memory location. The address of the memory
+///location does not have to be aligned.
+/// \returns A 128-bit vector of [2 x i64] containing the loaded value.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_loadu_si64(void const *__a)
 {
@@ -1609,6 +1620,17 @@ _mm_loadu_si64(void const *__a)
   return (__m128i){__u, 0L};
 }
 
+/// \brief Loads a 64-bit double-precision value to the low element of a
+///128-bit integer vector and clears the upper element.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VMOVSD / MOVSD  instruction.
+///
+/// \param __dp
+///An pointer to a memory location containing a double-precision value.
+///The address of the memory location does not have to be aligned.
+/// \returns A 128-bit vector of [2 x double] containing the loaded value.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_load_sd(double const *__dp)
 {
@@ -4019,7 +4041,7 @@ extern "C" {
 /// \param __p
 ///A pointer to the memory location used to identify the cache line to be
 ///flushed.
-void _mm_clflush(void const *);
+void _mm_clflush(void const * __p);
 
 /// \brief Forces strong memory ordering (serialization) between load
 ///instructions preceding this instruction and load instructions following
@@ -4141,7 +4163,7 @@ _mm_packus_epi16(__m128i __a, __m128i __
 /// \param __a
 ///A 128-bit integer vector.
 /// \param __imm
-///An immediate value. Bits [3:0] selects values from \a __a to be assigned
+///An immediate value. Bits [2:0] selects values from \a __a to be assigned
 ///to bits[15:0] of the result. \n

[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added a comment.

Looks like this is still breaking these buildbots:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3216/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Athinlto_backend.ll

I reverted the test change for now, and am thinking of how to reproduce/fix the 
problem...


https://reviews.llvm.org/D28588



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


r291874 - Temporarily revert the test change in 291870, which is broken in certain buildbots.

2017-01-12 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Jan 12 19:09:43 2017
New Revision: 291874

URL: http://llvm.org/viewvc/llvm-project?rev=291874=rev
Log:
Temporarily revert the test change in 291870, which is broken in certain 
buildbots.

Modified:
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291874=291873=291874=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Thu Jan 12 19:09:43 2017
@@ -8,10 +8,6 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
 
-; Ensure sample profile pass are passed to backend
-; RUN: %clang_cc1 -emit-obj -O2 -o %t5.o -x ir %t1.o 
-fthinlto-index=%t.thinlto.bc -fprofile-sample-use=%S/Inputs/pgo-sample.prof 
-mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
-; CHECK-SAMPLEPGO: Sample profile pass
-
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'


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


r291871 - Update C++ status pages for Clang 4 branch:

2017-01-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 12 18:57:54 2017
New Revision: 291871

URL: http://llvm.org/viewvc/llvm-project?rev=291871=rev
Log:
Update C++ status pages for Clang 4 branch:

 * Update version number in DR tests from 4.0 to 4
 * Teach make_cxx_dr_status script about version numbers that don't contain a
   period.
 * Update cxx_status.html and cxx_dr_status.html to list Clang 4 features as
   "Clang 4" rather than "SVN"

Clang 4 features are still listed in yellow rather than green until release.

Modified:
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/drs/dr12xx.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/CXX/drs/dr14xx.cpp
cfe/trunk/test/CXX/drs/dr15xx.cpp
cfe/trunk/test/CXX/drs/dr16xx.cpp
cfe/trunk/test/CXX/drs/dr18xx.cpp
cfe/trunk/test/CXX/drs/dr2xx.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/cxx_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/test/CXX/drs/dr0xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr0xx.cpp?rev=291871=291870=291871=diff
==
--- cfe/trunk/test/CXX/drs/dr0xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr0xx.cpp Thu Jan 12 18:57:54 2017
@@ -1032,7 +1032,7 @@ namespace dr91 { // dr91: yes
   int k = f(U());
 }
 
-namespace dr92 { // dr92: 4.0 c++17
+namespace dr92 { // dr92: 4 c++17
   void f() throw(int, float); // expected-error 0-1{{ISO C++1z does not 
allow}} expected-note 0-1{{use 'noexcept}}
   void (*p)() throw(int) =  // expected-error 0-1{{ISO C++1z does not 
allow}} expected-note 0-1{{use 'noexcept}}
 #if __cplusplus <= 201402L

Modified: cfe/trunk/test/CXX/drs/dr12xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr12xx.cpp?rev=291871=291870=291871=diff
==
--- cfe/trunk/test/CXX/drs/dr12xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr12xx.cpp Thu Jan 12 18:57:54 2017
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
-namespace dr1213 { // dr1213: 4.0
+namespace dr1213 { // dr1213: 4
 #if __cplusplus >= 201103L
   using T = int[3];
   int & = T{}[1];
@@ -26,7 +26,7 @@ struct Derived : Base {
 };
 } // dr1250
 
-namespace dr1295 {  // dr1295: 4.0
+namespace dr1295 {  // dr1295: 4
   struct X {
 unsigned bitfield : 4;
   };

Modified: cfe/trunk/test/CXX/drs/dr13xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr13xx.cpp?rev=291871=291870=291871=diff
==
--- cfe/trunk/test/CXX/drs/dr13xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr13xx.cpp Thu Jan 12 18:57:54 2017
@@ -31,7 +31,7 @@ namespace dr1315 { // dr1315: partial
   // expected-error@-1 {{type of specialized non-type template argument 
depends on a template parameter of the partial specialization}}
 }
 
-namespace dr1330 { // dr1330: 4.0 c++11
+namespace dr1330 { // dr1330: 4 c++11
   // exception-specifications are parsed in a context where the class is 
complete.
   struct A {
 void f() throw(T) {} // expected-error 0-1{{C++1z}} expected-note 
0-1{{noexcept}}
@@ -175,7 +175,7 @@ namespace dr1359 { // dr1359: 3.5
 #endif
 }
 
-namespace dr1388 { // dr1388: 4.0
+namespace dr1388 { // dr1388: 4
   template void f(T..., A); // expected-note 
1+{{candidate}} expected-error 0-1{{C++11}}
   template void g(T..., int); // expected-note 1+{{candidate}} 
expected-error 0-1{{C++11}}
   template void h(T..., A); // expected-note 
1+{{candidate}} expected-error 0-1{{C++11}}

Modified: cfe/trunk/test/CXX/drs/dr14xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr14xx.cpp?rev=291871=291870=291871=diff
==
--- cfe/trunk/test/CXX/drs/dr14xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr14xx.cpp Thu Jan 12 18:57:54 2017
@@ -343,7 +343,7 @@ namespace dr1490 {  // dr1490: 3.7 c++11
   std::initializer_list{"abc"}; // expected-error {{expected 
unqualified-id}}}
 } // dr190
 
-namespace dr1495 { // dr1495: 4.0
+namespace dr1495 { // dr1495: 4
   // Deduction succeeds in both directions.
   template struct A {}; // expected-note {{template is 
declared here}}
   template struct A {}; // expected-error 
{{class template partial specialization is not more specialized}}

Modified: cfe/trunk/test/CXX/drs/dr15xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr15xx.cpp?rev=291871=291870=291871=diff
==
--- cfe/trunk/test/CXX/drs/dr15xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr15xx.cpp Thu Jan 12 18:57:54 2017
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 

r291870 - Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Jan 12 18:51:55 2017
New Revision: 291870

URL: http://llvm.org/viewvc/llvm-project?rev=291870=rev
Log:
Pass -fprofile-sample-use to lto backends.

Summary: LTO backend will not invoke SampleProfileLoader pass even if 
-fprofile-sample-use is specified. This patch passes the flag down so that pass 
manager can add the SampleProfileLoader pass correctly.

Reviewers: mehdi_amini, tejohnson

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28588

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291870=291869=291870=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 12 18:51:55 2017
@@ -862,7 +862,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
 }
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
-  std::unique_ptr OS) {
+  std::unique_ptr OS,
+  std::string SampleProfile) {
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -930,6 +931,7 @@ static void runThinLTOBackend(ModuleSumm
 return llvm::make_unique(std::move(OS));
   };
   lto::Config Conf;
+  Conf.SampleProfile = SampleProfile;
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -965,7 +967,8 @@ void clang::EmitBackendOutput(Diagnostic
 // of an error).
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
+CGOpts.SampleProfileFile);
   return;
 }
   }

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291870=291869=291870=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Thu Jan 12 18:51:55 2017
@@ -8,6 +8,10 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
 
+; Ensure sample profile pass are passed to backend
+; RUN: %clang_cc1 -emit-obj -O2 -o %t5.o -x ir %t1.o 
-fthinlto-index=%t.thinlto.bc -fprofile-sample-use=%S/Inputs/pgo-sample.prof 
-mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
+; CHECK-SAMPLEPGO: Sample profile pass
+
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'


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


[PATCH] D27090: Add LocationContext as a parameter to checkRegionChanges

2017-01-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291869: [analyzer] Add LocationContext as a parameter to 
checkRegionChanges (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D27090?vs=79204=84197#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27090

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
@@ -321,9 +321,11 @@
   const InvalidatedSymbols *invalidated,
   ArrayRef Explicits,
   ArrayRef Regions,
+  const LocationContext *LCtx,
   const CallEvent *Call) {
-return ((const CHECKER *)checker)->checkRegionChanges(state, invalidated,
-  Explicits, Regions, Call);
+return ((const CHECKER *) checker)->checkRegionChanges(state, invalidated,
+   Explicits, Regions,
+   LCtx, Call);
   }
 
 public:
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -229,11 +229,12 @@
 
   ProgramStateRef bindLoc(Loc location,
   SVal V,
+  const LocationContext *LCtx,
   bool notifyChanges = true) const;
 
-  ProgramStateRef bindLoc(SVal location, SVal V) const;
+  ProgramStateRef bindLoc(SVal location, SVal V, const LocationContext *LCtx) const;
 
-  ProgramStateRef bindDefault(SVal loc, SVal V) const;
+  ProgramStateRef bindDefault(SVal loc, SVal V, const LocationContext *LCtx) const;
 
   ProgramStateRef killBinding(Loc LV) const;
 
@@ -681,9 +682,9 @@
   this, Val.castAs(), From, To);
 }
 
-inline ProgramStateRef ProgramState::bindLoc(SVal LV, SVal V) const {
+inline ProgramStateRef ProgramState::bindLoc(SVal LV, SVal V, const LocationContext *LCtx) const {
   if (Optional L = LV.getAs())
-return bindLoc(*L, V);
+return bindLoc(*L, V, LCtx);
   return this;
 }
 
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -293,6 +293,7 @@
const InvalidatedSymbols *invalidated,
ArrayRef ExplicitRegions,
ArrayRef Regions,
+   const LocationContext *LCtx,
const CallEvent *Call) override;
 
   /// printState - Called by ProgramStateManager to print checker-specific data.
@@ -522,7 +523,9 @@
 
   /// Call PointerEscape callback when a value escapes as a result of bind.
   ProgramStateRef processPointerEscapedOnBind(ProgramStateRef State,
-  SVal Loc, SVal Val) override;
+  SVal Loc,
+  SVal Val,
+  const LocationContext *LCtx) override;
   /// Call PointerEscape callback when a value escapes as a result of
   /// region invalidation.
   /// \param[in] ITraits Specifies invalidation traits for regions/symbols.
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
+++ 

r291867 - [analyzer] Support inlining of '[self classMethod]' and '[[self class] classMethod]'

2017-01-12 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Jan 12 18:50:47 2017
New Revision: 291867

URL: http://llvm.org/viewvc/llvm-project?rev=291867=rev
Log:
[analyzer] Support inlining of '[self classMethod]' and '[[self class] 
classMethod]'

Differential Revision: https://reviews.llvm.org/D28495

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=291867=291866=291867=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Thu Jan 12 18:50:47 2017
@@ -896,6 +896,38 @@ bool ObjCMethodCall::canBeOverridenInSub
   llvm_unreachable("The while loop should always terminate.");
 }
 
+static const ObjCMethodDecl *findDefiningRedecl(const ObjCMethodDecl *MD) {
+  if (!MD)
+return MD;
+
+  // Find the redeclaration that defines the method.
+  if (!MD->hasBody()) {
+for (auto I : MD->redecls())
+  if (I->hasBody())
+MD = cast(I);
+  }
+  return MD;
+}
+
+static bool isCallToSelfClass(const ObjCMessageExpr *ME) {
+  const Expr* InstRec = ME->getInstanceReceiver();
+  if (!InstRec)
+return false;
+  const auto *InstRecIg = 
dyn_cast(InstRec->IgnoreParenImpCasts());
+
+  // Check that receiver is called 'self'.
+  if (!InstRecIg || !InstRecIg->getFoundDecl() ||
+  !InstRecIg->getFoundDecl()->getName().equals("self"))
+return false;
+
+  // Check that the method name is 'class'.
+  if (ME->getSelector().getNumArgs() != 0 ||
+  !ME->getSelector().getNameForSlot(0).equals("class"))
+return false;
+
+  return true;
+}
+
 RuntimeDefinition ObjCMethodCall::getRuntimeDefinition() const {
   const ObjCMessageExpr *E = getOriginExpr();
   assert(E);
@@ -910,6 +942,7 @@ RuntimeDefinition ObjCMethodCall::getRun
 const MemRegion *Receiver = nullptr;
 
 if (!SupersType.isNull()) {
+  // The receiver is guaranteed to be 'super' in this case.
   // Super always means the type of immediate predecessor to the method
   // where the call occurs.
   ReceiverT = cast(SupersType);
@@ -921,7 +954,7 @@ RuntimeDefinition ObjCMethodCall::getRun
   DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
-  ReceiverT = dyn_cast(DynType);
+  ReceiverT = dyn_cast(DynType.getCanonicalType());
 
   if (ReceiverT && CanBeSubClassed)
 if (ObjCInterfaceDecl *IDecl = ReceiverT->getInterfaceDecl())
@@ -929,7 +962,32 @@ RuntimeDefinition ObjCMethodCall::getRun
 CanBeSubClassed = false;
 }
 
-// Lookup the method implementation.
+// Handle special cases of '[self classMethod]' and
+// '[[self class] classMethod]', which are treated by the compiler as
+// instance (not class) messages. We will statically dispatch to those.
+if (auto *PT = dyn_cast_or_null(ReceiverT)) {
+  // For [self classMethod], return the compiler visible declaration.
+  if (PT->getObjectType()->isObjCClass() &&
+  Receiver == getSelfSVal().getAsRegion())
+return RuntimeDefinition(findDefiningRedecl(E->getMethodDecl()));
+
+  // Similarly, handle [[self class] classMethod].
+  // TODO: We are currently doing a syntactic match for this pattern with 
is
+  // limiting as the test cases in 
Analysis/inlining/InlineObjCClassMethod.m
+  // shows. A better way would be to associate the meta type with the 
symbol
+  // using the dynamic type info tracking and use it here. We can add a new
+  // SVal for ObjC 'Class' values that know what interface declaration they
+  // come from. Then 'self' in a class method would be filled in with
+  // something meaningful in ObjCMethodCall::getReceiverSVal() and we could
+  // do proper dynamic dispatch for class methods just like we do for
+  // instance methods now.
+  if (E->getInstanceReceiver())
+if (const auto *M = 
dyn_cast(E->getInstanceReceiver()))
+  if (isCallToSelfClass(M))
+return RuntimeDefinition(findDefiningRedecl(E->getMethodDecl()));
+}
+
+// Lookup the instance method implementation.
 if (ReceiverT)
   if (ObjCInterfaceDecl *IDecl = ReceiverT->getInterfaceDecl()) {
 // Repeatedly calling lookupPrivateMethod() is expensive, especially

Modified: cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m?rev=291867=291866=291867=diff
==
--- cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m (original)
+++ cfe/trunk/test/Analysis/inlining/InlineObjCClassMethod.m Thu Jan 12 
18:50:47 2017
@@ -1,6 

[PATCH] D28387: [tsan] Do not report errors in __destroy_helper_block_

2017-01-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291868: [tsan] Do not report errors in 
__destroy_helper_block_ (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D28387?vs=83328=84196#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28387

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m


Index: cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
===
--- cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
+++ cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+
+// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
 
 __attribute__((objc_root_class))
 @interface NSObject
@@ -26,9 +28,14 @@
 }
 @end
 
-// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
-
 // TSAN: initialize{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: dealloc{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: cxx_destruct{{.*}}) [[ATTR:#[0-9]+]]
+
+void test2(id x) {
+  extern void test2_helper(id (^)(void));
+  test2_helper(^{ return x; });
+// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+}
+
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} 
"sanitize_thread_no_checking_at_run_time" {{.*}} }
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -708,6 +708,11 @@
   return false;
 }
 
+static void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn) {
+  Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
+  Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -751,16 +756,19 @@
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
-  // .cxx_destruct and all of their calees at run time.
+  // .cxx_destruct, __destroy_helper_block_ and all of their calees at run 
time.
   if (SanOpts.has(SanitizerKind::Thread)) {
 if (const auto *OMD = dyn_cast_or_null(D)) {
   IdentifierInfo *II = OMD->getSelector().getIdentifierInfoForSlot(0);
   if (OMD->getMethodFamily() == OMF_dealloc ||
   OMD->getMethodFamily() == OMF_initialize ||
   (OMD->getSelector().isUnarySelector() && 
II->isStr(".cxx_destruct"))) {
-Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
-Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+markAsIgnoreThreadCheckingAtRuntime(Fn);
   }
+} else if (const auto *FD = dyn_cast_or_null(D)) {
+  IdentifierInfo *II = FD->getIdentifier();
+  if (II && II->isStr("__destroy_helper_block_"))
+markAsIgnoreThreadCheckingAtRuntime(Fn);
 }
   }
 


Index: cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
===
--- cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
+++ cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+
+// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
 
 __attribute__((objc_root_class))
 @interface NSObject
@@ -26,9 +28,14 @@
 }
 @end
 
-// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
-
 // TSAN: initialize{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: dealloc{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: cxx_destruct{{.*}}) [[ATTR:#[0-9]+]]
+
+void test2(id x) {
+  extern void test2_helper(id (^)(void));
+  test2_helper(^{ return x; });
+// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+}
+
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} 

r291869 - [analyzer] Add LocationContext as a parameter to checkRegionChanges

2017-01-12 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Jan 12 18:50:57 2017
New Revision: 291869

URL: http://llvm.org/viewvc/llvm-project?rev=291869=rev
Log:
[analyzer] Add LocationContext as a parameter to checkRegionChanges

This patch adds LocationContext to checkRegionChanges and removes
wantsRegionChangeUpdate as it was unused.

A patch by Krzysztof Wiśniewski!

Differential Revision: https://reviews.llvm.org/D27090

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h?rev=291869=291868=291869=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h Thu Jan 12 18:50:57 
2017
@@ -321,9 +321,11 @@ class RegionChanges {
   const InvalidatedSymbols *invalidated,
   ArrayRef Explicits,
   ArrayRef Regions,
+  const LocationContext *LCtx,
   const CallEvent *Call) {
-return ((const CHECKER *)checker)->checkRegionChanges(state, invalidated,
-  Explicits, Regions, 
Call);
+return ((const CHECKER *) checker)->checkRegionChanges(state, invalidated,
+   Explicits, Regions,
+   LCtx, Call);
   }
 
 public:

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=291869=291868=291869=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Thu Jan 12 
18:50:57 2017
@@ -338,6 +338,7 @@ public:
   const InvalidatedSymbols *invalidated,
   ArrayRef ExplicitRegions,
   ArrayRef Regions,
+  const LocationContext *LCtx,
   const CallEvent *Call);
 
   /// \brief Run checkers when pointers escape.
@@ -443,10 +444,11 @@ public:
   typedef CheckerFn 
CheckLiveSymbolsFunc;
   
   typedef CheckerFn ExplicitRegions,
-ArrayRef Regions,
-const CallEvent *Call)>
+ const InvalidatedSymbols *symbols,
+ ArrayRef 
ExplicitRegions,
+ ArrayRef Regions,
+ const LocationContext *LCtx,
+ const CallEvent *Call)>
   CheckRegionChangesFunc;
   
   typedef CheckerFnhttp://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=291869=291868=291869=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Thu 
Jan 12 18:50:57 2017
@@ -293,6 +293,7 @@ public:
const InvalidatedSymbols *invalidated,
ArrayRef ExplicitRegions,
ArrayRef Regions,
+   const LocationContext *LCtx,
const CallEvent *Call) override;
 
   /// printState - Called by ProgramStateManager to print checker-specific 
data.
@@ -522,7 +523,9 @@ protected:
 
   /// Call PointerEscape callback when a value escapes as a result of bind.
   ProgramStateRef processPointerEscapedOnBind(ProgramStateRef State,
-  SVal Loc, SVal Val) override;
+   

r291866 - [analyzer] Fix false positives in Keychain API checker

2017-01-12 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Jan 12 18:50:41 2017
New Revision: 291866

URL: http://llvm.org/viewvc/llvm-project?rev=291866=rev
Log:
[analyzer] Fix false positives in Keychain API checker

The checker has several false positives that this patch addresses:
- Do not check if the return status has been compared to error (or no error) at 
the time when leaks are reported since the status symbol might no longer be 
alive. Instead, pattern match on the assume and stop tracking allocated symbols 
on error paths.
- The checker used to report error when an unknown symbol was freed. This could 
lead to false positives, let's not repot those. This leads to loss of coverage 
in double frees.
- Do not enforce that we should only call free if we are sure that error was 
not returned and the pointer is not null. That warning is too noisy and we 
received several false positive reports about it. (I removed: "Only call free 
if a valid (non-NULL) buffer was returned")
- Use !isDead instead of isLive in leak reporting. Otherwise, we report leaks 
for objects we loose track of. This change triggered change #1.

This also adds checker specific dump to the state.

Differential Revision: https://reviews.llvm.org/D28330

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
cfe/trunk/test/Analysis/keychainAPI.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=291866=291865=291866=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Thu Jan 
12 18:50:41 2017
@@ -28,7 +28,8 @@ using namespace ento;
 namespace {
 class MacOSKeychainAPIChecker : public Checker {
+   check::DeadSymbols,
+   eval::Assume> {
   mutable std::unique_ptr BT;
 
 public:
@@ -57,6 +58,10 @@ public:
   void checkPreStmt(const CallExpr *S, CheckerContext ) const;
   void checkPostStmt(const CallExpr *S, CheckerContext ) const;
   void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
+  ProgramStateRef evalAssume(ProgramStateRef state, SVal Cond,
+ bool Assumption) const;
+  void printState(raw_ostream , ProgramStateRef State,
+  const char *NL, const char *Sep) const;
 
 private:
   typedef std::pair AllocationPair;
@@ -106,19 +111,6 @@ private:
   std::unique_ptr generateAllocatedDataNotReleasedReport(
   const AllocationPair , ExplodedNode *N, CheckerContext ) const;
 
-  /// Check if RetSym evaluates to an error value in the current state.
-  bool definitelyReturnedError(SymbolRef RetSym,
-   ProgramStateRef State,
-   SValBuilder ,
-   bool noError = false) const;
-
-  /// Check if RetSym evaluates to a NoErr value in the current state.
-  bool definitelyDidnotReturnError(SymbolRef RetSym,
-   ProgramStateRef State,
-   SValBuilder ) const {
-return definitelyReturnedError(RetSym, State, Builder, true);
-  }
-
   /// Mark an AllocationPair interesting for diagnostic reporting.
   void markInteresting(BugReport *R, const AllocationPair ) const {
 R->markInteresting(AP.first);
@@ -221,24 +213,6 @@ static SymbolRef getAsPointeeSymbol(cons
   return nullptr;
 }
 
-// When checking for error code, we need to consider the following cases:
-// 1) noErr / [0]
-// 2) someErr / [1, inf]
-// 3) unknown
-// If noError, returns true iff (1).
-// If !noError, returns true iff (2).
-bool MacOSKeychainAPIChecker::definitelyReturnedError(SymbolRef RetSym,
-  ProgramStateRef State,
-  SValBuilder ,
-  bool noError) const {
-  DefinedOrUnknownSVal NoErrVal = Builder.makeIntVal(NoErr,
-Builder.getSymbolManager().getType(RetSym));
-  DefinedOrUnknownSVal NoErr = Builder.evalEQ(State, NoErrVal,
- 
nonloc::SymbolVal(RetSym));
-  ProgramStateRef ErrState = State->assume(NoErr, noError);
-  return ErrState == State;
-}
-
 // Report deallocator mismatch. Remove the region from tracking - reporting a
 // missing free error after this one is redundant.
 void MacOSKeychainAPIChecker::
@@ -289,27 +263,25 @@ void MacOSKeychainAPIChecker::checkPreSt
 const Expr *ArgExpr = CE->getArg(paramIdx);
 if (SymbolRef V = getAsPointeeSymbol(ArgExpr, C))
   if 

r291868 - [tsan] Do not report errors in __destroy_helper_block_

2017-01-12 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Jan 12 18:50:50 2017
New Revision: 291868

URL: http://llvm.org/viewvc/llvm-project?rev=291868=rev
Log:
[tsan] Do not report errors in __destroy_helper_block_

There is a synchronization point between the reference count of a block 
dropping to zero and it's destruction, which TSan does not observe. Do not 
report errors in the compiler-emitted block destroy method and everything 
called from it.

This is similar to https://reviews.llvm.org/D25857

Differential Revision: https://reviews.llvm.org/D28387

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=291868=291867=291868=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Jan 12 18:50:50 2017
@@ -708,6 +708,11 @@ static bool endsWithReturn(const Decl* F
   return false;
 }
 
+static void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn) {
+  Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
+  Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -751,16 +756,19 @@ void CodeGenFunction::StartFunction(Glob
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
-  // .cxx_destruct and all of their calees at run time.
+  // .cxx_destruct, __destroy_helper_block_ and all of their calees at run 
time.
   if (SanOpts.has(SanitizerKind::Thread)) {
 if (const auto *OMD = dyn_cast_or_null(D)) {
   IdentifierInfo *II = OMD->getSelector().getIdentifierInfoForSlot(0);
   if (OMD->getMethodFamily() == OMF_dealloc ||
   OMD->getMethodFamily() == OMF_initialize ||
   (OMD->getSelector().isUnarySelector() && 
II->isStr(".cxx_destruct"))) {
-Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
-Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+markAsIgnoreThreadCheckingAtRuntime(Fn);
   }
+} else if (const auto *FD = dyn_cast_or_null(D)) {
+  IdentifierInfo *II = FD->getIdentifier();
+  if (II && II->isStr("__destroy_helper_block_"))
+markAsIgnoreThreadCheckingAtRuntime(Fn);
 }
   }
 

Modified: cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m?rev=291868=291867=291868=diff
==
--- cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m (original)
+++ cfe/trunk/test/CodeGen/sanitize-thread-no-checking-at-run-time.m Thu Jan 12 
18:50:50 2017
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+
+// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
 
 __attribute__((objc_root_class))
 @interface NSObject
@@ -26,9 +28,14 @@ public:
 }
 @end
 
-// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
-
 // TSAN: initialize{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: dealloc{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: cxx_destruct{{.*}}) [[ATTR:#[0-9]+]]
+
+void test2(id x) {
+  extern void test2_helper(id (^)(void));
+  test2_helper(^{ return x; });
+// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+}
+
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} 
"sanitize_thread_no_checking_at_run_time" {{.*}} }


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


[PATCH] D28330: [analyzer] Fix false positives in Keychain API checker

2017-01-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291866: [analyzer] Fix false positives in Keychain API 
checker (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D28330?vs=83160=84194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28330

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  cfe/trunk/test/Analysis/keychainAPI.m

Index: cfe/trunk/test/Analysis/keychainAPI.m
===
--- cfe/trunk/test/Analysis/keychainAPI.m
+++ cfe/trunk/test/Analysis/keychainAPI.m
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI -fblocks %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
 
 // Fake typedefs.
 typedef unsigned int OSStatus;
 typedef unsigned int SecKeychainAttributeList;
 typedef unsigned int SecKeychainItemRef;
 typedef unsigned int SecItemClass;
 typedef unsigned int UInt32;
-typedef unsigned int CFTypeRef;
-typedef unsigned int UInt16;
 typedef unsigned int SecProtocolType;
 typedef unsigned int SecAuthenticationType;
 typedef unsigned int SecKeychainAttributeInfo;
@@ -77,7 +77,7 @@
   void *outData;
   st = SecKeychainItemCopyContent(2, ptr, ptr, , );
   if (st == GenericError)
-SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Only call free if a valid (non-NULL) buffer was returned}}
+SecKeychainItemFreeContent(ptr, outData);
 } // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'}}
 
 // If null is passed in, the data is not allocated, so no need for the matching free.
@@ -101,14 +101,6 @@
   SecKeychainItemFreeContent(ptr, outData);
 }
 
-void fooOnlyFree() {
-  unsigned int *ptr = 0;
-  OSStatus st = 0;
-  UInt32 length;
-  void *outData = 
-  SecKeychainItemFreeContent(ptr, outData);// expected-warning{{Trying to free data which has not been allocated}}
-}
-
 // Do not warn if undefined value is passed to a function.
 void fooOnlyFreeUndef() {
   unsigned int *ptr = 0;
@@ -220,11 +212,27 @@
 if (st == noErr)
   SecKeychainItemFreeContent(ptr, outData[3]);
   }
-  if (length) { // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'}}
+  if (length) { // TODO: We do not report a warning here since the symbol is no longer live, but it's not marked as dead.
 length++;
   }
   return 0;
-}// no-warning
+}
+
+int testErrorCodeAsLHS(CFTypeRef keychainOrArray, SecProtocolType protocol,
+SecAuthenticationType authenticationType, SecKeychainItemRef *itemRef) {
+  unsigned int *ptr = 0;
+  OSStatus st = 0;
+  UInt32 length;
+  void *outData;
+  st = SecKeychainFindInternetPassword(keychainOrArray,
+   16, "server", 16, "domain", 16, "account",
+   16, "path", 222, protocol, authenticationType,
+   , , itemRef);
+  if (noErr == st)
+SecKeychainItemFreeContent(ptr, outData);
+
+  return 0;
+}
 
 void free(void *ptr);
 void deallocateWithFree() {
@@ -251,7 +259,6 @@
 extern const CFAllocatorRef kCFAllocatorNull;
 extern const CFAllocatorRef kCFAllocatorUseContext;
 CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator);
-extern void CFRelease(CFStringRef cf);
 
 void DellocWithCFStringCreate1(CFAllocatorRef alloc) {
   unsigned int *ptr = 0;
@@ -333,11 +340,11 @@
 SecKeychainItemFreeContent(0, pwdBytes);
 }
 
-void radar10508828_2() {
+void radar10508828_20092614() {
   UInt32 pwdLen = 0;
   void*  pwdBytes = 0;
   OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", , , 0);
-  SecKeychainItemFreeContent(0, pwdBytes); // expected-warning {{Only call free if a valid (non-NULL) buffer was returned}}
+  SecKeychainItemFreeContent(0, pwdBytes);
 }
 
 //Example from bug 10797.
@@ -426,3 +433,24 @@
   SecKeychainItemFreeContent(attrList, outData);
 }
 
+typedef struct AuthorizationValue {
+int length;
+void *data;
+} AuthorizationValue;
+typedef struct AuthorizationCallback {
+OSStatus (*SetContextVal)(AuthorizationValue *inValue);
+} AuthorizationCallback;
+static AuthorizationCallback cb;
+int radar_19196494() {
+  @autoreleasepool {
+AuthorizationValue login_password = {};
+UInt32 passwordLength;
+void *passwordData = 0;
+OSStatus err = SecKeychainFindGenericPassword(0, 0, "", 0, "", (UInt32 *)_password.length, (void**)_password.data, 0);
+cb.SetContextVal(_password);
+if (err == noErr) {
+  SecKeychainItemFreeContent(0, login_password.data);
+}
+  }
+  return 0;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp

[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 84193.
danielcdh added a comment.

Updates the unittests to clang_cc1 to see if it fixes the buildbot failure.


https://reviews.llvm.org/D28588

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto_backend.ll


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -8,6 +8,10 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
 
+; Ensure sample profile pass are passed to backend
+; RUN: %clang_cc1 -emit-obj -O2 -o %t5.o -x ir %t1.o 
-fthinlto-index=%t.thinlto.bc -fprofile-sample-use=%S/Inputs/pgo-sample.prof 
-mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
+; CHECK-SAMPLEPGO: Sample profile pass
+
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -862,7 +862,8 @@
 }
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
-  std::unique_ptr OS) {
+  std::unique_ptr OS,
+  std::string SampleProfile) {
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -930,6 +931,7 @@
 return llvm::make_unique(std::move(OS));
   };
   lto::Config Conf;
+  Conf.SampleProfile = SampleProfile;
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -965,7 +967,8 @@
 // of an error).
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
+CGOpts.SampleProfileFile);
   return;
 }
   }


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -8,6 +8,10 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed with '-x ir'
 
+; Ensure sample profile pass are passed to backend
+; RUN: %clang_cc1 -emit-obj -O2 -o %t5.o -x ir %t1.o -fthinlto-index=%t.thinlto.bc -fprofile-sample-use=%S/Inputs/pgo-sample.prof -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
+; CHECK-SAMPLEPGO: Sample profile pass
+
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -862,7 +862,8 @@
 }
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
-  std::unique_ptr OS) {
+  std::unique_ptr OS,
+  std::string SampleProfile) {
   StringMap>
   ModuleToDefinedGVSummaries;
   CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -930,6 +931,7 @@
 return llvm::make_unique(std::move(OS));
   };
   lto::Config Conf;
+  Conf.SampleProfile = SampleProfile;
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -965,7 +967,8 @@
 // of an error).
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
+CGOpts.SampleProfileFile);
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-01-12 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

I think it's more valuable to report a warning here even if the error message 
is not very precise. Marking something as in bounds when we know it's not does 
not feel right and could lead to inconsistent states down the road.


Repository:
  rL LLVM

https://reviews.llvm.org/D28278



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


r291865 - Improve handling of instantiated thread_local variables in Itanium C++ ABI.

2017-01-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan 12 18:43:31 2017
New Revision: 291865

URL: http://llvm.org/viewvc/llvm-project?rev=291865=rev
Log:
Improve handling of instantiated thread_local variables in Itanium C++ ABI.

 * Do not initialize these variables when initializing the rest of the
   thread_locals in the TU; they have unordered initialization so they can be
   initialized by themselves.

   This fixes a rejects-valid bug: we would make the per-variable initializer
   function internal, but put it in a comdat keyed off the variable, resulting
   in link errors when the comdat is selected from a different TU (as the per
   TU TLS init function tries to call an init function that does not exist).

 * On Darwin, when we decide that we're not going to emit a thread wrapper
   function at all, demote its linkage to External. Fixes a verifier failure
   on explicit instantiation of a thread_local variable on Darwin.

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
cfe/trunk/test/OpenMP/threadprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=291865=291864=291865=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Jan 12 18:43:31 2017
@@ -353,9 +353,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
 
   if (D->getTLSKind()) {
 // FIXME: Should we support init_priority for thread_local?
-// FIXME: Ideally, initialization of instantiated thread_local static data
-// members of class templates should not trigger initialization of other
-// entities in the TU.
 // FIXME: We only need to register one __cxa_thread_atexit function for the
 // entire TU.
 CXXThreadLocalInits.push_back(Fn);

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=291865=291864=291865=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jan 12 18:43:31 2017
@@ -2272,7 +2272,21 @@ void ItaniumCXXABI::EmitThreadLocalInitF
 ArrayRef CXXThreadLocalInits,
 ArrayRef CXXThreadLocalInitVars) {
   llvm::Function *InitFunc = nullptr;
-  if (!CXXThreadLocalInits.empty()) {
+
+  // Separate initializers into those with ordered (or partially-ordered)
+  // initialization and those with unordered initialization.
+  llvm::SmallVector OrderedInits;
+  llvm::SmallDenseMap UnorderedInits;
+  for (unsigned I = 0; I != CXXThreadLocalInits.size(); ++I) {
+if (isTemplateInstantiation(
+CXXThreadLocalInitVars[I]->getTemplateSpecializationKind()))
+  UnorderedInits[CXXThreadLocalInitVars[I]->getCanonicalDecl()] =
+  CXXThreadLocalInits[I];
+else
+  OrderedInits.push_back(CXXThreadLocalInits[I]);
+  }
+
+  if (!OrderedInits.empty()) {
 // Generate a guarded initialization function.
 llvm::FunctionType *FTy =
 llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
@@ -2289,24 +2303,28 @@ void ItaniumCXXABI::EmitThreadLocalInitF
 CharUnits GuardAlign = CharUnits::One();
 Guard->setAlignment(GuardAlign.getQuantity());
 
-CodeGenFunction(CGM)
-.GenerateCXXGlobalInitFunc(InitFunc, CXXThreadLocalInits,
-   Address(Guard, GuardAlign));
+CodeGenFunction(CGM).GenerateCXXGlobalInitFunc(InitFunc, OrderedInits,
+   Address(Guard, GuardAlign));
 // On Darwin platforms, use CXX_FAST_TLS calling convention.
 if (CGM.getTarget().getTriple().isOSDarwin()) {
   InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
   InitFunc->addFnAttr(llvm::Attribute::NoUnwind);
 }
   }
+
+  // Emit thread wrappers.
   for (const VarDecl *VD : CXXThreadLocals) {
 llvm::GlobalVariable *Var =
 cast(CGM.GetGlobalValue(CGM.getMangledName(VD)));
+llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
 
 // Some targets require that all access to thread local variables go 
through
 // the thread wrapper.  This means that we cannot attempt to create a 
thread
 // wrapper or a thread helper.
-if (isThreadWrapperReplaceable(VD, CGM) && !VD->hasDefinition())
+if (isThreadWrapperReplaceable(VD, CGM) && !VD->hasDefinition()) {
+  Wrapper->setLinkage(llvm::Function::ExternalLinkage);
   continue;
+}
 
 // Mangle the name for the thread_local initialization function.
 SmallString<256> InitFnName;
@@ -2322,18 +2340,21 @@ void ItaniumCXXABI::EmitThreadLocalInitF
 bool InitIsInitFunc = false;
 if (VD->hasDefinition()) {
   InitIsInitFunc = true;
-  if (InitFunc)
+  llvm::Function 

[PATCH] D28590: [Sema] Restrict explicit instantation definition dllexport

2017-01-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks for the fix!


https://reviews.llvm.org/D28590



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


[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-12 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:810
+if (CE->getNumArgs() == 2)
+  State = ProcessZeroAllocation(C, CE, 1, State);
   } else if (CE->getNumArgs() == 3) {

Why did you remove the old behavior here and below? 

I would expect this patch to be strictly additive. If gmalloc APIs take a 
different number of arguments, please, process them separately. You might need 
to factor out the processing code to avoid code duplication.




Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:838
   State = ProcessZeroAllocation(C, CE, 1, State);
+  if (CE->getNumArgs() > 2)
+State = ProcessZeroAllocation(C, CE, 2, State);

Should this be conditional on the number of arguments instead of adding two 
calls to ProcessZeroAllocation?



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:846
   State = ProcessZeroAllocation(C, CE, 0, State);
-  State = ProcessZeroAllocation(C, CE, 1, State);
-} else if (FunI == II_free) {
+} else if (FunI == II_free || FunI == II_g_free) {
   State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);

This change in how calloc is handled broke the Analysis/malloc.c test.


Repository:
  rL LLVM

https://reviews.llvm.org/D28348



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


Re: r290392 - Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.

2017-01-12 Thread Hans Wennborg via cfe-commits
On Thu, Jan 12, 2017 at 3:01 PM, Chandler Carruth  wrote:
>> This isn't quite right, it should either be left as-is or dropped
>> completely. This path was allowing people to spell "-mllvm
>> -disable-llvm-optzns" for legacy reasons, even though the correct
>> spelling is "-Xclang -disable-llvm-optzns". There's no need to add
>> legacy support for "-mllvm -disable-llvm-passes", since that never
>> worked.
>
>
> Yeah, I don't think this was even really intended.
>
> r291850+r291853 fix this to preserve -disable-llvm-optzns exactly as it was.
>
> I've alse followed up with Hans to make sure LLVM 4 gets this.

Merged in r291860.

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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D28588#644489, @danielcdh wrote:

> Thanks for the prompt response.
>
> But looks like several other tests also has "-mllvm -debug-pass=Structure" in 
> their tests:
>
> tools/clang/test/CodeGen/pgo-instrumentation.c
>  test/CodeGen/Generic/llc-start-stop.ll
>
> I just verified that if I cmake with -DCMAKE_BUILD_TYPE=Release, it still 
> passes locally.


Hmm, maybe that flavor of -debug output is enabled with NDEBUG then. I'm not 
really sure unfortunately.

I don't even see an error message for the second one, do you? Just an error 
code.

> Thanks,
> Dehao




https://reviews.llvm.org/D28588



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2017-01-12 Thread Mathieu Duponchelle via Phabricator via cfe-commits
MathieuDuponchelle added a comment.

In https://reviews.llvm.org/D26082#644402, @jbcoe wrote:

> @MathieuDuponchelle I've set up a docker image with Fedora 23 and reproduced 
> the errors as you reported.
>
> I've no immediate idea what the problem might be. Might be worth looking with 
> address-sanitizer.


Hey, good to know!

Two questions:

- Did you try running the test with valgrind on OSX?
- Doesn't the fact that commenting out this line: 
https://github.com/llvm-mirror/clang/blob/master/bindings/python/clang/cindex.py#L181
 "solve" the problem give you a good starting point?


Repository:
  rL LLVM

https://reviews.llvm.org/D26082



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


Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.

2017-01-12 Thread Bill Seurer via cfe-commits

On 01/10/2017 01:53 PM, Benjamin Kramer wrote:

I didn't manage to reproduce this. Does adding ${PTHREAD_LIB} to
LINK_LIBS of tools/clang/tools/extra/include-fixer/plugin/CMakeLists.txt
help?


That does seem to make it work.


On Tue, Jan 10, 2017 at 8:31 PM, Bill Seurer  wrote:

On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote:


Author: d0k
Date: Mon Jan  9 09:18:28 2017
New Revision: 291446

URL: http://llvm.org/viewvc/llvm-project?rev=291446=rev
Log:
[include-fixer] Load symbol index asynchronously.

We don't actually need the index until parse time, so fetch it in the
background and start parsing. By the time it is actually needed it's
likely that the loading phase has completed in the background.



This update causes a linker error on ppc64le on a Release+Asserts+Shared
build.

cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
-DBUILD_SHARED_LIBS=ON

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754


Details:

[117/123] Linking CXX shared library
lib/libclangIncludeFixerPlugin.so.40.0svn
FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++  -fPIC -fPIC
-fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common
-Woverloaded-virtual -fno-strict-aliasing -O3
-L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs
-Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib  -Wl,-O3
-Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o
lib/libclangIncludeFixerPlugin.so.40.0svn
tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn
lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn
lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn
lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn
-Wl,-rpath,"\$ORIGIN/../lib" && :
tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0):
undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
[117/123] Building CXX object
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o
ninja: build stopped: subcommand failed.
[1/7] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn
FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++  -fPIC -fPIC
-fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common
-Woverloaded-virtual -fno-strict-aliasing -O3
-L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs
-Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib  -Wl,-O3
-Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o
lib/libclangIncludeFixerPlugin.so.40.0svn
tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn
lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn
lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn
lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn
-Wl,-rpath,"\$ORIGIN/../lib" && :
tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0):
undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status






Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL:
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446=291445=291446=diff

==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
(original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan
9 09:18:28 2017
@@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR
   do {
 std::vector Symbols;
 for (const auto  : SymbolIndices) {
-  auto Res = DB->search(Names.back().str());
+  auto Res = DB.get()->search(Names.back());
   Symbols.insert(Symbols.end(), Res.begin(), Res.end());
 }


Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
URL:

r291853 - Fix two test cases I missed updating in r291850. Sorry for the noise.

2017-01-12 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Jan 12 16:48:28 2017
New Revision: 291853

URL: http://llvm.org/viewvc/llvm-project?rev=291853=rev
Log:
Fix two test cases I missed updating in r291850. Sorry for the noise.

Modified:
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/Profile/gcc-flag-compatibility.c

Modified: cfe/trunk/test/CodeGen/always_inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/always_inline.c?rev=291853=291852=291853=diff
==
--- cfe/trunk/test/CodeGen/always_inline.c (original)
+++ cfe/trunk/test/CodeGen/always_inline.c Thu Jan 12 16:48:28 2017
@@ -1,7 +1,7 @@
 // RUN: %clang -emit-llvm -S -o %t %s
 // RUN: not grep '@f0' %t
 // RUN: not grep 'call ' %t
-// RUN: %clang -mllvm -disable-llvm-passes -emit-llvm -S -o %t %s
+// RUN: %clang -Xclang -disable-llvm-passes -emit-llvm -S -o %t %s
 // RUN: grep '@f0' %t | count 2
 
 //static int f0() { 

Modified: cfe/trunk/test/Profile/gcc-flag-compatibility.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/gcc-flag-compatibility.c?rev=291853=291852=291853=diff
==
--- cfe/trunk/test/Profile/gcc-flag-compatibility.c (original)
+++ cfe/trunk/test/Profile/gcc-flag-compatibility.c Thu Jan 12 16:48:28 2017
@@ -18,14 +18,14 @@
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/default.profdata
-// RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s
 // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2}
 
 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir/some/path
 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/file.prof
-// RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof | FileCheck 
-check-prefix=PROFILE-USE-3 %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof | FileCheck 
-check-prefix=PROFILE-USE-3 %s
 // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2}
 
 int X = 0;


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


r291851 - Replace some stray uses of the old spelling of the flag with the new

2017-01-12 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Jan 12 16:43:37 2017
New Revision: 291851

URL: http://llvm.org/viewvc/llvm-project?rev=291851=rev
Log:
Replace some stray uses of the old spelling of the flag with the new
spelling. NFC.

Modified:
cfe/trunk/test/CodeGen/ms-declspecs.c
cfe/trunk/test/CodeGenCXX/optnone-class-members.cpp
cfe/trunk/test/CodeGenCXX/optnone-def-decl.cpp

Modified: cfe/trunk/test/CodeGen/ms-declspecs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-declspecs.c?rev=291851=291850=291851=diff
==
--- cfe/trunk/test/CodeGen/ms-declspecs.c (original)
+++ cfe/trunk/test/CodeGen/ms-declspecs.c Thu Jan 12 16:43:37 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -O2 
-disable-llvm-optzns -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -O2 
-disable-llvm-passes -o - | FileCheck %s
 
 __declspec(selectany) int x1 = 1;
 const __declspec(selectany) int x2 = 2;

Modified: cfe/trunk/test/CodeGenCXX/optnone-class-members.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/optnone-class-members.cpp?rev=291851=291850=291851=diff
==
--- cfe/trunk/test/CodeGenCXX/optnone-class-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/optnone-class-members.cpp Thu Jan 12 16:43:37 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 < %s -triple %itanium_abi_triple -fms-extensions -O2 
-disable-llvm-optzns -emit-llvm -x c++ | FileCheck %s
+// RUN: %clang_cc1 < %s -triple %itanium_abi_triple -fms-extensions -O2 
-disable-llvm-passes -emit-llvm -x c++ | FileCheck %s
 
 // Test attribute 'optnone' on methods:
 //  -- member functions;

Modified: cfe/trunk/test/CodeGenCXX/optnone-def-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/optnone-def-decl.cpp?rev=291851=291850=291851=diff
==
--- cfe/trunk/test/CodeGenCXX/optnone-def-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/optnone-def-decl.cpp Thu Jan 12 16:43:37 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fms-extensions -O2 
-disable-llvm-optzns -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -fms-extensions -O2 
-disable-llvm-passes -emit-llvm -o - | FileCheck %s
 
 // Test optnone on both function declarations and function definitions.
 // Verify also that we don't generate invalid IR functions with


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


r291850 - Address review comments on r290392:

2017-01-12 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Jan 12 16:40:13 2017
New Revision: 291850

URL: http://llvm.org/viewvc/llvm-project?rev=291850=rev
Log:
Address review comments on r290392:
- Don't break using '-mllvm -disable-llvm-optzns' (yet).
- Don't add support for '-mllvm -disable-llvm-passes'.

This is important for LLVM 4 as we haven't yet really told folks this is
coming. I'll add release notes about this.

I've also added some explicit testing of this so its more obvious what
is happening here.

Added:
cfe/trunk/test/Driver/disable-llvm.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=291850=291849=291850=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jan 12 16:40:13 2017
@@ -6431,11 +6431,13 @@ void Clang::ConstructJob(Compilation ,
 A->claim();
 
 // We translate this by hand to the -cc1 argument, since nightly test uses
-// it and developers have been trained to spell it with -mllvm.
-if (StringRef(A->getValue(0)) == "-disable-llvm-passes") {
-  CmdArgs.push_back("-disable-llvm-passes");
-} else
+// it and developers have been trained to spell it with -mllvm. Both
+// spellings are now deprecated and should be removed.
+if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") {
+  CmdArgs.push_back("-disable-llvm-optzns");
+} else {
   A->render(Args, CmdArgs);
+}
   }
 
   // With -save-temps, we want to save the unoptimized bitcode output from the

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=291850=291849=291850=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Thu Jan 12 16:40:13 2017
@@ -535,7 +535,7 @@
 // RUN: -fno-ms-compatibility \
 // RUN: -fms-extensions \
 // RUN: -fno-ms-extensions \
-// RUN: -mllvm -disable-llvm-passes \
+// RUN: -Xclang -disable-llvm-passes \
 // RUN: -resource-dir asdf \
 // RUN: -resource-dir=asdf \
 // RUN: -Wunused-variable \

Added: cfe/trunk/test/Driver/disable-llvm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/disable-llvm.c?rev=291850=auto
==
--- cfe/trunk/test/Driver/disable-llvm.c (added)
+++ cfe/trunk/test/Driver/disable-llvm.c Thu Jan 12 16:40:13 2017
@@ -0,0 +1,22 @@
+// We support a CC1 option for disabling LLVM's passes.
+// RUN: %clang -O2 -Xclang -disable-llvm-passes -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DISABLED %s
+// DISABLED: -cc1
+// DISABLED-NOT: -mllvm
+// DISABLED: -disable-llvm-passes
+//
+// We also support two alternative spellings for historical reasons.
+// RUN: %clang -O2 -Xclang -disable-llvm-optzns -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s
+// RUN: %clang -O2 -mllvm -disable-llvm-optzns -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s
+// DISABLED-LEGACY: -cc1
+// DISABLED-LEGACY-NOT: -mllvm
+// DISABLED-LEGACY: -disable-llvm-optzns
+//
+// The main flag shouldn't be specially handled when used with '-mllvm'.
+// RUN: %clang -O2 -mllvm -disable-llvm-passes -### %s 2>&1 | FileCheck 
--check-prefix=MLLVM %s
+// MLLVM: -cc1
+// MLLVM-NOT: -disable-llvm-passes
+// MLLVM: "-mllvm" "-disable-llvm-passes"
+// MLLVM-NOT: -disable-llvm-passes


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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added a comment.

Thanks for the prompt response.

But looks like several other tests also has "-mllvm -debug-pass=Structure" in 
their tests:

tools/clang/test/CodeGen/pgo-instrumentation.c
test/CodeGen/Generic/llc-start-stop.ll

I just verified that if I cmake with -DCMAKE_BUILD_TYPE=Release, it still 
passes locally.

Thanks,
Dehao


https://reviews.llvm.org/D28588



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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D28588#644472, @tejohnson wrote:

> Otherwise I think "; REQUIRES: asserts" might do the trick?


Looks like it - I looked at another test that used -debug output and it 
requires asserts.


https://reviews.llvm.org/D28588



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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D28588#644467, @danielcdh wrote:

> The breaks some buildbots thus I reverted the patch:
>
> http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/1889
>  
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/32242/
>
> Unfortunately I could not reproduce the error locally.
>
> Any quick insights why this test change would break?


Looks like there was no output (at least on the buildbot that I looked at). 
Most likely because this is using debug output and perhaps those are build 
NDEBUG? I wonder if there is a better way to test this. Otherwise I think "; 
REQUIRES: asserts" might do the trick?

> Thanks,
> Dehao




https://reviews.llvm.org/D28588



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


[libcxx] r291845 - Drop 'svn' suffix from version.

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 16:13:09 2017
New Revision: 291845

URL: http://llvm.org/viewvc/llvm-project?rev=291845=rev
Log:
Drop 'svn' suffix from version.

Modified:
libcxx/branches/release_40/CMakeLists.txt

Modified: libcxx/branches/release_40/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/CMakeLists.txt?rev=291845=291844=291845=diff
==
--- libcxx/branches/release_40/CMakeLists.txt (original)
+++ libcxx/branches/release_40/CMakeLists.txt Thu Jan 12 16:13:09 2017
@@ -24,7 +24,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 4.0.0svn)
+  set(PACKAGE_VERSION 4.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libunwind] r291846 - Drop 'svn' suffix from version.

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 16:13:19 2017
New Revision: 291846

URL: http://llvm.org/viewvc/llvm-project?rev=291846=rev
Log:
Drop 'svn' suffix from version.

Modified:
libunwind/branches/release_40/CMakeLists.txt

Modified: libunwind/branches/release_40/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_40/CMakeLists.txt?rev=291846=291845=291846=diff
==
--- libunwind/branches/release_40/CMakeLists.txt (original)
+++ libunwind/branches/release_40/CMakeLists.txt Thu Jan 12 16:13:19 2017
@@ -71,7 +71,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 4.0.0svn)
+  set(PACKAGE_VERSION 4.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxxabi] r291844 - Drop 'svn' suffix from version.

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 16:12:54 2017
New Revision: 291844

URL: http://llvm.org/viewvc/llvm-project?rev=291844=rev
Log:
Drop 'svn' suffix from version.

Modified:
libcxxabi/branches/release_40/CMakeLists.txt

Modified: libcxxabi/branches/release_40/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_40/CMakeLists.txt?rev=291844=291843=291844=diff
==
--- libcxxabi/branches/release_40/CMakeLists.txt (original)
+++ libcxxabi/branches/release_40/CMakeLists.txt Thu Jan 12 16:12:54 2017
@@ -77,7 +77,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 4.0.0svn)
+  set(PACKAGE_VERSION 4.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[PATCH] D28588: Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh reopened this revision.
danielcdh added a comment.
This revision is now accepted and ready to land.

The breaks some buildbots thus I reverted the patch:

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/1889
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/32242/

Unfortunately I could not reproduce the error locally.

Any quick insights why this test change would break?

Thanks,
Dehao


https://reviews.llvm.org/D28588



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


[clang-tools-extra] r291838 - Clear the release notes for 5.0.0

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:58:40 2017
New Revision: 291838

URL: http://llvm.org/viewvc/llvm-project?rev=291838=rev
Log:
Clear the release notes for 5.0.0

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

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=291838=291837=291838=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Jan 12 15:58:40 2017
@@ -1,5 +1,5 @@
 ===
-Extra Clang Tools 4.0.0 (In-Progress) Release Notes
+Extra Clang Tools 5.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,15 +10,15 @@ Written by the `LLVM Team `_.
+   These are in-progress notes for the upcoming Extra Clang Tools 5 release.
+   You may prefer the `Extra Clang Tools 4 Release Notes
+   
`_.
 
 Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 4.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 5.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 4.0.0?
+What's New in Extra Clang Tools 5.0.0?
 ==
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -52,159 +52,17 @@ The improvements are...
 Improvements to clang-rename
 
 
-- Emacs integration was added.
+The improvements are...
 
 Improvements to clang-tidy
 --
 
-- New `cppcoreguidelines-slicing
-  
`_
 check
-
-  Flags slicing of member variables or vtable.
-
-- New `cppcoreguidelines-special-member-functions
-  
`_
 check
-
-  Flags classes where some, but not all, special member functions are 
user-defined.
-
-- The UseCERTSemantics option for the `misc-move-constructor-init
-  
`_
 check
-  has been removed as it duplicated the `modernize-pass-by-value
-  
`_ 
check.
-
-- New `misc-move-forwarding-reference
-  
`_
 check
-
-  Warns when ``std::move`` is applied to a forwarding reference instead of
-  ``std::forward``.
-
-- `misc-pointer-and-integral-operation` check was removed.
-
-- New `misc-string-compare
-  `_ 
check
-
-  Warns about using ``compare`` to test for string equality or inequality.
-
-- New `misc-use-after-move
-  `_ 
check
-
-  Warns if an object is used after it has been moved, without an intervening
-  reinitialization.
-
-- New `cppcoreguidelines-no-malloc
-  
`_
 check
-  warns if C-style memory management is used and suggests the use of RAII.
-
-- `modernize-make-unique
-  `_
-  and `modernize-make-shared
-  `_
-  now handle calls to the smart pointer's ``reset()`` method.
-
-- The `modernize-pass-by-value
-  
`_ 
check
-  now has a ValuesOnly option to only warn about parameters that are passed by
-  value but not moved.
-
-- The `modernize-use-auto
-  `_ 
check
-  now warns about variable declarations that are initialized with a cast, or by
-  calling a templated function that behaves as a cast.
-
-- The modernize-use-default check has been renamed to 
`modernize-use-equals-default
-  

r291837 - Clear the release notes for 5.0.0

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:55:16 2017
New Revision: 291837

URL: http://llvm.org/viewvc/llvm-project?rev=291837=rev
Log:
Clear the release notes for 5.0.0

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=291837=291836=291837=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Jan 12 15:55:16 2017
@@ -1,5 +1,5 @@
 ===
-Clang 4.0.0 (In-Progress) Release Notes
+Clang 5.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,15 +10,15 @@ Written by the `LLVM Team `_.
+   These are in-progress notes for the upcoming Clang 5 release. You may
+   prefer the `Clang 4 Release Notes
+   `_.
 
 Introduction
 
 
 This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release 4.0.0. Here we
+frontend, part of the LLVM Compiler Infrastructure, release 5.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
@@ -36,7 +36,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Clang 4.0.0?
+What's New in Clang 5.0.0?
 ==
 
 Some of the major new features and improvements to Clang are listed
@@ -47,10 +47,6 @@ sections with improvements to Clang's su
 Major New Features
 --
 
-- The ``diagnose_if`` attribute has been added to clang. This attribute allows
-  clang to emit a warning or error if a function call meets one or more
-  user-specified conditions.
-
 -  ...
 
 Improvements to Clang's diagnostics
@@ -61,13 +57,6 @@ Improvements to Clang's diagnostics
 New Compiler Flags
 --
 
-The option -Og has been added to optimize the debugging experience.
-For now, this option is exactly the same as -O1. However, in the future,
-some other optimizations might be enabled or disabled.
-
-The option -MJ has been added to simplify adding JSON compilation
-database output into existing build systems.
-
 The option 
 
 New Pragmas in Clang
@@ -127,7 +116,7 @@ OpenMP Support in Clang
 Internal API Changes
 
 
-These are major API changes that have happened since the 3.9 release of
+These are major API changes that have happened since the 4.0.0 release of
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
@@ -143,9 +132,6 @@ libclang
 
 ...
 
-With the option --show-description, scan-build's list of defects will also
-show the description of the defects.
-
 
 Static Analyzer
 ---


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


[clang-tools-extra] r291832 - Update docs/conf.py version

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:42:38 2017
New Revision: 291832

URL: http://llvm.org/viewvc/llvm-project?rev=291832=rev
Log:
Update docs/conf.py version

Modified:
clang-tools-extra/trunk/docs/conf.py

Modified: clang-tools-extra/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/conf.py?rev=291832=291831=291832=diff
==
--- clang-tools-extra/trunk/docs/conf.py (original)
+++ clang-tools-extra/trunk/docs/conf.py Thu Jan 12 15:42:38 2017
@@ -48,10 +48,10 @@ copyright = u'2007-%d, The Clang Team' %
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-# The short X.Y version.
-version = '4.0'
+# The short version.
+version = '5'
 # The full version, including alpha/beta/rc tags.
-release = '4.0'
+release = '5'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


r291831 - Update docs/conf.py version

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:41:38 2017
New Revision: 291831

URL: http://llvm.org/viewvc/llvm-project?rev=291831=rev
Log:
Update docs/conf.py version

Modified:
cfe/trunk/docs/analyzer/conf.py
cfe/trunk/docs/conf.py

Modified: cfe/trunk/docs/analyzer/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/conf.py?rev=291831=291830=291831=diff
==
--- cfe/trunk/docs/analyzer/conf.py (original)
+++ cfe/trunk/docs/analyzer/conf.py Thu Jan 12 15:41:38 2017
@@ -48,10 +48,10 @@ copyright = u'2013-%d, Analyzer Team' %
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-# The short X.Y version.
-version = '4.0'
+# The short version.
+version = '5'
 # The full version, including alpha/beta/rc tags.
-release = '4.0'
+release = '5'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

Modified: cfe/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=291831=291830=291831=diff
==
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Thu Jan 12 15:41:38 2017
@@ -48,10 +48,10 @@ copyright = u'2007-%d, The Clang Team' %
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
-# The short X.Y version.
-version = '4.0'
+# The short version.
+version = '5'
 # The full version, including alpha/beta/rc tags.
-release = '4.0'
+release = '5'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libunwind] r291830 - Bump version to 5.0.0svn

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:37:55 2017
New Revision: 291830

URL: http://llvm.org/viewvc/llvm-project?rev=291830=rev
Log:
Bump version to 5.0.0svn

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=291830=291829=291830=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Thu Jan 12 15:37:55 2017
@@ -71,7 +71,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 4.0.0svn)
+  set(PACKAGE_VERSION 5.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxxabi] r291829 - Bump version to 5.0.0svn

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:36:22 2017
New Revision: 291829

URL: http://llvm.org/viewvc/llvm-project?rev=291829=rev
Log:
Bump version to 5.0.0svn

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=291829=291828=291829=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Jan 12 15:36:22 2017
@@ -77,7 +77,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 4.0.0svn)
+  set(PACKAGE_VERSION 5.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libunwind] r291827 - Creating release_40 branch off revision 291814

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:26:18 2017
New Revision: 291827

URL: http://llvm.org/viewvc/llvm-project?rev=291827=rev
Log:
Creating release_40 branch off revision 291814

Added:
libunwind/branches/release_40/
  - copied from r291814, libunwind/trunk/

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


[libcxxabi] r291821 - Creating release_40 branch off revision 291814

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:25:46 2017
New Revision: 291821

URL: http://llvm.org/viewvc/llvm-project?rev=291821=rev
Log:
Creating release_40 branch off revision 291814

Added:
libcxxabi/branches/release_40/
  - copied from r291814, libcxxabi/trunk/

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


[libcxx] r291820 - Creating release_40 branch off revision 291814

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 15:25:41 2017
New Revision: 291820

URL: http://llvm.org/viewvc/llvm-project?rev=291820=rev
Log:
Creating release_40 branch off revision 291814

Added:
libcxx/branches/release_40/   (props changed)
  - copied from r291814, libcxx/trunk/

Propchange: libcxx/branches/release_40/
--
svn:mergeinfo = /libcxx/branches/apple:136569-137939


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


r291814 - Add entry for -MJ.

2017-01-12 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Thu Jan 12 15:11:55 2017
New Revision: 291814

URL: http://llvm.org/viewvc/llvm-project?rev=291814=rev
Log:
Add entry for -MJ.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=291814=291813=291814=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Jan 12 15:11:55 2017
@@ -65,6 +65,8 @@ The option -Og has been added to optimiz
 For now, this option is exactly the same as -O1. However, in the future,
 some other optimizations might be enabled or disabled.
 
+The option -MJ has been added to simplify adding JSON compilation
+database output into existing build systems.
 
 The option 
 


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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2017-01-12 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

@MathieuDuponchelle I've set up a docker image with Fedora 23 and reproduced 
the errors as you reported.

I've no immediate idea what the problem might be. Might be worth looking with 
address-sanitizer.


Repository:
  rL LLVM

https://reviews.llvm.org/D26082



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


r291807 - clang-format: Fix regression introduced by r291801.

2017-01-12 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Jan 12 14:06:28 2017
New Revision: 291807

URL: http://llvm.org/viewvc/llvm-project?rev=291807=rev
Log:
clang-format: Fix regression introduced by r291801.

Uncovered by polly tests.

Before:
  aa(aaa,
 {}, aaa);

After:
  aa(aaa, {},
 aaa);

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=291807=291806=291807=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Jan 12 14:06:28 2017
@@ -930,13 +930,6 @@ void ContinuationIndenter::moveStatePast
 return;
   }
 
-  const FormatToken *Previous = Current.getPreviousNonComment();
-  if (Previous && Previous->is(tok::comma) &&
-  !Previous->is(TT_OverloadedOperator)) {
-if (!Newline)
-  State.Stack.back().NoLineBreak = true;
-  }
-
   unsigned NewIndent;
   unsigned NewIndentLevel = State.Stack.back().IndentLevel;
   unsigned LastSpace = State.Stack.back().LastSpace;
@@ -1010,12 +1003,15 @@ void ContinuationIndenter::moveStatePast
   // Generally inherit NoLineBreak from the current scope to nested scope.
   // However, don't do this for non-empty nested blocks, dict literals and
   // array literals as these follow different indentation rules.
+  const FormatToken *Previous = Current.getPreviousNonComment();
   bool NoLineBreak =
   Current.Children.empty() &&
   !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) &&
   (State.Stack.back().NoLineBreak ||
(Current.is(TT_TemplateOpener) &&
-State.Stack.back().ContainsUnwrappedBuilder));
+State.Stack.back().ContainsUnwrappedBuilder) ||
+   (Current.is(tok::l_brace) && !Newline && Previous &&
+Previous->is(tok::comma)));
   State.Stack.push_back(ParenState(NewIndent, NewIndentLevel, LastSpace,
AvoidBinPacking, NoLineBreak));
   State.Stack.back().NestedBlockIndent = NestedBlockIndent;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=291807=291806=291807=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 12 14:06:28 2017
@@ -6822,6 +6822,8 @@ TEST_F(FormatTest, FormatsBracedListsInC
" {List1, List2,\n"
"  List3});",
getLLVMStyleWithColumns(35));
+  verifyFormat("aa(aaa, {},\n"
+   "   aaa);");
 }
 
 TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {


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


Re: [cfe-dev] Testcase for LLVM PR9350

2017-01-12 Thread Friedman, Eli via cfe-commits

On 1/6/2017 3:05 PM, Andrew Rogers wrote:


Hi,

This is a (tested!) patch to add checks that both pre-increment and 
pre-decrement don’t overflow, for both char and short integer types 
(since they’re both narrower than int), as per the problem fixed in 
PR9350.





r291805.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


Re: r290392 - Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.

2017-01-12 Thread Justin Bogner via cfe-commits
Chandler Carruth via cfe-commits  writes:
> Author: chandlerc
> Date: Thu Dec 22 18:23:01 2016
> New Revision: 290392
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290392=rev
> Log:
> Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.
>
> Much to my surprise, '-disable-llvm-optzns' which I thought was the
> magical flag I wanted to get at the raw LLVM IR coming out of Clang
> deosn't do that. It still runs some passes over the IR. I don't want
> that, I really want the *raw* IR coming out of Clang and I strongly
> suspect everyone else using it is in the same camp.
>
> There is actually a flag that does what I want that I didn't know about
> called '-disable-llvm-passes'. I suspect many others don't know about it
> either. It both does what I want and is much simpler.
>
> This removes the confusing version and makes that spelling of the flag
> an alias for '-disable-llvm-passes'. I've also moved everything in Clang
> to use the 'passes' spelling as it seems both more accurate (*all* LLVM
> passes are disabled, not just optimizations) and much easier to remember
> and spell correctly.
>
> This is part of simplifying how Clang drives LLVM to make it cleaner to
> wire up to the new pass manager.
>
> Differential Revision: https://reviews.llvm.org/D28047
>
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/CXX/drs/dr158.cpp
> cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
> cfe/trunk/test/CodeGen/always_inline.c
> cfe/trunk/test/CodeGen/attr-minsize.cpp
> cfe/trunk/test/CodeGen/bool_test.c
> cfe/trunk/test/CodeGen/builtin-expect.c
> cfe/trunk/test/CodeGen/builtin-unpredictable.c
> cfe/trunk/test/CodeGen/fixup-depth-overflow.c
> cfe/trunk/test/CodeGen/function-attributes.c
> cfe/trunk/test/CodeGen/inline.c
> cfe/trunk/test/CodeGen/may-alias.c
> cfe/trunk/test/CodeGen/tbaa-class.cpp
> cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp
> cfe/trunk/test/CodeGen/tbaa.cpp
> cfe/trunk/test/CodeGenCXX/PR26569.cpp
> cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
> cfe/trunk/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
> cfe/trunk/test/CodeGenCXX/destructors.cpp
> cfe/trunk/test/CodeGenCXX/dllexport.cpp
> cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
> cfe/trunk/test/CodeGenCXX/dllimport.cpp
> cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp
> cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
> cfe/trunk/test/CodeGenCXX/inline-hint.cpp
> cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
> cfe/trunk/test/CodeGenCXX/linkage.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-catch.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-extern-template.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
> cfe/trunk/test/CodeGenCXX/pr24097.cpp
> cfe/trunk/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
> cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
> cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
> cfe/trunk/test/CodeGenCXX/sanitize-dtor-trivial.cpp
> cfe/trunk/test/CodeGenCXX/sanitize-dtor-vtable.cpp
> cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
> cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
> cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
> cfe/trunk/test/CodeGenCXX/thunks.cpp
> cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp
> cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp
> cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
> cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
> cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
> cfe/trunk/test/CodeGenObjC/arc-blocks.m
> cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
> cfe/trunk/test/CodeGenObjC/arc-literals.m
> cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
> cfe/trunk/test/CodeGenObjC/arc-precise-lifetime.m
> cfe/trunk/test/CodeGenObjC/arc-ternary-op.m
> cfe/trunk/test/CodeGenObjC/arc-unsafeclaim.m
> cfe/trunk/test/CodeGenObjC/arc.m
> cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m
> cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m
> cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m
> cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m
> cfe/trunk/test/CodeGenObjCXX/arc-globals.mm
> cfe/trunk/test/CodeGenObjCXX/arc-move.mm
> cfe/trunk/test/CodeGenObjCXX/arc-new-delete.mm
> cfe/trunk/test/CodeGenObjCXX/arc-references.mm
> cfe/trunk/test/CodeGenObjCXX/arc.mm
> cfe/trunk/test/CodeGenObjCXX/destroy.mm
> cfe/trunk/test/CodeGenObjCXX/literals.mm
> 

r291805 - Add additional testcases for nsw markings on ++ and --.

2017-01-12 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Thu Jan 12 13:51:44 2017
New Revision: 291805

URL: http://llvm.org/viewvc/llvm-project?rev=291805=rev
Log:
Add additional testcases for nsw markings on ++ and --.

clang has generated correct IR for char/short decrement since r126816,
but we didn't have any test coverage for decrement.

Patch by Andrew Rogers.


Modified:
cfe/trunk/test/CodeGen/integer-overflow.c

Modified: cfe/trunk/test/CodeGen/integer-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/integer-overflow.c?rev=291805=291804=291805=diff
==
--- cfe/trunk/test/CodeGen/integer-overflow.c (original)
+++ cfe/trunk/test/CodeGen/integer-overflow.c Thu Jan 12 13:51:44 2017
@@ -65,13 +65,37 @@ void test1() {
   // TRAPV: getelementptr inbounds i32, i32*
   // CATCH_UB: getelementptr inbounds i32, i32*
 
-  // PR9350: char increment never overflows.
-  extern volatile signed char PR9350;
+  // PR9350: char pre-increment never overflows.
+  extern volatile signed char PR9350_char_inc;
   // DEFAULT: add i8 {{.*}}, 1
   // WRAPV: add i8 {{.*}}, 1
   // TRAPV: add i8 {{.*}}, 1
   // CATCH_UB: add i8 {{.*}}, 1
-  ++PR9350;
+  ++PR9350_char_inc;
+
+  // PR9350: char pre-decrement never overflows.
+  extern volatile signed char PR9350_char_dec;
+  // DEFAULT: add i8 {{.*}}, -1
+  // WRAPV: add i8 {{.*}}, -1
+  // TRAPV: add i8 {{.*}}, -1
+  // CATCH_UB: add i8 {{.*}}, -1
+  --PR9350_char_dec;
+
+  // PR9350: short pre-increment never overflows.
+  extern volatile signed short PR9350_short_inc;
+  // DEFAULT: add i16 {{.*}}, 1
+  // WRAPV: add i16 {{.*}}, 1
+  // TRAPV: add i16 {{.*}}, 1
+  // CATCH_UB: add i16 {{.*}}, 1
+  ++PR9350_short_inc;
+
+  // PR9350: short pre-decrement never overflows.
+  extern volatile signed short PR9350_short_dec;
+  // DEFAULT: add i16 {{.*}}, -1
+  // WRAPV: add i16 {{.*}}, -1
+  // TRAPV: add i16 {{.*}}, -1
+  // CATCH_UB: add i16 {{.*}}, -1
+  --PR9350_short_dec;
 
   // PR24256: don't instrument __builtin_frame_address.
   __builtin_frame_address(0 + 0);


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


r291801 - clang-format: Treat braced lists like other complex parameters.

2017-01-12 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Jan 12 13:35:26 2017
New Revision: 291801

URL: http://llvm.org/viewvc/llvm-project?rev=291801=rev
Log:
clang-format: Treat braced lists like other complex parameters.

Specifically, wrap before them if they are multi-line so that we don't
create long hanging indents. This prevents having a lot of code
indented a lot in some cases.

Before:
  someFunction(Param, {List1, List2,
   List3});

After:
  someFunction(Param,
   {List1, List2,
List3});

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=291801=291800=291801=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Jan 12 13:35:26 2017
@@ -930,6 +930,13 @@ void ContinuationIndenter::moveStatePast
 return;
   }
 
+  const FormatToken *Previous = Current.getPreviousNonComment();
+  if (Previous && Previous->is(tok::comma) &&
+  !Previous->is(TT_OverloadedOperator)) {
+if (!Newline)
+  State.Stack.back().NoLineBreak = true;
+  }
+
   unsigned NewIndent;
   unsigned NewIndentLevel = State.Stack.back().IndentLevel;
   unsigned LastSpace = State.Stack.back().LastSpace;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=291801=291800=291801=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 12 13:35:26 2017
@@ -6816,6 +6816,12 @@ TEST_F(FormatTest, FormatsBracedListsInC
"aa.aaa,\n"
"aa.aaa,\n"
"};");
+
+  // Don't create hanging lists.
+  verifyFormat("someFunction(Param,\n"
+   " {List1, List2,\n"
+   "  List3});",
+   getLLVMStyleWithColumns(35));
 }
 
 TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {


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


Re: r291783 - UsersManual.rst: Update clang-cl options list

2017-01-12 Thread Hans Wennborg via cfe-commits
Addressing this in r291798.

On Thu, Jan 12, 2017 at 11:18 AM, Nico Weber via cfe-commits
 wrote:
> Also, it looks like the main change is that this now lists
> /execution-charset: and /source-charset:. It doesn't list /utf-8 though
> (since that's just a CLIgnoredFlag behind the scenes I guess). It's a bit
> weird to list the two -charset flags (which just check that their arg is
> utf-8 and error out if not) but not /utf-8. Is there some way to either list
> all 3 or none of them?
>
> On Thu, Jan 12, 2017 at 2:13 PM, Nico Weber  wrote:
>>
>> Why do we list fdelayed-template-parsing in /? output now? That's on by
>> default with clang-cl.
>>
>> On Thu, Jan 12, 2017 at 1:15 PM, Hans Wennborg via cfe-commits
>>  wrote:
>>>
>>> Author: hans
>>> Date: Thu Jan 12 12:15:06 2017
>>> New Revision: 291783
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=291783=rev
>>> Log:
>>> UsersManual.rst: Update clang-cl options list
>>>
>>> Modified:
>>> cfe/trunk/docs/UsersManual.rst
>>>
>>> Modified: cfe/trunk/docs/UsersManual.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=291783=291782=291783=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/UsersManual.rst (original)
>>> +++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 12:15:06 2017
>>> @@ -2462,7 +2462,7 @@ Clang expects the GCC executable "gcc.ex
>>>  clang-cl
>>>  
>>>
>>> -clang-cl is an alternative command-line interface to Clang driver,
>>> designed for
>>> +clang-cl is an alternative command-line interface to Clang, designed for
>>>  compatibility with the Visual C++ compiler, cl.exe.
>>>
>>>  To enable clang-cl to find system headers, libraries, and the linker
>>> when run
>>> @@ -2470,7 +2470,7 @@ from the command-line, it should be exec
>>>  Command Prompt or a regular Command Prompt where the environment has
>>> been set
>>>  up using e.g. `vcvars32.bat
>>> `_.
>>>
>>> -clang-cl can also be used from inside Visual Studio  by using an LLVM
>>> Platform
>>> +clang-cl can also be used from inside Visual Studio by using an LLVM
>>> Platform
>>>  Toolset.
>>>
>>>  Command-Line Options
>>> @@ -2505,116 +2505,124 @@ Execute ``clang-cl /?`` to see a list of
>>>::
>>>
>>>  CL.EXE COMPATIBILITY OPTIONS:
>>> -  /? Display available options
>>> -  /arch:  Set architecture for code generation
>>> -  /Brepro-   Emit an object file which cannot be
>>> reproduced over time
>>> -  /BreproEmit an object file which can be reproduced
>>> over time
>>> -  /C Don't discard comments when preprocessing
>>> -  /c Compile only
>>> -  /D  Define macro
>>> -  /EH Exception handling model
>>> -  /EPDisable linemarker output and preprocess to
>>> stdout
>>> -  /E Preprocess to stdout
>>> -  /fallback  Fall back to cl.exe if clang-cl fails to
>>> compile
>>> -  /FAOutput assembly code file during
>>> compilation
>>> -  /Fa Output assembly code to this file during
>>> compilation (with /FA)
>>> -  /Fe Set output executable file or directory
>>> (ends in / or \)
>>> -  /FI Include file before parsing
>>> -  /Fi  Set preprocess output file name (with /P)
>>> -  /Fo Set output object file, or directory (ends
>>> in / or \) (with /c)
>>> +  /?  Display available options
>>> +  /arch:   Set architecture for code generation
>>> +  /Brepro-Emit an object file which cannot be
>>> reproduced over time
>>> +  /Brepro Emit an object file which can be
>>> reproduced over time
>>> +  /C  Don't discard comments when preprocessing
>>> +  /c  Compile only
>>> +  /D   Define macro
>>> +  /EH  Exception handling model
>>> +  /EP Disable linemarker output and preprocess
>>> to stdout
>>> +  /execution-charset:
>>> +  Runtime encoding, supports only UTF-8
>>> +  /E  Preprocess to stdout
>>> +  /fallback   Fall back to cl.exe if clang-cl fails to
>>> compile
>>> +  /FA Output assembly code file during
>>> compilation
>>> +  /Fa  Output assembly code to this file during
>>> compilation (with /FA)
>>> +  /Fe  Set output executable file or directory
>>> (ends in / or \)
>>> +  /FI  Include file before parsing
>>> +  /Fi   Set preprocess output file name (with /P)
>>> +  /Fo  Set output object file, or directory (ends
>>> in / or \) (with /c)
>>>

r291798 - UsersManual.rst: Update clang-cl options list again

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 13:26:54 2017
New Revision: 291798

URL: http://llvm.org/viewvc/llvm-project?rev=291798=rev
Log:
UsersManual.rst: Update clang-cl options list again

This time, make ignored options, such as /utf-8, show up as well if they
have help text.

Also, since we're now exposing -fdelayed-template-parsing, add help text
to the -fno version so that shows up as well.

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=291798=291797=291798=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 13:26:54 2017
@@ -2575,6 +2575,7 @@ Execute ``clang-cl /?`` to see a list of
   /Tc   Specify a C source file
   /TP Treat all source files as C++
   /Tp   Specify a C++ source file
+  /utf-8  Set source and runtime encoding to UTF-8 
(default)
   /U   Undefine macro
   /vd  Control vtordisp placement
   /vmbUse a best-case representation method for member 
pointers
@@ -2630,6 +2631,8 @@ Execute ``clang-cl /?`` to see a list of
   -fms-extensions Accept some non-standard constructs supported by 
the Microsoft compiler
   -fmsc-version=   Microsoft compiler version number to report in 
_MSC_VER
   (0 = don't define it (default))
+  -fno-delayed-template-parsing
+  Disable delayed template parsing
   -fno-sanitize-coverage=
   Disable specified features of coverage 
instrumentation for Sanitizers
   -fno-sanitize-recover=

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=291798=291797=291798=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Jan 12 13:26:54 2017
@@ -27,7 +27,7 @@ class CLCompileFlag : Optio
   Group, Flags<[CLOption, DriverOption]>;
 
 class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[CLOption, DriverOption, HelpHidden]>;
+  Group, Flags<[CLOption, DriverOption]>;
 
 class CLJoined : Option<["/", "-"], name, KIND_JOINED>,
   Group, Flags<[CLOption, DriverOption]>;
@@ -299,7 +299,7 @@ def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
 def _SLASH_FC : CLIgnoredFlag<"FC">;
 def _SLASH_Fd : CLIgnoredJoined<"Fd">;
-def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
+def _SLASH_FS : CLIgnoredFlag<"FS">;
 def _SLASH_GF : CLIgnoredFlag<"GF">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
@@ -308,7 +308,8 @@ def _SLASH_openmp_ : CLIgnoredFlag<"open
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
 def _SLASH_sdl : CLIgnoredFlag<"sdl">;
 def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">;
-def _SLASH_utf8 : CLIgnoredFlag<"utf-8">;
+def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
+  HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=291798=291797=291798=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jan 12 13:26:54 2017
@@ -1032,6 +1032,7 @@ def fno_ms_extensions : Flag<["-"], "fno
 def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group,
   Flags<[CoreOption]>;
 def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group,
+  HelpText<"Disable delayed template parsing">,
   Flags<[DriverOption, CoreOption]>;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;


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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-01-12 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

Bruno helped on collecting performance data for this patch:
$ cat cocoa-test.h
#import 

$ rm -rf tmp; clang -x objective-c -isysroot `xcrun --sdk macosx 
--show-sdk-path` -fblocks -fmodules -fmodules-cache-path=tmp cocoa-test.h 
-fsyntax-only

clang-release (10 runs)
---

name  avg min med max SD  SD%total
user 2.0023  1.9804  1.9994  2.0408  0.01490.74 20.0225
 sys 0.3601  0.3547  0.3505  0.4454  0.02877.98  3.6007
wall 2.5432  2.4291  2.4264  3.3604  0.2737   10.76 25.4324

clang-modhash-release (10 runs)
---

name  avg min med max SD  SD%total
user 2.1101  2.0935  2.1095  2.1274  0.01120.53 21.1012
 sys 0.3485  0.3462  0.3556  0.3476  0.00521.50  3.4854
wall 2.5614  2.5163  2.5605  2.6657  0.04191.63 25.6138

This ~5% slowdown for the total time of compiling all the modules (30+ modules).

A similar test for one object file in selfhost clang:

[TemplateName.cpp.o] clang-release (10 runs)


name  avg min med max SD  SD%total
user 7.4332  7.3716  7.4369  7.4976  0.04440.60 74.3318
 sys 0.5646  0.5512  0.5688  0.5570  0.01612.86  5.6464
wall 8.3357  8.1675  8.2991  8.2570  0.32403.89 83.3568

[TemplateName.cpp.o] clang-modhash-release (10 runs)


name  avg min med max SD  SD%total
user 7.6911  7.6202  7.6979  7.7779  0.04180.54 76.9114
 sys 0.5531  0.5437  0.5520  0.5622  0.01051.89  5.5315
wall 8.4598  8.3868  8.4839  8.5497  0.04550.54 84.5977

~3.5% slowdown for total of modules:

$ ls module.cache/1UKP65OUKXURH/
Clang_AST-1XMT5DOVQWGLJ.pcm   LLVM_C-2WKTHJHA6SDF0.pcm  
LLVM_Pass-HNKP05GYNHFQ.pcm
_Builtin_stddef_max_align_t-2T552E4NSAIDI.pcm
Clang_Basic-1XMT5DOVQWGLJ.pcm 
LLVM_Config_ABI_Breaking-2FT1AFJTZ51QZ.pcm
LLVM_Support_DataTypes-2FT1AFJTZ51QZ.pcm  modules.idx
Darwin-399Z2LWDSMSTV.pcm  LLVM_IR-HNKP05GYNHFQ.pcm  
LLVM_Utils-HNKP05GYNHFQ.pcm   std-1337JMP4UGPIP.pcm

Note that the cache was wiped out right before every tests instance.


Thanks Bruno. I am going to guard the hashing with a CC1 option (something like 
fmodules-hash-content) and force that flag to be enabled when the frontend 
implicitly builds a module. We will try to improve the hashing performance 
later (either improving SHA1 or using MD5 instead of SHA1).

Manman


https://reviews.llvm.org/D27689



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


[PATCH] D28614: [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291796: [clang-tidy] Fix check for trivially copyable types 
in modernize-pass-by-value (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D28614?vs=84135=84152#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28614

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
  
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
@@ -188,7 +188,8 @@
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
   // copyable type will cause a problem with misc-move-const-arg
-  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+  if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
+  *Result.Context))
 return;
 
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");
Index: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
===
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
@@ -1,4 +1,7 @@
 class ThreadId {
+public:
+  ThreadId(const ThreadId &) {}
+  ThreadId(ThreadId &&) {}
 };
 
 struct A {
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
@@ -2,8 +2,15 @@
 
 namespace {
 // POD types are trivially move constructible.
+struct POD {
+  int a, b, c;
+};
+
 struct Movable {
   int a, b, c;
+  Movable() = default;
+  Movable(const Movable &) {}
+  Movable(Movable &&) {}
 };
 
 struct NotMovable {
@@ -147,7 +154,8 @@
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-FIXES: O(Movable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
   Movable M;
 };
 
@@ -179,7 +187,8 @@
 }
 struct R {
   R(ns_R::RMovable M) : M(M) {}
-  // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
   ns_R::RMovable M;
 };
 
@@ -199,3 +208,8 @@
   // CHECK-FIXES: T(array a) : a_(a) {}
   array a_;
 };
+
+struct U {
+  U(const POD ) : M(M) {}
+  POD M;
+};
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
@@ -6,6 +6,8 @@
 #include HEADER
 
 struct A {
+  A(const A &) {}
+  A(A &&) {}
 };
 
 struct B {
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
@@ -3,6 +3,6 @@
 // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
 
 #include "pass-by-value-header.h"
-// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
 // CHECK-FIXES: #include 
 // CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}


Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
@@ -188,7 +188,8 @@
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
   // copyable type will cause a problem with misc-move-const-arg
-  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+  if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
+  *Result.Context))
 return;
 
   auto Diag = 

[clang-tools-extra] r291796 - [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

2017-01-12 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 12 13:20:35 2017
New Revision: 291796

URL: http://llvm.org/viewvc/llvm-project?rev=291796=rev
Log:
[clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

Summary:
rL270567 excluded trivially copyable types from being moved by
modernize-pass-by-value, but it didn't exclude references to them.
Change types used in the tests to not be trivially copyable.

Reviewers: madsravn, aaron.ballman, alexfh

Subscribers: JDevlieghere, cfe-commits

Differential Revision: https://reviews.llvm.org/D28614

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Thu Jan 
12 13:20:35 2017
@@ -188,7 +188,8 @@ void PassByValueCheck::check(const Match
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
   // copyable type will cause a problem with misc-move-const-arg
-  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+  if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
+  *Result.Context))
 return;
 
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");

Modified: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h?rev=291796=291795=291796=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
Thu Jan 12 13:20:35 2017
@@ -1,4 +1,7 @@
 class ThreadId {
+public:
+  ThreadId(const ThreadId &) {}
+  ThreadId(ThreadId &&) {}
 };
 
 struct A {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
Thu Jan 12 13:20:35 2017
@@ -3,6 +3,6 @@
 // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
 
 #include "pass-by-value-header.h"
-// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
 // CHECK-FIXES: #include 
 // CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp?rev=291796=291795=291796=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
 Thu Jan 12 13:20:35 2017
@@ -6,6 +6,8 @@
 #include HEADER
 
 struct A {
+  A(const A &) {}
+  A(A &&) {}
 };
 
 struct B {

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Thu Jan 
12 13:20:35 2017
@@ -2,8 +2,15 @@
 
 namespace {
 // POD types are trivially move constructible.
+struct POD {
+  int a, b, c;
+};
+
 struct Movable {
   int a, b, c;
+  Movable() = default;
+  Movable(const Movable &) {}
+  Movable(Movable &&) {}
 };
 
 struct NotMovable {
@@ -147,7 +154,8 @@ template  struct N {
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-FIXES: 

[PATCH] D28620: Guard __gnuc_va_list typedef

2017-01-12 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: yaron.keren.
probinson added a subscriber: cfe-commits.

https://reviews.llvm.org/D28620

Files:
  lib/Headers/stdarg.h
  test/Headers/stdarg-gnuc_va_list.c


Index: test/Headers/stdarg-gnuc_va_list.c
===
--- test/Headers/stdarg-gnuc_va_list.c
+++ test/Headers/stdarg-gnuc_va_list.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s
+// expected-no-diagnostics
+
+// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has
+// previously been defined in another header file.
+typedef __builtin_va_list __va_list;
+typedef __va_list __gnuc_va_list;
+#define __GNUC_VA_LIST
+
+#include 
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -46,7 +46,7 @@
 /* Hack required to make standard headers work, at least on Ubuntu */
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
-#endif
 typedef __builtin_va_list __gnuc_va_list;
+#endif
 
 #endif /* __STDARG_H */


Index: test/Headers/stdarg-gnuc_va_list.c
===
--- test/Headers/stdarg-gnuc_va_list.c
+++ test/Headers/stdarg-gnuc_va_list.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsystem-headers -std=c99 %s
+// expected-no-diagnostics
+
+// Check that no warnings are emitted from stdarg.h if __gnuc_va_list has
+// previously been defined in another header file.
+typedef __builtin_va_list __va_list;
+typedef __va_list __gnuc_va_list;
+#define __GNUC_VA_LIST
+
+#include 
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -46,7 +46,7 @@
 /* Hack required to make standard headers work, at least on Ubuntu */
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
-#endif
 typedef __builtin_va_list __gnuc_va_list;
+#endif
 
 #endif /* __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291794 - [Modules] Fix misleading warning about missing textual header in umbrella header

2017-01-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jan 12 13:15:33 2017
New Revision: 291794

URL: http://llvm.org/viewvc/llvm-project?rev=291794=rev
Log:
[Modules] Fix misleading warning about missing textual header in umbrella header

When a textual header is present inside a umbrella dir but not in the
header, we get the misleading warning:

warning: umbrella header for module 'FooFramework' does not include
header 'Baz_Private.h'

The module map in question:

framework module FooFramework {
umbrella header "FooUmbrella.h"

export *
module * { export * }

module Private {
textual header "Baz_Private.h"
}
}

Fix this by taking textual headers into account.

Added:
cfe/trunk/test/Modules/Inputs/FooFramework.framework/
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/

cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h

cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h

cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h
cfe/trunk/test/Modules/textual-hdr-in-umbrella-hdr.m
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=291794=291793=291794=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Jan 12 13:15:33 2017
@@ -446,9 +446,19 @@ ModuleMap::isHeaderUnavailableInModule(c
  I = Known->second.begin(),
  E = Known->second.end();
  I != E; ++I) {
-  if (I->isAvailable() && (!RequestingModule ||
-   
I->getModule()->isSubModuleOf(RequestingModule)))
+
+  if (I->isAvailable() &&
+  (!RequestingModule ||
+   I->getModule()->isSubModuleOf(RequestingModule))) {
+// When no requesting module is available, the caller is looking if a
+// header is part a module by only looking into the module map. This is
+// done by warn_uncovered_module_header checks; don't consider textual
+// headers part of it in this mode, otherwise we get misleading 
warnings
+// that a umbrella header is not including a textual header.
+if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader)
+  continue;
 return false;
+  }
 }
 return true;
   }

Added: 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap?rev=291794=auto
==
--- 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap 
Thu Jan 12 13:15:33 2017
@@ -0,0 +1,12 @@
+framework module FooFramework {
+umbrella header "FooUmbrella.h"
+
+export *
+module * {
+export *
+}
+
+explicit module Private {
+textual header "Baz_Private.h"
+}
+}

Added: cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h?rev=291794=auto
==
--- cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h 
Thu Jan 12 13:15:33 2017
@@ -0,0 +1,2 @@
+@interface Bar
+@end

Added: 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h?rev=291794=auto
==
--- 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
 Thu Jan 12 13:15:33 2017
@@ -0,0 +1,3 @@
+#ifndef Baz_h
+#define Baz_h
+#endif /* Baz_h */

Added: cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h?rev=291794=auto
==
--- cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h 
(added)
+++ 

Re: r291783 - UsersManual.rst: Update clang-cl options list

2017-01-12 Thread Nico Weber via cfe-commits
Also, it looks like the main change is that this now lists
/execution-charset: and /source-charset:. It doesn't list /utf-8 though
(since that's just a CLIgnoredFlag behind the scenes I guess). It's a bit
weird to list the two -charset flags (which just check that their arg is
utf-8 and error out if not) but not /utf-8. Is there some way to either
list all 3 or none of them?

On Thu, Jan 12, 2017 at 2:13 PM, Nico Weber  wrote:

> Why do we list fdelayed-template-parsing in /? output now? That's on by
> default with clang-cl.
>
> On Thu, Jan 12, 2017 at 1:15 PM, Hans Wennborg via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: hans
>> Date: Thu Jan 12 12:15:06 2017
>> New Revision: 291783
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291783=rev
>> Log:
>> UsersManual.rst: Update clang-cl options list
>>
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>>
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManu
>> al.rst?rev=291783=291782=291783=diff
>> 
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 12:15:06 2017
>> @@ -2462,7 +2462,7 @@ Clang expects the GCC executable "gcc.ex
>>  clang-cl
>>  
>>
>> -clang-cl is an alternative command-line interface to Clang driver,
>> designed for
>> +clang-cl is an alternative command-line interface to Clang, designed for
>>  compatibility with the Visual C++ compiler, cl.exe.
>>
>>  To enable clang-cl to find system headers, libraries, and the linker
>> when run
>> @@ -2470,7 +2470,7 @@ from the command-line, it should be exec
>>  Command Prompt or a regular Command Prompt where the environment has
>> been set
>>  up using e.g. `vcvars32.bat > us/library/f2ccy3wt.aspx>`_.
>>
>> -clang-cl can also be used from inside Visual Studio  by using an LLVM
>> Platform
>> +clang-cl can also be used from inside Visual Studio by using an LLVM
>> Platform
>>  Toolset.
>>
>>  Command-Line Options
>> @@ -2505,116 +2505,124 @@ Execute ``clang-cl /?`` to see a list of
>>::
>>
>>  CL.EXE COMPATIBILITY OPTIONS:
>> -  /? Display available options
>> -  /arch:  Set architecture for code generation
>> -  /Brepro-   Emit an object file which cannot be
>> reproduced over time
>> -  /BreproEmit an object file which can be reproduced
>> over time
>> -  /C Don't discard comments when preprocessing
>> -  /c Compile only
>> -  /D  Define macro
>> -  /EH Exception handling model
>> -  /EPDisable linemarker output and preprocess to
>> stdout
>> -  /E Preprocess to stdout
>> -  /fallback  Fall back to cl.exe if clang-cl fails to
>> compile
>> -  /FAOutput assembly code file during compilation
>> -  /Fa Output assembly code to this file during
>> compilation (with /FA)
>> -  /Fe Set output executable file or directory
>> (ends in / or \)
>> -  /FI Include file before parsing
>> -  /Fi  Set preprocess output file name (with /P)
>> -  /Fo Set output object file, or directory (ends
>> in / or \) (with /c)
>> +  /?  Display available options
>> +  /arch:   Set architecture for code generation
>> +  /Brepro-Emit an object file which cannot be
>> reproduced over time
>> +  /Brepro Emit an object file which can be
>> reproduced over time
>> +  /C  Don't discard comments when preprocessing
>> +  /c  Compile only
>> +  /D   Define macro
>> +  /EH  Exception handling model
>> +  /EP Disable linemarker output and preprocess
>> to stdout
>> +  /execution-charset:
>> +  Runtime encoding, supports only UTF-8
>> +  /E  Preprocess to stdout
>> +  /fallback   Fall back to cl.exe if clang-cl fails to
>> compile
>> +  /FA Output assembly code file during
>> compilation
>> +  /Fa  Output assembly code to this file during
>> compilation (with /FA)
>> +  /Fe  Set output executable file or directory
>> (ends in / or \)
>> +  /FI  Include file before parsing
>> +  /Fi   Set preprocess output file name (with /P)
>> +  /Fo  Set output object file, or directory (ends
>> in / or \) (with /c)
>>/fp:except-
>>/fp:except
>>/fp:fast
>>/fp:precise
>>/fp:strict
>> -  /Fp  Set pch filename (with /Yc and /Yu)
>> -  /GAAssume thread-local variables are defined
>> in the executable

Re: r291783 - UsersManual.rst: Update clang-cl options list

2017-01-12 Thread Hans Wennborg via cfe-commits
In r290990, Reid exposed that, and in particular the -fno variant for
users who want to disable it.

It seems the -fno variant doesn't show up because it has no help text :-/

On Thu, Jan 12, 2017 at 11:13 AM, Nico Weber via cfe-commits
 wrote:
> Why do we list fdelayed-template-parsing in /? output now? That's on by
> default with clang-cl.
>
> On Thu, Jan 12, 2017 at 1:15 PM, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Author: hans
>> Date: Thu Jan 12 12:15:06 2017
>> New Revision: 291783
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291783=rev
>> Log:
>> UsersManual.rst: Update clang-cl options list
>>
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>>
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=291783=291782=291783=diff
>>
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 12:15:06 2017
>> @@ -2462,7 +2462,7 @@ Clang expects the GCC executable "gcc.ex
>>  clang-cl
>>  
>>
>> -clang-cl is an alternative command-line interface to Clang driver,
>> designed for
>> +clang-cl is an alternative command-line interface to Clang, designed for
>>  compatibility with the Visual C++ compiler, cl.exe.
>>
>>  To enable clang-cl to find system headers, libraries, and the linker when
>> run
>> @@ -2470,7 +2470,7 @@ from the command-line, it should be exec
>>  Command Prompt or a regular Command Prompt where the environment has been
>> set
>>  up using e.g. `vcvars32.bat
>> `_.
>>
>> -clang-cl can also be used from inside Visual Studio  by using an LLVM
>> Platform
>> +clang-cl can also be used from inside Visual Studio by using an LLVM
>> Platform
>>  Toolset.
>>
>>  Command-Line Options
>> @@ -2505,116 +2505,124 @@ Execute ``clang-cl /?`` to see a list of
>>::
>>
>>  CL.EXE COMPATIBILITY OPTIONS:
>> -  /? Display available options
>> -  /arch:  Set architecture for code generation
>> -  /Brepro-   Emit an object file which cannot be
>> reproduced over time
>> -  /BreproEmit an object file which can be reproduced
>> over time
>> -  /C Don't discard comments when preprocessing
>> -  /c Compile only
>> -  /D  Define macro
>> -  /EH Exception handling model
>> -  /EPDisable linemarker output and preprocess to
>> stdout
>> -  /E Preprocess to stdout
>> -  /fallback  Fall back to cl.exe if clang-cl fails to
>> compile
>> -  /FAOutput assembly code file during compilation
>> -  /Fa Output assembly code to this file during
>> compilation (with /FA)
>> -  /Fe Set output executable file or directory
>> (ends in / or \)
>> -  /FI Include file before parsing
>> -  /Fi  Set preprocess output file name (with /P)
>> -  /Fo Set output object file, or directory (ends
>> in / or \) (with /c)
>> +  /?  Display available options
>> +  /arch:   Set architecture for code generation
>> +  /Brepro-Emit an object file which cannot be
>> reproduced over time
>> +  /Brepro Emit an object file which can be reproduced
>> over time
>> +  /C  Don't discard comments when preprocessing
>> +  /c  Compile only
>> +  /D   Define macro
>> +  /EH  Exception handling model
>> +  /EP Disable linemarker output and preprocess to
>> stdout
>> +  /execution-charset:
>> +  Runtime encoding, supports only UTF-8
>> +  /E  Preprocess to stdout
>> +  /fallback   Fall back to cl.exe if clang-cl fails to
>> compile
>> +  /FA Output assembly code file during
>> compilation
>> +  /Fa  Output assembly code to this file during
>> compilation (with /FA)
>> +  /Fe  Set output executable file or directory
>> (ends in / or \)
>> +  /FI  Include file before parsing
>> +  /Fi   Set preprocess output file name (with /P)
>> +  /Fo  Set output object file, or directory (ends
>> in / or \) (with /c)
>>/fp:except-
>>/fp:except
>>/fp:fast
>>/fp:precise
>>/fp:strict
>> -  /Fp  Set pch filename (with /Yc and /Yu)
>> -  /GAAssume thread-local variables are defined in
>> the executable
>> -  /GdSet __cdecl as a default calling convention
>> -  /GF-   Disable string pooling
>> -  /GR-   Disable emission 

Re: r291783 - UsersManual.rst: Update clang-cl options list

2017-01-12 Thread Nico Weber via cfe-commits
Why do we list fdelayed-template-parsing in /? output now? That's on by
default with clang-cl.

On Thu, Jan 12, 2017 at 1:15 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hans
> Date: Thu Jan 12 12:15:06 2017
> New Revision: 291783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291783=rev
> Log:
> UsersManual.rst: Update clang-cl options list
>
> Modified:
> cfe/trunk/docs/UsersManual.rst
>
> Modified: cfe/trunk/docs/UsersManual.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UsersManual.rst?rev=291783=291782=291783=diff
> 
> ==
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 12:15:06 2017
> @@ -2462,7 +2462,7 @@ Clang expects the GCC executable "gcc.ex
>  clang-cl
>  
>
> -clang-cl is an alternative command-line interface to Clang driver,
> designed for
> +clang-cl is an alternative command-line interface to Clang, designed for
>  compatibility with the Visual C++ compiler, cl.exe.
>
>  To enable clang-cl to find system headers, libraries, and the linker when
> run
> @@ -2470,7 +2470,7 @@ from the command-line, it should be exec
>  Command Prompt or a regular Command Prompt where the environment has been
> set
>  up using e.g. `vcvars32.bat  us/library/f2ccy3wt.aspx>`_.
>
> -clang-cl can also be used from inside Visual Studio  by using an LLVM
> Platform
> +clang-cl can also be used from inside Visual Studio by using an LLVM
> Platform
>  Toolset.
>
>  Command-Line Options
> @@ -2505,116 +2505,124 @@ Execute ``clang-cl /?`` to see a list of
>::
>
>  CL.EXE COMPATIBILITY OPTIONS:
> -  /? Display available options
> -  /arch:  Set architecture for code generation
> -  /Brepro-   Emit an object file which cannot be
> reproduced over time
> -  /BreproEmit an object file which can be reproduced
> over time
> -  /C Don't discard comments when preprocessing
> -  /c Compile only
> -  /D  Define macro
> -  /EH Exception handling model
> -  /EPDisable linemarker output and preprocess to
> stdout
> -  /E Preprocess to stdout
> -  /fallback  Fall back to cl.exe if clang-cl fails to
> compile
> -  /FAOutput assembly code file during compilation
> -  /Fa Output assembly code to this file during
> compilation (with /FA)
> -  /Fe Set output executable file or directory
> (ends in / or \)
> -  /FI Include file before parsing
> -  /Fi  Set preprocess output file name (with /P)
> -  /Fo Set output object file, or directory (ends
> in / or \) (with /c)
> +  /?  Display available options
> +  /arch:   Set architecture for code generation
> +  /Brepro-Emit an object file which cannot be
> reproduced over time
> +  /Brepro Emit an object file which can be reproduced
> over time
> +  /C  Don't discard comments when preprocessing
> +  /c  Compile only
> +  /D   Define macro
> +  /EH  Exception handling model
> +  /EP Disable linemarker output and preprocess to
> stdout
> +  /execution-charset:
> +  Runtime encoding, supports only UTF-8
> +  /E  Preprocess to stdout
> +  /fallback   Fall back to cl.exe if clang-cl fails to
> compile
> +  /FA Output assembly code file during compilation
> +  /Fa  Output assembly code to this file during
> compilation (with /FA)
> +  /Fe  Set output executable file or directory
> (ends in / or \)
> +  /FI  Include file before parsing
> +  /Fi   Set preprocess output file name (with /P)
> +  /Fo  Set output object file, or directory (ends
> in / or \) (with /c)
>/fp:except-
>/fp:except
>/fp:fast
>/fp:precise
>/fp:strict
> -  /Fp  Set pch filename (with /Yc and /Yu)
> -  /GAAssume thread-local variables are defined in
> the executable
> -  /GdSet __cdecl as a default calling convention
> -  /GF-   Disable string pooling
> -  /GR-   Disable emission of RTTI data
> -  /GREnable emission of RTTI data
> -  /GrSet __fastcall as a default calling
> convention
> -  /GS-   Disable buffer security check
> -  /GSEnable buffer security check
> -  /Gs Set stack probe size
> -  /GvSet __vectorcall as a default 

r291783 - UsersManual.rst: Update clang-cl options list

2017-01-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jan 12 12:15:06 2017
New Revision: 291783

URL: http://llvm.org/viewvc/llvm-project?rev=291783=rev
Log:
UsersManual.rst: Update clang-cl options list

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=291783=291782=291783=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 12:15:06 2017
@@ -2462,7 +2462,7 @@ Clang expects the GCC executable "gcc.ex
 clang-cl
 
 
-clang-cl is an alternative command-line interface to Clang driver, designed for
+clang-cl is an alternative command-line interface to Clang, designed for
 compatibility with the Visual C++ compiler, cl.exe.
 
 To enable clang-cl to find system headers, libraries, and the linker when run
@@ -2470,7 +2470,7 @@ from the command-line, it should be exec
 Command Prompt or a regular Command Prompt where the environment has been set
 up using e.g. `vcvars32.bat 
`_.
 
-clang-cl can also be used from inside Visual Studio  by using an LLVM Platform
+clang-cl can also be used from inside Visual Studio by using an LLVM Platform
 Toolset.
 
 Command-Line Options
@@ -2505,116 +2505,124 @@ Execute ``clang-cl /?`` to see a list of
   ::
 
 CL.EXE COMPATIBILITY OPTIONS:
-  /? Display available options
-  /arch:  Set architecture for code generation
-  /Brepro-   Emit an object file which cannot be reproduced 
over time
-  /BreproEmit an object file which can be reproduced over 
time
-  /C Don't discard comments when preprocessing
-  /c Compile only
-  /D  Define macro
-  /EH Exception handling model
-  /EPDisable linemarker output and preprocess to stdout
-  /E Preprocess to stdout
-  /fallback  Fall back to cl.exe if clang-cl fails to compile
-  /FAOutput assembly code file during compilation
-  /Fa Output assembly code to this file during 
compilation (with /FA)
-  /Fe Set output executable file or directory (ends in 
/ or \)
-  /FI Include file before parsing
-  /Fi  Set preprocess output file name (with /P)
-  /Fo Set output object file, or directory (ends in / 
or \) (with /c)
+  /?  Display available options
+  /arch:   Set architecture for code generation
+  /Brepro-Emit an object file which cannot be reproduced 
over time
+  /Brepro Emit an object file which can be reproduced over 
time
+  /C  Don't discard comments when preprocessing
+  /c  Compile only
+  /D   Define macro
+  /EH  Exception handling model
+  /EP Disable linemarker output and preprocess to 
stdout
+  /execution-charset:
+  Runtime encoding, supports only UTF-8
+  /E  Preprocess to stdout
+  /fallback   Fall back to cl.exe if clang-cl fails to compile
+  /FA Output assembly code file during compilation
+  /Fa  Output assembly code to this file during 
compilation (with /FA)
+  /Fe  Set output executable file or directory (ends in 
/ or \)
+  /FI  Include file before parsing
+  /Fi   Set preprocess output file name (with /P)
+  /Fo  Set output object file, or directory (ends in / 
or \) (with /c)
   /fp:except-
   /fp:except
   /fp:fast
   /fp:precise
   /fp:strict
-  /Fp  Set pch filename (with /Yc and /Yu)
-  /GAAssume thread-local variables are defined in the 
executable
-  /GdSet __cdecl as a default calling convention
-  /GF-   Disable string pooling
-  /GR-   Disable emission of RTTI data
-  /GREnable emission of RTTI data
-  /GrSet __fastcall as a default calling convention
-  /GS-   Disable buffer security check
-  /GSEnable buffer security check
-  /Gs Set stack probe size
-  /GvSet __vectorcall as a default calling convention
-  /Gw-   Don't put each data item in its own section
-  /GwPut each data item in its own section
-  /GX-   Enable exception handling
-  /GXEnable exception handling
-  /Gy-   Don't put each function in its own section
-  /GyPut each function in its own 

[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

> @yaxunl Sam, I think it would be nice to describe your recent change for 
> adding OpenCL extensions. Would you like to write up some text? Otherwise I 
> can draft something and you can review. :)

Anastasia, I am busy with some other work. If you can add it I will be happy to 
review it. Thanks!


https://reviews.llvm.org/D28080



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


[PATCH] D28602: [analyzer] Don't dereference the array bound to a reference.

2017-01-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291781: [analyzer] Don't dereference the array value when 
binding it to a reference. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D28602?vs=84097=84140#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28602

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -515,8 +515,9 @@
   Init = ASE->getBase()->IgnoreImplicit();
 
 SVal LValue = State->getSVal(Init, stackFrame);
-if (Optional LValueLoc = LValue.getAs())
-  InitVal = State->getSVal(*LValueLoc);
+if (!Field->getType()->isReferenceType())
+  if (Optional LValueLoc = LValue.getAs())
+InitVal = State->getSVal(*LValueLoc);
 
 // If we fail to get the value for some reason, use a symbolic value.
 if (InitVal.isUnknownOrUndef()) {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -253,12 +253,6 @@
   if (!TVR->getValueType()->isReferenceType())
 return;
 
-  // FIXME: This is a hotfix for https://llvm.org/bugs/show_bug.cgi?id=31592
-  // A proper fix is very much necessary. Otherwise we would never normally 
bind
-  // a NonLoc to a reference.
-  if (V.getAs())
-return;
-
   ProgramStateRef State = C.getState();
 
   ProgramStateRef StNonNull, StNull;


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -515,8 +515,9 @@
   Init = ASE->getBase()->IgnoreImplicit();
 
 SVal LValue = State->getSVal(Init, stackFrame);
-if (Optional LValueLoc = LValue.getAs())
-  InitVal = State->getSVal(*LValueLoc);
+if (!Field->getType()->isReferenceType())
+  if (Optional LValueLoc = LValue.getAs())
+InitVal = State->getSVal(*LValueLoc);
 
 // If we fail to get the value for some reason, use a symbolic value.
 if (InitVal.isUnknownOrUndef()) {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -253,12 +253,6 @@
   if (!TVR->getValueType()->isReferenceType())
 return;
 
-  // FIXME: This is a hotfix for https://llvm.org/bugs/show_bug.cgi?id=31592
-  // A proper fix is very much necessary. Otherwise we would never normally bind
-  // a NonLoc to a reference.
-  if (V.getAs())
-return;
-
   ProgramStateRef State = C.getState();
 
   ProgramStateRef StNonNull, StNull;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291781 - [analyzer] Don't dereference the array value when binding it to a reference.

2017-01-12 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jan 12 12:00:03 2017
New Revision: 291781

URL: http://llvm.org/viewvc/llvm-project?rev=291781=rev
Log:
[analyzer] Don't dereference the array value when binding it to a reference.

This replaces the hack in r291754, which was fixing pr31592, which was
caused by r291754, with a more appropriate solution.

rdar://problem/28832541
Differential revision: https://reviews.llvm.org/D28602

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=291781=291780=291781=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Thu Jan 12 
12:00:03 2017
@@ -253,12 +253,6 @@ void DereferenceChecker::checkBind(SVal
   if (!TVR->getValueType()->isReferenceType())
 return;
 
-  // FIXME: This is a hotfix for https://llvm.org/bugs/show_bug.cgi?id=31592
-  // A proper fix is very much necessary. Otherwise we would never normally 
bind
-  // a NonLoc to a reference.
-  if (V.getAs())
-return;
-
   ProgramStateRef State = C.getState();
 
   ProgramStateRef StNonNull, StNull;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=291781=291780=291781=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Jan 12 12:00:03 2017
@@ -515,8 +515,9 @@ void ExprEngine::ProcessInitializer(cons
   Init = ASE->getBase()->IgnoreImplicit();
 
 SVal LValue = State->getSVal(Init, stackFrame);
-if (Optional LValueLoc = LValue.getAs())
-  InitVal = State->getSVal(*LValueLoc);
+if (!Field->getType()->isReferenceType())
+  if (Optional LValueLoc = LValue.getAs())
+InitVal = State->getSVal(*LValueLoc);
 
 // If we fail to get the value for some reason, use a symbolic value.
 if (InitVal.isUnknownOrUndef()) {


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


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Since everyone agreed on the core part of this documentation I have committed 
the current revision in 291780 to make it easier for the release.

Feel free  to give me more feedback (if any) as small changes can still be 
merged in.

@yaxunl Sam, I think it would be nice to describe your recent change for adding 
OpenCL extensions. Would you like to write up some text? Otherwise I can draft 
something and you can review. :)


https://reviews.llvm.org/D28080



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


r291780 - [Docs][OpenCL] Added OpenCL feature description to Clang documentation.

2017-01-12 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Jan 12 11:52:22 2017
New Revision: 291780

URL: http://llvm.org/viewvc/llvm-project?rev=291780=rev
Log:
[Docs][OpenCL] Added OpenCL feature description to Clang documentation.

Updated index and UsersManual with OpenCL description.

Review: https://reviews.llvm.org/D28080 


Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/www/index.html

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=291780=291779=291780=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Jan 12 11:52:22 2017
@@ -41,6 +41,7 @@ specific section:
variants depending on base language.
 -  :ref:`C++ Language `
 -  :ref:`Objective C++ Language `
+-  :ref:`OpenCL C Language `: v1.0, v1.1, v1.2, v2.0.
 
 In addition to these base languages and their dialects, Clang supports a
 broad variety of language extensions, which are documented in the
@@ -1973,6 +1974,365 @@ Controlling implementation limits
  is provided or target does not support TLS, code generation for threadprivate
  variables relies on OpenMP runtime library.
 
+.. _opencl:
+
+OpenCL Features
+===
+
+Clang can be used to compile OpenCL kernels for execution on a device
+(e.g. GPU). It is possible to compile the kernel into a binary (e.g. for AMD or
+Nvidia targets) that can be uploaded to run directly on a device (e.g. using
+`clCreateProgramWithBinary
+`_) or
+into generic bitcode files loadable into other toolchains.
+
+Compiling to a binary using the default target from the installation can be 
done
+as follows:
+
+   .. code-block:: console
+
+ $ echo "kernel void k(){}" > test.cl
+ $ clang test.cl
+
+Compiling for a specific target can be done by specifying the triple 
corresponding
+to the target, for example:
+
+   .. code-block:: console
+
+ $ clang -target nvptx64-unknown-unknown test.cl
+ $ clang -target amdgcn-amd-amdhsa-opencl test.cl
+
+Compiling to bitcode can be done as follows:
+
+   .. code-block:: console
+
+ $ clang -c -emit-llvm test.cl
+
+This will produce a generic test.bc file that can be used in vendor toolchains
+to perform machine code generation.
+
+Clang currently supports OpenCL C language standards up to v2.0.
+
+OpenCL Specific Options
+---
+
+Most of the OpenCL build options from `the specification v2.0 section 5.8.4
+`_ are available.
+
+Examples:
+
+   .. code-block:: console
+
+ $ clang -cl-std=CL2.0 -cl-single-precision-constant test.cl
+
+Some extra options are available to support special OpenCL features.
+
+.. option:: -finclude-default-header
+
+Loads standard includes during compilations. By default OpenCL headers are not
+loaded and therefore standard library includes are not available. To load them
+automatically a flag has been added to the frontend (see also :ref:`the section
+on the OpenCL Header `):
+
+   .. code-block:: console
+
+ $ clang -Xclang -finclude-default-header test.cl
+
+Alternatively ``-include`` or ``-I`` followed by the path to the header 
location
+can be given manually.
+
+   .. code-block:: console
+
+ $ clang -I/lib/Headers/opencl-c.h test.cl
+
+In this case the kernel code should contain ``#include `` just as a
+regular C include.
+
+.. option:: -cl-ext
+
+Disables support of OpenCL extensions. All OpenCL targets provide a list
+of extensions that they support. Clang allows to amend this using the 
``-cl-ext``
+flag with a comma-separated list of extensions prefixed with ``'+'`` or 
``'-'``.
+The syntax: ``-cl-ext=<(['-'|'+'][,])+>``,  where extensions
+can be either one of `the OpenCL specification extensions
+`_
+or any known vendor extension. Alternatively, ``'all'`` can be used to enable
+or disable all known extensions.
+Example disabling double support for the 64-bit SPIR target:
+
+   .. code-block:: console
+
+ $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl
+
+Enabling all extensions except double support in R600 AMD GPU can be done 
using:
+
+   .. code-block:: console
+
+ $ clang -cc1 -triple r600-unknown-unknown -cl-ext=-all,+cl_khr_fp16 
test.cl
+
+.. _opencl_fake_address_space_map:
+
+.. option:: -ffake-address-space-map
+
+Overrides the target address space map with a fake map.
+This allows adding explicit address space IDs to the bitcode for non-segmented
+memory architectures that don't have separate IDs for each of the OpenCL
+logical address spaces by default. Passing ``-ffake-address-space-map`` will
+add/override address spaces of the target compiled for with the following 
values:
+``1-global``, ``2-constant``, ``3-local``, ``4-generic``. The private address
+space is 

[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2017-01-12 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

This is done.


https://reviews.llvm.org/D27773



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


[PATCH] D27090: Add LocationContext as a parameter to checkRegionChanges

2017-01-12 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

This needs to be committed.


https://reviews.llvm.org/D27090



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


[PATCH] D28606: Mention devirtualization in release notes

2017-01-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

Can you write something about this option for UsersManual.rst too? Then we 
could make this note link to it.


https://reviews.llvm.org/D28606



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-12 Thread Manman Ren via Phabricator via cfe-commits
manmanren updated this revision to Diff 84137.
manmanren added a comment.

Addressing review comments.


https://reviews.llvm.org/D28299

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/FileManager.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  include/clang/Serialization/ModuleManager.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/ChainedIncludesSource.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/system-out-of-date/X.h
  test/Modules/Inputs/system-out-of-date/Y.h
  test/Modules/Inputs/system-out-of-date/Z.h
  test/Modules/Inputs/system-out-of-date/module.map
  test/Modules/system-out-of-date-test.m

Index: test/Modules/system-out-of-date-test.m
===
--- /dev/null
+++ test/Modules/system-out-of-date-test.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: echo '@import X;' | \
+// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date \
+// RUN: -fsyntax-only -x objective-c -
+
+// We have an version built with different diagnostic options.
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module %s -fsyntax-only 2>&1 | FileCheck %s
+ @import X;
+ 
+ #import 
+// CHECK: While building module 'Z' imported from
+// CHECK: {{.*}}Y-{{.*}}pcm' was validated as a system module and is now being imported as a non-system module
Index: test/Modules/Inputs/system-out-of-date/module.map
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/module.map
@@ -0,0 +1,12 @@
+module X [system] {
+  header "X.h" // imports Y
+  export *
+}
+module Y {
+  header "Y.h"
+  export *
+}
+module Z {
+  header "Z.h" // imports Y
+  export *
+}
Index: test/Modules/Inputs/system-out-of-date/Z.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Z.h
@@ -0,0 +1 @@
+#import 
Index: test/Modules/Inputs/system-out-of-date/Y.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Y.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/system-out-of-date/X.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/X.h
@@ -0,0 +1 @@
+#import 
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,11 @@
 // Load the contents of the module
 if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
   // The buffer was already provided for us.
-  ModuleEntry->Buffer = std::move(Buffer);
+  ModuleEntry->Buffer = Buffer.get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(Buffer));
+} else if(llvm::MemoryBuffer *ConsistentB =
+  FileMgr.getPCMCache()->lookupConsistentBuffer(FileName)) {
+  ModuleEntry->Buffer = ConsistentB;
 } else {
   // Open the AST file.
   llvm::ErrorOr Buf(
@@ -131,7 +135,8 @@
 return Missing;
   }
 
-  ModuleEntry->Buffer = std::move(*Buf);
+  ModuleEntry->Buffer = (*Buf).get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(*Buf));
 }
 
 // Initialize the stream.
@@ -148,8 +153,11 @@
   ErrorStr = ModuleEntry->Signature != ASTFileSignature({{0}}) ?
  "signature mismatch" : "could not read module signature";
 
-  if (NewModule)
+  if (NewModule) {
+FileMgr.getPCMCache()->removeFromConsistentBuffer(
+ModuleEntry->FileName);
 delete ModuleEntry;
+  }
   return OutOfDate;
 }
   }
@@ -184,7 +192,8 @@
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl ,
-ModuleMap *modMap) {
+ModuleMap *modMap,
+llvm::SmallVectorImpl ) {
   if (first == last)
 return;
 
@@ -227,16 +236,76 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
-  FileMgr.invalidateCache((*victim)->File);
-
+if (LoadedSuccessfully.count(*victim) == 0) {
+  // Before removing the module file, check if it was validated in an
+  // ancestor 

[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: docs/UsersManual.rst:2130
+
+- x86 is used by some implementations that are x86 compatible
+  (e.g. `POCL `_) and currently remains for backwards

pekka.jaaskelainen wrote:
> Anastasia wrote:
> > pekka.jaaskelainen wrote:
> > > This is a bit confusing paragraph, probably due to my confusing 
> > > explanations of the problems with pocl. Currently pocl tries not to use 
> > > FASM for preserving logical AS IDs to LLVM IR due to the bunch of 
> > > problems it constantly produces with seemingly little benefits for common 
> > > CPUs. My patch related to this considered only the argument info switch. 
> > > Now pocl only derives the logical iDS from kernel arguments (and all 
> > > other IDs within the body of the IR function are lost for flat machines). 
> > >  In my patch, the argument info's address space IDs were made constant 
> > > and identical to SPIR's as previously they were the target's (which meant 
> > > losing the AS IDs altogether for flat AS machines).
> > > 
> > > You seem to document the arg-info md switch later, so this paragraph 
> > > might be removed or converted to my pocl blurb which mentions the need 
> > > for further processing for CPUs.
> > Yes, it's perhaps a bit confusing indeed. I find the usage of the x86 
> > backend for OpenCL is generally a bit confusing. Also there are a lot of 
> > program paths even in Clang that don't play well for OpenCL purposes or are 
> > not handled properly and are therefore a source of bugs.
> > 
> > I was just wondering whether it would be possible to switch to using SPIR 
> > as a generic target at some point in the future and "deprecate" the x86 
> > target for OpenCL . Do you think this might work for POCL? At the same time 
> > we have upcoming SPIR-V support as a new feature that might reshape things.
> > 
> > Regarding the address space I just know that it's common to use fake 
> > address space map with the x86 backend for some out of tree implementations 
> > to add missing memory segments to this target. That's why I added this text 
> > here.
> > 
> > 
> We have considered using SPIR internally, but it is likely to bring the same 
> problems as with the FASM as we need to convert to the target bitcode to 
> ensure all target specific IR level optimizations (especially vectorization) 
> is applied properly. Why do you think using the real target when generating 
> from OpenCL C kernels is problematic? 
Perhaps, it would be nice to understand better how you use x86 backend in your 
toolchain. What I have seen in some projects that some invalid IR was produced 
or Clang hit an asset in the place which has to be done differently in some 
CodeGen paths just for OpenCL. So the typical fix for this to specialize on the 
OpenCL is not that easy to get into upstream because the target hasn't been 
created for what it's being used for and people like to see more modular code 
in general anyways.

The target is ideally not just a processor architecture but a combination of 
hardware and runtime software layers (i.e. OpenCL runtime in our case). Btw 
what triple do you use exactly while compiling OpenCL for x86?



Comment at: docs/UsersManual.rst:2133
+
+- x86 is used by some implementations that are x86 compatible and currently
+  remains for backwards compatibility (with older implementations prior to

pekka.jaaskelainen wrote:
> ARM (and others) are treated similarly in pocl: OpenCL C is just yet another 
> frontend language in this picture, like C/C++. I would not "deprecate" that 
> path as of yet as forcing to another intermediate representation (which SPIR 
> basically is, albeit derived from LLVM IR) always loses some information on 
> the way.
I have removed the deprecation bit from the documentation now. Do you want me 
to change anything else here?

I think the idea of SPIR target was not to force the developers to yet another 
IR but rather to create a common generic target that is specifically tailored 
to OpenCL needs (not just as a language but RT as well). Also the intention of 
SPIR was to add missing semantics of OpenCL to LLVM IR, so it's supposed not to 
lose the information ideally even though I am not completely sure the goal was 
achieved. But since SPIR-V is gaining more popularity I am not sure how much 
SPIR will continue to be relevant in the community.

One more problem with x86 target is that there are currently not many 
contributors in the community that are willing to support it for OpenCL. That's 
why I am a bit reluctant to put it in the document as fully supported target. 
Do you have any relevant fixes in your internal branches btw? 


https://reviews.llvm.org/D28080



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


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 84136.
Anastasia added a comment.

Update based on comments from Pekka.


https://reviews.llvm.org/D28080

Files:
  docs/UsersManual.rst
  www/index.html

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -41,6 +41,7 @@
variants depending on base language.
 -  :ref:`C++ Language `
 -  :ref:`Objective C++ Language `
+-  :ref:`OpenCL C Language `: v1.0, v1.1, v1.2, v2.0.
 
 In addition to these base languages and their dialects, Clang supports a
 broad variety of language extensions, which are documented in the
@@ -1973,6 +1974,365 @@
  is provided or target does not support TLS, code generation for threadprivate
  variables relies on OpenMP runtime library.
 
+.. _opencl:
+
+OpenCL Features
+===
+
+Clang can be used to compile OpenCL kernels for execution on a device
+(e.g. GPU). It is possible to compile the kernel into a binary (e.g. for AMD or
+Nvidia targets) that can be uploaded to run directly on a device (e.g. using
+`clCreateProgramWithBinary
+`_) or
+into generic bitcode files loadable into other toolchains.
+
+Compiling to a binary using the default target from the installation can be done
+as follows:
+
+   .. code-block:: console
+
+ $ echo "kernel void k(){}" > test.cl
+ $ clang test.cl
+
+Compiling for a specific target can be done by specifying the triple corresponding
+to the target, for example:
+
+   .. code-block:: console
+
+ $ clang -target nvptx64-unknown-unknown test.cl
+ $ clang -target amdgcn-amd-amdhsa-opencl test.cl
+
+Compiling to bitcode can be done as follows:
+
+   .. code-block:: console
+
+ $ clang -c -emit-llvm test.cl
+
+This will produce a generic test.bc file that can be used in vendor toolchains
+to perform machine code generation.
+
+Clang currently supports OpenCL C language standards up to v2.0.
+
+OpenCL Specific Options
+---
+
+Most of the OpenCL build options from `the specification v2.0 section 5.8.4
+`_ are available.
+
+Examples:
+
+   .. code-block:: console
+
+ $ clang -cl-std=CL2.0 -cl-single-precision-constant test.cl
+
+Some extra options are available to support special OpenCL features.
+
+.. option:: -finclude-default-header
+
+Loads standard includes during compilations. By default OpenCL headers are not
+loaded and therefore standard library includes are not available. To load them
+automatically a flag has been added to the frontend (see also :ref:`the section
+on the OpenCL Header `):
+
+   .. code-block:: console
+
+ $ clang -Xclang -finclude-default-header test.cl
+
+Alternatively ``-include`` or ``-I`` followed by the path to the header location
+can be given manually.
+
+   .. code-block:: console
+
+ $ clang -I/lib/Headers/opencl-c.h test.cl
+
+In this case the kernel code should contain ``#include `` just as a
+regular C include.
+
+.. option:: -cl-ext
+
+Disables support of OpenCL extensions. All OpenCL targets provide a list
+of extensions that they support. Clang allows to amend this using the ``-cl-ext``
+flag with a comma-separated list of extensions prefixed with ``'+'`` or ``'-'``.
+The syntax: ``-cl-ext=<(['-'|'+'][,])+>``,  where extensions
+can be either one of `the OpenCL specification extensions
+`_
+or any known vendor extension. Alternatively, ``'all'`` can be used to enable
+or disable all known extensions.
+Example disabling double support for the 64-bit SPIR target:
+
+   .. code-block:: console
+
+ $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl
+
+Enabling all extensions except double support in R600 AMD GPU can be done using:
+
+   .. code-block:: console
+
+ $ clang -cc1 -triple r600-unknown-unknown -cl-ext=-all,+cl_khr_fp16 test.cl
+
+.. _opencl_fake_address_space_map:
+
+.. option:: -ffake-address-space-map
+
+Overrides the target address space map with a fake map.
+This allows adding explicit address space IDs to the bitcode for non-segmented
+memory architectures that don't have separate IDs for each of the OpenCL
+logical address spaces by default. Passing ``-ffake-address-space-map`` will
+add/override address spaces of the target compiled for with the following values:
+``1-global``, ``2-constant``, ``3-local``, ``4-generic``. The private address
+space is represented by the absence of an address space attribute in the IR (see
+also :ref:`the section on the address space attribute `).
+
+   .. code-block:: console
+
+ $ clang -ffake-address-space-map test.cl
+
+Some other flags used for the compilation for C can also be passed while
+compiling for OpenCL, examples: ``-c``, ``-O<1-4|s>``, ``-o``, ``-emit-llvm``, etc.
+
+OpenCL Targets
+--
+
+OpenCL targets are 

[PATCH] D28614: [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

2017-01-12 Thread Mads Ravn via Phabricator via cfe-commits
madsravn added a comment.

Looks good to me.


https://reviews.llvm.org/D28614



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


[PATCH] D28614: [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: madsravn, aaron.ballman, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: JDevlieghere.

https://reviews.llvm.org/rL270567 excluded trivially copyable types from being 
moved by
modernize-pass-by-value, but it didn't exclude references to them.
Change types used in the tests to not be trivially copyable.


https://reviews.llvm.org/D28614

Files:
  clang-tidy/modernize/PassByValueCheck.cpp
  test/clang-tidy/Inputs/modernize-pass-by-value/header.h
  test/clang-tidy/modernize-pass-by-value-header.cpp
  test/clang-tidy/modernize-pass-by-value-macro-header.cpp
  test/clang-tidy/modernize-pass-by-value.cpp


Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -2,8 +2,15 @@
 
 namespace {
 // POD types are trivially move constructible.
+struct POD {
+  int a, b, c;
+};
+
 struct Movable {
   int a, b, c;
+  Movable() = default;
+  Movable(const Movable &) {}
+  Movable(Movable &&) {}
 };
 
 struct NotMovable {
@@ -147,7 +154,8 @@
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-FIXES: O(Movable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
   Movable M;
 };
 
@@ -179,7 +187,8 @@
 }
 struct R {
   R(ns_R::RMovable M) : M(M) {}
-  // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
   ns_R::RMovable M;
 };
 
@@ -199,3 +208,8 @@
   // CHECK-FIXES: T(array a) : a_(a) {}
   array a_;
 };
+
+struct U {
+  U(const POD ) : M(M) {}
+  POD M;
+};
Index: test/clang-tidy/modernize-pass-by-value-macro-header.cpp
===
--- test/clang-tidy/modernize-pass-by-value-macro-header.cpp
+++ test/clang-tidy/modernize-pass-by-value-macro-header.cpp
@@ -6,6 +6,8 @@
 #include HEADER
 
 struct A {
+  A(const A &) {}
+  A(A &&) {}
 };
 
 struct B {
Index: test/clang-tidy/modernize-pass-by-value-header.cpp
===
--- test/clang-tidy/modernize-pass-by-value-header.cpp
+++ test/clang-tidy/modernize-pass-by-value-header.cpp
@@ -3,6 +3,6 @@
 // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
 
 #include "pass-by-value-header.h"
-// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
 // CHECK-FIXES: #include 
 // CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}
Index: test/clang-tidy/Inputs/modernize-pass-by-value/header.h
===
--- test/clang-tidy/Inputs/modernize-pass-by-value/header.h
+++ test/clang-tidy/Inputs/modernize-pass-by-value/header.h
@@ -1,4 +1,7 @@
 class ThreadId {
+public:
+  ThreadId(const ThreadId &) {}
+  ThreadId(ThreadId &&) {}
 };
 
 struct A {
Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -188,7 +188,8 @@
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
   // copyable type will cause a problem with misc-move-const-arg
-  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+  if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
+  *Result.Context))
 return;
 
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");


Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -2,8 +2,15 @@
 
 namespace {
 // POD types are trivially move constructible.
+struct POD {
+  int a, b, c;
+};
+
 struct Movable {
   int a, b, c;
+  Movable() = default;
+  Movable(const Movable &) {}
+  Movable(Movable &&) {}
 };
 
 struct NotMovable {
@@ -147,7 +154,8 @@
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-FIXES: O(Movable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
   Movable M;
 };
 
@@ -179,7 +187,8 @@
 }
 struct R {
   R(ns_R::RMovable M) : M(M) {}
-  // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
   ns_R::RMovable M;
 };
 
@@ -199,3 +208,8 @@
   

r291775 - Revert r291774 which caused buildbot failure.

2017-01-12 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Jan 12 10:56:18 2017
New Revision: 291775

URL: http://llvm.org/viewvc/llvm-project?rev=291775=rev
Log:
Revert r291774 which caused buildbot failure.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291775=291774=291775=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 12 10:56:18 2017
@@ -862,8 +862,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
 }
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
-  std::unique_ptr OS,
-  std::string SampleProfile) {
+  std::unique_ptr OS) {
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -931,7 +930,6 @@ static void runThinLTOBackend(ModuleSumm
 return llvm::make_unique(std::move(OS));
   };
   lto::Config Conf;
-  Conf.SampleProfile = SampleProfile;
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -967,8 +965,7 @@ void clang::EmitBackendOutput(Diagnostic
 // of an error).
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
-CGOpts.SampleProfileFile);
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
   return;
 }
   }

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291775=291774=291775=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Thu Jan 12 10:56:18 2017
@@ -8,10 +8,6 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
 
-; Ensure sample profile pass are passed to backend
-; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof -mllvm -debug-pass=Structure 
2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
-; CHECK-SAMPLEPGO: Sample profile pass
-
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'


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


r291774 - Pass -fprofile-sample-use to lto backends.

2017-01-12 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Jan 12 10:29:25 2017
New Revision: 291774

URL: http://llvm.org/viewvc/llvm-project?rev=291774=rev
Log:
Pass -fprofile-sample-use to lto backends.

Summary: LTO backend will not invoke SampleProfileLoader pass even if 
-fprofile-sample-use is specified. This patch passes the flag down so that pass 
manager can add the SampleProfileLoader pass correctly.

Reviewers: mehdi_amini, tejohnson

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28588

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291774=291773=291774=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan 12 10:29:25 2017
@@ -862,7 +862,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
 }
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
-  std::unique_ptr OS) {
+  std::unique_ptr OS,
+  std::string SampleProfile) {
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -930,6 +931,7 @@ static void runThinLTOBackend(ModuleSumm
 return llvm::make_unique(std::move(OS));
   };
   lto::Config Conf;
+  Conf.SampleProfile = SampleProfile;
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -965,7 +967,8 @@ void clang::EmitBackendOutput(Diagnostic
 // of an error).
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
+CGOpts.SampleProfileFile);
   return;
 }
   }

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291774=291773=291774=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Thu Jan 12 10:29:25 2017
@@ -8,6 +8,10 @@
 ; RUN: not %clang_cc1 -O2 -o %t1.o -x c %s -c -fthinlto-index=%t.thinlto.bc 
2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
 ; CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only allowed 
with '-x ir'
 
+; Ensure sample profile pass are passed to backend
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof -mllvm -debug-pass=Structure 
2>&1 | FileCheck %s -check-prefix=CHECK-SAMPLEPGO
+; CHECK-SAMPLEPGO: Sample profile pass
+
 ; Ensure we get expected error for missing index file
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'


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


[libcxx] r291773 - Add new macro _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR to use in std::char_traits.

2017-01-12 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jan 12 10:25:07 2017
New Revision: 291773

URL: http://llvm.org/viewvc/llvm-project?rev=291773=rev
Log:
Add new macro _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR to use in std::char_traits. 
This tells whether or not the builtin function __builtin_memcmp is constexpr.
Only defined for clang 4.0 and later, and not true for any shipping version of 
Apple's clang.


Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291773=291772=291773=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Jan 12 10:25:07 2017
@@ -396,6 +396,15 @@ namespace std {
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
 #endif 
 
+// A constexpr version of __builtin_memcmp was added in clang 4.0
+#if __has_builtin(__builtin_memcmp)
+# ifdef __apple_build_version__
+// No shipping version of Apple's clang has constexpr __builtin_memcmp
+# elif __clang_major__ > 3
+#  define _LIBCPP_BUILTIN_MEMCMP_ISCONSTEXPR
+# endif
+#endif
+
 #elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))


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


[PATCH] D28610: [libcxx] Improve design documentation for the external-thread-library configuration

2017-01-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.

Trying to improve the documentation for the external-thread-library 
configuration of `libc++`.


https://reviews.llvm.org/D28610

Files:
  docs/DesignDocs/ThreadingSupportAPI.rst


Index: docs/DesignDocs/ThreadingSupportAPI.rst
===
--- docs/DesignDocs/ThreadingSupportAPI.rst
+++ docs/DesignDocs/ThreadingSupportAPI.rst
@@ -33,13 +33,22 @@
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
-
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+libc++ can be compiled with its internal threading API delegated to an external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
+
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading implementations available in ``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+paricular configuration of the library without being tied to a vendor-specific
+threading implementation. This option is only meant to be used by libc++ 
library
+developers.
 
 Threading Configuration Macros
 ==


Index: docs/DesignDocs/ThreadingSupportAPI.rst
===
--- docs/DesignDocs/ThreadingSupportAPI.rst
+++ docs/DesignDocs/ThreadingSupportAPI.rst
@@ -33,13 +33,22 @@
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
-
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+libc++ can be compiled with its internal threading API delegated to an external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
+
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading implementations available in ``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+paricular configuration of the library without being tied to a vendor-specific
+threading implementation. This option is only meant to be used by libc++ library
+developers.
 
 Threading Configuration Macros
 ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20428: Tracking exception specification source locations

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291771: Tracking exception specification source locations 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D20428?vs=83816=84127#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20428

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/TypeLoc.h
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/unittests/AST/SourceLocationTest.cpp

Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -629,6 +629,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -5990,6 +5990,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
+  TL.setExceptionSpecRange(SourceRange(Reader->ReadSourceLocation(*F, Record, Idx),
+   Reader->ReadSourceLocation(*F, Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, Reader->ReadDeclAs(*F, Record, Idx));
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -3544,7 +3544,7 @@
   Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
   NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
 } else {
-  NoexceptType = EST_None;
+  NoexceptType = EST_BasicNoexcept;
 }
   } else {
 // There is no argument.
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -2990,6 +2990,18 @@
   return RTRange;
 }
 
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+  const TypeSourceInfo *TSI = getTypeSourceInfo();
+  if (!TSI)
+return SourceRange();
+  FunctionTypeLoc FTL =
+TSI->getTypeLoc().IgnoreParens().getAs();
+  if (!FTL)
+return SourceRange();
+
+  return FTL.getExceptionSpecRange();
+}
+
 const Attr *FunctionDecl::getUnusedResultAttr() const {
   QualType RetType = getReturnType();
   if (RetType->isRecordType()) {
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5263,7 +5263,7 @@
 ParmVarDecl *Param = cast(FTI.Params[i].Param);
 TL.setParam(tpi++, Param);
   }
-  // FIXME: exception specs
+  TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
 }
 void VisitParenTypeLoc(ParenTypeLoc TL) {
   assert(Chunk.Kind == DeclaratorChunk::Paren);
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -5023,6 +5023,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
 NewTL.setParam(i, ParamDecls[i]);
Index: cfe/trunk/unittests/AST/SourceLocationTest.cpp
===
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp
@@ -670,5 +670,72 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc ) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+class ParmVarExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const ParmVarDecl ) override {
+if (const TypeSourceInfo *TSI = Node.getTypeSourceInfo()) {
+  TypeLoc TL = TSI->getTypeLoc();
+  if (TL.getType()->isPointerType()) {

r291771 - Tracking exception specification source locations

2017-01-12 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 12 10:11:28 2017
New Revision: 291771

URL: http://llvm.org/viewvc/llvm-project?rev=291771=rev
Log:
Tracking exception specification source locations

Summary:
We do not currently track the source locations for exception specifications such
that their source range can be queried through the AST. This leads to trying to
write more complex code to determine the source range for uses like FixItHints
(see D18575 for an example). In addition to use within tools like clang-tidy, I
think this information may become more important to track as exception
specifications become more integrated into the type system.

Patch by Don Hinton.

Reviewers: rsmith

Subscribers: malcolm.parsons, sbarzowski, alexfh, hintonda, cfe-commits

Differential Revision: https://reviews.llvm.org/D20428

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/unittests/AST/SourceLocationTest.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=291771=291770=291771=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Jan 12 10:11:28 2017
@@ -2061,6 +2061,10 @@ public:
   /// limited representation in the AST.
   SourceRange getReturnTypeSourceRange() const;
 
+  /// \brief Attempt to compute an informative source range covering the
+  /// function exception specification, if any.
+  SourceRange getExceptionSpecSourceRange() const;
+
   /// \brief Determine the type of an expression that calls this function.
   QualType getCallResultType() const {
 assert(getType()->getAs() && "Expected a FunctionType!");

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=291771=291770=291771=diff
==
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Thu Jan 12 10:11:28 2017
@@ -1351,6 +1351,19 @@ class FunctionTypeLoc : public ConcreteT
FunctionTypeLoc,
FunctionType,
FunctionLocInfo> {
+  bool hasExceptionSpec() const {
+if (auto *FPT = dyn_cast(getTypePtr())) {
+  return FPT->hasExceptionSpec();
+}
+return false;
+  }
+
+  SourceRange *getExceptionSpecRangePtr() const {
+assert(hasExceptionSpec() && "No exception spec range");
+// After the Info comes the ParmVarDecl array, and after that comes the
+// exception specification information.
+return (SourceRange *)(getParmArray() + getNumParams());
+  }
 public:
   SourceLocation getLocalRangeBegin() const {
 return getLocalData()->LocalRangeBegin;
@@ -1384,6 +1397,16 @@ public:
 return SourceRange(getLParenLoc(), getRParenLoc());
   }
 
+  SourceRange getExceptionSpecRange() const {
+if (hasExceptionSpec())
+  return *getExceptionSpecRangePtr();
+return SourceRange();
+  }
+  void setExceptionSpecRange(SourceRange R) {
+if (hasExceptionSpec())
+  *getExceptionSpecRangePtr() = R;
+  }
+
   ArrayRef getParams() const {
 return llvm::makeArrayRef(getParmArray(), getNumParams());
   }
@@ -1416,12 +1439,15 @@ public:
 setLocalRangeEnd(Loc);
 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
   setParam(i, nullptr);
+if (hasExceptionSpec())
+  setExceptionSpecRange(Loc);
   }
 
   /// \brief Returns the size of the type source info data block that is
   /// specific to this type.
   unsigned getExtraLocalDataSize() const {
-return getNumParams() * sizeof(ParmVarDecl *);
+unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
+return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
   }
 
   unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); 
}

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=291771=291770=291771=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Jan 12 10:11:28 2017
@@ -2990,6 +2990,18 @@ SourceRange FunctionDecl::getReturnTypeS
   return RTRange;
 }
 
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+  const TypeSourceInfo *TSI = getTypeSourceInfo();
+  if (!TSI)
+return SourceRange();
+  FunctionTypeLoc FTL =
+TSI->getTypeLoc().IgnoreParens().getAs();
+  if (!FTL)
+return SourceRange();

[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:26
+  auto explicit_initialized_value_used = [j = 1] { return j + 1; };
+  auto explicit_initialized_value_unused = [j = 1] {}; // 
expected-warning{{lambda capture 'j' is not used}}
+

aaron.ballman wrote:
> malcolm.parsons wrote:
> > Quuxplusone wrote:
> > > Would this still produce a diagnostic if `decltype(j)` were something 
> > > complicated like `lock_guard` or `string`? Presumably it should do the 
> > > same thing, more or less, as the other -Wunused diagnostics, which I 
> > > think is "don't warn if the constructor/destructor might actually do 
> > > important work".
> > I was planning to check for that; thanks for the reminder.
> One more complex case:
> ```
> #include 
> 
> struct B {
>   virtual ~B() = default;
> };
> 
> struct D : B {};
> 
> struct C {
>   B& get_d() const;
>   C get_c() const;
> };
> 
> void f() {
>   C c1, c2;
>   [c1, c2] {
> (void)typeid(c1.get_d());
> (void)typeid(c2.get_c());
>   }();
> }
> ```
> Hopefully this does not diagnose `c1` as being unused but still diagnoses 
> `c2` as unused.
These tests are run with `-nostdsysteminc`, so I ran it manually:
```
aaron.cpp:17:21: warning: expression with side effects will be evaluated 
despite being used as an operand to 'typeid'
  [-Wpotentially-evaluated-expression]
(void)typeid(c1.get_d());
^
aaron.cpp:16:8: warning: lambda capture 'c2' is not required to be captured for 
use in an unevaluated context [-Wunused-lambda-capture]
  [c1, c2] {
   ^
2 warnings generated.
```


https://reviews.llvm.org/D28467



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 84122.
malcolm.parsons marked 9 inline comments as done.
malcolm.parsons added a comment.

Improve warning message for use in unevaluated context.
Initialise used flags in constructors.


https://reviews.llvm.org/D28467

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLambda.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
  test/SemaCXX/uninitialized.cpp
  test/SemaCXX/warn-unused-lambda-capture.cpp

Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s
+
+class NonTrivialConstructor {
+public:
+  NonTrivialConstructor() {}
+};
+
+class NonTrivialDestructor {
+public:
+  ~NonTrivialDestructor() {}
+};
+
+class Trivial {
+public:
+  Trivial() = default;
+  Trivial(int a) {}
+};
+
+int side_effect() {
+  return 42;
+}
+
+void test() {
+  int i = 0;
+
+  auto captures_nothing = [] {};
+
+  auto captures_nothing_by_value = [=] {};
+  auto captures_nothing_by_reference = [&] {};
+
+  auto implicit_by_value = [=]() mutable { i++; };
+  auto implicit_by_reference = [&] { i++; };
+
+  auto explicit_by_value_used = [i] { return i + 1; };
+  auto explicit_by_value_used_void = [i] { (void)i; };
+  auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
+
+  auto explicit_by_reference_used = [] { i++; };
+  auto explicit_by_reference_unused = [] {}; // expected-warning{{lambda capture 'i' is not used}}
+
+  auto explicit_initialized_reference_used = [ = i] { return j + 1; };
+  auto explicit_initialized_reference_unused = [ = i]{}; // expected-warning{{lambda capture 'j' is not used}}
+
+  auto explicit_initialized_value_used = [j = 1] { return j + 1; };
+  auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}}
+  auto explicit_initialized_value_non_trivial_constructor = [j = NonTrivialConstructor()]{};
+  auto explicit_initialized_value_non_trivial_destructor = [j = NonTrivialDestructor()]{};
+  auto explicit_initialized_value_trivial_init = [j = Trivial()]{}; // expected-warning{{lambda capture 'j' is not used}}
+  auto explicit_initialized_value_non_trivial_init = [j = Trivial(42)]{};
+  auto explicit_initialized_value_with_side_effect = [j = side_effect()]{};
+
+  auto nested = [] {
+auto explicit_by_value_used = [i] { return i + 1; };
+auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
+  };
+}
+
+class Foo
+{
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+  }
+  int i;
+};
+
+template 
+void test_templated() {
+  int i = 0;
+
+  auto captures_nothing = [] {};
+
+  auto captures_nothing_by_value = [=] {};
+  auto captures_nothing_by_reference = [&] {};
+
+  auto implicit_by_value = [=]() mutable { i++; };
+  auto implicit_by_reference = [&] { i++; };
+
+  auto explicit_by_value_used = [i] { return i + 1; };
+  auto explicit_by_value_used_void = [i] { (void)i; };
+  auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for use in an unevaluated context}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is not used}}
+
+  auto explicit_by_reference_used = [] { i++; };
+  auto explicit_by_reference_unused = [] {}; // expected-warning{{lambda capture 'i' is not used}}
+
+  auto explicit_initialized_reference_used = [ = i] { return j + 1; };
+  auto explicit_initialized_reference_unused = [ = i]{}; // expected-warning{{lambda capture 'j' is not used}}
+
+  auto explicit_initialized_value_used = [j = 1] { return j + 1; };
+  auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not 

[PATCH] D26015: Correctly classify main file includes if there is a prefix added

2017-01-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

LG, committed as r291767.


Repository:
  rL LLVM

https://reviews.llvm.org/D26015



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


[PATCH] D26015: Correctly classify main file includes if there is a prefix added

2017-01-12 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291767: Correctly classify main file includes if there is a 
prefix added (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D26015?vs=84001=84121#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26015

Files:
  clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -73,6 +73,17 @@
   bool IsAngledInclude() const override { return false; }
 };
 
+class EarlyInAlphabetHeaderInserterCheck : public IncludeInserterCheckBase {
+public:
+  EarlyInAlphabetHeaderInserterCheck(StringRef CheckName, ClangTidyContext *Context)
+  : IncludeInserterCheckBase(CheckName, Context) {}
+
+  std::vector HeadersToInclude() const override {
+return {"a/header.h"};
+  }
+  bool IsAngledInclude() const override { return false; }
+};
+
 class MultipleHeaderInserterCheck : public IncludeInserterCheckBase {
 public:
   MultipleHeaderInserterCheck(StringRef CheckName, ClangTidyContext *Context)
@@ -114,6 +125,7 @@
"insert_includes_test_header.h",
"\n"},
   // Non system headers
+  {"a/header.h", "\n"},
   {"path/to/a/header.h", "\n"},
   {"path/to/z/header.h", "\n"},
   {"path/to/header.h", "\n"},
@@ -522,6 +534,77 @@
"insert_includes_test_header.cc"));
 }
 
+TEST(IncludeInserterTest, DontInsertDuplicateIncludeEvenIfMiscategorized) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, "workspace_folder/clang_tidy/tests/"
+   "insert_includes_test_header.cc"));
+}
+
+TEST(IncludeInserterTest, HandleOrderInSubdirectory) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, "workspace_folder/clang_tidy/tests/"
+   "insert_includes_test_header.cc"));
+}
+
 } // anonymous namespace
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
@@ -61,7 +61,8 @@
   : IncludeSorter::IK_CXXSystemInclude;
   }
   StringRef CanonicalInclude = MakeCanonicalName(IncludeFile, Style);
-  if (CanonicalFile.equals(CanonicalInclude)) {
+  if (CanonicalFile.endswith(CanonicalInclude)
+  || CanonicalInclude.endswith(CanonicalFile)) {
 return IncludeSorter::IK_MainTUInclude;
   }
   if (Style == IncludeSorter::IS_Google) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r291767 - Correctly classify main file includes if there is a prefix added

2017-01-12 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jan 12 09:31:50 2017
New Revision: 291767

URL: http://llvm.org/viewvc/llvm-project?rev=291767=rev
Log:
Correctly classify main file includes if there is a prefix added

Summary:
Prevents misclassifying includes based on the command-line filename (e.g. if a 
project is in a subdirectory).

This is slightly more robust than the additional duplicate detection, however 
the current classification scheme is still kind of brittle for a lot of code.

Reviewers: hokein, alexfh

Subscribers: cfe-commits, #clang-tools-extra

Patch by Julian Bangert!

Differential Revision: https://reviews.llvm.org/D26015

Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp?rev=291767=291766=291767=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeSorter.cpp Thu Jan 12 
09:31:50 2017
@@ -61,7 +61,8 @@ DetermineIncludeKind(StringRef Canonical
   : IncludeSorter::IK_CXXSystemInclude;
   }
   StringRef CanonicalInclude = MakeCanonicalName(IncludeFile, Style);
-  if (CanonicalFile.equals(CanonicalInclude)) {
+  if (CanonicalFile.endswith(CanonicalInclude)
+  || CanonicalInclude.endswith(CanonicalFile)) {
 return IncludeSorter::IK_MainTUInclude;
   }
   if (Style == IncludeSorter::IS_Google) {

Modified: clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp?rev=291767=291766=291767=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/IncludeInserterTest.cpp Thu 
Jan 12 09:31:50 2017
@@ -73,6 +73,17 @@ public:
   bool IsAngledInclude() const override { return false; }
 };
 
+class EarlyInAlphabetHeaderInserterCheck : public IncludeInserterCheckBase {
+public:
+  EarlyInAlphabetHeaderInserterCheck(StringRef CheckName, ClangTidyContext 
*Context)
+  : IncludeInserterCheckBase(CheckName, Context) {}
+
+  std::vector HeadersToInclude() const override {
+return {"a/header.h"};
+  }
+  bool IsAngledInclude() const override { return false; }
+};
+
 class MultipleHeaderInserterCheck : public IncludeInserterCheckBase {
 public:
   MultipleHeaderInserterCheck(StringRef CheckName, ClangTidyContext *Context)
@@ -114,6 +125,7 @@ std::string runCheckOnCode(StringRef Cod
"insert_includes_test_header.h",
"\n"},
   // Non system headers
+  {"a/header.h", "\n"},
   {"path/to/a/header.h", "\n"},
   {"path/to/z/header.h", "\n"},
   {"path/to/header.h", "\n"},
@@ -522,6 +534,77 @@ void foo() {
"insert_includes_test_header.cc"));
 }
 
+TEST(IncludeInserterTest, DontInsertDuplicateIncludeEvenIfMiscategorized) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, "workspace_folder/clang_tidy/tests/"
+   "insert_includes_test_header.cc"));
+}
+
+TEST(IncludeInserterTest, HandleOrderInSubdirectory) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+#include 
+
+#include "a/header.h"
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, "workspace_folder/clang_tidy/tests/"
+   "insert_includes_test_header.cc"));
+}
+
 } // anonymous namespace
 } // namespace tidy
 } // namespace clang



[PATCH] D20428: Tracking exception specification source locations

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D20428#644007, @hintonda wrote:

> Sorry, but I do not have commit access.


Ah! My apologies, I thought you did.

@malcolm.parsons, can you perform the commit? I'm traveling currently and can't 
do it myself right now.


https://reviews.llvm.org/D20428



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


[PATCH] D20428: Tracking exception specification source locations

2017-01-12 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Sorry, but I do not have commit access.


https://reviews.llvm.org/D20428



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


[PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:319
   InGroup, DefaultIgnore;
+def warn_unused_lambda_capture: Warning<"lambda capture %0 is not odr-used">,
+  InGroup, DefaultIgnore;

We do not use the term "odr-use" in any of our other frontend diagnostics; I 
don't think this is a term that users will actually understand. I think we 
should drop the term and just use "used".



Comment at: include/clang/Sema/ScopeInfo.h:457
+/// lambda.
+bool Used = false;
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > arphaman wrote:
> > > malcolm.parsons wrote:
> > > > Should this be moved into one of the `PointerIntPair`s?
> > > I'm not sure.. If we needed other capturing information in the future I 
> > > would say that this should be its own field, but I'm not aware of 
> > > anything else that's needed for this class. So I guess it would be better 
> > > to pack it into `VarAndNestedAndThis`, but I wouldn't say it's a deal 
> > > breaker.
> > I'm not keen on inconsistently initializating data members; can you perform 
> > this initialization in the constructor instead?
> I'm not keen on repeating the initialization in every constructor.
Consistency is the important bit (see the golden rule in 
http://llvm.org/docs/CodingStandards.html) -- if you want to move things to be 
in-class initializers, that would be a reasonable follow-up patch. For this 
patch, please put the initializer into the constructor.



Comment at: lib/Sema/SemaLambda.cpp:1479
 for (unsigned I = 0, N = LSI->Captures.size(); I != N; ++I, ++CurField) {
-  LambdaScopeInfo::Capture From = LSI->Captures[I];
+  LambdaScopeInfo::Capture  = LSI->Captures[I];
   assert(!From.isBlockCapture() && "Cannot capture __block variables");

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Why does `From` need to be a non-const reference?
> It's not related to the warning; it looks like an unnecessary copy.
Thanks for adding the `const` qualifier.



Comment at: test/SemaCXX/warn-unused-lambda-capture.cpp:17
+  auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 
'i' is not used}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not used}}
+

malcolm.parsons wrote:
> Quuxplusone wrote:
> > malcolm.parsons wrote:
> > > Quuxplusone wrote:
> > > > aaron.ballman wrote:
> > > > > This does not match the behavior for other -Wunused flags. e.g.,
> > > > > ```
> > > > > void f() {
> > > > >   int i;
> > > > >   (void)sizeof(i);
> > > > > }
> > > > > ```
> > > > > I don't think diagnosing this test case is correct.
> > > > I see some value to maybe diagnosing *something* here. For example, `[] 
> > > > { return sizeof(i); }` would produce the same result as `[i] { return 
> > > > sizeof(i); }` but with one fewer capture, so removing the `i` might be 
> > > > seen as an improvement.
> > > > 
> > > > But I'm not sure how to convey this information to the user. You could 
> > > > say "variable `i` used in unevaluated context refers to the `i` in the 
> > > > outer scope, not the captured `i`"... except that I think that would be 
> > > > false. Given that you *have* captured an `i`, `sizeof(i)` definitely 
> > > > refers to the captured one AFAIK. The fact that the captured `i` 
> > > > shadows an `i` in the outer scope is irrelevant --- in fact the user is 
> > > > *expecting* to shadow the outer `i`.
> > > > 
> > > > Perhaps it would be appropriate to reword the diagnostic to "lambda 
> > > > captures variable `i` unnecessarily".  I would also lean toward 
> > > > splitting it into two diagnostics — one for "this capture is 
> > > > unnecessary" (as in this example) and one for "this capture doesn't 
> > > > even appear lexically in the body of the lambda". Not sure how other 
> > > > people would feel about that.
> > > > 
> > > > You should add some test cases with `decltype(i)` for the same reason 
> > > > as `sizeof(i)`.
> > > Does "lambda capture 'i' is not odr-used" make more sense?
> > > Does "lambda capture 'i' is not odr-used" make more sense?
> > 
> > That would completely satisfy *me*, for what that's worth. It admittedly 
> > doesn't match the other -Wunused diagnostics, but it is concise and correct 
> > — at least I assume it's correct. :)
> C++14 [expr.prim.lambda]p18:
> 
> > [ Note: An id-expression that is not an odr-use refers to the original 
> > entity, never to a member
> > of the closure type. Furthermore, such an id-expression does not cause the 
> > implicit capture of the entity.
> > — end note ]
Yes, that is correct; it's just incredibly confusing to most mortal 
programmers. Perhaps instead we can add extra information to the diagnostic 
telling the user that the variable need not be captured when it's in an 
unevaluated context (if possible). e.g.,

"lambda 

[PATCH] D28608: [libcxx] Don't assume __libcpp_thread_t is an integral type.

2017-01-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: compnerd, EricWF.
rmaprath added a subscriber: cfe-commits.

We have refactored the underlying platform thread type into 
`__libcpp_thread_t`, but there are few places in the source where it is assumed 
to be an integral type.

This was discovered while trying to port `libcxx` onto a platform with a 
slightly wonkier threading system.


https://reviews.llvm.org/D28608

Files:
  include/__threading_support
  include/thread


Index: include/thread
===
--- include/thread
+++ include/thread
@@ -290,7 +290,7 @@
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template (data.__func(data.__arg));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {


Index: include/thread
===
--- include/thread
+++ include/thread
@@ -290,7 +290,7 @@
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template (data.__func(data.__arg));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >