[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

2018-07-18 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

This was reverted in r333482 because it was causing "definition with same 
mangled name as another definition" errors in some internal google builds.

It turned out this uncovered an (unrelated) issue in module importing. This has 
now been fixed (r336240), so I'm planning to resubmit this patch. Let me know 
if you have any concerns.


Repository:
  rC Clang

https://reviews.llvm.org/D46685



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


[PATCH] D48786: [Preprocessor] Stop entering included files after hitting a fatal error.

2018-07-18 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a reviewer: jkorous.
jkorous added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:1875
+  // Stop further preprocessing if a fatal error has occurred. Any diagnostics
+  // we might have raised will not be visible.
+  if (ShouldEnter && Diags->hasFatalErrorOccurred())

I am not sure I understand this - does that mean that we are not displaying 
diagnostics that were produced before "now"?


https://reviews.llvm.org/D48786



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


[PATCH] D49075: [NEON] Define fp16 vld and vst intrinsics conditionally

2018-07-18 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Ping.


https://reviews.llvm.org/D49075



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


[PATCH] D48829: [NEON] Fix support for vrndi_f32(), vrndiq_f32() and vrndns_f32() intrinsics

2018-07-18 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Ping.


https://reviews.llvm.org/D48829



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


[PATCH] D49417: [clangd] Implement trigram generation algorithm for new symbol index

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Some high-level comments before jumping into details.




Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.cpp:23
+
+// FIXME(kbobyrev): Deal with short symbol symbol names.
+std::vector generateSearchAtoms(StringRef SymbolName) {

maybe also add how short symbol names are handled in the current algorithm and 
what the potential solution would be.



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.cpp:28
+  // Apply lowercase text normalization.
+  for (auto &Token : Tokens)
+std::for_each(Token.begin(), Token.end(), ::tolower);

Any reason not to do this in segmentation?



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:27
+
+/// \brief Hashable SearchAtom, which represents a search token primitive.
+///

Any reason to call this `Atom` instead of `Token`? `Token` seems to be a more 
commonly used name for this (e.g. 
https://yomguithereal.github.io/mnemonist/inverted-index#tokens). 



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:45
+public:
+  enum class Namespace : short {
+Trigram,

`Namespace` can be easily confused with namespaces in clang world. Maybe `Kind` 
or `Type`?



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:51
+
+  SearchAtom() = default;
+  SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram)

What is an empty atom? Why do we need it?



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:52
+  SearchAtom() = default;
+  SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram)
+  : Data(Data), Hash(std::hash{}(Data)), Type(Type) {}

Why default `Type` to `Trigram`? 



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:52
+  SearchAtom() = default;
+  SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram)
+  : Data(Data), Hash(std::hash{}(Data)), Type(Type) {}

ioeric wrote:
> Why default `Type` to `Trigram`? 
Please add documentation. What is the semantic of `Data`? 



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:53
+  SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram)
+  : Data(Data), Hash(std::hash{}(Data)), Type(Type) {}
+

Should we also incorporate `Type` into hash?



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:53
+  SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram)
+  : Data(Data), Hash(std::hash{}(Data)), Type(Type) {}
+

ioeric wrote:
> Should we also incorporate `Type` into hash?
I'm wondering if we should use different hashes for different token types. For 
example, a trigram token "xyz" can be encoded in a 4 -byte int with `('x'<<16) 
& ('y'<<8) & 'z'`, which seems cheaper than `std::hash`.



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:62
+
+  const llvm::StringRef getData() const { return Data; }
+

nit:
s/getData/data/
s/getType/type/



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:76
+
+/// \brief Splits unqualified symbol name into tokens for trigram generation.
+///

nit: I'd avoid calling these `tokens`, as it they can be confused with tokens 
for the invert index. How about `segments`?  Similarly, `tokenize` should 
probably be something like `segment` or `segmentIdentifier`.



Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:141
+///  trigram belongs to more than one class it is only inserted once.
+std::vector generateSearchAtoms(llvm::StringRef SymbolName);
+

`generateSearchAtoms` is too generalized a name for this. Maybe just 
`trigram()`? I also think this could take a list of segments from `tokenize`.


https://reviews.llvm.org/D49417



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


[PATCH] D46190: For a used declaration, mark any associated usings as referenced.

2018-07-18 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

@rsmith and @probinson:

Is there anything I can add to this patch?

The review

https://reviews.llvm.org/D44826

is already approved and it is blocked by this patch being reviewed.

Thanks very much


https://reviews.llvm.org/D46190



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


[PATCH] D44823: [libcxx] Improving std::vector and std::deque perfomance

2018-07-18 Thread Danila Kutenin via Phabricator via cfe-commits
danlark added inline comments.
Herald added a subscriber: ldionne.



Comment at: libcxx/trunk/include/__split_buffer:201
 __alloc_rr& __a = this->__alloc();
+pointer __to_be_end = this->__end_;
 do

lichray wrote:
> mclow.lists wrote:
> > I have been asked specifically by the optimizer folks to NOT do things like 
> > this in libc++, but rather to file bugs against the optimizer.
> > 
> > And I have done so for this exact case:  
> > https://bugs.llvm.org/show_bug.cgi?id=35637
> From the thread I didn't see that the compiler side asked you not to do so.
> 
> And I disagree with the view.  libc++ shouldn't *wait* for compilers, because 
> we don't dictate users' compiler choices.  This change doesn't make libc++ 
> worse to coming compilers, and makes libc++ better on existing compilers, so 
> what benefit we get by not approving this?
So, what is the status? Are we waiting for the compiler code-gen fix?

At Yandex we are using patched version like half a year or more.

https://github.com/catboost/catboost/blob/master/contrib/libs/cxxsupp/libcxx/include/vector#L995


Repository:
  rCXX libc++

https://reviews.llvm.org/D44823



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-07-18 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp added a comment.

> Which means that for some calls we aren't even trying to make a CTU lookup.

Thanks @NoQ, we will take a look at it!


Repository:
  rC Clang

https://reviews.llvm.org/D30691



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


r337381 - Mention clang-cl improvements from r335466 and r336379 in ReleaseNotes.rst

2018-07-18 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jul 18 04:55:03 2018
New Revision: 337381

URL: http://llvm.org/viewvc/llvm-project?rev=337381&view=rev
Log:
Mention clang-cl improvements from r335466 and r336379 in ReleaseNotes.rst

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=337381&r1=337380&r2=337381&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 18 04:55:03 2018
@@ -166,7 +166,19 @@ Attribute Changes in Clang
 Windows Support
 ---
 
-Clang's support for building native Windows programs ...
+- clang-cl's support for precompiled headers has been much improved:
+
+   - When using a pch file, clang-cl now no longer redundantly emits inline
+ methods that are already stored in the obj that was built together with
+ the pch file (matching cl.exe).  This speeds up builds using pch files
+ by around 30%.
+
+   - The /Ycfoo.h and /Yufoo.h flags an now be used without /FIfoo.h when
+ foo.h is instead included by an explicit `#include` directive. This means
+ Visual Studio's default stdafx.h setup now uses precompiled headers with
+ clang-cl.
+
+- ...
 
 
 C Language Changes in Clang


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


[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-07-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D46652#1164016, @thakis wrote:

> And finally (sorry about all the mails), this should probably be mentioned in 
> the release notes (docs/ReleaseNotes.rst in the clang repo) since it's a 
> notable new feature :-)


I added this to releasenotes in r337381.


Repository:
  rC Clang

https://reviews.llvm.org/D46652



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


[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Adding Richard to see if he agrees with the direction taken.




Comment at: lib/Sema/SemaAccess.cpp:1871-1873
+// The access should be AS_none as we don't know how the member was
+// accessed - `AccessedEntity::getAccess` describes what access was used to
+// access an entity.

This seems to contradict the function-level comment that says the check seems 
to only take the access specifiers into account and not how the member is 
accessed.



Comment at: lib/Sema/SemaCodeComplete.cpp:1307
+  if (Ctx) {
+auto *AccessingCtx = Ctx;
+// If ND comes from a base class, set the naming class back to the

Please do not use `auto` as the type is not spelled out in the initialization.



Comment at: lib/Sema/SemaCodeComplete.cpp:1316-1317
+//   void D::f() { this->^; }
+// The completion after "this->" will have `InBaseClass` set to true 
and
+// `Ctx` set to "B". We need to set the actual accessing context (i.e.
+// naming class) to "D" so that access can be calculated correctly.

This makes it sound like the caller has messed something up, but I'm also 
pretty unfamiliar with the code completion logic. Why would `InBaseClass` be 
true for that completion point and why would the context be set to `B`?



Comment at: lib/Sema/SemaCodeComplete.cpp:1319
+// naming class) to "D" so that access can be calculated correctly.
+if (InBaseClass && llvm::isa(Ctx)) {
+  CXXRecordDecl *RC = nullptr;

You can drop the `llvm::`



Comment at: lib/Sema/SemaCodeComplete.cpp:1322
+  // Get the enclosing record.
+  for (auto *DC = CurContext; !DC->isFileContext();
+   DC = DC->getParent()) {

Please don't use `auto` here either.



Comment at: lib/Sema/SemaCodeComplete.cpp:1324
+   DC = DC->getParent()) {
+if ((RC = llvm::dyn_cast(DC)))
+  break;

You can drop the `llvm::`


Repository:
  rC Clang

https://reviews.llvm.org/D49421



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


[PATCH] D49457: DR330: when determining whether a cast casts away constness, consider qualifiers from all levels matching a multidimensional array

2018-07-18 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hi @rsmith – I've verified this patch fixes the original issue. Thanks for the 
quick fix!


Repository:
  rC Clang

https://reviews.llvm.org/D49457



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


[PATCH] D49476: [Index] Set OrigD before D is changed.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: akyrtzi, arphaman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D49476

Files:
  lib/Index/IndexingContext.cpp


Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -350,6 +350,9 @@
 }
   }
 
+  if (!OrigD)
+OrigD = D;
+
   if (isTemplateImplicitInstantiation(D)) {
 if (!IsRef)
   return true;
@@ -359,9 +362,6 @@
 assert(!isTemplateImplicitInstantiation(D));
   }
 
-  if (!OrigD)
-OrigD = D;
-
   if (IsRef)
 Roles |= (unsigned)SymbolRole::Reference;
   else if (isDeclADefinition(OrigD, ContainerDC, *Ctx))


Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -350,6 +350,9 @@
 }
   }
 
+  if (!OrigD)
+OrigD = D;
+
   if (isTemplateImplicitInstantiation(D)) {
 if (!IsRef)
   return true;
@@ -359,9 +362,6 @@
 assert(!isTemplateImplicitInstantiation(D));
   }
 
-  if (!OrigD)
-OrigD = D;
-
   if (IsRef)
 Roles |= (unsigned)SymbolRole::Reference;
   else if (isDeclADefinition(OrigD, ContainerDC, *Ctx))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r336380 - Add PCH tests for R336379

2018-07-18 Thread Nico Weber via cfe-commits
I think normally we don't set all these svn properties. Did you set them
intentionally?

On Thu, Jul 5, 2018 at 1:28 PM Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Thu Jul  5 10:23:15 2018
> New Revision: 336380
>
> URL: http://llvm.org/viewvc/llvm-project?rev=336380&view=rev
> Log:
> Add PCH tests for R336379
>
> I seemingly forgot the tests for this commit, added here.
>
> Added:
> cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through1.h   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through2.h   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through3.h   (with props)
> cfe/trunk/test/PCH/Inputs/pch-through4.h   (with props)
> cfe/trunk/test/PCH/pch-through1.cpp   (with props)
> cfe/trunk/test/PCH/pch-through2.cpp   (with props)
> cfe/trunk/test/PCH/pch-through3a.cpp   (with props)
> cfe/trunk/test/PCH/pch-through3b.cpp   (with props)
>
> Added: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp?rev=336380&view=auto
>
> ==
> --- cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp (added)
> +++ cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp Thu Jul  5 10:23:15 2018
> @@ -0,0 +1,2 @@
> +void foo() {
> +}
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
>
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
>
> --
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
>
> --
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp?rev=336380&view=auto
>
> ==
> --- cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp (added)
> +++ cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp Thu Jul  5 10:23:15 2018
> @@ -0,0 +1,5 @@
> +#include "Inputs/pch-through1.h"
> +#include "Inputs/pch-through3.h"
> +void foo() {
> +  through2(0);
> +}
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
>
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
>
> --
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
>
> --
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp?rev=336380&view=auto
>
> ==
> --- cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp (added)
> +++ cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp Thu Jul  5 10:23:15 2018
> @@ -0,0 +1,3 @@
> +void foo() {
> +  through4(0);
> +}
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
>
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
>
> --
> svn:keywords = Author Date Id Rev URL
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
>
> --
> svn:mime-type = text/plain
>
> Added: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp?rev=336380&view=auto
>
> ==
> --- cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp (added)
> +++ cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp Thu Jul  5 10:23:15
> 2018
> @@ -0,0 +1,2 @@
> +#define AFOO 0
> +#include "Inputs/pch-through1.h"
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
>
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.

[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 156056.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- addressed review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D49421

Files:
  lib/Sema/SemaAccess.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-access-checks.cpp

Index: test/Index/complete-access-checks.cpp
===
--- test/Index/complete-access-checks.cpp
+++ test/Index/complete-access-checks.cpp
@@ -36,10 +36,10 @@
 
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func1}{LeftParen (}{RightParen )} (36)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func2}{LeftParen (}{RightParen )} (36) (inaccessible)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func2}{LeftParen (}{RightParen )} (36)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func3}{LeftParen (}{RightParen )} (36) (inaccessible)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37)
-// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible)
+// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81)
@@ -87,3 +87,26 @@
 // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText Q}{Text ::} (75)
 // CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (81)
 // CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (79)
+
+class B {
+protected:
+  int member;
+};
+
+class C : private B {};
+
+
+class D : public C {
+ public:
+  void f(::B *b);
+};
+
+void D::f(::B *that) {
+  // RUN: c-index-test -code-completion-at=%s:106:9 %s | FileCheck -check-prefix=CHECK-PRIVATE-SUPER-THIS %s
+  this->;
+// CHECK-PRIVATE-SUPER-THIS: FieldDecl:{ResultType int}{Informative B::}{TypedText member} (37) (inaccessible)
+
+  // RUN: c-index-test -code-completion-at=%s:110:9 %s | FileCheck -check-prefix=CHECK-PRIVATE-SUPER-THAT %s
+  that->;
+// CHECK-PRIVATE-SUPER-THAT: FieldDecl:{ResultType int}{TypedText member} (35) (inaccessible)
+}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -1303,8 +1303,33 @@
 void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
bool InBaseClass) override {
   bool Accessible = true;
-  if (Ctx)
-Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
+  if (Ctx) {
+DeclContext *AccessingCtx = Ctx;
+// If ND comes from a base class, set the naming class back to the
+// derived class if the search starts from the derived class (i.e.
+// InBaseClass is true).
+//
+// Example:
+//   class B { protected: int X; }
+//   class D : public B { void f(); }
+//   void D::f() { this->^; }
+// The completion after "this->" will have `InBaseClass` set to true and
+// `Ctx` set to "B", when looking up in `B`. We need to set the actual
+// accessing context (i.e. naming class) to "D" so that access can be
+// calculated correctly.
+if (InBaseClass && isa(Ctx)) {
+  CXXRecordDecl *RC = nullptr;
+  // Get the enclosing record.
+  for (DeclContext *DC = CurContext; !DC->isFileContext();
+   DC = DC->getParent()) {
+if ((RC = dyn_cast(DC)))
+  break;
+  }
+  if (RC)
+AccessingCtx = RC;
+}
+Accessible = Results.getSema().IsSimplyAccessible(ND, AccessingCtx);
+  }
 
   ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr,
false, Accessible, FixIts);
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1868,16 +1868,16 @@
   return true;
 
 QualType qType = Class->getTypeForDecl()->getCanonicalTypeInternal();
+// The unprivileged access is AS_none as we don't know how the member was
+// accessed, which is described by the access in DeclAccessPair.
+// `IsAccessible` will examine the actual access of Decl (i.e.
+// Decl->getAccess()) when calculating the access.
 AccessTarget En

