[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked 2 inline comments as done.
rsmith added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3991-3992
+  if (auto *MD = dyn_cast(D)) {
+// FIXME: There's no reason to do this if the key function is inline.
+// Formally, the ABI requires it, but the difference is not observable.
+if (declaresSameEntity(Context.getCurrentKeyFunction(MD->getParent()), MD))

rjmccall wrote:
> rsmith wrote:
> > rjmccall wrote:
> > > rsmith wrote:
> > > > @rjmccall Is there any reason we (from the CodeGen perspective) should 
> > > > treat an inline key function as emitting the vtable? I can't think of 
> > > > any reason to do so -- it's not in a comdat with the vtable or anything 
> > > > like that, so every translation unit that emits a reference to the 
> > > > vtable should emit its own copy anyway.
> > > The thinking was as follows: translation units that can't see a 
> > > definition of the key function don't know that the definition is actually 
> > > inline, so they'll emit a reference to an external v-table definition, 
> > > which will lead to link failures if the translation units that do contain 
> > > the inline definition don't eagerly emit the v-table.  However, ARM 
> > > pointed out years ago that the ODR requires inline definitions of virtual 
> > > functions to be present in every translation unit which declares the 
> > > virtual function at all, so there's no legal situation where a 
> > > translation unit can't see the definition of an inline key function.  
> > > Furthermore, I believe Clang has never made v-tables undiscardable in 
> > > translation units with inline key function definitions, so there's no 
> > > real guarantee that ODR-violating code will actually link, although you 
> > > can certainly imagine ways in which an ODR-violating program might get by 
> > > without such a guarantee.
> > > 
> > > Personally, I think the strongest argument for "deviating" here is that 
> > > the language standard takes priority over the ABI, which means we're 
> > > allowed to assume the program is overall well-formed, i.e. we're only 
> > > required to interoperate with legal code.  Now, that's a line of 
> > > reasoning which leads us into some grey areas of 
> > > implementation-definedness, but I feel fairly comfortable about deviating 
> > > in this particular instance because I don't know why someone would really 
> > > *want* to take advantage of v-tables being emitted eagerly; in general, 
> > > eager emission of inline code is a bad thing that significantly slows 
> > > down builds.
> > > 
> > > Now, ARM used this property of inline definitions to change the key 
> > > function to the first non-inline function, and unfortunately we can't do 
> > > that on existing targets without breaking interoperation.  (We did do it 
> > > on some newer Darwin targets, though, and we haven't had any problem with 
> > > it.)  But I do think we could use this property of inline definitions to 
> > > just treat the class as no longer having a key function when we see an 
> > > inline definition of it.  That would rid us of this particular scourge of 
> > > eager emission of inline code.
> > My thinking is this: if a vtable has discardable linkage, then it can be 
> > discarded when optimizing if it's not referenced. So there's no point 
> > emitting it unless we also emit a reference to it. So we should only emit 
> > vtables with discardable linkage if they're actually referenced, just like 
> > we do for other symbols with discardable linkage. This is, I think, 
> > stronger than what you're suggesting, because it affects internal-linkage 
> > explicit instantiations too.
> Given only the ABI rule, using discardable linkage is a bug.  If you take the 
> "those translation units containing the definition must emit the v-table so 
> that other translation units can use it" argument seriously, you obviously 
> can't use discardable linkage, because the other translation units can't use 
> it.  That's why I bothered developing the whole argument above about why it's 
> okay to ignore the ABI rule here.
> 
> Your argument about internal-linkage explicit instantiations abstractly makes 
> a lot of sense but also sets off a bunch of klaxons in my mind about ignoring 
> obvious programmer intent.  Still, I think it's reasonable to try it out.
OK, fair enough. I was only starting from the "these vtables have discardable 
linkage" position because that has been the status quo in Clang ~forever 
(godbolt.org only goes back to Clang 3). I'll give it a go and see what shakes 
out.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54986/new/

https://reviews.llvm.org/D54986



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


r347730 - PR39809: (const void*)0 is not a null pointer constant in C.

2018-11-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 27 22:25:06 2018
New Revision: 347730

URL: http://llvm.org/viewvc/llvm-project?rev=347730=rev
Log:
PR39809: (const void*)0 is not a null pointer constant in C.

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/conditional.c

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=347730=347729=347730=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Nov 27 22:25:06 2018
@@ -3441,20 +3441,20 @@ Expr::isNullPointerConstant(ASTContext &
   // Check that it is a cast to void*.
   if (const PointerType *PT = CE->getType()->getAs()) {
 QualType Pointee = PT->getPointeeType();
+Qualifiers Qs = Pointee.getQualifiers();
 // Only (void*)0 or equivalent are treated as nullptr. If pointee type
 // has non-default address space it is not treated as nullptr.
 // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
 // since it cannot be assigned to a pointer to constant address space.
-bool PointeeHasDefaultAS =
-Pointee.getAddressSpace() == LangAS::Default ||
-(Ctx.getLangOpts().OpenCLVersion >= 200 &&
+if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
  Pointee.getAddressSpace() == LangAS::opencl_generic) ||
 (Ctx.getLangOpts().OpenCL &&
  Ctx.getLangOpts().OpenCLVersion < 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_private);
+ Pointee.getAddressSpace() == LangAS::opencl_private))
+  Qs.removeAddressSpace();
 
-if (PointeeHasDefaultAS && Pointee->isVoidType() && // to void*
-CE->getSubExpr()->getType()->isIntegerType())   // from int.
+if (Pointee->isVoidType() && Qs.empty() && // to void*
+CE->getSubExpr()->getType()->isIntegerType()) // from int
   return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
   }
 }

Modified: cfe/trunk/test/Sema/conditional.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conditional.c?rev=347730=347729=347730=diff
==
--- cfe/trunk/test/Sema/conditional.c (original)
+++ cfe/trunk/test/Sema/conditional.c Tue Nov 27 22:25:06 2018
@@ -12,3 +12,10 @@ int _php_stream_free1() {
 int _php_stream_free2() {
   return (1 ? _efree(0) : free(0));  // expected-error {{returning 'void' from 
a function with incompatible result type 'int'}}
 }
+
+void pr39809() {
+  _Generic(0 ? (int const *)0 : (void *)0, int const *: (void)0);
+  _Generic(0 ? (int const *)0 : (void *)1, void const *: (void)0);
+  _Generic(0 ? (int volatile*)0 : (void const*)1, void volatile const*: 
(void)0);
+  _Generic(0 ? (int volatile*)0 : (void const*)0, void volatile const*: 
(void)0);
+}


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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-11-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D50119#1308869 , @rjmccall wrote:

> Hmm.  I don't remember what we do in this case for `trivial_abi` (which does 
> need to address it because it's possible to return types like `DestroyBase`). 
>  It looks like we currently make it non-trivial.  But trivial-ABI needs to 
> consider copy constructors as well as move constructors, which would 
> undermine my case that it should be a subset of trivially-relocatability, at 
> least in the fantasy world where there are correct types which default their 
> move constructors but not their copy constructors or vice-versa.


Submitted for your consideration:

  template
  class HeapResource {
  std::unique_ptr ptr_;
  HeapResource(const HeapResource& rhs) : ptr_(rhs.ptr_->clone()) {}  // 
not defaulted
  HeapResource(HeapResource&&) = default;  // defaulted
  ~HeapResource() = default;
  };

This type is isomorphic to a real-world implementation of `std::function`. When 
you copy a HeapResource, you copy a T (which is observable); when you move a 
HeapResource, you do not touch T at all. Therefore copy-and-destroy is 
observably different from move-and-destroy. But (A) as a library vendor, I 
don't think I would care about clients who pathologically try to observe the 
difference; and (B) I don't think I grasp exactly how `[[trivial_abi]]` would 
care about this case either. (But remember: I still think of `[[trivial_abi]]` 
as completely orthogonal. You cut that debate short. ;) I would see no 
intrinsic difficulty with marking `HeapResource` as `[[trivial_abi]]`, for 
example.)

>> So maybe you need a notion like "a class is BlahBlah if all of its direct 
>> members are BlahBlah, //and// either it is annotated 
>> `[[maybe_trivially_relocatable]]` or else it has no non-defaulted move or 
>> destroy operations." And then "a move-constructible, destructible class is 
>> trivially relocatable if it is BlahBlah, //or// if it is annotated 
>> `[[trivially_relocatable]]`." And then a class like `DestroyBase` can be 
>> "BlahBlah but not move-constructible," and if it's placed inside `MoveBase`, 
>> and `MoveBase` is //both// annotated and move-constructible, then `MoveBase` 
>> becomes trivially relocatable.
> 
> I'm completely comfortable with saying that `MoveBase` just isn't 
> trivially-relocatable under `maybe_trivially_relocatable` attribute, and if 
> you've somehow arranged for it to be, you need to use the stronger attribute.

To clarify: you'd be completely comfortable with the user's //having the 
ability// to "use the stronger attribute"? That is, there seems to be a 
reasonable argument in favor of the existence of the stronger attribute, even 
in the presence of the weaker attribute?

> In practice types like this either won't exist or won't actually satisfy the 
> requirements.

I think we probably agree on the nature of reality here, but I don't understand 
the way you phrased this sentence. I mean, `DestroyBase` and `MoveBase` 
absolutely //do// exist, in libc++'s implementation of `optional`. If you just 
mean that "in practice all such types will be private implementation details, 
and we'll never have to worry about the implications of these types' 
advertising themselves as trivially relocatable because they'll only ever be 
used in highly controlled circumstances where we can trust the programmer not 
to fall into any pits of their own making," then I agree, I think.

>> If I get time today I'll try adding the boolean argument to the attribute, 
>> and do the libc++ patches that way for comparison.
> 
> Okay.  Sorry for the delayed response, I had last week off.

No worries. I didn't have last week off, and I still didn't actually get around 
to adding the boolean argument yet.

Speaking of the boolean argument... The usual usage will be something like 
`[[trivially_relocatable(is_trivially_relocatable_v && 
is_trivially_relocatable_v && 
is_trivially_relocatable_v)]]`, basically listing out the types of 
all the class's non-static data members. This has suddenly suggested to me that 
maybe the compiler could generate this kind of thing automatically... which 
we'd naturally spell `[[trivially_relocatable(auto)]]`! That is, maybe the 
right spelling for `[[maybe_trivially_relocatable]]` is 
`[[trivially_relocatable(auto)]]`!
...Or, on second thought, maybe not. That seems super prone to overuse and thus 
abuse, like, if someone blindly applied it to their codebase's equivalent of 
`std::list`. Yeah, I keep coming back to: the best way to avoid accidental 
knife injuries is to keep the knife sharp.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50119/new/

https://reviews.llvm.org/D50119



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


[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3991-3992
+  if (auto *MD = dyn_cast(D)) {
+// FIXME: There's no reason to do this if the key function is inline.
+// Formally, the ABI requires it, but the difference is not observable.
+if (declaresSameEntity(Context.getCurrentKeyFunction(MD->getParent()), MD))

rsmith wrote:
> rjmccall wrote:
> > rsmith wrote:
> > > @rjmccall Is there any reason we (from the CodeGen perspective) should 
> > > treat an inline key function as emitting the vtable? I can't think of any 
> > > reason to do so -- it's not in a comdat with the vtable or anything like 
> > > that, so every translation unit that emits a reference to the vtable 
> > > should emit its own copy anyway.
> > The thinking was as follows: translation units that can't see a definition 
> > of the key function don't know that the definition is actually inline, so 
> > they'll emit a reference to an external v-table definition, which will lead 
> > to link failures if the translation units that do contain the inline 
> > definition don't eagerly emit the v-table.  However, ARM pointed out years 
> > ago that the ODR requires inline definitions of virtual functions to be 
> > present in every translation unit which declares the virtual function at 
> > all, so there's no legal situation where a translation unit can't see the 
> > definition of an inline key function.  Furthermore, I believe Clang has 
> > never made v-tables undiscardable in translation units with inline key 
> > function definitions, so there's no real guarantee that ODR-violating code 
> > will actually link, although you can certainly imagine ways in which an 
> > ODR-violating program might get by without such a guarantee.
> > 
> > Personally, I think the strongest argument for "deviating" here is that the 
> > language standard takes priority over the ABI, which means we're allowed to 
> > assume the program is overall well-formed, i.e. we're only required to 
> > interoperate with legal code.  Now, that's a line of reasoning which leads 
> > us into some grey areas of implementation-definedness, but I feel fairly 
> > comfortable about deviating in this particular instance because I don't 
> > know why someone would really *want* to take advantage of v-tables being 
> > emitted eagerly; in general, eager emission of inline code is a bad thing 
> > that significantly slows down builds.
> > 
> > Now, ARM used this property of inline definitions to change the key 
> > function to the first non-inline function, and unfortunately we can't do 
> > that on existing targets without breaking interoperation.  (We did do it on 
> > some newer Darwin targets, though, and we haven't had any problem with it.) 
> >  But I do think we could use this property of inline definitions to just 
> > treat the class as no longer having a key function when we see an inline 
> > definition of it.  That would rid us of this particular scourge of eager 
> > emission of inline code.
> My thinking is this: if a vtable has discardable linkage, then it can be 
> discarded when optimizing if it's not referenced. So there's no point 
> emitting it unless we also emit a reference to it. So we should only emit 
> vtables with discardable linkage if they're actually referenced, just like we 
> do for other symbols with discardable linkage. This is, I think, stronger 
> than what you're suggesting, because it affects internal-linkage explicit 
> instantiations too.
Given only the ABI rule, using discardable linkage is a bug.  If you take the 
"those translation units containing the definition must emit the v-table so 
that other translation units can use it" argument seriously, you obviously 
can't use discardable linkage, because the other translation units can't use 
it.  That's why I bothered developing the whole argument above about why it's 
okay to ignore the ABI rule here.

Your argument about internal-linkage explicit instantiations abstractly makes a 
lot of sense but also sets off a bunch of klaxons in my mind about ignoring 
obvious programmer intent.  Still, I think it's reasonable to try it out.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54986/new/

https://reviews.llvm.org/D54986



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


r347729 - PR12884: Add test (bug is already fixed).

2018-11-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 27 21:15:46 2018
New Revision: 347729

URL: http://llvm.org/viewvc/llvm-project?rev=347729=rev
Log:
PR12884: Add test (bug is already fixed).

Modified:
cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp

Modified: cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp?rev=347729=347728=347729=diff
==
--- cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp Tue Nov 27 21:15:46 
2018
@@ -18,3 +18,59 @@ B c() {
 template struct test2 { T b() { return typename T::a; } }; // 
expected-error{{expected '(' for function-style cast or type construction}}
 template struct test3 { T b() { return typename a; } }; // 
expected-error{{expected a qualified name after 'typename'}}
 template struct test4 { T b() { return typename ::a; } }; // 
expected-error{{refers to non-type member}} expected-error{{expected '(' for 
function-style cast or type construction}}
+
+// PR12884
+namespace PR12884_original {
+  template  struct A {
+struct B {
+  template  struct X {};
+  typedef int arg;
+};
+struct C {
+  typedef B::X x; // expected-error {{missing 'typename'}}
+};
+  };
+
+  template <> struct A::B {
+template  struct X {};
+static const int arg = 0;
+  };
+
+  A::C::x a;
+}
+namespace PR12884_half_fixed {
+  template  struct A {
+struct B {
+  template  struct X {};
+  typedef int arg;
+};
+struct C {
+  typedef typename B::X x; // expected-error {{use 
'template'}} expected-error {{refers to non-type}}
+};
+  };
+
+  template <> struct A::B {
+template  struct X {};
+static const int arg = 0; // expected-note {{here}}
+  };
+
+  A::C::x a; // expected-note {{here}}
+}
+namespace PR12884_fixed {
+  template  struct A {
+struct B {
+  template  struct X {};
+  typedef int arg;
+};
+struct C {
+  typedef typename B::template X x;
+};
+  };
+
+  template <> struct A::B {
+template  struct X {};
+static const int arg = 0;
+  };
+
+  A::C::x a; // ok
+}


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


[PATCH] D54592: [CStringChecker] evaluate explicit_bzero

2018-11-27 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54592/new/

https://reviews.llvm.org/D54592



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


[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked an inline comment as done.
rsmith added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3991-3992
+  if (auto *MD = dyn_cast(D)) {
+// FIXME: There's no reason to do this if the key function is inline.
+// Formally, the ABI requires it, but the difference is not observable.
+if (declaresSameEntity(Context.getCurrentKeyFunction(MD->getParent()), MD))

rjmccall wrote:
> rsmith wrote:
> > @rjmccall Is there any reason we (from the CodeGen perspective) should 
> > treat an inline key function as emitting the vtable? I can't think of any 
> > reason to do so -- it's not in a comdat with the vtable or anything like 
> > that, so every translation unit that emits a reference to the vtable should 
> > emit its own copy anyway.
> The thinking was as follows: translation units that can't see a definition of 
> the key function don't know that the definition is actually inline, so 
> they'll emit a reference to an external v-table definition, which will lead 
> to link failures if the translation units that do contain the inline 
> definition don't eagerly emit the v-table.  However, ARM pointed out years 
> ago that the ODR requires inline definitions of virtual functions to be 
> present in every translation unit which declares the virtual function at all, 
> so there's no legal situation where a translation unit can't see the 
> definition of an inline key function.  Furthermore, I believe Clang has never 
> made v-tables undiscardable in translation units with inline key function 
> definitions, so there's no real guarantee that ODR-violating code will 
> actually link, although you can certainly imagine ways in which an 
> ODR-violating program might get by without such a guarantee.
> 
> Personally, I think the strongest argument for "deviating" here is that the 
> language standard takes priority over the ABI, which means we're allowed to 
> assume the program is overall well-formed, i.e. we're only required to 
> interoperate with legal code.  Now, that's a line of reasoning which leads us 
> into some grey areas of implementation-definedness, but I feel fairly 
> comfortable about deviating in this particular instance because I don't know 
> why someone would really *want* to take advantage of v-tables being emitted 
> eagerly; in general, eager emission of inline code is a bad thing that 
> significantly slows down builds.
> 
> Now, ARM used this property of inline definitions to change the key function 
> to the first non-inline function, and unfortunately we can't do that on 
> existing targets without breaking interoperation.  (We did do it on some 
> newer Darwin targets, though, and we haven't had any problem with it.)  But I 
> do think we could use this property of inline definitions to just treat the 
> class as no longer having a key function when we see an inline definition of 
> it.  That would rid us of this particular scourge of eager emission of inline 
> code.
My thinking is this: if a vtable has discardable linkage, then it can be 
discarded when optimizing if it's not referenced. So there's no point emitting 
it unless we also emit a reference to it. So we should only emit vtables with 
discardable linkage if they're actually referenced, just like we do for other 
symbols with discardable linkage. This is, I think, stronger than what you're 
suggesting, because it affects internal-linkage explicit instantiations too.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54986/new/

https://reviews.llvm.org/D54986



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


[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3991-3992
+  if (auto *MD = dyn_cast(D)) {
+// FIXME: There's no reason to do this if the key function is inline.
+// Formally, the ABI requires it, but the difference is not observable.
+if (declaresSameEntity(Context.getCurrentKeyFunction(MD->getParent()), MD))

rsmith wrote:
> @rjmccall Is there any reason we (from the CodeGen perspective) should treat 
> an inline key function as emitting the vtable? I can't think of any reason to 
> do so -- it's not in a comdat with the vtable or anything like that, so every 
> translation unit that emits a reference to the vtable should emit its own 
> copy anyway.
The thinking was as follows: translation units that can't see a definition of 
the key function don't know that the definition is actually inline, so they'll 
emit a reference to an external v-table definition, which will lead to link 
failures if the translation units that do contain the inline definition don't 
eagerly emit the v-table.  However, ARM pointed out years ago that the ODR 
requires inline definitions of virtual functions to be present in every 
translation unit which declares the virtual function at all, so there's no 
legal situation where a translation unit can't see the definition of an inline 
key function.  Furthermore, I believe Clang has never made v-tables 
undiscardable in translation units with inline key function definitions, so 
there's no real guarantee that ODR-violating code will actually link, although 
you can certainly imagine ways in which an ODR-violating program might get by 
without such a guarantee.

Personally, I think the strongest argument for "deviating" here is that the 
language standard takes priority over the ABI, which means we're allowed to 
assume the program is overall well-formed, i.e. we're only required to 
interoperate with legal code.  Now, that's a line of reasoning which leads us 
into some grey areas of implementation-definedness, but I feel fairly 
comfortable about deviating in this particular instance because I don't know 
why someone would really *want* to take advantage of v-tables being emitted 
eagerly; in general, eager emission of inline code is a bad thing that 
significantly slows down builds.

Now, ARM used this property of inline definitions to change the key function to 
the first non-inline function, and unfortunately we can't do that on existing 
targets without breaking interoperation.  (We did do it on some newer Darwin 
targets, though, and we haven't had any problem with it.)  But I do think we 
could use this property of inline definitions to just treat the class as no 
longer having a key function when we see an inline definition of it.  That 
would rid us of this particular scourge of eager emission of inline code.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54986/new/

https://reviews.llvm.org/D54986



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


r347728 - Move LoopHint.h from Sema to Parse

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 20:36:31 2018
New Revision: 347728

URL: http://llvm.org/viewvc/llvm-project?rev=347728=rev
Log:
Move LoopHint.h from Sema to Parse

struct LoopHint was only used within Parse and not in any of the Sema or
Codegen files.  In the non-Parse files where it was included, it either wasn't
used or LoopHintAttr was used, so its inclusion did nothing.

Added:
cfe/trunk/include/clang/Parse/LoopHint.h
  - copied, changed from r347727, cfe/trunk/include/clang/Sema/LoopHint.h
Removed:
cfe/trunk/include/clang/Sema/LoopHint.h
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaStmtAttr.cpp

Copied: cfe/trunk/include/clang/Parse/LoopHint.h (from r347727, 
cfe/trunk/include/clang/Sema/LoopHint.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/LoopHint.h?p2=cfe/trunk/include/clang/Parse/LoopHint.h=cfe/trunk/include/clang/Sema/LoopHint.h=347727=347728=347728=diff
==
--- cfe/trunk/include/clang/Sema/LoopHint.h (original)
+++ cfe/trunk/include/clang/Parse/LoopHint.h Tue Nov 27 20:36:31 2018
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_SEMA_LOOPHINT_H
-#define LLVM_CLANG_SEMA_LOOPHINT_H
+#ifndef LLVM_CLANG_PARSE_LOOPHINT_H
+#define LLVM_CLANG_PARSE_LOOPHINT_H
 
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -42,4 +42,4 @@ struct LoopHint {
 
 } // end namespace clang
 
-#endif // LLVM_CLANG_SEMA_LOOPHINT_H
+#endif // LLVM_CLANG_PARSE_LOOPHINT_H

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=347728=347727=347728=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Nov 27 20:36:31 2018
@@ -22,7 +22,6 @@
 #include "clang/Lex/CodeCompletionHandler.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
-#include "clang/Sema/LoopHint.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
@@ -38,6 +37,7 @@ namespace clang {
   class CorrectionCandidateCallback;
   class DeclGroupRef;
   class DiagnosticBuilder;
+  struct LoopHint;
   class Parser;
   class ParsingDeclRAIIObject;
   class ParsingDeclSpec;

Removed: cfe/trunk/include/clang/Sema/LoopHint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/LoopHint.h?rev=347727=auto
==
--- cfe/trunk/include/clang/Sema/LoopHint.h (original)
+++ cfe/trunk/include/clang/Sema/LoopHint.h (removed)
@@ -1,45 +0,0 @@
-//===--- LoopHint.h - Types for LoopHint *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_SEMA_LOOPHINT_H
-#define LLVM_CLANG_SEMA_LOOPHINT_H
-
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Sema/Ownership.h"
-#include "clang/Sema/ParsedAttr.h"
-
-namespace clang {
-
-/// Loop optimization hint for loop and unroll pragmas.
-struct LoopHint {
-  // Source range of the directive.
-  SourceRange Range;
-  // Identifier corresponding to the name of the pragma.  "loop" for
-  // "#pragma clang loop" directives and "unroll" for "#pragma unroll"
-  // hints.
-  IdentifierLoc *PragmaNameLoc;
-  // Name of the loop hint.  Examples: "unroll", "vectorize".  In the
-  // "#pragma unroll" and "#pragma nounroll" cases, this is identical to
-  // PragmaNameLoc.
-  IdentifierLoc *OptionLoc;
-  // Identifier for the hint state argument.  If null, then the state is
-  // default value such as for "#pragma unroll".
-  IdentifierLoc *StateLoc;
-  // Expression for the hint argument if it exists, null otherwise.
-  Expr *ValueExpr;
-
-  LoopHint()
-  : PragmaNameLoc(nullptr), OptionLoc(nullptr), StateLoc(nullptr),
-ValueExpr(nullptr) {}
-};
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_LOOPHINT_H

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=347728=347727=347728=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Tue Nov 27 20:36:31 2018
@@ -10,7 +10,6 @@
 #include "CGLoopInfo.h"
 #include "clang/AST/ASTContext.h"
 #include 

r347727 - [CodeGen] Fix included headers.

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 20:14:29 2018
New Revision: 347727

URL: http://llvm.org/viewvc/llvm-project?rev=347727=rev
Log:
[CodeGen] Fix included headers.

Remove the included Parse header because CodeGen should not depend on Parse.
Instead, include the Lex headers that it needs instead.

Modified:
cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=347727=347726=347727=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Tue Nov 27 20:14:29 2018
@@ -14,7 +14,8 @@
 #include "MacroPPCallbacks.h"
 #include "CGDebugInfo.h"
 #include "clang/CodeGen/ModuleBuilder.h"
-#include "clang/Parse/Parser.h"
+#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/Preprocessor.h"
 
 using namespace clang;
 


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


r347726 - [diagtool] Remove unneeded header includes.

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 19:59:35 2018
New Revision: 347726

URL: http://llvm.org/viewvc/llvm-project?rev=347726=rev
Log:
[diagtool] Remove unneeded header includes.

Modified:
cfe/trunk/tools/diagtool/ListWarnings.cpp
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/tools/diagtool/ListWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/ListWarnings.cpp?rev=347726=347725=347726=diff
==
--- cfe/trunk/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/trunk/tools/diagtool/ListWarnings.cpp Tue Nov 27 19:59:35 2018
@@ -14,7 +14,6 @@
 
 #include "DiagTool.h"
 #include "DiagnosticNames.h"
-#include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/AllDiagnostics.h"
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/ADT/StringMap.h"

Modified: cfe/trunk/tools/diagtool/TreeView.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/TreeView.cpp?rev=347726=347725=347726=diff
==
--- cfe/trunk/tools/diagtool/TreeView.cpp (original)
+++ cfe/trunk/tools/diagtool/TreeView.cpp Tue Nov 27 19:59:35 2018
@@ -9,7 +9,6 @@
 
 #include "DiagTool.h"
 #include "DiagnosticNames.h"
-#include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/AllDiagnostics.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"


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


[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked an inline comment as done.
rsmith added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3991-3992
+  if (auto *MD = dyn_cast(D)) {
+// FIXME: There's no reason to do this if the key function is inline.
+// Formally, the ABI requires it, but the difference is not observable.
+if (declaresSameEntity(Context.getCurrentKeyFunction(MD->getParent()), MD))

@rjmccall Is there any reason we (from the CodeGen perspective) should treat an 
inline key function as emitting the vtable? I can't think of any reason to do 
so -- it's not in a comdat with the vtable or anything like that, so every 
translation unit that emits a reference to the vtable should emit its own copy 
anyway.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54986/new/

https://reviews.llvm.org/D54986



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


[PATCH] D53925: [modules] Defer emission of inline key functions.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

If CodeGen is able to emit inline key functions when the vtable is needed 
anyway, can we instead change `DeclMustBeEmitted` to not treat inline key 
functions specially? There is no reason we need to emit any symbols for:

  struct A { virtual void f(); };
  inline void A::f() {}

... and if suppressing `DeclMustBeEmitted` works in the modules case, it really 
should work in the general case.

Indeed, deleting the relevant code from `DeclMustBeEmitted` appears to work 
fine. It's not actually enough to prevent us from spuriously emitting the 
vtable and inline function definition in the above case, though: `Sema` marks 
the vtable as "used" because the key function was defined (it doesn't know 
whether CodeGen might decide to emit it and prepares for the worst, but that 
then marks the vtable as "used", which *forces* it to be emitted). Fixing that 
requires some more invasive changes.

See https://reviews.llvm.org/D54986 for my proposed alternative to this. The 
idea is to allow CodeGen to decide when to emit a vtable, and to do so only 
when we actually emit a use of the vtable / key function / explicit 
instantiation definition of the class. This doesn't require any 
eagerly-deserialized declaration tracking except for explicit instantiation 
definitions.




Comment at: lib/Serialization/ASTWriterDecl.cpp:2267-2278
+  // If the ABI supports inline key functions we must emit them eagerly. The
+  // generic reason is that CodeGen might assume they are emitted and generate 
a
+  // reference to the vtable. In deserialization this rule becomes a little 
less
+  // clear because if a reference is generated, CodeGen will make a request and
+  // we will emit the vtable on demand.
+  //
+  // This change in behavior is driven mostly by performance considerations and

If the function must be emitted for some reason other than being a key function 
(for instance, due to `__attribute__((used))` or simply not being declared 
inline), this may result in it not getting emitted; that doesn't seem correct. 
(For a module it might typically work because most such cases would be 
redefinition errors, but it's wrong for cases like a precompiled preamble or 
PCH, which can be intended to be used only once and thus can contain strong 
external symbol definitions.)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53925/new/

https://reviews.llvm.org/D53925



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


[PATCH] D54986: Make CodeGen choose when to emit vtables.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added reviewers: rjmccall, v.g.vassilev, bruno.
Herald added subscribers: cfe-commits, javed.absar.

Previously, we expected Sema to make this ABI decision for us, resulting
in our emitting vtables in some cases where we didn't need them. With
this change, we emit vtables in precisely three cases:

1. When we emit a reference to the vtable and it has suitable linkage.
2. When we emit a key function definition.
3. When we emit an explicit instantiation of a class.

This also removes the need to mark key functions as "must be emitted",
which means that an inline key function is no longer added to the list
of eagerly deserialized declarations in an AST file.

In exchange, we do now list explicit instantiation definitions of
dynamic classes as eagerly deserialized declarations. But they should
be much rarer in header files!


Repository:
  rC Clang

https://reviews.llvm.org/D54986

Files:
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/CodeGen/ModuleBuilder.cpp
  lib/Serialization/ASTReaderDecl.cpp
  test/CodeGenCXX/aarch64-cxxabi.cpp
  test/CodeGenCXX/key-function-vtable.cpp
  test/CodeGenCXX/rtti-linkage.cpp
  test/CodeGenCXX/type_visibility.cpp
  test/CodeGenCXX/visibility.cpp
  test/CodeGenCXX/vtt-layout.cpp

Index: test/CodeGenCXX/vtt-layout.cpp
===
--- test/CodeGenCXX/vtt-layout.cpp
+++ test/CodeGenCXX/vtt-layout.cpp
@@ -78,12 +78,12 @@
   }
 }
 
-// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTVN5Test11BE, i32 0, inrange i32 0, i32 3) to i8*)]
-// CHECK: @_ZTVN5Test51AE = unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test51AE to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%"struct.Test5::A"*)* @_ZN5Test51A6anchorEv to i8*)] }
-// CHECK: @_ZTVN5Test61AE = unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test61AE to i8*), i8* bitcast (void ()* @__cxa_deleted_virtual to i8*), i8* bitcast (void (%"struct.Test6::A"*)* @_ZN5Test61A6anchorEv to i8*)] }
-// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, inrange i32 0, i32 4) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5Test21CE, i32 0, inrange i32 0, i32 4) to i8*)]
-// CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, inrange i32 0, i32 5) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE0_NS_2C1E, i32 0, inrange i32 0, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE0_NS_2C1E, i32 0, inrange i32 1, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, inrange i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, inrange i32 0, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, inrange i32 1, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [7 x i8*], [3 x i8*], [4 x i8*] }, { [7 x i8*], [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE16_NS_2C2E, i32 0, inrange i32 2, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, inrange i32 2, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, inrange i32 1, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, inrange i32 1, i32 6) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }, { [5 x i8*], [7 x i8*], [4 x i8*], [3 x i8*] }* @_ZTVN5Test31DE, i32 0, inrange i32 3, i32 3) to i8*), i8* bitcast (i8** getelementptr inbounds ({ [3 x i8*], [4 x i8*] }, { [3 x i8*], [4 x i8*] }* @_ZTCN5Test31DE64_NS_2V2E, i32 0, inrange i32 

[PATCH] D54958: [OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp - (NFC)

2018-11-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347723: [OPENMP] remove redundant ColonExpected flag in 
ParseOpenMP.cpp (NFC) (authored by kli, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54958?vs=175531=175605#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54958/new/

https://reviews.llvm.org/D54958

Files:
  cfe/trunk/lib/Parse/ParseOpenMP.cpp


Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -1867,7 +1867,6 @@
   getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok)))
 : OMPC_MAP_unknown;
 Data.DepLinMapLoc = Tok.getLocation();
-bool ColonExpected = false;
 
 if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
@@ -1935,8 +1934,6 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();
-else if (ColonExpected)
-  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";
   }
 
   bool IsComma =


Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -1867,7 +1867,6 @@
   getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok)))
 : OMPC_MAP_unknown;
 Data.DepLinMapLoc = Tok.getLocation();
-bool ColonExpected = false;
 
 if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
@@ -1935,8 +1934,6 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();
-else if (ColonExpected)
-  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";
   }
 
   bool IsComma =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347723 - [OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp (NFC)

2018-11-27 Thread Kelvin Li via cfe-commits
Author: kli
Date: Tue Nov 27 16:51:08 2018
New Revision: 347723

URL: http://llvm.org/viewvc/llvm-project?rev=347723=rev
Log:
[OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp (NFC)

The flag ColonExpected is not changed after being initialized to 
false at declaration.

Patch by Ahsan Saghir

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

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=347723=347722=347723=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Nov 27 16:51:08 2018
@@ -1867,7 +1867,6 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
   getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok)))
 : OMPC_MAP_unknown;
 Data.DepLinMapLoc = Tok.getLocation();
-bool ColonExpected = false;
 
 if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
@@ -1935,8 +1934,6 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();
-else if (ColonExpected)
-  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";
   }
 
   bool IsComma =


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


[PATCH] D54436: [analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

2018-11-27 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Ping^2


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54436/new/

https://reviews.llvm.org/D54436



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


[PATCH] D54903: [Sema] Improve static_assert diagnostics.

2018-11-27 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: test/SemaCXX/static-assert.cpp:111
+static_assert(std::is_same::value, 
"message"); // expected-error{{static_assert failed due to requirement 
'std::is_same::value' "message"}}
+static_assert(std::is_const::value, "message");   
  // expected-error{{static_assert failed due to requirement 
'std::is_const::value' "message"}}

