Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-20 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 64642.
courbet added a comment.

rebase


https://reviews.llvm.org/D21992

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
  test/clang-tidy/cppcoreguidelines-slicing.cpp

Index: test/clang-tidy/cppcoreguidelines-slicing.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-slicing.cpp
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-slicing %t
+
+class Base {
+  int i;
+  void f() {}
+  virtual void g() {}
+};
+
+class DerivedWithMemberVariables : public Base {
+  void f();
+  int j;
+};
+
+class TwiceDerivedWithNoMemberVariables : public DerivedWithMemberVariables {
+  void f();
+};
+
+class DerivedWithOverride : public Base {
+  void f();
+  void g() override {}
+};
+
+class TwiceDerivedWithNoOverride : public DerivedWithOverride {
+  void f();
+};
+
+void TakesBaseByValue(Base base);
+
+DerivedWithMemberVariables ReturnsDerived();
+
+void positivesWithMemberVariables() {
+  DerivedWithMemberVariables b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state [cppcoreguidelines-slicing]
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+
+  TwiceDerivedWithNoMemberVariables c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'TwiceDerivedWithNoMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+
+  a = ReturnsDerived();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards 4*sizeof(char) bytes of state
+}
+
+void positivesWithOverride() {
+  DerivedWithOverride b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+
+  TwiceDerivedWithNoOverride c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+}
+
+void TakesBaseByReference(Base &base);
+
+class DerivedThatAddsVirtualH : public Base {
+  virtual void h();
+};
+
+class DerivedThatOverridesH : public DerivedThatAddsVirtualH {
+  void h() override;
+};
+
+void negatives() {
+  // OK, simple copying from the same type.
+  Base a;
+  TakesBaseByValue(a);
+  DerivedWithMemberVariables b;
+  DerivedWithMemberVariables c{b};
+  b = c;
+
+  // OK, derived type does not have extra state.
+  TwiceDerivedWithNoMemberVariables d;
+  DerivedWithMemberVariables e{d};
+  e = d;
+
+  // OK, derived does not override any method.
+  TwiceDerivedWithNoOverride f;
+  DerivedWithOverride g{f};
+  g = f;
+
+  // OK, no copying.
+  TakesBaseByReference(d);
+  TakesBaseByReference(f);
+
+  // Derived type overrides methods, but these methods are not in the base type,
+  // so cannot be called accidentally. Right now this triggers, but we might
+  // want to allow it.
+  DerivedThatOverridesH h;
+  a = h;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedThatOverridesH' to 'Base' discards override 'h'
+}
Index: docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - cppcoreguidelines-slicing
+
+cppcoreguidelines-slicing
+=
+
+Flags slicing of member variables or vtable. Slicing happens when copying a
+derived object into a base object: the members of the derived object (both
+member variables and virtual member functions) will be discarded.
+This can be misleading especially for member function slicing, for example:
+
+.. code:: c++
+
+	struct B { int a; virtual int f(); };
+	struct D : B { int b; int f() override; };
+	void use(B b) {  // Missing reference, intended ?
+	  b.f();  // Calls B::f.
+	}
+	D d;
+	use(d);  // Slice.
+
+See the relevant CppCoreGuidelines sections for details:
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
+https://github.com/isoc

Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-20 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:30
@@ +29,3 @@
+  //   or
+  //   - B does not define any additional members (either variables or
+  //   overrides) wrt A.

What is A and what is B? I guess you are missing very important fact, that A is 
a base class of B


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.h:19
@@ +18,3 @@
+
+/// Flags slicing of member variables or vtable. See:
+///   -

some short description what does this check do?


https://reviews.llvm.org/D21992



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-20 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In https://reviews.llvm.org/D22463#489461, @rengolin wrote:

> You will not be required to use submodules at all, as we'll all use the 
> individual projects, like we have always been. I don't understand why people 
> keep going back to it.


There is a key use case that is not supported by the current setup.  This is 
something that I -- and basically anyone who works on an llvm project other 
than llvm itself -- do every day.  It will be supported with submodules, but 
badly.  It is not supported at all today, and it will not be supported at all 
in the proposed world if I don't use submodules.  Maybe the people who keep 
coming back to this have not explained this use-case clearly, so let me try.

The use-case is: Maintaining a branch which contains changes to clang (or your 
favorite subproject) and also is locked to a specific revision of llvm.  That 
is, I can check out branch A or branch B of my changes to clang, and it 
automatically checks out a corresponding revision of llvm that is tied to the 
branch.

Again, we can make this work with submodules, but it's a giant pain, see my 
earlier comment.  It works with zero effort if we have a monolithic repository. 
 This would be 'uge for anyone who works on clang (or any other subproject 
that's not llvm itself) and uses branches.

> Having a single repository was part of the original proposal for years, and 
> every time it was shot down as impractical.


I've read as many of these as I can find in the past few hours, and every 
argument I have found is, in my evaluation, very likely overblown or incorrect. 
 There is strong evidence for this, in the single git repository that already 
exists (and includes the test-suite, so is much larger than what I propose), 
and also in the fact that adding everything to a single git repository will not 
more than ~double the size of the llvm git repo.  (I'll have better numbers 
tomorrow, don't quote me on that just yet.)

Moreover, the current setup of unrelated git repos can be *exactly duplicated* 
by making sparse checkouts of the monolithic repository.  You can clone the big 
repo and then check out only the directories you want (so it's like the others 
never existed, beyond their presence in your .git packfiles).  Or if you want 
to be able to check out different revisions of (say) clang and llvm, you can do 
that too: Clone the big repo and make two shallow working copies, one for llvm 
and the other for clang.  You can even place the clang working copy in 
tools/clang of the llvm working copy, so it functions identically to the 
current setup in almost every way.

The critical point is that it's trivial to use sparse checkouts to make the 
monolithic repository behave identically to separate repos.  But it is 
impossible, as far as I'm aware, to make separate repos behave like a 
monolithic repository.  So the monolithic repository is strictly more powerful.

> Indeed, this is not the place for such discussion, but unless you can finish 
> the discussion thus week, I suggest you make you point clear in the survey 
> instead of delaying the process.


The e-mail you sent out two days ago said two weeks.  Can you give me a bit 
more than three days?

> I'm not pushing for *my* solution. Thus *has* been discussed already to 
> exhaustion. The current agreement was that we'd do a survey on the proposal, 
> and that's what we need to do. Anything else will just send us back to square 
> one and I seriously don't have the stamina to keep going round in circles.

> 

> Ie. Please, try to be considerate.


I am very grateful for the work that you're doing here.  I have participated in 
efforts very similar to this one in the past, and I appreciate how difficult 
and taxing they can be, and also how frustrating it can be to be see perfect be 
made the enemy of the good.  In fact I quit my last job in part over friction 
created by a botched move to git.

But.  I would ask you to please give me a few days to work with the community 
to dig in to this specific question.  If I am right, it will be a boon for all 
of us every time we type a command that starts with "git".  And if I'm wrong, 
I'll buy you a well-deserved beer or three, and we'll forget it and move on.

Does that sound agreeable to you?


https://reviews.llvm.org/D22463



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


Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-20 Thread Clement Courbet via cfe-commits
courbet marked an inline comment as done.


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.h:19
@@ +18,3 @@
+
+/// Flags slicing of member variables or vtable. See:
+///   -

Prazek wrote:
> some short description what does this check do?
There is already a more detialed explanation provided in 
extra/clang-tidy/checks/cppcoreguidelines-slicing.html, and I feel that the 
links explain it better than anything short we could put in the comments there. 
Or should I copy-paste what's in 
extra/clang-tidy/checks/cppcoreguidelines-slicing.html ?


https://reviews.llvm.org/D21992



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


Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-07-20 Thread Elena Demikhovsky via cfe-commits
delena added a comment.

#include in the test is not clear for me. Does it mean that you 
broke backward compatibility?



Comment at: lib/CodeGen/CGBuiltin.cpp:6779
@@ -6776,1 +6778,3 @@
   }
+  case X86::BI__builtin_ia32_xgetbv: {
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);

remove {}