[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Thanks for the review!




Comment at: lib/Sema/SemaAccess.cpp:1871-1873
+// The access should be AS_none as we don't know how the member was
+// accessed - `AccessedEntity::getAccess` describes what access was used to
+// access an entity.

aaron.ballman wrote:
> This seems to contradict the function-level comment that says the check seems 
> to only take the access specifiers into account and not how the member is 
> accessed.
> not how the member is accessed.
It's not very clear to me what exactly this means.  But I think we are still 
not taking how member was accessed into account. The access in `DeclAccessPair` 
describes how a member was accessed, and this should be None instead of the 
access specifier of the member as we don't have this information here. 

I updated the wording in the comment to make this a bit clearer.



Comment at: lib/Sema/SemaCodeComplete.cpp:1316-1317
+//   void D::f() { this->^; }
+// The completion after "this->" will have `InBaseClass` set to true 
and
+// `Ctx` set to "B". We need to set the actual accessing context (i.e.
+// naming class) to "D" so that access can be calculated correctly.

aaron.ballman wrote:
> This makes it sound like the caller has messed something up, but I'm also 
> pretty unfamiliar with the code completion logic. Why would `InBaseClass` be 
> true for that completion point and why would the context be set to `B`?
It's a bit messy, but this is roughly how lookup inside a class, say D,works:
1. lookup inside the class (InBaseClass = false, Context=D).
2. Run the same lookup on all base classes (InBaseClass=true, Context=B). 
(https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaLookup.cpp#L3584)

So, `InBaseClass` would be true when a lookup starts from a derived class. 


Repository:
  rC Clang

https://reviews.llvm.org/D49421



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


RE: r336380 - Add PCH tests for R336379

2018-07-18 Thread Keane, Erich via cfe-commits
Ugg… I did not.  Seemingly my svn-property cleaning script isn’t working for 
some reason.  If it hasn’t been done yet, I’ll clear the properties now.

From: Nico Weber [mailto:tha...@chromium.org]
Sent: Wednesday, July 18, 2018 5:21 AM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r336380 - Add PCH tests for R336379

I think normally we don't set all these svn properties. Did you set them 
intentionally?

On Thu, Jul 5, 2018 at 1:28 PM Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Thu Jul  5 10:23:15 2018
New Revision: 336380

URL: http://llvm.org/viewvc/llvm-project?rev=336380&view=rev
Log:
Add PCH tests for R336379

I seemingly forgot the tests for this commit, added here.

Added:
cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp   (with props)
cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp   (with props)
cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp   (with props)
cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp   (with props)
cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp   (with props)
cfe/trunk/test/PCH/Inputs/pch-through1.h   (with props)
cfe/trunk/test/PCH/Inputs/pch-through2.h   (with props)
cfe/trunk/test/PCH/Inputs/pch-through3.h   (with props)
cfe/trunk/test/PCH/Inputs/pch-through4.h   (with props)
cfe/trunk/test/PCH/pch-through1.cpp   (with props)
cfe/trunk/test/PCH/pch-through2.cpp   (with props)
cfe/trunk/test/PCH/pch-through3a.cpp   (with props)
cfe/trunk/test/PCH/pch-through3b.cpp   (with props)

Added: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp?rev=336380&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp Thu Jul  5 10:23:15 2018
@@ -0,0 +1,2 @@
+void foo() {
+}

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
svn:mime-type = text/plain

Added: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp?rev=336380&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp Thu Jul  5 10:23:15 2018
@@ -0,0 +1,5 @@
+#include "Inputs/pch-through1.h"
+#include "Inputs/pch-through3.h"
+void foo() {
+  through2(0);
+}

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
svn:mime-type = text/plain

Added: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp?rev=336380&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp Thu Jul  5 10:23:15 2018
@@ -0,0 +1,3 @@
+void foo() {
+  through4(0);
+}

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
svn:mime-type = text/plain

Added: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp?rev=336380&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp (added)
+++ cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp Thu Jul  5 10:23:15 2018
@@ -0,0 +1,2 @@
+#define AFOO 0
+#include "Inputs/pch-through1.h"

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
--

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Decl.h:2212-2213
 
+  bool isCpuDispatchMultiVersion() const;
+  bool isCpuSpecificMultiVersion() const;
+

aaron.ballman wrote:
> Pedantic nit: CPU instead of Cpu?
Thoughts on `isCPUDispatchMultiVersion()` instead of 
`isCpuDispatchMultiVersion()`?



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [Clang<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

`Cpus` -> `CPUs` ?



Comment at: include/clang/Basic/Attr.td:865
+  let Spellings = [Clang<"cpu_dispatch">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

`Cpus` -> `CPUs` ?



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [GCC<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > Be sure to add a test for using this attribute with the C++ spelling, 
> > > > as I'm not certain how well we would parse something like 
> > > > `[[gnu::cpu_specific(ivybridge)]]` currently (it may just work, 
> > > > however).
> > > > 
> > > > Also, why an identifier instead of a string literal?
> > > I'll add it, presumably as 'clang::cpu_specific'.  The decision for 
> > > string-literal vs identifier was made quite a few years before I was here 
> > > sadly.  I believe the EDG FE doesn't make identifiers any more difficult 
> > > so the implementer here chose to make it that way.
> > > 
> > > In this case, I'd very much like to keep it with the same implementation 
> > > as ICC, simply because users of this are already familiar with it in this 
> > > form.
> > > In this case, I'd very much like to keep it with the same implementation 
> > > as ICC, simply because users of this are already familiar with it in this 
> > > form.
> > 
> > The compatibility with ICC is important for the GNU-style attribute, but 
> > for the C++ spelling this is novel territory where there is no 
> > compatibility story. Another approach to consider is whether to accept 
> > identifiers or string literals depending on the spelling, but that might 
> > not be worth it.
> I'd like to think about that... I could forsee accepting BOTH forms, simply 
> because it would slightly simplify the conversion from an attribute-target-mv 
> situation, though I'm not sure it is important enough to do. 
> 
> 
I'm okay with the current approach that uses identifiers only. We can relax the 
rule to allow string literals if it turns out there is user demand for such a 
thing.



Comment at: include/clang/Basic/AttrDocs.td:247
+It is also possible to specify a CPU name of ``generic``, which is the
+condition-less implementation, which will be resolved if the executing 
processor
+doesn't satisfy the features required in the CPU name. The behavior of a 
program

I'd drop the bit about "which is the condition-less implementation". It reads a 
bit oddly to begin with and doesn't really add much to the explanation.



Comment at: lib/CodeGen/CodeGenModule.cpp:866
+  StringRef Name) {
+  const auto &Target = CGM.getTarget();
+  return (Twine('.') + Twine(Target.CPUSpecificManglingCharacter(Name))).str();

Don't use `auto` here.



Comment at: lib/CodeGen/CodeGenModule.cpp:2446
+  const auto *FD = cast(GD.getDecl());
+  assert(FD && "Not a FunctionDecl?");
+  const auto *DD = FD->getAttr();

`cast<>` already asserts this.



Comment at: lib/CodeGen/CodeGenModule.cpp:2457
+  false);
+  llvm::Function *ResolverFunc = cast(
+  GetOrCreateLLVMFunction(ResolverName, ResolverType, GlobalDecl{},

Can use `auto *` here.



Comment at: lib/CodeGen/CodeGenModule.cpp:2464
+  const TargetInfo &Target = getTarget();
+  for (IdentifierInfo *II : DD->cpus()) {
+// Get the name of the target function so we can look it up/create it.

`const IdentifierInfo *`



Comment at: lib/Sema/Sema.cpp:1733
 
+static bool IsCPUDispatchCPUSpecificMultiVersion(Expr *E) {
+  if (const auto *UO = dyn_cast(E))

`const Expr *`?



Comment at: lib/Sema/SemaDecl.cpp:9587
+  } else if (NewMVType == MultiVersioning::CPUSpecific && CurCPUSpec) {
+
+if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&

Spurious newline? Also, `else` after a return.



Comment at: lib/Sema/SemaDecl.cpp:9614
+  }
+  // if The two decls aren't the same MVType, there is no possible error
+  // condition.

s/if The/If the



Comment at: lib/Sem

r337388 - Clear properties inadvertantly added to tests in R336379

2018-07-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jul 18 06:07:13 2018
New Revision: 337388

URL: http://llvm.org/viewvc/llvm-project?rev=337388&view=rev
Log:
Clear properties inadvertantly added to tests in R336379

Modified:
cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through1.h   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through2.h   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through3.h   (props changed)
cfe/trunk/test/PCH/Inputs/pch-through4.h   (props changed)
cfe/trunk/test/PCH/pch-through1.cpp   (props changed)
cfe/trunk/test/PCH/pch-through2.cpp   (props changed)
cfe/trunk/test/PCH/pch-through3a.cpp   (props changed)
cfe/trunk/test/PCH/pch-through3b.cpp   (props changed)

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use0.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use1.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use2.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3a.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through-use3b.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain

Propchange: cfe/trunk/test/PCH/Inputs/pch-through1.h
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/PCH/Inputs/pch-through1.h
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/PCH/Inputs/pch-through1.h
--
--- svn:mime-type (orig

[PATCH] D49403: More aggressively complete RecordTypes with Function Pointers

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: olga.chupina.
erichkeane added a comment.

In https://reviews.llvm.org/D49403#1165845, @rjmccall wrote:

> Can you explain why this is important for the optimizer?


@olga.a.chupina  (or is it @olga.chupina ) is the one who reported this to me, 
so hopefully she can explain it in a disclosable fashion.


https://reviews.llvm.org/D49403



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


[PATCH] D49112: [Sema] Implement -Wmemset-transposed-args

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7975-7976
+static void CheckMemsetSizeof(Sema &S, unsigned BId, const CallExpr *Call) {
+  if (BId != Builtin::BImemset)
+return;
+

erik.pilkington wrote:
> aaron.ballman wrote:
> > This functionality should apply equally to `wmemset()` as well, should it 
> > not? The only difference I can think of would be that the type should be 
> > cast to `wchar_t` instead of `int` to silence the warning.
> Looks like clang doesn't have a builtin for wmemset, its just defined as a 
> normal function. I suppose that we could still try to diagnose calls to 
> top-level functions named wmemset, but thats unprecedented and doesn't really 
> seem worth the trouble.
I'm fine leaving it off then; I agree it's not worth the trouble.


https://reviews.llvm.org/D49112



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


Re: r337255 - Temporarily revert r337226 "Restructure checking for, and warning on, lifetime extension."

2018-07-18 Thread Florian Hahn via cfe-commits



On 17/07/2018 23:29, Richard Smith wrote:

Thank you. I added an 'alignas(8)' and reapplied in r337329.



Great thank you very much!
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49480: Haiku: support for secondary arch

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 created this revision.
Herald added subscribers: cfe-commits, mgorny.

Enables Haiku to build llvm for secondary architectures.


Repository:
  rC Clang

https://reviews.llvm.org/D49480

Files:
  CMakeLists.txt
  lib/Driver/ToolChains/Haiku.cpp
  lib/Frontend/InitHeaderSearch.cpp


Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -238,7 +238,19 @@
   if (HSOpts.UseBuiltinIncludes) {
 // Ignore the sys root, we *always* look for clang headers relative to
 // supplied path.
+#ifdef HAIKU_HYBRID_SECONDARY
+// Remove version from foo/lib/clang/version
+StringRef Ver = llvm::sys::path::filename(HSOpts.ResourceDir);
+StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
+// Remove clang from foo/lib/clang
+StringRef Clang = llvm::sys::path::filename(NoVer);
+SmallString<128> P = llvm::sys::path::parent_path(NoVer);
+
+// Get foo/include/c++/v1
+llvm::sys::path::append(P, HAIKU_HYBRID_SECONDARY, Clang, Ver);
+#else
 SmallString<128> P = StringRef(HSOpts.ResourceDir);
+#endif
 llvm::sys::path::append(P, "include");
 AddUnmappedPath(P, ExternCSystem, false);
   }
@@ -272,7 +284,12 @@
   }
 
   case llvm::Triple::Haiku:
+#ifdef HAIKU_HYBRID_SECONDARY
+AddPath("/boot/system/non-packaged/develop/headers/" 
HAIKU_HYBRID_SECONDARY,
+System, false);
+#else
 AddPath("/boot/system/non-packaged/develop/headers", System, false);
+#endif
 AddPath("/boot/system/develop/headers/os", System, false);
 AddPath("/boot/system/develop/headers/os/app", System, false);
 AddPath("/boot/system/develop/headers/os/arch", System, false);
@@ -304,6 +321,13 @@
 AddPath("/boot/system/develop/headers/bsd", System, false);
 AddPath("/boot/system/develop/headers/glibc", System, false);
 AddPath("/boot/system/develop/headers/posix", System, false);
+#ifdef HAIKU_HYBRID_SECONDARY
+AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY, System, 
false);
+AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY "/os", 
System,
+false);
+AddPath("/boot/system/develop/headers/" HAIKU_HYBRID_SECONDARY 
"/os/opengl",
+System, false);
+#endif
 AddPath("/boot/system/develop/headers",  System, false);
 break;
   case llvm::Triple::RTEMS:
Index: lib/Driver/ToolChains/Haiku.cpp
===
--- lib/Driver/ToolChains/Haiku.cpp
+++ lib/Driver/ToolChains/Haiku.cpp
@@ -20,6 +20,13 @@
 Haiku::Haiku(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
   : Generic_ELF(D, Triple, Args) {
 
+#ifdef HAIKU_HYBRID_SECONDARY
+  getProgramPaths().insert(getProgramPaths().begin(), getDriver().SysRoot
+   + "/system/bin/" HAIKU_HYBRID_SECONDARY);
+  getFilePaths().clear();
+  getFilePaths().push_back(getDriver().SysRoot + "/system/lib/"
+   HAIKU_HYBRID_SECONDARY);
+#endif
 }
 
 void Haiku::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
@@ -30,6 +37,13 @@
 
 void Haiku::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args) const {
+
+#ifdef HAIKU_HYBRID_SECONDARY
+  addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers"
+ HAIKU_HYBRID_SECONDARY "/c++", getTriple().str(), "", "", 
"",
+ DriverArgs, CC1Args);
+#else
   addLibStdCXXIncludePaths(getDriver().SysRoot, "/system/develop/headers/c++",
getTriple().str(), "", "", "", DriverArgs, CC1Args);
+#endif
 }
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -412,6 +412,10 @@
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")
 endif()
 
+if(DEFINED HAIKU_HYBRID_SECONDARY)
+  add_definitions(-DHAIKU_HYBRID_SECONDARY=${HAIKU_HYBRID_SECONDARY})
+endif()
+
 if(CLANG_ANALYZER_BUILD_Z3)
   find_package(Z3 4.5)
   if(Z3_FOUND)


Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -238,7 +238,19 @@
   if (HSOpts.UseBuiltinIncludes) {
 // Ignore the sys root, we *always* look for clang headers relative to
 // supplied path.
+#ifdef HAIKU_HYBRID_SECONDARY
+// Remove version from foo/lib/clang/version
+StringRef Ver = llvm::sys::path::filename(HSOpts.ResourceDir);
+StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
+// Remove clang from foo/lib/clang
+StringRef Clang = llvm::sys::path::filename(NoVer);
+SmallString<128> P = llvm::sys::path::parent_path(NoVer);
+
+// Get foo/include/c++/v1
+llvm::sys::path::append(P, HAIKU_HYBRID_SECOND

[PATCH] D49480: Haiku: support for secondary arch

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

Original author is "Jerome Duval "  I don't have 
permission to modify this, can author be updated? (I don't have permission to)


Repository:
  rC Clang

https://reviews.llvm.org/D49480



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


[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.

2018-07-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D49148#1165826, @echristo wrote:

> I think you should break it out on an option by option basis. Just warning on 
> "non-standard" options won't make as much sense to end users. Perhaps a "this 
> option is unsupported on the target you're compiling for" etc.
>
> Thoughts?




1. I can split it, no problems.
2. Hmm, actually this what the warning already says. If the option is not 
supported it says 'debug option '-xxx' is not supported for target 
'xxx-xxx-xxx''. It does not seem to me like a warning on non-standard option.


Repository:
  rC Clang

https://reviews.llvm.org/D49148



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


[PATCH] D49481: Haiku: Enable thread-local storage and disable PIE by default

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D49481

Files:
  lib/Basic/Targets/OSTargets.h
  lib/Driver/ToolChains/Haiku.h


Index: lib/Driver/ToolChains/Haiku.h
===
--- lib/Driver/ToolChains/Haiku.h
+++ lib/Driver/ToolChains/Haiku.h
@@ -23,9 +23,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);

-  bool isPIEDefault() const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPIEDefault() const override { return false; }

   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -266,7 +266,6 @@
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
   }
 };



Index: lib/Driver/ToolChains/Haiku.h
===
--- lib/Driver/ToolChains/Haiku.h
+++ lib/Driver/ToolChains/Haiku.h
@@ -23,9 +23,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);

-  bool isPIEDefault() const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPIEDefault() const override { return false; }

   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -266,7 +266,6 @@
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
   }
 };

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


[PATCH] D49481: Haiku: Enable thread-local storage and disable PIE by default

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

The original author is "Jerome Duval " I don't have 
permission to modify this, can the author be updated?


Repository:
  rC Clang

https://reviews.llvm.org/D49481



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


[PATCH] D49482: Haiku: add a test for haiku driver

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D49482

Files:
  test/Driver/haiku.c


Index: test/Driver/haiku.c
===
--- /dev/null
+++ test/Driver/haiku.c
@@ -0,0 +1,11 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-haiku %s -### 2> 
%t.log
+// RUN: FileCheck --check-prefix=CHECK-X86_64 -input-file %t.log %s
+
+// CHECK-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-haiku"
+// CHECK-X86_64: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes -target i586-pc-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86 -input-file %t.log %s
+
+// CHECK-X86: clang{{.*}}" "-cc1" "-triple" "i586-pc-haiku"
+// CHECK-X86: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"


Index: test/Driver/haiku.c
===
--- /dev/null
+++ test/Driver/haiku.c
@@ -0,0 +1,11 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86_64 -input-file %t.log %s
+
+// CHECK-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-haiku"
+// CHECK-X86_64: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes -target i586-pc-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86 -input-file %t.log %s
+
+// CHECK-X86: clang{{.*}}" "-cc1" "-triple" "i586-pc-haiku"
+// CHECK-X86: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49482: Haiku: add a test for haiku driver

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

Original author is "Jerome Duval "  I don't have 
permission to modify this, can author be updated?


Repository:
  rC Clang

https://reviews.llvm.org/D49482



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-07-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Just added a new entry to our roadmap: 
https://github.com/Ericsson/clang/issues/435


Repository:
  rC Clang

https://reviews.llvm.org/D30691



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-07-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

@NoQ , @dkrupp

CallEvent::getRuntimeDefinition is overwritten in

- AnyFunctionCall
- CXXInstanceCall
- CXXMemberCall
- CXXDestructorCall
- ObjCMethodCall

AnyFunctionCall handles the CTU logic.
CXXInstanceCall calls into AnyFunctionCall if the function is not virtual.
If the function is virtual then we try to find the Decl of it via the dynamic 
type info.
At this point, we could get the definition of that function via the CTU logic, 
indeed.
This is something we should implement in the future.

However, it seems like this is the only case (not considering ObjC).
CXXMemberCall calls back to AnyFunctionCall or to CXXInstanceCall.
CXXDestructorCall does the same.


Repository:
  rC Clang

https://reviews.llvm.org/D30691



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


[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Map/Reduce change looks good to me.




Comment at: clang-tools-extra/test/clang-doc/yaml-record.cpp:44
+// CHECK-0: ---
+// CHECK-0-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-0-NEXT: Name:'C'

> Yes, in most regex worlds, but it doesn't work in FileCheck regex (complains 
> about unbalanced braces).
Forgot this was `FileCheck` ;) Have you tried `[0-9A-Z]{{n}}`? If nothing 
works, I'd probably just  check length of one USR and use `{{.*}}` to match the 
rest of USRs in all tests.


https://reviews.llvm.org/D48341



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


[PATCH] D47196: [Time-report ](2): Recursive timers in Clang

2018-07-18 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 updated this revision to Diff 156064.
avt77 added a comment.

I added required comments and did the required changes.


https://reviews.llvm.org/D47196

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.h
  include/clang/Frontend/Utils.h
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendTiming.cpp
  lib/Parse/CMakeLists.txt
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  test/Frontend/ftime-report-template-decl.cpp
  test/Headers/opencl-c-header.cl

Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -71,4 +71,5 @@
 }
 #endif //__OPENCL_C_VERSION__
 
-// CHECK-MOD: Reading modules
+// CHECK-DAG-MOD: Clang Timers: CodeGen Functions
+// CHECK-DAG-MOD: Reading modules
Index: test/Frontend/ftime-report-template-decl.cpp
===
--- test/Frontend/ftime-report-template-decl.cpp
+++ test/Frontend/ftime-report-template-decl.cpp
@@ -3,9 +3,15 @@
 
 // Template function declarations
 template 
-void foo();
+T foo(T bar) {
+  T Result = bar * bar + bar / 1.2 + bar;
+  return Result;
+};
 template 
-void foo();
+T foo(T bar, U bar2) {
+  T Result = bar2 * bar + bar / 1.2 + bar2;
+  return Result;
+};
 
 // Template function definitions.
 template 
@@ -130,9 +136,15 @@
 template 
 oneT L<0>::O::Fun(U) { return one; }
 
-void Instantiate() {
+double Instantiate() {
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
+  int R1 = foo(123) + foo(177.2) - foo(331.442);
+  char R2 = foo('d', 1234) * foo(1.26);
+  int R3 = foo(1.2) + foo(11.22) / foo(66.77);
+  double R4 = foo(34.56, 1234);
+  double R5 = R1 + R2 * R3 - R4 + one[0] * foo(15.52) - two[1] / foo(51.25);
+  return R5 * R1 + R4 / R3 + R2;
 }
 }
 
@@ -150,7 +162,10 @@
 };
 _Wrap_alloc::rebind w;
 