I would like to see some more realistic test cases. I suggest this test case 
for example:
```
struct BI_tag {};
struct RAI_tag : BI_tag {};
struct MyIterator {
using tag = BI_tag;
};
struct MyContainer {
using iterator = MyIterator;
};
template
void foo() {
static_assert(std::is_base_of_v);
}
```
This is an example where as a programmer I would not want to see //only// 
`failed due to requirement std::is_base_of_v` — that doesn't 
help me solve the issue. OTOH, since every diagnostic includes a cursor to the 
exact text of the `static_assert` already, I think it's fair to say that the 
current diagnostic message is redundant, and therefore it's okay to replace it 
(as you propose to do) with something that is not redundant.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54903/new/

https://reviews.llvm.org/D54903



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


Re: r347035 - [clang] - Simplify tools::SplitDebugName.

2018-11-27 Thread David Blaikie via cfe-commits
Just copying some of the information given through Phab (
https://reviews.llvm.org/rL347035 ) - this patch was reverted in r347676.
Would be great to get that fixed/recommitted!

On Fri, Nov 16, 2018 at 12:01 AM George Rimar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: grimar
> Date: Thu Nov 15 23:59:24 2018
> New Revision: 347035
>
> URL: http://llvm.org/viewvc/llvm-project?rev=347035=rev
> Log:
> [clang] - Simplify tools::SplitDebugName.
>
> This should be NFC change.
>
> SplitDebugName recently started to accept the `Output` that
> can be used to simplify the logic a bit, also it
> seems that code in SplitDebugName that uses
> OPT_fdebug_compilation_dir is simply dead.
>
> Differential revision: https://reviews.llvm.org/D54576
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
> cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
> cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=347035=347034=347035=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Nov 15 23:59:24 2018
> @@ -3936,7 +3936,7 @@ void Clang::ConstructJob(Compilation ,
>const char *SplitDWARFOut;
>if (SplitDWARF) {
>  CmdArgs.push_back("-split-dwarf-file");
> -SplitDWARFOut = SplitDebugName(Args, Input, Output);
> +SplitDWARFOut = SplitDebugName(Args, Output);
>  CmdArgs.push_back(SplitDWARFOut);
>}
>
> @@ -5902,7 +5902,7 @@ void ClangAs::ConstructJob(Compilation &
>if ((getDebugFissionKind(D, Args, A) == DwarfFissionKind::Split) &&
>(T.isOSLinux() || T.isOSFuchsia())) {
>  CmdArgs.push_back("-split-dwarf-file");
> -CmdArgs.push_back(SplitDebugName(Args, Input, Output));
> +CmdArgs.push_back(SplitDebugName(Args, Output));
>}
>
>assert(Input.isFilename() && "Invalid input.");
>
> Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347035=347034=347035=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Nov 15 23:59:24 2018
> @@ -808,26 +808,15 @@ bool tools::areOptimizationsEnabled(cons
>return false;
>  }
>
> -const char *tools::SplitDebugName(const ArgList , const InputInfo
> ,
> +const char *tools::SplitDebugName(const ArgList ,
>const InputInfo ) {
>if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
>  if (StringRef(A->getValue()) == "single")
>return Args.MakeArgString(Output.getFilename());
>
> -  Arg *FinalOutput = Args.getLastArg(options::OPT_o);
> -  if (FinalOutput && Args.hasArg(options::OPT_c)) {
> -SmallString<128> T(FinalOutput->getValue());
> -llvm::sys::path::replace_extension(T, "dwo");
> -return Args.MakeArgString(T);
> -  } else {
> -// Use the compilation dir.
> -SmallString<128> T(
> -Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
> -SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
> -llvm::sys::path::replace_extension(F, "dwo");
> -T += F;
> -return Args.MakeArgString(F);
> -  }
> +  SmallString<128> T(Output.getFilename());
> +  llvm::sys::path::replace_extension(T, "dwo");
> +  return Args.MakeArgString(T);
>  }
>
>  void tools::SplitDebugInfo(const ToolChain , Compilation , const
> Tool ,
>
> Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=347035=347034=347035=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Thu Nov 15 23:59:24 2018
> @@ -63,7 +63,7 @@ void AddHIPLinkerScript(const ToolChain
>  const Tool );
>
>  const char *SplitDebugName(const llvm::opt::ArgList ,
> -   const InputInfo , const InputInfo
> );
> +   const InputInfo );
>
>  void SplitDebugInfo(const ToolChain , Compilation , const Tool ,
>  const JobAction , const llvm::opt::ArgList ,
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=347035=347034=347035=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Nov 15 23:59:24 

[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

2018-11-27 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Ping^2


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54401/new/

https://reviews.llvm.org/D54401



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


r347720 - [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-27 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Nov 27 14:53:57 2018
New Revision: 347720

URL: http://llvm.org/viewvc/llvm-project?rev=347720=rev
Log:
[RISCV] Mark unit tests as "requires: riscv-registered-target"

Some of these tests break if the RISCV backend has not been built.

Reland D54816.

Modified:
cfe/trunk/test/Driver/riscv-abi.c
cfe/trunk/test/Driver/riscv-arch.c
cfe/trunk/test/Driver/riscv-features.c
cfe/trunk/test/Driver/riscv-gnutools.c
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c

Modified: cfe/trunk/test/Driver/riscv-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-abi.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv-abi.c (original)
+++ cfe/trunk/test/Driver/riscv-abi.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \

Modified: cfe/trunk/test/Driver/riscv-arch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-arch.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv-arch.c (original)
+++ cfe/trunk/test/Driver/riscv-arch.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \

Modified: cfe/trunk/test/Driver/riscv-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-features.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv-features.c (original)
+++ cfe/trunk/test/Driver/riscv-features.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 

Modified: cfe/trunk/test/Driver/riscv-gnutools.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-gnutools.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv-gnutools.c (original)
+++ cfe/trunk/test/Driver/riscv-gnutools.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // Check gnutools are invoked with propagated values for -mabi and -march.
 
 // RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s

Modified: cfe/trunk/test/Driver/riscv64-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv64-toolchain.c?rev=347720=347719=347720=diff
==
--- cfe/trunk/test/Driver/riscv64-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv64-toolchain.c Tue Nov 27 14:53:57 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck 
-check-prefix=CC1 %s


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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-11-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik requested changes to this revision.
shafik added a comment.
This revision now requires changes to proceed.

The rest of the changes look good.




Comment at: lib/AST/ExternalASTMerger.cpp:147
   ToTag->setHasExternalLexicalStorage();
-  ToTag->setMustBuildLookupTable();
+  ToTag->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToTag));

This change looks unrelated to the refactoring of `GetAlreadyImportedOrNull()` 
so should probably be in another PR



Comment at: lib/AST/ExternalASTMerger.cpp:154
   ToContainer->setHasExternalLexicalStorage();
-  ToContainer->setMustBuildLookupTable();
+  ToContainer->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToContainer));

martong wrote:
> a_sidorin wrote:
> > Do we have to do the same for NamespaceDecls?
> Yes, I think so.
> The primary context of a `NamespaceDecl` can be other than itself:
> ```
> DeclContext *DeclContext::getPrimaryContext() {
>   switch (DeclKind) {
>   case Decl::TranslationUnit:
>   case Decl::ExternCContext:
>   case Decl::LinkageSpec:
>   case Decl::Export:
>   case Decl::Block:
>   case Decl::Captured:
>   case Decl::OMPDeclareReduction:
> // There is only one DeclContext for these entities.
> return this;
> 
>   case Decl::Namespace:
> // The original namespace is our primary context.
> return static_cast(this)->getOriginalNamespace();
> ```
> Consequently, we should call `setMustBuildLookupTable` only on a 
> `NamespaceDecl` if we know for sure that is a primary context.
This change looks unrelated to the refactoring of `GetAlreadyImportedOrNull()` 
so should probably be in another PR


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53755/new/

https://reviews.llvm.org/D53755



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


r347718 - Fix typo in "[clang][ARC] Fix test for commit r347699"

2018-11-27 Thread Tatyana Krasnukha via cfe-commits
Author: tkrasnukha
Date: Tue Nov 27 14:22:33 2018
New Revision: 347718

URL: http://llvm.org/viewvc/llvm-project?rev=347718=rev
Log:
Fix typo in "[clang][ARC] Fix test for commit r347699"

Modified:
cfe/trunk/test/CodeGen/arc/arguments.c

Modified: cfe/trunk/test/CodeGen/arc/arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arc/arguments.c?rev=347718=347717=347718=diff
==
--- cfe/trunk/test/CodeGen/arc/arguments.c (original)
+++ cfe/trunk/test/CodeGen/arc/arguments.c Tue Nov 27 14:22:33 2018
@@ -132,4 +132,4 @@ s16 st4(int x, s8 a, s16 b, s16 c) { ret
 
 // 1 sret + 2*(i32 coerce) + 4*(i32 coerce) + 4*(i32 coerce)
 s16 st5(s8 a, s16 b, s16 c) { return b; }
-// CHECK: define void @st5(%struct.s16* noalias sret %agg.result, i32 inreg 
%a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg %b.coerce1, 
i32 inreg %b.coerce2, i32 inreg %b.coerce3, i32 %c.coerce0, { i32, i32, i32, 
i32 } %c.coerce)
+// CHECK: define void @st5(%struct.s16* noalias sret %agg.result, i32 inreg 
%a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg %b.coerce1, 
i32 inreg %b.coerce2, i32 inreg %b.coerce3, { i32, i32, i32, i32 } %c.coerce)


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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2018-11-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/utils/LexerUtils.h:43
+  if (Start.isInvalid() || Start.isMacroID())
+return SourceLocation();
   while (true) {

{} could returned instead.



Comment at: docs/ReleaseNotes.rst:180
   removal of the ``const`` keyword.
+>>> master
 

Merge artifact.



Comment at: docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst:6
+
+This check implements detection of local variables which could be declared as
+``const``, but are not. Declaring variables as ``const`` is required by many

Will be good idea to synchronize first statement with Release Notes.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54943/new/

https://reviews.llvm.org/D54943



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


[PATCH] D53655: [ASTImporter] Fix redecl chain of classes and class templates

2018-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

This seems mostly reasonable to me, but @rsmith is more well-versed in this 
area and may have further comments. You should give him a few days to chime in 
before committing.




Comment at: include/clang/AST/DeclContextInternals.h:125-129
+  bool containsInVector(const NamedDecl *D) {
+assert(getAsVector() && "Must have a vector at this point");
+DeclsTy  = *getAsVector();
+return is_contained(Vec, D);
+  }

Given that this is only called in one place and is effectively a one-liner, I'd 
get rid of this function entirely and replace the call below.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1169
+///   matches 'a'.
+extern const internal::VariadicDynCastAllOfMatcher
+indirectFieldDecl;

martong wrote:
> aaron.ballman wrote:
> > Be sure to update Registry.cpp and regenerate the AST matcher documentation 
> > by running clang\docs\tools\dump_ast_matchers.py.
> > 
> > This change feels orthogonal to the rest of the patch; perhaps it should be 
> > split out into its own patch?
> > This change feels orthogonal to the rest of the patch; perhaps it should be 
> > split out into its own patch?
> 
> I agree this part could go into a separate patch, but the first use of this 
> new ASTMatcher is in the new unittests of this patch, so I think it fits 
> better to add them here.
Okay, that's fair enough.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53655/new/

https://reviews.llvm.org/D53655



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-27 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Alright, will patch it into my fork in a bit and try it out, if everything 
looks good, I'll land the stack. (Again huge sorry about this taking some time, 
have lots on my hands at the moment)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54379/new/

https://reviews.llvm.org/D54379



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


[PATCH] D54903: [Sema] Improve static_assert diagnostics.

2018-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaTemplate.cpp:3070
+// and returns true.
+static bool prettyPrintTypeTrait(const NestedNameSpecifier *const NNS,
+ llvm::raw_string_ostream ,

No need for the pointer itself to be `const` qualified -- drop the top-level 
`const` qualifier (here and elsewhere).



Comment at: lib/Sema/SemaTemplate.cpp:3073-3085
+  // We are looking for a type.
+  if (NNS == nullptr || NNS->getKind() != NestedNameSpecifier::TypeSpec)
+return false;
+  // In namespace "::std".
+  const NestedNameSpecifier *const Parent = NNS->getPrefix();
+  if (Parent == nullptr ||
+  Parent->getKind() != NestedNameSpecifier::Namespace ||

I would drop all of this logic and replace it (see below).



Comment at: lib/Sema/SemaTemplate.cpp:3096
+  OS << "std::" << Record->getName() << "<";
+  auto Args = TmplDecl->getTemplateArgs().asArray();
+  Args.front().print(PrintPolicy, OS);

Please don't use `auto` here.



Comment at: lib/Sema/SemaTemplate.cpp:3115
+// This might be `std::some_type_trait::value`.
+if (Var && Var->isStaticDataMember() && Var->getName() == "value" &&
+prettyPrintTypeTrait(DR->getQualifier(), OS, PrintPolicy)) {

You can also check `Var->isInStdNamespace()` here to simplify the logic above.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54903/new/

https://reviews.llvm.org/D54903



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


[PATCH] D54970: [OpenMP] Add a new version of the SPMD deinit kernel function

2018-11-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 175573.
gtbercea added a comment.

  Add constant values to function calls.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54970/new/

https://reviews.llvm.org/D54970

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_target_parallel_codegen.cpp
  test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -757,7 +757,7 @@
   //
   // CHECK: [[EXIT]]
   // call void @__kmpc_restore_team_static_memory(i16 1)
-  // CHECK: call void @__kmpc_spmd_kernel_deinit(
+  // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
 
   // CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable{{.+}}, i16* dereferenceable{{.+}})
   //
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -79,7 +79,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -93,7 +93,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
@@ -107,7 +107,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
@@ -123,7 +123,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
@@ -32,7 +32,7 @@
 
 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* @
 
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 
 // CHECK: define internal void [[PARALLEL]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} [[ARGC:%.+]], i32* dereferenceable{{.*}})
 // CHECK-NOT: call i8* @__kmpc_data_sharing_push_stack(
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -84,7 +84,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -98,7 +98,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
@@ -112,7 +112,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void 

r347715 - [OPENMP][NVPTX]Basic support for reductions across the teams.

2018-11-27 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Nov 27 13:24:54 2018
New Revision: 347715

URL: http://llvm.org/viewvc/llvm-project?rev=347715=rev
Log:
[OPENMP][NVPTX]Basic support for reductions across the teams.

Added basic codegen support for the reductions across the teams.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=347715=347714=347715=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Nov 27 13:24:54 2018
@@ -290,6 +290,16 @@ protected:
   /// default location.
   virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
 
+  /// Get the LLVM type for the critical name.
+  llvm::ArrayType *getKmpCriticalNameTy() const {return KmpCriticalNameTy;}
+
+  /// Returns corresponding lock object for the specified critical region
+  /// name. If the lock object does not exist it is created, otherwise the
+  /// reference to the existing copy is returned.
+  /// \param CriticalName Name of the critical region.
+  ///
+  llvm::Value *getCriticalRegionLock(StringRef CriticalName);
+
 private:
   /// Default const ident_t object used for initialization of all other
   /// ident_t objects.
@@ -707,13 +717,6 @@ private:
 llvm::Value *Ctor, llvm::Value *CopyCtor,
 llvm::Value *Dtor, SourceLocation Loc);
 
-  /// Returns corresponding lock object for the specified critical region
-  /// name. If the lock object does not exist it is created, otherwise the
-  /// reference to the existing copy is returned.
-  /// \param CriticalName Name of the critical region.
-  ///
-  llvm::Value *getCriticalRegionLock(StringRef CriticalName);
-
   struct TaskResultTy {
 llvm::Value *NewTask = nullptr;
 llvm::Value *TaskEntry = nullptr;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=347715=347714=347715=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Nov 27 13:24:54 2018
@@ -62,22 +62,12 @@ enum OpenMPRTLFunctionNVPTX {
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
   OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
-  /// Call to __kmpc_nvptx_simd_reduce_nowait(kmp_int32
-  /// global_tid, kmp_int32 num_vars, size_t reduce_size, void* reduce_data,
-  /// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
-  /// lane_offset, int16_t shortCircuit),
-  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
-  OMPRTL_NVPTX__kmpc_simd_reduce_nowait,
-  /// Call to __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
-  /// int32_t num_vars, size_t reduce_size, void *reduce_data,
-  /// void (*kmp_ShuffleReductFctPtr)(void *rhs, int16_t lane_id, int16_t
-  /// lane_offset, int16_t shortCircuit),
-  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
-  /// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
-  /// int32_t index, int32_t width),
-  /// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad, 
int32_t
-  /// index, int32_t width, int32_t reduce))
-  OMPRTL_NVPTX__kmpc_teams_reduce_nowait,
+  /// Call to __kmpc_nvptx_teams_reduce_nowait_simple(ident_t *loc, kmp_int32
+  /// global_tid, kmp_critical_name *lck)
+  OMPRTL_NVPTX__kmpc_nvptx_teams_reduce_nowait_simple,
+  /// Call to __kmpc_nvptx_teams_end_reduce_nowait_simple(ident_t *loc,
+  /// kmp_int32 global_tid, kmp_critical_name *lck)
+  OMPRTL_NVPTX__kmpc_nvptx_teams_end_reduce_nowait_simple,
   /// Call to __kmpc_nvptx_end_reduce_nowait(int32_t global_tid);
   OMPRTL_NVPTX__kmpc_end_reduce_nowait,
   /// Call to void __kmpc_data_sharing_init_stack();
@@ -1703,83 +1693,37 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 FnTy, /*Name=*/"__kmpc_nvptx_parallel_reduce_nowait");
 break;
   }
-  case OMPRTL_NVPTX__kmpc_simd_reduce_nowait: {
-// Build int32_t kmpc_nvptx_simd_reduce_nowait(kmp_int32 global_tid,
-// kmp_int32 num_vars, size_t reduce_size, void* reduce_data,
-// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
-// lane_offset, int16_t Algorithm Version),
-// void (*kmp_InterWarpCopyFctPtr)(void* src, int warp_num));
-llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
- CGM.Int16Ty, CGM.Int16Ty};
-auto *ShuffleReduceFnTy =
-llvm::FunctionType::get(CGM.VoidTy, ShuffleReduceTypeParams,
-

r347713 - [MS] Push outermost class DeclContexts only in -fdelayed-template-parsing

2018-11-27 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Nov 27 13:20:42 2018
New Revision: 347713

URL: http://llvm.org/viewvc/llvm-project?rev=347713=rev
Log:
[MS] Push outermost class DeclContexts only in -fdelayed-template-parsing

This is more or less a complete rewrite of r347627, and it fixes PR38460
I added a reduced test case to DelayedTemplateParsing.cpp.

Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/Parser/DelayedTemplateParsing.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=347713=347712=347713=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Tue Nov 27 13:20:42 2018
@@ -1381,26 +1381,37 @@ void Parser::ParseLateTemplatedFuncDef(L
 
   SmallVector TemplateParamScopeStack;
 
-  // Get the list of DeclContexts to reenter.
-  SmallVector DeclContextsToReenter;
+  // Get the list of DeclContexts to reenter. For inline methods, we only want
+  // to push the DeclContext of the outermost class. This matches the way the
+  // parser normally parses bodies of inline methods when the outermost class 
is
+  // complete.
+  struct ContainingDC {
+ContainingDC(DeclContext *DC, bool ShouldPush) : Pair(DC, ShouldPush) {}
+llvm::PointerIntPair Pair;
+DeclContext *getDC() { return Pair.getPointer(); }
+bool shouldPushDC() { return Pair.getInt(); }
+  };
+  SmallVector DeclContextsToReenter;
   DeclContext *DD = FunD;
+  DeclContext *NextContaining = Actions.getContainingDC(DD);
   while (DD && !DD->isTranslationUnit()) {
-DeclContextsToReenter.push_back(DD);
+bool ShouldPush = DD == NextContaining;
+DeclContextsToReenter.push_back({DD, ShouldPush});
+if (ShouldPush)
+  NextContaining = Actions.getContainingDC(DD);
 DD = DD->getLexicalParent();
   }
 
   // Reenter template scopes from outermost to innermost.
-  SmallVectorImpl::reverse_iterator II =
-  DeclContextsToReenter.rbegin();
-  for (; II != DeclContextsToReenter.rend(); ++II) {
-TemplateParamScopeStack.push_back(new ParseScope(this,
-  Scope::TemplateParamScope));
-unsigned NumParamLists =
-  Actions.ActOnReenterTemplateScope(getCurScope(), cast(*II));
+  for (ContainingDC CDC : reverse(DeclContextsToReenter)) {
+TemplateParamScopeStack.push_back(
+new ParseScope(this, Scope::TemplateParamScope));
+unsigned NumParamLists = Actions.ActOnReenterTemplateScope(
+getCurScope(), cast(CDC.getDC()));
 CurTemplateDepthTracker.addDepth(NumParamLists);
-if (*II != FunD) {
+if (CDC.shouldPushDC()) {
   TemplateParamScopeStack.push_back(new ParseScope(this, 
Scope::DeclScope));
-  Actions.PushDeclContext(Actions.getCurScope(), *II);
+  Actions.PushDeclContext(Actions.getCurScope(), CDC.getDC());
 }
   }
 

Modified: cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/DelayedTemplateParsing.cpp?rev=347713=347712=347713=diff
==
--- cfe/trunk/test/Parser/DelayedTemplateParsing.cpp (original)
+++ cfe/trunk/test/Parser/DelayedTemplateParsing.cpp Tue Nov 27 13:20:42 2018
@@ -181,3 +181,33 @@ static void h() {
 }
 
 }
+
+struct PR38460 {
+  template 
+  struct T {
+static void foo() {
+  struct U {
+void dummy() {
+  use_delayed_identifier();
+}
+  };
+}
+  };
+};
+void use_delayed_identifier();
+void trigger_PR38460() {
+  PR38460::T::foo();
+}
+
+template  struct PR38460_2 {
+  struct p {
+struct G {
+  bool operator()(int) {}
+};
+  };
+  static void as() {
+typename p::G g;
+g(0);
+  }
+};
+template struct PR38460_2;


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


[PATCH] D54970: [OpenMP] Add a new version of the SPMD deinit kernel function

2018-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_target_parallel_codegen.cpp:71
   // CHECK: [[DONE]]
-  // CHECK: call void @__kmpc_spmd_kernel_deinit()
+  // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
   // CHECK: br label {{%?}}[[EXIT:.+]]

Add the argument checks in all updated tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54970/new/

https://reviews.llvm.org/D54970



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


[PATCH] D54970: [OpenMP] Add a new version of the SPMD deinit kernel function

2018-11-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 175570.
gtbercea added a comment.

  Delete old function.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54970/new/

https://reviews.llvm.org/D54970

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_target_parallel_codegen.cpp
  test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -757,7 +757,7 @@
   //
   // CHECK: [[EXIT]]
   // call void @__kmpc_restore_team_static_memory(i16 1)
-  // CHECK: call void @__kmpc_spmd_kernel_deinit(
+  // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 
   // CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable{{.+}}, i16* dereferenceable{{.+}})
   //
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -79,7 +79,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -93,7 +93,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
@@ -107,7 +107,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
@@ -123,7 +123,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
@@ -32,7 +32,7 @@
 
 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* @
 
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 
 // CHECK: define internal void [[PARALLEL]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} [[ARGC:%.+]], i32* dereferenceable{{.*}})
 // CHECK-NOT: call i8* @__kmpc_data_sharing_push_stack(
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -84,7 +84,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -98,7 +98,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
@@ -112,7 +112,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// 

[PATCH] D54970: [OpenMP] Add a new version of the SPMD deinit kernel function

2018-11-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong, jholewinski.
gtbercea added a parent revision: D54969: [OpenMP][libomptarget] Add new 
version of SPMD deinit kernel function with argument.

This patch adds a new runtime for the SPMD deinit kernel function which 
replaces the previous function. The new function takes as argument the flag 
which signals whether the runtime is required or not. This enables the compiler 
to optimize out the part of the deinit function which are not needed.


Repository:
  rC Clang

https://reviews.llvm.org/D54970

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_target_parallel_codegen.cpp
  test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -757,7 +757,7 @@
   //
   // CHECK: [[EXIT]]
   // call void @__kmpc_restore_team_static_memory(i16 1)
-  // CHECK: call void @__kmpc_spmd_kernel_deinit(
+  // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 
   // CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable{{.+}}, i16* dereferenceable{{.+}})
   //
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -79,7 +79,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -93,7 +93,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
@@ -107,7 +107,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
@@ -123,7 +123,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
@@ -32,7 +32,7 @@
 
 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* @
 
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 
 // CHECK: define internal void [[PARALLEL]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} [[ARGC:%.+]], i32* dereferenceable{{.*}})
 // CHECK-NOT: call i8* @__kmpc_data_sharing_push_stack(
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -84,7 +84,7 @@
 // CHECK: {{call|invoke}} void [[OUTL1:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_restore_team_static_memory(i16 1)
-// CHECK: call void @__kmpc_spmd_kernel_deinit()
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL1]](
@@ -98,7 +98,7 @@
 // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 

r347705 - [clang][ARC] Fix test for commit r347699

2018-11-27 Thread Tatyana Krasnukha via cfe-commits
Author: tkrasnukha
Date: Tue Nov 27 12:56:30 2018
New Revision: 347705

URL: http://llvm.org/viewvc/llvm-project?rev=347705=rev
Log:
[clang][ARC] Fix test for commit r347699

Modified:
cfe/trunk/test/CodeGen/arc/arguments.c

Modified: cfe/trunk/test/CodeGen/arc/arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arc/arguments.c?rev=347705=347704=347705=diff
==
--- cfe/trunk/test/CodeGen/arc/arguments.c (original)
+++ cfe/trunk/test/CodeGen/arc/arguments.c Tue Nov 27 12:56:30 2018
@@ -124,12 +124,12 @@ void st2(s16 a, s16 b) {}
 
 // Use 8-byte struct 3 times, gets 8 registers, 1 byval struct argument.
 void st3(s16 a, s16 b, s16 c) {}
-// CHECK: define void @st3(i32 inreg %a.coerce0, i32 inreg %a.coerce1, i32 
inreg %a.coerce2, i32 inreg %a.coerce3, i32 inreg %b.coerce0, i32 inreg 
%b.coerce1, i32 inreg %b.coerce2, i32 inreg %b.coerce3, i32 %c.coerce0, i32 
%c.coerce1, i32 %c.coerce2, i32 %c.coerce3)
+// CHECK: define void @st3(i32 inreg %a.coerce0, i32 inreg %a.coerce1, i32 
inreg %a.coerce2, i32 inreg %a.coerce3, i32 inreg %b.coerce0, i32 inreg 
%b.coerce1, i32 inreg %b.coerce2, i32 inreg %b.coerce3, { i32, i32, i32, i32 } 
%c.coerce)
 
 // 1 sret + 1 i32 + 2*(i32 coerce) + 4*(i32 coerce) + 1 byval
 s16 st4(int x, s8 a, s16 b, s16 c) { return b; }
-// CHECK: define void @st4(%struct.s16* noalias sret %agg.result, i32 inreg 
%x, i32 inreg %a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg 
%b.coerce1, i32 inreg %b.coerce2, i32 inreg %b.coerce3, i32 %c.coerce0, i32 
%c.coerce1, i32 %c.coerce2, i32 %c.coerce3)
+// CHECK: define void @st4(%struct.s16* noalias sret %agg.result, i32 inreg 
%x, i32 inreg %a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg 
%b.coerce1, i32 inreg %b.coerce2, i32 inreg %b.coerce3, { i32, i32, i32, i32 } 
%c.coerce)
 
 // 1 sret + 2*(i32 coerce) + 4*(i32 coerce) + 4*(i32 coerce)
 s16 st5(s8 a, s16 b, s16 c) { return b; }
-// CHECK: define void @st5(%struct.s16* noalias sret %agg.result, i32 inreg 
%a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg %b.coerce1, 
i32 inreg %b.coerce2, i32 inreg %b.coerce3, i32 %c.coerce0, i32 %c.coerce1, i32 
%c.coerce2, i32 %c.coerce3)
+// CHECK: define void @st5(%struct.s16* noalias sret %agg.result, i32 inreg 
%a.coerce0, i32 inreg %a.coerce1, i32 inreg %b.coerce0, i32 inreg %b.coerce1, 
i32 inreg %b.coerce2, i32 inreg %b.coerce3, i32 %c.coerce0, { i32, i32, i32, 
i32 } %c.coerce)


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


[PATCH] D53751: [ASTImporter] Added Import functions for transition to new API.

2018-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D53751#1301551 , @shafik wrote:

> I think these changes make sense at a high level but I am not sure about the 
> refactoring strategy. I am especially concerned we may end up in place where 
> all the effected users of the API don't get updated and we are stuck with 
> this parallel API.


I didn't actually see this comment get addressed other than to say it won't be 
a problem in practice, which I'm not certain I agree with. Was there a reason 
why this got commit before finding out if the reviewer with the concern agrees 
with your rationale? FWIW, I share the concern that having parallel APIs for 
any length of time is a dangerous thing. Given that "almost ready to go" is not 
"ready to go" but there's not an imminent release, I don't understand the rush 
to commit this.

When is the renaming and removal of the old API expected take place? Days? 
Weeks? Months?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53751/new/

https://reviews.llvm.org/D53751



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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2018-11-27 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 175553.
Rakete added a comment.

Rebase and friendly ping! :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53847/new/

https://reviews.llvm.org/D53847

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Parse/ParseTentative.cpp
  lib/Parse/Parser.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/drs/dr1xx.cpp
  test/CXX/drs/dr2xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/CXX/drs/dr5xx.cpp
  test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
  test/FixIt/fixit.cpp
  test/Parser/cxx-member-initializers.cpp
  test/Parser/editor-placeholder-recovery.cpp
  test/SemaCXX/MicrosoftCompatibility.cpp
  test/SemaCXX/MicrosoftExtensions.cpp
  test/SemaCXX/MicrosoftSuper.cpp
  test/SemaCXX/unknown-type-name.cpp

Index: test/SemaCXX/unknown-type-name.cpp
===
--- test/SemaCXX/unknown-type-name.cpp
+++ test/SemaCXX/unknown-type-name.cpp
@@ -36,15 +36,15 @@
 
   static int n;
   static type m;
-  static int h(T::type, int); // expected-error{{missing 'typename'}}
-  static int h(T::type x, char); // expected-error{{missing 'typename'}}
+  static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++2a extension}}
+  static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++2a extension}}
 };
 
 template