Comment at: lib/Headers/intrin.h:905
@@ -906,9 +904,3 @@
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {

I'm not sure that we can move it from one file to another. And what was wrong 
with current implementation.


https://reviews.llvm.org/D21959



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-20 Thread Renato Golin via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D22463#489483, @jlebar wrote:

> Again, we can make this work with submodules, but it's a giant pain, see my 
> earlier comment.


(...)

> I've read as many of these as I can find in the past few hours, and every 
> argument I have found is, in my evaluation, very likely overblown or 
> incorrect.


We've heard both sides making equal claims. People work differently.

> The critical point is that it's trivial to use sparse checkouts to make the 
> monolithic repository behave identically to separate repos.  But it is 
> impossible, as far as I'm aware, to make separate repos behave like a 
> monolithic repository.  So the monolithic repository is strictly more 
> powerful.


LLVM is *not* a single project, but a large selection of smaller ones that 
*are* used independently by the *majority* of users. It may tax you more than 
others, but it will tax the majority less than today's solution.

This is not about finding the best possible way for everyone, since that's 
clearly impossible. This is about finding the least horrible solution for the 
majority.

> The e-mail you sent out two days ago said two weeks.  Can you give me a bit 
> more than three days?


Moving to Git has been in discussion for at least 2 years.

This time round, my first email with a concrete proposal to migrate was 2nd 
June. We had so far 320+ emails about the subject since, and the overwhelming 
majority is in favour to move to Git and a large part is *content* with 
sub-modules. Counter proposals were presented (including a monolithic 
repository) and were all shot down by the community (not me).

This is not the time to be second guessing ourselves. I'll be finishing this 
proposal this week and asking the foundation to put up a survey as soon as 
possible.

> But.  I would ask you to please give me a few days to work with the community 
> to dig in to this specific question.  If I am right, it will be a boon for 
> all of us every time we type a command that starts with "git".  And if I'm 
> wrong, I'll buy you a well-deserved beer or three, and we'll forget it and 
> move on.


A monolithic repository was proposed and discredited by the community. I can't 
vouch for it myself (in the interest of progress), but we *will* allow people 
to add comments on the survey. If there is a sound opposition to sub-modules in 
the survey, and a solid proposal to use a monolithic repo instead, we'll go to 
the next cycle, in which case, I'll politely step down and let other people in 
charge (whomever wants it).

All in all, we (for any definition of "we") are not going to force anyone to do 
anything they don't want. But as a community, we really should be thinking 
about the whole process, not just a single use case.


https://reviews.llvm.org/D22463



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


[clang-tools-extra] r276096 - [include-fixer] Tweak: remove unintended const.

2016-07-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jul 20 04:00:22 2016
New Revision: 276096

URL: http://llvm.org/viewvc/llvm-project?rev=276096&view=rev
Log:
[include-fixer] Tweak: remove unintended const.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=276096&r1=276095&r2=276096&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Wed Jul 20 
04:00:22 2016
@@ -76,7 +76,7 @@ std::string createQualifiedNameForReplac
 
 IncludeFixerContext::IncludeFixerContext(
 const QuerySymbolInfo &QuerySymbol,
-const std::vector Symbols)
+std::vector Symbols)
 : MatchedSymbols(std::move(Symbols)), QuerySymbol(QuerySymbol) {
   for (const auto &Symbol : MatchedSymbols) {
 HeaderInfos.push_back(

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h?rev=276096&r1=276095&r2=276096&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h Wed Jul 20 
04:00:22 2016
@@ -47,7 +47,7 @@ public:
 
   IncludeFixerContext() = default;
   IncludeFixerContext(const QuerySymbolInfo &QuerySymbol,
-  const std::vector Symbols);
+  std::vector Symbols);
 
   /// \brief Get symbol name.
   llvm::StringRef getSymbolIdentifier() const {


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


[clang-tools-extra] r276098 - [include-fixer] Make error messages a bit prettier and make sure to

2016-07-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jul 20 04:12:19 2016
New Revision: 276098

URL: http://llvm.org/viewvc/llvm-project?rev=276098&view=rev
Log:
[include-fixer] Make error messages a bit prettier and make sure to
include a newline at the end.

Modified:
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=276098&r1=276097&r2=276098&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed Jul 20 
04:12:19 2016
@@ -335,7 +335,8 @@ int includeFixerMain(int argc, const cha
 
   auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
   if (!Buffer) {
-errs() << "Couldn't open file: " << FilePath;
+errs() << "Couldn't open file: " << FilePath << ": "
+   << Buffer.getError().message() << '\n';
 return 1;
   }
 
@@ -349,7 +350,8 @@ int includeFixerMain(int argc, const cha
   }
 
   if (!Quiet)
-llvm::errs() << "Added #include" << 
Context.getHeaderInfos().front().Header;
+errs() << "Added #include " << Context.getHeaderInfos().front().Header
+   << '\n';
 
   // Add missing namespace qualifiers to the unidentified symbol.
   Replacements->insert({FilePath, Context.getSymbolRange().getOffset(),


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


Re: [PATCH] D22465: [clang-rename] introduce better symbol finding and add few more tests

2016-07-20 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Can anyone please take a look at this?

My current work is based on this patch and I'd be happy to know I'm doing 
things right :)


https://reviews.llvm.org/D22465



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


r276102 - [X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR

2016-07-20 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jul 20 05:18:01 2016
New Revision: 276102

URL: http://llvm.org/viewvc/llvm-project?rev=276102&view=rev
Log:
[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic 
IR

D20859 and D20860 attempted to replace the SSE (V)CVTTPS2DQ and VCVTTPD2DQ 
truncating conversions with generic IR instead.

It turns out that the behaviour of these intrinsics is different enough from 
generic IR that this will cause problems, INF/NAN/out of range values are 
guaranteed to result in a 0x8000 value - which plays havoc with constant 
folding which converts them to either zero or UNDEF. This is also an issue with 
the scalar implementations (which were already generic IR and what I was trying 
to match).

This patch changes both scalar and packed versions back to using x86-specific 
builtins.

It also deals with the other scalar conversion cases that are runtime rounding 
mode dependent and can have similar issues with constant folding.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=276102&r1=276101&r2=276102&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jul 20 05:18:01 2016
@@ -303,7 +303,9 @@ TARGET_BUILTIN(__builtin_ia32_pabsd128,
 TARGET_BUILTIN(__builtin_ia32_ldmxcsr, "vUi", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_stmxcsr, "Ui", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si64, "LLiV4f", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvttss2si64, "LLiV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "", "sse")
@@ -328,8 +330,12 @@ TARGET_BUILTIN(__builtin_ia32_cvtpd2dq,
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps, "V4fV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq, "V4iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si, "iV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttsd2si, "iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si64, "LLiV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttsd2si64, "LLiV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvtsd2ss, "V4fV4fV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq, "V4iV4f", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttps2dq, "V4iV4f", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_clflush, "vvC*", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
@@ -455,7 +461,9 @@ TARGET_BUILTIN(__builtin_ia32_cmpss, "V4
 TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cvttpd2dq256, "V4iV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2dq256, "V4iV4d", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_cvttps2dq256, "V8iV8f", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_pd256, "V4dV4dV4dIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_ps256, "V8fV8fV8fIc", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_si256, "V8iV8iV8iIc", "", "avx")

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=276102&r1=276101&r2=276102&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Wed Jul 20 05:18:01 2016
@@ -2117,7 +2117,7 @@ _mm256_cvtps_pd(__m128 __a)
 static __inline __m128i __DEFAULT_FN_ATTRS
 _mm256_cvttpd_epi32(__m256d __a)
 {
-  return (__m128i)__builtin_convertvector((__v4df) __a, __v4si);
+  return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a);
 }
 
 static __inline __m128i __DEFAULT_FN_ATTRS
@@ -2129,7 +2129,7 @@ _mm256_cvtpd_epi32(__m256d __a)
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_cvttps_epi32(__m256 __a)
 {
-  return (__m256i)__builtin_convertvector((__v8sf) __a, __v8si);
+  return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
 }
 
 static __inline double __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=276102&r1=276101&r

Re: [PATCH] D22105: [X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR

2016-07-20 Thread Simon Pilgrim via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276102: [X86][SSE] Reimplement SSE fp2si conversion 
intrinsics instead of using… (authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D22105?vs=64534&id=64653#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22105

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/avxintrin.h
  cfe/trunk/lib/Headers/emmintrin.h
  cfe/trunk/lib/Headers/xmmintrin.h
  cfe/trunk/test/CodeGen/avx-builtins.c
  cfe/trunk/test/CodeGen/builtins-x86.c
  cfe/trunk/test/CodeGen/sse-builtins.c
  cfe/trunk/test/CodeGen/sse2-builtins.c

Index: cfe/trunk/lib/Headers/xmmintrin.h
===
--- cfe/trunk/lib/Headers/xmmintrin.h
+++ cfe/trunk/lib/Headers/xmmintrin.h
@@ -1350,7 +1350,7 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_cvttss_si32(__m128 __a)
 {
-  return __a[0];
+  return __builtin_ia32_cvttss2si((__v4sf)__a);
 }
 
 /// \brief Converts a float value contained in the lower 32 bits of a vector of
@@ -1386,7 +1386,7 @@
 static __inline__ long long __DEFAULT_FN_ATTRS
 _mm_cvttss_si64(__m128 __a)
 {
-  return __a[0];
+  return __builtin_ia32_cvttss2si64((__v4sf)__a);
 }
 
 /// \brief Converts two low-order float values in a 128-bit vector of
Index: cfe/trunk/lib/Headers/avxintrin.h
===
--- cfe/trunk/lib/Headers/avxintrin.h
+++ cfe/trunk/lib/Headers/avxintrin.h
@@ -2117,7 +2117,7 @@
 static __inline __m128i __DEFAULT_FN_ATTRS
 _mm256_cvttpd_epi32(__m256d __a)
 {
-  return (__m128i)__builtin_convertvector((__v4df) __a, __v4si);
+  return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a);
 }
 
 static __inline __m128i __DEFAULT_FN_ATTRS
@@ -2129,7 +2129,7 @@
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_cvttps_epi32(__m256 __a)
 {
-  return (__m256i)__builtin_convertvector((__v8sf) __a, __v8si);
+  return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
 }
 
 static __inline double __DEFAULT_FN_ATTRS
Index: cfe/trunk/lib/Headers/emmintrin.h
===
--- cfe/trunk/lib/Headers/emmintrin.h
+++ cfe/trunk/lib/Headers/emmintrin.h
@@ -417,8 +417,7 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_cvtsd_ss(__m128 __a, __m128d __b)
 {
-  __a[0] = __b[0];
-  return __a;
+  return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
@@ -444,7 +443,7 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_cvttsd_si32(__m128d __a)
 {
-  return __a[0];
+  return __builtin_ia32_cvttsd2si((__v2df)__a);
 }
 
 static __inline__ __m64 __DEFAULT_FN_ATTRS
@@ -1707,7 +1706,7 @@
 static __inline__ long long __DEFAULT_FN_ATTRS
 _mm_cvttsd_si64(__m128d __a)
 {
-  return __a[0];
+  return __builtin_ia32_cvttsd2si64((__v2df)__a);
 }
 #endif
 
@@ -1755,7 +1754,7 @@
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvttps_epi32(__m128 __a)
 {
-  return (__m128i)__builtin_convertvector((__v4sf)__a, __v4si);
+  return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a);
 }
 
 /// \brief Returns a vector of [4 x i32] where the lowest element is the input
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -303,7 +303,9 @@
 TARGET_BUILTIN(__builtin_ia32_ldmxcsr, "vUi", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_stmxcsr, "Ui", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si64, "LLiV4f", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvttss2si64, "LLiV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "", "sse")
@@ -328,8 +330,12 @@
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps, "V4fV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq, "V4iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si, "iV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttsd2si, "iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtsd2si64, "LLiV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttsd2si64, "LLiV2d", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvtsd2ss, "V4fV4fV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq, "V4iV4f", "", "sse2")
+TARGET_BUILTIN(__builtin_ia32_cvttps2dq, "V4iV4f", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_clflush, "vvC*", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
@@ -455,7 +461,9 @@
 TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8

Re: [PATCH] D21472: [clang-tidy] readability-identifier-naming - support for other case types

2016-07-20 Thread James Reynolds via cfe-commits
JamesReynolds added a comment.

Thank you! Can you land this for me please?

This is me done for the time being, but once our implementation gets into the 
swing of things I'll try and start picking up some bugs / enhancements.


https://reviews.llvm.org/D21472



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


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-20 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 64663.
a.sidorin added a comment.

An attempt to fix unit test on Windows.
Serge, thank you! Could you please check this patch again?


https://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -456,5 +456,30 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+/// \brief Matches the decayed type, whose original type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasOriginalType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const wchar_t wstr1[] = L"DEF";
+const wchar_t wstr2[] = L"DEF" L"123";
+
+
+// Boolean literals
+const bool bval1 = true;
+const bool bval2 = false;
+
+// Floating Literals
+const float F1 = 12.2F;
+const double F2 = 1E4;
+const long double F3 = 1.2E-3L;
+
+
+// nullptr literal
+const void *vptr = nullptr;
+
+
+int glb_1[4] = { 10, 20, 30, 40 };
+
+struct S1 {
+  int a;
+  int b[3];
+};
+
+struct S2 {
+  int c;
+  S1 d;
+};
+
+S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 };
+
+void testNewThrowDelete() {
+  throw;
+  char *p = new char[10];
+  delete[] p;
+}
+
+int testArrayElement(int *x, int n) {
+  return x[n];
+}
+
+int testTernaryOp(int c, int x, int y) {
+  return c ? x : y;
+}
+
+S1 &testConstCast(const S1 &x) {
+  return const_cast(x);
+}
+
+S1 &testStaticCast(S1 &x) {
+  return static_cast(x);
+}
+
+S1 &testReinterpretCast(S1 &x) {
+  return reinterpret_cast(x);
+}
+
+S1 &testDynamicCast(S1 &x) {
+  return dynamic_cast(x);
+}
+
+int testScalarInit(int

[PATCH] D22566: Make RecursiveASTVisitor visit lambda capture initialization expressions

2016-07-20 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: klimek.
mboehme added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Lambda capture initializations are part of the explicit source code and 
therefore should be visited by default but, so far, RecursiveASTVisitor does 
not visit them.

This appears to be an oversight. Because the lambda body needs custom handling 
(calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets 
ShouldVisitChildren to false but then neglects to visit the lambda capture 
initializations. This patch adds code to visit the expressions associated with 
lambda capture initializations.

https://reviews.llvm.org/D22566

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp

Index: unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
+++ unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
@@ -191,6 +191,14 @@
 "void x(); void y() { x(); }"));
 }
 
+TEST(RecursiveASTVisitor, VisitsLambdaCaptureInit) {
+  DeclRefExprVisitor Visitor;
+  Visitor.ExpectMatch("i", 1, 20);
+  EXPECT_TRUE(Visitor.runOver(
+"void f() { int i; [i]{}; };",
+DeclRefExprVisitor::Lang_CXX11));
+}
+
 /* FIXME: According to Richard Smith this is a bug in the AST.
 TEST(RecursiveASTVisitor, VisitsBaseClassTemplateArgumentsInInstantiation) {
   DeclRefExprVisitor Visitor;
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -2254,6 +2254,9 @@
C != CEnd; ++C) {
 TRY_TO(TraverseLambdaCapture(S, C));
   }
+  for (Expr *Init : S->capture_inits()) {
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Init);
+  }
 
   TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
   FunctionProtoTypeLoc Proto = TL.castAs();


Index: unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
+++ unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
@@ -191,6 +191,14 @@
 "void x(); void y() { x(); }"));
 }
 
+TEST(RecursiveASTVisitor, VisitsLambdaCaptureInit) {
+  DeclRefExprVisitor Visitor;
+  Visitor.ExpectMatch("i", 1, 20);
+  EXPECT_TRUE(Visitor.runOver(
+"void f() { int i; [i]{}; };",
+DeclRefExprVisitor::Lang_CXX11));
+}
+
 /* FIXME: According to Richard Smith this is a bug in the AST.
 TEST(RecursiveASTVisitor, VisitsBaseClassTemplateArgumentsInInstantiation) {
   DeclRefExprVisitor Visitor;
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -2254,6 +2254,9 @@
C != CEnd; ++C) {
 TRY_TO(TraverseLambdaCapture(S, C));
   }
+  for (Expr *Init : S->capture_inits()) {
+TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Init);
+  }
 
   TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
   FunctionProtoTypeLoc Proto = TL.castAs();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22465: [clang-rename] introduce better symbol finding and add few more tests

2016-07-20 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 64668.
omtcyfz added a comment.

add support for renaming inside NestedNameSpecifier's


https://reviews.llvm.org/D22465

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRFinder.cpp
  clang-rename/USRFinder.h
  clang-rename/USRLocFinder.cpp
  test/clang-rename/ClassNameInFunctionDefenition.cpp
  test/clang-rename/ComplicatedClassType.cpp
  test/clang-rename/ComplicatedClassTypeInCustomNamespace.cpp
  test/clang-rename/FindNameSpaceInNestedNameSpec.cpp
  test/clang-rename/NestedNamespace.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/UserDefinedConversion.cpp
  test/clang-rename/UserDefinedConversionFindByConversion.cpp
  test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp

Index: test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp
===
--- test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp
+++ test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp
@@ -1,7 +1,6 @@
-// Currently unsupported test.
 // RUN: cat %s > %t.cpp
-// FIXME: while renaming class/struct clang-rename should be able to change
-// this type name corresponding user-defined conversions, too.
+// RUN: clang-rename -offset=136 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar {
 //^ offset must be here
Index: test/clang-rename/UserDefinedConversionFindByConversion.cpp
===
--- test/clang-rename/UserDefinedConversionFindByConversion.cpp
+++ test/clang-rename/UserDefinedConversionFindByConversion.cpp
@@ -1,11 +1,10 @@
-// Currently unsupported test.
 // RUN: cat %s > %t.cpp
-// FIXME: clang-rename should handle conversions from a class type to another
-// type.
+// RUN: clang-rename -offset=136 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo {}; // CHECK: class Bar {};
 
-class Baz {   // CHECK: class Bar {
+class Baz {
   operator Foo() const {  // CHECK: operator Bar() const {
 Foo foo;  // CHECK: Bar foo;
 return foo;
Index: test/clang-rename/TemplateTypename.cpp
===
--- test/clang-rename/TemplateTypename.cpp
+++ test/clang-rename/TemplateTypename.cpp
@@ -1,12 +1,20 @@
-// Currently unsupported test.
 // RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=270 -new-name=U %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+// Currently unsupported test.
 // FIXME: clang-rename should be able to rename template parameters correctly.
+// XFAIL: *
 
-template 
-T foo(T arg, T& ref, T* ptr) {
-  T value;
+template  // CHECK: template 
+class Foo {
+T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
+  T value;// CHECK: U value;
   int number = 42;
-  value = (T)number;
-  value = static_cast(number);
+  value = (T)number;  // CHECK: value = (U)number;
+  value = static_cast(number); // CHECK: value = static_cast(number);
   return value;
 }
+
+T member; // CHECK: U member;
+};
Index: test/clang-rename/NestedNamespace.cpp
===
--- /dev/null
+++ test/clang-rename/NestedNamespace.cpp
@@ -0,0 +1,38 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace Baz {
+namespace Foo { // CHECK: namespace Bar {
+class A {
+public:
+  static int aFunction() { return 0; }
+};
+int FooFunction() { return 0; }
+namespace Qux {
+class B {
+public:
+  static int bFunction() { return 0; }
+};
+int QuxFunction() { return 0; }
+} // namespace Qux
+} // namespace Foo
+} // namespace Baz
+
+int main() {
+
+  // Variable type tests.
+  Baz::Foo::A a;  // CHECK: Baz::Bar::A a;
+  Baz::Foo::Qux::B b; // CHECK: Baz::Bar::Qux::B b;
+  unsigned i = 42;
+  for (Baz::Foo::A c; i < 100; i++);  // CHECK: for (Baz::Bar::A c; i < 100; i++);
+  for (Baz::Foo::Qux::B d; i < 200; i++); // CHECK: for (Baz::Bar::Qux::B d; i < 200; i++);
+
+  // Function tests.
+  int x = Baz::Foo::A::aFunction();   // CHECK: int x = Baz::Bar::A::aFunction();
+  x = Baz::Foo::FooFunction();// CHECK: x = Baz::Bar::FooFunction();
+  x = Baz::Foo::Qux::B::bFunction();  // CHECK: x = Baz::Bar::Qux::B::bFunction();
+  x = Baz::Foo::Qux::QuxFunction();   // CHECK: x = Baz::Bar::Qux::QuxFunction();
+
+  return 0;
+}
Index: test/clang-rename/FindNameSpaceInNestedNameSpec.cpp
===
--- /dev/null
+++ test/clang-rename/FindNameSpaceInNestedNameSpec.cpp
@@ -0,0 +1,37 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=583 -new-name=Bar 

Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-07-20 Thread Guy Blank via cfe-commits
guyblank added a comment.

the  include is because i added calls to the intrinsics themselves 
in the test, no just the builtins.



Comment at: lib/Headers/intrin.h:905
@@ -906,9 +904,3 @@
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {

delena wrote:
> I'm not sure that we can move it from one file to another. And what was wrong 
> with current implementation.
it can't be left here since it will conflict with non-windows implementation.

my impression was that it is generally better to use "regular" lowering flow, 
over using inline asm.


https://reviews.llvm.org/D21959



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


Re: [PATCH] D22566: Make RecursiveASTVisitor visit lambda capture initialization expressions

2016-07-20 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D22566



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


[clang-tools-extra] r276110 - [clang-tidy] readability-identifier-naming - support for other case types

2016-07-20 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Jul 20 07:28:38 2016
New Revision: 276110

URL: http://llvm.org/viewvc/llvm-project?rev=276110&view=rev
Log:
[clang-tidy] readability-identifier-naming - support for other case types

Added Camel_Snake_Case and camel_Snake_Back

class Camel_Snake_Case_Class_Name
{
  void private_Camel_Snake_Back_Method_Name();
}

Patch by James Reynolds!

Reviewers: alexfh

Subscribers: cfe-commits

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


Modified:
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=276110&r1=276109&r2=276110&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Wed Jul 20 07:28:38 2016
@@ -163,6 +163,8 @@ IdentifierNamingCheck::IdentifierNamingC
 .Case("UPPER_CASE", CT_UpperCase)
 .Case("camelBack", CT_CamelBack)
 .Case("CamelCase", CT_CamelCase)
+.Case("Camel_Snake_Case", CT_CamelSnakeCase)
+.Case("camel_Snake_Back", CT_CamelSnakeBack)
 .Default(CT_AnyCase);
   };
 
@@ -189,6 +191,10 @@ void IdentifierNamingCheck::storeOptions
   return "UPPER_CASE";
 case CT_CamelCase:
   return "CamelCase";
+case CT_CamelSnakeCase:
+  return "Camel_Snake_Case";
+case CT_CamelSnakeBack:
+  return "camel_Snake_Back";
 }
 
 llvm_unreachable("Unknown Case Type");
@@ -230,6 +236,8 @@ static bool matchesStyle(StringRef Name,
   llvm::Regex("^[a-z][a-zA-Z0-9]*$"),
   llvm::Regex("^[A-Z][A-Z0-9_]*$"),
   llvm::Regex("^[A-Z][a-zA-Z0-9]*$"),
+  llvm::Regex("^[A-Z]([a-z0-9]*(_[A-Z])?)*"),
+  llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"),
   };
 
   bool Matches = true;
@@ -319,6 +327,27 @@ static std::string fixupWithCase(StringR
   }
 }
 break;
+
+  case IdentifierNamingCheck::CT_CamelSnakeCase:
+for (auto const &Word : Words) {
+  if (&Word != &Words.front())
+Fixup += "_";
+  Fixup += Word.substr(0, 1).upper();
+  Fixup += Word.substr(1).lower();
+}
+break;
+
+  case IdentifierNamingCheck::CT_CamelSnakeBack:
+for (auto const &Word : Words) {
+  if (&Word != &Words.front()) {
+Fixup += "_";
+Fixup += Word.substr(0, 1).upper();
+  } else {
+Fixup += Word.substr(0, 1).lower();
+  }
+  Fixup += Word.substr(1).lower();
+}
+break;
   }
 
   return Fixup;

Modified: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h?rev=276110&r1=276109&r2=276110&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h Wed 
Jul 20 07:28:38 2016
@@ -48,6 +48,8 @@ public:
 CT_CamelBack,
 CT_UpperCase,
 CT_CamelCase,
+CT_CamelSnakeCase,
+CT_CamelSnakeBack
   };
 
   struct NamingStyle {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp?rev=276110&r1=276109&r2=276110&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
Wed Jul 20 07:28:38 2016
@@ -59,10 +59,10 @@
 // RUN: {key: readability-identifier-naming.UsingCase, value: lower_case}, 
\
 // RUN: {key: readability-identifier-naming.ValueTemplateParameterCase, 
value: camelBack}, \
 // RUN: {key: readability-identifier-naming.VariableCase, value: 
lower_case}, \
-// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: 
UPPER_CASE}, \
+// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: 
Camel_Snake_Case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 
'v_'}, \
 // RUN: {key: readability-identifier-naming.MacroDefinitionCase, value: 
UPPER_CASE}, \
-// RUN: {key: readability-identifier-naming.TypeAliasCase, value: 
lower_case}, \
+// RUN: {key: readability-identifier-naming.TypeAliasCase, value: 
camel_Snake_Back}, \
 // RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, 
\
 // RUN:   

Re: [PATCH] D21472: [clang-tidy] readability-identifier-naming - support for other case types

2016-07-20 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276110: [clang-tidy] readability-identifier-naming - support 
for other case types (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D21472?vs=63462&id=64671#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21472

Files:
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
@@ -59,10 +59,10 @@
 // RUN: {key: readability-identifier-naming.UsingCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.ValueTemplateParameterCase, value: camelBack}, \
 // RUN: {key: readability-identifier-naming.VariableCase, value: lower_case}, \
-// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
+// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: Camel_Snake_Case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
 // RUN: {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE}, \
-// RUN: {key: readability-identifier-naming.TypeAliasCase, value: lower_case}, \
+// RUN: {key: readability-identifier-naming.TypeAliasCase, value: camel_Snake_Back}, \
 // RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
 // RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
@@ -261,7 +261,7 @@
 // CHECK-FIXES: {{^}}virtual ~AAbstractClass() = 0;{{$}}
 virtual void VIRTUAL_METHOD();
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for virtual method 'VIRTUAL_METHOD'
-// CHECK-FIXES: {{^}}virtual void v_VIRTUAL_METHOD();{{$}}
+// CHECK-FIXES: {{^}}virtual void v_Virtual_Method();{{$}}
 void non_Virtual_METHOD() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'non_Virtual_METHOD'
 // CHECK-FIXES: {{^}}void __non_Virtual_METHOD() {}{{$}}
@@ -316,12 +316,12 @@
 
 using my_struct_type = THIS___Structure;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'my_struct_type'
-// CHECK-FIXES: {{^}}using my_struct_type_t = this_structure;{{$}}
+// CHECK-FIXES: {{^}}using my_Struct_Type_t = this_structure;{{$}}
 
 template
 using SomeOtherTemplate = my_other_templated_class  <:: FOO_NS  ::my_class>;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'SomeOtherTemplate'
-// CHECK-FIXES: {{^}}using some_other_template_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
+// CHECK-FIXES: {{^}}using some_Other_Template_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
 
 static void static_Function() {
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function'
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h
@@ -48,6 +48,8 @@
 CT_CamelBack,
 CT_UpperCase,
 CT_CamelCase,
+CT_CamelSnakeCase,
+CT_CamelSnakeBack
   };
 
   struct NamingStyle {
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -163,6 +163,8 @@
 .Case("UPPER_CASE", CT_UpperCase)
 .Case("camelBack", CT_CamelBack)
 .Case("CamelCase", CT_CamelCase)
+.Case("Camel_Snake_Case", CT_CamelSnakeCase)
+.Case("camel_Snake_Back", CT_CamelSnakeBack)
 .Default(CT_AnyCase);
   };
 
@@ -189,6 +191,10 @@
   return "UPPER_CASE";
 case CT_CamelCase:
   return "CamelCase";
+case CT_CamelSnakeCase:
+  return "Camel_Snake_Case";
+case CT_CamelSnakeBack:
+  return "camel_Snake_Back";
 }
 
 llvm_unreachable("Unknown Case Type");
@@ -230,6 +236,8 @@
   llvm::Regex("^[a-z][a-zA-Z0-9]*$"),
   llvm::Regex("^[A-Z][A-Z0-9_]*$"),
   llvm::Regex("^[A-Z][a-zA-Z0-9]*$"),
+  llvm::Regex("^[A-Z]([a-z0-9]*(_[A-Z])?)*"),
+  llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"),
   };
 
   bool Matches = true;
@@ -319,6 +327,27 @@
   }
 }
 break;
+
+  case IdentifierNamingCheck::CT_Camel

Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-20 Thread Vassil Vassilev via cfe-commits
v.g.vassilev requested changes to this revision.
v.g.vassilev added a comment.

I guess the question about the binary size holds here, too. What would be the 
impact on the binary size?



Comment at: lib/Analysis/CloneDetection.cpp:104
@@ +103,3 @@
+/// defines what a 'similar' clone is. For example, this class doesn't collect
+/// names of variables for example, which makes statements that only differ in
+/// the names of the referenced variables clones of each other.

duplicate "for example".


Comment at: lib/Analysis/CloneDetection.cpp:145
@@ +144,3 @@
+  }
+  #include "clang/AST/StmtNodes.inc"
+

Why do we need this? Wouldn't `callAddDataStmt` properly dispatch to the 
concrete method call?


Comment at: lib/Analysis/CloneDetection.cpp:306
@@ -112,1 +305,3 @@
 for (Stmt const *Child : Parent->children()) {
+  if (!Child)
+continue;

In which case this happens?


Comment at: lib/Analysis/CloneDetection.cpp:324
@@ -128,2 +323,3 @@
 }
-llvm_unreachable("Couldn't find CloneSignature for StmtSequence");
+// We return an empty signature on a cache miss. This isn't a perfect
+// solution, but it's better than crashing when RecursiveASTVisitor is

Could you prefix this as // FIXME:


https://reviews.llvm.org/D22514



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


[clang-tools-extra] r276111 - clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

2016-07-20 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Wed Jul 20 07:32:06 2016
New Revision: 276111

URL: http://llvm.org/viewvc/llvm-project?rev=276111&view=rev
Log:
clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 
28341)

Summary:
Previoly, the added test failed with the fillowing fixit:

 char v[5];

-for(size_t i = 0; i < 5; ++i)
+for(char value : v)
 {
-unsigned char value = v[i];
 if (value > 127)

i.e. the variable 'value' changes from unsigned char to signed char. And
thus the following 'if' does not work anymore.

With this commit, the fixit is changed to:
 char v[5];

-for(size_t i = 0; i < 5; ++i)
+for(unsigned char value : v)
 {
-unsigned char value = v[i];
 if (value > 127)

Reviewers: alexfh, klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=276111&r1=276110&r2=276111&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed Jul 
20 07:32:06 2016
@@ -517,7 +517,17 @@ void LoopConvertCheck::doConversion(
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
 VarName = AliasVar->getName().str();
-AliasVarIsRef = AliasVar->getType()->isReferenceType();
+
+// Use the type of the alias if it's not the same
+QualType AliasVarType = AliasVar->getType();
+assert(!AliasVarType.isNull() && "Type in VarDecl is null");
+if (AliasVarType->isReferenceType()) {
+  AliasVarType = AliasVarType.getNonReferenceType();
+  AliasVarIsRef = true;
+}
+if (Descriptor.ElemType.isNull() ||
+!Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
+  Descriptor.ElemType = AliasVarType;
 
 // We keep along the entire DeclStmt to keep the correct range here.
 SourceRange ReplaceRange = AliasDecl->getSourceRange();

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=276111&r1=276110&r2=276111&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
Wed Jul 20 07:32:06 2016
@@ -1060,3 +1060,15 @@ void f() {
 }
 
 } // namespace InitLists
+
+void bug28341() {
+  char v[5];
+  for(int i = 0; i < 5; ++i) {
+  unsigned char value = v[i];
+  if (value > 127)
+;
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for(unsigned char value : v)
+  // CHECK-FIXES-NEXT: if (value > 127)
+  }
+}


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


Re: [PATCH] D22069: clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

2016-07-20 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276111: clang-tidy modernize-loop-convert: preserve type of 
alias declaration (bug… (authored by mgehre).

Changed prior to commit:
  https://reviews.llvm.org/D22069?vs=63400&id=64672#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22069

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -517,7 +517,17 @@
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
 VarName = AliasVar->getName().str();
-AliasVarIsRef = AliasVar->getType()->isReferenceType();
+
+// Use the type of the alias if it's not the same
+QualType AliasVarType = AliasVar->getType();
+assert(!AliasVarType.isNull() && "Type in VarDecl is null");
+if (AliasVarType->isReferenceType()) {
+  AliasVarType = AliasVarType.getNonReferenceType();
+  AliasVarIsRef = true;
+}
+if (Descriptor.ElemType.isNull() ||
+!Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
+  Descriptor.ElemType = AliasVarType;
 
 // We keep along the entire DeclStmt to keep the correct range here.
 SourceRange ReplaceRange = AliasDecl->getSourceRange();
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -1060,3 +1060,15 @@
 }
 
 } // namespace InitLists
+
+void bug28341() {
+  char v[5];
+  for(int i = 0; i < 5; ++i) {
+  unsigned char value = v[i];
+  if (value > 127)
+;
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for(unsigned char value : v)
+  // CHECK-FIXES-NEXT: if (value > 127)
+  }
+}


Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -517,7 +517,17 @@
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
 VarName = AliasVar->getName().str();
-AliasVarIsRef = AliasVar->getType()->isReferenceType();
+
+// Use the type of the alias if it's not the same
+QualType AliasVarType = AliasVar->getType();
+assert(!AliasVarType.isNull() && "Type in VarDecl is null");
+if (AliasVarType->isReferenceType()) {
+  AliasVarType = AliasVarType.getNonReferenceType();
+  AliasVarIsRef = true;
+}
+if (Descriptor.ElemType.isNull() ||
+!Context->hasSameUnqualifiedType(AliasVarType, Descriptor.ElemType))
+  Descriptor.ElemType = AliasVarType;
 
 // We keep along the entire DeclStmt to keep the correct range here.
 SourceRange ReplaceRange = AliasDecl->getSourceRange();
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -1060,3 +1060,15 @@
 }
 
 } // namespace InitLists
+
+void bug28341() {
+  char v[5];
+  for(int i = 0; i < 5; ++i) {
+  unsigned char value = v[i];
+  if (value > 127)
+;
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for(unsigned char value : v)
+  // CHECK-FIXES-NEXT: if (value > 127)
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-20 Thread Eric Liu via cfe-commits
ioeric added a comment.

Ping


https://reviews.llvm.org/D21748



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


Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-20 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:145
@@ -145,4 +144,3 @@
 
-/// \brief A set of Replacements.
-/// FIXME: Change to a vector and deduplicate in the RefactoringTool.
-typedef std::set Replacements;
+/// \brief This maintains a set of replacements that are conflict-free.
+/// Two replacements are considered conflicts if they overlap or have the same

s/This //


Comment at: lib/Tooling/Core/Replacement.cpp:146
@@ +145,3 @@
+return llvm::make_error(
+"All replacements must have the SAME FILE PATH! New replacement: " 
+
+R.getFilePath() + ", existing replacements: " +

DO NOT SCREAM!!! :D


Comment at: lib/Tooling/Core/Replacement.cpp:306
@@ +305,3 @@
+  return LHS.getLength() < RHS.getLength();
+});
+  std::vector Result;

I believe it's better. Can you add a comment expanding what this is for, so we 
don't have to re-think about that next time we stumble over it? :)


https://reviews.llvm.org/D21748



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


Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-20 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 64675.
ioeric marked 5 inline comments as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D21748

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/TokenAnalyzer.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  lib/Tooling/RefactoringCallbacks.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp
  unittests/Tooling/RewriterTest.cpp

Index: unittests/Tooling/RewriterTest.cpp
===
--- unittests/Tooling/RewriterTest.cpp
+++ unittests/Tooling/RewriterTest.cpp
@@ -39,8 +39,11 @@
 
 TEST(Rewriter, AdjacentInsertAndDelete) {
   Replacements Replaces;
-  Replaces.insert(Replacement("", 6, 6, ""));
-  Replaces.insert(Replacement("", 6, 0, "replaced\n"));
+  auto Err = Replaces.add(Replacement("", 6, 6, ""));
+  EXPECT_TRUE(!Err);
+  Replaces =
+  Replaces.merge(Replacements(Replacement("", 6, 0, "replaced\n")));
+
   auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces);
   EXPECT_TRUE(static_cast(Rewritten));
   EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten);
Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -109,62 +109,72 @@
   EXPECT_TRUE(Replace2.getFilePath().empty());
 }
 
-TEST_F(ReplacementTest, CanApplyReplacements) {
-  FileID ID = Context.createInMemoryFile("input.cpp",
- "line1\nline2\nline3\nline4");
+static Replacements toReplacements(const std::set &Replaces) {
+  Replacements Result;
+  for (const auto &R : Replaces) {
+auto Err = Result.add(R);
+EXPECT_TRUE(!Err);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return Replacements();
+}
+  }
+  return Result;
+}
+
+TEST_F(ReplacementTest, FailAddReplacements) {
   Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 1),
-  5, "other"));
-  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
-  EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
+  auto Err = Replaces.add(Replacement("x.cc", 0, 10, "3"));
+  EXPECT_TRUE(!Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 0, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("x.cc", 2, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
+  Err = Replaces.add(Replacement("y.cc", 20, 2, ""));
+  EXPECT_TRUE((bool)Err);
+  llvm::consumeError(std::move(Err));
 }
 
-// FIXME: Remove this test case when Replacements is implemented as std::vector
-// instead of std::set. The other ReplacementTest tests will need to be updated
-// at that point as well.
-TEST_F(ReplacementTest, VectorCanApplyReplacements) {
+TEST_F(ReplacementTest, CanApplyReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  std::vector Replaces;
-  Replaces.push_back(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
- 5, "replaced"));
-  Replaces.push_back(
-  Replacement(Context.Sources, Context.getLocation(ID, 3, 1), 5, "other"));
+  Replacements Replaces =
+  toReplacements({Replacement(Context.Sources,
+  Context.getLocation(ID, 2, 1), 5, "replaced"),
+  Replacement(Context.Sources,
+  Context.getLocation(ID, 3, 1), 5, "other")});
   EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
   EXPECT_EQ("line1\nreplaced\nother\nline4", Context.getRewrittenText(ID));
 }
 
 TEST_F(ReplacementTest, SkipsDuplicateReplacements) {
   FileID ID = Context.createInMemoryFile("input.cpp",
  "line1\nline2\nline3\nline4");
-  Replacements Replaces;
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
-  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 2, 1),
-  5, "replaced"));
+  auto Replaces = toReplacements({Replacement(
+  Context.Sources, Context.getLocation(ID, 2, 1), 5, "replaced")});
+
+  auto Err = Replaces.add

Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-20 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a reviewer: rengolin.
rengolin added a comment.
This revision is now accepted and ready to land.

I'm auto accepting this proposal, as it seems to have ran its course.

The commit is r276097.

If anyone has any additional comment/suggestion, please submit a new review.


https://reviews.llvm.org/D22463



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


[PATCH] D22567: [include-fixer] Add mising qualifiers to all instances of an unidentified symbol.

2016-07-20 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D22567

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -97,9 +97,11 @@
 return "";
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
-  Replaces->insert({FakeFileName, FixerContext.getSymbolRange().getOffset(),
-FixerContext.getSymbolRange().getLength(),
-FixerContext.getHeaderInfos().front().QualifiedName});
+  for (const auto &Info : FixerContext.getQuerySymbolInfos()) {
+Replaces->insert({FakeFileName, Info.Range.getOffset(),
+  Info.Range.getLength(),
+  FixerContext.getHeaderInfos().front().QualifiedName});
+  }
   clang::tooling::applyAllReplacements(*Replaces, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
@@ -275,6 +277,67 @@
 runIncludeFixer("namespace a {\n::a::b::bar b;\n}\n"));
 }
 
+TEST(IncludeFixer, FixNamespaceQualifiersForAllInstances) {
+  const char TestCode[] = R"(
+namespace a {
+bar b; // Fix
+int func1() {
+  bar a; // Fix
+  bar *p = new bar(); // Fix
+  return 0;
+}
+} // namespace a
+
+namespace a {
+bar func2() { // Fix
+  bar f; // Fix
+  return f;
+}
+} // namespace a
+
+void f() {
+  bar b; // No-fix: Not in the same scope.
+}
+
+namespace a {
+namespace c {
+  bar b; // No-fix: Not in the same scope.
+} // namespace c
+} // namespace a
+)";
+
+  const char ExpectedCode[] = R"(
+#include "bar.h"
+namespace a {
+b::bar b; // Fix
+int func1() {
+  b::bar a; // Fix
+  b::bar *p = new b::bar(); // Fix
+  return 0;
+}
+} // namespace a
+
+namespace a {
+b::bar func2() { // Fix
+  b::bar f; // Fix
+  return f;
+}
+} // namespace a
+
+void f() {
+  bar b; // No-fix: Not in the same scope.
+}
+
+namespace a {
+namespace c {
+  bar b; // No-fix: Not in the same scope.
+} // namespace c
+} // namespace a
+)";
+
+  EXPECT_EQ(ExpectedCode, runIncludeFixer(TestCode));
+}
+
 } // namespace
 } // namespace include_fixer
 } // namespace clang
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,9 +1,9 @@
 // REQUIRES: shell
 // RUN: echo "foo f;" > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfo: {RawIdentifier: foo, Range: {Offset: 0, Length: 3}}, HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"}]}' %t.cpp | FileCheck %s -check-prefix=CHECK-CODE
-// RUN: cat %t.cpp | not clang-include-fixer -stdin -insert-header='{QuerySymbolInfo: {RawIdentifier: foo, Range: {Offset: 0, Length: 3}}, HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"},{Header: "\"foo2.h\"", QualifiedName: "foo"}]}' %t.cpp
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfo: {RawIdentifier: foo, Range: {Offset: 0, Length: 3}}, HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "a:foo"},{Header: "\"foo.h\"", QualifiedName: "b:foo"}]}' %t.cpp
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"}]}' %t.cpp | FileCheck %s -check-prefix=CHECK-CODE
+// RUN: cat %t.cpp | not clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"},{Header: "\"foo2.h\"", QualifiedName: "foo"}]}' %t.cpp
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "a:foo"},{Header: "\"foo.h\"", QualifiedName: "b:foo"}]}' %t.cpp
 //
 // CHECK: "HeaderInfos": [
 // CHECK-NEXT:  {"Header": "\"foo.h\"",
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -127,8 +127,8 @@
 return
 
   include_fixer_context = json.loads(stdout)
-  query_symbol_info = include_fixer_context["QuerySymbolInfo"]
-  symbol = query_symbol_info["RawIdentifier"]
+  query_symbol_infos = include_fixer_context["QuerySymbolInfos

Re: [libcxx] r276003 - Fix undefined behavior in __tree

2016-07-20 Thread Hans Wennborg via cfe-commits
On Wed, Jul 20, 2016 at 1:42 AM, Marshall Clow  wrote:
>
>
> On Tue, Jul 19, 2016 at 11:06 AM, Eric Fiselier  wrote:
>>
>> @Hans. This needs to be merged into 3.9. It fixes PR28469 which is a
>> release blocker.
>
>
> I'm fine with this.

Thanks! Eric, go ahead and merge this, or let me know if you'd like me to do it.

Cheers,
Hans


>> On Tue, Jul 19, 2016 at 11:56 AM, Eric Fiselier via cfe-commits
>>  wrote:
>>>
>>> Author: ericwf
>>> Date: Tue Jul 19 12:56:20 2016
>>> New Revision: 276003
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=276003&view=rev
>>> Log:
>>> Fix undefined behavior in __tree
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-20 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 64676.
a.sidorin added a comment.

Removed unneeded matcher.


https://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -456,5 +456,24 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const wchar_t wstr1[] = L"DEF";
+const wchar_t wstr2[] = L"DEF" L"123";
+
+
+// Boolean literals
+const bool bval1 = true;
+const bool bval2 = false;
+
+// Floating Literals
+const float F1 = 12.2F;
+const double F2 = 1E4;
+const long double F3 = 1.2E-3L;
+
+
+// nullptr literal
+const void *vptr = nullptr;
+
+
+int glb_1[4] = { 10, 20, 30, 40 };
+
+struct S1 {
+  int a;
+  int b[3];
+};
+
+struct S2 {
+  int c;
+  S1 d;
+};
+
+S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 };
+
+void testNewThrowDelete() {
+  throw;
+  char *p = new char[10];
+  delete[] p;
+}
+
+int testArrayElement(int *x, int n) {
+  return x[n];
+}
+
+int testTernaryOp(int c, int x, int y) {
+  return c ? x : y;
+}
+
+S1 &testConstCast(const S1 &x) {
+  return const_cast(x);
+}
+
+S1 &testStaticCast(S1 &x) {
+  return static_cast(x);
+}
+
+S1 &testReinterpretCast(S1 &x) {
+  return reinterpret_cast(x);
+}
+
+S1 &testDynamicCast(S1 &x) {
+  return dynamic_cast(x);
+}
+
+int testScalarInit(int x) {
+  return int(x);
+}
+
+struct S {
+  float f;
+  double d;
+};
+struct T {
+  int i;
+  struct S s[10];
+};
+
+void testOffsetOf() {
+  __builtin_offsetof(struct T, s[2].d);
+}
+
+
+unsigned char asmFunc(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  

Re: [PATCH] D22567: [include-fixer] Add mising qualifiers to all instances of an unidentified symbol.

2016-07-20 Thread Eric Liu via cfe-commits
ioeric added a subscriber: ioeric.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:365
@@ +364,3 @@
+  for (const auto &Info : Context.getQuerySymbolInfos()) {
+Replacements->insert({FilePath, Info.Range.getOffset(),
+  Info.Range.getLength(),

Now that we insert namespace qualifiers, we might want to do a 
`formatReplacements` before applying them.


https://reviews.llvm.org/D22567



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


Re: [PATCH] D21970: Add attribute abi_tag to the release notes

2016-07-20 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276113: Add attribute abi_tag to the release notes (authored 
by hans).

Changed prior to commit:
  https://reviews.llvm.org/D21970?vs=62673&id=64678#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21970

Files:
  cfe/branches/release_39/docs/ReleaseNotes.rst

Index: cfe/branches/release_39/docs/ReleaseNotes.rst
===
--- cfe/branches/release_39/docs/ReleaseNotes.rst
+++ cfe/branches/release_39/docs/ReleaseNotes.rst
@@ -51,6 +51,9 @@
   linkers that is a relatively expensive option. It can be passed explicitly
   with -Wl,--build-id. To have clang always pass it, build clang with
   -DENABLE_LINKER_BUILD_ID.
+- On Itanium ABI targets, attribute abi_tag is now supported for compatibility
+  with GCC. Clang implementation of abi_tag is mostly compatible with GCC ABI
+  version 10.
 
 Improvements to Clang's diagnostics
 ^^^


Index: cfe/branches/release_39/docs/ReleaseNotes.rst
===
--- cfe/branches/release_39/docs/ReleaseNotes.rst
+++ cfe/branches/release_39/docs/ReleaseNotes.rst
@@ -51,6 +51,9 @@
   linkers that is a relatively expensive option. It can be passed explicitly
   with -Wl,--build-id. To have clang always pass it, build clang with
   -DENABLE_LINKER_BUILD_ID.
+- On Itanium ABI targets, attribute abi_tag is now supported for compatibility
+  with GCC. Clang implementation of abi_tag is mostly compatible with GCC ABI
+  version 10.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21970: Add attribute abi_tag to the release notes

2016-07-20 Thread Hans Wennborg via cfe-commits
hans added a comment.

Committed r276113. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D21970



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


Re: [PATCH] D22567: [include-fixer] Add mising qualifiers to all instances of an unidentified symbol.

2016-07-20 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/IncludeFixer.cpp:246
@@ +245,3 @@
+if (!QuerySymbolInfos.empty()) {
+  if (ScopedQualifiers.str() == QuerySymbolInfos.front().ScopedQualifiers 
&&
+  Query.str() == QuerySymbolInfos.front().RawIdentifier) {

Drop .str() when comparing StringRef with std::string.


Comment at: include-fixer/IncludeFixerContext.h:73
@@ -64,1 +72,3 @@
 
+  /// \brief The information of the symbol being queried.
+  std::vector QuerySymbolInfos;

This comment is rather useless as-is, maybe explain what it means to have 
multiple elements in the vector.


https://reviews.llvm.org/D22567



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


Re: [clang-tools-extra] r275943 - clang-rename: fix referenced variable in vim-script

2016-07-20 Thread Hans Wennborg via cfe-commits
Sure, r276115.

Thanks,
Hans

On Mon, Jul 18, 2016 at 10:22 PM, Saleem Abdulrasool
 wrote:
> Hey Hans,
>
> I think that we should get this merged into 3.9.  Its a trivial fix and
> makes the script usable if you set g:clang_rename_path.
>
> Thanks!
>
> On Mon, Jul 18, 2016 at 7:13 PM, Saleem Abdulrasool via cfe-commits
>  wrote:
>>
>> Author: compnerd
>> Date: Mon Jul 18 21:13:08 2016
>> New Revision: 275943
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=275943&view=rev
>> Log:
>> clang-rename: fix referenced variable in vim-script
>>
>> Modified:
>> clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
>>
>> Modified: clang-tools-extra/trunk/clang-rename/tool/clang-rename.py
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/clang-rename.py?rev=275943&r1=275942&r2=275943&view=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clang-rename/tool/clang-rename.py (original)
>> +++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.py Mon Jul 18
>> 21:13:08 2016
>> @@ -25,7 +25,7 @@ import sys
>>  def main():
>>  binary = 'clang-rename'
>>  if vim.eval('exists("g:clang_rename_path")') == "1":
>> -binary = vim.eval('g:clang_rename')
>> +binary = vim.eval('g:clang_rename_path')
>>
>>  # Get arguments for clang-rename binary.
>>  offset = int(vim.eval('line2byte(line("."))+col(".")')) - 2
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-20 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaInit.cpp:6945
@@ +6944,3 @@
+  // get the integer literal.
+  Init = cast(const_cast(
+Var->getInit()))->getSubExpr();

What if global variable sampler is initialized with another sampler variable:
  sampler_t s1 = ...;
  sampler_t s2 = s1;
  ...
  foo(s2);

Btw, I am wondering whether this code is needed at all, because I am guessing 
variable initialization will be handled separately anyways, irrespective to 
whether it's being used in a call or not...


Comment at: lib/Sema/SemaInit.cpp:6949-6980
@@ -6917,3 +6948,34 @@
+}
   }
 
+  // Case 1a, 2a and 2b
+  // Insert cast from integer to sampler.
+  if (!Init->isConstantInitializer(S.Context, false))
+S.Diag(Kind.getLocation(),
+   diag::err_sampler_initializer_not_constant);
+  if (!SourceType->isIntegerType() ||
+  32 != S.Context.getIntWidth(SourceType))
+S.Diag(Kind.getLocation(), diag::err_sampler_initializer_not_integer)
+  << SourceType;
+
+  llvm::APSInt Result;
+  Init->EvaluateAsInt(Result, S.Context);
+  const uint64_t SamplerValue = Result.getLimitedValue();
+  // 32-bit value of sampler's initializer is interpreted as
+  // bit-field with the following structure:
+  // |unspecified|Filter|Addressing Mode| Normalized Coords|
+  // |316|54|3 1| 0|
+  // This structure corresponds to enum values of sampler properties 
defined
+  // in SPIR spec v1.2 and also opencl-c.h
+  unsigned AddressingMode  = (0x0E & SamplerValue) >> 1;
+  unsigned FilterMode  = (0x30 & SamplerValue) >> 4;
+  if (FilterMode != 1 && FilterMode != 2)
+S.Diag(Kind.getLocation(), diag::warn_sampler_initializer_invalid_bits)
+  << "Filter Mode";
+  if (AddressingMode > 4)
+S.Diag(Kind.getLocation(), diag::warn_sampler_initializer_invalid_bits)
+  << "Addressing Mode";
+
+  CurInit = S.ImpCastExprToType(Init, S.Context.OCLSamplerTy,
+  CK_IntToOCLSampler);
   break;

Is this being tested anywhere:
  sampler_t initialization requires 32-bit integer


https://reviews.llvm.org/D21567



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


r276120 - [MS] Improve VPtrInfo field names and doc comments

2016-07-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Jul 20 09:40:25 2016
New Revision: 276120

URL: http://llvm.org/viewvc/llvm-project?rev=276120&view=rev
Log:
[MS] Improve VPtrInfo field names and doc comments

'ReusingBase' was a terrible name. It might actually refer to the most
derived class, which is not a base. 'BaseWithVPtr' was also bad, since
again, it could refer to the most derived class. It was actually the
first base to introduce the vptr, so now it is 'IntroducingObject'.

Modified:
cfe/trunk/include/clang/AST/VTableBuilder.h
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/include/clang/AST/VTableBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/VTableBuilder.h?rev=276120&r1=276119&r2=276120&view=diff
==
--- cfe/trunk/include/clang/AST/VTableBuilder.h (original)
+++ cfe/trunk/include/clang/AST/VTableBuilder.h Wed Jul 20 09:40:25 2016
@@ -398,21 +398,21 @@ struct VPtrInfo {
   typedef SmallVector BasePath;
 
   VPtrInfo(const CXXRecordDecl *RD)
-  : ReusingBase(RD), BaseWithVPtr(RD), NextBaseToMangle(RD) {}
+  : ObjectWithVPtr(RD), IntroducingObject(RD), NextBaseToMangle(RD) {}
 
-  /// The vtable will hold all of the virtual bases or virtual methods of
-  /// ReusingBase.  This may or may not be the same class as 
VPtrSubobject.Base.
-  /// A derived class will reuse the vptr of the first non-virtual base
-  /// subobject that has one.
-  const CXXRecordDecl *ReusingBase;
+  /// This is the most derived class that has this vptr at offset zero. When
+  /// single inheritance is used, this is always the most derived class. If
+  /// multiple inheritance is used, it may be any direct or indirect base.
+  const CXXRecordDecl *ObjectWithVPtr;
+
+  /// This is the class that introduced the vptr by declaring new virtual
+  /// methods or virtual bases.
+  const CXXRecordDecl *IntroducingObject;
 
-  /// BaseWithVPtr is at this offset from its containing complete object or
+  /// IntroducingObject is at this offset from its containing complete object 
or
   /// virtual base.
   CharUnits NonVirtualOffset;
 
-  /// The vptr is stored inside this subobject.
-  const CXXRecordDecl *BaseWithVPtr;
-
   /// The bases from the inheritance path that got used to mangle the vbtable
   /// name.  This is not really a full path like a CXXBasePath.  It holds the
   /// subset of records that need to be mangled into the vbtable symbol name in
@@ -431,7 +431,7 @@ struct VPtrInfo {
   /// This holds the base classes path from the complete type to the first base
   /// with the given vfptr offset, in the base-to-derived order.  Only used for
   /// vftables.
-  BasePath PathToBaseWithVPtr;
+  BasePath PathToIntroducingObject;
 
   /// Static offset from the top of the most derived class to this vfptr,
   /// including any virtual base offset.  Only used for vftables.

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=276120&r1=276119&r2=276120&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Wed Jul 20 09:40:25 2016
@@ -2931,8 +2931,8 @@ void VFTableBuilder::AddMethods(BaseSubo
   // class.
   const CXXRecordDecl *NextBase = nullptr, *NextLastVBase = LastVBase;
   CharUnits NextBaseOffset;
-  if (BaseDepth < WhichVFPtr.PathToBaseWithVPtr.size()) {
-NextBase = WhichVFPtr.PathToBaseWithVPtr[BaseDepth];
+  if (BaseDepth < WhichVFPtr.PathToIntroducingObject.size()) {
+NextBase = WhichVFPtr.PathToIntroducingObject[BaseDepth];
 if (isDirectVBase(NextBase, RD)) {
   NextLastVBase = NextBase;
   NextBaseOffset = MostDerivedClassLayout.getVBaseClassOffset(NextBase);
@@ -3124,7 +3124,7 @@ static void dumpMicrosoftThunkAdjustment
 
 void VFTableBuilder::dumpLayout(raw_ostream &Out) {
   Out << "VFTable for ";
-  PrintBasePath(WhichVFPtr.PathToBaseWithVPtr, Out);
+  PrintBasePath(WhichVFPtr.PathToIntroducingObject, Out);
   Out << "'";
   MostDerivedClass->printQualifiedName(Out);
   Out << "' (" << Components.size()
@@ -3311,10 +3311,10 @@ void MicrosoftVTableContext::computeVTab
   // Keep track of which vtable the derived class is going to extend with
   // new methods or bases.  We append to either the vftable of our primary
   // base, or the first non-virtual base that has a vbtable.
-  if (P->ReusingBase == Base &&
+  if (P->ObjectWithVPtr == Base &&
   Base == (ForVBTables ? Layout.getBaseSharingVBPtr()
: Layout.getPrimaryBase()))
-P->ReusingBase = RD;
+P->ObjectWithVPtr = RD;
 
   // Keep track of the full adjustment from the MDC to this vtable.  The
   // adjustment is captured by an optional vbase and a non-virtual offset.
@@ -3401,14 +3401,14 @@ typedef llvm::SetVe

Re: [PATCH] D22523: [OpenCL] AMDGCN target will generate images in constant address space

2016-07-20 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!



Comment at: lib/CodeGen/TargetInfo.cpp:6868
@@ +6867,3 @@
+unsigned 
AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) 
const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);;
+}

can you remove one ;


Repository:
  rL LLVM

https://reviews.llvm.org/D22523



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-20 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Sema/SemaInit.cpp:6945
@@ +6944,3 @@
+  // get the integer literal.
+  Init = cast(const_cast(
+Var->getInit()))->getSubExpr();

Anastasia wrote:
> What if global variable sampler is initialized with another sampler variable:
>   sampler_t s1 = ...;
>   sampler_t s2 = s1;
>   ...
>   foo(s2);
> 
> Btw, I am wondering whether this code is needed at all, because I am guessing 
> variable initialization will be handled separately anyways, irrespective to 
> whether it's being used in a call or not...
clang currently does not allow assigning a sampler global variable with another 
sampler global variable. An error will be emitted:

 initializer element is not a compile-time constant

We could allow this, but I think allowing this is not a very useful feature, so 
I would recommend continue not allowing it.

If we do not replace references of function-scope sampler variable with its 
initializer here, we will end up with a global variable initialized with an 
integer and we will not be able to do codegen for it as in LLVM we cannot 
initialize a global variable with a function call.


https://reviews.llvm.org/D21567



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-20 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Hi, Renato.

Just to explain why I'm going to go forward with this RFC about a monolithic 
repository: From speaking with some top contributors on IRC, I have heard that 
they feel that the discussion of whether to move to git has been conflated with 
the discussion of how the git repository should be set up.  So there is a 
sizable set of important individuals who don't feel that this question has been 
considered sufficiently.

I would love not to alienate you by asking this question, but I understand if I 
already have.  If so, I sincerely apologize.


https://reviews.llvm.org/D22463



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


[libunwind] r276128 - libunwind: limit stack usage in unwind cursor

2016-07-20 Thread Ed Maste via cfe-commits
Author: emaste
Date: Wed Jul 20 10:19:09 2016
New Revision: 276128

URL: http://llvm.org/viewvc/llvm-project?rev=276128&view=rev
Log:
libunwind: limit stack usage in unwind cursor

Obtained from FreeBSD SVN r302475

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

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/src/DwarfParser.hpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=276128&r1=276127&r2=276128&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed Jul 20 10:19:09 2016
@@ -22,18 +22,22 @@
 #  define _LIBUNWIND_TARGET_I386 1
 #  define _LIBUNWIND_CONTEXT_SIZE 8
 #  define _LIBUNWIND_CURSOR_SIZE 19
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 9
 # elif defined(__x86_64__)
 #  define _LIBUNWIND_TARGET_X86_64 1
 #  define _LIBUNWIND_CONTEXT_SIZE 21
 #  define _LIBUNWIND_CURSOR_SIZE 33
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 17
 # elif defined(__ppc__)
 #  define _LIBUNWIND_TARGET_PPC 1
 #  define _LIBUNWIND_CONTEXT_SIZE 117
 #  define _LIBUNWIND_CURSOR_SIZE 128
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 113
 # elif defined(__aarch64__)
 #  define _LIBUNWIND_TARGET_AARCH64 1
 #  define _LIBUNWIND_CONTEXT_SIZE 66
 #  define _LIBUNWIND_CURSOR_SIZE 78
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
 # elif defined(__arm__)
 #  define _LIBUNWIND_TARGET_ARM 1
 #  if defined(__ARM_WMMX)
@@ -43,10 +47,12 @@
 #define _LIBUNWIND_CONTEXT_SIZE 42
 #define _LIBUNWIND_CURSOR_SIZE 49
 #  endif
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 96
 # elif defined(__or1k__)
 #  define _LIBUNWIND_TARGET_OR1K 1
 #  define _LIBUNWIND_CONTEXT_SIZE 16
 #  define _LIBUNWIND_CURSOR_SIZE 28
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
 # else
 #  error "Unsupported architecture."
 # endif
@@ -59,6 +65,7 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_CONTEXT_SIZE 128
 # define _LIBUNWIND_CURSOR_SIZE 140
+# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 120
 #endif // _LIBUNWIND_IS_NATIVE_ONLY
 
 #endif // LIBUNWIND_CONFIG_H__

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=276128&r1=276127&r2=276128&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Wed Jul 20 10:19:09 2016
@@ -62,7 +62,7 @@ public:
   };
 
   enum {
-kMaxRegisterNumber = 120
+kMaxRegisterNumber = _LIBUNWIND_HIGHEST_DWARF_REGISTER
   };
   enum RegisterSavedWhere {
 kRegisterUnused,


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


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-20 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

With this patch unit tests pass on Windows as well.
I do not have formal authority to approve patches, but for me the patch is good 
enough to be accepted.



Comment at: lib/AST/ASTImporter.cpp:3422
@@ +3421,3 @@
+  D->getTrailingObjects();
+  for (int I = 0; I < D->NumTPLists; I++) {
+TemplateParameterList *List = ImportTemplateParameterList(FromTPLists[I]);

Consider using `unsigned` instead of `int` to avoid MSVC warning about mix of 
signed and unsigned types.


https://reviews.llvm.org/D14326



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


Buildmaster restart in few minutes

2016-07-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted in few minutes.
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


Re: r202329 - Add a 'use-external-names' option to VFS overlay files

2016-07-20 Thread Ben Langmuir via cfe-commits

> On Jul 18, 2016, at 3:21 PM, Richard Smith  wrote:
> 
> On Wed, Feb 26, 2014 at 4:25 PM, Ben Langmuir  > wrote:
> Author: benlangmuir
> Date: Wed Feb 26 18:25:12 2014
> New Revision: 202329
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=202329&view=rev 
> 
> Log:
> Add a 'use-external-names' option to VFS overlay files
> 
> When true, sets the name of the file to be the name from
> 'external-contents'. Otherwise, you get the virtual path that the file
> was looked up by. This will not affect any non-virtual paths, or fully
> virtual paths (for which there is no reasonable 'external' name anyway).
> 
> The setting is available globally, but can be overriden on a per-file
> basis.
> 
> The goal is that this setting will control which path you see in debug
> info, diagnostics, etc. which are sensitive to which path is used. That
> will come in future patches that pass the name through to FileManager.
> 
> Modified:
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=202329&r1=202328&r2=202329&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Wed Feb 26 18:25:12 2014
> @@ -29,7 +29,6 @@ namespace vfs {
>  /// \brief The result of a \p status operation.
>  class Status {
>std::string Name;
> -  std::string ExternalName;
>llvm::sys::fs::UniqueID UID;
>llvm::sys::TimeValue MTime;
>uint32_t User;
> @@ -46,16 +45,9 @@ public:
>   uint64_t Size, llvm::sys::fs::file_type Type,
>   llvm::sys::fs::perms Perms);
> 
> -  /// \brief Returns the name this status was looked up by.
> +  /// \brief Returns the name that should be used for this file or directory.
>StringRef getName() const { return Name; }
> -
> -  /// \brief Returns the name to use outside the compiler.
> -  ///
> -  /// For example, in diagnostics or debug info we should use this name.
> -  StringRef getExternalName() const { return ExternalName; }
> -
>void setName(StringRef N) { Name = N; }
> -  void setExternalName(StringRef N) { ExternalName = N; }
> 
>/// @name Status interface from llvm::sys::fs
>/// @{
> 
> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=202329&r1=202328&r2=202329&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Feb 26 18:25:12 2014
> @@ -35,8 +35,8 @@ Status::Status(const file_status &Status
>  Status::Status(StringRef Name, StringRef ExternalName, UniqueID UID,
> sys::TimeValue MTime, uint32_t User, uint32_t Group,
> uint64_t Size, file_type Type, perms Perms)
> -: Name(Name), ExternalName(ExternalName), UID(UID), MTime(MTime),
> -  User(User), Group(Group), Size(Size), Type(Type), Perms(Perms) {}
> +: Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), 
> Size(Size),
> +  Type(Type), Perms(Perms) {}
> 
>  bool Status::equivalent(const Status &Other) const {
>return getUniqueID() == Other.getUniqueID();
> @@ -145,7 +145,6 @@ ErrorOr RealFileSystem::status(c
>  return EC;
>Status Result(RealStatus);
>Result.setName(Path.str());
> -  Result.setExternalName(Path.str());
>return Result;
>  }
> 
> @@ -253,12 +252,22 @@ public:
>  };
> 
>  class FileEntry : public Entry {
> +public:
> +  enum NameKind {
> +NK_NotSet,
> +NK_External,
> +NK_Virtual
> +  };
> +private:
>std::string ExternalContentsPath;
> -
> +  NameKind UseName;
>  public:
> -  FileEntry(StringRef Name, StringRef ExternalContentsPath)
> -  : Entry(EK_File, Name), ExternalContentsPath(ExternalContentsPath) {}
> +  FileEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)
> +  : Entry(EK_File, Name), ExternalContentsPath(ExternalContentsPath),
> +UseName(UseName) {}
>StringRef getExternalContentsPath() const { return ExternalContentsPath; }
> +  /// \brief whether to use the external path as the name for this file.
> +  NameKind useName() const { return UseName; }
>static bool classof(const Entry *E) { return E->getKind() == EK_File; }
>  };
> 
> @@ -280,6 +289,7 @@ public:

Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-07-20 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 64704.
a.sidorin added a comment.

Fix signed/unsigned mismatch warning in the loop condition.


https://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -456,5 +456,24 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const wchar_t wstr1[] = L"DEF";
+const wchar_t wstr2[] = L"DEF" L"123";
+
+
+// Boolean literals
+const bool bval1 = true;
+const bool bval2 = false;
+
+// Floating Literals
+const float F1 = 12.2F;
+const double F2 = 1E4;
+const long double F3 = 1.2E-3L;
+
+
+// nullptr literal
+const void *vptr = nullptr;
+
+
+int glb_1[4] = { 10, 20, 30, 40 };
+
+struct S1 {
+  int a;
+  int b[3];
+};
+
+struct S2 {
+  int c;
+  S1 d;
+};
+
+S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 };
+
+void testNewThrowDelete() {
+  throw;
+  char *p = new char[10];
+  delete[] p;
+}
+
+int testArrayElement(int *x, int n) {
+  return x[n];
+}
+
+int testTernaryOp(int c, int x, int y) {
+  return c ? x : y;
+}
+
+S1 &testConstCast(const S1 &x) {
+  return const_cast(x);
+}
+
+S1 &testStaticCast(S1 &x) {
+  return static_cast(x);
+}
+
+S1 &testReinterpretCast(S1 &x) {
+  return reinterpret_cast(x);
+}
+
+S1 &testDynamicCast(S1 &x) {
+  return dynamic_cast(x);
+}
+
+int testScalarInit(int x) {
+  return int(x);
+}
+
+struct S {
+  float f;
+  double d;
+};
+struct T {
+  int i;
+  struct S s[10];
+};
+
+void testOffsetOf() {
+  __builtin_offsetof(struct T, s[2].d);
+}
+
+
+unsigned char asmFunc(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int l

Re: [PATCH] D22523: [OpenCL] AMDGCN target will generate images in constant address space

2016-07-20 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 64706.
ashi1 marked an inline comment as done.
ashi1 added a comment.

Removed excess semicolon by Anastasia's comments


Repository:
  rL LLVM

https://reviews.llvm.org/D22523

Files:
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/opencl_types.cl

Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -1,40 +1,49 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR
+// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN
 
 constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+// CHECK-SPIR: constant i32 7
+// CHECK-AMDGCN: addrspace(2) constant i32 7
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK-SPIR: @fnc1(%opencl.image1d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1(%opencl.image1d_ro_t addrspace(2)*
 
 void fnc1arr(image1d_array_t img) {}
-// CHECK: @fnc1arr(%opencl.image1d_array_ro_t*
+// CHECK-SPIR: @fnc1arr(%opencl.image1d_array_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1arr(%opencl.image1d_array_ro_t addrspace(2)*
 
 void fnc1buff(image1d_buffer_t img) {}
-// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t*
+// CHECK-SPIR: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(2)*
 
 void fnc2(image2d_t img) {}
-// CHECK: @fnc2(%opencl.image2d_ro_t*
+// CHECK-SPIR: @fnc2(%opencl.image2d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc2(%opencl.image2d_ro_t addrspace(2)*
 
 void fnc2arr(image2d_array_t img) {}
-// CHECK: @fnc2arr(%opencl.image2d_array_ro_t*
+// CHECK-SPIR: @fnc2arr(%opencl.image2d_array_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc2arr(%opencl.image2d_array_ro_t addrspace(2)*
 
 void fnc3(image3d_t img) {}
-// CHECK: @fnc3(%opencl.image3d_ro_t*
+// CHECK-SPIR: @fnc3(%opencl.image3d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc3(%opencl.image3d_ro_t addrspace(2)*
 
 void fnc4smp(sampler_t s) {}
-// CHECK-LABEL: define {{.*}}void @fnc4smp(i32
+// CHECK-SPIR-LABEL: define {{.*}}void @fnc4smp(i32
 
 kernel void foo(image1d_t img) {
   sampler_t smp = 5;
-  // CHECK: alloca i32
+  // CHECK-SPIR: alloca i32
   event_t evt;
-  // CHECK: alloca %opencl.event_t*
-  // CHECK: store i32 5,
+  // CHECK-SPIR: alloca %opencl.event_t*
+  // CHECK-SPIR: store i32 5,
   fnc4smp(smp);
-  // CHECK: call {{.*}}void @fnc4smp(i32
+  // CHECK-SPIR: call {{.*}}void @fnc4smp(i32
   fnc4smp(glb_smp);
-  // CHECK: call {{.*}}void @fnc4smp(i32
+  // CHECK-SPIR: call {{.*}}void @fnc4smp(i32
 }
 
 void __attribute__((overloadable)) bad1(image1d_t b, image2d_t c, image2d_t d) {}
-// CHECK-LABEL: @{{_Z4bad114ocl_image1d_ro14ocl_image2d_roS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d_ro@@PAUocl_image2d_ro@@1@Z"}}
+// CHECK-SPIR-LABEL: @{{_Z4bad114ocl_image1d_ro14ocl_image2d_roS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d_ro@@PAUocl_image2d_ro@@1@Z"}}
+// CHECK-AMDGCN-LABEL: @{{_Z4bad114ocl_image1d_ro14ocl_image2d_roS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d_ro@@PAUocl_image2d_ro@@1@Z"}}(%opencl.image1d_ro_t addrspace(2)*{{.*}}%opencl.image2d_ro_t addrspace(2)*{{.*}}%opencl.image2d_ro_t addrspace(2)*{{.*}})
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -220,6 +220,9 @@
 
   /// Get LLVM calling convention for OpenCL kernel.
   virtual unsigned getOpenCLKernelCallingConv() const;
+
+  /// Get LLVM Image Address Space for OpenCL kernel.
+  virtual unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -375,6 +375,11 @@
 unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv() const {
   return llvm::CallingConv::C;
 }
+
+unsigned TargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+}
+
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
@@ -6832,6 +6832,7 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
   unsigned getOpenCLKernelCallingConv() const override;
+  unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const override;
 };
 
 }
@@ -6864,6 +6864,10 @@
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
+unsigned AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
+  return CGM.getContext().

Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2016-07-20 Thread Ed Maste via cfe-commits
emaste added a comment.

Is this going to be committed?
Libunwind is about to grow the same alignment attribute 
(https://reviews.llvm.org/D22543)


https://reviews.llvm.org/D12512



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


Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2016-07-20 Thread Dan Albert via cfe-commits
danalbert added a comment.

The configure-time check LGTM. Android has it for all recent versions (since 
JB), but that will cover the case of GB and ICS.



Comment at: src/cxa_exception.cpp:127
@@ +126,3 @@
+// on 32 bit targets.
+ptr = std::malloc(size);
+#endif

`#warning` until that's done?


https://reviews.llvm.org/D12512



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


Re: [PATCH] D21145: [Sema] Fix crash on valid where instantiation of lambda cannot access type of 'this'

2016-07-20 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D21145



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


[PATCH] D22577: Include unreferenced nested types in member list only for CodeView

2016-07-20 Thread Adrian McCarthy via cfe-commits
amccarth created this revision.
amccarth added reviewers: rnk, dblaikie.
amccarth added a subscriber: cfe-commits.

Unreferenced nested structs and classes were omitted from the debug info.  In 
DWARF, this was intentional, to avoid bloat.  But, for CodeView, we want this 
information to be consistent with what Microsoft tools would produce and expect.

This is essentially my earlier patch with a switch to apply it only when 
generating CodeView.

https://reviews.llvm.org/D22577

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
  test/CodeGenCXX/debug-info-ms-abi.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -121,15 +121,19 @@
 // CHECK-SAME: flags: DIFlagFwdDecl,
 // CHECK-SAME: identifier: "_ZTS9Template1IPvE")
 
-// Explicit instatiation.
+// Explicit instantiation.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1",
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS9Template1IiE")
 
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate",
 // CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME: flags: DIFlagFwdDecl
+// CHECK-SAME: identifier: "_ZTSN11SpecializedIiE6MemberE")
+
 // Forward-declared member of a template.
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
 // CHECK-SAME: flags: DIFlagFwdDecl
Index: test/CodeGenCXX/debug-info-ms-abi.cpp
===
--- test/CodeGenCXX/debug-info-ms-abi.cpp
+++ test/CodeGenCXX/debug-info-ms-abi.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -debug-info-kind=limited -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
 
 // Tests that certain miscellaneous features work in the MS ABI.
 
@@ -14,6 +14,9 @@
 // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
 // CHECK-SAME: identifier: ".?AUFoo@@"
 
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
+// CHECK-SAME: identifier: ".?AUNested@Foo@@"
+
 // CHECK: !DISubprogram(name: "f",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
@@ -25,6 +28,3 @@
 // CHECK: !DISubprogram(name: "h",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
-
-// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
-// CHECK-SAME: identifier: ".?AUNested@Foo@@"
Index: test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
===
--- test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
+++ test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
@@ -19,6 +19,6 @@
 
 Test t;
 
-// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
+// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -254,6 +254,8 @@
 llvm::DIFile *F,
 SmallVectorImpl &E,
 llvm::DIType *RecordTy, const RecordDecl *RD);
+  void CollectRecordNestedRecord(const RecordDecl *RD,
+ SmallVectorImpl &E);
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl &E,
llvm::DICompositeType *RecordTy);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1090,6 +1090,13 @@
   elements.push_back(FieldType);
 }
 
+void CGDebugInfo::CollectRecordNestedRecord(
+const RecordDecl *RD, SmallVectorImpl &elements) {
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
+  elements.push_back(nestedType);
+}
+
 void CGDebugInfo::CollectRecordFields(
 const RecordDecl *record, llvm::DIFile *tunit,
 SmallVectorImpl &elements,
@@ -1101,6 +1108,10 @@
   else {
 const ASTRecordLayout &layout = CGM.getContext().getA

Re: [PATCH] D22577: Include unreferenced nested types in member list only for CodeView

2016-07-20 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1096
@@ +1095,3 @@
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
+  elements.push_back(nestedType);

Is getOrCreateMainFile correct here? I thought we'd use 
`getOrCreateFile(RD->getLocation())`, like this other code:
```
llvm::DIType *CGDebugInfo::getOrCreateRecordType(QualType RTy,
 SourceLocation Loc) {
  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
  llvm::DIType *T = getOrCreateType(RTy, getOrCreateFile(Loc));
  return T;
}
```


Comment at: test/CodeGenCXX/debug-info-ms-abi.cpp:15
@@ -14,3 +14,3 @@
 // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "Foo",
 // CHECK-SAME: identifier: ".?AUFoo@@"
 

We should check what shows up in `elements:`, something like:
```
// CHECK-SAME: elements: ![[elements:[0-9]+]]

// CHECK: ![[elements]] = {![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]], 
![[Nested:[0-9]+]]}

// CHECK: ![[Nested]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "Nested",
```

And we can look for [[f]], g, and h, before the DISubprograms below.


https://reviews.llvm.org/D22577



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


r276152 - Fix modules self-host: add missing include and forward-decl.

2016-07-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jul 20 13:28:19 2016
New Revision: 276152

URL: http://llvm.org/viewvc/llvm-project?rev=276152&view=rev
Log:
Fix modules self-host: add missing include and forward-decl.

Modified:
cfe/trunk/include/clang/Lex/PTHManager.h

Modified: cfe/trunk/include/clang/Lex/PTHManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHManager.h?rev=276152&r1=276151&r2=276152&view=diff
==
--- cfe/trunk/include/clang/Lex/PTHManager.h (original)
+++ cfe/trunk/include/clang/Lex/PTHManager.h Wed Jul 20 13:28:19 2016
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_LEX_PTHMANAGER_H
 
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/OnDiskHashTable.h"
@@ -26,6 +27,7 @@ namespace llvm {
 namespace clang {
 
 class FileEntry;
+class Preprocessor;
 class PTHLexer;
 class DiagnosticsEngine;
 class FileSystemStatCache;


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


Re: [PATCH] D22557: [libcxx] Diagnose invalid memory order arguments in . Fixes PR21179.

2016-07-20 Thread JF Bastien via cfe-commits
jfb added a subscriber: jfb.
jfb added a comment.

Awesome, thanks for doing this!

Should this be a warning or an error?



Comment at: include/atomic:581
@@ +580,3 @@
+   || __f == memory_order_acq_rel, "")))  \
+__attribute__ ((__unavailable__("memory order argument to atomic operation 
is invalid")))
+#endif

This isn't checking for the following requirement from the standard:

> The failure argument shall be no stronger than the success argument.

I think that's OK because I intend to remove that requirement from C++ :)

Should we nonetheless enforce the requirement until the standard drops it? If 
so, "stronger" isn't well defined by the standard, details here: 
https://github.com/jfbastien/papers/blob/master/source/D0418r1.bs


Comment at: test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp:30
@@ +29,3 @@
+vx.load(std::memory_order_release); // expected-error {{operation is 
invalid}}
+vx.load(std::memory_order_acq_rel); // expected-error {{operation is 
invalid}}
+}

Could you test that the other memory orders don't have any diagnostic (here and 
below).


Comment at: test/libcxx/atomics/diagnose_invalid_memory_order.fail.cpp:55
@@ +54,3 @@
+}
+// compare exchange weak
+{

For cmpxchg (weak and strong), should you also test the version with only a 
`success` ordering? The `failure` one is auto-generated from `success`, but it 
would be good to know that it never generates a diagnostic.


https://reviews.llvm.org/D22557



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


Re: [PATCH] D22557: [libcxx] Diagnose invalid memory order arguments in . Fixes PR21179.

2016-07-20 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.


Comment at: include/atomic:569
@@ +568,3 @@
+__attribute__ ((__enable_if__(__m == memory_order_release \
+   || __m == memory_order_acq_rel, "")))  \
+__attribute__ ((__unavailable__("memory order argument to atomic operation 
is invalid")))

what about relaxed?


https://reviews.llvm.org/D22557



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


r276159 - [modules] Don't emit initializers for VarDecls within a module eagerly whenever

2016-07-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jul 20 14:10:16 2016
New Revision: 276159

URL: http://llvm.org/viewvc/llvm-project?rev=276159&view=rev
Log:
[modules] Don't emit initializers for VarDecls within a module eagerly whenever
we first touch any part of that module. Instead, defer them until the first
time that module is (transitively) imported. The initializer step for a module
then recursively initializes modules that its own headers imported.

For example, this avoids running the  global initializer in programs
that don't actually use iostreams, but do use other parts of the standard
library.

Added:
cfe/trunk/test/Modules/Inputs/unused-global-init/
  - copied from r275623, cfe/trunk/test/Modules/Inputs/unused-global-init/
cfe/trunk/test/Modules/unused-global-init.cpp
  - copied, changed from r275623, 
cfe/trunk/test/Modules/unused-global-init.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/Inputs/unused-global-init/used.h
cfe/trunk/test/Modules/odr.cpp
cfe/trunk/test/Modules/templates.mm

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=276159&r1=276158&r2=276159&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jul 20 14:10:16 2016
@@ -312,6 +312,18 @@ class ASTContext : public RefCountedBase
   /// definitions of that entity.
   llvm::DenseMap> MergedDefModules;
 
+  /// \brief Initializers for a module, in order. Each Decl will be either
+  /// something that has a semantic effect on startup (such as a variable with
+  /// a non-constant initializer), or an ImportDecl (which recursively triggers
+  /// initialization of another module).
+  struct PerModuleInitializers {
+llvm::SmallVector Initializers;
+llvm::SmallVector LazyInitializers;
+
+void resolve(ASTContext &Ctx);
+  };
+  llvm::DenseMap ModuleInitializers;
+
 public:
   /// \brief A type synonym for the TemplateOrInstantiation mapping.
   typedef llvm::PointerUnion
@@ -883,6 +895,17 @@ public:
 return MergedIt->second;
   }
 
+  /// Add a declaration to the list of declarations that are initialized
+  /// for a module. This will typically be a global variable (with internal
+  /// linkage) that runs module initializers, such as the iostream initializer,
+  /// or an ImportDecl nominating another module that has initializers.
+  void addModuleInitializer(Module *M, Decl *Init);
+
+  void addLazyModuleInitializers(Module *M, ArrayRef IDs);
+
+  /// Get the initializations to perform when importing a module, if any.
+  ArrayRef getModuleInitializers(Module *M);
+
   TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
 
   ExternCContextDecl *getExternCContextDecl() const;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=276159&r1=276158&r2=276159&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jul 20 14:10:16 2016
@@ -1390,8 +1390,14 @@ private:
   bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
TypeDiagnoser *Diagnoser);
 
+  struct ModuleScope {
+clang::Module *Module;
+VisibleModuleSet OuterVisibleModules;
+  };
+  /// The modules we're currently parsing.
+  llvm::SmallVector ModuleScopes;
+
   VisibleModuleSet VisibleModules;
-  llvm::SmallVector VisibleModulesStack;
 
   Module *CachedFakeTopLevelModule;
 

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=276159&r1=276158&r2=276159&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Jul 20 14:10:16 2016
@@ -684,6 +684,9 @@ namespace clang {
   /// \brief Specifies a header that is private to this submodule but
   /// must be textually included.
   SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15,
+  /// \brief Specifies some declarations with initializers that must be
+  /// emitted to initialize the module.
+  SUBMODULE_INITIALIZERS = 16,
 };
 
 /// \brief Record types used within a comme

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-20 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 64724.
yaxunl added a comment.

Added more diagnostic tests.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,6 +1,34 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{sampler_t initialization requires compile time constant}} // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}
+
+constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}
+
+constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
 
 void foo(sampler_t);
 
@@ -10,22 +38,27 @@
 
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
   foo(const_smp);
+  foo(const_smp2);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}
   &smp1; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
 }
 
-sampler_t bad(); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+//
+// This test covers 6 cases of sampler initialzation:
+//   1. function argument passing
+//  1a. argument is a file-scope variable
+//  1b. argument is a function-scope variable
+//

r276161 - [OpenCL] AMDGCN target will generate images in constant address space

2016-07-20 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Jul 20 14:21:11 2016
New Revision: 276161

URL: http://llvm.org/viewvc/llvm-project?rev=276161&view=rev
Log:
[OpenCL] AMDGCN target will generate images in constant address space

Allows AMDGCN target to generate images (such as %opencl.image2d_t) in constant 
address space.
Images will still be generated in global address space by default.

Added tests to existing opencl-types.cl in test\CodeGenOpenCL.

Patch by Aaron En Ye Shi.

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGenOpenCL/opencl_types.cl

Modified: cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp?rev=276161&r1=276160&r2=276161&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp Wed Jul 20 14:21:11 2016
@@ -15,6 +15,7 @@
 
 #include "CGOpenCLRuntime.h"
 #include "CodeGenFunction.h"
+#include "TargetInfo.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/GlobalValue.h"
 #include 
@@ -35,7 +36,7 @@ llvm::Type *CGOpenCLRuntime::convertOpen
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
   uint32_t ImgAddrSpc =
-CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+CGM.getTargetCodeGenInfo().getOpenCLImageAddrSpace(CGM);
   switch (cast(T)->getKind()) {
   default: 
 llvm_unreachable("Unexpected opencl builtin type!");

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=276161&r1=276160&r2=276161&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 20 14:21:11 2016
@@ -375,6 +375,11 @@ TargetCodeGenInfo::getDependentLibraryOp
 unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv() const {
   return llvm::CallingConv::C;
 }
+
+unsigned TargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule 
&CGM) const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+}
+
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
@@ -6832,6 +6837,7 @@ public:
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
   unsigned getOpenCLKernelCallingConv() const override;
+  unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const override;
 };
 
 }
@@ -6868,6 +6874,10 @@ unsigned AMDGPUTargetCodeGenInfo::getOpe
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
+unsigned 
AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) 
const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);
+}
+
 
//===--===//
 // SPARC v8 ABI Implementation.
 // Based on the SPARC Compliance Definition version 2.4.1.

Modified: cfe/trunk/lib/CodeGen/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.h?rev=276161&r1=276160&r2=276161&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.h (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.h Wed Jul 20 14:21:11 2016
@@ -220,6 +220,9 @@ public:
 
   /// Get LLVM calling convention for OpenCL kernel.
   virtual unsigned getOpenCLKernelCallingConv() const;
+
+  /// Get LLVM Image Address Space for OpenCL kernel.
+  virtual unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen

Modified: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/opencl_types.cl?rev=276161&r1=276160&r2=276161&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Wed Jul 20 14:21:11 2016
@@ -1,40 +1,49 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | 
FileCheck %s --check-prefix=CHECK-SPIR
+// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck 
%s --check-prefix=CHECK-AMDGCN
 
 constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+// CHECK-SPIR: constant i32 7
+// CHECK-AMDGCN: addrspace(2) constant i32 7
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK-SPIR: @fnc1(%opencl.image1d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1(%opencl.image1d_ro_t addrspace(2)*
 
 void fnc1arr(image1d_array_t img) 

Re: [PATCH] D22523: [OpenCL] AMDGCN target will generate images in constant address space

2016-07-20 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276161: [OpenCL] AMDGCN target will generate images in 
constant address space (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D22523?vs=64706&id=64729#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22523

Files:
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/test/CodeGenOpenCL/opencl_types.cl

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -375,6 +375,11 @@
 unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv() const {
   return llvm::CallingConv::C;
 }
+
+unsigned TargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+}
+
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
@@ -6832,6 +6837,7 @@
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
   unsigned getOpenCLKernelCallingConv() const override;
+  unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const override;
 };
 
 }
@@ -6868,6 +6874,10 @@
   return llvm::CallingConv::AMDGPU_KERNEL;
 }
 
+unsigned AMDGPUTargetCodeGenInfo::getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const {
+  return CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);
+}
+
 //===--===//
 // SPARC v8 ABI Implementation.
 // Based on the SPARC Compliance Definition version 2.4.1.
Index: cfe/trunk/lib/CodeGen/TargetInfo.h
===
--- cfe/trunk/lib/CodeGen/TargetInfo.h
+++ cfe/trunk/lib/CodeGen/TargetInfo.h
@@ -220,6 +220,9 @@
 
   /// Get LLVM calling convention for OpenCL kernel.
   virtual unsigned getOpenCLKernelCallingConv() const;
+
+  /// Get LLVM Image Address Space for OpenCL kernel.
+  virtual unsigned getOpenCLImageAddrSpace(CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen
Index: cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
@@ -15,6 +15,7 @@
 
 #include "CGOpenCLRuntime.h"
 #include "CodeGenFunction.h"
+#include "TargetInfo.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/GlobalValue.h"
 #include 
@@ -35,7 +36,7 @@
 
   llvm::LLVMContext& Ctx = CGM.getLLVMContext();
   uint32_t ImgAddrSpc =
-CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+CGM.getTargetCodeGenInfo().getOpenCLImageAddrSpace(CGM);
   switch (cast(T)->getKind()) {
   default: 
 llvm_unreachable("Unexpected opencl builtin type!");
Index: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
===
--- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
+++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
@@ -1,40 +1,49 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR
+// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN
 
 constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+// CHECK-SPIR: constant i32 7
+// CHECK-AMDGCN: addrspace(2) constant i32 7
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK-SPIR: @fnc1(%opencl.image1d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1(%opencl.image1d_ro_t addrspace(2)*
 
 void fnc1arr(image1d_array_t img) {}
-// CHECK: @fnc1arr(%opencl.image1d_array_ro_t*
+// CHECK-SPIR: @fnc1arr(%opencl.image1d_array_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1arr(%opencl.image1d_array_ro_t addrspace(2)*
 
 void fnc1buff(image1d_buffer_t img) {}
-// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t*
+// CHECK-SPIR: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(2)*
 
 void fnc2(image2d_t img) {}
-// CHECK: @fnc2(%opencl.image2d_ro_t*
+// CHECK-SPIR: @fnc2(%opencl.image2d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc2(%opencl.image2d_ro_t addrspace(2)*
 
 void fnc2arr(image2d_array_t img) {}
-// CHECK: @fnc2arr(%opencl.image2d_array_ro_t*
+// CHECK-SPIR: @fnc2arr(%opencl.image2d_array_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc2arr(%opencl.image2d_array_ro_t addrspace(2)*
 
 void fnc3(image3d_t img) {}
-// CHECK: @fnc3(%opencl.image3d_ro_t*
+// CHECK-SPIR: @fnc3(%opencl.image3d_ro_t addrspace(1)*
+// CHECK-AMDGCN: @fnc3(%opencl.image3d_ro_t addrspace(2)*
 
 void fnc4smp(sampler_

Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-07-20 Thread Ben Harper via cfe-commits
bmharper added a comment.

PING



Comment at: lib/Format/WhitespaceManager.cpp:95
@@ -97,2 +94,3 @@
   std::sort(Changes.begin(), Changes.end(), Change::IsBeforeInFile(SourceMgr));
+  calculateScopeLevel();
   calculateLineBreakInformation();

berenm wrote:
> Maybe we could spare the computation if we aren't going to align anything?
> 
> Is it better for clarity to always compute additional information? @djasper 
> what's the Clang way to do?
> 
That's a good point. One certainly could elide that if alignment was turned 
off. I think so long as it was mentioned in the comments of the ScopeLevel 
member variable, it would be OK to do so. However, I'll also just defer this 
decision to @djasper.


Repository:
  rL LLVM

https://reviews.llvm.org/D21279



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


r276167 - [OpenMP] Ignore parens in atomic capture

2016-07-20 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Jul 20 14:41:17 2016
New Revision: 276167

URL: http://llvm.org/viewvc/llvm-project?rev=276167&view=rev
Log:
[OpenMP] Ignore parens in atomic capture

Clang misdiagnoses atomic captures cases that contains parens.
i.e.

  int v, int *p;
#pragma omp atomic capture
{ v = (*p); (*p)++; }

Patch by David S.

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/atomic_messages.c
cfe/trunk/test/OpenMP/atomic_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=276167&r1=276166&r2=276167&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Jul 20 14:41:17 2016
@@ -6163,7 +6163,7 @@ bool OpenMPAtomicUpdateChecker::checkSta
 AtomicCompAssignOp->getOpcode());
 OpLoc = AtomicCompAssignOp->getOperatorLoc();
 E = AtomicCompAssignOp->getRHS();
-X = AtomicCompAssignOp->getLHS();
+X = AtomicCompAssignOp->getLHS()->IgnoreParens();
 IsXLHSInRHSPart = true;
   } else if (auto *AtomicBinOp = dyn_cast(
  AtomicBody->IgnoreParenImpCasts())) {
@@ -6177,7 +6177,7 @@ bool OpenMPAtomicUpdateChecker::checkSta
   IsPostfixUpdate = AtomicUnaryOp->isPostfix();
   Op = AtomicUnaryOp->isIncrementOp() ? BO_Add : BO_Sub;
   OpLoc = AtomicUnaryOp->getOperatorLoc();
-  X = AtomicUnaryOp->getSubExpr();
+  X = AtomicUnaryOp->getSubExpr()->IgnoreParens();
   E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64_t Val=*/1).get();
   IsXLHSInRHSPart = true;
 } else {

Modified: cfe/trunk/test/OpenMP/atomic_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_messages.c?rev=276167&r1=276166&r2=276167&view=diff
==
--- cfe/trunk/test/OpenMP/atomic_messages.c (original)
+++ cfe/trunk/test/OpenMP/atomic_messages.c Wed Jul 20 14:41:17 2016
@@ -313,6 +313,8 @@ int captureint() {
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
@@ -321,6 +323,8 @@ int captureint() {
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}

Modified: cfe/trunk/test/OpenMP/atomic_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_messages.cpp?rev=276167&r1=276166&r2=276167&view=diff
==
--- cfe/trunk/test/OpenMP/atomic_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_messages.cpp Wed Jul 20 14:41:17 2016
@@ -453,6 +453,8 @@ T capture() {
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
@@ -461,6 +463,8 @@ T capture() {
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}


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


Re: [PATCH] D22487: [OpenMP] Ignore parens in atomic capture

2016-07-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276167: [OpenMP] Ignore parens in atomic capture (authored 
by kli).

Changed prior to commit:
  https://reviews.llvm.org/D22487?vs=64416&id=64732#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22487

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/atomic_messages.c
  cfe/trunk/test/OpenMP/atomic_messages.cpp

Index: cfe/trunk/test/OpenMP/atomic_messages.cpp
===
--- cfe/trunk/test/OpenMP/atomic_messages.cpp
+++ cfe/trunk/test/OpenMP/atomic_messages.cpp
@@ -453,14 +453,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: cfe/trunk/test/OpenMP/atomic_messages.c
===
--- cfe/trunk/test/OpenMP/atomic_messages.c
+++ cfe/trunk/test/OpenMP/atomic_messages.c
@@ -313,14 +313,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -6163,7 +6163,7 @@
 AtomicCompAssignOp->getOpcode());
 OpLoc = AtomicCompAssignOp->getOperatorLoc();
 E = AtomicCompAssignOp->getRHS();
-X = AtomicCompAssignOp->getLHS();
+X = AtomicCompAssignOp->getLHS()->IgnoreParens();
 IsXLHSInRHSPart = true;
   } else if (auto *AtomicBinOp = dyn_cast(
  AtomicBody->IgnoreParenImpCasts())) {
@@ -6177,7 +6177,7 @@
   IsPostfixUpdate = AtomicUnaryOp->isPostfix();
   Op = AtomicUnaryOp->isIncrementOp() ? BO_Add : BO_Sub;
   OpLoc = AtomicUnaryOp->getOperatorLoc();
-  X = AtomicUnaryOp->getSubExpr();
+  X = AtomicUnaryOp->getSubExpr()->IgnoreParens();
   E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64_t Val=*/1).get();
   IsXLHSInRHSPart = true;
 } else {


Index: cfe/trunk/test/OpenMP/atomic_messages.cpp
===
--- cfe/trunk/test/OpenMP/atomic_messages.cpp
+++ cfe/trunk/test/OpenMP/atomic_messages.cpp
@@ -453,14 +453,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: cfe/trunk/test/OpenMP/atomic_messages.c
===
--- cfe/trunk/test/OpenMP/atomic_messages.c
+++ cfe/trunk/test/OpenMP/atomic_messages.c
@@ -313,14 +313,18 @@
 #pragma omp atomic capture
   {c = a; a++;}
 #pragma omp atomic capture
+  {c = a; (a)++;}
+#pragma omp atomic capture
   {++a;c = a;}
 #pragma omp atomic capture
   {c = a;a--;}
 #pragma omp atomic capture
   {--a;c = a;}
 #pragma omp atomic capture
   {c = a; a += b;}
 #pragma omp atomic capture
+  {c = a; (a) += b;}
+#pragma omp atomic capture
   {a %= b; c = a;}
 #pragma omp atomic capture
   {c = a; a *= b;}
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -6163,7 +6163,7 @@
 AtomicCompAssignOp->getOpcode());
 OpLoc = AtomicCompAssignOp->getOperatorLoc();
 E = AtomicCompAssignOp->getRHS();
-X = AtomicCompAssignOp->getLHS();
+X = AtomicCompAssignOp->getLHS()->IgnoreParens();
 IsXLHSInRHSPart = true;
   } else if (auto *AtomicBinOp = dyn_cast(
  AtomicBody->IgnoreParenImpCasts())) {
@@ -6177,7 +6177,7 @@
   IsPostfixUpdate = AtomicUnaryOp->isPostfix();
   Op = AtomicUnaryOp->isIncrementOp() ? BO_Add : BO_Sub;
   OpLoc = AtomicUnaryOp->getOperatorLoc();
-  X = AtomicUnaryOp->getSubExpr();
+  X = AtomicUnaryOp->getSubExpr()->IgnoreParens();
   E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64

Re: [PATCH] D22439: Add missing includes.

2016-07-20 Thread Richard Smith via cfe-commits
rsmith added a comment.

ManagedStatic.h already includes , so the additional includes of 
 don't seem appropriate to me. Looks like this may have hit a bug in 
enum merging?


https://reviews.llvm.org/D22439



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


[PATCH] D22587: [ASTContext] Fix part of DR224 for nontype template arguments

2016-07-20 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: klimek, aaron.ballman, rsmith.
mgehre added a subscriber: cfe-commits.

Look through expressions to determine if a nontype template argument has been 
given the value of the template parameter.

https://reviews.llvm.org/D22587

Files:
  lib/AST/ASTContext.cpp
  test/CXX/drs/dr2xx.cpp

Index: test/CXX/drs/dr2xx.cpp
===
--- test/CXX/drs/dr2xx.cpp
+++ test/CXX/drs/dr2xx.cpp
@@ -275,9 +275,9 @@
   static const int my_I = I;
   static const int my_I2 = I+0;
   static const int my_I3 = my_I;
-  B::type b3; // FIXME: expected-error {{missing 
'typename'}}
+  B::type b3;
   B::type b4; // expected-error {{missing 'typename'}}
-  B::type b5; // FIXME: expected-error {{missing 
'typename'}}
+  B::type b5;
 };
   }
 
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4448,8 +4448,26 @@
 case TemplateArgument::Null:
   return Arg;
 
-case TemplateArgument::Expression:
+case TemplateArgument::Expression: {
+  // Look through variable declarations that have been initialized to a 
non-type template
+  // parameter, see 14.6.2.1 [temp.dep.type]:
+  // [...], the argument must have been given the value of
+  // the template parameter and not an expression involving the template 
parameter.
+  auto *E = Arg.getAsExpr()->IgnoreImpCasts();
+  while(auto *DeclRef = dyn_cast_or_null(E)) {
+auto *D = DeclRef->getDecl();
+if (isa(D))
+  return TemplateArgument(DeclRef);
+
+auto *VD = dyn_cast(D);
+if (!VD)
+  break;
+E = VD->getInit();
+if (E)
+  E = E->IgnoreImpCasts();
+  }
   return Arg;
+}
 
 case TemplateArgument::Declaration: {
   ValueDecl *D = cast(Arg.getAsDecl()->getCanonicalDecl());


Index: test/CXX/drs/dr2xx.cpp
===
--- test/CXX/drs/dr2xx.cpp
+++ test/CXX/drs/dr2xx.cpp
@@ -275,9 +275,9 @@
   static const int my_I = I;
   static const int my_I2 = I+0;
   static const int my_I3 = my_I;
-  B::type b3; // FIXME: expected-error {{missing 'typename'}}
+  B::type b3;
   B::type b4; // expected-error {{missing 'typename'}}
-  B::type b5; // FIXME: expected-error {{missing 'typename'}}
+  B::type b5;
 };
   }
 
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4448,8 +4448,26 @@
 case TemplateArgument::Null:
   return Arg;
 