-// CHECK: Miscellaneous Ungrouped Timers
+// FIXME:  We need more complex test to increase the compilation time;
+// otherwise we see the foolowing message from time to time only.
+// VIOLATILE-CHECK: Clang Timers: CodeGen Functions
+// CHECK-DAG: Miscellaneous Ungrouped Timers
 // CHECK-DAG: LLVM IR Generation Time
 // CHECK-DAG: Code Generation Time
 // CHECK: Total
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -27,6 +27,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtOpenMP.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Ownership.h"
@@ -11002,6 +11003,14 @@
 
   LSI->CallOperator = NewCallOperator;
 
+  if (FrontendTimesIsEnabled) {
+// At this point we're sure we're dealing with some function that's why
+// we're starting the corresponding time slice. We'll stop it in
+// Sema::ActOnFinishFunctionBody.
+getFrontendFunctionTimeCtx()->startFrontendTimer(
+{NewCallOperator, 0.0});
+  }
+
   for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
I != NumParams; ++I) {
 auto *P = NewCallOperator->getParamDecl(I);
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -10,17 +10,18 @@
 //  This file implements semantic analysis for C++ lambda expressions.
 //
 //===--===//
-#include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/SemaLambda.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
-#include "clang/Sema/SemaLambda.h"
 using namespace clang;
 using namespace sema;
 
@@ -1437,6 +1438,14 @@
 ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, 
  Scope *CurScope) {
   LambdaScopeInfo LSI = *cast(FunctionScopes.back());
+
+  if (FrontendTimesIsEnabled) {
+// We're dealing with lambda-function that's why we're starting
+// the corresponding time slice. It will be finished in
+// ActOnFinishFunctionBody.
+getFrontendFunctionTimeCtx()->startFrontendTimer(
+{LSI.CallOperator, 0.0});
+  }
   ActOnFinishFunctionBody(LSI.CallOperator, Body);
   return BuildLambdaExpr(StartLoc, Body->getLocEnd(), &LSI);
 }
Index: lib/Sema/SemaDecl.cpp
==

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 156068.
erichkeane marked 13 inline comments as done.
erichkeane added a comment.

All of @aaron.ballman s comments have been dealt with except for Cpus->CPUs in 
the Attr.td file for explained reasons. Still negotiable :)


https://reviews.llvm.org/D47474

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/X86Target.def
  lib/AST/Decl.cpp
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGen/attr-cpuspecific.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-cpuspecific.c
  test/SemaCXX/attr-cpuspecific.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1173,6 +1173,13 @@
 }
   };
 
+  class VariadicIdentifierArgument : public VariadicArgument {
+  public:
+VariadicIdentifierArgument(const Record &Arg, StringRef Attr)
+  : VariadicArgument(Arg, Attr, "IdentifierInfo *")
+{}
+  };
+
   class VariadicStringArgument : public VariadicArgument {
   public:
 VariadicStringArgument(const Record &Arg, StringRef Attr)
@@ -1278,6 +1285,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "ParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr, "ParamIdx");
+  else if (ArgName == "VariadicIdentifierArgument")
+Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
 
@@ -2106,6 +2115,34 @@
 .Default(false);
 }
 
+static bool isVariadicIdentifierArgument(Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ .Case("VariadicIdentifierArgument", true)
+ .Default(false);
+}
+
+static void emitClangAttrVariadicIdentifierArgList(RecordKeeper &Records,
+   raw_ostream &OS) {
+  OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n";
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+  for (const auto *A : Attrs) {
+// Determine whether the first argument is a variadic identifier.
+std::vector Args = A->getValueAsListOfDefs("Args");
+if (Args.empty() || !isVariadicIdentifierArgument(Args[0]))
+  continue;
+
+// All these spellings take an identifier argument.
+forEachUniqueSpelling(*A, [&](const FlattenedSpelling &S) {
+  OS << ".Case(\"" << S.name() << "\", "
+ << "true"
+ << ")\n";
+});
+  }
+  OS << "#endif // CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST\n\n";
+}
+
 // Emits the first-argument-is-identifier property for attributes.
 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
@@ -3697,6 +3734,7 @@
   emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
   emitClangAttrArgContextList(Records, OS);
   emitClangAttrIdentifierArgList(Records, OS);
+  emitClangAttrVariadicIdentifierArgList(Records, OS);
   emitClangAttrTypeArgList(Records, OS);
   emitClangAttrLateParsedList(Records, OS);
 }
Index: test/SemaCXX/attr-cpuspecific.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-cpuspecific.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+
+// expected-error@+1{{invalid option 'invalid' for cpu_dispatch}}
+void __attribute__((cpu_dispatch(atom, invalid))) invalid_cpu();
+
+void __attribute__((cpu_specific(atom))) no_default(void);
+void __attribute__((cpu_specific(sandybridge)))  no_default(void);
+
+struct MVReference {
+  int __attribute__((cpu_specific(sandybridge))) bar(void);
+  int __attribute__((cpu_specific(ivybridge))) bar(void);
+  int __attribute__((cpu_specific(sandybridge))) foo(void);
+};
+
+void use1(void){
+  // OK, will fail in the linker, unless another TU provides the cpu_dispatch.
+  no_default();
+
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::bar;
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::foo;
+  // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call 

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.







Comment at: include/clang/AST/Decl.h:2212-2213
 
+  bool isCpuDispatchMultiVersion() const;
+  bool isCpuSpecificMultiVersion() const;
+

aaron.ballman wrote:
> aaron.ballman wrote:
> > Pedantic nit: CPU instead of Cpu?
> Thoughts on `isCPUDispatchMultiVersion()` instead of 
> `isCpuDispatchMultiVersion()`?
Well, I can definitely switch it back if CPU is your preference.  Looking at 
it, we're probably about 75/25 in our codebase preferring CPU, so I prefer it 
as well.



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [Clang<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> `Cpus` -> `CPUs` ?
So, I agree with you we should be consistent with spelling.  However, in this 
case, I'd prefer not changing this one.  This is what the generated code in 
Attrs.inc looks like if I change it:

typedef IdentifierInfo ** cPUs_iterator;
cPUs_iterator cPUs_begin() const { return cPUs_; }
cPUs_iterator cPUs_end() const { return cPUs_ + cPUs_Size; }
unsigned cPUs_size() const { return cPUs_Size; }
llvm::iterator_range cPUs() const { return 
llvm::make_range(cPUs_begin(), cPUs_end()); }

I think having "Cpus" in 2 places is way better than having to spell it as 
cPUs_begin.  Your thoughts?



Comment at: lib/Sema/SemaOverload.cpp:9017
+
+return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName();
+  }

aaron.ballman wrote:
> If there's no mismatch, doesn't this wind up dereferencing the end iterator 
> of the range?
Yikes, you're right!  However, that would require 2 declarations to have 
identical cpu_specific lists, which is against the rules previously enforced.  
I've put an assert in here to ensure that never happens.


https://reviews.llvm.org/D47474



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


[PATCH] D49484: [CodeComplete] Allow getDeclaration on RK_Pattern result.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
Herald added a subscriber: cfe-commits.

RK_Pattern results can also have associated declarations e.g. field
decls in constructor initializers.


Repository:
  rC Clang

https://reviews.llvm.org/D49484

Files:
  include/clang/Sema/CodeCompleteConsumer.h


Index: include/clang/Sema/CodeCompleteConsumer.h
===
--- include/clang/Sema/CodeCompleteConsumer.h
+++ include/clang/Sema/CodeCompleteConsumer.h
@@ -895,9 +895,11 @@
 computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-assert(Kind == RK_Declaration && "Not a declaration result");
+assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+   "Not a declaration or pattern result");
 return Declaration;
   }
 


Index: include/clang/Sema/CodeCompleteConsumer.h
===
--- include/clang/Sema/CodeCompleteConsumer.h
+++ include/clang/Sema/CodeCompleteConsumer.h
@@ -895,9 +895,11 @@
 computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-assert(Kind == RK_Declaration && "Not a declaration result");
+assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+   "Not a declaration or pattern result");
 return Declaration;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49480: Haiku: support for secondary arch

2018-07-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg requested changes to this revision.
joerg added a comment.
This revision now requires changes to proceed.

This is absolutely not how the clang driver is supposed to work. No conditional 
compilation.


Repository:
  rC Clang

https://reviews.llvm.org/D49480



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


[PATCH] D49482: Haiku: add a test for haiku driver

2018-07-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

It seems to miss most of the interesting checks, i.e. crt files. Compare with 
any of the entries on netbsd.c for example.


Repository:
  rC Clang

https://reviews.llvm.org/D49482



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


[PATCH] D49486: [cfe][CMake] Export the clang resource directory

2018-07-18 Thread Philip Pfaffe via Phabricator via cfe-commits
philip.pfaffe created this revision.
philip.pfaffe added reviewers: mgorny, beanz, gottesmm.
Herald added a subscriber: bollu.

Out-of-tree tools trying to parse source files need the builtin headers
such as `stddef.h`. If the tool isn't installed together with clang, it
can't find them automatically. Exporting the location makes this much
easier.

(Resubmitting because I've subscribed the wrong list, sorry for the noise).


https://reviews.llvm.org/D49486

Files:
  clang/cmake/modules/CMakeLists.txt
  clang/cmake/modules/ClangConfig.cmake.in


Index: clang/cmake/modules/ClangConfig.cmake.in
===
--- clang/cmake/modules/ClangConfig.cmake.in
+++ clang/cmake/modules/ClangConfig.cmake.in
@@ -8,6 +8,7 @@
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 set(CLANG_INCLUDE_DIRS "@CLANG_CONFIG_INCLUDE_DIRS@")
+set(CLANG_RESOURCE_DIR "@CLANG_CONFIG_RESOURCE_DIR@")
 
 # Provide all our library targets to users.
 include("@CLANG_CONFIG_EXPORTS_FILE@")
Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -19,6 +19,13 @@
   "${CLANG_SOURCE_DIR}/include"
   "${CLANG_BINARY_DIR}/include"
   )