-A::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+A::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
-A::type A::f() { return type(); } // expected-error{{missing 'typename'}}
+A::type A::f() { return type(); } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
 void f(T::type) { } // expected-error{{missing 'typename'}}
@@ -72,9 +72,7 @@
 
 int *p;
 
-// FIXME: We should assume that 'undeclared' is a type, not a parameter name
-//here, and produce an 'unknown type name' diagnostic instead.
-int f1(undeclared, int); // expected-error{{requires a type specifier}}
+int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
 
 int f2(undeclared, 0); // expected-error{{undeclared identifier}}
 
@@ -86,11 +84,11 @@
 
 template int A::n(T::value); // ok
 template
-A::type // expected-error{{missing 'typename'}}
+A::type // expected-warning {{implicit 'typename' is a C++2a extension}}
 A::m(T::value, 0); // ok
 
-template int A::h(T::type, int) {} // expected-error{{missing 'typename'}}
-template int A::h(T::type x, char) {} // expected-error{{missing 'typename'}}
+template int A::h(T::type, int) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
+template int A::h(T::type x, char) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template int h(T::type, int); // expected-error{{missing 'typename'}}
 template int h(T::type x, char); // expected-error{{missing 'typename'}}
@@ -118,4 +116,5 @@
 // FIXME: We know which type specifier should have been specified here. Provide
 //a fix-it to add 'typename A::type'
 template
-A::g() { } // expected-error{{requires a type specifier}}
+A::g() { } // expected-error{{expected unqualified-id}}
+// expected-warning@-1{{implicit 'typename' is a C++2a extension}}
Index: test/SemaCXX/MicrosoftSuper.cpp
===
--- test/SemaCXX/MicrosoftSuper.cpp
+++ test/SemaCXX/MicrosoftSuper.cpp
@@ -108,8 +108,8 @@
   typename __super::XXX a;
   typedef typename __super::XXX b;
 
-  __super::XXX c; // expected-error {{missing 'typename'}}
-  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+  __super::XXX c; // expected-warning {{implicit 'typename' is a C++2a extension}}
+  typedef __super::XXX d; // expected-warning {{implicit 'typename' is a C++2a extension}}
 
   void foo() {
 typename __super::XXX e;
@@ -127,8 +127,8 @@
   typename __super::XXX a;
   typedef typename __super::XXX b;
 
-  __super::XXX c; // expected-error {{missing 'typename'}}
-  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+  __super::XXX c; // expected-warning {{implicit 'typename' is a C++2a extension}}
+  typedef __super::XXX d; // expected-warning {{implicit 'typename' is a C++2a extension}}
 
   void foo() {
 typename __super::XXX e;
Index: test/SemaCXX/MicrosoftExtensions.cpp
===
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -526,7 +526,7 @@
 
 namespace PR32750 {
 template struct A {};
-template struct B : A> { A::C::D d; }; // expected-error {{missing 'typename' prior to dependent type 

[PATCH] D54816: [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I'm a bit confused - what in these tests requires that lib/Target/RISCV was 
built?

These tests obviously don't fail on the standard builders for instance.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54816/new/

https://reviews.llvm.org/D54816



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


r347701 - [clang][slh] add attribute for speculative load hardening

2018-11-27 Thread Zola Bridges via cfe-commits
Author: zbrid
Date: Tue Nov 27 11:56:46 2018
New Revision: 347701

URL: http://llvm.org/viewvc/llvm-project?rev=347701=rev
Log:
[clang][slh] add attribute for speculative load hardening

Summary:
Resubmit this with no changes because I think the build was broken
by a different diff.
-
The prior diff had to be reverted because there were two tests
that failed. I updated the two tests in this diff

clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaCXX/attr-speculative-load-hardening.cpp

- Summary from Previous Diff (Still Accurate) -

LLVM IR already has an attribute for speculative_load_hardening. Before
this commit, when a user passed the -mspeculative-load-hardening flag to
Clang, every function would have this attribute added to it. This Clang
attribute will allow users to opt into SLH on a function by function basis.

This can be applied to functions and Objective C methods.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

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

Added:
cfe/trunk/test/CodeGen/attr-speculative-load-hardening.cpp
cfe/trunk/test/CodeGen/attr-speculative-load-hardening.m
cfe/trunk/test/SemaCXX/attr-speculative-load-hardening.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=347701=347700=347701=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Nov 27 11:56:46 2018
@@ -3091,3 +3091,9 @@ def AlwaysDestroy : InheritableAttr {
   let Subjects = SubjectList<[Var]>;
   let Documentation = [AlwaysDestroyDocs];
 }
+
+def SpeculativeLoadHardening : InheritableAttr {
+  let Spellings = [Clang<"speculative_load_hardening">];
+  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
+  let Documentation = [SpeculativeLoadHardeningDocs];
+}

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=347701=347700=347701=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Nov 27 11:56:46 2018
@@ -3629,3 +3629,27 @@ GNU inline semantics are the default beh
 ``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
   }];
 }
+
+def SpeculativeLoadHardeningDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+  This attribute can be applied to a function declaration in order to indicate
+  that `Speculative Load Hardening 
`_
+  should be enabled for the function body. This can also be applied to a method
+  in Objective C.
+
+  Speculative Load Hardening is a best-effort mitigation against
+  information leak attacks that make use of control flow
+  miss-speculation - specifically miss-speculation of whether a branch
+  is taken or not. Typically vulnerabilities enabling such attacks are
+  classified as "Spectre variant #1". Notably, this does not attempt to
+  mitigate against miss-speculation of branch target, classified as
+  "Spectre variant #2" vulnerabilities.
+
+  When inlining, the attribute is sticky. Inlining a function that
+  carries this attribute will cause the caller to gain the
+  attribute. This is intended to provide a maximally conservative model
+  where the code in a function annotated with this attribute will always
+  (even after inlining) end up hardened.
+  }];
+}

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=347701=347700=347701=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Nov 27 11:56:46 2018
@@ -1791,6 +1791,8 @@ void CodeGenModule::ConstructDefaultFnAt
 if (CodeGenOpts.Backchain)
   FuncAttrs.addAttribute("backchain");
 
+// FIXME: The interaction of this attribute with the SLH command line flag
+// has not been determined.
 if (CodeGenOpts.SpeculativeLoadHardening)
   FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
   }
@@ -1854,6 +1856,8 @@ void CodeGenModule::ConstructAttributeLi
   FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute(llvm::Attribute::SpeculativeLoadHardening);
 
 if (const FunctionDecl *Fn = 

[PATCH] D54489: Implement -frecord-command-line (-frecord-gcc-switches)

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54489/new/

https://reviews.llvm.org/D54489



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


[PATCH] D53100: clang: Add ARCTargetInfo

2018-11-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347699: [clang][ARC] Add ARCTargetInfo (authored by 
tkrasnukha, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53100?vs=175290=175549#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53100/new/

https://reviews.llvm.org/D53100

Files:
  lib/Basic/CMakeLists.txt
  lib/Basic/Targets.cpp
  lib/Basic/Targets/ARC.cpp
  lib/Basic/Targets/ARC.h
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arc/arguments.c
  test/CodeGen/arc/struct-align.c
  test/CodeGen/target-data.c

Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -71,6 +71,7 @@
   Targets.cpp
   Targets/AArch64.cpp
   Targets/AMDGPU.cpp
+  Targets/ARC.cpp
   Targets/ARM.cpp
   Targets/AVR.cpp
   Targets/BPF.cpp
Index: lib/Basic/Targets/ARC.cpp
===
--- lib/Basic/Targets/ARC.cpp
+++ lib/Basic/Targets/ARC.cpp
@@ -0,0 +1,25 @@
+//===--- ARC.cpp - Implement ARC target feature support ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements ARC TargetInfo objects.
+//
+//===--===//
+
+#include "ARC.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void ARCTargetInfo::getTargetDefines(const LangOptions ,
+ MacroBuilder ) const {
+  Builder.defineMacro("__arc__");
+}
Index: lib/Basic/Targets/ARC.h
===
--- lib/Basic/Targets/ARC.h
+++ lib/Basic/Targets/ARC.h
@@ -0,0 +1,74 @@
+//===--- ARC.h - Declare ARC target feature support -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file declares ARC TargetInfo objects.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_ARC_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_ARC_H
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public TargetInfo {
+public:
+  ARCTargetInfo(const llvm::Triple , const TargetOptions &)
+  : TargetInfo(Triple) {
+NoAsmVariants = true;
+LongLongAlign = 32;
+SuitableAlign = 32;
+DoubleAlign = LongDoubleAlign = 32;
+SizeType = UnsignedInt;
+PtrDiffType = SignedInt;
+IntPtrType = SignedInt;
+UseZeroLengthBitfieldAlignment = true;
+resetDataLayout("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-"
+"i32:32:32-f32:32:32-i64:32-f64:32-a:0:32-n32");
+  }
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override;
+
+  ArrayRef getTargetBuiltins() const override { return None; }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::VoidPtrBuiltinVaList;
+  }
+
+  const char *getClobbers() const override { return ""; }
+
+  ArrayRef getGCCRegNames() const override {
+static const char *const GCCRegNames[] = {
+"r0",  "r1",  "r2",  "r3",  "r4",  "r5", "r6",  "r7",
+"r8",  "r9",  "r10", "r11", "r12", "r13","r14", "r15",
+"r16", "r17", "r18", "r19", "r20", "r21","r22", "r23",
+"r24", "r25", "gp",  "sp",  "fp",  "ilink1", "r30", "blink"};
+return llvm::makeArrayRef(GCCRegNames);
+  }
+
+  ArrayRef getGCCRegAliases() const override {
+return None;
+  }
+
+  bool validateAsmConstraint(const char *,
+ TargetInfo::ConstraintInfo ) const override {
+return false;
+  }
+};
+
+} // namespace targets
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_BASIC_TARGETS_ARC_H
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -16,6 +16,7 @@
 
 #include "Targets/AArch64.h"
 #include "Targets/AMDGPU.h"
+#include "Targets/ARC.h"
 #include "Targets/ARM.h"
 #include "Targets/AVR.h"
 #include "Targets/BPF.h"
@@ -124,6 +125,9 @@
   default:
 return nullptr;
 
+  case llvm::Triple::arc:
+return new ARCTargetInfo(Triple, Opts);
+
   case 