-case TemplateArgument::Expression:
+case TemplateArgument::Expression: {
+  // Look through variable declarations that have been initialized to a non-type template
+  // parameter, see 14.6.2.1 [temp.dep.type]:
+  // [...], the argument must have been given the value of
+  // the template parameter and not an expression involving the template parameter.
+  auto *E = Arg.getAsExpr()->IgnoreImpCasts();
+  while(auto *DeclRef = dyn_cast_or_null(E)) {
+auto *D = DeclRef->getDecl();
+if (isa(D))
+  return TemplateArgument(DeclRef);
+
+auto *VD = dyn_cast(D);
+if (!VD)
+  break;
+E = VD->getInit();
+if (E)
+  E = E->IgnoreImpCasts();
+  }
   return Arg;
+}
 
 case TemplateArgument::Declaration: {
   ValueDecl *D = cast(Arg.getAsDecl()->getCanonicalDecl());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r276177 - [OpenMP] Allow negative lower bound in array sections based on pointers

2016-07-20 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Jul 20 15:45:29 2016
New Revision: 276177

URL: http://llvm.org/viewvc/llvm-project?rev=276177&view=rev
Log:
[OpenMP] Allow negative lower bound in array sections based on pointers

OpenMP 4.5 removed the restriction that array section lower bound must be non 
negative.
This change is to allow negative values for array section based on pointers.
For array section based on array type there is still a restriction: "The array 
section must be a subset of the original array."

Patch by David S.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/OpenMP/target_depend_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_depend_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
cfe/trunk/test/OpenMP/target_update_depend_messages.cpp
cfe/trunk/test/OpenMP/task_depend_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=276177&r1=276176&r2=276177&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 20 15:45:29 
2016
@@ -8260,8 +8260,10 @@ def warn_omp_section_is_char : Warning<"
   InGroup, DefaultIgnore;
 def err_omp_section_incomplete_type : Error<
   "section of pointer to incomplete type %0">;
-def err_omp_section_negative : Error<
-  "section %select{lower bound|length}0 is evaluated to a negative value %1">;
+def err_omp_section_not_subset_of_array : Error<
+  "array section must be a subset of the original array">;
+def err_omp_section_length_negative : Error<
+  "section length is evaluated to a negative value %0">;
 def err_omp_section_length_undefined : Error<
   "section length is unspecified and cannot be inferred because subscripted 
value is %select{not an array|an array of unknown bound}0">;
 def err_omp_wrong_linear_modifier : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=276177&r1=276176&r2=276177&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jul 20 15:45:29 2016
@@ -4304,14 +4304,13 @@ ExprResult Sema::ActOnOMPArraySectionExp
   diag::err_omp_section_incomplete_type, Base))
 return ExprError();
 