+if (CLANG_RESOURCE_DIR)
+  set(CLANG_CONFIG_RESOURCE_DIR ${CLANG_RESOURCE_DIR})
+else()
+  set(CLANG_CONFIG_RESOURCE_DIR
+${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+endif()
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake


Index: clang/cmake/modules/ClangConfig.cmake.in
===
--- clang/cmake/modules/ClangConfig.cmake.in
+++ clang/cmake/modules/ClangConfig.cmake.in
@@ -8,6 +8,7 @@
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 set(CLANG_INCLUDE_DIRS "@CLANG_CONFIG_INCLUDE_DIRS@")
+set(CLANG_RESOURCE_DIR "@CLANG_CONFIG_RESOURCE_DIR@")
 
 # Provide all our library targets to users.
 include("@CLANG_CONFIG_EXPORTS_FILE@")
Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -19,6 +19,13 @@
   "${CLANG_SOURCE_DIR}/include"
   "${CLANG_BINARY_DIR}/include"
   )
+if (CLANG_RESOURCE_DIR)
+  set(CLANG_CONFIG_RESOURCE_DIR ${CLANG_RESOURCE_DIR})
+else()
+  set(CLANG_CONFIG_RESOURCE_DIR
+${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+endif()
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49484: [CodeComplete] Allow getDeclaration on RK_Pattern result.

2018-07-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rC Clang

https://reviews.llvm.org/D49484



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


[PATCH] D49302: [AST] Various micro-optimizations in CXXInheritance

2018-07-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

cool


Repository:
  rC Clang

https://reviews.llvm.org/D49302



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


[PATCH] D49274: [CUDA] Provide integer SIMD functions for CUDA-9.2

2018-07-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Headers/__clang_cuda_device_functions.h:1080
+  unsigned int r;
+  asm("vabsdiff2.u32.u32.u32.sat %0,%1,%2,0;" : "=r"(r) : "r"(__a), "r"(__b));
+  return r;

Should this really saturate?



Comment at: clang/lib/Headers/__clang_cuda_device_functions.h:1095
+  unsigned int r;
+  asm("vabsdiff2.s32.s32.s32.sat %0,%1,0,0;" : "=r"(r) : "r"(__a));
+  return r;

vabsdiff4?


https://reviews.llvm.org/D49274



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


[PATCH] D49417: [clangd] Implement trigram generation algorithm for new symbol index

2018-07-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz updated this revision to Diff 156073.
omtcyfz marked 11 inline comments as done.
omtcyfz added a comment.

Addressed all comments by Eric.

As discussed internally, I should also exercise my naming skills and come up 
with a better for the symbol index to substitute "Noctem" which doesn't point 
to any project's feature.


https://reviews.llvm.org/D49417

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/noctem/SearchToken.cpp
  clang-tools-extra/clangd/index/noctem/SearchToken.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/NoctemIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/NoctemIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/NoctemIndexTests.cpp
@@ -0,0 +1,95 @@
+//===-- NoctemIndexTests.cpp  -*- C++ -*---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "index/noctem/SearchToken.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace noctem {
+
+std::vector>
+toSmallStrings(const std::vector Strings) {
+  std::vector> Result(Strings.size());
+  for (size_t Index = 0; Index < Strings.size(); ++Index) {
+Result[Index] = Strings[Index];
+  }
+  return Result;
+}
+
+std::vector
+getTrigrams(std::initializer_list Trigrams) {
+  std::vector Result;
+  for (const auto &Symbols : Trigrams) {
+Result.push_back(SearchToken(Symbols, SearchToken::Kind::Trigram));
+  }
+  return Result;
+}
+
+TEST(NoctemIndexTokens, TrigramSymbolNameTokenization) {
+  EXPECT_EQ(segmentIdentifier("unique_ptr"), toSmallStrings({"unique", "ptr"}));
+
+  EXPECT_EQ(segmentIdentifier("TUDecl"), toSmallStrings({"TU", "Decl"}));
+
+  EXPECT_EQ(segmentIdentifier("table_name_"),
+toSmallStrings({"table", "name"}));
+
+  EXPECT_EQ(segmentIdentifier("kDaysInAWeek"),
+toSmallStrings({"k", "Days", "In", "A", "Week"}));
+
+  EXPECT_EQ(segmentIdentifier("AlternateUrlTableErrors"),
+toSmallStrings({"Alternate", "Url", "Table", "Errors"}));
+
+  EXPECT_EQ(segmentIdentifier("IsOK"), toSmallStrings({"Is", "OK"}));
+
+  EXPECT_EQ(segmentIdentifier("ABSL_FALLTHROUGH_INTENDED"),
+toSmallStrings({"ABSL", "FALLTHROUGH", "INTENDED"}));
+
+  EXPECT_EQ(segmentIdentifier("SystemZ"), toSmallStrings({"System", "Z"}));
+
+  EXPECT_EQ(segmentIdentifier("X86"), toSmallStrings({"X86"}));
+
+  EXPECT_EQ(segmentIdentifier("ASTNodeKind"),
+toSmallStrings({"AST", "Node", "Kind"}));
+
+  EXPECT_EQ(segmentIdentifier("ObjCDictionaryElement"),
+toSmallStrings({"Obj", "C", "Dictionary", "Element"}));
+
+  EXPECT_EQ(segmentIdentifier("multiple__underscores___everywhere"),
+toSmallStrings({"multiple", "underscores", "everywhere"}));
+
+  EXPECT_EQ(segmentIdentifier("__cuda_builtin_threadIdx_t"),
+toSmallStrings({"cuda", "builtin", "thread", "Idx", "t"}));
+
+  EXPECT_EQ(segmentIdentifier("longUPPERCASESequence"),
+toSmallStrings({"long", "UPPERCASE", "Sequence"}));
+}
+
+TEST(NoctemIndexTrigrams, TrigramGeneration) {
+  EXPECT_EQ(
+  generateTrigrams("a_b_c_d_e_"),
+  getTrigrams({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"}));
+
+  EXPECT_EQ(generateTrigrams("clangd"),
+getTrigrams({"cla", "lan", "ang", "ngd"}));
+
+  EXPECT_EQ(generateTrigrams("abc_def"),
+getTrigrams({"abc", "def", "abd", "ade", "bcd", "bde", "cde"}));
+
+  EXPECT_EQ(generateTrigrams("unique_ptr"),
+getTrigrams({"uni", "niq", "iqu", "que", "ptr", "unp", "upt", "nip",
+ "npt", "iqp", "ipt", "qup", "qpt", "uep", "ept"}));
+
+  EXPECT_EQ(generateTrigrams("nl"), getTrigrams({}));
+}
+
+} // namespace noctem
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/unittests/clangd/CMakeLists.txt
===
--- clang-tools-extra/unittests/clangd/CMakeLists.txt
+++ clang-tools-extra/unittests/clangd/CMakeLists.txt
@@ -23,6 +23,7 @@
   GlobalCompilationDatabaseTests.cpp
   HeadersTests.cpp
   IndexTests.cpp
+  NoctemIndexTests.cpp
   QualityTests.cpp
   SourceCodeTests.cpp
   SymbolCollectorTests.cpp
Index: clang-tools-extra/clangd/index/noctem/SearchToken.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/noctem/SearchToken.h
@@ -0,0 +1,194 @@
+//===--- SearchToken.h- Symbol Search primitive --*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See L

[PATCH] D49480: Haiku: support for secondary arch

2018-07-18 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

No worries. I was wondering if this one would match llvm's goals.
Do you see any iteration of these changes that would be accepted? (not using 
define's, etc)

We currently support "hybrid" operating system builds where we compile a 
secondary toolchain / abi.

An current functional example of this is we offer a gcc2 compiler + support 
libraries, and then also offer a gcc7 compiler + support libraries.

  $ getarch
  x86_gcc2
  $ gcc --version
  ~gcc 2.95
  $ gcc test.c -o test
  $ ./test
  
  test is a functional binary generated by gcc2 and run using the gcc2 ABI + 
libraries.
  
  
  $ setarch x86
  $ getarch
  x86
  $ gcc --version
  ~gcc 7.3
  $ gcc test.c -o test
  $ ./test
  
  test is now a functional binary generated by gcc7 and run using the gcc7 
ABI's + libraries


Repository:
  rC Clang

https://reviews.llvm.org/D49480



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


[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:444
+auto HandleValue =
+CtorBuilder.CreateAlignedLoad(GpuBinaryHandle, CGM.getPointerAlign());
+llvm::Constant *Zero = 
llvm::Constant::getNullValue(HandleValue->getType());

rjmccall wrote:
> Do you not need to worry about concurrency here?
The ctor functions are executed by the dynamic loader before the program gains 
the control. The dynamic loader cannot excute the ctor functions concurrently 
since doing that would not gurantee thread safety of the loaded program. 
Therefore we can assume sequential execution of ctor functions here.


https://reviews.llvm.org/D49083



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-07-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Aha, cool, so it's probably just virtual functions.


Repository:
  rC Clang

https://reviews.llvm.org/D30691



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


r337394 - [CodeComplete] Allow getDeclaration on RK_Pattern result.

2018-07-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Jul 18 08:17:52 2018
New Revision: 337394

URL: http://llvm.org/viewvc/llvm-project?rev=337394&view=rev
Log:
[CodeComplete] Allow getDeclaration on RK_Pattern result.

Summary:
RK_Pattern results can also have associated declarations e.g. field
decls in constructor initializers.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=337394&r1=337393&r2=337394&view=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Wed Jul 18 08:17:52 2018
@@ -895,9 +895,11 @@ public:
 computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-assert(Kind == RK_Declaration && "Not a declaration result");
+assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+   "Not a declaration or pattern result");
 return Declaration;
   }
 


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


[PATCH] D49484: [CodeComplete] Allow getDeclaration on RK_Pattern result.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337394: [CodeComplete] Allow getDeclaration on RK_Pattern 
result. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49484

Files:
  cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h


Index: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
===
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
@@ -895,9 +895,11 @@
 computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-assert(Kind == RK_Declaration && "Not a declaration result");
+assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+   "Not a declaration or pattern result");
 return Declaration;
   }
 


Index: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
===
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
@@ -895,9 +895,11 @@
 computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-assert(Kind == RK_Declaration && "Not a declaration result");
+assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+   "Not a declaration or pattern result");
 return Declaration;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49481: Haiku: Enable thread-local storage and disable PIE by default

2018-07-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg requested changes to this revision.
joerg added a comment.
This revision now requires changes to proceed.

Both needs a test case :)


Repository:
  rC Clang

https://reviews.llvm.org/D49481



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


[clang-tools-extra] r337396 - [clangd] Also get scope for RK_pattern completion results.

2018-07-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Jul 18 08:31:14 2018
New Revision: 337396

URL: http://llvm.org/viewvc/llvm-project?rev=337396&view=rev
Log:
[clangd] Also get scope for RK_pattern completion results.

For exmaple, clas field candidates in constructor initializers can be
RK_Pattern, but they can still have scopes.

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=337396&r1=337395&r2=337396&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed Jul 18 08:31:14 2018
@@ -270,12 +270,14 @@ struct CodeCompletionBuilder {
 if (C.SemaResult) {
   Completion.Origin |= SymbolOrigin::AST;
   Completion.Name = llvm::StringRef(SemaCCS->getTypedText());
-  if (Completion.Scope.empty())
-if (C.SemaResult->Kind == CodeCompletionResult::RK_Declaration)
+  if (Completion.Scope.empty()) {
+if ((C.SemaResult->Kind == CodeCompletionResult::RK_Declaration) ||
+(C.SemaResult->Kind == CodeCompletionResult::RK_Pattern))
   if (const auto *D = C.SemaResult->getDeclaration())
 if (const auto *ND = llvm::dyn_cast(D))
   Completion.Scope =
   splitQualifiedName(printQualifiedName(*ND)).first;
+  }
   Completion.Kind =
   toCompletionItemKind(C.SemaResult->Kind, C.SemaResult->Declaration);
 }

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=337396&r1=337395&r2=337396&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Wed Jul 18 
08:31:14 2018
@@ -1309,6 +1309,18 @@ TEST(CompletionTest, IgnoreRecoveryResul
   EXPECT_THAT(Results.Completions, 
UnorderedElementsAre(Named("NotRecovered")));
 }
 
+TEST(CompletionTest, ScopeOfClassFieldInConstructorInitializer) {
+  auto Results = completions(
+  R"cpp(
+namespace ns {
+  class X { public: X(); int x_; };
+  X::X() : x_^(0) {}
+}
+  )cpp");
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Scope("ns::X::"), Named("x_";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D49294: Sema: Fix explicit address space cast in C++

2018-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:3150
+  !getLangOpts().OpenCLCPlusPlus)
+return false;
+

rjmccall wrote:
> It's not really OpenCL C++ that's special here, it's the possibility of 
> promotions between address spaces.
For OpenCL C++, there is language rule about address space promotion.

For other languages, there is no generic rule about adderss space promotion, 
since the meaning of address space and their relations are target dependent. Do 
we want to introduce a target hook Target::canPromote(AddressSpace Src, 
AddressSpace Dest, LanguageOptions LangOpts) to represent this? Or do we just 
assume a simple rule, that is, all address space can be promoted to default 
address space 0, otherwise it is not allowed?


https://reviews.llvm.org/D49294



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


[PATCH] D49492: Run bounds checking sanitizer earlier to make it easier to optimize away its checks.

2018-07-18 Thread Joel Galenson via Phabricator via cfe-commits
jgalenson created this revision.
jgalenson added reviewers: eugenis, chandlerc.
Herald added a subscriber: cfe-commits.

Running the bounds checking sanitizer earlier makes it easier for other 
optimizations to remove the checks it inserts. 
 While it could also inhibit other optimizations, I ran a few benchmarks and 
this did seem to improve performance and code size slightly.

Note that I'm not sure how to hook this up to the new PM, as I couldn't find a 
similar hook into the beginning of the pipeline.  Are there any suggestions on 
what to do about that, or is it fine for this to work just on the old PM?


Repository:
  rC Clang

https://reviews.llvm.org/D49492

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/bounds-checking-opt.c


Index: test/CodeGen/bounds-checking-opt.c
===
--- /dev/null
+++ test/CodeGen/bounds-checking-opt.c
@@ -0,0 +1,20 @@
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target x86_64-- %s -o - 
| FileCheck -check-prefix=O0 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target x86_64-- -O2 %s 
-o - | FileCheck -check-prefix=O2 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target aarch64-- %s -o - 
| FileCheck -check-prefix=O0 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target aarch64-- -O2 %s 
-o - | FileCheck -check-prefix=O2 %s
+
+extern void fill(int *arr);
+
+// CHECK-LABEL: @f
+int f(int x) {
+  // O0: call {{.*}} @llvm.trap
+  // O2-NOT: call {{.*}} @llvm.trap
+  int foo[1000];
+  fill(foo);
+  int sum = 0;
+  #pragma clang loop vectorize(disable)
+  #pragma clang loop unroll(disable)
+  for (unsigned i = 0; i < 1000; i++)
+sum += foo[i];
+  return sum;
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -562,7 +562,7 @@
 addCoroutinePassesToExtensionPoints(PMBuilder);
 
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) {
-PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
addBoundsCheckingPass);
 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
addBoundsCheckingPass);


Index: test/CodeGen/bounds-checking-opt.c
===
--- /dev/null
+++ test/CodeGen/bounds-checking-opt.c
@@ -0,0 +1,20 @@
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target x86_64-- %s -o - | FileCheck -check-prefix=O0 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target x86_64-- -O2 %s -o - | FileCheck -check-prefix=O2 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target aarch64-- %s -o - | FileCheck -check-prefix=O0 %s
+// RUN: %clang -S -fsanitize=local-bounds -emit-llvm -target aarch64-- -O2 %s -o - | FileCheck -check-prefix=O2 %s
+
+extern void fill(int *arr);
+
+// CHECK-LABEL: @f
+int f(int x) {
+  // O0: call {{.*}} @llvm.trap
+  // O2-NOT: call {{.*}} @llvm.trap
+  int foo[1000];
+  fill(foo);
+  int sum = 0;
+  #pragma clang loop vectorize(disable)
+  #pragma clang loop unroll(disable)
+  for (unsigned i = 0; i < 1000; i++)
+sum += foo[i];
+  return sum;
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -562,7 +562,7 @@
 addCoroutinePassesToExtensionPoints(PMBuilder);
 
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) {
-PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
+PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
addBoundsCheckingPass);
 PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
addBoundsCheckingPass);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49058: [analyzer] Move DanglingInternalBufferChecker out of alpha

2018-07-18 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

Two more reports on Ceph that seem to be true positives (no other reports from 
this checker):

1. Here  (or if it does not work, the bug is on L130 
here ).
2. Here  (or L363 and L373 here 
).


https://reviews.llvm.org/D49058



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


[PATCH] D49274: [CUDA] Provide integer SIMD functions for CUDA-9.2

2018-07-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I'm in the middle of writing the tests for these as it's very easy to mess 
things up. I'll update the patch once I run it through the tests.

Another problem with the patch in the current form is that these instructions 
apparently do not accept immediate arguments. PTX is a never ending source of 
surprises...


https://reviews.llvm.org/D49274



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


[PATCH] D46190: For a used declaration, mark any associated usings as referenced.

2018-07-18 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

A bunch of style comments.  Maybe try clang-format-diff.




Comment at: include/clang/Sema/SemaInternal.h:91
   Var->markUsed(SemaRef.Context);
+  SemaRef.MarkUsingReferenced(Var, Loc, /*CXXScopeSpec*=*/nullptr, RefExpr);
 }

The comments on a nullptr parameter usually use the formal parameter name, not 
its type.



Comment at: lib/Sema/SemaDeclCXX.cpp:15549
+  R.setAddUsingDirectives();
+  LookupName(R,getCurScope());
+

Space after the comma.



Comment at: lib/Sema/SemaDeclCXX.cpp:15554
+
+  for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I) {
+NamedDecl *D = (*I)->getUnderlyingDecl();

Could this be a range-based for loop?



Comment at: lib/Sema/SemaDeclCXX.cpp:15566
+// Check if the declaration was introduced by a 'using-directive'.
+if (auto *UDir = dyn_cast(D))
+  if (UDir->getNominatedNamespace() == Target) {

else if



Comment at: lib/Sema/SemaExpr.cpp:14460
   Func->markUsed(Context);
+  MarkUsingReferenced(Func, Loc, /*CXXScopeSpec*=*/nullptr, E);
 }

Parameter comments usually use the formal parameter name, not its type.



Comment at: lib/Sema/SemaExpr.cpp:15374
+  SemaRef.MarkAnyDeclReferenced(Loc, D, MightBeOdrUse,
+/*CXXScopeSpec*=*/nullptr, E);
 

Parameter comments usually use the formal parameter name, not its type.



Comment at: lib/Sema/SemaExpr.cpp:15396
+SemaRef.MarkAnyDeclReferenced(Loc, DM, MightBeOdrUse,
+  /*CXXScopeSpec*=*/nullptr, E);
 }

Parameter comments usually use the formal parameter name, not its type.



Comment at: lib/Sema/SemaLookup.cpp:196
+void addUsingDirective(LookupResult &R) {
+  for (auto I = usings.begin(), E = usings.end(); I != E; ++I)
+R.addDecl((*I));

Can this be a range-based for loop?



Comment at: lib/Sema/SemaLookup.cpp:1064
+static void
+AddUsingDirectives(LookupResult &R,UnqualUsingDirectiveSet &UDirs) {
+  if (R.isAddUsingDirectives())

Space after the comma.
`UDirs` has a different meaning elsewhere in this file, maybe `UsingDirs` 
instead?



Comment at: lib/Sema/SemaLookup.cpp:1236
 UDirs.done();
+AddUsingDirectives(R,UDirs);
 

Space after the comma.



Comment at: lib/Sema/SemaLookup.cpp:1277
 UDirs.done();
+AddUsingDirectives(R,UDirs);
   }

Space after the comma.


https://reviews.llvm.org/D46190



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-mapand -ffile-prefix-map

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/Lex/Preprocessor.h:155
+  /// A prefix map for __FILE__ and __BASEFILE__
+  llvm::SmallDenseMap MacroPrefixMap;
+

Scrolling back up, put this implementation as close to the debug implementation 
as you can, they are so ridiculously related that having them far enough apart 
that future changes could cause them to divert is troublesome to me.



Comment at: include/clang/Lex/PreprocessorOptions.h:171
+  /// A prefix map for __FILE__ and __BASEFILE__
+  std::map MacroPrefixMap;
+

It seems this can be StringRefs as well.



Comment at: lib/Driver/ToolChains/Clang.cpp:617
+  }
   for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
 StringRef Map = A->getValue();

filtered can take multiple options, you should be able to not add anything here 
except adding OPT_ffile_prefix_map_EQ to the filtered line, plus a ternary in 
the Diag line.



Comment at: lib/Driver/ToolChains/Clang.cpp:628
+/// Add a CC1 option to specify the macro file path prefix map.
+static void addMacroPrefixMapArg(const Driver &D, const ArgList &Args, 
ArgStringList &CmdArgs) {
+  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ)) {

See advice above.

Additionally/alternatively, I wonder if these two functions could be trivially 
combined.



Comment at: lib/Driver/ToolChains/Clang.cpp:1255
+
+  addMacroPrefixMapArg(D, Args, CmdArgs);
 }

Is there a good reason for this to not live with the call to 
addDebugPrefixMapArg?



Comment at: lib/Frontend/CompilerInvocation.cpp:2848
 