[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-11-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:80
+// used with the same version of generated operators.
+RecTy = Context.getAddrSpaceQualType(RecTy, LangAS::opencl_generic);
+

rjmccall wrote:
> Anastasia wrote:
> > rjmccall wrote:
> > > I would suggest taking this opportunity to set up the AST to support 
> > > declaring methods in an arbitrary address space, so that you can just ask 
> > > a `CXXMethodDecl` what address space it's in.  You don't have to actually 
> > > add language support for that — OpenCL C++ would simply change the it to 
> > > the generic address space instead of the default — but I think that's the 
> > > right technical approach for implementing this, as opposed to adding a 
> > > bunch of OpenCL C++ -specific logic all over the compiler that just 
> > > hardcodes a different address space.
> > I quite like this idea. Apart from providing more clean implementation, it 
> > opens opportunities for solving several problems that I am trying to 
> > understand how to address. Specifically I am trying to find a way to 
> > 'overload' methods based on the address space of the object.
> > 
> > For example, if an object is created in the address space 1 then 
> > programmers should be able to provide a method to be used for objects in 
> > such address space for efficiency or even correctness issue.
> > 
> > The reasons I am looking at it is that currently C++ doesn't make much 
> > sense for address spaces, because we are removing them to generate just one 
> > implementation with generic/default address space. However,
> > - Not all address spaces can be converted to generic/default address space. 
> > Example in OpenCL is constant AS that can't be converted to any other.
> > - Higher performance can be achieved on some HW when using specific address 
> > spaces instead of default.
> > 
> > I was wondering if a method qualifier is a good language solution for this? 
> > For example in OpenCL we could write something like:
> > 
> >   class foo
> >   {
> >   public:
> > void bar() __private; // implies bar(__private foo*)
> > void bar() __constant; // implies bar(__constant foo*)
> >   };
> > 
> > I guess in C++ it can be done similarly:
> > 
> >   class foo
> >   {
> >   public:
> > void bar() __attribute__((address_space(1)));
> > void bar() __attribute__((address_space(2)));
> >   };
> > 
> > I would quite like to solve this generically, not just for OpenCL. I think 
> > a lot of implementation can be unified/reused then.
> > 
> > Without this address spaces seem pretty useless with C++ because they are 
> > just cast away to generic/default and no specific address space ends up at 
> > the AST level at all. This means implementation will have to rely on the 
> > optimizers to recover/deduce address spaces. But I would quite like to 
> > provide a way for the developers to manually tune the code for address 
> > spaces, just as it was done for OpenCL C.
> > 
> > Let me know if you have any thought/suggestions.
> > I was wondering if a method qualifier is a good language solution for this? 
> > For example in OpenCL we could write something like:
> 
> Yes, I think that's a very natural extension of C++'s method-qualification 
> rules for `const` and `volatile`.  Overloads would then be resolved based on 
> which address space was the best match.
> 
> Now, to briefly take a holistic perspective on the language design, this 
> feature would *strongly* benefit from a way to make a method templated over 
> the address space of `this`.  Unfortunately, I don't think that's reasonable 
> to solve in a language extension; it's really something that needs core 
> language work.  That would be a pretty big leap in scope; that said, if 
> you're interested in pursuing it, I'd be happy to share some thoughts on how 
> it'd look, and I think there are several people in the Clang community who 
> could help you with putting a proposal before the committee.
Thanks! Yes, I believe some template-based approach could make this a lot more 
usable. I would be really interested to learn more about your ideas. I would 
also quite like to see this properly in the spec. I will follow up with you in 
a separate thread.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54862/new/

https://reviews.llvm.org/D54862



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


r347699 - [clang][ARC] Add ARCTargetInfo

2018-11-27 Thread Tatyana Krasnukha via cfe-commits
Author: tkrasnukha
Date: Tue Nov 27 11:52:10 2018
New Revision: 347699

URL: http://llvm.org/viewvc/llvm-project?rev=347699=rev
Log:
[clang][ARC] Add ARCTargetInfo

Based-on-patch-by: Pete Couperus 

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

Added:
cfe/trunk/lib/Basic/Targets/ARC.cpp
cfe/trunk/lib/Basic/Targets/ARC.h
cfe/trunk/test/CodeGen/arc/
cfe/trunk/test/CodeGen/arc/arguments.c
cfe/trunk/test/CodeGen/arc/struct-align.c
Modified:
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/target-data.c

Modified: cfe/trunk/lib/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=347699=347698=347699=diff
==
--- cfe/trunk/lib/Basic/CMakeLists.txt (original)
+++ cfe/trunk/lib/Basic/CMakeLists.txt Tue Nov 27 11:52:10 2018
@@ -71,6 +71,7 @@ add_clang_library(clangBasic
   Targets.cpp
   Targets/AArch64.cpp
   Targets/AMDGPU.cpp
+  Targets/ARC.cpp
   Targets/ARM.cpp
   Targets/AVR.cpp
   Targets/BPF.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=347699=347698=347699=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov 27 11:52:10 2018
@@ -16,6 +16,7 @@
 
 #include "Targets/AArch64.h"
 #include "Targets/AMDGPU.h"
+#include "Targets/ARC.h"
 #include "Targets/ARM.h"
 #include "Targets/AVR.h"
 #include "Targets/BPF.h"
@@ -124,6 +125,9 @@ TargetInfo *AllocateTarget(const llvm::T
   default:
 return nullptr;
 
+  case llvm::Triple::arc:
+return new ARCTargetInfo(Triple, Opts);
+
   case llvm::Triple::xcore:
 return new XCoreTargetInfo(Triple, Opts);
 

Added: cfe/trunk/lib/Basic/Targets/ARC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARC.cpp?rev=347699=auto
==
--- cfe/trunk/lib/Basic/Targets/ARC.cpp (added)
+++ cfe/trunk/lib/Basic/Targets/ARC.cpp Tue Nov 27 11:52:10 2018
@@ -0,0 +1,25 @@
+//===--- ARC.cpp - Implement ARC target feature support 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements ARC TargetInfo objects.
+//
+//===--===//
+
+#include "ARC.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void ARCTargetInfo::getTargetDefines(const LangOptions ,
+ MacroBuilder ) const {
+  Builder.defineMacro("__arc__");
+}

Added: cfe/trunk/lib/Basic/Targets/ARC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARC.h?rev=347699=auto
==
--- cfe/trunk/lib/Basic/Targets/ARC.h (added)
+++ cfe/trunk/lib/Basic/Targets/ARC.h Tue Nov 27 11:52:10 2018
@@ -0,0 +1,74 @@
+//===--- ARC.h - Declare ARC target feature support -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file declares ARC TargetInfo objects.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_ARC_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_ARC_H
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public TargetInfo {
+public:
+  ARCTargetInfo(const llvm::Triple , const TargetOptions &)
+  : TargetInfo(Triple) {
+NoAsmVariants = true;
+LongLongAlign = 32;
+SuitableAlign = 32;
+DoubleAlign = LongDoubleAlign = 32;
+SizeType = UnsignedInt;
+PtrDiffType = SignedInt;
+IntPtrType = SignedInt;
+UseZeroLengthBitfieldAlignment = true;
+resetDataLayout("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-"
+"i32:32:32-f32:32:32-i64:32-f64:32-a:0:32-n32");
+  }
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override;
+
+  ArrayRef getTargetBuiltins() const override { return None; }
+
+  BuiltinVaListKind getBuiltinVaListKind() const 

[PATCH] D54858: [OpenCL] Improve diagnostics for address spaces in template instantiation

2018-11-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/Sema/TreeTransform.h:4241
+  if (SemaRef.getLangOpts().OpenCL && T.getType()->isTemplateTypeParmType())
+Quals.removeAddressSpace();
+

rjmccall wrote:
> When do you actually add the qualifier back?
> 
> Also, I don't think this is specific to either OpenCL or direct references to 
> template type parameters; it has to be any dependent type.
As far as I understand the qualifiers here are only used to rebuild the type. 
Therefore I assumed I don't need to restore the original. I am now thinking of 
moving this down into `RebuildQualifiedType` that has similar code for handling 
qualifiers.

However, after enabling it for C++ in general I am getting some issues with 
deduction of templates with pointers that have address spaces in pointees. So I 
am investigating this further whether it's the right approach at all. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54858/new/

https://reviews.llvm.org/D54858



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


[PATCH] D38479: Make -mgeneral-regs-only more like GCC's

2018-11-27 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Bump, this is still listed as a TODO in the Linux kernel that works around the 
issue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D38479/new/

https://reviews.llvm.org/D38479



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


[PATCH] D54768: Don't speculatively emit VTTs for classes unless we are able to correctly emit references to all the functions they will (directly or indirectly) reference.

2018-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347692: Dont speculatively emit VTTs for classes 
unless we are able to correctly emit… (authored by rsmith, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54768?vs=174822=175545#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54768/new/

https://reviews.llvm.org/D54768

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/speculative-vtt.cpp


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -287,6 +287,7 @@
   void emitVirtualInheritanceTables(const CXXRecordDecl *RD) override;
 
   bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const override;
+  bool canSpeculativelyEmitVTableAsBaseClass(const CXXRecordDecl *RD) const;
 
   void setThunkLinkage(llvm::Function *Thunk, bool ForVTable, GlobalDecl GD,
bool ReturnAdjustment) override {
@@ -1777,7 +1778,8 @@
   VTables.EmitVTTDefinition(VTT, CGM.getVTableLinkage(RD), RD);
 }
 
-bool ItaniumCXXABI::canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const {
+bool ItaniumCXXABI::canSpeculativelyEmitVTableAsBaseClass(
+const CXXRecordDecl *RD) const {
   // We don't emit available_externally vtables if we are in -fapple-kext mode
   // because kext mode does not permit devirtualization.
   if (CGM.getLangOpts().AppleKext)
@@ -1795,7 +1797,43 @@
   // to emit an available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyUnusedVirtualInlineFunction(RD);
+  if (hasAnyUnusedVirtualInlineFunction(RD))
+return false;
+
+  // For a class with virtual bases, we must also be able to speculatively
+  // emit the VTT, because CodeGen doesn't have separate notions of "can emit
+  // the vtable" and "can emit the VTT". For a base subobject, this means we
+  // need to be able to emit non-virtual base vtables.
+  if (RD->getNumVBases()) {
+for (const auto  : RD->bases()) {
+  auto *BRD = B.getType()->getAsCXXRecordDecl();
+  assert(BRD && "no class for base specifier");
+  if (B.isVirtual() || !BRD->isDynamicClass())
+continue;
+  if (!canSpeculativelyEmitVTableAsBaseClass(BRD))
+return false;
+}
+  }
+
+  return true;
+}
+
+bool ItaniumCXXABI::canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const {
+  if (!canSpeculativelyEmitVTableAsBaseClass(RD))
+return false;
+
+  // For a complete-object vtable (or more specifically, for the VTT), we need
+  // to be able to speculatively emit the vtables of all dynamic virtual bases.
+  for (const auto  : RD->vbases()) {
+auto *BRD = B.getType()->getAsCXXRecordDecl();
+assert(BRD && "no class for base specifier");
+if (!BRD->isDynamicClass())
+  continue;
+if (!canSpeculativelyEmitVTableAsBaseClass(BRD))
+  return false;
+  }
+
+  return true;
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction ,
   Address InitialPtr,
Index: test/CodeGenCXX/speculative-vtt.cpp
===
--- test/CodeGenCXX/speculative-vtt.cpp
+++ test/CodeGenCXX/speculative-vtt.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -O2 -disable-llvm-passes 
-emit-llvm -o - | FileCheck %s
+struct A { virtual ~A(); };
+template struct B : virtual A {
+  ~B() override {}
+};
+struct C : B, B { C(); ~C() override; };
+struct D : C { ~D() override; };
+
+// We must not create a reference to B::~B() here, because we're not 
going to emit it.
+// CHECK-NOT: @_ZN1BIiED1Ev
+// CHECK-NOT: @_ZTC1D0_1BIiE =
+// CHECK-NOT: @_ZTT1D = available_externally
+D *p = new D;


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -287,6 +287,7 @@
   void emitVirtualInheritanceTables(const CXXRecordDecl *RD) override;
 
   bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const override;
+  bool canSpeculativelyEmitVTableAsBaseClass(const CXXRecordDecl *RD) const;
 
   void setThunkLinkage(llvm::Function *Thunk, bool ForVTable, GlobalDecl GD,
bool ReturnAdjustment) override {
@@ -1777,7 +1778,8 @@
   VTables.EmitVTTDefinition(VTT, CGM.getVTableLinkage(RD), RD);
 }
 
-bool ItaniumCXXABI::canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const {
+bool ItaniumCXXABI::canSpeculativelyEmitVTableAsBaseClass(
+const CXXRecordDecl *RD) const {
   // We don't emit available_externally vtables if we are in -fapple-kext mode
   // because kext mode does not permit devirtualization.
   if (CGM.getLangOpts().AppleKext)
@@ -1795,7 +1797,43 @@
   // to emit an available_externally copy of vtable.
   // FIXME we can still emit a copy of 

r347692 - Don't speculatively emit VTTs for classes unless we are able to correctly emit references to all the functions they will (directly or indirectly) reference.

2018-11-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 27 11:33:49 2018
New Revision: 347692

URL: http://llvm.org/viewvc/llvm-project?rev=347692=rev
Log:
Don't speculatively emit VTTs for classes unless we are able to correctly emit 
references to all the functions they will (directly or indirectly) reference.

Summary:
This fixes a miscompile where we'd emit a VTT for a class that ends up
referencing an inline virtual member function that we can't actually
emit a body for (because we never instantiated it in the current TU),
which in a corner case of a corner case can lead to link errors.

Reviewers: rjmccall

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/speculative-vtt.cpp
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=347692=347691=347692=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Nov 27 11:33:49 2018
@@ -287,6 +287,7 @@ public:
   void emitVirtualInheritanceTables(const CXXRecordDecl *RD) override;
 
   bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const override;
+  bool canSpeculativelyEmitVTableAsBaseClass(const CXXRecordDecl *RD) const;
 
   void setThunkLinkage(llvm::Function *Thunk, bool ForVTable, GlobalDecl GD,
bool ReturnAdjustment) override {
@@ -1777,7 +1778,8 @@ void ItaniumCXXABI::emitVirtualInheritan
   VTables.EmitVTTDefinition(VTT, CGM.getVTableLinkage(RD), RD);
 }
 
-bool ItaniumCXXABI::canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const {
+bool ItaniumCXXABI::canSpeculativelyEmitVTableAsBaseClass(
+const CXXRecordDecl *RD) const {
   // We don't emit available_externally vtables if we are in -fapple-kext mode
   // because kext mode does not permit devirtualization.
   if (CGM.getLangOpts().AppleKext)
@@ -1795,7 +1797,43 @@ bool ItaniumCXXABI::canSpeculativelyEmit
   // to emit an available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyUnusedVirtualInlineFunction(RD);
+  if (hasAnyUnusedVirtualInlineFunction(RD))
+return false;
+
+  // For a class with virtual bases, we must also be able to speculatively
+  // emit the VTT, because CodeGen doesn't have separate notions of "can emit
+  // the vtable" and "can emit the VTT". For a base subobject, this means we
+  // need to be able to emit non-virtual base vtables.
+  if (RD->getNumVBases()) {
+for (const auto  : RD->bases()) {
+  auto *BRD = B.getType()->getAsCXXRecordDecl();
+  assert(BRD && "no class for base specifier");
+  if (B.isVirtual() || !BRD->isDynamicClass())
+continue;
+  if (!canSpeculativelyEmitVTableAsBaseClass(BRD))
+return false;
+}
+  }
+
+  return true;
+}
+
+bool ItaniumCXXABI::canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const {
+  if (!canSpeculativelyEmitVTableAsBaseClass(RD))
+return false;
+
+  // For a complete-object vtable (or more specifically, for the VTT), we need
+  // to be able to speculatively emit the vtables of all dynamic virtual bases.
+  for (const auto  : RD->vbases()) {
+auto *BRD = B.getType()->getAsCXXRecordDecl();
+assert(BRD && "no class for base specifier");
+if (!BRD->isDynamicClass())
+  continue;
+if (!canSpeculativelyEmitVTableAsBaseClass(BRD))
+  return false;
+  }
+
+  return true;
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction ,
   Address InitialPtr,

Added: cfe/trunk/test/CodeGenCXX/speculative-vtt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/speculative-vtt.cpp?rev=347692=auto
==
--- cfe/trunk/test/CodeGenCXX/speculative-vtt.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/speculative-vtt.cpp Tue Nov 27 11:33:49 2018
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -O2 -disable-llvm-passes 
-emit-llvm -o - | FileCheck %s
+struct A { virtual ~A(); };
+template struct B : virtual A {
+  ~B() override {}
+};
+struct C : B, B { C(); ~C() override; };
+struct D : C { ~D() override; };
+
+// We must not create a reference to B::~B() here, because we're not 
going to emit it.
+// CHECK-NOT: @_ZN1BIiED1Ev
+// CHECK-NOT: @_ZTC1D0_1BIiE =
+// CHECK-NOT: @_ZTT1D = available_externally
+D *p = new D;


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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-11-27 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added a comment.

In D53738#1309171 , @ebevhan wrote:

> In D53738#1308314 , @leonardchan 
> wrote:
>
> > > Generally I think it's good! One final note; I assume we could 
> > > technically reuse/rename the EmitFixedPointAdd function and use it to 
> > > emit other binops when those are added?
> >
> > Yes, but I imagine if we choose to keep the call to 
> > `EmitFixedPointConversion` to cast both operands to a common type, this 
> > wouldn't be reused for division or multiplication since I believe those do 
> > not require for the operands to be converted to a common type.
>
>
> They don't? The example given by the spec is even `int * _Fract`.


Oh, I meant that the scales of both operands won't need to be aligned before 
performing the operation. Since for multiplication, we can multiply fixed point 
numbers in any scale without shifting and only need to perform a shift on the 
result to convert to the destination type. Although this would only apply to 
non-saturating multiplication since to use the intrinsics, both operands would 
need to be in the same scale.

@rjmccall Any more comments on this patch?




Comment at: clang/test/Frontend/fixed_point_add.c:269
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = call i15 @llvm.uadd.sat.i15(i15 
[[USA_TRUNC]], i15 [[USA_SAT_TRUNC]])
+  // UNSIGNED-NEXT: [[SUM_EXT:%[a-z0-9]+]] = zext i15 [[SUM]] to i16
+  // UNSIGNED-NEXT: store i16 [[SUM_EXT]], i16* %usa_sat, align 2

ebevhan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > leonardchan wrote:
> > > > ebevhan wrote:
> > > > > This is probably a candidate for an isel optimization. This operation 
> > > > > also works as an `i16 ssat.add` with a negative-clamp-to-zero 
> > > > > afterwards, and if the target supports `i16 ssat.add` natively then 
> > > > > it will likely be a lot more efficient than whatever an `i15 
> > > > > uadd.sat` produces.
> > > > Do you think it would be more efficient for now then if instead we did 
> > > > SHL by 1, saturate, then [AL]SHR by 1? This way we could use `i16 
> > > > ssat.add` instead of `i15 ssat.add`?
> > > We should probably just do it in isel or instcombine instead. We don't 
> > > know at this point which intrinsic is a better choice (though, I think 
> > > power-of-two-types are generally better).
> > Ok. Are you suggesting something should be changed here though? I imagine 
> > that during legalization, `i15 ssat.add` would be legalized into `i16 
> > ssat.add` if that is what's natively supported.
> No, it doesn't have to be changed. Just something to keep in mind.
> > i15 ssat.add would be legalized into i16 ssat.add if that is what's 
> > natively supported.
> Sure, but I meant that `i15 usat.add` could be more efficient as `i16 
> ssat.add`.
Got it. Thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53738/new/

https://reviews.llvm.org/D53738



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


[PATCH] D54964: Add test about __builtin_constant_p

2018-11-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: rsmith, void, shafik.
Herald added subscribers: cfe-commits, kristina.

Repository:
  rC Clang

https://reviews.llvm.org/D54964

Files:
  test/SemaCXX/constant-expression-cxx1y.cpp


Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1122,3 +1122,8 @@
 static_assert(e2.x != e2.y, "");
 
 } // namespace IndirectFields
+
+constexpr bool indirect_builtin_constant_p(const char *__s) {
+  return __builtin_constant_p(*__s);
+}
+constexpr bool n = indirect_builtin_constant_p("a");


Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1122,3 +1122,8 @@
 static_assert(e2.x != e2.y, "");
 
 } // namespace IndirectFields
+
+constexpr bool indirect_builtin_constant_p(const char *__s) {
+  return __builtin_constant_p(*__s);
+}
+constexpr bool n = indirect_builtin_constant_p("a");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54816: [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-27 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347688: [RISCV] Mark unit tests as requires: 
riscv-registered-target (authored by mgrang, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54816?vs=174988=175541#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54816/new/

https://reviews.llvm.org/D54816

Files:
  cfe/trunk/Driver/riscv-abi.c
  cfe/trunk/Driver/riscv-arch.c
  cfe/trunk/Driver/riscv-features.c
  cfe/trunk/Driver/riscv-gnutools.c
  cfe/trunk/Driver/riscv32-toolchain.c
  cfe/trunk/Driver/riscv64-toolchain.c
  cfe/trunk/test/Driver/riscv-abi.c
  cfe/trunk/test/Driver/riscv-arch.c
  cfe/trunk/test/Driver/riscv-features.c
  cfe/trunk/test/Driver/riscv-gnutools.c
  cfe/trunk/test/Driver/riscv32-toolchain.c
  cfe/trunk/test/Driver/riscv64-toolchain.c

Index: cfe/trunk/Driver/riscv-features.c
===
--- cfe/trunk/Driver/riscv-features.c
+++ cfe/trunk/Driver/riscv-features.c
@@ -0,0 +1,15 @@
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: fno-signed-char
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// RELAX: "-target-feature" "+relax"
+// NO-RELAX: "-target-feature" "-relax"
+// DEFAULT-NOT: "-target-feature" "+relax"
+// DEFAULT-NOT: "-target-feature" "-relax"
Index: cfe/trunk/Driver/riscv-arch.c
===
--- cfe/trunk/Driver/riscv-arch.c
+++ cfe/trunk/Driver/riscv-arch.c
@@ -0,0 +1,319 @@
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imac -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imafc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imafdc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ia -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iaf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iafd -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iac -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iafc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iafdc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32g -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64ima -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64imaf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64imafd -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv64-unknown-elf -march=rv64ic -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64imc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-unknown-elf -march=rv64imac -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang 

[PATCH] D54489: Implement -frecord-command-line (-frecord-gcc-switches)

2018-11-27 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 175540.
scott.linder added a comment.

Update documentation for new option


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54489/new/

https://reviews.llvm.org/D54489

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c
  test/Driver/debug-options.c

Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -157,6 +157,17 @@
 // RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \
 // | FileCheck -check-prefix=GRECORD_OPT %s
 //
+// RUN: %clang -### -c -grecord-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD %s
+// RUN: %clang -### -c -gno-record-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GNO_RECORD %s
+// RUN: %clang -### -c -grecord-command-line -gno-record-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GNO_RECORD %s/
+// RUN: %clang -### -c -grecord-command-line -o - %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD_O %s
+// RUN: %clang -### -c -O3 -ffunction-sections -grecord-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD_OPT %s
+//
 // RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
 // RUN:| FileCheck -check-prefix=GIGNORE %s
 //
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -538,3 +538,18 @@
 // RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
 // CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
 // CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
+
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// Test with a couple examples of non-ELF object file formats
+// RUN: %clang -### -S -target x86_64-unknown-macosx -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s
+// RUN: %clang -### -S -target x86_64-unknown-windows -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s
+// CHECK-RECORD-GCC-SWITCHES: "-record-command-line"
+// CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
+// CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -644,6 +644,7 @@
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.RecordCommandLine = Args.getLastArgValue(OPT_record_command_line);
   Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
   Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5057,14 +5057,22 @@
 
   const char *Exec = D.getClangProgramPath();
 
-  // Optionally embed the -cc1 level arguments into the debug info, for build
-  // analysis.
+  // Optionally embed the -cc1 level arguments into the debug info or a
+  // 

r347689 - Revert "[RISCV] Mark unit tests as "requires: riscv-registered-target""

2018-11-27 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Nov 27 11:13:52 2018
New Revision: 347689

URL: http://llvm.org/viewvc/llvm-project?rev=347689=rev
Log:
Revert "[RISCV] Mark unit tests as "requires: riscv-registered-target""

This reverts commit 1a6a0c9ea2716378d55858c11adf5941608531f8.

Added:
cfe/trunk/test/Driver/riscv-abi.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv-abi.c
cfe/trunk/test/Driver/riscv-arch.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv-arch.c
cfe/trunk/test/Driver/riscv-features.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv-features.c
cfe/trunk/test/Driver/riscv-gnutools.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv-gnutools.c
cfe/trunk/test/Driver/riscv32-toolchain.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
  - copied, changed from r347688, cfe/trunk/Driver/riscv64-toolchain.c
Removed:
cfe/trunk/Driver/riscv-abi.c
cfe/trunk/Driver/riscv-arch.c
cfe/trunk/Driver/riscv-features.c
cfe/trunk/Driver/riscv-gnutools.c
cfe/trunk/Driver/riscv32-toolchain.c
cfe/trunk/Driver/riscv64-toolchain.c

Removed: cfe/trunk/Driver/riscv-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-abi.c?rev=347688=auto
==
--- cfe/trunk/Driver/riscv-abi.c (original)
+++ cfe/trunk/Driver/riscv-abi.c (removed)
@@ -1,49 +0,0 @@
-// REQUIRES: riscv-registered-target
-
-// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
-// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
-
-// CHECK-ILP32: "-target-abi" "ilp32"
-
-// TODO: ilp32f support.
-// RUN: not %clang -target riscv32-unknown-elf %s -o %t.o -mabi=ilp32f 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ILP32F %s
-
-// CHECK-ILP32F: error: unknown target ABI 'ilp32f'
-
-// TODO: ilp32d support.
-// RUN: not %clang -target riscv32-unknown-elf %s -o %t.o -mabi=ilp32d 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
-
-// CHECK-ILP32D: error: unknown target ABI 'ilp32d'
-
-// RUN: not %clang -target riscv32-unknown-elf %s -o %t.o -mabi=lp64 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-RV32-LP64 %s
-
-// CHECK-RV32-LP64: error: unknown target ABI 'lp64'
-
-// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
-// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -mabi=lp64 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
-
-// CHECK-LP64: "-target-abi" "lp64"
-
-// TODO: lp64f support.
-// RUN: not %clang -target riscv64-unknown-elf %s -o %t.o -mabi=lp64f 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LP64F %s
-
-// CHECK-LP64F: error: unknown target ABI 'lp64f'
-
-// TODO: lp64d support.
-// RUN: not %clang -target riscv64-unknown-elf %s -o %t.o -mabi=lp64d 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
-
-// CHECK-LP64D: error: unknown target ABI 'lp64d'
-
-// RUN: not %clang -target riscv64-unknown-elf %s -o %t.o -mabi=ilp32 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-RV64-ILP32 %s
-
-// CHECK-RV64-ILP32: error: unknown target ABI 'ilp32'

Removed: cfe/trunk/Driver/riscv-arch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-arch.c?rev=347688=auto
==
--- cfe/trunk/Driver/riscv-arch.c (original)
+++ cfe/trunk/Driver/riscv-arch.c (removed)
@@ -1,319 +0,0 @@
-// REQUIRES: riscv-registered-target
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imac -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafc -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafdc -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ia -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf 

r347688 - [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-27 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Nov 27 11:13:13 2018
New Revision: 347688

URL: http://llvm.org/viewvc/llvm-project?rev=347688=rev
Log:
[RISCV] Mark unit tests as "requires: riscv-registered-target"

Summary: Some of these tests break if the RISCV backend has not been built.

Reviewers: asb, apazos, sabuasal

Reviewed By: sabuasal

Subscribers: rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, 
shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, 
the_o, rkruppe, PkmX, jocewei, cfe-commits

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

Added:
cfe/trunk/Driver/
cfe/trunk/Driver/riscv-abi.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv-abi.c
cfe/trunk/Driver/riscv-arch.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv-arch.c
cfe/trunk/Driver/riscv-features.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv-features.c
cfe/trunk/Driver/riscv-gnutools.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv-gnutools.c
cfe/trunk/Driver/riscv32-toolchain.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/Driver/riscv64-toolchain.c
  - copied, changed from r347685, cfe/trunk/test/Driver/riscv64-toolchain.c
Removed:
cfe/trunk/test/Driver/riscv-abi.c
cfe/trunk/test/Driver/riscv-arch.c
cfe/trunk/test/Driver/riscv-features.c
cfe/trunk/test/Driver/riscv-gnutools.c
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c

Copied: cfe/trunk/Driver/riscv-abi.c (from r347685, 
cfe/trunk/test/Driver/riscv-abi.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-abi.c?p2=cfe/trunk/Driver/riscv-abi.c=cfe/trunk/test/Driver/riscv-abi.c=347685=347688=347688=diff
==
--- cfe/trunk/test/Driver/riscv-abi.c (original)
+++ cfe/trunk/Driver/riscv-abi.c Tue Nov 27 11:13:13 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \

Copied: cfe/trunk/Driver/riscv-arch.c (from r347685, 
cfe/trunk/test/Driver/riscv-arch.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-arch.c?p2=cfe/trunk/Driver/riscv-arch.c=cfe/trunk/test/Driver/riscv-arch.c=347685=347688=347688=diff
==
--- cfe/trunk/test/Driver/riscv-arch.c (original)
+++ cfe/trunk/Driver/riscv-arch.c Tue Nov 27 11:13:13 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \

Copied: cfe/trunk/Driver/riscv-features.c (from r347685, 
cfe/trunk/test/Driver/riscv-features.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-features.c?p2=cfe/trunk/Driver/riscv-features.c=cfe/trunk/test/Driver/riscv-features.c=347685=347688=347688=diff
==
--- cfe/trunk/test/Driver/riscv-features.c (original)
+++ cfe/trunk/Driver/riscv-features.c Tue Nov 27 11:13:13 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 

Copied: cfe/trunk/Driver/riscv-gnutools.c (from r347685, 
cfe/trunk/test/Driver/riscv-gnutools.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv-gnutools.c?p2=cfe/trunk/Driver/riscv-gnutools.c=cfe/trunk/test/Driver/riscv-gnutools.c=347685=347688=347688=diff
==
--- cfe/trunk/test/Driver/riscv-gnutools.c (original)
+++ cfe/trunk/Driver/riscv-gnutools.c Tue Nov 27 11:13:13 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // Check gnutools are invoked with propagated values for -mabi and -march.
 
 // RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \

Copied: cfe/trunk/Driver/riscv32-toolchain.c (from r347685, 
cfe/trunk/test/Driver/riscv32-toolchain.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/riscv32-toolchain.c?p2=cfe/trunk/Driver/riscv32-toolchain.c=cfe/trunk/test/Driver/riscv32-toolchain.c=347685=347688=347688=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/Driver/riscv32-toolchain.c Tue Nov 27 11:13:13 2018
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | 

[PATCH] D53280: [analyzer] Emit an error for invalid -analyzer-config inputs

2018-11-27 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Thanks! I'll commit around friday (with the requested fixes) to leave enough 
time for everyone to object.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53280/new/

https://reviews.llvm.org/D53280



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


[PATCH] D50147: clang-format: support external styles

2018-11-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D50147#1309880 , @Typz wrote:

> ping?


Sorry for losing track of this.

I think `-style=` is a logical extension of the current options. I'm 
less sure of supporting it in BasedOnStyle, but happy to go either way.

Referring to styles by names in installed style directories seems like a 
relatively marginal feature that would need a more careful design, e.g.:

- respecting platform conventions
- supporting build-time configuration
- understanding how distro packaging is going to work
- thinking about addressing the resulting fragmentation as .clang-format files 
are shared but the referenced files are not

Within a tightly controlled organization, these things are less of an issue. 
We've had luck simply making local changes to support different styles for 
these scenarios, though that's not ideal.
One possibility to reduce the scope here: search for unknown names on under 
`$CLANG_FORMAT_STYLES` if the variable is set. That way it can be set by 
administrators within an org if appropriate, but clang-format doesn't have to 
have opinions about the policy here, and all binaries still behave the same.




Comment at: lib/Basic/VirtualFileSystem.cpp:288
 SmallVectorImpl ) const {
-  return llvm::sys::fs::real_path(Path, Output);
+  return llvm::sys::fs::real_path(Path, Output, true);
 }

(this change isn't a good idea - if you want to expand tilde call 
fs::expand_tilde - it's not related to VFS)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50147/new/

https://reviews.llvm.org/D50147



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


[PATCH] D52578: Thread safety analysis: Allow scoped releasing of capabilities

2018-11-27 Thread Victor Costan via Phabricator via cfe-commits
pwnall added a comment.

In D52578#1307145 , @aaronpuchert 
wrote:

> To be clear, I'm not a big fan of this change myself, I just wanted to see if 
> it was feasible. My personal opinion, as I wrote in the bug report, is that 
> scoped releasing of mutexes is taking RAII a step too far. I'm putting this 
> on ice for now until we're reached a state where it looks a bit less crazy. I 
> hope @pwnall can live with that, since Clang 8 will not come out soon anyway.


If it makes a difference, Chrome (loosely) tracks Clang trunk 
.
 We wouldn't wait for a stable release to adopt the new code.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52578/new/

https://reviews.llvm.org/D52578



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


[PATCH] D54961: [AArch64] Add command-line option for SSBS

2018-11-27 Thread Pablo Barrio via Phabricator via cfe-commits
pbarrio created this revision.
pbarrio added reviewers: olista01, samparker, aemerson.
Herald added subscribers: kristof.beyls, javed.absar.

SSBS (Speculative Store Bypass Safe) is only mandatory from 8.5
onwards but is optional from Armv8.0-A. This patch adds testing for
the ssbs command line option, added to allow enabling the feature
in previous Armv8-A architectures to 8.5.


Repository:
  rC Clang

https://reviews.llvm.org/D54961

Files:
  test/Driver/aarch64-ssbs.c


Index: test/Driver/aarch64-ssbs.c
===
--- /dev/null
+++ test/Driver/aarch64-ssbs.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+ssbs   %s 
2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+ssbs"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+nossbs %s 
2>&1 | FileCheck %s --check-prefix=NOSSBS
+// NOSSBS: "-target-feature" "-ssbs"
+
+// RUN: %clang -### -target aarch64-none-none-eabi  %s 
2>&1 | FileCheck %s --check-prefix=ABSENTSSBS
+// ABSENTSSBS-NOT: "-target-feature" "+ssbs"
+// ABSENTSSBS-NOT: "-target-feature" "-ssbs"


Index: test/Driver/aarch64-ssbs.c
===
--- /dev/null
+++ test/Driver/aarch64-ssbs.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+ssbs   %s 2>&1 | FileCheck %s
+// CHECK: "-target-feature" "+ssbs"
+
+// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+nossbs %s 2>&1 | FileCheck %s --check-prefix=NOSSBS
+// NOSSBS: "-target-feature" "-ssbs"
+
+// RUN: %clang -### -target aarch64-none-none-eabi  %s 2>&1 | FileCheck %s --check-prefix=ABSENTSSBS
+// ABSENTSSBS-NOT: "-target-feature" "+ssbs"
+// ABSENTSSBS-NOT: "-target-feature" "-ssbs"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54958: [OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp - (NFC)

2018-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54958/new/

https://reviews.llvm.org/D54958



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


[PATCH] D54958: [OPENMP] remove redundant ColonExpected flag in ParseOpenMP.cpp - (NFC)

2018-11-27 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir created this revision.
saghir added reviewers: ABataev, kkwli0, RaviNarayanaswamy, mikerice, Hahnfeld, 
hfinkel, gtbercea.
saghir added a project: OpenMP.
Herald added subscribers: cfe-commits, guansong.

In ParseOpenMP.cpp:

bool ColonExpected = false;
...
...
...
else if (ColonExpected)

  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";

The flag ColonExpected is not changed after being initialized to false at 
declaration. Hence, the code within the else if is never executed.

We should remove all instances of this flag.


Repository:
  rC Clang

https://reviews.llvm.org/D54958

Files:
  clang/lib/Parse/ParseOpenMP.cpp


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1867,7 +1867,6 @@
   getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok)))
 : OMPC_MAP_unknown;
 Data.DepLinMapLoc = Tok.getLocation();
-bool ColonExpected = false;
 
 if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
@@ -1935,8 +1934,6 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();
-else if (ColonExpected)
-  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";
   }
 
   bool IsComma =


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1867,7 +1867,6 @@
   getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok)))
 : OMPC_MAP_unknown;
 Data.DepLinMapLoc = Tok.getLocation();
-bool ColonExpected = false;
 
 if (IsMapClauseModifierToken(Tok)) {
   if (PP.LookAhead(0).is(tok::colon)) {
@@ -1935,8 +1934,6 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();
-else if (ColonExpected)
-  Diag(Tok, diag::warn_pragma_expected_colon) << "map type";
   }
 
   bool IsComma =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53751: [ASTImporter] Added Import functions for transition to new API.

2018-11-27 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347685: [ASTImporter] Added Import functions for transition 
to new API. (authored by balazske, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53751/new/

https://reviews.llvm.org/D53751

Files:
  cfe/trunk/include/clang/AST/ASTImporter.h
  cfe/trunk/lib/AST/ASTImporter.cpp

Index: cfe/trunk/include/clang/AST/ASTImporter.h
===
--- cfe/trunk/include/clang/AST/ASTImporter.h
+++ cfe/trunk/include/clang/AST/ASTImporter.h
@@ -166,30 +166,41 @@
 }
 
 /// Import the given type from the "from" context into the "to"
-/// context.
+/// context. A null type is imported as a null type (no error).
 ///
-/// \returns the equivalent type in the "to" context, or a NULL type if
-/// an error occurred.
+/// \returns The equivalent type in the "to" context, or the import error.
+llvm::Expected Import_New(QualType FromT);
+// FIXME: Remove this version.
 QualType Import(QualType FromT);
 
 /// Import the given type source information from the
 /// "from" context into the "to" context.
 ///
-/// \returns the equivalent type source information in the "to"
-/// context, or NULL if an error occurred.
+/// \returns The equivalent type source information in the "to"
+/// context, or the import error.
+llvm::Expected Import_New(TypeSourceInfo *FromTSI);
+// FIXME: Remove this version.
 TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
 
 /// Import the given attribute from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent attribute in the "to" context.
+/// \returns The equivalent attribute in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(const Attr *FromAttr);
+// FIXME: Remove this version.
 Attr *Import(const Attr *FromAttr);
 
 /// Import the given declaration from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent declaration in the "to" context, or a NULL type
-/// if an error occurred.
+/// \returns The equivalent declaration in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Decl *FromD);
+llvm::Expected Import_New(const Decl *FromD) {
+  return Import_New(const_cast(FromD));
+}
+// FIXME: Remove this version.
 Decl *Import(Decl *FromD);
 Decl *Import(const Decl *FromD) {
   return Import(const_cast(FromD));
@@ -210,87 +221,117 @@
 /// Import the given expression from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent expression in the "to" context, or NULL if
-/// an error occurred.
+/// \returns The equivalent expression in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Expr *FromE);
+// FIXME: Remove this version.
 Expr *Import(Expr *FromE);
 
 /// Import the given statement from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent statement in the "to" context, or NULL if
-/// an error occurred.
+/// \returns The equivalent statement in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Stmt *FromS);
+// FIXME: Remove this version.
 Stmt *Import(Stmt *FromS);
 
 /// Import the given nested-name-specifier from the "from"
 /// context into the "to" context.
 ///
-/// \returns the equivalent nested-name-specifier in the "to"
-/// context, or NULL if an error occurred.
+/// \returns The equivalent nested-name-specifier in the "to"
+/// context, or the import error.
+llvm::Expected
+Import_New(NestedNameSpecifier *FromNNS);
+// FIXME: Remove this version.
 NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS);
 
-/// Import the given nested-name-specifier from the "from"
+/// Import the given nested-name-specifier-loc from the "from"
 /// context into the "to" context.
 ///
-/// \returns the equivalent nested-name-specifier in the "to"
-/// context.
+/// \returns The equivalent nested-name-specifier-loc in the "to"
+/// context, or the import error.
+llvm::Expected
+Import_New(NestedNameSpecifierLoc FromNNS);
+// FIXME: Remove this version.
 NestedNameSpecifierLoc Import(NestedNameSpecifierLoc FromNNS);
 
-/// Import the goven template name from the "from" context into the
-/// "to" context.
+/// Import the given template name from the "from" context into the
+/// "to" context, or the import error.
+llvm::Expected Import_New(TemplateName From);
+// FIXME: Remove this version.
 TemplateName Import(TemplateName From);
 
 /// Import the given source location from the "from" context into
 /// the 

r347685 - [ASTImporter] Added Import functions for transition to new API.

2018-11-27 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Tue Nov 27 10:36:31 2018
New Revision: 347685

URL: http://llvm.org/viewvc/llvm-project?rev=347685=rev
Log:
[ASTImporter] Added Import functions for transition to new API.

Summary:
These Import_New functions should be used in the ASTImporter,
and the old Import functions should not be used. Later the
Import_New should be renamed to Import again and the old Import
functions must be removed. But this can happen only after LLDB
was updated to use the new Import interface.

This commit is only about introducing the new Import_New
functions. These are not implemented now, only calling the old
Import ones.

Reviewers: shafik, rsmith, a_sidorin, a.sidorin

Reviewed By: a_sidorin

Subscribers: spyffe, a_sidorin, gamesh411, shafik, rsmith, dkrupp, martong, 
Szelethus, cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=347685=347684=347685=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Tue Nov 27 10:36:31 2018
@@ -166,30 +166,41 @@ class Attr;
 }
 
 /// Import the given type from the "from" context into the "to"
-/// context.
+/// context. A null type is imported as a null type (no error).
 ///
-/// \returns the equivalent type in the "to" context, or a NULL type if
-/// an error occurred.
+/// \returns The equivalent type in the "to" context, or the import error.
+llvm::Expected Import_New(QualType FromT);
+// FIXME: Remove this version.
 QualType Import(QualType FromT);
 
 /// Import the given type source information from the
 /// "from" context into the "to" context.
 ///
-/// \returns the equivalent type source information in the "to"
-/// context, or NULL if an error occurred.
+/// \returns The equivalent type source information in the "to"
+/// context, or the import error.
+llvm::Expected Import_New(TypeSourceInfo *FromTSI);
+// FIXME: Remove this version.
 TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
 
 /// Import the given attribute from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent attribute in the "to" context.
+/// \returns The equivalent attribute in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(const Attr *FromAttr);
+// FIXME: Remove this version.
 Attr *Import(const Attr *FromAttr);
 
 /// Import the given declaration from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent declaration in the "to" context, or a NULL type
-/// if an error occurred.
+/// \returns The equivalent declaration in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Decl *FromD);
+llvm::Expected Import_New(const Decl *FromD) {
+  return Import_New(const_cast(FromD));
+}
+// FIXME: Remove this version.
 Decl *Import(Decl *FromD);
 Decl *Import(const Decl *FromD) {
   return Import(const_cast(FromD));
@@ -210,87 +221,117 @@ class Attr;
 /// Import the given expression from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent expression in the "to" context, or NULL if
-/// an error occurred.
+/// \returns The equivalent expression in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Expr *FromE);
+// FIXME: Remove this version.
 Expr *Import(Expr *FromE);
 
 /// Import the given statement from the "from" context into the
 /// "to" context.
 ///
-/// \returns the equivalent statement in the "to" context, or NULL if
-/// an error occurred.
+/// \returns The equivalent statement in the "to" context, or the import
+/// error.
+llvm::Expected Import_New(Stmt *FromS);
+// FIXME: Remove this version.
 Stmt *Import(Stmt *FromS);
 
 /// Import the given nested-name-specifier from the "from"
 /// context into the "to" context.
 ///
-/// \returns the equivalent nested-name-specifier in the "to"
-/// context, or NULL if an error occurred.
+/// \returns The equivalent nested-name-specifier in the "to"
+/// context, or the import error.
+llvm::Expected
+Import_New(NestedNameSpecifier *FromNNS);
+// FIXME: Remove this version.
 NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS);
 
-/// Import the given nested-name-specifier from the "from"
+/// Import the given nested-name-specifier-loc from the "from"
 /// context into the "to" context.
 ///
-/// \returns the equivalent nested-name-specifier in the "to"
-/// context.
+/// \returns The 

[PATCH] D52879: Derive builtin return type from its definition

2018-11-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D52879#1309856 , @mantognini wrote:

> In D52879#1309734 , @riccibruno 
> wrote:
>
> > I see plenty of `TheCall->setType` left in `Sema::CheckBuiltinFunctionCall`
> >  (`Builtin::BI__builtin_classify_type`, `Builtin::BI__builtin_constant_p`,
> >  `Builtin::BI__builtin_dump_struct` and so on...).
> >
> > Is there a reason for not removing them ?
>
>
> Mainly because I was focusing on OpenCL builtins and was confident about 
> changing those, but wanted to be conservative on code that I don't test/work 
> with. If one wanted to remove those, I would encourage them to double check 
> their definitions are correct as I had to fix 
> (https://reviews.llvm.org/D52875) some for OpenCL.


Got it. Thanks for explanation. Perhaps you could leave a TODO here with a note 
including what you just said so that
we don't forget about it in the future (including the advice to double check 
the definition) ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52879/new/

https://reviews.llvm.org/D52879



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


[PATCH] D54816: [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-27 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Ping for reviews please.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54816/new/

https://reviews.llvm.org/D54816



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


[PATCH] D53751: [ASTImporter] Added Import functions for transition to new API.

2018-11-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 175529.
balazske added a comment.

- Corrected Import_New(const Attr *)
- Added missing Import_New with Selector and DeclarationName.
- Split long lines.
- Split long lines (ASTImporter.cpp).

Rebase to newest master.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53751/new/

https://reviews.llvm.org/D53751

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -7683,6 +7683,12 @@
 
 ASTImporter::~ASTImporter() = default;
 
+Expected ASTImporter::Import_New(QualType FromT) {
+  QualType ToT = Import(FromT);
+  if (ToT.isNull() && !FromT.isNull())
+return make_error();
+  return ToT;
+}
 QualType ASTImporter::Import(QualType FromT) {
   if (FromT.isNull())
 return {};
@@ -7709,6 +7715,12 @@
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
 
+Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
+  TypeSourceInfo *ToTSI = Import(FromTSI);
+  if (!ToTSI && FromTSI)
+return llvm::make_error();
+  return ToTSI;
+}
 TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
@@ -7723,8 +7735,12 @@
   T, Import(FromTSI->getTypeLoc().getBeginLoc()));
 }
 
+Expected ASTImporter::Import_New(const Attr *FromAttr) {
+  return Import(FromAttr);
+}
 Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
+  // NOTE: Import of SourceRange may fail.
   ToAttr->setRange(Import(FromAttr->getRange()));
   return ToAttr;
 }
@@ -7742,6 +7758,12 @@
   }
 }
 
+Expected ASTImporter::Import_New(Decl *FromD) {
+  Decl *ToD = Import(FromD);
+  if (!ToD && FromD)
+return llvm::make_error();
+  return ToD;
+}
 Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
@@ -7830,6 +7852,12 @@
   return ToDC;
 }
 
+Expected ASTImporter::Import_New(Expr *FromE) {
+  Expr *ToE = Import(FromE);
+  if (!ToE && FromE)
+return llvm::make_error();
+  return ToE;
+}
 Expr *ASTImporter::Import(Expr *FromE) {
   if (!FromE)
 return nullptr;
@@ -7837,6 +7865,12 @@
   return cast_or_null(Import(cast(FromE)));
 }
 
+Expected ASTImporter::Import_New(Stmt *FromS) {
+  Stmt *ToS = Import(FromS);
+  if (!ToS && FromS)
+return llvm::make_error();
+  return ToS;
+}
 Stmt *ASTImporter::Import(Stmt *FromS) {
   if (!FromS)
 return nullptr;
@@ -7872,6 +7906,13 @@
   return *ToSOrErr;
 }
 
+Expected
+ASTImporter::Import_New(NestedNameSpecifier *FromNNS) {
+  NestedNameSpecifier *ToNNS = Import(FromNNS);
+  if (!ToNNS && FromNNS)
+return llvm::make_error();
+  return ToNNS;
+}
 NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) {
   if (!FromNNS)
 return nullptr;
@@ -7925,6 +7966,11 @@
   llvm_unreachable("Invalid nested name specifier kind");
 }
 
+Expected
+ASTImporter::Import_New(NestedNameSpecifierLoc FromNNS) {
+  NestedNameSpecifierLoc ToNNS = Import(FromNNS);
+  return ToNNS;
+}
 NestedNameSpecifierLoc ASTImporter::Import(NestedNameSpecifierLoc FromNNS) {
   // Copied from NestedNameSpecifier mostly.
   SmallVector NestedNames;
@@ -7996,6 +8042,12 @@
   return Builder.getWithLocInContext(getToContext());
 }
 
+Expected ASTImporter::Import_New(TemplateName From) {
+  TemplateName To = Import(From);
+  if (To.isNull() && !From.isNull())
+return llvm::make_error();
+  return To;
+}
 TemplateName ASTImporter::Import(TemplateName From) {
   switch (From.getKind()) {
   case TemplateName::Template:
@@ -8086,6 +8138,12 @@
   llvm_unreachable("Invalid template name kind");
 }
 
+Expected ASTImporter::Import_New(SourceLocation FromLoc) {
+  SourceLocation ToLoc = Import(FromLoc);
+  if (ToLoc.isInvalid() && !FromLoc.isInvalid())
+return llvm::make_error();
+  return ToLoc;
+}
 SourceLocation ASTImporter::Import(SourceLocation FromLoc) {
   if (FromLoc.isInvalid())
 return {};
@@ -8100,10 +8158,20 @@
   return ToSM.getComposedLoc(ToFileID, Decomposed.second);
 }
 
+Expected ASTImporter::Import_New(SourceRange FromRange) {
+  SourceRange ToRange = Import(FromRange);
+  return ToRange;
+}
 SourceRange ASTImporter::Import(SourceRange FromRange) {
   return SourceRange(Import(FromRange.getBegin()), Import(FromRange.getEnd()));
 }
 
+Expected ASTImporter::Import_New(FileID FromID) {
+  FileID ToID = Import(FromID);
+  if (ToID.isInvalid() && FromID.isValid())
+return llvm::make_error();
+  return ToID;
+}
 FileID ASTImporter::Import(FileID FromID) {
   llvm::DenseMap::iterator Pos = ImportedFileIDs.find(FromID);
   if (Pos != ImportedFileIDs.end())
@@ -8161,6 +8229,13 @@
   return ToID;
 }
 
+Expected
+ASTImporter::Import_New(CXXCtorInitializer *From) {
+  CXXCtorInitializer *To = Import(From);
+  if (!To && From)
+return llvm::make_error();
+  return To;
+}
 CXXCtorInitializer 

[PATCH] D54737: [clang-tidy] Add the abseil-duration-comparison check

2018-11-27 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked 12 inline comments as done.
hwright added inline comments.



Comment at: clang-tidy/abseil/DurationComparisonCheck.cpp:25
+static llvm::Optional getScaleForInverse(llvm::StringRef Name) {
+  static const std::unordered_map ScaleMap(
+  {{"ToDoubleHours", DurationScale::Hours},

aaron.ballman wrote:
> sammccall wrote:
> > aaron.ballman wrote:
> > > sammccall wrote:
> > > > aaron.ballman wrote:
> > > > > sammccall wrote:
> > > > > > hwright wrote:
> > > > > > > JonasToth wrote:
> > > > > > > > hwright wrote:
> > > > > > > > > JonasToth wrote:
> > > > > > > > > > I think this could be made a `DenseMap` with just the right 
> > > > > > > > > > amount of dense entries. 12 elements seems not too much to 
> > > > > > > > > > me.
> > > > > > > > > > Does the key-type need to be `std::string`, or could it be 
> > > > > > > > > > `StringRef`(or `StringLiteral` making everything 
> > > > > > > > > > `constexpr` if possible)?
> > > > > > > > > > Is there some strange stuff with dangling pointers or other 
> > > > > > > > > > issues going on?
> > > > > > > > > Conceptually, this could easily be `constexpr`, but my 
> > > > > > > > > compiler doesn't seem to want to build something which is 
> > > > > > > > > called `static constexpr llvm::DenseMap > > > > > > > > DurationScale>`.  It's chief complaint is that such a type 
> > > > > > > > > has a non-trivial destructor. Am I using this correctly?
> > > > > > > > I honestly never tried to make a `constexpr DenseMap<>` but it 
> > > > > > > > makes sense it is not possible, as `DenseMap` is involved with 
> > > > > > > > dynamic memory after all, which is not possible with 
> > > > > > > > `constexpr` (yet). So you were my test-bunny ;)
> > > > > > > > 
> > > > > > > > I did reread the Data-structures section in the LLVM manual, i 
> > > > > > > > totally forgot about `StringMap` that maps strings to values.
> > > > > > > > `DenseMap` is good when mapping small values to each other, as 
> > > > > > > > we do here (`const char* -> int (whatever the enum deduces 
> > > > > > > > too)`), which would fit.
> > > > > > > > `StringMap` does allocations for the strings, which we don't 
> > > > > > > > need.
> > > > > > > > 
> > > > > > > > `constexpr` aside my bet is that `DenseMap` fits this case the 
> > > > > > > > better, because we can lay every thing out and never touch it 
> > > > > > > > again. Maybe someone else has better arguments for the decision 
> > > > > > > > :)
> > > > > > > > 
> > > > > > > > Soo: could you please try `static const 
> > > > > > > > llvm::DenseMap`? :)
> > > > > > > > (should work in theory: https://godbolt.org/z/Qo7Nv4)
> > > > > > > `static const llvm::DenseMap` 
> > > > > > > works here. :)
> > > > > > Sorry for the drive-by...
> > > > > > This has a non-trivial destructor, so violates 
> > > > > > https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
> > > > > >  at least in spirit.
> > > > > > 
> > > > > > Best to leak it (`auto  = *new const 
> > > > > > llvm::DenseMap<...>(...)`) to avoid the destructor issues. The 
> > > > > > constructor issues are already handled by making it function-local.
> > > > > I do not think this violates the coding standard -- that's talking 
> > > > > mostly about global objects, not local objects, and is concerned 
> > > > > about startup performance and initialization orders. I don't see any 
> > > > > destructor ordering issues with this, so I do not think any of that 
> > > > > applies here and leaking would be less than ideal.
> > > > There are three main issues with global objects that the coding 
> > > > standard mentions:
> > > >  - performance when unused. Not relevant to function-local statics, 
> > > > only constructed when used
> > > >  - static initialization order fiasco (constructors). Not relevant to 
> > > > function-local statics, constructed in well-defined order
> > > >  - static initialization order fiasco (destructors). Just as relevant 
> > > > to function-local statics as to any other object!
> > > > 
> > > > That's why I say it violates the rule in spirit: the destructor is 
> > > > global. https://isocpp.org/wiki/faq/ctors#construct-on-first-use-v2
> > > > 
> > > > > I don't see any destructor ordering issues with this
> > > > The reason these constructs are disallowed in coding guidelines is that 
> > > > humans can't see the problems, and they manifest in non-local ways :-(
> > > > 
> > > > > leaking would be less than ideal
> > > > Why? The current code will (usually) destroy the object when the 
> > > > program exits. This is a waste of CPU, the OS will free the memory.
> > > > The reason these constructs are disallowed in coding guidelines is that 
> > > > humans can't see the problems, and they manifest in non-local ways :-(
> > > 
> > > Can you explain why you think this would have any non-local impact on 
> > > destruction? The DenseMap is local to the function and a pointer to it 
> > > never escapes 

[PATCH] D54923: [Modules] Remove non-determinism while serializing DECL_CONTEXT_LEXICAL and DECL_RECORD

2018-11-27 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Although we can't synthesize a testcase for inclusion in the patch. Here is how 
one should attempt to reproduce the problem in macOS 10.14.

  echo '@import Foundation;' > test.m
  clang -fmodules test.m -o test.o -c \
-fmodules-cache-path=/tmp/cache \
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
  mv /tmp/cache /tmp/cache1
  
  clang -fmodules test.m -o test.o -c \
-fmodules-cache-path=/tmp/cache \
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
  mv /tmp/cache /tmp/cache2
  
  HASH=`ls /tmp/cache1`
  for i in `find /tmp/cache1 -type f -iname "*.pcm"`; do
F=`basename $i`;
diff /tmp/cache1/$HASH/$F /tmp/cache2/$HASH/$F;
  done




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54923/new/

https://reviews.llvm.org/D54923



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


[PATCH] D54792: add -march=cascadelake support in clang

2018-11-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347682: [X86] Add -march=cascadelake support in clang. 
(authored by ctopper, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54792/new/

https://reviews.llvm.org/D54792

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  test/Driver/x86-march.c
  test/Misc/target-invalid-cpu-note.c
  test/Preprocessor/predefined-arch-macros.c

Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -142,7 +142,6 @@
 setFeatureEnabledImpl(Features, "gfni", true);
 setFeatureEnabledImpl(Features, "vpclmulqdq", true);
 setFeatureEnabledImpl(Features, "avx512bitalg", true);
-setFeatureEnabledImpl(Features, "avx512vnni", true);
 setFeatureEnabledImpl(Features, "avx512vbmi2", true);
 setFeatureEnabledImpl(Features, "avx512vpopcntdq", true);
 setFeatureEnabledImpl(Features, "rdpid", true);
@@ -152,6 +151,12 @@
 setFeatureEnabledImpl(Features, "avx512vbmi", true);
 setFeatureEnabledImpl(Features, "sha", true);
 LLVM_FALLTHROUGH;
+  case CK_Cascadelake:
+//Cannonlake has no VNNI feature inside while Icelake has
+if (Kind != CK_Cannonlake)
+  // CLK inherits all SKX features plus AVX512_VNNI
+  setFeatureEnabledImpl(Features, "avx512vnni", true);
+LLVM_FALLTHROUGH;
   case CK_SkylakeServer:
 setFeatureEnabledImpl(Features, "avx512f", true);
 setFeatureEnabledImpl(Features, "avx512cd", true);
@@ -166,7 +171,9 @@
 setFeatureEnabledImpl(Features, "xsavec", true);
 setFeatureEnabledImpl(Features, "xsaves", true);
 setFeatureEnabledImpl(Features, "mpx", true);
-if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
+if (Kind != CK_SkylakeServer
+&& Kind != CK_Cascadelake)
+  // SKX/CLX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "aes", true);
@@ -949,6 +956,7 @@
   case CK_Broadwell:
   case CK_SkylakeClient:
   case CK_SkylakeServer:
+  case CK_Cascadelake:
   case CK_Cannonlake:
   case CK_IcelakeClient:
   case CK_IcelakeServer:
Index: include/clang/Basic/X86Target.def
===
--- include/clang/Basic/X86Target.def
+++ include/clang/Basic/X86Target.def
@@ -154,6 +154,10 @@
 PROC_WITH_FEAT(SkylakeServer, "skylake-avx512", PROC_64_BIT, FEATURE_AVX512F)
 PROC_ALIAS(SkylakeServer, "skx")
 
+/// \name Cascadelake Server
+/// Cascadelake Server microarchitecture based processors.
+PROC_WITH_FEAT(Cascadelake, "cascadelake", PROC_64_BIT, FEATURE_AVX512VNNI)
+
 /// \name Cannonlake Client
 /// Cannonlake client microarchitecture based processors.
 PROC_WITH_FEAT(Cannonlake, "cannonlake", PROC_64_BIT, FEATURE_AVX512VBMI)
Index: test/Driver/x86-march.c
===
--- test/Driver/x86-march.c
+++ test/Driver/x86-march.c
@@ -48,6 +48,10 @@
 // RUN:   | FileCheck %s -check-prefix=skx
 // skx: "-target-cpu" "skx"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=cascadelake 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=cascadelake
+// cascadelake: "-target-cpu" "cascadelake"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=knl 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=knl
 // knl: "-target-cpu" "knl"
Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -16,7 +16,7 @@
 // X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
 // X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
 // X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
-// X86-SAME: skx, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
+// X86-SAME: skx, cascadelake, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
 // X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
@@ -27,7 +27,7 @@
 // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
 // X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
 // X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
-// X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake,
+// X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cannonlake,
 // X86_64-SAME: 

r347682 - [X86] Add -march=cascadelake support in clang.

2018-11-27 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Nov 27 10:05:14 2018
New Revision: 347682

URL: http://llvm.org/viewvc/llvm-project?rev=347682=rev
Log:
[X86] Add -march=cascadelake support in clang.

This is skylake-avx512 with the addition of avx512vnni ISA.

Patch by Jianping Chen

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

Modified:
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Driver/x86-march.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=347682=347681=347682=diff
==
--- cfe/trunk/include/clang/Basic/X86Target.def (original)
+++ cfe/trunk/include/clang/Basic/X86Target.def Tue Nov 27 10:05:14 2018
@@ -154,6 +154,10 @@ PROC_WITH_FEAT(SkylakeClient, "skylake",
 PROC_WITH_FEAT(SkylakeServer, "skylake-avx512", PROC_64_BIT, FEATURE_AVX512F)
 PROC_ALIAS(SkylakeServer, "skx")
 
+/// \name Cascadelake Server
+/// Cascadelake Server microarchitecture based processors.
+PROC_WITH_FEAT(Cascadelake, "cascadelake", PROC_64_BIT, FEATURE_AVX512VNNI)
+
 /// \name Cannonlake Client
 /// Cannonlake client microarchitecture based processors.
 PROC_WITH_FEAT(Cannonlake, "cannonlake", PROC_64_BIT, FEATURE_AVX512VBMI)

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=347682=347681=347682=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Nov 27 10:05:14 2018
@@ -142,7 +142,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "gfni", true);
 setFeatureEnabledImpl(Features, "vpclmulqdq", true);
 setFeatureEnabledImpl(Features, "avx512bitalg", true);
-setFeatureEnabledImpl(Features, "avx512vnni", true);
 setFeatureEnabledImpl(Features, "avx512vbmi2", true);
 setFeatureEnabledImpl(Features, "avx512vpopcntdq", true);
 setFeatureEnabledImpl(Features, "rdpid", true);
@@ -152,6 +151,12 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "avx512vbmi", true);
 setFeatureEnabledImpl(Features, "sha", true);
 LLVM_FALLTHROUGH;
+  case CK_Cascadelake:
+//Cannonlake has no VNNI feature inside while Icelake has
+if (Kind != CK_Cannonlake)
+  // CLK inherits all SKX features plus AVX512_VNNI
+  setFeatureEnabledImpl(Features, "avx512vnni", true);
+LLVM_FALLTHROUGH;
   case CK_SkylakeServer:
 setFeatureEnabledImpl(Features, "avx512f", true);
 setFeatureEnabledImpl(Features, "avx512cd", true);
@@ -166,7 +171,9 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "xsavec", true);
 setFeatureEnabledImpl(Features, "xsaves", true);
 setFeatureEnabledImpl(Features, "mpx", true);
-if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
+if (Kind != CK_SkylakeServer
+&& Kind != CK_Cascadelake)
+  // SKX/CLX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "aes", true);
@@ -949,6 +956,7 @@ void X86TargetInfo::getTargetDefines(con
   case CK_Broadwell:
   case CK_SkylakeClient:
   case CK_SkylakeServer:
+  case CK_Cascadelake:
   case CK_Cannonlake:
   case CK_IcelakeClient:
   case CK_IcelakeServer:

Modified: cfe/trunk/test/Driver/x86-march.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-march.c?rev=347682=347681=347682=diff
==
--- cfe/trunk/test/Driver/x86-march.c (original)
+++ cfe/trunk/test/Driver/x86-march.c Tue Nov 27 10:05:14 2018
@@ -48,6 +48,10 @@
 // RUN:   | FileCheck %s -check-prefix=skx
 // skx: "-target-cpu" "skx"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=cascadelake 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=cascadelake
+// cascadelake: "-target-cpu" "cascadelake"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=knl 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=knl
 // knl: "-target-cpu" "knl"

Modified: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/target-invalid-cpu-note.c?rev=347682=347681=347682=diff
==
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c (original)
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c Tue Nov 27 10:05:14 2018
@@ -16,7 +16,7 @@
 // X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, 
goldmont-plus, tremont,
 // X86-SAME: nehalem, corei7, westmere, 

[PATCH] D54737: [clang-tidy] Add the abseil-duration-comparison check

2018-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/abseil/DurationComparisonCheck.cpp:25
+static llvm::Optional getScaleForInverse(llvm::StringRef Name) {
+  static const std::unordered_map ScaleMap(
+  {{"ToDoubleHours", DurationScale::Hours},

sammccall wrote:
> aaron.ballman wrote:
> > sammccall wrote:
> > > aaron.ballman wrote:
> > > > sammccall wrote:
> > > > > hwright wrote:
> > > > > > JonasToth wrote:
> > > > > > > hwright wrote:
> > > > > > > > JonasToth wrote:
> > > > > > > > > I think this could be made a `DenseMap` with just the right 
> > > > > > > > > amount of dense entries. 12 elements seems not too much to me.
> > > > > > > > > Does the key-type need to be `std::string`, or could it be 
> > > > > > > > > `StringRef`(or `StringLiteral` making everything `constexpr` 
> > > > > > > > > if possible)?
> > > > > > > > > Is there some strange stuff with dangling pointers or other 
> > > > > > > > > issues going on?
> > > > > > > > Conceptually, this could easily be `constexpr`, but my compiler 
> > > > > > > > doesn't seem to want to build something which is called `static 
> > > > > > > > constexpr llvm::DenseMap`.  
> > > > > > > > It's chief complaint is that such a type has a non-trivial 
> > > > > > > > destructor. Am I using this correctly?
> > > > > > > I honestly never tried to make a `constexpr DenseMap<>` but it 
> > > > > > > makes sense it is not possible, as `DenseMap` is involved with 
> > > > > > > dynamic memory after all, which is not possible with `constexpr` 
> > > > > > > (yet). So you were my test-bunny ;)
> > > > > > > 
> > > > > > > I did reread the Data-structures section in the LLVM manual, i 
> > > > > > > totally forgot about `StringMap` that maps strings to values.
> > > > > > > `DenseMap` is good when mapping small values to each other, as we 
> > > > > > > do here (`const char* -> int (whatever the enum deduces too)`), 
> > > > > > > which would fit.
> > > > > > > `StringMap` does allocations for the strings, which we don't need.
> > > > > > > 
> > > > > > > `constexpr` aside my bet is that `DenseMap` fits this case the 
> > > > > > > better, because we can lay every thing out and never touch it 
> > > > > > > again. Maybe someone else has better arguments for the decision :)
> > > > > > > 
> > > > > > > Soo: could you please try `static const 
> > > > > > > llvm::DenseMap`? :)
> > > > > > > (should work in theory: https://godbolt.org/z/Qo7Nv4)
> > > > > > `static const llvm::DenseMap` works 
> > > > > > here. :)
> > > > > Sorry for the drive-by...
> > > > > This has a non-trivial destructor, so violates 
> > > > > https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
> > > > >  at least in spirit.
> > > > > 
> > > > > Best to leak it (`auto  = *new const 
> > > > > llvm::DenseMap<...>(...)`) to avoid the destructor issues. The 
> > > > > constructor issues are already handled by making it function-local.
> > > > I do not think this violates the coding standard -- that's talking 
> > > > mostly about global objects, not local objects, and is concerned about 
> > > > startup performance and initialization orders. I don't see any 
> > > > destructor ordering issues with this, so I do not think any of that 
> > > > applies here and leaking would be less than ideal.
> > > There are three main issues with global objects that the coding standard 
> > > mentions:
> > >  - performance when unused. Not relevant to function-local statics, only 
> > > constructed when used
> > >  - static initialization order fiasco (constructors). Not relevant to 
> > > function-local statics, constructed in well-defined order
> > >  - static initialization order fiasco (destructors). Just as relevant to 
> > > function-local statics as to any other object!
> > > 
> > > That's why I say it violates the rule in spirit: the destructor is 
> > > global. https://isocpp.org/wiki/faq/ctors#construct-on-first-use-v2
> > > 
> > > > I don't see any destructor ordering issues with this
> > > The reason these constructs are disallowed in coding guidelines is that 
> > > humans can't see the problems, and they manifest in non-local ways :-(
> > > 
> > > > leaking would be less than ideal
> > > Why? The current code will (usually) destroy the object when the program 
> > > exits. This is a waste of CPU, the OS will free the memory.
> > > The reason these constructs are disallowed in coding guidelines is that 
> > > humans can't see the problems, and they manifest in non-local ways :-(
> > 
> > Can you explain why you think this would have any non-local impact on 
> > destruction? The DenseMap is local to the function and a pointer to it 
> > never escapes (so nothing can rely on it), and the data contained are 
> > StringRefs wrapping string literals and integer values.
> > 
> > > Why? The current code will (usually) destroy the object when the program 
> > > exits. This is a waste of CPU, the OS will free the memory.
> > 
> > Static 

[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54589/new/

https://reviews.llvm.org/D54589



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


[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D54589#1309929 , @rjmccall wrote:

> LGTM.


Thank you for the review!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54589/new/

https://reviews.llvm.org/D54589



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


[PATCH] D54195: Fix linker option for -fprofile-arcs -ftest-coverage

2018-11-27 Thread Marco Romano via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347677: Fix linker option for -fprofile-arcs -ftest-coverage 
(authored by marco, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54195/new/

https://reviews.llvm.org/D54195

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -85,6 +85,10 @@
 // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
 // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
 
+// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck 
-check-prefix=CHECK-u %s
+// RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
+// CHECK-u-NOT: "-u{{.*}}"
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -1019,7 +1019,7 @@
 
   // Add linker option -u__llvm_runtime_variable to cause runtime
   // initialization module to be linked in.
-  if (!Args.hasArg(options::OPT_coverage))
+  if ((!Args.hasArg(options::OPT_coverage)) && 
(!Args.hasArg(options::OPT_ftest_coverage)))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -85,6 +85,10 @@
 // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
 // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
 
+// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
+// RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
+// CHECK-u-NOT: "-u{{.*}}"
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -1019,7 +1019,7 @@
 
   // Add linker option -u__llvm_runtime_variable to cause runtime
   // initialization module to be linked in.
-  if (!Args.hasArg(options::OPT_coverage))
+  if ((!Args.hasArg(options::OPT_coverage)) && (!Args.hasArg(options::OPT_ftest_coverage)))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347677 - Fix linker option for -fprofile-arcs -ftest-coverage

2018-11-27 Thread Marco Castelluccio via cfe-commits
Author: marco
Date: Tue Nov 27 09:31:08 2018
New Revision: 347677

URL: http://llvm.org/viewvc/llvm-project?rev=347677=rev
Log:
Fix linker option for -fprofile-arcs -ftest-coverage

Summary:
Linux toolchain accidentally added "-u__llvm_runtime_variable" when 
"-fprofile-arcs -ftest-coverage", this is not added when "--coverage" option is 
used.
Using "-u__llvm_runtime_variable" generates an empty default.profraw file while 
an application built with  "-fprofile-arcs -ftest-coverage" is running. 

Reviewers: calixte, marco-c, sylvestre.ledru

Reviewed By: marco-c

Subscribers: vsk, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=347677=347676=347677=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Nov 27 09:31:08 2018
@@ -1019,7 +1019,7 @@ void Linux::addProfileRTLibs(const llvm:
 
   // Add linker option -u__llvm_runtime_variable to cause runtime
   // initialization module to be linked in.
-  if (!Args.hasArg(options::OPT_coverage))
+  if ((!Args.hasArg(options::OPT_coverage)) && 
(!Args.hasArg(options::OPT_ftest_coverage)))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=347677=347676=347677=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Tue Nov 27 09:31:08 2018
@@ -85,6 +85,10 @@
 // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
 // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
 
+// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck 
-check-prefix=CHECK-u %s
+// RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
+// CHECK-u-NOT: "-u{{.*}}"
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-DIR %s


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


[PATCH] D54945: This commit adds a chapter about clang-tidy integrations

2018-11-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D54945#1309467 , @JonasToth wrote:

> I like the overview, maybe a link to `clangd` here might help, as there is 
> currently a lot of effort of integrating `clang-tidy` into it. (@sammccall 
> WDYT?)


This would be great! The integration is not yet complete, so I'm not sure if 
it's best to add now or later.

For the table:

- on-the-fly inspection: yes (I think - this means showing fixes overlaid on 
the code as you edit, right?)
- check list configuration (GUI): no
- options to checks (GUI): no
- configuration via .clang-tidy file: this will be the supported mechanism. Not 
done yet.
- custom clang-tidy binary: no

The behavior today is that three hard-coded checks are always enabled, as a 
proof-of-concept. Configuration via .clang-tidy is the main missing piece.
Clang-tidy diagnostics are shown along with others, as-you-type. Fixes can be 
applied.
Static analyzer checks will probably never be supported.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54945/new/

https://reviews.llvm.org/D54945



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


r347676 - Revert "[clang] - Simplify tools::SplitDebugName."

2018-11-27 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Nov 27 09:28:38 2018
New Revision: 347676

URL: http://llvm.org/viewvc/llvm-project?rev=347676=rev
Log:
Revert "[clang] - Simplify tools::SplitDebugName."

This reverts commit r347035 as it introduced assertion failures under
certain conditions. More information can be found here:
https://reviews.llvm.org/rL347035

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=347676=347675=347676=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Nov 27 09:28:38 2018
@@ -3966,7 +3966,7 @@ void Clang::ConstructJob(Compilation ,
   const char *SplitDWARFOut;
   if (SplitDWARF) {
 CmdArgs.push_back("-split-dwarf-file");
-SplitDWARFOut = SplitDebugName(Args, Output);
+SplitDWARFOut = SplitDebugName(Args, Input, Output);
 CmdArgs.push_back(SplitDWARFOut);
   }
 
@@ -5933,7 +5933,7 @@ void ClangAs::ConstructJob(Compilation &
   if ((getDebugFissionKind(D, Args, A) == DwarfFissionKind::Split) &&
   (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
-CmdArgs.push_back(SplitDebugName(Args, Output));
+CmdArgs.push_back(SplitDebugName(Args, Input, Output));
   }
 
   assert(Input.isFilename() && "Invalid input.");

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347676=347675=347676=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Nov 27 09:28:38 2018
@@ -808,15 +808,26 @@ bool tools::areOptimizationsEnabled(cons
   return false;
 }
 
-const char *tools::SplitDebugName(const ArgList ,
+const char *tools::SplitDebugName(const ArgList , const InputInfo ,
   const InputInfo ) {
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
 if (StringRef(A->getValue()) == "single")
   return Args.MakeArgString(Output.getFilename());
 
-  SmallString<128> T(Output.getFilename());
-  llvm::sys::path::replace_extension(T, "dwo");
-  return Args.MakeArgString(T);
+  Arg *FinalOutput = Args.getLastArg(options::OPT_o);
+  if (FinalOutput && Args.hasArg(options::OPT_c)) {
+SmallString<128> T(FinalOutput->getValue());
+llvm::sys::path::replace_extension(T, "dwo");
+return Args.MakeArgString(T);
+  } else {
+// Use the compilation dir.
+SmallString<128> T(
+Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
+SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
+llvm::sys::path::replace_extension(F, "dwo");
+T += F;
+return Args.MakeArgString(F);
+  }
 }
 
 void tools::SplitDebugInfo(const ToolChain , Compilation , const Tool ,

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=347676=347675=347676=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Tue Nov 27 09:28:38 2018
@@ -63,7 +63,7 @@ void AddHIPLinkerScript(const ToolChain
 const Tool );
 
 const char *SplitDebugName(const llvm::opt::ArgList ,
-   const InputInfo );
+   const InputInfo , const InputInfo );
 
 void SplitDebugInfo(const ToolChain , Compilation , const Tool ,
 const JobAction , const llvm::opt::ArgList ,

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=347676=347675=347676=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Nov 27 09:28:38 2018
@@ -817,7 +817,7 @@ void tools::gnutools::Assembler::Constru
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
   getToolChain().getTriple().isOSLinux())
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
-   SplitDebugName(Args, Output));
+   SplitDebugName(Args, Inputs[0], Output));
 }
 
 namespace {

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=347676=347675=347676=diff

[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 175494.
lebedev.ri marked 4 inline comments as done.
lebedev.ri added a comment.

Address @rjmccall review notes.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54589/new/

https://reviews.llvm.org/D54589

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  test/CodeGen/catch-alignment-assumption-blacklist.c
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  test/CodeGen/catch-alignment-assumption-openmp.cpp

Index: test/CodeGen/catch-alignment-assumption-openmp.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-openmp.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fopenmp-simd -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 100, i32 30 }, {{.*}}* @[[CHAR]] }
+
+void func(char *data) {
+  // CHECK: define void @{{.*}}(i8* %[[DATA:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT:   %[[DATA_ADDR:.*]] = alloca i8*, align 8
+  // CHECK:   store i8* %[[DATA]], i8** %[[DATA_ADDR]], align 8
+  // CHECK:   %[[DATA_RELOADED:.*]] = load i8*, i8** %[[DATA_ADDR]], align 8
+  // CHECK-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64
+  // CHECK-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 1073741823
+  // CHECK-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
+  // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
+  // CHECK-SANITIZE:  [[CONT]]:
+  // CHECK-NEXT:call void @llvm.assume(i1 %[[MASKCOND]])
+
+#line 100
+#pragma omp for simd aligned(data : 0x4000)
+  for (int x = 0; x < 1; x++)
+data[x] = data[x];
+}
Index: test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s 

[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: docs/ReleaseNotes.rst:310
+  char **passthrough(__attribute__((align_value(1024))) char **x) {
+return x; // <- check the
+  }

unfinished



Comment at: docs/UndefinedBehaviorSanitizer.rst:198
+assume-aligned-like attributes), `object-size``, and ``vptr`` checks do not
+apply to pointers to types with the ``volatile`` qualifier
 

lebedev.ri wrote:
> lebedev.ri wrote:
> > rjmccall wrote:
> > > lebedev.ri wrote:
> > > > rjmccall wrote:
> > > > > Is there a reason for this exception?
> > > > Are you asking about the LHS of the diff, or about adding an exception 
> > > > to that for this sanitizer?
> > > > I'm adding an exception here because i don't know what should be done 
> > > > here.
> > > > Does it make sense to emit an assumptions for volatile pointers, but do 
> > > > not sanitize these assumptions?
> > > > Are you asking about the LHS of the diff, or about adding an exception 
> > > > to that for this sanitizer?
> > > 
> > > I'm asking about adding a new exception for one portion of one sanitizer.
> > > 
> > > > I'm adding an exception here because i don't know what should be done 
> > > > here.
> > > 
> > > Okay, that's not a good enough reason.
> > > 
> > > The overall rule for annotation-based language/tool designs is that 
> > > explicit/specific/close wins over implicit/general/distant.  So the 
> > > question is: how does that rule apply here?
> > > 
> > > You can't end up with a pointer to `volatile` completely implicitly — at 
> > > some point, a programmer was explicit about requesting `volatile` 
> > > semantics, and that has somehow propagated to this particular 
> > > access/assumption site.  So that's a pretty strong piece of information, 
> > > and if we have a general rule for the sanitizers that `volatile` bypasses 
> > > the check, it's generally a good idea to be consistent with that.
> > > 
> > > On the other hand, these assumption annotations are themselves always 
> > > explicit, right?  If you have to be explicit about putting `align_value` 
> > > on a specific pointer variable, and that pointer just happens to be 
> > > `volatile`-qualified, we probably *shouldn't* bypass the check: that's 
> > > about an explicit, specific, and close as a programmer can get, just 
> > > short of literally writing it on every access to the variable.  The only 
> > > counter-argument is that maybe the pointer is only `volatile`-qualified 
> > > because of template instantiation or something.
> > > 
> > > So I think it makes sense to enforce it for at least some of these 
> > > annotations and/or builtin calls, but we should be clear about *why* it 
> > > makes sense.  However, it's possible that I may be misunderstanding part 
> > > of the motivation behind the general exception for `volatile`, so you 
> > > should reach out for input from the UBSan etc. people.
> > Tried with nullability attributes https://godbolt.org/z/rJUb9U
> > They do not bypass this "ignore volatile".
> > So i guess i will drop this exception.
> Whoops, i meant `nullable` of course, showed the wrong snippet 
> https://godbolt.org/z/DbzKK0
Okay, WFM.



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:1476
 llvm::Value *PtrValue = CGF.EmitScalarExpr(E);
-CGF.EmitAlignmentAssumption(PtrValue, Alignment);
+CGF.EmitAlignmentAssumption(PtrValue, E, {/*No second loc needed*/},
+Alignment);

Same comment here about `SourceLocation()`.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2508
+// Loc - where the diagnostic will point, where in the source code this
+//  alignemnt has failed.
+// SecondaryLoc - if present (will be present if sufficiently different from

typo


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54589/new/

https://reviews.llvm.org/D54589



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


[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2018-11-27 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50078/new/

https://reviews.llvm.org/D50078



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


[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-27 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy marked 15 inline comments as done.
donat.nagy added a comment.

I will add tests for macro handling later.




Comment at: clang-tidy/bugprone/BranchCloneCheck.cpp:71
+// Check whether this `if` is part of an `else if`:
+if (const auto *IP =
+dyn_cast(Result.Nodes.getNodeAs("ifParent"))) {

JonasToth wrote:
> This if should always be true, no? The matcher will always bind `ifParent`
I moved this check to the AST matcher.



Comment at: clang-tidy/bugprone/BranchCloneCheck.cpp:116
+Branches.push_back(Else);
+// Note: We will exit the while loop here.
+  }

JonasToth wrote:
> This note is misplaced? The exit is at the `break`.
The note was placed correctly, but I replaced it with a break.



Comment at: docs/clang-tidy/checks/list.rst:13
abseil-str-cat-append
+   abseil-string-find-startswith
android-cloexec-accept

JonasToth wrote:
> spurious change
It was added automatically by the python script, which sorts this list 
alphabetically. If I remove it now, it will be automatically re-added later.



Comment at: test/clang-tidy/bugprone-branch-clone.cpp:4
+void test_basic1(int in, int ) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else 
branches [bugprone-branch-clone]

JonasToth wrote:
> could you please add tests for ternary operators?
Currently the check does not handle ternary operators, but I added some checks 
reflecting this.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54757/new/

https://reviews.llvm.org/D54757



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


[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-27 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy updated this revision to Diff 175502.
donat.nagy added a comment.

Remove braces, move if parent checking to ASTMatcher, other minor improvements


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54757/new/

https://reviews.llvm.org/D54757

Files:
  clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tidy/bugprone/BranchCloneCheck.h
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-branch-clone.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-branch-clone.cpp

Index: test/clang-tidy/bugprone-branch-clone.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-branch-clone.cpp
@@ -0,0 +1,760 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t
+
+void test_basic1(int in, int ) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic2(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+  }
+
+  out++;
+}
+
+void test_basic3(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic4(int in, int ) {
+  if (in > 77) {
+out--;
+  }
+  else {
+out++;
+  }
+}
+
+void test_basic5(int in, int ) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++;
+out++;
+  }
+}
+
+void test_basic6(int in, int ) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++, out++;
+  }
+}
+
+void test_basic7(int in, int ) {
+  if (in > 77) {
+out++;
+out++;
+  }
+  else
+out++;
+
+  out++;
+}
+
+void test_basic8(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+out++;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+out++;
+out++;
+  }
+
+  if (in % 2)
+out++;
+}
+
+void test_basic9(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+  }
+}
+
+// If we remove the braces from the previous example, the check recognizes it
+// as an `else if`.
+void test_basic10(int in, int ) {
+  if (in > 77)
+if (in % 2)
+  out++;
+else
+  out--;
+  else
+if (in % 2)
+  out++;
+else
+  out--;
+
+}
+
+void test_basic11(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  }
+}
+
+void test_basic12(int in, int ) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+  }
+}
+
+void test_basic13(int in, int ) {
+  if (in > 77) {
+// Empty compound statement is not identical to null statement.
+  } else;
+}
+
+
+void test_chain1(int in, int ) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: repeated branch in conditional chain [bugprone-branch-clone]
+out++;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: note: end of the original
+  else if (in > 55)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 1 starts here
+out++;
+
+  out++;
+}
+
+void test_chain2(int in, int ) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: repeated branch in conditional chain [bugprone-branch-clone]
+out++;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: note: end of the original
+  else if (in > 55)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 1 starts here
+out++;
+  else if (in > 42)
+out--;
+  else if (in > 28)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 2 starts here
+out++;
+  else if (in > 12) {
+out++;
+out *= 7;
+  } else if (in > 7) {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: note: clone 3 starts here
+out++;
+  }
+}
+
+void test_chain3(int in, int ) {
+  if (in > 77) {
+// 

[PATCH] D37813: clang-format: better handle namespace macros

2018-11-27 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D37813/new/

https://reviews.llvm.org/D37813



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


[PATCH] D50147: clang-format: support external styles

2018-11-27 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50147/new/

https://reviews.llvm.org/D50147



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


[PATCH] D53280: [analyzer] Emit an error for invalid -analyzer-config inputs

2018-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Overall looks good to me, some minor comments inline.




Comment at: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:231
 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
\
+  /* Create a field for each -analyzer-config option. */   
\
   TYPE NAME;

I wonder if it is a good idea to put the comment inside the macro.



Comment at: lib/Driver/ToolChains/Clang.cpp:2348
+  // Enable compatilibily mode to avoid analyzer-config related errors.
+  CmdArgs.push_back("-analyzer-config-compatibility-mode=true");
+

I wonder if it makes more sense to not add this here but rather make the 
default option to be true.



Comment at: lib/Frontend/CompilerInvocation.cpp:367
 
-  parseAnalyzerConfigs(Opts, Diags);
+  if (Opts.ShouldEmitErrorsOnInvalidConfigValue)
+parseAnalyzerConfigs(Opts, );

Do we actually need the branching here? It would be perfectly fine to always 
pass a pointer to `Diags` but sometimes just ignore it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53280/new/

https://reviews.llvm.org/D53280



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


[PATCH] D54799: [clangd] textDocument/SymbolInfo method

2018-11-27 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347674: [clangd][NFC] Move SymbolID to a separate file 
(authored by jkorous, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54799?vs=175475=175497#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54799/new/

https://reviews.llvm.org/D54799

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/index/Index.cpp
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/SymbolID.cpp
  clang-tools-extra/trunk/clangd/index/SymbolID.h

Index: clang-tools-extra/trunk/clangd/index/SymbolID.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolID.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolID.cpp
@@ -0,0 +1,58 @@
+//===--- SymbolID.cpp *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "SymbolID.h"
+#include "llvm/Support/SHA1.h"
+
+using namespace llvm;
+namespace clang {
+namespace clangd {
+
+SymbolID::SymbolID(StringRef USR) {
+  auto Hash = llvm::SHA1::hash(arrayRefFromStringRef(USR));
+  static_assert(sizeof(Hash) >= RawSize, "RawSize larger than SHA1");
+  memcpy(HashValue.data(), Hash.data(), RawSize);
+}
+
+llvm::StringRef SymbolID::raw() const {
+  return StringRef(reinterpret_cast(HashValue.data()), RawSize);
+}
+
+SymbolID SymbolID::fromRaw(StringRef Raw) {
+  SymbolID ID;
+  assert(Raw.size() == RawSize);
+  memcpy(ID.HashValue.data(), Raw.data(), RawSize);
+  return ID;
+}
+
+std::string SymbolID::str() const { return toHex(raw()); }
+
+Expected SymbolID::fromStr(StringRef Str) {
+  if (Str.size() != RawSize * 2)
+return createStringError(inconvertibleErrorCode(), "Bad ID length");
+  for (char C : Str)
+if (!isHexDigit(C))
+  return createStringError(inconvertibleErrorCode(), "Bad hex ID");
+  return fromRaw(fromHex(Str));
+}
+
+raw_ostream <<(raw_ostream , const SymbolID ) {
+  return OS << toHex(ID.raw());
+}
+
+llvm::hash_code hash_value(const SymbolID ) {
+  // We already have a good hash, just return the first bytes.
+  assert(sizeof(size_t) <= SymbolID::RawSize && "size_t longer than SHA1!");
+  size_t Result;
+  memcpy(, ID.raw().data(), sizeof(size_t));
+  return llvm::hash_code(Result);
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -11,11 +11,11 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
 
 #include "ExpectedTypes.h"
+#include "SymbolID.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -95,53 +95,6 @@
 }
 llvm::raw_ostream <<(llvm::raw_ostream &, const SymbolLocation &);
 
-// The class identifies a particular C++ symbol (class, function, method, etc).
-//
-// As USRs (Unified Symbol Resolution) could be large, especially for functions
-// with long type arguments, SymbolID is using truncated SHA1(USR) values to
-// guarantee the uniqueness of symbols while using a relatively small amount of
-// memory (vs storing USRs directly).
-//
-// SymbolID can be used as key in the symbol indexes to lookup the symbol.
-class SymbolID {
-public:
-  SymbolID() = default;
-  explicit SymbolID(llvm::StringRef USR);
-
-  bool operator==(const SymbolID ) const {
-return HashValue == Sym.HashValue;
-  }
-  bool operator<(const SymbolID ) const {
-return HashValue < Sym.HashValue;
-  }
-
-  // The stored hash is truncated to RawSize bytes.
-  // This trades off memory against the number of symbols we can handle.
-  constexpr static size_t RawSize = 8;
-  llvm::StringRef raw() const {
-return StringRef(reinterpret_cast(HashValue.data()), RawSize);
-  }
-  static SymbolID fromRaw(llvm::StringRef);
-
-  // Returns a hex encoded string.
-  std::string str() const;
-  static llvm::Expected fromStr(llvm::StringRef);
-
-private:
-  std::array HashValue;
-};
-
-inline llvm::hash_code hash_value(const SymbolID ) {
-  // We already have a good hash, just return the first bytes.
-  assert(sizeof(size_t) <= SymbolID::RawSize && "size_t longer than SHA1!");
-  size_t Result;
-  memcpy(, ID.raw().data(), sizeof(size_t));
-  return llvm::hash_code(Result);
-}
-
-// Write SymbolID into the given stream. 

[PATCH] D52879: Derive builtin return type from its definition

2018-11-27 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

In D52879#1309734 , @riccibruno wrote:

> I see plenty of `TheCall->setType` left in `Sema::CheckBuiltinFunctionCall`
>  (`Builtin::BI__builtin_classify_type`, `Builtin::BI__builtin_constant_p`,
>  `Builtin::BI__builtin_dump_struct` and so on...).
>
> Is there a reason for not removing them ?


Mainly because I was focusing on OpenCL builtins and was confident about 
changing those, but wanted to be conservative on code that I don't test/work 
with. If one wanted to remove those, I would encourage them to double check 
their definitions are correct as I had to fix (https://reviews.llvm.org/D52875) 
some for OpenCL.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52879/new/

https://reviews.llvm.org/D52879



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


[clang-tools-extra] r347675 - [clangd] textDocument/SymbolInfo extension

2018-11-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Nov 27 08:40:46 2018
New Revision: 347675

URL: http://llvm.org/viewvc/llvm-project?rev=347675=rev
Log:
[clangd] textDocument/SymbolInfo extension

New method returning symbol info for given source position.

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

rdar://problem/46050281

Added:
clang-tools-extra/trunk/test/clangd/symbol-info.test
clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/XRefs.h
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=347675=347674=347675=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Nov 27 08:40:46 2018
@@ -698,6 +698,12 @@ void ClangdLSPServer::onReference(const
  std::move(Reply));
 }
 
+void ClangdLSPServer::onSymbolInfo(const TextDocumentPositionParams ,
+   Callback> Reply) 
{
+  Server->symbolInfo(Params.textDocument.uri.file(), Params.position,
+ std::move(Reply));
+}
+
 ClangdLSPServer::ClangdLSPServer(class Transport ,
  const clangd::CodeCompleteOptions ,
  Optional CompileCommandsDir,
@@ -733,6 +739,7 @@ ClangdLSPServer::ClangdLSPServer(class T
   MsgHandler->bind("textDocument/didChange", 
::onDocumentDidChange);
   MsgHandler->bind("workspace/didChangeWatchedFiles", 
::onFileEvent);
   MsgHandler->bind("workspace/didChangeConfiguration", 
::onChangeConfiguration);
+  MsgHandler->bind("textDocument/symbolInfo", ::onSymbolInfo);
   // clang-format on
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=347675=347674=347675=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Nov 27 08:40:46 2018
@@ -92,6 +92,8 @@ private:
   void onHover(const TextDocumentPositionParams &,
Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
+  void onSymbolInfo(const TextDocumentPositionParams &,
+Callback>);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic );
 

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=347675=347674=347675=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Nov 27 08:40:46 2018
@@ -503,6 +503,18 @@ void ClangdServer::findReferences(PathRe
   WorkScheduler.runWithAST("References", File, Bind(Action, std::move(CB)));
 }
 
+void ClangdServer::symbolInfo(PathRef File, Position Pos,
+  Callback> CB) {
+  auto Action = [Pos](Callback> CB,
+  Expected InpAST) {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::getSymbolInfo(InpAST->AST, Pos));
+  };
+
+  WorkScheduler.runWithAST("SymbolInfo", File, Bind(Action, std::move(CB)));
+}
+
 std::vector>
 ClangdServer::getUsedBytesPerFile() const {
   return WorkScheduler.getUsedBytesPerFile();

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=347675=347674=347675=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Tue Nov 27 08:40:46 2018
@@ -202,6 +202,11 @@ public:
   /// Called when an event occurs for a watched file in the workspace.
   void onFileEvent(const DidChangeWatchedFilesParams );
 
+  /// Get symbol info for given position.
+  /// Clangd extension - not part of official LSP.
+  void symbolInfo(PathRef File, Position Pos,
+  Callback> CB);
+
   /// Returns estimated memory usage for each of the currently open files.
   /// The order of results is unspecified.
   /// Overall memory usage of clangd may be significantly more than reported

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 

[clang-tools-extra] r347674 - [clangd][NFC] Move SymbolID to a separate file

2018-11-27 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Nov 27 08:40:34 2018
New Revision: 347674

URL: http://llvm.org/viewvc/llvm-project?rev=347674=rev
Log:
[clangd][NFC] Move SymbolID to a separate file

Prerequisity for textDocument/SymbolInfo

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

Added:
clang-tools-extra/trunk/clangd/index/SymbolID.cpp
clang-tools-extra/trunk/clangd/index/SymbolID.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=347674=347673=347674=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Nov 27 08:40:34 2018
@@ -46,6 +46,7 @@ add_clang_library(clangDaemon
   index/IndexAction.cpp
   index/MemIndex.cpp
   index/Merge.cpp
+  index/SymbolID.cpp
   index/Serialization.cpp
   index/SymbolCollector.cpp
   index/YAMLSerialization.cpp

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=347674=347673=347674=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Tue Nov 27 08:40:34 2018
@@ -25,6 +25,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROTOCOL_H
 
 #include "URI.h"
+#include "index/SymbolID.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/JSON.h"
 #include 

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=347674=347673=347674=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Tue Nov 27 08:40:34 2018
@@ -12,7 +12,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/SHA1.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -43,34 +42,6 @@ raw_ostream <<(raw_ostream ,
 << "-" << L.End.line() << ":" << L.End.column() << ")";
 }
 
-SymbolID::SymbolID(StringRef USR) {
-  auto Hash = SHA1::hash(arrayRefFromStringRef(USR));
-  static_assert(sizeof(Hash) >= RawSize, "RawSize larger than SHA1");
-  memcpy(HashValue.data(), Hash.data(), RawSize);
-}
-
-raw_ostream <<(raw_ostream , const SymbolID ) {
-  return OS << toHex(ID.raw());
-}
-
-SymbolID SymbolID::fromRaw(StringRef Raw) {
-  SymbolID ID;
-  assert(Raw.size() == RawSize);
-  memcpy(ID.HashValue.data(), Raw.data(), RawSize);
-  return ID;
-}
-
-std::string SymbolID::str() const { return toHex(raw()); }
-
-Expected SymbolID::fromStr(StringRef Str) {
-  if (Str.size() != RawSize * 2)
-return createStringError(inconvertibleErrorCode(), "Bad ID length");
-  for (char C : Str)
-if (!isHexDigit(C))
-  return createStringError(inconvertibleErrorCode(), "Bad hex ID");
-  return fromRaw(fromHex(Str));
-}
-
 raw_ostream <<(raw_ostream , SymbolOrigin O) {
   if (O == SymbolOrigin::Unknown)
 return OS << "unknown";

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=347674=347673=347674=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Tue Nov 27 08:40:34 2018
@@ -11,11 +11,11 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
 
 #include "ExpectedTypes.h"
+#include "SymbolID.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -95,53 +95,6 @@ inline bool operator<(const SymbolLocati
 }
 llvm::raw_ostream <<(llvm::raw_ostream &, const SymbolLocation &);
 
-// The class identifies a particular C++ symbol (class, function, method, etc).
-//
-// As USRs (Unified Symbol Resolution) could be large, especially for functions
-// with long type arguments, SymbolID is using truncated SHA1(USR) values to
-// guarantee the uniqueness of symbols while using a relatively small amount of
-// memory (vs storing USRs directly).
-//
-// SymbolID can be used as key in the symbol indexes to lookup the symbol.
-class SymbolID {
-public:
-  SymbolID() = default;
-  explicit SymbolID(llvm::StringRef USR);
-
-  bool operator==(const SymbolID ) const {
-return HashValue == 

[PATCH] D53708: [ASTImporter] Add importer specific lookup

2018-11-27 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 175495.
martong marked 5 inline comments as done.
martong added a comment.

- Address Alexei's comments


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53708/new/

https://reviews.llvm.org/D53708

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/ASTImporterLookupTable.h
  include/clang/CrossTU/CrossTranslationUnit.h
  lib/AST/ASTImporter.cpp
  lib/AST/ASTImporterLookupTable.cpp
  lib/AST/CMakeLists.txt
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/ASTMerge.cpp
  tools/clang-import-test/clang-import-test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -14,6 +14,7 @@
 #include "MatchVerifier.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
+#include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
@@ -307,24 +308,27 @@
   Unit->enableSourceFileDiagnostics();
 }
 
-void lazyInitImporter(ASTUnit *ToAST) {
+void lazyInitImporter(ASTImporterLookupTable , ASTUnit *ToAST) {
   assert(ToAST);
   if (!Importer) {
-Importer.reset(new ASTImporter(
-ToAST->getASTContext(), ToAST->getFileManager(),
-Unit->getASTContext(), Unit->getFileManager(), false));
+Importer.reset(
+new ASTImporter(ToAST->getASTContext(), ToAST->getFileManager(),
+Unit->getASTContext(), Unit->getFileManager(),
+false, ));
   }
   assert(>getASTContext() == >getToContext());
   createVirtualFileIfNeeded(ToAST, FileName, Code);
 }
 
-Decl *import(ASTUnit *ToAST, Decl *FromDecl) {
-  lazyInitImporter(ToAST);
+Decl *import(ASTImporterLookupTable , ASTUnit *ToAST,
+ Decl *FromDecl) {
+  lazyInitImporter(LookupTable, ToAST);
   return Importer->Import(FromDecl);
- }
+}
 
-QualType import(ASTUnit *ToAST, QualType FromType) {
-  lazyInitImporter(ToAST);
+QualType import(ASTImporterLookupTable , ASTUnit *ToAST,
+QualType FromType) {
+  lazyInitImporter(LookupTable, ToAST);
   return Importer->Import(FromType);
 }
   };
@@ -338,13 +342,23 @@
   // vector is expanding, with the list we won't have these issues.
   std::list FromTUs;
 
-  void lazyInitToAST(Language ToLang) {
+  // Initialize the lookup table if not initialized already.
+  void lazyInitLookupTable(TranslationUnitDecl *ToTU) {
+assert(ToTU);
+if (!LookupTablePtr)
+  LookupTablePtr = llvm::make_unique(*ToTU);
+  }
+
+  void lazyInitToAST(Language ToLang, StringRef ToSrcCode, StringRef FileName) {
 if (ToAST)
   return;
 ArgVector ToArgs = getArgVectorForLanguage(ToLang);
+// Source code must be a valid live buffer through the tests lifetime.
+ToCode = ToSrcCode;
 // Build the AST from an empty file.
-ToAST = tooling::buildASTFromCodeWithArgs(/*Code=*/"", ToArgs, "empty.cc");
+ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, FileName);
 ToAST->enableSourceFileDiagnostics();
+lazyInitLookupTable(ToAST->getASTContext().getTranslationUnitDecl());
   }
 
   TU *findFromTU(Decl *From) {
@@ -358,6 +372,10 @@
 return &*It;
   }
 
+protected:
+
+  std::unique_ptr LookupTablePtr;
+
 public:
   // We may have several From context but only one To context.
   std::unique_ptr ToAST;
@@ -374,26 +392,23 @@
 FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs);
 TU  = FromTUs.back();
 
-ToCode = ToSrcCode;
 assert(!ToAST);
-ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
-ToAST->enableSourceFileDiagnostics();
+lazyInitToAST(ToLang, ToSrcCode, OutputFileName);
 
 ASTContext  = FromTU.Unit->getASTContext();
 
-createVirtualFileIfNeeded(ToAST.get(), InputFileName, FromTU.Code);
-
 IdentifierInfo *ImportedII = (Identifier);
 assert(ImportedII && "Declaration with the given identifier "
  "should be specified in test!");
 DeclarationName ImportDeclName(ImportedII);
-SmallVector FoundDecls;
+SmallVector FoundDecls;
 FromCtx.getTranslationUnitDecl()->localUncachedLookup(ImportDeclName,
   FoundDecls);
 
 assert(FoundDecls.size() == 1);
 
-Decl *Imported = FromTU.import(ToAST.get(), FoundDecls.front());
+Decl *Imported =
+FromTU.import(*LookupTablePtr, ToAST.get(), FoundDecls.front());
 
 assert(Imported);
 return std::make_tuple(*FoundDecls.begin(), Imported);
@@ -419,11 +434,8 @@
   // Creates the To context with the given source code and returns the TU decl.
   TranslationUnitDecl *getToTuDecl(StringRef ToSrcCode, 

[PATCH] D53708: [ASTImporter] Add importer specific lookup

2018-11-27 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 18 inline comments as done.
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:7605
+
+ASTImporter::ASTImporter(ASTImporterLookupTable *LookupTable,
+ ASTContext , FileManager ,

a_sidorin wrote:
> It's better to make `LookupTable` an optional parameter of the previous ctor 
> and remove this one.
Okay, I have changed it to be a default initalized to nullptr parameter.



Comment at: lib/AST/ASTImporterLookupTable.cpp:84
+  DeclContext *DC = ND->getDeclContext()->getPrimaryContext();
+  remove(DC, ND);
+  DeclContext *ReDC = DC->getRedeclContext()->getPrimaryContext();

a_sidorin wrote:
> Should we remove DC-related entry if it is empty after deletion?
I don't think so.
The only place where we are going to use `remove` is in case we had an error 
during import (upcoming patch). Even if we had an error before, subsequent 
successfully imported Decls could be part of the same DC (so, chances are we 
would superfluously do a ping-pong of delete/create).



Comment at: unittests/AST/ASTImporterTest.cpp:3845
+  ASTImporterLookupTable LT(*ToTU);
+}
+

a_sidorin wrote:
> Could you please explain what does this test do?
Well, it makes sure that we can build a lookup table for an empty file without 
any *assertion*. We may have an assertion in the ctor during traversing the 
AST. I consider this the most basic use case as it tests only the constructor.
However, if you find it weird I can remove it.



Comment at: unittests/AST/ASTImporterTest.cpp:3889
+if (ND->getDeclName() == Name)
+  Found = ND;
+}

a_sidorin wrote:
> Do we need break/early return here?
Yes, that's better to have.



Comment at: unittests/AST/ASTImporterTest.cpp:3930
+
+  auto FindInDeclListOfDC = [](DeclContext *DC, DeclarationName Name) {
+Decl *Found = nullptr;

a_sidorin wrote:
> This lambda is the same as in previous func so it's better to extract it into 
> a helper.
Good catch, thanks.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53708/new/

https://reviews.llvm.org/D53708



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


[PATCH] D54737: [clang-tidy] Add the abseil-duration-comparison check

2018-11-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationRewriter.h:62
+
+AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher,
+ DurationConversionFunction) {

JonasToth wrote:
> I think you can even make this an `AST_MATCHER(FunctionDecl, 
> durationConversionFunction) { ... }`, or was there an issue with it? (`git 
> grep -n AST_MATCHER` in clang-tidy for other examples)
> With this, the wrapping with `functionDecl()` should not be necessary.
Nevermind, that was wrong. That would do 
`functionDecl(durationConversionFunction())`, sorry for noise.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54737/new/

https://reviews.llvm.org/D54737



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


[PATCH] D54737: [clang-tidy] Add the abseil-duration-comparison check

2018-11-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationRewriter.h:62
+
+AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher,
+ DurationConversionFunction) {

I think you can even make this an `AST_MATCHER(FunctionDecl, 
durationConversionFunction) { ... }`, or was there an issue with it? (`git grep 
-n AST_MATCHER` in clang-tidy for other examples)
With this, the wrapping with `functionDecl()` should not be necessary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54737/new/

https://reviews.llvm.org/D54737



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


[PATCH] D54941: [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion

2018-11-27 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347671: [clang-tidy] Ignore bool - single bit bitfield 
conversion in readability… (authored by malcolm.parsons, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54941/new/

https://reviews.llvm.org/D54941

Files:
  clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
  
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -306,6 +306,11 @@
   auto boolOpAssignment =
   binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")),
  hasLHS(expr(hasType(booleanType();
+  auto bitfieldAssignment = binaryOperator(
+  hasLHS(memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1));
+  auto bitfieldConstruct = cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
+  withInitializer(equalsBoundNode("implicitCastFromBool")),
+  forField(hasBitWidth(1);
   Finder->addMatcher(
   implicitCastExpr(
   implicitCastFromBool,
@@ -313,14 +318,15 @@
   // in such context:
   //   bool_expr_a == bool_expr_b
   //   bool_expr_a != bool_expr_b
-  unless(hasParent(binaryOperator(
-  anyOf(boolComparison, boolXor, boolOpAssignment,
+  unless(hasParent(binaryOperator(anyOf(
+  boolComparison, boolXor, boolOpAssignment, 
bitfieldAssignment,
+  implicitCastExpr().bind("implicitCastFromBool"),
+  unless(hasParent(bitfieldConstruct)),
   // Check also for nested casts, for example: bool -> int -> float.
   anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
 anything()),
   unless(isInTemplateInstantiation()),
-  unless(hasAncestor(functionTemplateDecl(
-  .bind("implicitCastFromBool"),
+  unless(hasAncestor(functionTemplateDecl(,
   this);
 }
 
Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
@@ -74,7 +74,8 @@
 
 - pointer/pointer to member/``nullptr``/``NULL`` to boolean,
 
-- boolean expression/literal to integer,
+- boolean expression/literal to integer (conversion from boolean to a single
+  bit bitfield is explicitly allowed),
 
 - boolean expression/literal to floating.
 
Index: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
@@ -444,14 +444,27 @@
   int a;
   int b : 1;
   int c : 2;
+
+  S(bool a, bool b, bool c) : a(a), b(b), c(c) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit conversion bool -> 
'int'
+  // CHECK-MESSAGES: :[[@LINE-2]]:45: warning: implicit conversion bool -> 
'int'
+  // CHECK-FIXES: S(bool a, bool b, bool c) : a(static_cast(a)), b(b), 
c(static_cast(c)) {}
 };
 
-bool f(const S& s) {
+bool f(S& s) {
   functionTaking(s.a);
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion 'int' -> 
bool
   // CHECK-FIXES: functionTaking(s.a != 0);
   functionTaking(s.b);
   // CHECK-FIXES: functionTaking(s.b);
+  s.a = true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicit conversion bool -> 'int'
+  // CHECK-FIXES: s.a = 1;
+  s.b = true;
+  // CHECK-FIXES: s.b = true;
+  s.c = true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicit conversion bool -> 'int'
+  // CHECK-FIXES: s.c = 1;
   functionTaking(s.c);
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion 'int' -> 
bool
   // CHECK-FIXES: functionTaking(s.c != 0);


Index: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -306,6 +306,11 @@
   auto boolOpAssignment =
   binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")),
  hasLHS(expr(hasType(booleanType();
+  auto 

[PATCH] D53329: Generate DIFile with main program if source is not available

2018-11-27 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

See https://reviews.llvm.org/D54953 for the Verifier work.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53329/new/

https://reviews.llvm.org/D53329



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


[clang-tools-extra] r347671 - [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion

2018-11-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Nov 27 08:23:39 2018
New Revision: 347671

URL: http://llvm.org/viewvc/llvm-project?rev=347671=rev
Log:
[clang-tidy] Ignore bool -> single bit bitfield conversion in 
readability-implicit-bool-conversion

Summary: There is no ambiguity / information loss in this conversion

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

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

Modified:

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

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
Tue Nov 27 08:23:39 2018
@@ -306,6 +306,11 @@ void ImplicitBoolConversionCheck::regist
   auto boolOpAssignment =
   binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")),
  hasLHS(expr(hasType(booleanType();
+  auto bitfieldAssignment = binaryOperator(
+  hasLHS(memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1));
+  auto bitfieldConstruct = cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
+  withInitializer(equalsBoundNode("implicitCastFromBool")),
+  forField(hasBitWidth(1);
   Finder->addMatcher(
   implicitCastExpr(
   implicitCastFromBool,
@@ -313,14 +318,15 @@ void ImplicitBoolConversionCheck::regist
   // in such context:
   //   bool_expr_a == bool_expr_b
   //   bool_expr_a != bool_expr_b
-  unless(hasParent(binaryOperator(
-  anyOf(boolComparison, boolXor, boolOpAssignment,
+  unless(hasParent(binaryOperator(anyOf(
+  boolComparison, boolXor, boolOpAssignment, 
bitfieldAssignment,
+  implicitCastExpr().bind("implicitCastFromBool"),
+  unless(hasParent(bitfieldConstruct)),
   // Check also for nested casts, for example: bool -> int -> float.
   anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
 anything()),
   unless(isInTemplateInstantiation()),
-  unless(hasAncestor(functionTemplateDecl(
-  .bind("implicitCastFromBool"),
+  unless(hasAncestor(functionTemplateDecl(,
   this);
 }
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
 Tue Nov 27 08:23:39 2018
@@ -74,7 +74,8 @@ In general, the following conversion typ
 
 - pointer/pointer to member/``nullptr``/``NULL`` to boolean,
 
-- boolean expression/literal to integer,
+- boolean expression/literal to integer (conversion from boolean to a single
+  bit bitfield is explicitly allowed),
 
 - boolean expression/literal to floating.
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
 Tue Nov 27 08:23:39 2018
@@ -444,14 +444,27 @@ struct S {
   int a;
   int b : 1;
   int c : 2;
+
+  S(bool a, bool b, bool c) : a(a), b(b), c(c) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit conversion bool -> 
'int'
+  // CHECK-MESSAGES: :[[@LINE-2]]:45: warning: implicit conversion bool -> 
'int'
+  // CHECK-FIXES: S(bool a, bool b, bool c) : a(static_cast(a)), b(b), 
c(static_cast(c)) {}
 };
 
-bool f(const S& s) {
+bool f(S& s) {
   functionTaking(s.a);
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion 'int' -> 
bool
   // CHECK-FIXES: functionTaking(s.a != 0);
   functionTaking(s.b);
   // CHECK-FIXES: functionTaking(s.b);
+  s.a = true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicit conversion bool -> 'int'
+  // CHECK-FIXES: 

[PATCH] D54737: [clang-tidy] Add the abseil-duration-comparison check

2018-11-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/abseil/DurationComparisonCheck.cpp:50
+  static const std::unordered_map>
+  InverseMap(

hwright wrote:
> hwright wrote:
> > JonasToth wrote:
> > > This variable is a little hard to read. Could you make a little 
> > > wrapper-struct instead of the `tuple` to make clear which element 
> > > represents what?
> > > Otherwise, why not `std::pair`?
> > > 
> > > - same `DenseMap` argument
> > > - same `StringRef`/`StringLiteral` instead `string` consideration
> > `std::pair` works here.
> > 
> > I'll defer the `DenseMap` and `StringRef`/`StringLiteral` changes until we 
> > determine if they are actually possible.
> ...but using `DenseMap` here doesn't work.  From the mountains of compiler 
> output I get when I try, it appears that `DenseMap` adds some constraints on 
> the key type, and an `enum class` doesn't meet those constraints.
> 
> fwiw, the errors are mostly of this form:
> ```
> /llvm/llvm/include/llvm/ADT/DenseMap.h:1277:45: error: ‘getEmptyKey’ is not a 
> member of ‘llvm::DenseMapInfo’
>  const KeyT Empty = KeyInfoT::getEmptyKey();
> ~^~
> /llvm/llvm/include/llvm/ADT/DenseMap.h:1278:53: error: ‘getTombstoneKey’ is 
> not a member of ‘llvm::DenseMapInfo’
>  const KeyT Tombstone = KeyInfoT::getTombstoneKey();
> ~^~
> /llvm/llvm/include/llvm/ADT/DenseMap.h:1280:44: error: ‘isEqual’ is not a 
> member of ‘llvm::DenseMapInfo’
>  while (Ptr != End && (KeyInfoT::isEqual(Ptr[-1].getFirst(), Empty) ||
>~^~~
> /llvm/llvm/include/llvm/ADT/DenseMap.h:1281:44: error: ‘isEqual’ is not a 
> member of ‘llvm::DenseMapInfo’
>KeyInfoT::isEqual(Ptr[-1].getFirst(), Tombstone)))
> ```
in order to use `DenseMap` you need to specialize the `DenseMapInfo` for types, 
that are not supported yet. More in the llvm manual and by examples.
Storing the integer is no issue, but the `enum class` makes its a type on its 
own, same with the pair.

I believe its fine to leave it an `unordered_map`, even though it might be 
slower on access. You can certainly do the extra-mile.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54737/new/

https://reviews.llvm.org/D54737



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


[PATCH] D54941: [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion

2018-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
docs/clang-tidy/checks/readability-implicit-bool-conversion.rst:77-78
 
-- boolean expression/literal to integer,
+- boolean expression/literal to integer (conversion from boolean to a single
+  bit bitfield is explicitly allowed),
 

alexfh wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > I think it should only be allowed if the bit-field type is unsigned; 
> > > signed bit-fields with a single bit are inherently not portable because 
> > > you don't know if that bit represents a sign bit or a value bit (imagine 
> > > a sign and magnitude integer representation).
> > > 
> > > C++20 is changing this by standardizing on two's complement, but earlier 
> > > versions of C++ (and currently, all versions of C) are still impacted, so 
> > > another approach is to gate this on the language standard mode that's in 
> > > effect.
> > I think it's the responsibility of a compiler using sign and magnitude 
> > representation to warn about signed single bit bitfields.
> I agree with Malcolm's argument. But if the concern is practical (i.e. if 
> there's a user of this check, who's working with such compiler), we can add 
> an option to enable the warning in this case. Any objections?
I think LLVM only supports two's complement backends currently anyway, so this 
is probably fine as-is. It was more a reaction to "there is no information 
loss" because there is information loss with the integer value, even in two's 
complement. It seems like clang is missing a warning that could handle this, 
however. https://godbolt.org/z/34xXIQ

Boolean assignments are a bit of a different beast in that the `bool` is 
converted to integer as either `0` or `1`, explicitly. It's a bit strange that 
you put in `true` (which would be converted to `1`) and get back out `-1` as 
the integer value, but it's not awful because of the usual "0 is false, nonzero 
is true" conversion behavior back to `bool`.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54941/new/

https://reviews.llvm.org/D54941



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


[PATCH] D54952: [clangd] DO NOT SUBMIT. Draft interfaces for build system integration.

2018-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: klimek, sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

A proposal for the interface of the new build system integration.
Similar to CompilationDatabase, but will provide more functionality and live
in clangd instead of tooling until stabilized.

Main points of interest are:

- clangd::Integration is a user-facing API, it handles loading the proper build 
system integrations from the directory structure and notifying the clients 
about all changes. It implements clang::GlobalCompilationDatabase and is used 
by all of clangd to get compile commands, etc.

- clangd::BuildSystem interface is for build system implementations. It handles 
interactions with a single build system (initially only 
'compile_commands.json', but we also plan to experiment with adding direct 
CMake or ninja support).

- The clangd::GlobalCompilationDatabase now also provides a VFS instance 
alongside the compile command. The idea is to allow build systems to overlay 
generated files, if they can need (this is Bazel-specific AFAIK). It is also 
the responsibility of the buildsystem to update any dependencies (e.g. the 
generated files) it knows about before providing the compile commands.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54952

Files:
  clangd/BuildSystem.h
  clangd/BuildSystemPlugin.h
  clangd/FSProvider.h
  clangd/FSWatch.h
  clangd/GlobalCompilationDatabase.h

Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -10,8 +10,10 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
 
+#include "FSProvider.h"
 #include "Function.h"
 #include "Path.h"
+#include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringMap.h"
 #include 
 #include 
@@ -34,15 +36,30 @@
   std::string SourceRoot;
 };
 
+/// Full information required to run clang frontend on the file.
+struct CompileInputs {
+  /// Command used to build the AST.
+  tooling::CompileCommand Command;
+  /// An instance of VFS that should be used for compilations. Must have proper
+  /// working directory set in advance, can contain overlays that include the
+  /// generated files.
+  IntrusiveRefCntPtr FS;
+  /// Information about the project that the file belongs to.
+  llvm::Optional Project;
+};
+
+using CommandChanged = Event>;
+
 /// Provides compilation arguments used for parsing C and C++ files.
 class GlobalCompilationDatabase {
 public:
   virtual ~GlobalCompilationDatabase() = default;
 
+  virtual FileSystemProvider () const = 0;
+
   /// If there are any known-good commands for building this file, returns one.
-  /// If the ProjectInfo pointer is set, it will also be populated.
-  virtual llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const = 0;
+  virtual llvm::Optional
+  getCompileCommand(PathRef File) const = 0;
 
   /// Makes a guess at how to build a file.
   /// The default implementation just runs clang on the file.
@@ -52,12 +69,7 @@
   using CommandChanged = Event>;
   /// The callback is notified when files may have new compile commands.
   /// The argument is a list of full file paths.
-  CommandChanged::Subscription watch(CommandChanged::Listener L) const {
-return OnCommandChanged.observe(std::move(L));
-  }
-
-protected:
-  mutable CommandChanged OnCommandChanged;
+  virtual CommandChanged::Subscription watch(CommandChanged::Listener L) const;
 };
 
 /// Gets compile args from tooling::CompilationDatabases built for parent
Index: clangd/FSWatch.h
===
--- /dev/null
+++ clangd/FSWatch.h
@@ -0,0 +1,48 @@
+//===--- FSWatch.h *-C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_WATCH_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_WATCH_H
+
+#include "Function.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+enum class FSEventKind { Added, Modified, Removed };
+
+/// An event that fires when the file has changed.
+using FileChangedEvent = Event;
+
+/// An interface to allow watching for changes in the filesystem.
+class FileSystemWatcher {
+public:
+  virtual ~FileSystemWatcher() = default;
+
+  /// Add a watch for a single file or directory.
+  virtual FileChangedEvent::Subscription
+  watchFile(llvm::StringRef Path, FileChangedEvent::Listener L) = 0;
+};
+
+/// Polls the 

[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-11-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:4035
+  V = Builder.CreatePointerBitCastOrAddrSpaceCast(V, DestTy);
+}
 

mikael wrote:
> rjmccall wrote:
> > Always use the `performAddrSpaceConversion` target hook if there's a 
> > semantic address-space conversion required.  But really, this doesn't seem 
> > like the right place to be doing this; it ought to happen higher up when 
> > we're adding the `this` argument to the call, either explicitly in IRGen or 
> > implicitly by expecting the object expression to already yield a value in 
> > the right address space.
> > 
> > I could definitely believe that we don't currently create `CastExpr`s for 
> > simple qualification conversions of the object argument of a C++ method 
> > call, since (ignoring these address-space conversions) they're always 
> > trivial.
> Thanks for the input! It seems like the name `performAddrSpaceConversion` 
> does not exist in the code-base though.
Sorry, `performAddrSpaceCast`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54862/new/

https://reviews.llvm.org/D54862



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


[libclc] r347668 - travis: Add cmake build

2018-11-27 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Nov 27 08:07:21 2018
New Revision: 347668

URL: http://llvm.org/viewvc/llvm-project?rev=347668=rev
Log:
travis: Add cmake build

Reviewer: Aaron Watry

Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=347668=347667=347668=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Tue Nov 27 08:07:21 2018
@@ -93,12 +93,100 @@ matrix:
 # From sources above
 - llvm-7-dev
 - clang-7
+- env:
+- LABEL="cmake gcc LLVM-3.9"
+- LLVM_VERSION=3.9
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-3.9
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-3.9-dev
+- clang-3.9
+- env:
+- LABEL="cmake gcc LLVM-4.0"
+- LLVM_VERSION=4.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-4.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-4.0-dev
+- clang-4.0
+- env:
+- LABEL="cmake gcc LLVM-5.0"
+- LLVM_VERSION=5.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-5.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-5.0-dev
+- clang-5.0
+- env:
+- LABEL="cmake gcc LLVM-6.0"
+- LLVM_VERSION=6.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+# llvm passes -Werror=date-time which is only supported in gcc-4.9+
+- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-6.0
+- ubuntu-toolchain-r-test
+  packages:
+- libedit-dev
+# LLVM-6 needs libstdc++4.9
+- g++-4.9
+# From sources above
+- llvm-6.0-dev
+- clang-6.0
+- env:
+- LABEL="cmake gcc LLVM-7"
+- LLVM_VERSION=7
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc 
tahiti-amdgcn-mesa-mesa3d.bc nvptx--nvidiacl.bc nvptx64--nvidiacl.bc"
+# llvm passes -Werror=date-time which is only supported in gcc-4.9+
+- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
+  addons:
+apt:
+  sources:
+- sourceline: 'deb http://apt.llvm.org/trusty/ 
llvm-toolchain-trusty-7 main'
+  key_url: https://apt.llvm.org/llvm-snapshot.gpg.key
+- ubuntu-toolchain-r-test
+  packages:
+- libedit-dev
+# LLVM-7 needs libstdc++4.9
+- g++-4.9
+# From sources above
+- llvm-7-dev
+- clang-7
 
 before_install:
 - eval "${MATRIX_EVAL}"
 
 script:
-  - $PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG 
--with-cxx-compiler=$CXX && make -j4
+  - if $(echo $LABEL | grep cmake > /dev/null) ; then
+mkdir built_libs && cd built_libs && cmake .. 
-DLLVM_CONFIG=$LLVM_CONFIG && make -j4 && cd .. ;
+else
+$PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG 
--with-cxx-compiler=$CXX && make -j4;
+fi
   - ret=0;
 for f in $CHECK_FILES; do
 ./check_external_calls.sh built_libs/$f || ret=1;


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


[libclc] r347667 - Add cmake build system

2018-11-27 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Nov 27 08:07:19 2018
New Revision: 347667

URL: http://llvm.org/viewvc/llvm-project?rev=347667=rev
Log:
Add cmake build system

Add cmake support for CLC and ll asm language,
the latter includes clang preprocessing stage.
Add ctests to check for external function calls.

v2: fix typos, style

Signed-off-by: Jan Vesely 
Acked-by: Aaron Watry 
Tested-by: Aaron Watry 
Acked-by: Vedran Miletić 

Added:
libclc/trunk/CMakeLists.txt
libclc/trunk/cmake/
libclc/trunk/cmake/CMakeCLCCompiler.cmake.in
libclc/trunk/cmake/CMakeCLCInformation.cmake
libclc/trunk/cmake/CMakeDetermineCLCCompiler.cmake
libclc/trunk/cmake/CMakeDetermineLLAsmCompiler.cmake
libclc/trunk/cmake/CMakeLLAsmCompiler.cmake.in
libclc/trunk/cmake/CMakeLLAsmInformation.cmake
libclc/trunk/cmake/CMakeTestCLCCompiler.cmake
libclc/trunk/cmake/CMakeTestLLAsmCompiler.cmake
libclc/trunk/libclc.pc.in

Added: libclc/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/CMakeLists.txt?rev=347667=auto
==
--- libclc/trunk/CMakeLists.txt (added)
+++ libclc/trunk/CMakeLists.txt Tue Nov 27 08:07:19 2018
@@ -0,0 +1,298 @@
+cmake_minimum_required( VERSION 3.9.2 )
+
+project( libclc VERSION 0.2.0 LANGUAGES CXX )
+
+# List of all targets
+set( LIBCLC_TARGETS_ALL
+  amdgcn--
+  amdgcn--amdhsa
+  r600--
+  nvptx--
+  nvptx64--
+  nvptx--nvidiacl
+  nvptx64--nvidiacl
+)
+
+set( LIBCLC_MIN_LLVM "3.9.0" )
+
+set( LIBCLC_TARGETS_TO_BUILD "all"
+CACHE STRING "Semicolon-separated list of targets to build, or 'all'." )
+
+option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support."
+OFF )
+
+if( NOT LLVM_CONFIG )
+   find_program( LLVM_CONFIG llvm-config )
+endif()
+execute_process( COMMAND ${LLVM_CONFIG} "--version"
+OUTPUT_VARIABLE LLVM_VERSION
+OUTPUT_STRIP_TRAILING_WHITESPACE )
+message( "LLVM version: ${LLVM_VERSION}" )
+
+if( ${LLVM_VERSION} VERSION_LESS ${LIBCLC_MIN_LLVM} )
+   message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" )
+endif()
+
+# mesa3d environment is only available since LLVM 4.0
+if( ${LLVM_VERSION} VERSION_GREATER "3.9.0" )
+   set( LIBCLC_TARGETS_ALL ${LIBCLC_TARGETS_ALL} amdgcn-mesa-mesa3d )
+endif()
+
+if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
+   set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
+endif()
+
+list( SORT LIBCLC_TARGETS_TO_BUILD )
+
+execute_process( COMMAND ${LLVM_CONFIG} "--system-libs"
+   OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+execute_process( COMMAND ${LLVM_CONFIG} "--libs" "core" "bitreader" "bitwriter"
+   OUTPUT_VARIABLE LLVM_LIBS
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+execute_process( COMMAND ${LLVM_CONFIG} "--libdir"
+   OUTPUT_VARIABLE LLVM_LIBDIR
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+execute_process( COMMAND ${LLVM_CONFIG} "--ldflags"
+   OUTPUT_VARIABLE LLVM_LD_FLAGS
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+execute_process( COMMAND ${LLVM_CONFIG} "--cxxflags"
+   OUTPUT_VARIABLE LLVM_CXX_FLAGS
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+separate_arguments( LLVM_CXX_FLAGS )
+execute_process( COMMAND ${LLVM_CONFIG} "--bindir"
+   OUTPUT_VARIABLE LLVM_BINDIR
+   OUTPUT_STRIP_TRAILING_WHITESPACE )
+
+# These were not properly reported in early LLVM and we don't need them
+set( LLVM_CXX_FLAGS ${LLVM_CXX_FLAGS} -fno-rtti -fno-exceptions )
+
+# Print LLVM variables
+message( "LLVM system libs: ${LLVM_SYSTEM_LIBS}" )
+message( "LLVM libs: ${LLVM_LIBS}" )
+message( "LLVM libdir: ${LLVM_LIBDIR}" )
+message( "LLVM bindir: ${LLVM_BINDIR}" )
+message( "LLVM ld flags: ${LLVM_LD_FLAGS}" )
+message( "LLVM cxx flags: ${LLVM_CXX_FLAGS}" )
+message( "" )
+
+find_program( LLVM_CLANG clang PATHS ${LLVM_BINDIR} NO_DEFAULT_PATH )
+find_program( LLVM_AS llvm-as PATHS ${LLVM_BINDIR} NO_DEFAULT_PATH )
+find_program( LLVM_LINK llvm-link PATHS ${LLVM_BINDIR} NO_DEFAULT_PATH )
+find_program( LLVM_OPT opt PATHS ${LLVM_BINDIR} NO_DEFAULT_PATH )
+
+# Print toolchain
+message( "clang: ${LLVM_CLANG}" )
+message( "llvm-as: ${LLVM_AS}" )
+message( "llvm-link: ${LLVM_LINK}" )
+message( "opt: ${LLVM_OPT}" )
+message( "" )
+if( NOT LLVM_CLANG OR NOT LLVM_OPT OR NOT LLVM_AS OR NOT LLVM_LINK )
+   message( FATAL_ERROR "toolchain incomplete!" )
+endif()
+
+set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
+set( CMAKE_CLC_COMPILER ${LLVM_CLANG} )
+set( CMAKE_CLC_ARCHIVE ${LLVM_LINK} )
+set( CMAKE_LLAsm_PREPROCESSOR ${LLVM_CLANG} )
+set( CMAKE_LLAsm_COMPILER ${LLVM_AS} )
+set( CMAKE_LLAsm_ARCHIVE ${LLVM_LINK} )
+enable_language( CLC LLAsm )
+
+# Construct LLVM version define
+string( REPLACE "." ";" LLVM_VERSION_LIST ${LLVM_VERSION} )
+list( GET LLVM_VERSION_LIST 0 LLVM_MAJOR )
+list( GET LLVM_VERSION_LIST 1 LLVM_MINOR )
+set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_MAJOR}0${LLVM_MINOR}" )
+
+# This needs to be set before any 

[PATCH] D54817: [clangd] Put direct headers into srcs section.

2018-11-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE347669: [clangd] Put direct headers into srcs section. 
(authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54817?vs=175483=175486#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54817/new/

https://reviews.llvm.org/D54817

Files:
  clangd/Headers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/Serialization.cpp
  clangd/index/Serialization.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/SerializationTests.cpp

Index: clangd/Headers.h
===
--- clangd/Headers.h
+++ clangd/Headers.h
@@ -48,6 +48,20 @@
 };
 llvm::raw_ostream <<(llvm::raw_ostream &, const Inclusion&);
 
+// Contains information about one file in the build grpah and its direct
+// dependencies. Doesn't own the strings it references (IncludeGraph is
+// self-contained).
+struct IncludeGraphNode {
+  // True if current file is a main file rather than a header.
+  bool IsTU;
+  llvm::StringRef URI;
+  FileDigest Digest;
+  std::vector DirectIncludes;
+};
+// FileURI and FileInclusions are references to keys of the map containing
+// them.
+using IncludeGraph = llvm::StringMap;
+
 // Information captured about the inclusion graph in a translation unit.
 // This includes detailed information about the direct #includes, and summary
 // information about all transitive includes.
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -227,5 +227,17 @@
  Left.end.character == Right.start.character;
 }
 
+FileDigest digest(StringRef Content) {
+  return llvm::SHA1::hash({(const uint8_t *)Content.data(), Content.size()});
+}
+
+Optional digestFile(const SourceManager , FileID FID) {
+  bool Invalid = false;
+  StringRef Content = SM.getBufferData(FID, );
+  if (Invalid)
+return None;
+  return digest(Content);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -16,13 +16,22 @@
 #include "Protocol.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/SHA1.h"
 
 namespace clang {
 class SourceManager;
 
 namespace clangd {
 
+// We tend to generate digests for source codes in a lot of different places.
+// This represents the type for those digests to prevent us hard coding details
+// of hashing function at every place that needs to store this information.
+using FileDigest = decltype(llvm::SHA1::hash({}));
+FileDigest digest(StringRef Content);
+Optional digestFile(const SourceManager , FileID FID);
+
 // Counts the number of UTF-16 code units needed to represent a string (LSP
 // specifies string lengths in UTF-16 code units).
 size_t lspLength(StringRef Code);
Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -11,6 +11,7 @@
 #include "ClangdUnit.h"
 #include "Compiler.h"
 #include "Logger.h"
+#include "SourceCode.h"
 #include "Threading.h"
 #include "Trace.h"
 #include "URI.h"
@@ -149,19 +150,6 @@
   QueueCV.notify_all();
 }
 
-static BackgroundIndex::FileDigest digest(StringRef Content) {
-  return SHA1::hash({(const uint8_t *)Content.data(), Content.size()});
-}
-
-static Optional digestFile(const SourceManager ,
-FileID FID) {
-  bool Invalid = false;
-  StringRef Content = SM.getBufferData(FID, );
-  if (Invalid)
-return None;
-  return digest(Content);
-}
-
 // Resolves URI to file paths with cache.
 class URIToFileCache {
 public:
@@ -193,8 +181,7 @@
 };
 
 /// Given index results from a TU, only update files in \p FilesToUpdate.
-void BackgroundIndex::update(StringRef MainFile, SymbolSlab Symbols,
- RefSlab Refs,
+void BackgroundIndex::update(StringRef MainFile, IndexFileIn Index,
  const StringMap ,
  BackgroundIndexStorage *IndexStorage) {
   // Partition symbols/references into files.
@@ -204,7 +191,7 @@
   };
   StringMap Files;
   URIToFileCache URICache(MainFile);
-  for (const auto  : Symbols) {
+  for (const auto  : *Index.Symbols) {
 if (Sym.CanonicalDeclaration) {
   auto DeclPath = URICache.resolve(Sym.CanonicalDeclaration.FileURI);
   if (FilesToUpdate.count(DeclPath) != 0)
@@ -222,7 +209,7 @@
 }
   }
   DenseMap RefToIDs;
-  for (const auto  : Refs) {
+  for (const auto  : *Index.Refs) {
 for (const auto  : SymRefs.second) {
   auto 

  1   2   >