-  if (LowerBound) {
+  if (LowerBound && !OriginalTy->isAnyPointerType()) {
 llvm::APSInt LowerBoundValue;
 if (LowerBound->EvaluateAsInt(LowerBoundValue, Context)) {
-  // OpenMP 4.0, [2.4 Array Sections]
-  // The lower-bound and length must evaluate to non-negative integers.
+  // OpenMP 4.5, [2.4 Array Sections]
+  // The array section must be a subset of the original array.
   if (LowerBoundValue.isNegative()) {
-Diag(LowerBound->getExprLoc(), diag::err_omp_section_negative)
-<< 0 << LowerBoundValue.toString(/*Radix=*/10, /*Signed=*/true)
+Diag(LowerBound->getExprLoc(), 
diag::err_omp_section_not_subset_of_array)
 << LowerBound->getSourceRange();
 return ExprError();
   }
@@ -4321,11 +4320,11 @@ ExprResult Sema::ActOnOMPArraySectionExp
   if (Length) {
 llvm::APSInt LengthValue;
 if (Length->EvaluateAsInt(LengthValue, Context)) {
-  // OpenMP 4.0, [2.4 Array Sections]
-  // The lower-bound and length must evaluate to non-negative integers.
+  // OpenMP 4.5, [2.4 Array Sections]
+  // The length must evaluate to non-negative integers.
   if (LengthValue.isNegative()) {
-Diag(Length->getExprLoc(), diag::err_omp_section_negative)
-<< 1 << LengthValue.toString(/*Radix=*/10, /*Signed=*/true)
+Diag(Length->getExprLoc(), diag::err_omp_section_length_negative)
+<< LengthValue.toString(/*Radix=*/10, /*Signed=*/true)
 << Length->getSourceRange();
 return ExprError();
   }
@@ -4333,7 +4332,7 @@ ExprResult Sema::ActOnOMPArraySectionExp
   } else if (ColonLoc.isValid() &&
  (OriginalTy.isNull() || (!OriginalTy->isConstantArrayType() &&
   !OriginalTy->isVariableArrayType( {
-// OpenMP 4.0, [2.4 Array Sections]
+// OpenMP 4.5, [2.4 Array Sections]
   

Re: [PATCH] D22481: [OpenMP] Allow negative lower bound in array sections based on pointers

2016-07-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276177: [OpenMP] Allow negative lower bound in array 
sections based on pointers (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D22481?vs=64389&id=64754#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22481

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/OpenMP/target_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_enter_data_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_map_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_map_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
  cfe/trunk/test/OpenMP/target_update_depend_messages.cpp
  cfe/trunk/test/OpenMP/task_depend_messages.cpp

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -4304,14 +4304,13 @@
   diag::err_omp_section_incomplete_type, Base))
 return ExprError();
 
-  if (LowerBound) {
+  if (LowerBound && !OriginalTy->isAnyPointerType()) {
 llvm::APSInt LowerBoundValue;
 if (LowerBound->EvaluateAsInt(LowerBoundValue, Context)) {
-  // OpenMP 4.0, [2.4 Array Sections]
-  // The lower-bound and length must evaluate to non-negative integers.
+  // OpenMP 4.5, [2.4 Array Sections]
+  // The array section must be a subset of the original array.
   if (LowerBoundValue.isNegative()) {
-Diag(LowerBound->getExprLoc(), diag::err_omp_section_negative)
-<< 0 << LowerBoundValue.toString(/*Radix=*/10, /*Signed=*/true)
+Diag(LowerBound->getExprLoc(), diag::err_omp_section_not_subset_of_array)
 << LowerBound->getSourceRange();
 return ExprError();
   }
@@ -4321,19 +4320,19 @@
   if (Length) {
 llvm::APSInt LengthValue;
 if (Length->EvaluateAsInt(LengthValue, Context)) {
-  // OpenMP 4.0, [2.4 Array Sections]
-  // The lower-bound and length must evaluate to non-negative integers.
+  // OpenMP 4.5, [2.4 Array Sections]
+  // The length must evaluate to non-negative integers.
   if (LengthValue.isNegative()) {
-Diag(Length->getExprLoc(), diag::err_omp_section_negative)
-<< 1 << LengthValue.toString(/*Radix=*/10, /*Signed=*/true)
+Diag(Length->getExprLoc(), diag::err_omp_section_length_negative)
+<< LengthValue.toString(/*Radix=*/10, /*Signed=*/true)
 << Length->getSourceRange();
 return ExprError();
   }
 }
   } else if (ColonLoc.isValid() &&
  (OriginalTy.isNull() || (!OriginalTy->isConstantArrayType() &&
   !OriginalTy->isVariableArrayType( {
-// OpenMP 4.0, [2.4 Array Sections]
+// OpenMP 4.5, [2.4 Array Sections]
 // When the size of the array dimension is not known, the length must be
 // specified explicitly.
 Diag(ColonLoc, diag::err_omp_section_length_undefined)
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8260,8 +8260,10 @@
   InGroup, DefaultIgnore;
 def err_omp_section_incomplete_type : Error<
   "section of pointer to incomplete type %0">;
-def err_omp_section_negative : Error<
-  "section %select{lower bound|length}0 is evaluated to a negative value %1">;
+def err_omp_section_not_subset_of_array : Error<
+  "array section must be a subset of the original array">;
+def err_omp_section_length_negative : Error<
+  "section length is evaluated to a negative value %0">;
 def err_omp_section_length_undefined : Error<
   "section length is unspecified and cannot be inferred because subscripted value is %select{not an array|an array of unknown bound}0">;
 def err_omp_wrong_linear_modifier : Error<
Index: cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
@@ -80,6 +80,10 @@
   foo();
 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
   foo();
+#pragma omp target parallel map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
+  foo();
+#pragma omp target parallel map(l[:-1]) // expected-error 2 {{section leng

r276180 - When copying an array into a lambda, destroy temporaries from

2016-07-20 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Jul 20 16:02:43 2016
New Revision: 276180

URL: http://llvm.org/viewvc/llvm-project?rev=276180&view=rev
Log:
When copying an array into a lambda, destroy temporaries from
the copy-constructor immediately and enter a partial array
cleanup for previously-copied elements.

Fixes PR28595.

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=276180&r1=276179&r2=276180&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Jul 20 16:02:43 2016
@@ -562,6 +562,20 @@ static void EmitBaseInitializer(CodeGenF
   isBaseVirtual);
 }
 
+/// Initialize a member of aggregate type using the given expression
+/// as an initializer.
+///
+/// The member may be an array.  If so:
+/// - the destination l-value will be a pointer of the *base* element type,
+/// - ArrayIndexVar will be a pointer to a variable containing the current
+///   index within the destination array, and
+/// - ArrayIndexes will be an array of index variables, one for each level
+///   of array nesting, which will need to be updated as appropriate for the
+///   array structure.
+///
+/// On an array, this function will invoke itself recursively.  Each time,
+/// it drills into one nesting level of the member type and sets up a
+/// loop updating the appropriate array index variable.
 static void EmitAggMemberInitializer(CodeGenFunction &CGF,
  LValue LHS,
  Expr *Init,
@@ -569,10 +583,18 @@ static void EmitAggMemberInitializer(Cod
  QualType T,
  ArrayRef ArrayIndexes,
  unsigned Index) {
+  assert(ArrayIndexVar.isValid() == (ArrayIndexes.size() != 0));
+
   if (Index == ArrayIndexes.size()) {
 LValue LV = LHS;
 
+Optional Scope;
+
 if (ArrayIndexVar.isValid()) {
+  // When we're processing an array, the temporaries from each
+  // element's construction are destroyed immediately.
+  Scope.emplace(CGF);
+
   // If we have an array index variable, load it and use it as an offset.
   // Then, increment the value.
   llvm::Value *Dest = LHS.getPointer();
@@ -586,6 +608,19 @@ static void EmitAggMemberInitializer(Cod
   CharUnits EltSize = CGF.getContext().getTypeSizeInChars(T);
   CharUnits Align = LV.getAlignment().alignmentOfArrayElement(EltSize);
   LV.setAddress(Address(Dest, Align));
+
+  // Enter a partial-array EH cleanup to destroy previous members
+  // of the array if this initialization throws.
+  if (CGF.CGM.getLangOpts().Exceptions) {
+if (auto DtorKind = T.isDestructedType()) {
+  if (CGF.needsEHCleanup(DtorKind)) {
+CGF.pushRegularPartialArrayCleanup(LHS.getPointer(),
+   LV.getPointer(), T,
+   LV.getAlignment(),
+   CGF.getDestroyer(DtorKind));
+  }
+}
+  }
 }
 
 switch (CGF.getEvaluationKind(T)) {

Modified: cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp?rev=276180&r1=276179&r2=276180&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp Wed Jul 20 16:02:43 2016
@@ -116,6 +116,56 @@ int *PR22071_fun() {
   return [&] { return &y; }();
 }
 
+namespace pr28595 {
+  struct Temp {
+Temp();
+~Temp() noexcept(false);
+  };
+  struct A {
+A();
+A(const A &a, const Temp &temp = Temp());
+~A();
+  };
+
+  // CHECK-LABEL: define void @_ZN7pr285954testEv()
+  void test() {
+// CHECK: [[ARRAY:%.*]] = alloca [3 x [5 x [[A:%.*, align 1
+// CHECK: [[DESTIDX:%.*]] = alloca i64, align 8
+// CHECK: [[I0:%.*]] = alloca i64, align 8
+// CHECK: [[I1:%.*]] = alloca i64, align 8
+A array[3][5];
+
+// CHECK: [[DESTBASE:%.*]] = bitcast [3 x [5 x [[A* {{.*}} to [[A]]*
+// CHECK: store i64 0, i64* [[DESTIDX]], align 8
+// CHECK: store i64 0, i64* [[I0]], align 8
+// CHECK: br label
+// CHECK: icmp ult
+// CHECK: store i64 0, i64* [[I1]], align 8
+// CHECK: br label
+// CHECK: icmp ult
+// CHECK: [[T0:%.*]] = load i64, i64* [[DESTIDX]], align 8
+// CHECK: [[DEST:%.*]] = getelementptr inbounds [[A]], [[A]]* 
[[DESTBASE]], i64 [[T0]]
+// CHECK: invoke void @_ZN7pr285954TempC1Ev
+// CHECK: invoke void @_ZN7pr285951AC1ERKS0_RKNS_4TempE
+// CHECK: invoke v

[PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread David Li via cfe-commits
davidxl created this revision.
davidxl added reviewers: vsk, silvas.
davidxl added a subscriber: cfe-commits.

Added documentation for %h and %m specifiers.  %m specifier which specifies 
the number of copies is not documented yet (treated as internal for now)

https://reviews.llvm.org/D22593

Files:
  docs/UsersManual.rst

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,45 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can 
still
+   happen because of the ``pid`` re-use by the OS. Aother side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the 
profile
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)
+   will be automatically merged by the profiler runtime during the dumping. If
+   the program links in multiple instrumented shared libraries, each library 
will
+   dump the profile data into its own profile data file (with its unique 
integer
+   id embedded in the profile name).
+
+   .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,45 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can still
+   happen because of the ``pid`` re-use by the OS. Aother side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier ca

Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread David Li via cfe-commits
davidxl updated this revision to Diff 64759.
davidxl added a comment.

Fixed a typo


https://reviews.llvm.org/D22593

Files:
  docs/UsersManual.rst

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,45 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can 
still
+   happen because of the ``pid`` re-use by the OS. Another side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the 
profile
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)
+   will be automatically merged by the profiler runtime during the dumping. If
+   the program links in multiple instrumented shared libraries, each library 
will
+   dump the profile data into its own profile data file (with its unique 
integer
+   id embedded in the profile name).
+
+   .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,45 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can still
+   happen because of the ``pid`` re-use by the OS. Another side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the profile
+   name.  When this specifier is used, the profiler runtime will substitute ``%m``
+   with a unique integer identifier associated with the instrumente

Re: [PATCH] D22577: Include unreferenced nested types in member list only for CodeView

2016-07-20 Thread Adrian McCarthy via cfe-commits
amccarth updated this revision to Diff 64761.
amccarth added a comment.

Addressed feedback.


https://reviews.llvm.org/D22577

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
  test/CodeGenCXX/debug-info-ms-abi.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -121,15 +121,19 @@
 // CHECK-SAME: flags: DIFlagFwdDecl,
 // CHECK-SAME: identifier: "_ZTS9Template1IPvE")
 
-// Explicit instatiation.
+// Explicit instantiation.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1",
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS9Template1IiE")
 
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate",
 // CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME: flags: DIFlagFwdDecl
+// CHECK-SAME: identifier: "_ZTSN11SpecializedIiE6MemberE")
+
 // Forward-declared member of a template.
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
 // CHECK-SAME: flags: DIFlagFwdDecl
Index: test/CodeGenCXX/debug-info-ms-abi.cpp
===
--- test/CodeGenCXX/debug-info-ms-abi.cpp
+++ test/CodeGenCXX/debug-info-ms-abi.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -debug-info-kind=limited -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
 
 // Tests that certain miscellaneous features work in the MS ABI.
 
@@ -12,19 +12,22 @@
 Foo::Nested n;
 
 // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
 // CHECK-SAME: identifier: ".?AUFoo@@"
 
-// CHECK: !DISubprogram(name: "f",
+// CHECK: ![[elements]] = !{![[vptr:[0-9]+]], ![[Nested:[0-9]+]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]]}
+
+// CHECK: ![[Nested]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
+// CHECK-SAME: identifier: ".?AUNested@Foo@@"
+
+// CHECK: ![[f]] = !DISubprogram(name: "f",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
 
-// CHECK: !DISubprogram(name: "g",
+// CHECK: ![[g]] = !DISubprogram(name: "g",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
 
-// CHECK: !DISubprogram(name: "h",
+// CHECK: ![[h]] = !DISubprogram(name: "h",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
-
-// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
-// CHECK-SAME: identifier: ".?AUNested@Foo@@"
Index: test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
===
--- test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
+++ test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
@@ -19,6 +19,6 @@
 
 Test t;
 
-// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
+// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -254,6 +254,8 @@
 llvm::DIFile *F,
 SmallVectorImpl &E,
 llvm::DIType *RecordTy, const RecordDecl *RD);
+  void CollectRecordNestedRecord(const RecordDecl *RD,
+ SmallVectorImpl &E);
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl &E,
llvm::DICompositeType *RecordTy);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1090,6 +1090,14 @@
   elements.push_back(FieldType);
 }
 
+void CGDebugInfo::CollectRecordNestedRecord(
+const RecordDecl *RD, SmallVectorImpl &elements) {
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  SourceLocation Loc = RD->getLocation();
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateFile(Loc));
+  elements.push_back(nestedType);
+}
+
 void CGDebugInfo

Re: [PATCH] D22577: Include unreferenced nested types in member list only for CodeView

2016-07-20 Thread Adrian McCarthy via cfe-commits
amccarth marked 2 inline comments as done.
amccarth added a comment.

https://reviews.llvm.org/D22577



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


Re: [libcxx] r276092 - Unbreak is_constructible tests for Clang <= 3.7.

2016-07-20 Thread Lang Hames via cfe-commits
Hi Eric,

I'm seeing failures on the builders that look like they're related to this
- http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/359/

Could you look in to what's going on here?

- Lang.


On Tue, Jul 19, 2016 at 11:36 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Jul 20 01:36:11 2016
> New Revision: 276092
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276092&view=rev
> Log:
> Unbreak is_constructible tests for Clang <= 3.7.
>
> There is a bug in Clang's __is_constructible builtin that causes it
> to return true for function types; ex [T = void()].
>
>
>
> Modified:
>
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>
> Modified:
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>
> ==
> ---
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> (original)
> +++
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> Wed Jul 20 01:36:11 2016
> @@ -151,9 +151,21 @@ int main()
>  test_is_constructible();
>  test_is_not_constructible();
>
> +test_is_not_constructible();
> +test_is_not_constructible();
> +
> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
> regularly.
> +// In those compiler versions the __is_constructible builtin gives the
> wrong
> +// results for abominable function types.
> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
> +#define WORKAROUND_CLANG_BUG
> +#endif
> +#if !defined(WORKAROUND_CLANG_BUG)
> +test_is_not_constructible();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  #endif
> +#endif
>  }
>
> Modified:
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>
> ==
> ---
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> (original)
> +++
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> Wed Jul 20 01:36:11 2016
> @@ -107,7 +107,19 @@ int main()
>  #if TEST_STD_VER >= 11
>  test_is_not_default_constructible();
>  test_is_not_default_constructible();
> +
> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
> regularly.
> +// In those compiler versions the __is_constructible builtin gives the
> wrong
> +// results for abominable function types.
> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
> +#define WORKAROUND_CLANG_BUG
> +#endif
> +#if !defined(WORKAROUND_CLANG_BUG)
>  test_is_not_default_constructible();
> -test_is_not_default_constructible();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +#endif
>  #endif
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2016-07-20 Thread Ed Maste via cfe-commits
emaste added a comment.

As it happens on FreeBSD/i386 malloc returns a 16-byte-aligned pointer for 
allocations with size >= 16 so will not be affected by this issue.


https://reviews.llvm.org/D12512



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


Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2016-07-20 Thread Ed Maste via cfe-commits
emaste added inline comments.


Comment at: test/test_cxa_allocate_exception.pass.cpp:34
@@ +33,3 @@
+const std::size_t required_alignment = alignof(__cxa_exception);
+const bool requires_over_alignment = max_alignment < required_alignment;
+

`requires_over_alignment` not used?


https://reviews.llvm.org/D12512



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


Re: [PATCH] D22577: Include unreferenced nested types in member list only for CodeView

2016-07-20 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D22577



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


[PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-20 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: echristo, dexonsmith.
vsk added a subscriber: cfe-commits.
Herald added subscribers: mehdi_amini, aemerson.

Compute an effective triple once per job. Cache the triple in the
prevailing ToolChain for the duration of the job.

Clients which need effective triples now look them up in the ToolChain.
This eliminates wasteful re-computation of effective triples (e.g in
getARMFloatABI()).

While we're at it, delete MachO::ComputeEffectiveClangTriple. It was a
no-op override.

---

Note: This commit is based on ToT clang with the original attempt
(r275895) reverted. See the list thread on r275895 for more context.

https://reviews.llvm.org/D22596

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -791,7 +791,7 @@
 // -mfloat-abi=.
 arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
   const Driver &D = TC.getDriver();
-  const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(Args));
+  const llvm::Triple &Triple = TC.getEffectiveTriple();
   auto SubArch = getARMSubArchVersionNumber(Triple);
   arm::FloatABI ABI = FloatABI::Invalid;
   if (Arg *A =
@@ -1192,8 +1192,7 @@
 
 void Clang::AddAArch64TargetArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   if (!Args.hasFlag(options::OPT_mred_zone, options::OPT_mno_red_zone, true) ||
   Args.hasArg(options::OPT_mkernel) ||
@@ -3844,8 +3843,8 @@
 void Clang::ConstructJob(Compilation &C, const JobAction &JA,
  const InputInfo &Output, const InputInfoList &Inputs,
  const ArgList &Args, const char *LinkingOutput) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const std::string &TripleStr = Triple.getTriple();
 
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -6501,9 +6500,8 @@
   assert(Inputs.size() == 1 && "Unexpected number of inputs.");
   const InputInfo &Input = Inputs[0];
 
-  std::string TripleStr =
-  getToolChain().ComputeEffectiveClangTriple(Args, Input.getType());
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const std::string &TripleStr = Triple.getTriple();
 
   // Don't warn about "clang -w -c foo.s"
   Args.ClaimAllArgs(options::OPT_w);
@@ -8879,9 +8877,7 @@
 break;
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
-arm::appendEBLinkFlags(
-Args, CmdArgs,
-llvm::Triple(getToolChain().ComputeEffectiveClangTriple(Args)));
+arm::appendEBLinkFlags(Args, CmdArgs, getToolChain().getEffectiveTriple());
 CmdArgs.push_back("-m");
 switch (getToolChain().getTriple().getEnvironment()) {
 case llvm::Triple::EABI:
@@ -9045,8 +9041,7 @@
const char *LinkingOutput) const {
   claimNoWarnArgs(Args);
 
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple = llvm::Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   ArgStringList CmdArgs;
 
@@ -9381,8 +9376,7 @@
   static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
 
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple = llvm::Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
   const bool isAndroid = ToolChain.getTriple().isAndroid();
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -312,9 +312,6 @@
   /// @name ToolChain Implementation
   /// {
 
-  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
-  types::ID InputType) const override;
-
   types::ID LookupTypeForExtension(const char *Ext) const override;
 
   bool HasNativeLLVMSupport() const override;
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -176,13 +176,6 @@
 
 MachO::~MachO() {}
 
-std::string MachO::ComputeEffectiveClangTriple(const ArgList &Args,
-   types::ID InputType) const {
-  llvm::Triple Triple(ComputeLLVMTri

r276188 - Fix memory leak introduced in r276159.

2016-07-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jul 20 16:38:26 2016
New Revision: 276188

URL: http://llvm.org/viewvc/llvm-project?rev=276188&view=rev
Log:
Fix memory leak introduced in r276159.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=276188&r1=276187&r2=276188&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 20 16:38:26 2016
@@ -787,6 +787,9 @@ ASTContext::~ASTContext() {
MaterializedTemporaryValues)
 MTVPair.second->~APValue();
 
+  for (const auto &Value : ModuleInitializers)
+Value.second->~PerModuleInitializers();
+
   llvm::DeleteContainerSeconds(MangleNumberingContexts);
 }
 


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


Re: r275895 - [Driver] Compute effective target triples once per job (NFCI)

2016-07-20 Thread Vedant Kumar via cfe-commits

> On Jul 19, 2016, at 3:53 PM, Eric Christopher  wrote:
> 
> 
> 
> On Tue, Jul 19, 2016 at 3:51 PM Vedant Kumar  wrote:
> 
> > On Jul 19, 2016, at 3:38 PM, Eric Christopher  wrote:
> >
> >
> >
> > On Tue, Jul 19, 2016 at 3:24 PM Vedant Kumar  wrote:
> >
> > > On Jul 19, 2016, at 3:02 PM, Eric Christopher  wrote:
> > >
> > > ... this is pretty crazy. I think that you needed to plumb the effective 
> > > triple through everything means that it really needs to be owned 
> > > somewhere else and cached.
> > >
> > > Can you rethink this? In general it doesn't make sense to have everything 
> > > need this passed down.
> >
> > This came up during review.
> >
> > I couldn't find a thread anywhere - and there's not one in the phab 
> > revision.
> 
> Here's the relevant part of the discussion:
> 
>   http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160711/164519.html
> 
> 
> 
> OK.
>  
> > I did try to find a suitable place to cache the effective triple, but did 
> > not
> > see one. I still don't, and am open to suggestions / willing to revert for 
> > more
> > review if you'd like.
> >
> > Initially I thought it would be possible to cache the triple in the Tool or
> > ToolChain, but that seems like it could break use-cases in which jobs are
> > constructed from different threads.
> >
> >
> > Where do we do that? As far as I know we don't have a case where this 
> > applies and I'd consider all of this infrastructure to be internal for any 
> > external tools.
> 
> We don't do that in-tree.
> 
> OK. 
>  
> 
> 
> > Caching the triple in the Compilation seems like it would have have the same
> > issue. I'm not sure how much of a problem this is in practice. We could try
> > setting the effective triple in the Compilation with a RAII wrapper, e.g:
> >
> >   {
> > RegisterEffectiveTriple TripleRAII(C, EffectiveTriple);
> > T->ConstructJob(...);
> >   } // Effective triple cleared from the Compilation.
> >
> > Let me know if you have alternate suggestions, and how you'd like to move
> > forward.
> >
> >
> > Adding Justin here a bit since he's looked at it more recently, but my 
> > general case would be to cache in the ToolChain. Anything that has problems 
> > with that caching will need to be fixed to deal (either anything depending 
> > on ToolChain in clang or external code).
> 
> Sure, I can give that a shot (barring any alternate suggestions that may come
> up).
> 
> To sketch it:
> 
>   - Add {get,set}EffectiveTriple to ToolChain
>   - Assert that the triple exists in getEffectiveTriple()
>   - Use a wrapper to set the triple before Tool::ConstructJob()
>   - Remove the extra triple arguments
> 
> 
> Seems like it'll work. Maybe even compute it at ToolChain initialization so 
> you don't need the setter?

In general, it looks like effective triples are allowed to change based on the
`types::ID InputType` supplied by the job. I'll look into changing that. For
now, that information isn't available when ToolChain's are initialized.

PTAL at https://reviews.llvm.org/D22596.

thanks,
vedant


> 
> -eric
>  
> vedant
> 
> 
> >
> > -eric
> >
> > thanks,
> > vedant
> >
> >
> > >
> > > Thanks!
> > >
> > > -eric
> > >
> > > On Mon, Jul 18, 2016 at 1:04 PM Vedant Kumar via cfe-commits 
> > >  wrote:
> > > Author: vedantk
> > > Date: Mon Jul 18 14:56:38 2016
> > > New Revision: 275895
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=275895&view=rev
> > > Log:
> > > [Driver] Compute effective target triples once per job (NFCI)
> > >
> > > Compute an effective target triple exactly once in ConstructJob(), and
> > > then simply pass around references to it. This eliminates wasteful
> > > re-computation of effective triples (e.g in getARMFloatABI()).
> > >
> > > Differential Revision: https://reviews.llvm.org/D22290
> > >
> > > Modified:
> > > cfe/trunk/docs/ReleaseNotes.rst
> > > cfe/trunk/include/clang/Driver/SanitizerArgs.h
> > > cfe/trunk/include/clang/Driver/Tool.h
> > > cfe/trunk/include/clang/Driver/ToolChain.h
> > > cfe/trunk/lib/Driver/Driver.cpp
> > > cfe/trunk/lib/Driver/SanitizerArgs.cpp
> > > cfe/trunk/lib/Driver/ToolChain.cpp
> > > cfe/trunk/lib/Driver/ToolChains.cpp
> > > cfe/trunk/lib/Driver/ToolChains.h
> > > cfe/trunk/lib/Driver/Tools.cpp
> > > cfe/trunk/lib/Driver/Tools.h
> > >
> > > Modified: cfe/trunk/docs/ReleaseNotes.rst
> > > URL: 
> > > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=275895&r1=275894&r2=275895&view=diff
> > > ==
> > > --- cfe/trunk/docs/ReleaseNotes.rst (original)
> > > +++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 18 14:56:38 2016
> > > @@ -121,7 +121,8 @@ These are major API changes that have ha
> > >  Clang. If upgrading an external codebase that uses Clang as a library,
> > >  this section should help get you past the largest hurdles of upgrading.
> > >
> > > --  ...
> > > +- Classes which inherit from ``driver::Tool

Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-20 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.


Comment at: include/clang/Driver/ToolChain.h:71
@@ -70,2 +70,3 @@
   const llvm::Triple Triple;
+  mutable llvm::Triple EffectiveTriple;
   const llvm::opt::ArgList &Args;

Documentation would be appreciated, a mutable field is never trivial to me.


Comment at: include/clang/Driver/ToolChain.h:145
@@ -143,1 +144,3 @@
 
+  /// \brief Set the toolchain's effective clang triple.
+  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }

No brief.


https://reviews.llvm.org/D22596



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


Re: [PATCH] D22476: [AST] Make MemberExpr non-dependent according to core issue 224

2016-07-20 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 64777.
mgehre added a comment.

- Properly check for being member of current instantiation.
- Add new testcase test/CXX/temp/temp.res/temp.dep/temp.dep.expr/p5.cpp
- Added assert() according to review comment


https://reviews.llvm.org/D22476

Files:
  lib/AST/Expr.cpp
  lib/Sema/SemaOverload.cpp
  test/Analysis/stack-addr-ps.cpp
  test/CXX/class.access/class.access.dcl/p1.cpp
  test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
  test/CXX/drs/dr3xx.cpp
  test/CXX/temp/temp.res/temp.dep/temp.dep.expr/p5.cpp
  test/SemaTemplate/dependent-names.cpp
  test/SemaTemplate/enum-argument.cpp
  test/SemaTemplate/member-access-expr.cpp

Index: test/SemaTemplate/member-access-expr.cpp
===
--- test/SemaTemplate/member-access-expr.cpp
+++ test/SemaTemplate/member-access-expr.cpp
@@ -154,9 +154,7 @@
   template  class Derived : public Base {
 A *field;
 void get(B **ptr) {
-  // It's okay if at some point we figure out how to diagnose this
-  // at instantiation time.
-  *ptr = field;
+  *ptr = field; // expected-error{{assigning to 'test6::B *' from incompatible type 'test6::A *'}}
 }
   };
 }
Index: test/SemaTemplate/enum-argument.cpp
===
--- test/SemaTemplate/enum-argument.cpp
+++ test/SemaTemplate/enum-argument.cpp
@@ -31,7 +31,7 @@
 unsigned long long bitfield : e0;
 
 void f(int j) {
-  bitfield + j;
+  (void)(bitfield + j);
 }
   };
 }
Index: test/SemaTemplate/dependent-names.cpp
===
--- test/SemaTemplate/dependent-names.cpp
+++ test/SemaTemplate/dependent-names.cpp
@@ -274,7 +274,7 @@
   int e[10];
 };
 void g() {
-  S().f(); // expected-note {{here}}
+  S().f();
 }
   }
 
Index: test/CXX/temp/temp.res/temp.dep/temp.dep.expr/p5.cpp
===
--- /dev/null
+++ test/CXX/temp/temp.res/temp.dep/temp.dep.expr/p5.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace CWG224 {
+  template  struct A {
+int* i;
+typedef T newT;
+static const int my_I = I;
+static const int my_I2 = I+0;
+static const int my_I3 = my_I;
+void f() {
+  char* j = nullptr;
+  i = j; // expected-error {{incompatible type}}
+  i = nullptr;
+  (*this).i = j; // FIXME {{incompatible type}}
+  this->i = j; // FIXME {{incompatible type}}
+  A::i = j; // expected-error {{incompatible type}}
+  A::i = j; // expected-error {{incompatible type}}
+  A::i = j; // not current instantiation
+  A::i = j; // expected-error {{incompatible type}}
+  ::CWG224::A::i = j; // expected-error {{incompatible type}}
+  A::i = j; // FIXME (https://reviews.llvm.org/D22587)
+  A::i = j; // not current instantiation
+  A::i = j; // FIXME (https://reviews.llvm.org/D22587)
+}
+struct B {
+  int* b;
+  void f() {
+char* c = nullptr;
+b = c; // expected-error {{incompatible type}}
+B::b = c; // expected-error {{incompatible type}}
+A::B::b = c; // expected-error {{incompatible type}}
+A::B::b = c; // not current instantiation
+  }
+};
+  };
+
+  template  class A {
+void f(A* a1, A* a2) {
+  a1->i = 1; // FIXME {{incompatible type}}
+  a2->i = 1; // not current instantiation
+}
+  };
+}
Index: test/CXX/drs/dr3xx.cpp
===
--- test/CXX/drs/dr3xx.cpp
+++ test/CXX/drs/dr3xx.cpp
@@ -1167,8 +1167,8 @@
 namespace dr390 { // dr390: yes
   template
   struct A {
-A() { f(); } // expected-warning {{call to pure virt}}
-virtual void f() = 0; // expected-note {{here}}
+A() { f(); } // expected-warning {{call to pure virt}} expected-warning {{call to pure virt}}
+virtual void f() = 0; // expected-note {{here}} expected-note {{here}}
 virtual ~A() = 0;
   };
   template A::~A() { T::error; } // expected-error {{cannot be used prior to}}
Index: test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
===
--- test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
+++ test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
@@ -29,7 +29,10 @@
   };
 }
 
-struct Opaque0 {};
+struct Opaque0 {}; // expected-note {{no known conversion}}
+#if __cplusplus >= 201103L
+//  expected-note@-2 {{no known conversion}}
+#endif
 
 namespace test1 {
   struct A {
@@ -112,7 +115,7 @@
 }
 
 void test5() {
-  Opaque0 _ = hiding;
+  Opaque0 _ = hiding; // expected-error {{no viable conversion from 'int' to 'Opaque0'}}
 }
   };
 }
Index: test/CXX/class.access/class.access.dcl/p1.cpp
===
--- test/CXX/class.access/class.access.dcl/p1.cpp
+++ test

Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-07-20 Thread Loki Astari via cfe-commits
LokiAstari added a comment.

@djasper@klimek

Is that a sufficient example? Or do I need to do some more exhaustive search of 
github for projects?


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22426: Fix automatic detection of ARM MSVC toolset in clang.exe

2016-07-20 Thread Dave Bartolomeo via cfe-commits
DaveBartolomeo added a comment.

Just to make sure I'm clear on the consensus, the new plan is:

If clang.exe is x64-hosted and an x64-hosted MSVC toolchain is available, use 
the x64-hosted MSVC toolchain. Otherwise, use the x86-hosted MSVC toolchain.

Right?


https://reviews.llvm.org/D22426



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


Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread Sean Silva via cfe-commits
silvas added a comment.

LGTM with some small wording nits.

We may want to extend this to mention number modifier to `%m` (e.g. `%4m`). 
Perhaps it is better to leave that to more advanced documentation -- your 
experiments showed that even just 1 merge pool is quite scalable IIRC.



Comment at: docs/UsersManual.rst:1500
@@ +1499,3 @@
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)

I would suggest saying `Additionally, multiple...` instead of just `Multiple` 
to highlight that this is an additional behavior that is caused by using `%m`.


Comment at: docs/UsersManual.rst:1501
@@ +1500,3 @@
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)
+   will be automatically merged by the profiler runtime during the dumping. If

You probably want to say "raw profiles" instead of just "profile" to clarify 
that this is a different sense of "merge" than `llvm-profdata merge ...` (or 
otherwise clarify).


https://reviews.llvm.org/D22593



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


Re: [libcxx] r276092 - Unbreak is_constructible tests for Clang <= 3.7.

2016-07-20 Thread Eric Fiselier via cfe-commits
Hi Lang,

Sorry about the breakage. I always forget __clang_major__ and
__clang_minor__ are useless when dealing with apple-clang.
Who can I complain to about that?

I'll check in a fix shortly.

/Eric

On Wed, Jul 20, 2016 at 3:32 PM, Lang Hames  wrote:

> Hi Eric,
>
> I'm seeing failures on the builders that look like they're related to this
> - http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/359/
>
> Could you look in to what's going on here?
>
> - Lang.
>
>
> On Tue, Jul 19, 2016 at 11:36 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Wed Jul 20 01:36:11 2016
>> New Revision: 276092
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276092&view=rev
>> Log:
>> Unbreak is_constructible tests for Clang <= 3.7.
>>
>> There is a bug in Clang's __is_constructible builtin that causes it
>> to return true for function types; ex [T = void()].
>>
>>
>>
>> Modified:
>>
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>>
>> Modified:
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>>
>> ==
>> ---
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>> Wed Jul 20 01:36:11 2016
>> @@ -151,9 +151,21 @@ int main()
>>  test_is_constructible();
>>  test_is_not_constructible();
>>
>> +test_is_not_constructible();
>> +test_is_not_constructible();
>> +
>> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
>> regularly.
>> +// In those compiler versions the __is_constructible builtin gives the
>> wrong
>> +// results for abominable function types.
>> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
>> +#define WORKAROUND_CLANG_BUG
>> +#endif
>> +#if !defined(WORKAROUND_CLANG_BUG)
>> +test_is_not_constructible();
>>  test_is_not_constructible ();
>>  test_is_not_constructible ();
>>  test_is_not_constructible ();
>>  test_is_not_constructible ();
>>  #endif
>> +#endif
>>  }
>>
>> Modified:
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>>
>> ==
>> ---
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>> Wed Jul 20 01:36:11 2016
>> @@ -107,7 +107,19 @@ int main()
>>  #if TEST_STD_VER >= 11
>>  test_is_not_default_constructible();
>>  test_is_not_default_constructible();
>> +
>> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
>> regularly.
>> +// In those compiler versions the __is_constructible builtin gives the
>> wrong
>> +// results for abominable function types.
>> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
>> +#define WORKAROUND_CLANG_BUG
>> +#endif
>> +#if !defined(WORKAROUND_CLANG_BUG)
>>  test_is_not_default_constructible();
>> -test_is_not_default_constructible();
>> +test_is_not_default_constructible ();
>> +test_is_not_default_constructible ();
>> +test_is_not_default_constructible ();
>> +test_is_not_default_constructible ();
>> +#endif
>>  #endif
>>  }
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22557: [libcxx] Diagnose invalid memory order arguments in . Fixes PR21179.

2016-07-20 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:569
@@ +568,3 @@
+__attribute__ ((__enable_if__(__m == memory_order_release \
+   || __m == memory_order_acq_rel, "")))  \
+__attribute__ ((__unavailable__("memory order argument to atomic operation 
is invalid")))

bcraig wrote:
> what about relaxed?
Load relaxed is valid.


https://reviews.llvm.org/D22557



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


[libcxx] r276200 - Unbreak traits tests by handling differences between version macros in clang/apple-clang.

2016-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 20 17:53:21 2016
New Revision: 276200

URL: http://llvm.org/viewvc/llvm-project?rev=276200&view=rev
Log:
Unbreak traits tests by handling differences between version macros in 
clang/apple-clang.

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
libcxx/trunk/test/support/test_macros.h

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=276200&r1=276199&r2=276200&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 Wed Jul 20 17:53:21 2016
@@ -157,7 +157,8 @@ int main()
 // TODO: Remove this workaround once Clang <= 3.7 are no longer used regularly.
 // In those compiler versions the __is_constructible builtin gives the wrong
 // results for abominable function types.
-#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
+#if (defined(TEST_APPLE_CLANG_VER) && TEST_APPLE_CLANG_VER < 703) \
+ || (defined(TEST_CLANG_VER) && TEST_CLANG_VER < 308)
 #define WORKAROUND_CLANG_BUG
 #endif
 #if !defined(WORKAROUND_CLANG_BUG)

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp?rev=276200&r1=276199&r2=276200&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
 Wed Jul 20 17:53:21 2016
@@ -111,7 +111,8 @@ int main()
 // TODO: Remove this workaround once Clang <= 3.7 are no longer used regularly.
 // In those compiler versions the __is_constructible builtin gives the wrong
 // results for abominable function types.
-#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
+#if (defined(TEST_APPLE_CLANG_VER) && TEST_APPLE_CLANG_VER < 703) \
+ || (defined(TEST_CLANG_VER) && TEST_CLANG_VER < 308)
 #define WORKAROUND_CLANG_BUG
 #endif
 #if !defined(WORKAROUND_CLANG_BUG)

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=276200&r1=276199&r2=276200&view=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Wed Jul 20 17:53:21 2016
@@ -34,6 +34,14 @@
 #define TEST_HAS_BUILTIN(X) 0
 #endif
 
+#if defined(__apple_build_version__)
+#define TEST_APPLE_CLANG_VER (__clang_major__ * 100) + __clang_minor__
+#elif defined(__clang_major__)
+#define TEST_CLANG_VER (__clang_major__ * 100) + __clang_minor__
+#elif defined(__GNUC__)
+#define TEST_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#endif
+
 /* Make a nice name for the standard version */
 #ifndef TEST_STD_VER
 #if  __cplusplus <= 199711L


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


Re: [libcxx] r276092 - Unbreak is_constructible tests for Clang <= 3.7.

2016-07-20 Thread Eric Fiselier via cfe-commits
I think it should be fixed in r276200. I'll watch the bots.

On Wed, Jul 20, 2016 at 4:39 PM, Eric Fiselier  wrote:

> Hi Lang,
>
> Sorry about the breakage. I always forget __clang_major__ and
> __clang_minor__ are useless when dealing with apple-clang.
> Who can I complain to about that?
>
> I'll check in a fix shortly.
>
> /Eric
>
> On Wed, Jul 20, 2016 at 3:32 PM, Lang Hames  wrote:
>
>> Hi Eric,
>>
>> I'm seeing failures on the builders that look like they're related to
>> this -
>> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/359/
>>
>> Could you look in to what's going on here?
>>
>> - Lang.
>>
>>
>> On Tue, Jul 19, 2016 at 11:36 PM, Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Wed Jul 20 01:36:11 2016
>>> New Revision: 276092
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=276092&view=rev
>>> Log:
>>> Unbreak is_constructible tests for Clang <= 3.7.
>>>
>>> There is a bug in Clang's __is_constructible builtin that causes it
>>> to return true for function types; ex [T = void()].
>>>
>>>
>>>
>>> Modified:
>>>
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>>
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>>>
>>> Modified:
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>>>
>>> ==
>>> ---
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>> (original)
>>> +++
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>> Wed Jul 20 01:36:11 2016
>>> @@ -151,9 +151,21 @@ int main()
>>>  test_is_constructible();
>>>  test_is_not_constructible();
>>>
>>> +test_is_not_constructible();
>>> +test_is_not_constructible();
>>> +
>>> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
>>> regularly.
>>> +// In those compiler versions the __is_constructible builtin gives the
>>> wrong
>>> +// results for abominable function types.
>>> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
>>> +#define WORKAROUND_CLANG_BUG
>>> +#endif
>>> +#if !defined(WORKAROUND_CLANG_BUG)
>>> +test_is_not_constructible();
>>>  test_is_not_constructible ();
>>>  test_is_not_constructible ();
>>>  test_is_not_constructible ();
>>>  test_is_not_constructible ();
>>>  #endif
>>> +#endif
>>>  }
>>>
>>> Modified:
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp?rev=276092&r1=276091&r2=276092&view=diff
>>>
>>> ==
>>> ---
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>>> (original)
>>> +++
>>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>>> Wed Jul 20 01:36:11 2016
>>> @@ -107,7 +107,19 @@ int main()
>>>  #if TEST_STD_VER >= 11
>>>  test_is_not_default_constructible();
>>>  test_is_not_default_constructible();
>>> +
>>> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
>>> regularly.
>>> +// In those compiler versions the __is_constructible builtin gives the
>>> wrong
>>> +// results for abominable function types.
>>> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
>>> +#define WORKAROUND_CLANG_BUG
>>> +#endif
>>> +#if !defined(WORKAROUND_CLANG_BUG)
>>>  test_is_not_default_constructible();
>>> -test_is_not_default_constructible();
>>> +test_is_not_default_constructible ();
>>> +test_is_not_default_constructible ();
>>> +test_is_not_default_constructible ();
>>> +test_is_not_default_constructible ();
>>> +#endif
>>>  #endif
>>>  }
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread Vedant Kumar via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D22593#490490, @silvas wrote:

> LGTM with some small wording nits.
>
> We may want to extend this to mention number modifier to `%m` (e.g. `%4m`). 
> Perhaps it is better to leave that to more advanced documentation -- your 
> experiments showed that even just 1 merge pool is quite scalable IIRC.


Actually, I think this is the right place to document the numeric modifier to 
`%m`. LGTM with Sean's nits.


https://reviews.llvm.org/D22593



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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-20 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 64792.
vsk added a comment.

- Address Mehdi's comments (drop \brief, document a field).
- Make ToolChain::setEffectiveTriple() private.


https://reviews.llvm.org/D22596

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -791,7 +791,7 @@
 // -mfloat-abi=.
 arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
   const Driver &D = TC.getDriver();
-  const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(Args));
+  const llvm::Triple &Triple = TC.getEffectiveTriple();
   auto SubArch = getARMSubArchVersionNumber(Triple);
   arm::FloatABI ABI = FloatABI::Invalid;
   if (Arg *A =
@@ -1192,8 +1192,7 @@
 
 void Clang::AddAArch64TargetArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   if (!Args.hasFlag(options::OPT_mred_zone, options::OPT_mno_red_zone, true) ||
   Args.hasArg(options::OPT_mkernel) ||
@@ -3844,8 +3843,8 @@
 void Clang::ConstructJob(Compilation &C, const JobAction &JA,
  const InputInfo &Output, const InputInfoList &Inputs,
  const ArgList &Args, const char *LinkingOutput) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const std::string &TripleStr = Triple.getTriple();
 
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -6501,9 +6500,8 @@
   assert(Inputs.size() == 1 && "Unexpected number of inputs.");
   const InputInfo &Input = Inputs[0];
 
-  std::string TripleStr =
-  getToolChain().ComputeEffectiveClangTriple(Args, Input.getType());
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const std::string &TripleStr = Triple.getTriple();
 
   // Don't warn about "clang -w -c foo.s"
   Args.ClaimAllArgs(options::OPT_w);
@@ -8879,9 +8877,7 @@
 break;
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
-arm::appendEBLinkFlags(
-Args, CmdArgs,
-llvm::Triple(getToolChain().ComputeEffectiveClangTriple(Args)));
+arm::appendEBLinkFlags(Args, CmdArgs, getToolChain().getEffectiveTriple());
 CmdArgs.push_back("-m");
 switch (getToolChain().getTriple().getEnvironment()) {
 case llvm::Triple::EABI:
@@ -9045,8 +9041,7 @@
const char *LinkingOutput) const {
   claimNoWarnArgs(Args);
 
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple = llvm::Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   ArgStringList CmdArgs;
 
@@ -9381,8 +9376,7 @@
   static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
 
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple = llvm::Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
   const bool isAndroid = ToolChain.getTriple().isAndroid();
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -312,9 +312,6 @@
   /// @name ToolChain Implementation
   /// {
 
-  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
-  types::ID InputType) const override;
-
   types::ID LookupTypeForExtension(const char *Ext) const override;
 
   bool HasNativeLLVMSupport() const override;
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -176,13 +176,6 @@
 
 MachO::~MachO() {}
 
-std::string MachO::ComputeEffectiveClangTriple(const ArgList &Args,
-   types::ID InputType) const {
-  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
-
-  return Triple.getTriple();
-}
-
 std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
 types::ID InputType) const {
   llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -68,7 +68,8 @@
 ToolChain::ToolChain(const Driver &D, const ll

Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-20 Thread Vedant Kumar via cfe-commits
vsk marked 2 inline comments as done.
vsk added a comment.

https://reviews.llvm.org/D22596



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


Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: docs/UsersManual.rst:1500
@@ +1499,3 @@
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)

silvas wrote:
> I would suggest saying `Additionally, multiple...` instead of just `Multiple` 
> to highlight that this is an additional behavior that is caused by using `%m`.
Done.


Comment at: docs/UsersManual.rst:1501
@@ +1500,3 @@
+   with a unique integer identifier associated with the instrumented binary. 
Multiple
+   profiles dumped from different processes (running on the same or different 
hosts)
+   will be automatically merged by the profiler runtime during the dumping. If

silvas wrote:
> You probably want to say "raw profiles" instead of just "profile" to clarify 
> that this is a different sense of "merge" than `llvm-profdata merge ...` (or 
> otherwise clarify).
Done. I also added another sentence clarifying it.


https://reviews.llvm.org/D22593



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


Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread David Li via cfe-commits
davidxl updated this revision to Diff 64793.
davidxl added a comment.

Addressed review comments.

I still think %4m etc is an advanced feature that needs more explanation. We 
can delay that to a later time.


https://reviews.llvm.org/D22593

Files:
  docs/UsersManual.rst

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,48 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can 
still
+   happen because of the ``pid`` re-use by the OS. Another side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the 
profile
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Additionally,
+   multiple raw profiles dumped from different processes (running on the same 
or
+   different hosts) will be automatically merged by the profiler runtime 
during the
+   dumping. If the program links in multiple instrumented shared libraries, 
each library
+   will dump the profile data into its own profile data file (with its unique 
integer
+   id embedded in the profile name). Note that the merging enabled by ``%m`` 
is for raw
+   profile data generated by profiler runtime. The resulting merged "raw" 
profile data
+   file still needs to be converted to a different format expected by the 
compiler (
+   see step 3 below).
+
+   .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1470,16 +1470,48 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can still
+   hap

Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread Sean Silva via cfe-commits
silvas accepted this revision.
silvas added a comment.
This revision is now accepted and ready to land.

LGTM (also, another small suggestion).



Comment at: docs/UsersManual.rst:1502
@@ +1501,3 @@
+   multiple raw profiles dumped from different processes (running on the same 
or
+   different hosts) will be automatically merged by the profiler runtime 
during the
+   dumping. If the program links in multiple instrumented shared libraries, 
each library

"running on the same or different hosts" should probably just be "that share a 
file system" to clarify that we depend on the filesystem guarantees and aren't 
doing anything else special.


https://reviews.llvm.org/D22593



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


Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread David Li via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276207: [Profile] Document new profile file name modifiers 
(authored by davidxl).

Changed prior to commit:
  https://reviews.llvm.org/D22593?vs=64793&id=64794#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22593

Files:
  cfe/trunk/docs/UsersManual.rst

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1470,16 +1470,48 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can 
still
+   happen because of the ``pid`` re-use by the OS. Another side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the 
profile
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Additionally,
+   multiple raw profiles dumped from different processes that share a file 
system (can be
+   on different hosts) will be automatically merged by the profiler runtime 
during the
+   dumping. If the program links in multiple instrumented shared libraries, 
each library
+   will dump the profile data into its own profile data file (with its unique 
integer
+   id embedded in the profile name). Note that the merging enabled by ``%m`` 
is for raw
+   profile data generated by profiler runtime. The resulting merged "raw" 
profile data
+   file still needs to be converted to a different format expected by the 
compiler (
+   see step 3 below).
+
+   .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1470,16 +1470,48 @@
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
 
.. code-block:: console
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of

r276207 - [Profile] Document new profile file name modifiers

2016-07-20 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Wed Jul 20 18:32:50 2016
New Revision: 276207

URL: http://llvm.org/viewvc/llvm-project?rev=276207&view=rev
Log:
[Profile] Document new profile file name modifiers

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



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=276207&r1=276206&r2=276207&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jul 20 18:32:50 2016
@@ -1470,8 +1470,13 @@ instrumentation:
 
 2. Run the instrumented executable with inputs that reflect the typical usage.
By default, the profile data will be written to a ``default.profraw`` file
-   in the current directory. You can override that default by setting the
-   ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file.
+   in the current directory. You can override that default by using option
+   ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` 
+   environment variable to specify an alternate file. If non-default file name
+   is specified by both the environment variable and the command line option,
+   the environment variable takes precedence. The file name pattern specified
+   can include different modifiers: ``%p``, ``%h``, and ``%m``.
+
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
runs.
@@ -1480,6 +1485,33 @@ instrumentation:
 
  $ LLVM_PROFILE_FILE="code-%p.profraw" ./code
 
+   The modifier ``%h`` can be used in scenarios where the same instrumented
+   binary is run in multiple different host machines dumping profile data
+   to a shared network based storage. The ``%h`` specifier will be substituted
+   with the hostname so that profiles collected from different hosts do not
+   clobber each other.
+
+   While the use of ``%p`` specifier can reduce the likelihood for the profiles
+   dumped from different processes to clobber each other, such clobbering can 
still
+   happen because of the ``pid`` re-use by the OS. Another side-effect of using
+   ``%p`` is that the storage requirement for raw profile data files is greatly
+   increased.  To avoid issues like this, the ``%m`` specifier can used in the 
profile
+   name.  When this specifier is used, the profiler runtime will substitute 
``%m``
+   with a unique integer identifier associated with the instrumented binary. 
Additionally,
+   multiple raw profiles dumped from different processes that share a file 
system (can be
+   on different hosts) will be automatically merged by the profiler runtime 
during the
+   dumping. If the program links in multiple instrumented shared libraries, 
each library
+   will dump the profile data into its own profile data file (with its unique 
integer
+   id embedded in the profile name). Note that the merging enabled by ``%m`` 
is for raw
+   profile data generated by profiler runtime. The resulting merged "raw" 
profile data
+   file still needs to be converted to a different format expected by the 
compiler (
+   see step 3 below).
+
+   .. code-block:: console
+
+ $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
+
+
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
``llvm-profdata`` tool to do this.


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


[libcxx] r276208 - Disable warning flags when running .fail.cpp tests.

2016-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 20 18:37:28 2016
New Revision: 276208

URL: http://llvm.org/viewvc/llvm-project?rev=276208&view=rev
Log:
Disable warning flags when running .fail.cpp tests.

Increasingly the .fail.cpp tests are written using -verify, making them
sensitive to the exact diagnostics generated by the compiler. To prevent
additional diagnostics from being generated, and causing the tests to fail,
this patch removes the warning flags when compiling those tests.



Modified:
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=276208&r1=276207&r2=276208&view=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Wed Jul 20 18:37:28 2016
@@ -13,11 +13,17 @@ import libcxx.util
 
 
 class CXXCompiler(object):
+CM_Default = 0
+CM_PreProcess = 1
+CM_Compile = 2
+CM_Link = 3
+
 def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
  use_ccache=False):
 self.path = path
 self.flags = list(flags or [])
 self.compile_flags = list(compile_flags or [])
+self.warning_flags = []
 self.link_flags = list(link_flags or [])
 self.use_ccache = use_ccache
 self.type = None
@@ -47,10 +53,13 @@ class CXXCompiler(object):
 self.type = compiler_type
 self.version = (major_ver, minor_ver, patchlevel)
 
-def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False,
-  disable_ccache=False):
+def _basicCmd(self, source_files, out, mode=CM_Default, flags=[],
+  input_is_cxx=False,
+  enable_warnings=True, disable_ccache=False):
 cmd = []
-if self.use_ccache and not disable_ccache and not is_link:
+if self.use_ccache and not disable_ccache \
+and not mode == self.CM_Link \
+and not mode == self.CM_PreProcess:
 cmd += ['ccache']
 cmd += [self.path]
 if out is not None:
@@ -63,30 +72,45 @@ class CXXCompiler(object):
 cmd += [source_files]
 else:
 raise TypeError('source_files must be a string or list')
+if mode == self.CM_PreProcess:
+cmd += ['-E']
+elif mode == self.CM_Compile:
+cmd += ['-c']
+cmd += self.flags
+if mode != self.CM_Link:
+cmd += self.compile_flags
+if enable_warnings:
+cmd += self.warning_flags
+if mode != self.CM_PreProcess and mode != self.CM_Compile:
+cmd += self.link_flags
+cmd += flags
 return cmd
 
-def preprocessCmd(self, source_files, out=None, flags=[]):
-cmd = self._basicCmd(source_files, out, input_is_cxx=True,
- disable_ccache=True) + ['-E']
-cmd += self.flags + self.compile_flags + flags
-return cmd
+def _getWarningFlags(self, enable_warnings=True):
+return self.warning_flags if enable_warnings else []
+
+def preprocessCmd(self, source_files, out=None, flags=[],
+  enable_warnings=True):
+return self._basicCmd(source_files, out, flags=flags,
+ mode=self.CM_PreProcess,
+ enable_warnings=enable_warnings,
+ input_is_cxx=True)
 
 def compileCmd(self, source_files, out=None, flags=[],
-   disable_ccache=False):
-cmd = self._basicCmd(source_files, out, input_is_cxx=True,
+   disable_ccache=False, enable_warnings=True):
+return self._basicCmd(source_files, out, flags=flags,
+ mode=self.CM_Compile,
+ input_is_cxx=True,
+ enable_warnings=enable_warnings,
  disable_ccache=disable_ccache) + ['-c']
-cmd += self.flags + self.compile_flags + flags
-return cmd
 
 def linkCmd(self, source_files, out=None, flags=[]):
-cmd = self._basicCmd(source_files, out, is_link=True)
-cmd += self.flags + self.link_flags + flags
-return cmd
+return self._basicCmd(source_files, out, mode=self.CM_Link)
 
-def compileLinkCmd(self, source_files, out=None, flags=[]):
-cmd = self._basicCmd(source_files, out, is_link=True)
-cmd += self.flags + self.compile_flags + self.link_flags + flags
-return cmd
+def compileLinkCmd(self, source_files, out=None, flags=[],
+   enable_warnings=True):
+return self._basicCmd(source_files, out, flags=flags,
+  enable_warnings=enable_warnings)
 
 def preprocess(self,

Re: [PATCH] D22593: [Profile] document %h and %m

2016-07-20 Thread Xinliang David Li via cfe-commits
ok

David

On Wed, Jul 20, 2016 at 4:32 PM, Sean Silva  wrote:

> silvas accepted this revision.
> silvas added a comment.
> This revision is now accepted and ready to land.
>
> LGTM (also, another small suggestion).
>
>
> 
> Comment at: docs/UsersManual.rst:1502
> @@ +1501,3 @@
> +   multiple raw profiles dumped from different processes (running on the
> same or
> +   different hosts) will be automatically merged by the profiler runtime
> during the
> +   dumping. If the program links in multiple instrumented shared
> libraries, each library
> 
> "running on the same or different hosts" should probably just be "that
> share a file system" to clarify that we depend on the filesystem guarantees
> and aren't doing anything else special.
>
>
> https://reviews.llvm.org/D22593
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r276212 - Merging r276003:

2016-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 20 18:53:44 2016
New Revision: 276212

URL: http://llvm.org/viewvc/llvm-project?rev=276212&view=rev
Log:
Merging r276003:

r276003 | ericwf | 2016-07-19 11:56:20 -0600 (Tue, 19 Jul 2016) | 35 lines

Fix undefined behavior in __tree

Summary:
This patch attempts to fix the undefined behavior in __tree by changing the 
node pointer types used throughout. The pointer types are changed for raw 
pointers in the current ABI and for fancy pointers in ABI V2 (since the fancy 
pointer types may not be ABI compatible).

The UB in `__tree` arises because tree downcasts the embedded end node and then 
deferences that pointer. Currently there are 3 node types in __tree.

* `__tree_end_node` which contains the `__left_` pointer. This node is embedded 
within the container.
* `__tree_node_base` which contains `__right_`, `__parent_` and `__is_black`. 
This node is used throughout the tree rebalancing algorithms.
* `__tree_node` which contains `__value_`.

Currently `__tree` stores the start of the tree, `__begin_node_`, as a pointer 
to a `__tree_node`. Additionally the iterators store their position as a 
pointer to a `__tree_node`. In both of these cases the pointee can be the end 
node. This is fixed by changing them to store `__tree_end_node` pointers 
instead.

To make this change I introduced an `__iter_pointer` typedef which is defined 
to be a pointer to either `__tree_end_node` in the new ABI or `__tree_node` in 
the current one.
Both `__tree::__begin_node_` and iterator pointers are now stored as 
`__iter_pointers`.

The other situation where `__tree_end_node` is stored as the wrong type is in 
`__tree_node_base::__parent_`.  Currently `__left_`, `__right_`, and 
`__parent_` are all `__tree_node_base` pointers. Since the end node will only 
be stored in `__parent_` the fix is to change `__parent_` to be a pointer to 
`__tree_end_node`.

To make this change I introduced a `__parent_pointer` typedef which is defined 
to be a pointer to either `__tree_end_node` in the new ABI or 
`__tree_node_base` in the current one.

Note that in the new ABI `__iter_pointer` and `__parent_pointer` are the same 
type (but not in the old one). The confusion between these two types is 
unfortunate but it was the best solution I could come up with that maintains 
the ABI.

The typedef changes force a ton of explicit type casts to correct pointer types 
and to make current code compatible with both the old and new pointer typedefs. 
This is the bulk of the change and it's really messy. Unfortunately I don't 
know how to avoid it.

Please let me know what you think.





Reviewers: howard.hinnant, mclow.lists

Subscribers: howard.hinnant, bbannier, cfe-commits

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


Added:

libcxx/branches/release_39/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp
Modified:
libcxx/branches/release_39/include/__config
libcxx/branches/release_39/include/__tree

libcxx/branches/release_39/test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp

libcxx/branches/release_39/test/libcxx/containers/associative/tree_left_rotate.pass.cpp

libcxx/branches/release_39/test/libcxx/containers/associative/tree_remove.pass.cpp

libcxx/branches/release_39/test/libcxx/containers/associative/tree_right_rotate.pass.cpp
libcxx/branches/release_39/test/ubsan_blacklist.txt

Modified: libcxx/branches/release_39/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_39/include/__config?rev=276212&r1=276211&r2=276212&view=diff
==
--- libcxx/branches/release_39/include/__config (original)
+++ libcxx/branches/release_39/include/__config Wed Jul 20 18:53:44 2016
@@ -41,6 +41,8 @@
 #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
 // Fix undefined behavior in how std::list stores it's linked nodes.
 #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
+// Fix undefined behavior in  how __tree stores its end and parent nodes.
+#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
 #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD

Modified: libcxx/branches/release_39/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_39/include/__tree?rev=276212&r1=276211&r2=276212&view=diff
==
--- libcxx/branches/release_39/include/__tree (original)
+++ libcxx/branches/release_39/include/__tree Wed Jul 20 18:53:44 2016
@@ -165,21 +165,36 @@ __tree_next(_NodePtr __x) _NOEXCEPT
 if (__x->__right_ != nullptr)
 return __tree_min(__x->__right_);
 while (!__tree_is_left_child(__x))
-__x = __x

[libunwind] r276214 - Update .arcconfig

2016-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 20 18:56:17 2016
New Revision: 276214

URL: http://llvm.org/viewvc/llvm-project?rev=276214&view=rev
Log:
Update .arcconfig

Modified:
libunwind/trunk/.arcconfig

Modified: libunwind/trunk/.arcconfig
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/.arcconfig?rev=276214&r1=276213&r2=276214&view=diff
==
--- libunwind/trunk/.arcconfig (original)
+++ libunwind/trunk/.arcconfig Wed Jul 20 18:56:17 2016
@@ -1,4 +1,4 @@
 {
   "project_id" : "libunwind",
-  "conduit_uri" : "http://reviews.llvm.org/";
+  "conduit_uri" : "https://reviews.llvm.org/";
 }


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


[libunwind] r276215 - [libunwind] Properly align _Unwind_Exception.

2016-07-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jul 20 18:56:42 2016
New Revision: 276215

URL: http://llvm.org/viewvc/llvm-project?rev=276215&view=rev
Log:
[libunwind] Properly align _Unwind_Exception.

Summary: _Unwind_Exception is required to be double word aligned. Currently the 
struct is under aligned.

Reviewers: mclow.lists, compnerd, kledzik, emaste

Subscribers: emaste, cfe-commits

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

Added:
libunwind/trunk/test/alignment.pass.cpp
Modified:
libunwind/trunk/include/unwind.h

Modified: libunwind/trunk/include/unwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/unwind.h?rev=276215&r1=276214&r2=276215&view=diff
==
--- libunwind/trunk/include/unwind.h (original)
+++ libunwind/trunk/include/unwind.h Wed Jul 20 18:56:42 2016
@@ -122,13 +122,16 @@ struct _Unwind_Exception {
   uintptr_t private_1; // non-zero means forced unwind
   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
 #ifndef __LP64__
-  // The gcc implementation of _Unwind_Exception used attribute mode on the
-  // above fields which had the side effect of causing this whole struct to
+  // The implementation of _Unwind_Exception uses an attribute mode on the
+  // above fields which has the side effect of causing this whole struct to
   // round up to 32 bytes in size. To be more explicit, we add pad fields
   // added for binary compatibility.
   uint32_t reserved[3];
 #endif
-};
+  // The Itanium ABI requires that _Unwind_Exception objects are "double-word
+  // aligned".  GCC has interpreted this to mean "use the maximum useful
+  // alignment for the target"; so do we.
+} __attribute__((__aligned__));
 
 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
 (int version,

Added: libunwind/trunk/test/alignment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/alignment.pass.cpp?rev=276215&view=auto
==
--- libunwind/trunk/test/alignment.pass.cpp (added)
+++ libunwind/trunk/test/alignment.pass.cpp Wed Jul 20 18:56:42 2016
@@ -0,0 +1,21 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// The Itanium ABI requires that _Unwind_Exception objects are "double-word
+// aligned".
+
+#include 
+
+struct MaxAligned {} __attribute__((aligned));
+static_assert(alignof(_Unwind_Exception) == alignof(MaxAligned), "");
+
+int main()
+{
+}


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


Re: [libunwind] r276215 - [libunwind] Properly align _Unwind_Exception.

2016-07-20 Thread Eric Fiselier via cfe-commits
@Hans This should be merged into 3.9.

Can a code owner give this the thumbs up?

/Eric

On Wed, Jul 20, 2016 at 5:56 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Jul 20 18:56:42 2016
> New Revision: 276215
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276215&view=rev
> Log:
> [libunwind] Properly align _Unwind_Exception.
>
> Summary: _Unwind_Exception is required to be double word aligned.
> Currently the struct is under aligned.
>
> Reviewers: mclow.lists, compnerd, kledzik, emaste
>
> Subscribers: emaste, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D22543
>
> Added:
> libunwind/trunk/test/alignment.pass.cpp
> Modified:
> libunwind/trunk/include/unwind.h
>
> Modified: libunwind/trunk/include/unwind.h
> URL:
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/unwind.h?rev=276215&r1=276214&r2=276215&view=diff
>
> ==
> --- libunwind/trunk/include/unwind.h (original)
> +++ libunwind/trunk/include/unwind.h Wed Jul 20 18:56:42 2016
> @@ -122,13 +122,16 @@ struct _Unwind_Exception {
>uintptr_t private_1; // non-zero means forced unwind
>uintptr_t private_2; // holds sp that phase1 found for phase2 to use
>  #ifndef __LP64__
> -  // The gcc implementation of _Unwind_Exception used attribute mode on
> the
> -  // above fields which had the side effect of causing this whole struct
> to
> +  // The implementation of _Unwind_Exception uses an attribute mode on the
> +  // above fields which has the side effect of causing this whole struct
> to
>// round up to 32 bytes in size. To be more explicit, we add pad fields
>// added for binary compatibility.
>uint32_t reserved[3];
>  #endif
> -};
> +  // The Itanium ABI requires that _Unwind_Exception objects are
> "double-word
> +  // aligned".  GCC has interpreted this to mean "use the maximum useful
> +  // alignment for the target"; so do we.
> +} __attribute__((__aligned__));
>
>  typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
>  (int version,
>
> Added: libunwind/trunk/test/alignment.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/alignment.pass.cpp?rev=276215&view=auto
>
> ==
> --- libunwind/trunk/test/alignment.pass.cpp (added)
> +++ libunwind/trunk/test/alignment.pass.cpp Wed Jul 20 18:56:42 2016
> @@ -0,0 +1,21 @@
> +// -*- C++ -*-
>
> +//===--===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is dual licensed under the MIT and the University of
> Illinois Open
> +// Source Licenses. See LICENSE.TXT for details.
> +//
>
> +//===--===//
> +
> +// The Itanium ABI requires that _Unwind_Exception objects are
> "double-word
> +// aligned".
> +
> +#include 
> +
> +struct MaxAligned {} __attribute__((aligned));
> +static_assert(alignof(_Unwind_Exception) == alignof(MaxAligned), "");
> +
> +int main()
> +{
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21459: Implement http://wg21.link/P0254R1: "Integrating std::string_view and std::string"

2016-07-20 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

FYI this patch adds 6 new symbols to the dylib:

  Symbol added: 
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEmmNS_17basic_string_viewIcS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7replaceEmmNS_17basic_string_viewIcS2_EEmm'}
  
  Symbol added: 
_ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEmmNS_17basic_string_viewIwS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNKSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7compareEmmNS_17basic_string_viewIwS2_EEmm'}
  
  Symbol added: 
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEmNS_17basic_string_viewIcS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEmNS_17basic_string_viewIcS2_EEmm'}
  
  Symbol added: 
_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEmNS_17basic_string_viewIwS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEmNS_17basic_string_viewIwS2_EEmm'}
  
  Symbol added: 
_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEmmNS_17basic_string_viewIwS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE7replaceEmmNS_17basic_string_viewIwS2_EEmm'}
  
  Symbol added: 
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEmmNS_17basic_string_viewIcS2_EEmm
  {'type': 'FUNC', 'name': 
'_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEmmNS_17basic_string_viewIcS2_EEmm'}

More comments to come.



Comment at: include/string:3206
@@ -3658,3 +3205,3 @@
 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): 
received nullptr");
-return _VSTD::__str_find_last_not_of
+return __str_find_last_not_of
 (data(), size(), __s, __pos, __n);

Why is this call no longer qualified? It has UDT's that can force ADL.


Comment at: include/string:3216
@@ -3668,3 +3215,3 @@
 {
-return _VSTD::__str_find_last_not_of
+return __str_find_last_not_of
 (data(), size(), __str.data(), __pos, __str.size());

Why is this call no longer qualified? It has UDT's that can force ADL.


https://reviews.llvm.org/D21459



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


  1   2   >