+  for (const auto &A : Args.getAllArgValues(OPT_fmacro_prefix_map_EQ))
+  {

Again, this is so much like the debug-prefix otpion, it should probably just be 
right next to it.

Additionally, we don't use curley brackets on single-line bodies.



Comment at: lib/Lex/PPMacroExpansion.cpp:1457
+static std::string remapMacroPath(StringRef Path,
+   llvm::SmallDenseMap &MacroPrefixMap) {

make MacroPrefixMap const.



Comment at: lib/Lex/PPMacroExpansion.cpp:1528
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
-SmallString<128> FN;
+std::string FN;
 if (PLoc.isValid()) {

This change shouldn't be necessary, SmallString is still likely the right 
answer here.



Comment at: lib/Lex/Preprocessor.cpp:160
+
+  for (const auto &KV : this->PPOpts->MacroPrefixMap)
+MacroPrefixMap[KV.first] = KV.second;

I'm unconvinced that this is necessary.  ExpandBuiltinMacro is in Preprocessor, 
so it has access to PPOpts directly.


Repository:
  rC Clang

https://reviews.llvm.org/D49466



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


[PATCH] D48862: [OpenEmbedded] Fix lib paths for OpenEmbedded targets

2018-07-18 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Ping 3 for reviews please.


https://reviews.llvm.org/D48862



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


[libcxx] r337406 - Update the synopsis for for C++20. No functional change.

2018-07-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jul 18 10:37:51 2018
New Revision: 337406

URL: http://llvm.org/viewvc/llvm-project?rev=337406&view=rev
Log:
Update the synopsis for  for C++20. No functional change.


Modified:
libcxx/trunk/include/chrono

Modified: libcxx/trunk/include/chrono
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=337406&r1=337405&r2=337406&view=diff
==
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Wed Jul 18 10:37:51 2018
@@ -147,6 +147,11 @@ template  struct is_clock;  // C++20
+template inline constexpr bool is_clock_v = is_clock::value;   // 
C++20
+
+
 // duration arithmetic
 template 
   constexpr
@@ -204,6 +209,8 @@ template 
 constexpr ToDuration round(const duration& d);// C++17
 
+// duration I/O is elsewhere
+
 // time_point arithmetic (all constexpr in C++14)
 template 
   time_point>::type>
@@ -251,6 +258,7 @@ template 
 constexpr duration abs(duration d);  // C++17
+
 // Clocks
 
 class system_clock
@@ -267,6 +275,28 @@ public:
 static time_point from_time_t(time_t __t) noexcept;
 };
 
+template 
+  using sys_time  = time_point; // C++20
+using sys_seconds = sys_time;  // C++20
+using sys_days= sys_time; // C++20
+
+class utc_clock;// C++20
+
+template 
+  using utc_time  = time_point;// C++20
+using utc_seconds = utc_time;  // C++20
+
+class tai_clock;// C++20
+
+template 
+  using tai_time  = time_point;// C++20
+using tai_seconds = tai_time;  // C++20
+
+class file_clock;   // C++20
+
+template
+  using file_time = time_point;   // C++20
+
 class steady_clock
 {
 public:
@@ -281,8 +311,466 @@ public:
 
 typedef steady_clock high_resolution_clock;
 
+// 25.7.8, local time   // C++20
+struct local_t {};
+template
+  using local_time  = time_point;
+using local_seconds = local_time;
+using local_days= local_time;
+
+// 25.7.9, time_point conversions template 
   // C++20
+struct clock_time_conversion;
+
+template
+  auto clock_cast(const time_point& t);
+  
+// 25.8.2, class last_spec// C++20
+struct last_spec;
+
+// 25.8.3, class day  // C++20
+
+class day;
+constexpr bool operator==(const day& x, const day& y) noexcept;
+constexpr bool operator!=(const day& x, const day& y) noexcept;
+constexpr bool operator< (const day& x, const day& y) noexcept;
+constexpr bool operator> (const day& x, const day& y) noexcept;
+constexpr bool operator<=(const day& x, const day& y) noexcept;
+constexpr bool operator>=(const day& x, const day& y) noexcept;
+constexpr day  operator+(const day&  x, const days& y) noexcept;
+constexpr day  operator+(const days& x, const day&  y) noexcept;
+constexpr day  operator-(const day&  x, const days& y) noexcept;
+constexpr days operator-(const day&  x, const day&  y) noexcept;
+
+// 25.8.4, class month// C++20
+class month;
+constexpr bool operator==(const month& x, const month& y) noexcept;
+constexpr bool operator!=(const month& x, const month& y) noexcept;
+constexpr bool operator< (const month& x, const month& y) noexcept;
+constexpr bool operator> (const month& x, const month& y) noexcept;
+constexpr bool operator<=(const month& x, const month& y) noexcept;
+constexpr bool operator>=(const month& x, const month& y) noexcept;
+constexpr month  operator+(const month&  x, const months& y) noexcept;
+constexpr month  operator+(const months& x,  const month& y) noexcept;
+constexpr month  operator-(const month&  x, const months& y) noexcept;
+constexpr months operator-(const month&  x,  const month& y) noexcept;
+
+// 25.8.5, class year// C++20
+class year;
+constexpr bool operator==(const year& x, const year& y) noexcept;
+constexpr bool operator!=(const year& x, const year& y) noexcept;
+constexpr bool operator< (const year& x, const year& y) noexcept;
+constexpr bool operator> (const year& x, const year& y) noexcept;
+constexpr bool operator<=(const year& x, const year& y) noexcept;
+constexpr bool operator>=(const year& x, const year& y) noexcept;
+constexpr year  operator+(const year&  x, const years& y) noexcept;
+constexpr year  operator+(const years& x, const year&  y) noexcept;
+constexpr year  operator-(const year&  x, const years& y) noexcept;
+constexpr years operator-(const year&  x, const year&  y) noexcept;
+
+// 25.8.6, class weekday// C++20
+class weekday;
+
+constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+constexpr weekday operator+(const weekday& x, const days&y) noexcept;
+constexpr weekday operator+(const days&x, const weekday& y) noexcept;
+constexpr weekday operator-(const weekday& x, const days&y) noexcept;
+constexpr daysoperator-(const weekday& x, cons

[PATCH] D49294: Sema: Fix explicit address space cast in C++

2018-07-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:3150
+  !getLangOpts().OpenCLCPlusPlus)
+return false;
+

yaxunl wrote:
> rjmccall wrote:
> > It's not really OpenCL C++ that's special here, it's the possibility of 
> > promotions between address spaces.
> For OpenCL C++, there is language rule about address space promotion.
> 
> For other languages, there is no generic rule about adderss space promotion, 
> since the meaning of address space and their relations are target dependent. 
> Do we want to introduce a target hook Target::canPromote(AddressSpace Src, 
> AddressSpace Dest, LanguageOptions LangOpts) to represent this? Or do we just 
> assume a simple rule, that is, all address space can be promoted to default 
> address space 0, otherwise it is not allowed?
A target-specific hook for handling target-specific address spaces makes sense 
to me.  I don't think there's a generic rule allowing promotion into the 
default AS.


https://reviews.llvm.org/D49294



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


[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:444
+auto HandleValue =
+CtorBuilder.CreateAlignedLoad(GpuBinaryHandle, CGM.getPointerAlign());
+llvm::Constant *Zero = 
llvm::Constant::getNullValue(HandleValue->getType());

yaxunl wrote:
> rjmccall wrote:
> > Do you not need to worry about concurrency here?
> The ctor functions are executed by the dynamic loader before the program 
> gains the control. The dynamic loader cannot excute the ctor functions 
> concurrently since doing that would not gurantee thread safety of the loaded 
> program. Therefore we can assume sequential execution of ctor functions here.
Okay.  That's worth a comment.

Is the name here specified by some ABI document, or is it just a conventional 
name that we're picking now?


https://reviews.llvm.org/D49083



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


[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.

2018-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D49148#1166429, @ABataev wrote:

> In https://reviews.llvm.org/D49148#1165826, @echristo wrote:
>
> > I think you should break it out on an option by option basis. Just warning 
> > on "non-standard" options won't make as much sense to end users. Perhaps a 
> > "this option is unsupported on the target you're compiling for" etc.
> >
> > Thoughts?
>
>
>
>
> 1. I can split it, no problems.
> 2. Hmm, actually this what the warning already says. If the option is not 
> supported it says 'debug option '-xxx' is not supported for target 
> 'xxx-xxx-xxx''. It does not seem to me like a warning on non-standard option.


Let me try to elaborate a bit, I agree that I'm not very clear above.

I'm not a fan of the generic "non default debug options". It feels misleading. 
I think we probably want to separate it by "dwarf extensions", and "dwarf 
version".

As far as the error message itself: "debug option" sounds like an option to 
debug clang rather than a debug information option. Perhaps say "debug 
information option" rather than "debug option"?


Repository:
  rC Clang

https://reviews.llvm.org/D49148



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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

It's usually preferred to submit patches with full context - it'll make this a 
bit easier if you do please?


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


[PATCH] D49083: [HIP] Register/unregister device fat binary only once

2018-07-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:444
+auto HandleValue =
+CtorBuilder.CreateAlignedLoad(GpuBinaryHandle, CGM.getPointerAlign());
+llvm::Constant *Zero = 
llvm::Constant::getNullValue(HandleValue->getType());

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > Do you not need to worry about concurrency here?
> > The ctor functions are executed by the dynamic loader before the program 
> > gains the control. The dynamic loader cannot excute the ctor functions 
> > concurrently since doing that would not gurantee thread safety of the 
> > loaded program. Therefore we can assume sequential execution of ctor 
> > functions here.
> Okay.  That's worth a comment.
> 
> Is the name here specified by some ABI document, or is it just a conventional 
> name that we're picking now?
Will add a comment for that.

You mean `__hip_gpubin_handle`? It is an implementation detail. It is not 
defined by ABI or other documentation. Since it is only used internally by ctor 
functions, it is not a visible elf symbol. Its name is by convention since the 
cuda corresponding one was named __cuda_gpubin_handle.


https://reviews.llvm.org/D49083



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


[PATCH] D49458: Support implicit _Atomic struct load / store

2018-07-18 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I'm sure there are other bugs around `_Atomic`, please file a bug an CC me if 
that's the case. I'll commit this fix for now.


Repository:
  rC Clang

https://reviews.llvm.org/D49458



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


r337410 - Support implicit _Atomic struct load / store

2018-07-18 Thread JF Bastien via cfe-commits
Author: jfb
Date: Wed Jul 18 11:01:41 2018
New Revision: 337410

URL: http://llvm.org/viewvc/llvm-project?rev=337410&view=rev
Log:
Support implicit _Atomic struct load / store

Summary:
Using _Atomic to do implicit load / store is just a seq_cst atomic_load / 
atomic_store. Stores currently assert in Sema::ImpCastExprToType with 'can't 
implicitly cast lvalue to rvalue with this cast kind', but that's erroneous. 
The codegen is fine as the test shows.

While investigating I found that Richard had found the problem here: 
https://reviews.llvm.org/D46112#1113557



Reviewers: dexonsmith

Subscribers: cfe-commits, efriedma, rsmith, aaron.ballman

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

Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/CodeGen/atomic-ops.c

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=337410&r1=337409&r2=337410&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Jul 18 11:01:41 2018
@@ -481,6 +481,7 @@ ExprResult Sema::ImpCastExprToType(Expr
 case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
 case CK_ToVoid:
+case CK_NonAtomicToAtomic:
   break;
 }
   }

Modified: cfe/trunk/test/CodeGen/atomic-ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic-ops.c?rev=337410&r1=337409&r2=337410&view=diff
==
--- cfe/trunk/test/CodeGen/atomic-ops.c (original)
+++ cfe/trunk/test/CodeGen/atomic-ops.c Wed Jul 18 11:01:41 2018
@@ -183,6 +183,18 @@ struct S {
   double x;
 };
 
+void implicit_store(_Atomic(struct S) *a, struct S s) {
+  // CHECK-LABEL: @implicit_store(
+  // CHECK: store atomic i64 %{{.*}}, i64* %{{.*}} seq_cst, align 8
+  *a = s;
+}
+
+struct S implicit_load(_Atomic(struct S) *a) {
+  // CHECK-LABEL: @implicit_load(
+  // CHECK: load atomic i64, i64* %{{.*}} seq_cst, align 8
+  return *a;
+}
+
 struct S fd1(struct S *a) {
   // CHECK-LABEL: @fd1
   // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4


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


[PATCH] D49458: Support implicit _Atomic struct load / store

2018-07-18 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337410: Support implicit _Atomic struct load / store 
(authored by jfb, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49458

Files:
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/test/CodeGen/atomic-ops.c


Index: cfe/trunk/test/CodeGen/atomic-ops.c
===
--- cfe/trunk/test/CodeGen/atomic-ops.c
+++ cfe/trunk/test/CodeGen/atomic-ops.c
@@ -183,6 +183,18 @@
   double x;
 };
 
+void implicit_store(_Atomic(struct S) *a, struct S s) {
+  // CHECK-LABEL: @implicit_store(
+  // CHECK: store atomic i64 %{{.*}}, i64* %{{.*}} seq_cst, align 8
+  *a = s;
+}
+
+struct S implicit_load(_Atomic(struct S) *a) {
+  // CHECK-LABEL: @implicit_load(
+  // CHECK: load atomic i64, i64* %{{.*}} seq_cst, align 8
+  return *a;
+}
+
 struct S fd1(struct S *a) {
   // CHECK-LABEL: @fd1
   // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -481,6 +481,7 @@
 case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
 case CK_ToVoid:
+case CK_NonAtomicToAtomic:
   break;
 }
   }


Index: cfe/trunk/test/CodeGen/atomic-ops.c
===
--- cfe/trunk/test/CodeGen/atomic-ops.c
+++ cfe/trunk/test/CodeGen/atomic-ops.c
@@ -183,6 +183,18 @@
   double x;
 };
 
+void implicit_store(_Atomic(struct S) *a, struct S s) {
+  // CHECK-LABEL: @implicit_store(
+  // CHECK: store atomic i64 %{{.*}}, i64* %{{.*}} seq_cst, align 8
+  *a = s;
+}
+
+struct S implicit_load(_Atomic(struct S) *a) {
+  // CHECK-LABEL: @implicit_load(
+  // CHECK: load atomic i64, i64* %{{.*}} seq_cst, align 8
+  return *a;
+}
+
 struct S fd1(struct S *a) {
   // CHECK-LABEL: @fd1
   // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -481,6 +481,7 @@
 case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
 case CK_ToVoid:
+case CK_NonAtomicToAtomic:
   break;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.

2018-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D49148#1166859, @echristo wrote:

> In https://reviews.llvm.org/D49148#1166429, @ABataev wrote:
>
> > In https://reviews.llvm.org/D49148#1165826, @echristo wrote:
> >
> > > I think you should break it out on an option by option basis. Just 
> > > warning on "non-standard" options won't make as much sense to end users. 
> > > Perhaps a "this option is unsupported on the target you're compiling for" 
> > > etc.
> > >
> > > Thoughts?
> >
> >
> >
> >
> > 1. I can split it, no problems.
> > 2. Hmm, actually this what the warning already says. If the option is not 
> > supported it says 'debug option '-xxx' is not supported for target 
> > 'xxx-xxx-xxx''. It does not seem to me like a warning on non-standard 
> > option.
>
>
> Let me try to elaborate a bit, I agree that I'm not very clear above.
>
> I'm not a fan of the generic "non default debug options". It feels 
> misleading. I think we probably want to separate it by "dwarf extensions", 
> and "dwarf version".
>
> As far as the error message itself: "debug option" sounds like an option to 
> debug clang rather than a debug information option. Perhaps say "debug 
> information option" rather than "debug option"?


Summarizing offline (irc) conversation:

Let's keep the generic solution that Alexey was using here, but instead migrate 
it to a "supports debug flag" routine that uses enums to check for which things 
we support. This way targets that don't quite support various levels of debug 
info or extensions can define them for themselves and even check OS versions.

(This would probably have been useful for darwin in the past and still might 
be).


Repository:
  rC Clang

https://reviews.llvm.org/D49148



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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Jiading Gai via Phabricator via cfe-commits
gaijiading updated this revision to Diff 156117.
gaijiading added a comment.

Include the full context in the update diff.


Repository:
  rC Clang

https://reviews.llvm.org/D46230

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/x86_64-amazon-linux/7/crtbegin.o
  
test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/x86_64-amazon-linux/7/crtbeginT.o
  test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/x86_64-amazon-linux/7/crtend.o
  test/Driver/Inputs/ami_linux_tree/usr/lib64/crt1.o
  test/Driver/Inputs/ami_linux_tree/usr/lib64/crti.o
  test/Driver/Inputs/ami_linux_tree/usr/lib64/crtn.o
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1792,3 +1792,25 @@
 // CHECK-LD-RHLE7-DTS: Selected GCC installation: 
[[GCC_INSTALL:[[SYSROOT]]/lib/gcc/x86_64-redhat-linux/7]]
 // CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
 // CHECK-LD-RHLE7-DTS: [[GCC_INSTALL]/../../../bin/ld
+
+// Check whether gcc7 install works fine on Amazon Linux AMI
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-amazon-linux -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/ami_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-AMI %s
+// CHECK-LD-AMI-NOT: warning:
+// CHECK-LD-AMI: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-AMI: "--eh-frame-hdr"
+// CHECK-LD-AMI: "-m" "elf_x86_64"
+// CHECK-LD-AMI: "-dynamic-linker"
+// CHECK-LD-AMI: "{{.*}}/usr/lib/gcc/x86_64-amazon-linux/7{{/|}}crtbegin.o"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7"
+// CHECK-LD-AMI: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../../../lib64"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../.."
+// CHECK-LD-AMI: "-L[[SYSROOT]]/lib"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-AMI: "-lc"
+// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+//
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1838,7 +1838,8 @@
   "x86_64-pc-linux-gnu","x86_64-redhat-linux6E",
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
-  "x86_64-slackware-linux", "x86_64-unknown-linux"};
+  "x86_64-slackware-linux", "x86_64-unknown-linux",
+  "x86_64-amazon-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1792,3 +1792,25 @@
 // CHECK-LD-RHLE7-DTS: Selected GCC installation: [[GCC_INSTALL:[[SYSROOT]]/lib/gcc/x86_64-redhat-linux/7]]
 // CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
 // CHECK-LD-RHLE7-DTS: [[GCC_INSTALL]/../../../bin/ld
+
+// Check whether gcc7 install works fine on Amazon Linux AMI
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-amazon-linux -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/ami_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-AMI %s
+// CHECK-LD-AMI-NOT: warning:
+// CHECK-LD-AMI: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-AMI: "--eh-frame-hdr"
+// CHECK-LD-AMI: "-m" "elf_x86_64"
+// CHECK-LD-AMI: "-dynamic-linker"
+// CHECK-LD-AMI: "{{.*}}/usr/lib/gcc/x86_64-amazon-linux/7{{/|}}crtbegin.o"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../../../lib64"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../.."
+// CHECK-LD-AMI: "-L[[SYSROOT]]/lib"
+// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-AMI: "-lc"
+// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+//
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1838,7 +1838,8 @@
   "x86_64-pc-linux-gnu","x86_64-redhat-linux6E",
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
-  "x86_64-slackware-linux", "x86_64-unknown-linux"};
+  "x86_64-slackware-linux", "x86_64-unknown-linux",
+  "x86_64-amazon-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
___
cfe-commits mailing list
cfe-co

[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

-eric


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Jiading Gai via Phabricator via cfe-commits
gaijiading added a comment.

Thanks very much for the comments and the review.


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


r337417 - [analyzer] Remove a debug print that was accidentally left around.

2018-07-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Jul 18 11:44:40 2018
New Revision: 337417

URL: http://llvm.org/viewvc/llvm-project?rev=337417&view=rev
Log:
[analyzer] Remove a debug print that was accidentally left around.

No functional change intended.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=337417&r1=337416&r2=337417&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed Jul 18 11:44:40 2018
@@ -2562,7 +2562,6 @@ generateVisitorsDiagnostics(BugReport *R
   assert(!LastPiece &&
  "There can only be one final piece in a diagnostic.");
   LastPiece = std::move(Piece);
-  llvm::errs() << "Writing to last piece" << "\n";
   (*Notes)[ErrorNode].push_back(LastPiece);
 }
   }


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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Jiading Gai via Phabricator via cfe-commits
gaijiading added a comment.

In https://reviews.llvm.org/D46230#1166919, @echristo wrote:

> LGTM.
>
> -eric


Hi Eric, I do not have commit access to trunk. Could you commit the change for 
me? Thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [Clang<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

erichkeane wrote:
> aaron.ballman wrote:
> > `Cpus` -> `CPUs` ?
> So, I agree with you we should be consistent with spelling.  However, in this 
> case, I'd prefer not changing this one.  This is what the generated code in 
> Attrs.inc looks like if I change it:
> 
> typedef IdentifierInfo ** cPUs_iterator;
> cPUs_iterator cPUs_begin() const { return cPUs_; }
> cPUs_iterator cPUs_end() const { return cPUs_ + cPUs_Size; }
> unsigned cPUs_size() const { return cPUs_Size; }
> llvm::iterator_range cPUs() const { return 
> llvm::make_range(cPUs_begin(), cPUs_end()); }
> 
> I think having "Cpus" in 2 places is way better than having to spell it as 
> cPUs_begin.  Your thoughts?
Oh wow that is disgusting. Yes, please leave as `Cpus` here.


https://reviews.llvm.org/D47474



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


[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library

2018-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: EricWF.
Herald added subscribers: cfe-commits, ldionne, christof, mgorny.

Currently it's possible to select whether to statically link unwinder
or the C++ ABI library, but this option applies to both the shared
and static library. However, in some scenarios it may be desirable to
only statically link unwinder and C++ ABI library into static C++
library since for shared C++ library we can rely on dynamic linking
and linker scripts. This change enables selectively enabling or
disabling statically linking only to shared or static library.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49502

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/Modules/HandleLibCXXABI.cmake
  libcxx/lib/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libcxxabi/src/CMakeLists.txt

Index: libcxxabi/src/CMakeLists.txt
===
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -61,9 +61,9 @@
   # Prefer using the in-tree version of libunwind, either shared or static. If
   # none are found fall back to using -lunwind.
   # FIXME: Is it correct to prefer the static version of libunwind?
-  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER_SHARED AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
 list(APPEND LIBCXXABI_LIBRARIES unwind_shared)
-  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER_STATIC AND (TARGET unwind_static OR HAVE_LIBUNWIND))
 list(APPEND LIBCXXABI_LIBRARIES unwind_static)
   else()
 list(APPEND LIBCXXABI_LIBRARIES unwind)
@@ -155,7 +155,7 @@
 # Build the static library.
 if (LIBCXXABI_ENABLE_STATIC)
   set(cxxabi_static_sources $)
-  if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER)
+  if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_ENABLE_STATIC_UNWINDER_STATIC)
 if (TARGET unwind_static OR HAVE_LIBUNWIND)
   list(APPEND cxxabi_static_sources $)
 endif()
Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -84,6 +84,13 @@
 option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
 option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
 
+cmake_dependent_option(LIBCXXABI_ENABLE_STATIC_UNWINDER_STATIC
+  "Statically link the LLVM unwinder to static library" ON
+  "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)
+cmake_dependent_option(LIBCXXABI_ENABLE_STATIC_UNWINDER_SHARED
+  "Statically link the LLVM unwinder to shared library" ON
+  "LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF)
+
 option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
 # The default terminate handler attempts to demangle uncaught exceptions, which
 # causes extra I/O and demangling code to be pulled in.
Index: libcxx/lib/CMakeLists.txt
===
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -44,7 +44,7 @@
   set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
 endif()
 
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY_SHARED)
   add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
   add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
   add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
@@ -259,14 +259,16 @@
 
   list(APPEND LIBCXX_TARGETS "cxx_static")
   # Attempt to merge the libc++.a archive and the ABI library archive into one.
-  if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY_STATIC)
 set(MERGE_ARCHIVES_SEARCH_PATHS "")
 if (LIBCXX_CXX_ABI_LIBRARY_PATH)
   set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 endif()
-if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
-(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
-  set(MERGE_ARCHIVES_ABI_TARGET "$")
+if (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?"
+AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
+#if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
+#(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
+  set(MERGE_ARCHIVES_ABI_TARGET "$")
 else()
   set(MERGE_ARCHIVES_ABI_TARGET
   "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
Index: libcxx/cmake/Modules/HandleLibCXXABI.cmake
===
--- libcxx/cmake/Modules/HandleLibCXXABI.cmake
+++ libcxx/cmake/Modules/HandleLibCXXABI.cmake
@@ -104,10 +104,10 @@
 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
   if (LIBCXX_CXX_ABI_INTREE)
 # Link against just-built "cxxabi" target.
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
-   

[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library

2018-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This came up in Fuchsia. Clang driver, add `-lc++` as a dependency. This is 
sufficient for shared libc++, but for static user has to manually pass 
`-lc++abi -lunwind`, so for static libc++ we would actually like to combine 
both libc++abi and libunwind into a single archive.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49502



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


[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library

2018-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: libcxx/CMakeLists.txt:158
 
+cmake_dependent_option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY_STATIC
+  "Statically link the ABI library to static library" ON

Maybe `LIBCXX_ENABLE_STATIC_ABI_LIBRARY_IN_STATIC_LIBRARY` would be more 
accurate?


Repository:
  rCXX libc++

https://reviews.llvm.org/D49502



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


[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library

2018-07-18 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: libcxx/CMakeLists.txt:158
 
+cmake_dependent_option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY_STATIC
+  "Statically link the ABI library to static library" ON

phosek wrote:
> Maybe `LIBCXX_ENABLE_STATIC_ABI_LIBRARY_IN_STATIC_LIBRARY` would be more 
> accurate?
`LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY` and 
`LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY`?

And then 
`LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY`/`LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY`.



Comment at: libcxx/lib/CMakeLists.txt:269
+AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
+#if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
+#(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND 
HAVE_LIBCXXABI))

I don't understand why any of this needs to change -- can you please explain? 
Also, you probably didn't mean to leave the commented-out lines.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49502



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


[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaAccess.cpp:1871-1873
+// The access should be AS_none as we don't know how the member was
+// accessed - `AccessedEntity::getAccess` describes what access was used to
+// access an entity.

ioeric wrote:
> aaron.ballman wrote:
> > This seems to contradict the function-level comment that says the check 
> > seems to only take the access specifiers into account and not how the 
> > member is accessed.
> > not how the member is accessed.
> It's not very clear to me what exactly this means.  But I think we are still 
> not taking how member was accessed into account. The access in 
> `DeclAccessPair` describes how a member was accessed, and this should be None 
> instead of the access specifier of the member as we don't have this 
> information here. 
> 
> I updated the wording in the comment to make this a bit clearer.
I'm still wondering about the removal of the public access check -- if the 
declaration has a public access specifier, that early return saves work. So 
`Entity` may still require passing `AS_none` but we might want to continue to 
check `Decl->getAccess() == AS_public` for the early return?

(Drive-by nit that's not yours: `Decl` is the name of a type, so if you wanted 
to rename the parameter to something that isn't a type name, I would not be 
sad, but you're not required to do it.)



Comment at: lib/Sema/SemaCodeComplete.cpp:1316-1317
+//   void D::f() { this->^; }
+// The completion after "this->" will have `InBaseClass` set to true 
and
+// `Ctx` set to "B". We need to set the actual accessing context (i.e.
+// naming class) to "D" so that access can be calculated correctly.

ioeric wrote:
> aaron.ballman wrote:
> > This makes it sound like the caller has messed something up, but I'm also 
> > pretty unfamiliar with the code completion logic. Why would `InBaseClass` 
> > be true for that completion point and why would the context be set to `B`?
> It's a bit messy, but this is roughly how lookup inside a class, say D,works:
> 1. lookup inside the class (InBaseClass = false, Context=D).
> 2. Run the same lookup on all base classes (InBaseClass=true, Context=B). 
> (https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaLookup.cpp#L3584)
> 
> So, `InBaseClass` would be true when a lookup starts from a derived class. 
Ah, thank you for the explanation; that helps.


Repository:
  rC Clang

https://reviews.llvm.org/D49421



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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D46230#1166958, @gaijiading wrote:

> In https://reviews.llvm.org/D46230#1166919, @echristo wrote:
>
> > LGTM.
> >
> > -eric
>
>
> Hi Eric, I do not have commit access to trunk. Could you commit the change 
> for me? Thanks.


The binaries make that hard, can you email me a tarball please?


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


[PATCH] D49504: Enable C++2a Chrono Literals

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rsmith, gribozavr, ddunbar, eli.friedman.
Herald added a subscriber: cfe-commits.

C++2a via http://wg21.link/p0355 permits the library
literals of 'd' and 'y'.  This patch enables them in the
Lexer so that they can be properly parsed.

Note that 'd' gets confused with the hex character, so 
modifications to how octal, binary, and decimal numbers are
parsed were required. Since this is simply making previously 
invalid code legal, this should be fine.

Hex still greedily parses the 'd' as a hexit, since it would 
a: violate [lex.ext]p1
b: break existing code.


Repository:
  rC Clang

https://reviews.llvm.org/D49504

Files:
  lib/Lex/LiteralSupport.cpp
  test/SemaCXX/cxx2a-user-defined-literals.cpp


Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -751,7 +751,8 @@
 
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
-  if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
+  if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
+  !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
 diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 
0);
 hadError = true;
@@ -804,12 +805,14 @@
   if (!LangOpts.CPlusPlus14)
 return false;
 
-  // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.
+  // In C++14, "s", "h", "min", "ms", "us", and "ns" are used in the library.
   // Per tweaked N3660, "il", "i", and "if" are also used in the library.
+  // In C++2a "d" and "y" are used in the library.
   return llvm::StringSwitch(Suffix)
   .Cases("h", "min", "s", true)
   .Cases("ms", "us", "ns", true)
   .Cases("il", "i", "if", true)
+  .Cases("d", "y", LangOpts.CPlusPlus2a)
   .Default(false);
 }
 
@@ -922,7 +925,9 @@
 s = SkipBinaryDigits(s);
 if (s == ThisTokEnd) {
   // Done.
-} else if (isHexDigit(*s)) {
+} else if (isHexDigit(*s) &&
+   !isValidUDSuffix(PP.getLangOpts(),
+StringRef(s, ThisTokEnd - s))) {
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
   diag::err_invalid_digit) << StringRef(s, 1) << 2;
   hadError = true;
Index: test/SemaCXX/cxx2a-user-defined-literals.cpp
===
--- test/SemaCXX/cxx2a-user-defined-literals.cpp
+++ test/SemaCXX/cxx2a-user-defined-literals.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  struct string {};
+  namespace chrono {
+struct day{};
+struct year{};
+  }
+  using size_t = decltype(sizeof(0));
+  constexpr chrono::day operator"" d(unsigned long long d) noexcept;
+  constexpr chrono::year operator"" y(unsigned long long y) noexcept;
+}
+
+#else
+
+using namespace std;
+chrono::day dec_d = 5d;
+chrono::day oct_d = 05d;
+chrono::day bin_d = 0b011d;
+// expected-error@+3{{no viable conversion from 'int' to 'chrono::day'}}
+// expected-note@11{{candidate constructor (the implicit copy constructor)}}
+// expected-note@11{{candidate constructor (the implicit move constructor)}}
+chrono::day hex_d = 0x44d;
+chrono::year y  = 10y;
+#endif


Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -751,7 +751,8 @@
 
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
-  if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
+  if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
+  !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
 diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 0);
 hadError = true;
@@ -804,12 +805,14 @@
   if (!LangOpts.CPlusPlus14)
 return false;
 
-  // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.
+  // In C++14, "s", "h", "min", "ms", "us", and "ns" are used in the library.
   // Per tweaked N3660, "il", "i", and "if" are also used in the library.
+  // In C++2a "d" and "y" are used in the library.
   return llvm::StringSwitch(Suffix)
   .Cases("h", "min", "s", true)
   .Cases("ms", "us", "ns", true)
   .Cases("il", "i", "if", true)
+  .Cases("d", "y", LangOpts.CPlusPlus2a)
   .Default(false);
 }
 
@@ -922,7 +925,9 @@
 s = SkipBinaryDigits(s);
 if (s == ThisTokEnd) {
   // Done.
-} else if (isHexDigit(*s)) {
+} else if (isHexDigit(*s) &&
+   !isValidUDSuffix(PP.getLangOpts(),
+StringRef(s, ThisTokEnd

Re: r337381 - Mention clang-cl improvements from r335466 and r336379 in ReleaseNotes.rst

2018-07-18 Thread Kim Gräsman via cfe-commits
This is lovely! Found a bit inline...

On Wed, Jul 18, 2018, 14:00 Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Wed Jul 18 04:55:03 2018
> New Revision: 337381
>
> URL: http://llvm.org/viewvc/llvm-project?rev=337381&view=rev
> Log:
> Mention clang-cl improvements from r335466 and r336379 in ReleaseNotes.rst
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=337381&r1=337380&r2=337381&view=diff
>
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 18 04:55:03 2018
> @@ -166,7 +166,19 @@ Attribute Changes in Clang
>  Windows Support
>  ---
>
> -Clang's support for building native Windows programs ...
> +- clang-cl's support for precompiled headers has been much improved:
> +
> +   - When using a pch file, clang-cl now no longer redundantly emits
> inline
> + methods that are already stored in the obj that was built together
> with
> + the pch file (matching cl.exe).  This speeds up builds using pch
> files
> + by around 30%.
> +
> +   - The /Ycfoo.h and /Yufoo.h flags an now be used without /FIfoo.h when
>
> typo: an - > can
>
> - Kim
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49504: Enable C++2a Chrono Literals

2018-07-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

This looks ok to me - I'm assuming that somewhere there's a test for `int foo = 
0x123d`, so we're sure that didn't get broken.




Comment at: test/SemaCXX/cxx2a-user-defined-literals.cpp:8
+namespace std {
+  struct string {};
+  namespace chrono {

Do you need `string` here, or is this a copy-pasto?


Repository:
  rC Clang

https://reviews.llvm.org/D49504



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [Clang<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > `Cpus` -> `CPUs` ?
> > So, I agree with you we should be consistent with spelling.  However, in 
> > this case, I'd prefer not changing this one.  This is what the generated 
> > code in Attrs.inc looks like if I change it:
> > 
> > typedef IdentifierInfo ** cPUs_iterator;
> > cPUs_iterator cPUs_begin() const { return cPUs_; }
> > cPUs_iterator cPUs_end() const { return cPUs_ + cPUs_Size; }
> > unsigned cPUs_size() const { return cPUs_Size; }
> > llvm::iterator_range cPUs() const { return 
> > llvm::make_range(cPUs_begin(), cPUs_end()); }
> > 
> > I think having "Cpus" in 2 places is way better than having to spell it as 
> > cPUs_begin.  Your thoughts?
> Oh wow that is disgusting. Yes, please leave as `Cpus` here.
:-D  Already Done!


https://reviews.llvm.org/D47474



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


[PATCH] D49504: Enable C++2a Chrono Literals

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D49504#1167045, @mclow.lists wrote:

> This looks ok to me - I'm assuming that somewhere there's a test for `int foo 
> = 0x123d`, so we're sure that didn't get broken.


The hex_d SHOULD be testing that, it ensures that the RHS is an integer.




Comment at: test/SemaCXX/cxx2a-user-defined-literals.cpp:8
+namespace std {
+  struct string {};
+  namespace chrono {

mclow.lists wrote:
> Do you need `string` here, or is this a copy-pasto?
Gah, good catch.  I was testing something else briefly.


Repository:
  rC Clang

https://reviews.llvm.org/D49504



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


[PATCH] D49492: Run bounds checking sanitizer earlier to make it easier to optimize away its checks.

2018-07-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Are you sure this will actually do what you want, in general?  I suspect it 
will end up missing bounds checks in some cases because it's running it too 
early (before mem2reg/inlining/etc).


Repository:
  rC Clang

https://reviews.llvm.org/D49492



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


r337420 - Add support for __declspec(code_seg("segname"))

2018-07-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jul 18 13:04:48 2018
New Revision: 337420

URL: http://llvm.org/viewvc/llvm-project?rev=337420&view=rev
Log:
Add support for __declspec(code_seg("segname"))

This patch uses CodeSegAttr to represent __declspec(code_seg) rather than 
building on the existing support for #pragma code_seg.
The code_seg declspec is applied on functions and classes. This attribute 
enables the placement of code into separate named segments, including compiler-
generated codes and template instantiations.

For more information, please see the following:
https://msdn.microsoft.com/en-us/library/dn636922.aspx

This patch fixes the regression for the support for attribute ((section).
https://github.com/llvm-mirror/clang/commit/746b78de7812bc785fbb5207b788348040b23fa7

Patch by Soumi Manna (Manna)
Differential Revision: https://reviews.llvm.org/D48841


Added:
cfe/trunk/test/CodeGenCXX/code-seg.cpp
cfe/trunk/test/CodeGenCXX/code-seg1.cpp
cfe/trunk/test/CodeGenCXX/code-seg2.cpp
cfe/trunk/test/CodeGenCXX/code-seg3.cpp
cfe/trunk/test/SemaCXX/code-seg.cpp
cfe/trunk/test/SemaCXX/code-seg1.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=337420&r1=337419&r2=337420&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Jul 18 13:04:48 2018
@@ -1770,6 +1770,13 @@ def Section : InheritableAttr {
   let Documentation = [SectionDocs];
 }
 
+def CodeSeg : InheritableAttr {
+  let Spellings = [Declspec<"code_seg">];
+  let Args = [StringArgument<"Name">];
+  let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
+  let Documentation = [CodeSegDocs];
+}
+
 def PragmaClangBSSSection : InheritableAttr {
   // This attribute has no spellings as it is only ever created implicitly.
   let Spellings = [];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=337420&r1=337419&r2=337420&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Jul 18 13:04:48 2018
@@ -306,6 +306,18 @@ An example of how to use ``alloc_size``
   }];
 }
 
+def CodeSegDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``__declspec(code_seg)`` attribute enables the placement of code into 
separate
+named segments that can be paged or locked in memory individually. This 
attribute
+is used to control the placement of instantiated templates and 
compiler-generated
+code. See the documentation for `__declspec(code_seg)`_ on MSDN.
+
+.. _`__declspec(code_seg)`: 
http://msdn.microsoft.com/en-us/library/dn636922.aspx
+  }];
+}
+
 def AllocAlignDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337420&r1=337419&r2=337420&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 18 13:04:48 
2018
@@ -2668,11 +2668,19 @@ def err_only_annotate_after_access_spec
   "access specifier can only have annotation attributes">;
 
 def err_attribute_section_invalid_for_target : Error<
-  "argument to 'section' attribute is not valid for this target: %0">;
+  "argument to %select{'code_seg'|'section'}1 attribute is not valid for this 
target: %0">;
 def warn_mismatched_section : Warning<
-  "section does not match previous declaration">, InGroup;
+  "%select{codeseg|section}0 does not match previous declaration">, 
InGroup;
 def warn_attribute_section_on_redeclaration : Warning<
   "section attribute is specified on redeclared variable">, InGroup;
+def err_mismatched_code_seg_base : Error<
+  "derived class must specify the same code segment as its base classes">;
+def err_mismatched_code_seg_override : Error<
+  "overriding virtual function must specify the same code segment as its 
overridden function">;
+def err_conflicting_codeseg_attribute : Error<
+  "conflicting code segment specifiers">;
+def warn_duplicate_codeseg_attribute : Warning<
+  "duplicate code segment specifiers">, InGroup;
 
 def err_anonymous_property: Error<
   "anon

[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.

2018-07-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 156139.
ABataev added a comment.

Renamed function supportsNonDefaultDebugOptions() -> 
supportsDebugInfoOption(const Arg*). Instead of the enum it accepts and should 
check one of the debug info options.


Repository:
  rC Clang

https://reviews.llvm.org/D49148

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-unsupported-debug-options.cu
  test/Driver/openmp-unsupported-debug-options.c

Index: test/Driver/openmp-unsupported-debug-options.c
===
--- /dev/null
+++ test/Driver/openmp-unsupported-debug-options.c
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gz 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-info-for-profiling 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -glldb 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gcodeview 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gmodules 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gembed-source -gdwarf-5 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-macro 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -ggnu-pubnames 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gdwarf-aranges 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -fdebug-types-section 2>&1 | FileCheck %s
+// CHECK: debug information option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx64-nvidia-cuda' [-Wunsupported-target-opt]
+// CHECK-NOT: debug information option '{{.*}}' is not supported for target 'x86
+// CHECK: "-triple" "nvptx64-nvidia-cuda"
+// CHECK-NOT: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}}
+// CHECK: "-triple" "x86_64
+// CHECK-SAME: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}}
Index: test/Driver/cuda-unsupported-debug-options.cu
===
--- /dev/null
+++ test/Driver/cuda-unsupported-debug-options.cu
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-info-for-profiling 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -glldb 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gcodeview 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gmodules 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gembed-source -gdwarf-5 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-macro 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -ggnu-pubnames 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gdwarf-aranges 2>&1 | FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -fdebug-types-section 2>&1 | FileCheck %s
+// CHECK: debug information option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx64-nvidia-cuda' [-Wunsupported-target-opt]
+// CHECK-NOT: debug information option '{{.*}}' is not supported for target 'x86
+// CHECK: "-triple" "nvptx64-nvidia-cuda"
+// CHECK-NOT: {{-comp

[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:23
+
+const char DefaultIgnoredValues[] = "0;1;2;10;100;";
+

Why 2, 10, and 100?



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:30-32
+  for (const std::string &IgnoredValue : IngnoredValuesInput) {
+IngnoredValues.push_back(std::stoll(IgnoredValue));
+  }

This can be replaced with `llvm::transform(IgnoredValuesInput, 
IgnoredValues.begin(), std::stoll);`



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:33
+  }
+  std::sort(IngnoredValues.begin(), IngnoredValues.end());
+}

Please use `llvm::sort()` instead to help find non-determinism bugs. (I'm a bit 
surprised we don't have a range-based sort though.)



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:37
+void MagicNumbersCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoredValues", DefaultIgnoredValues);
+}

`IgnoredIntegerValues` as the public facing option as well, unless you want to 
allow users to specify ignored floating-point values too (which could be useful 
as well).



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:41-42
+void MagicNumbersCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(integerLiteral().bind("ii"), this);
+  Finder->addMatcher(floatLiteral().bind("ff"), this);
+}

The names `ii` and `ff` could be a bit more user-friendly. Also, this can be 
written using a single matcher, I think.
`anyOf(integerLiteral().bind("integer"), floatLiteral().bind("float"))`



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:54
+  Result.Nodes.getNodeAs("ii");
+  if (MatchedInteger) {
+

Rather than indent everything for the typical case, I'd prefer this to be an 
early return.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:72
+
+diag(MatchedInteger->getLocation(), "magic number integer literal %0")
+<< Str.data();

This diagnostic text doesn't really tell the user what's wrong with their code 
or how to fix it. Also, this function is largely duplicated in 
`checkFloatMatch()`. I think they should be combined where possible and the 
diagnostic should read: `'%0' is a magic number; consider replacing with a 
named constant` or something along those lines.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:118
+const ast_type_traits::DynTypedNode &Node) const {
+  const VarDecl *AsVarDecl = Node.get();
+  if (AsVarDecl) {

Can use `const auto *` here as the type is spelled out in the initialization.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:119-123
+  if (AsVarDecl) {
+if (AsVarDecl->getType().isConstQualified()) {
+  return true;
+}
+  }

The `if` statements can be combined into a single statement and the braces can 
be elided.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:124-126
+  const FieldDecl *AsFieldDecl = Node.get();
+  if (AsFieldDecl) {
+if (AsFieldDecl->getType().isConstQualified()) {

Same here for `auto` and single statement.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:135-140
+  const SubstNonTypeTemplateParmExpr *AsTemplateArgument =
+  Node.get();
+  if (AsTemplateArgument) {
+return true;
+  }
+  return false;

`return Node.get != nullptr;` However, that makes 
me wonder why this should be a function at all.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:147
+
+  if (isConstantDefinition(Node)) {
+return true;

Elide braces



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:151-158
+  for (const ast_type_traits::DynTypedNode &Parent :
+   Result.Context->getParents(Node)) {
+if (isEventuallyConstant(Result, Parent)) {
+  return true;
+}
+  }
+

I think this could be replaced by a call to `llvm::any_of()`



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:164
+const ast_type_traits::DynTypedNode &Node) const {
+  const EnumConstantDecl *AsEnumConstantDecl = Node.get();
+  if (AsEnumConstantDecl)

No need for this local variable.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:168-174
+  for (const ast_type_traits::DynTypedNode &Parent :
+   Result.Context->getParents(Node)) {
+if (isEnumerationDefinition(Result, Parent))
+  return true;
+  }
+
+  return false;

`llvm::any_of()`



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:183-186
+/*
+ * Ignore this instance, because this is the report where the template is
+ * defined, not w

r337422 - DR330: when determining whether a cast casts away constness, consider

2018-07-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jul 18 13:13:36 2018
New Revision: 337422

URL: http://llvm.org/viewvc/llvm-project?rev=337422&view=rev
Log:
DR330: when determining whether a cast casts away constness, consider
qualifiers from all levels matching a multidimensional array.

For example, this allows casting from
  pointer to   array ofarray of   const volatile int
to
  pointer to const pointer to volatile pointer toint
because the multidimensional array part of the source type corresponds
to a part of the destination type that contains both 'const' and
'volatile'.

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/CXX/drs/dr3xx.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=337422&r1=337421&r2=337422&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jul 18 13:13:36 2018
@@ -2289,6 +2289,7 @@ public:
const ObjCMethodDecl *MethodImp);
 
   bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
+  bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
 
   /// Determine if two types are similar, according to the C++ rules. That is,
   /// determine if they are the same other than qualifiers on the initial

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=337422&r1=337421&r2=337422&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 18 13:13:36 2018
@@ -5008,28 +5008,29 @@ QualType ASTContext::getUnqualifiedArray
 /// Attempt to unwrap two types that may both be array types with the same 
bound
 /// (or both be array types of unknown bound) for the purpose of comparing the
 /// cv-decomposition of two types per C++ [conv.qual].
-static void unwrapSimilarArrayTypes(ASTContext &Ctx, QualType &T1,
-QualType &T2) {
+bool ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
+  bool UnwrappedAny = false;
   while (true) {
-auto *AT1 = Ctx.getAsArrayType(T1);
-if (!AT1) return;
+auto *AT1 = getAsArrayType(T1);
+if (!AT1) return UnwrappedAny;
 
-auto *AT2 = Ctx.getAsArrayType(T2);
-if (!AT2) return;
+auto *AT2 = getAsArrayType(T2);
+if (!AT2) return UnwrappedAny;
 
 // If we don't have two array types with the same constant bound nor two
 // incomplete array types, we've unwrapped everything we can.
 if (auto *CAT1 = dyn_cast(AT1)) {
   auto *CAT2 = dyn_cast(AT2);
   if (!CAT2 || CAT1->getSize() != CAT2->getSize())
-return;
+return UnwrappedAny;
 } else if (!isa(AT1) ||
!isa(AT2)) {
-  return;
+  return UnwrappedAny;
 }
 
 T1 = AT1->getElementType();
 T2 = AT2->getElementType();
+UnwrappedAny = true;
   }
 }
 
@@ -5046,7 +5047,7 @@ static void unwrapSimilarArrayTypes(ASTC
 /// \return \c true if a pointer type was unwrapped, \c false if we reached a
 /// pair of types that can't be unwrapped further.
 bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2) {
-  unwrapSimilarArrayTypes(*this, T1, T2);
+  UnwrapSimilarArrayTypes(T1, T2);
 
   const auto *T1PtrType = T1->getAs();
   const auto *T2PtrType = T2->getAs();
@@ -5055,7 +5056,7 @@ bool ASTContext::UnwrapSimilarTypes(Qual
 T2 = T2PtrType->getPointeeType();
 return true;
   }
-  
+
   const auto *T1MPType = T1->getAs();
   const auto *T2MPType = T2->getAs();
   if (T1MPType && T2MPType && 

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=337422&r1=337421&r2=337422&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Wed Jul 18 13:13:36 2018
@@ -459,50 +459,83 @@ enum CastAwayConstnessKind {
 /// Like Sema::UnwrapSimilarTypes, this removes one level of indirection from
 /// both types, provided that they're both pointer-like or array-like. Unlike
 /// the Sema function, doesn't care if the unwrapped pieces are related.
+///
+/// This function may remove additional levels as necessary for correctness:
+/// the resulting T1 is unwrapped sufficiently that it is never an array type,
+/// so that its qualifiers can be directly compared to those of T2 (which will
+/// have the combined set of qualifiers from all indermediate levels of T2),
+/// as (effectively) required by [expr.const.cast]p7 replacing T1's qualifiers
+/// with those from T2.
 static CastAwayConstnessKind
 

[PATCH] D49457: DR330: when determining whether a cast casts away constness, consider qualifiers from all levels matching a multidimensional array

2018-07-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC337422: DR330: when determining whether a cast casts away 
constness, consider (authored by rsmith, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49457

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/Sema/SemaCast.cpp
  test/CXX/drs/dr3xx.cpp

Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -2289,6 +2289,7 @@
const ObjCMethodDecl *MethodImp);
 
   bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
+  bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2);
 
   /// Determine if two types are similar, according to the C++ rules. That is,
   /// determine if they are the same other than qualifiers on the initial
Index: test/CXX/drs/dr3xx.cpp
===
--- test/CXX/drs/dr3xx.cpp
+++ test/CXX/drs/dr3xx.cpp
@@ -403,6 +403,28 @@
 (void) reinterpret_cast(q); // expected-error {{casts away qualifiers}}
 (void) reinterpret_cast(t);
   }
+
+  namespace swift_17882 {
+typedef const char P[72];
+typedef int *Q;
+void f(P &pr, P *pp) {
+  (void) reinterpret_cast(pr);
+  (void) reinterpret_cast(pp);
+}
+
+struct X {};
+typedef const volatile int A[1][2][3];
+typedef int *const X::*volatile *B1;
+typedef int *const X::* *B2;
+typedef int *X::*  volatile *B3;
+typedef volatile int *(*const B4)[4];
+void f(A *a) {
+  (void) reinterpret_cast(a);
+  (void) reinterpret_cast(a); // expected-error {{casts away qualifiers}}
+  (void) reinterpret_cast(a); // expected-error {{casts away qualifiers}}
+  (void) reinterpret_cast(a);
+}
+  }
 }
 
 namespace dr331 { // dr331: yes
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -5008,28 +5008,29 @@
 /// Attempt to unwrap two types that may both be array types with the same bound
 /// (or both be array types of unknown bound) for the purpose of comparing the
 /// cv-decomposition of two types per C++ [conv.qual].
-static void unwrapSimilarArrayTypes(ASTContext &Ctx, QualType &T1,
-QualType &T2) {
+bool ASTContext::UnwrapSimilarArrayTypes(QualType &T1, QualType &T2) {
+  bool UnwrappedAny = false;
   while (true) {
-auto *AT1 = Ctx.getAsArrayType(T1);
-if (!AT1) return;
+auto *AT1 = getAsArrayType(T1);
+if (!AT1) return UnwrappedAny;
 
-auto *AT2 = Ctx.getAsArrayType(T2);
-if (!AT2) return;
+auto *AT2 = getAsArrayType(T2);
+if (!AT2) return UnwrappedAny;
 
 // If we don't have two array types with the same constant bound nor two
 // incomplete array types, we've unwrapped everything we can.
 if (auto *CAT1 = dyn_cast(AT1)) {
   auto *CAT2 = dyn_cast(AT2);
   if (!CAT2 || CAT1->getSize() != CAT2->getSize())
-return;
+return UnwrappedAny;
 } else if (!isa(AT1) ||
!isa(AT2)) {
-  return;
+  return UnwrappedAny;
 }
 
 T1 = AT1->getElementType();
 T2 = AT2->getElementType();
+UnwrappedAny = true;
   }
 }
 
@@ -5046,16 +5047,16 @@
 /// \return \c true if a pointer type was unwrapped, \c false if we reached a
 /// pair of types that can't be unwrapped further.
 bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2) {
-  unwrapSimilarArrayTypes(*this, T1, T2);
+  UnwrapSimilarArrayTypes(T1, T2);
 
   const auto *T1PtrType = T1->getAs();
   const auto *T2PtrType = T2->getAs();
   if (T1PtrType && T2PtrType) {
 T1 = T1PtrType->getPointeeType();
 T2 = T2PtrType->getPointeeType();
 return true;
   }
-  
+
   const auto *T1MPType = T1->getAs();
   const auto *T2MPType = T2->getAs();
   if (T1MPType && T2MPType && 
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -459,50 +459,83 @@
 /// Like Sema::UnwrapSimilarTypes, this removes one level of indirection from
 /// both types, provided that they're both pointer-like or array-like. Unlike
 /// the Sema function, doesn't care if the unwrapped pieces are related.
+///
+/// This function may remove additional levels as necessary for correctness:
+/// the resulting T1 is unwrapped sufficiently that it is never an array type,
+/// so that its qualifiers can be directly compared to those of T2 (which will
+/// have the combined set of qualifiers from all indermediate levels of T2),
+/// as (effectively) required by [expr.const.cast]p7 replacing T1's qualifiers
+/// with those from T2.
 static CastAwayConstnessKind
 unwrapCastAwayConstnessLevel(ASTContext &Context, Q

[PATCH] D49504: Enable C++2a Chrono Literals

2018-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 156143.
erichkeane added a comment.

@mclow.lists s comments.


https://reviews.llvm.org/D49504

Files:
  lib/Lex/LiteralSupport.cpp
  test/SemaCXX/cxx2a-user-defined-literals.cpp


Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -751,7 +751,8 @@
 
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
-  if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
+  if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
+  !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
 diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 
0);
 hadError = true;
@@ -804,12 +805,14 @@
   if (!LangOpts.CPlusPlus14)
 return false;
 
-  // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.
+  // In C++14, "s", "h", "min", "ms", "us", and "ns" are used in the library.
   // Per tweaked N3660, "il", "i", and "if" are also used in the library.
+  // In C++2a "d" and "y" are used in the library.
   return llvm::StringSwitch(Suffix)
   .Cases("h", "min", "s", true)
   .Cases("ms", "us", "ns", true)
   .Cases("il", "i", "if", true)
+  .Cases("d", "y", LangOpts.CPlusPlus2a)
   .Default(false);
 }
 
@@ -922,7 +925,9 @@
 s = SkipBinaryDigits(s);
 if (s == ThisTokEnd) {
   // Done.
-} else if (isHexDigit(*s)) {
+} else if (isHexDigit(*s) &&
+   !isValidUDSuffix(PP.getLangOpts(),
+StringRef(s, ThisTokEnd - s))) {
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
   diag::err_invalid_digit) << StringRef(s, 1) << 2;
   hadError = true;
Index: test/SemaCXX/cxx2a-user-defined-literals.cpp
===
--- test/SemaCXX/cxx2a-user-defined-literals.cpp
+++ test/SemaCXX/cxx2a-user-defined-literals.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++2a %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  namespace chrono {
+struct day{};
+struct year{};
+  }
+  using size_t = decltype(sizeof(0));
+  constexpr chrono::day operator"" d(unsigned long long d) noexcept;
+  constexpr chrono::year operator"" y(unsigned long long y) noexcept;
+}
+
+#else
+
+using namespace std;
+chrono::day dec_d = 5d;
+chrono::day oct_d = 05d;
+chrono::day bin_d = 0b011d;
+// expected-error@+3{{no viable conversion from 'int' to 'chrono::day'}}
+// expected-note@9{{candidate constructor (the implicit copy constructor)}}
+// expected-note@9{{candidate constructor (the implicit move constructor)}}
+chrono::day hex_d = 0x44d;
+chrono::year y  = 10y;
+#endif


Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -751,7 +751,8 @@
 
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
-  if (isHexDigit(*s) && *s != 'e' && *s != 'E') {
+  if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
+  !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
 diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 0);
 hadError = true;
@@ -804,12 +805,14 @@
   if (!LangOpts.CPlusPlus14)
 return false;
 
-  // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.
+  // In C++14, "s", "h", "min", "ms", "us", and "ns" are used in the library.
   // Per tweaked N3660, "il", "i", and "if" are also used in the library.
+  // In C++2a "d" and "y" are used in the library.
   return llvm::StringSwitch(Suffix)
   .Cases("h", "min", "s", true)
   .Cases("ms", "us", "ns", true)
   .Cases("il", "i", "if", true)
+  .Cases("d", "y", LangOpts.CPlusPlus2a)
   .Default(false);
 }
 
@@ -922,7 +925,9 @@
 s = SkipBinaryDigits(s);
 if (s == ThisTokEnd) {
   // Done.
-} else if (isHexDigit(*s)) {
+} else if (isHexDigit(*s) &&
+   !isValidUDSuffix(PP.getLangOpts(),
+StringRef(s, ThisTokEnd - s))) {
   PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
   diag::err_invalid_digit) << StringRef(s, 1) << 2;
   hadError = true;
Index: test/SemaCXX/cxx2a-user-defined-literals.cpp
===
--- test/SemaCXX/cxx2a-user-defined-literals.cpp
+++ test/SemaCXX/cxx2a-user-defined-literals.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++2a %s -include %s -verify
+
+#ifndef INCLUDED
+#define INCLUDED
+
+#pragma clang system_header
+namespace std {
+  namespace chrono {
+stru

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

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

Aside from an `assert` than can be removed, this LGTM on the attribute side of 
things.




Comment at: lib/CodeGen/CodeGenModule.cpp:2446
+  const auto *FD = cast(GD.getDecl());
+  assert(FD && "Not a FunctionDecl?");
+  const auto *DD = FD->getAttr();

aaron.ballman wrote:
> `cast<>` already asserts this.
I don't think this is done -- the assert can be removed.


https://reviews.llvm.org/D47474



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


[PATCH] D49508: [CodeGen] VisitMaterializeTemporaryExpr(): don't skip NoOp Casts.

2018-07-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: rsmith, rjmccall, majnemer, efriedma.
Herald added a subscriber: cfe-commits.

As discussed in PR38166 , we need 
to be able to distinqush whether the cast
we are visiting is actually a cast, or part of an `ExplicitCast`.
There are at least two ways to get there:

1. Introduce a new `CastKind`, and use it instead of `IntegralCast` if we are 
in `ExplicitCast`.

  Would work, but does not scale - what if we will need more of these cast 
kinds?
2. Fix `ScalarExprEmitter::VisitCastExpr()` to visit these `NoOp` casts.

  As pointed out by @rsmith, CodeGenFunction::EmitMaterializeTemporaryExpr calls

  skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast`,

  which explains why we currently don't visit those.

Now, the problem is, this is a very specific area of clang.
I'm not familiar with it.
At first, when i saw these test regressions, i immediately panicked,
But now that i have actually looked at them in detail, at least in the case of 
`test/CodeGenCXX/cxx0x-initializer-*`,
as far as i can tell, only the IR is different, the assembly is still exactly 
the same. Or i'm really failing to look..
So i'm not sure whether these test changes are really ok or not, thus i'm 
posting this differential.


Repository:
  rC Clang

https://reviews.llvm.org/D49508

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/const-init-cxx11.cpp
  test/CodeGenCXX/cxx0x-initializer-references.cpp
  test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Index: test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
===
--- test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -501,7 +501,7 @@
   void PR22940_helper(const pair&) { }
   void PR22940() {
 // CHECK-LABEL: @_ZN9B197730107PR22940Ev
-// CHECK: call {{.*}} @_ZN9B197730104pairIPviEC{{.}}Ev(
+// CHECK-NOT: call {{.*}} @_ZN9B197730104pairIPviEC{{.}}Ev(
 // CHECK: call {{.*}} @_ZN9B1977301014PR22940_helperERKNS_4pairIPviEE(
 PR22940_helper(pair());
   }
Index: test/CodeGenCXX/cxx0x-initializer-references.cpp
===
--- test/CodeGenCXX/cxx0x-initializer-references.cpp
+++ test/CodeGenCXX/cxx0x-initializer-references.cpp
@@ -94,9 +94,9 @@
 }
 
 void foo() {
-// CHECK-LABEL: @_ZN7PR231653fooEv
-// CHECK: call {{.*}} @_ZN7PR2316510ChildClassC1Ev
-// CHECK: call void @_ZN7PR231656helperERKNS_13AbstractClassE
+  // CHECK-LABEL: @_ZN7PR231653fooEv
+  // CHECK-NOT: call {{.*}} @_ZN7PR2316510ChildClassC1Ev
+  // CHECK: call void @_ZN7PR231656helperERKNS_13AbstractClassE
   helper(ChildClass());
 }
 
Index: test/CodeGenCXX/const-init-cxx11.cpp
===
--- test/CodeGenCXX/const-init-cxx11.cpp
+++ test/CodeGenCXX/const-init-cxx11.cpp
@@ -226,7 +226,7 @@
   };
 
   // This creates a non-const temporary and binds a reference to it.
-  // CHECK: @[[TEMP:.*]] = internal global {{.*}} { i32 5 }, align 4
+  // CHECK: @[[TEMP:.*]] = internal constant {{.*}} { i32 5 }, align 4
   // CHECK: @_ZN16LiteralReference3litE = constant {{.*}} @[[TEMP]], align 8
   const Lit &lit = Lit();
 
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1835,8 +1835,8 @@
   assert(E->getStorageDuration() == SD_Static);
   SmallVector CommaLHSs;
   SmallVector Adjustments;
-  const Expr *Inner = E->GetTemporaryExpr()
-  ->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
+  const Expr *Inner = E->GetTemporaryExpr()->skipRValueSubobjectAdjustments(
+  CommaLHSs, Adjustments, /*CanSkipNoOpCasts*/ false);
   return CGM.GetAddrOfGlobalTemporary(E, Inner);
 }
 
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -467,7 +467,8 @@
 
   SmallVector CommaLHSs;
   SmallVector Adjustments;
-  E = E->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
+  E = E->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments,
+/*CanSkipNoOpCasts*/ false);
 
   for (const auto &Ignored : CommaLHSs)
 EmitIgnoredExpr(Ignored);
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -76,7 +76,8 @@
 
 const Expr *Expr::skipRValueSubobjectAdjustments(
 SmallVectorImpl &CommaLHSs,
-SmallVectorImpl &Adjustments) const {
+SmallVectorImpl &Adjustments,
+bool CanSkipNoOpCasts) const {
   const Expr *E = this;
   while (true) {
 E = E->IgnoreParens();
@@ -92,10 +93,16 @@
 continue;
   }
 
-

[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/MagicNumbersCheck.cpp:23
+
+const char DefaultIgnoredValues[] = "0;1;2;10;100;";
+

aaron.ballman wrote:
> Why 2, 10, and 100?
These really should be a config option.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 156146.
ioeric marked an inline comment as done.
ioeric added a comment.

- addressed review comments.
- Addressed review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D49421

Files:
  lib/Sema/SemaAccess.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-access-checks.cpp

Index: test/Index/complete-access-checks.cpp
===
--- test/Index/complete-access-checks.cpp
+++ test/Index/complete-access-checks.cpp
@@ -36,10 +36,10 @@
 
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func1}{LeftParen (}{RightParen )} (36)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func2}{LeftParen (}{RightParen )} (36) (inaccessible)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func2}{LeftParen (}{RightParen )} (36)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func3}{LeftParen (}{RightParen )} (36) (inaccessible)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37)
-// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible)
+// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79)
 // CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81)
@@ -87,3 +87,26 @@
 // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText Q}{Text ::} (75)
 // CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (81)
 // CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (79)
+
+class B {
+protected:
+  int member;
+};
+
+class C : private B {};
+
+
+class D : public C {
+ public:
+  void f(::B *b);
+};
+
+void D::f(::B *that) {
+  // RUN: c-index-test -code-completion-at=%s:106:9 %s | FileCheck -check-prefix=CHECK-PRIVATE-SUPER-THIS %s
+  this->;
+// CHECK-PRIVATE-SUPER-THIS: FieldDecl:{ResultType int}{Informative B::}{TypedText member} (37) (inaccessible)
+
+  // RUN: c-index-test -code-completion-at=%s:110:9 %s | FileCheck -check-prefix=CHECK-PRIVATE-SUPER-THAT %s
+  that->;
+// CHECK-PRIVATE-SUPER-THAT: FieldDecl:{ResultType int}{TypedText member} (35) (inaccessible)
+}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -1303,8 +1303,33 @@
 void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
bool InBaseClass) override {
   bool Accessible = true;
-  if (Ctx)
-Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
+  if (Ctx) {
+DeclContext *AccessingCtx = Ctx;
+// If ND comes from a base class, set the naming class back to the
+// derived class if the search starts from the derived class (i.e.
+// InBaseClass is true).
+//
+// Example:
+//   class B { protected: int X; }
+//   class D : public B { void f(); }
+//   void D::f() { this->^; }
+// The completion after "this->" will have `InBaseClass` set to true and
+// `Ctx` set to "B", when looking up in `B`. We need to set the actual
+// accessing context (i.e. naming class) to "D" so that access can be
+// calculated correctly.
+if (InBaseClass && isa(Ctx)) {
+  CXXRecordDecl *RC = nullptr;
+  // Get the enclosing record.
+  for (DeclContext *DC = CurContext; !DC->isFileContext();
+   DC = DC->getParent()) {
+if ((RC = dyn_cast(DC)))
+  break;
+  }
+  if (RC)
+AccessingCtx = RC;
+}
+Accessible = Results.getSema().IsSimplyAccessible(ND, AccessingCtx);
+  }
 
   ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr,
false, Accessible, FixIts);
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -11,6 +11,7 @@
 //
 //===--===//
 
+#include "clang/Basic/Specifiers.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
@@ -1856,29 +1857,31 @@
   }
 }
 
-/// Checks access to Decl from the given class. The check will take access
+/// Checks access t

[PATCH] D49421: [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: lib/Sema/SemaAccess.cpp:1871-1873
+// The access should be AS_none as we don't know how the member was
+// accessed - `AccessedEntity::getAccess` describes what access was used to
+// access an entity.

aaron.ballman wrote:
> ioeric wrote:
> > aaron.ballman wrote:
> > > This seems to contradict the function-level comment that says the check 
> > > seems to only take the access specifiers into account and not how the 
> > > member is accessed.
> > > not how the member is accessed.
> > It's not very clear to me what exactly this means.  But I think we are 
> > still not taking how member was accessed into account. The access in 
> > `DeclAccessPair` describes how a member was accessed, and this should be 
> > None instead of the access specifier of the member as we don't have this 
> > information here. 
> > 
> > I updated the wording in the comment to make this a bit clearer.
> I'm still wondering about the removal of the public access check -- if the 
> declaration has a public access specifier, that early return saves work. So 
> `Entity` may still require passing `AS_none` but we might want to continue to 
> check `Decl->getAccess() == AS_public` for the early return?
> 
> (Drive-by nit that's not yours: `Decl` is the name of a type, so if you 
> wanted to rename the parameter to something that isn't a type name, I would 
> not be sad, but you're not required to do it.)
Added `Decl->getAccess() == AS_public` back to preserve the behavior.

s/Decl/Target/


Repository:
  rC Clang

https://reviews.llvm.org/D49421



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-mapand -ffile-prefix-map

2018-07-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:609
 static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, 
ArgStringList &CmdArgs) {
+  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ)) {
+StringRef Map = A->getValue();

I find it confusing that `-ffile_prefix_map` implies `-fdebug-prefix-map`. I'm 
not sure that is desirable in every case. It seems better to have a combined 
option that explicitly does both.



Comment at: lib/Driver/ToolChains/Clang.cpp:612
+if (Map.find('=') == StringRef::npos)
+  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
+else

I'd prefer the bailout style here, i.e. `if (...) { D.diag(...); continue }`



Comment at: lib/Driver/ToolChains/Clang.cpp:628
+/// Add a CC1 option to specify the macro file path prefix map.
+static void addMacroPrefixMapArg(const Driver &D, const ArgList &Args, 
ArgStringList &CmdArgs) {
+  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ)) {

erichkeane wrote:
> See advice above.
> 
> Additionally/alternatively, I wonder if these two functions could be 
> trivially combined.
Or at least the for loop could be refactored into a small helper function that 
takes the option name, output option and error as argument.



Comment at: lib/Lex/PPMacroExpansion.cpp:1460
+  for (const auto &Entry : MacroPrefixMap)
+if (Path.startswith(Entry.first))
+  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();

This doesn't handle directory vs string prefix prefix correctly, does it? At 
the very least, it should have a test case :)


Repository:
  rC Clang

https://reviews.llvm.org/D49466



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


[PATCH] D49360: [analyzer] Add support for more basic_string API in DanglingInternalBufferChecker

2018-07-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Let's commit this patch and make another round later, as we gather ideas for 
better names and messages.


https://reviews.llvm.org/D49360



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


[PATCH] D49360: [analyzer] Add support for more basic_string API in DanglingInternalBufferChecker

2018-07-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/dangling-internal-buffer.cpp:175
   std::string s;
-  {
-c = s.c_str();
-  }
-  consume(c); // no-warning
+  c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained 
here}}
+  s.clear(); // expected-note {{Method call is allowed to invalidate the 
internal buffer}}

rnkovacs wrote:
> dcoughlin wrote:
> > In other parts of clang we use the term "inner pointer" to mean a pointer 
> > that will be invalidated if its containing object is destroyed 
> > https://clang.llvm.org/docs/AutomaticReferenceCounting.html#interior-pointers.
> >  There are existing attributes that use this term to specify that a method 
> > returns an inner pointer.
> > 
> > I think it would be good to use the same terminology here. So the 
> > diagnostic could be something like "Dangling inner pointer obtained here".
> I feel like I should also retitle the checker to `DanglingInnerBuffer` to 
> remain consistent. What do you think?
My intuition suggests that we should remove the word "Dangling" from the 
checker name, because our checker names are usually indicating what they check, 
not what bugs they find. Eg., `MallocChecker` doesn't find all mallocs, it 
checks that mallocs are used correctly. This checker checks that pointers to 
inner buffers are used correctly, so we may call it `InnerPointerChecker` or 
something like that.


https://reviews.llvm.org/D49360



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


[PATCH] D46230: For x86_64, gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux

2018-07-18 Thread Jiading Gai via Phabricator via cfe-commits
gaijiading added a comment.

In https://reviews.llvm.org/D46230#1167023, @echristo wrote:

> In https://reviews.llvm.org/D46230#1166958, @gaijiading wrote:
>
> > In https://reviews.llvm.org/D46230#1166919, @echristo wrote:
> >
> > > LGTM.
> > >
> > > -eric
> >
> >
> > Hi Eric, I do not have commit access to trunk. Could you commit the change 
> > for me? Thanks.
>
>
> The binaries make that hard, can you email me a tarball please?


Sure, I can do that. Please let me know what’s the email address I should send 
this to. Thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D46230



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


  1   2   >