[PATCH] D48159: [clangd] Implement hover for "auto" and "decltype"

2018-07-02 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added inline comments.



Comment at: clangd/XRefs.cpp:559
+  //- auto& i = 1;
+  bool VisitDeclaratorDecl(DeclaratorDecl *D) {
+if (!D->getTypeSourceInfo() ||

klimek wrote:
> malaperle wrote:
> > klimek wrote:
> > > sammccall wrote:
> > > > malaperle wrote:
> > > > > sammccall wrote:
> > > > > > out of curiosity, why not implement `VisitTypeLoc` and handle all 
> > > > > > the cases where it turns out to be `auto` etc?
> > > > > > Even for `auto&` I'd expect the inner `auto` to have a `TypeLoc` 
> > > > > > you could visit, saving the trouble of unwrapping.
> > > > > > 
> > > > > > (I'm probably wrong about all this, I don't know the AST well. But 
> > > > > > I'd like to learn!)
> > > > > From what I saw, there are actually two different AutoType* for each 
> > > > > textual "auto". The AutoType* containing the deduced type does not 
> > > > > get visited via a typeloc. It's not entirely clear to me why since I 
> > > > > don't know the AST well either. I was thinking maybe the first is 
> > > > > created when the type is not deduced yet and later on, then the rest 
> > > > > of the function or expression is parsed, a second one with the actual 
> > > > > type deduced is created. If I look at the code paths where they are 
> > > > > created, it seems like this is roughly what's happening. The first 
> > > > > one is created when the declarator is parsed (no deduced type yet) 
> > > > > and the second is created when the expression of the initializer (or 
> > > > > return statement) is evaluated and the type is then deduced. The 
> > > > > visitor only visits the first one's typeloc. I don't think I'm 
> > > > > knowledgeable enough to say whether or not that's a bug but it seems 
> > > > > on purpose that it is modelled this way. Although it would be much 
> > > > > nicer to only have to visit typelocs...
> > > > > The AutoType* containing the deduced type does not get visited via a 
> > > > > typeloc
> > > > Ah, OK.
> > > > Could you add a high level comment (maybe on the class) saying this is 
> > > > the reason for the implementation? Otherwise as a reader I'll think 
> > > > "this seems unneccesarily complicated" but not understand why.
> > > > 
> > > > @klimek Can you shed any light on this?
> > > Can't you go from AutoTypeLoc -> AutoType -> getDeducedType()?
> > The visitor doesn't visit the AutoTypeLoc that has the deduced type. In 
> > fact, there are two AutoType* instances. I'm not sure that's is a bug that 
> > there are two AutoType*, or if not visiting both AutoTypeLoc is a bug...or 
> > neither.
> +Richard Smith:
> 
> This is weird. If I just create a minimal example:
>   int f() {
> auto i = f();
> return i;
>   }
> 
> I only get the undeduced auto type - Richard, in which cases are auto-typed 
> being deduced? The AST dump doens't give an indication that there was an auto 
> involved at all. Is this the famous syntactic vs. smenatic form problem? Do 
> we have a backlink between the AutoTypeLoc and the deduced type somewhere?
Given that Richard is known to have ~1 month ping times now and then I think 
it's fine to land this with a FIXME above to figure out how to represent this 
better in the AST. I'd still say it's a missing feature in the AST :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48159



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


[PATCH] D45094: [LibTooling] Make interface of VFS injection into ClangTool more user-friendly

2018-07-02 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Pinging this as the talk has stalled.


https://reviews.llvm.org/D45094



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


[PATCH] D45094: [LibTooling] Make interface of VFS injection into ClangTool more user-friendly

2018-07-02 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Basic/VirtualFileSystem.cpp:328
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
+  // FIXME: OverlayFS containing another one in its stack could be flattened.
   FSList.push_back(FS);

ilya-biryukov wrote:
> I generally agree that it might be useful, but given that we can't use 
> `dynamic_cast` in LLVM code addressing this `FIXME` is probably not worth the 
> effort.
> 
> And this patch is probably not the right place to add this comment, since it 
> doesn't change `OverlayFileSystem` in any way.
We can dyn_cast in LLVM code. It incurs some cost on the class hierarchy, but 
it's possible.


https://reviews.llvm.org/D45094



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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-07-02 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D28462#1148732, @enyquist wrote:

> @klimek having gotten that out of the way, I do occasionally drink too much 
> and have sudden urges to re-implement things from scratch. Close it if you 
> need to, since I can't commit to anything, but it it happens to be still 
> open on one of those nights, who knows, maybe I'll end up doing it :)


Lol, let's hope you'll hit the Ballmer Peak at one of these nights ;)


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

2018-07-02 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Ping?


https://reviews.llvm.org/D46013



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


[PATCH] D48821: [clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.

2018-07-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ioeric.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov.

This provides more structured information that embedders can use for rendering.
ClangdLSPServer continues to call render(), so NFC.

The patch is:

- trivial changes to ClangdServer/ClangdLSPServer
- mostly-mechanical updates to CodeCompleteTests etc for the new API
- new direct tests of render() in CodeCompleteTests
- tiny cleanups to CodeCompletionItem (operator<< and missing initializers)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48821

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -22,7 +22,7 @@
 void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
 WantDiagnostics WantDiags = WantDiagnostics::Auto);
 
-llvm::Expected
+llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts);
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -68,10 +68,10 @@
 }
 } // namespace
 
-llvm::Expected
+llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts) {
-  llvm::Optional> Result;
+  llvm::Optional> Result;
   Server.codeComplete(File, Pos, Opts, capture(Result));
   return std::move(*Result);
 }
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -13,6 +13,7 @@
 #include "Compiler.h"
 #include "Matchers.h"
 #include "Protocol.h"
+#include "Quality.h"
 #include "SourceCode.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
@@ -43,70 +44,42 @@
 };
 
 // GMock helpers for matching completion items.
-MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
-MATCHER_P(Scope, Name, "") { return arg.SymbolScope == Name; }
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(Scope, S, "") { return arg.Scope == S; }
+MATCHER_P(Qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(Labeled, Label, "") {
-  std::string Indented;
-  if (!StringRef(Label).startswith(
-  CodeCompleteOptions().IncludeIndicator.Insert) &&
-  !StringRef(Label).startswith(
-  CodeCompleteOptions().IncludeIndicator.NoInsert))
-Indented =
-(Twine(CodeCompleteOptions().IncludeIndicator.NoInsert) + Label).str();
-  else
-Indented = Label;
-  return arg.label == Indented;
+  return arg.RequiredQualifier + arg.Name + arg.Signature == Label;
 }
 MATCHER_P(SigHelpLabeled, Label, "") { return arg.label == Label; }
-MATCHER_P(Kind, K, "") { return arg.kind == K; }
-MATCHER_P(Filter, F, "") { return arg.filterText == F; }
-MATCHER_P(Doc, D, "") { return arg.documentation == D; }
-MATCHER_P(Detail, D, "") { return arg.detail == D; }
+MATCHER_P(Kind, K, "") { return arg.Kind == K; }
+MATCHER_P(Doc, D, "") { return arg.Documentation == D; }
+MATCHER_P(ReturnType, D, "") { return arg.ReturnType == D; }
 MATCHER_P(InsertInclude, IncludeHeader, "") {
-  if (arg.additionalTextEdits.size() != 1)
-return false;
-  const auto &Edit = arg.additionalTextEdits[0];
-  if (Edit.range.start != Edit.range.end)
-return false;
-  SmallVector Matches;
-  llvm::Regex RE(R"(#include[ ]*(["<][^">]*[">]))");
-  return RE.match(Edit.newText, &Matches) && Matches[1] == IncludeHeader;
-}
-MATCHER_P(PlainText, Text, "") {
-  return arg.insertTextFormat == clangd::InsertTextFormat::PlainText &&
- arg.insertText == Text;
-}
-MATCHER_P(Snippet, Text, "") {
-  return arg.insertTextFormat == clangd::InsertTextFormat::Snippet &&
- arg.insertText == Text;
+  return arg.Header == IncludeHeader && bool(arg.HeaderInsertion);
 }
-MATCHER(NameContainsFilter, "") {
-  if (arg.filterText.empty())
-return true;
-  return llvm::StringRef(arg.insertText).contains(arg.filterText);
-}
-MATCHER(HasAdditionalEdits, "") { return !arg.additionalTextEdits.empty(); }
+MATCHER(InsertInclude, "") { return bool(arg.HeaderInsertion); }
+MATCHER_P(SnippetSuffix, Text, "") { return arg.SnippetSuffix == Text; }
 
 // Shorthand for Contains(Named(Name)).
-Matcher &> Has(std::string Name) {
+Matcher &> Has(std::string Name) {
   return Contains(Named(std::move(Name)));
 }
-Matcher &> Has(std::string Name,
+Matcher &> Has(std::string Name,
  CompletionItemKind K) {
   return Co

[PATCH] D48441: [clangd] Incorporate transitive #includes into code complete proximity scoring.

2018-07-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm.

Again, we might still want to measure the performance impact on files with 
potentially large #include tree ;)




Comment at: clangd/FileDistance.cpp:26
+//  /bar/foo = 1
+///foo = 1
+//  /foo/bar = 2

Shouldn't /foo a down from / and `2+1 = 3`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48441



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


[PATCH] D48716: [clang-format] Fix counting parameters/arguments for ObjC

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak marked 6 inline comments as done.
jolesiak added inline comments.



Comment at: lib/Format/FormatToken.h:247-248
+  /// If this is the first ObjC selector name in an ObjC method
+  /// definition or call, this contains the number of parts that whole selector
+  /// consist of.
   unsigned ObjCSelectorNameParts = 0;

benhamilton wrote:
> Grammar nit: that whole selector consist of -> that the whole selector 
> consists of
> 
Thanks!



Comment at: lib/Format/TokenAnnotator.cpp:519
+// FirstObjCSelectorName is set when a colon is found. This does
+// not work, however, when method has no parameters.
+// Here, we set FirstObjCSelectorName when the end of the expression is

benhamilton wrote:
> Grammar nit-pick: when method -> when the method
> 
Thanks!



Comment at: lib/Format/TokenAnnotator.cpp:520
+// not work, however, when method has no parameters.
+// Here, we set FirstObjCSelectorName when the end of the expression is
+// reached, in case it was not set already.

benhamilton wrote:
> expression -> method call
> 
Thanks!



Comment at: lib/Format/TokenAnnotator.cpp:627
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
+// For ObjC methods number of parameters is calculated differently as
+// method declarations have different structure (parameters are not inside

benhamilton wrote:
> Grammar nit-pick: methods number -> methods, the number
> 
Thanks!



Comment at: lib/Format/TokenAnnotator.cpp:628
+// For ObjC methods number of parameters is calculated differently as
+// method declarations have different structure (parameters are not inside
+// parenthesis scope).

benhamilton wrote:
> benhamilton wrote:
> > Grammar nit-picks:
> > 
> > * have different structure -> have a different structure
> > * parameters are not -> the parameters are not
> > 
> Why does parenthesis scope matter here? `updateParameterCount()` is called 
> from `parseSquare()`.
> 
> I'm not sure what the goal of this change is.
> 
Thanks!



Comment at: lib/Format/TokenAnnotator.cpp:628-629
+// For ObjC methods number of parameters is calculated differently as
+// method declarations have different structure (parameters are not inside
+// parenthesis scope).
 if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)

jolesiak wrote:
> benhamilton wrote:
> > benhamilton wrote:
> > > Grammar nit-picks:
> > > 
> > > * have different structure -> have a different structure
> > > * parameters are not -> the parameters are not
> > > 
> > Why does parenthesis scope matter here? `updateParameterCount()` is called 
> > from `parseSquare()`.
> > 
> > I'm not sure what the goal of this change is.
> > 
> Thanks!
My bad, I thought the word "parenthesis" can also mean any of "(", "[", "{", 
"<" (not only specifically the first one).
I've replaced with "a bracket scope".

I'll comment on the goal of this change in non-inline comment.


Repository:
  rC Clang

https://reviews.llvm.org/D48716



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


[PATCH] D48716: [clang-format] Fix counting parameters/arguments for ObjC

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak marked 6 inline comments as done.
jolesiak added a comment.

In https://reviews.llvm.org/D48716#1146796, @benhamilton wrote:

> > Count selector parts also for method declarations.
>
> What bug does this fix? Can you add a test which breaks before this change 
> and is fixed by this change?


Sorry for the confusion.

General comment to changes https://reviews.llvm.org/D48716, 
https://reviews.llvm.org/D48718, https://reviews.llvm.org/D48719, 
https://reviews.llvm.org/D48720 (which are the split of 
https://reviews.llvm.org/D48352):
These changes are separate, in the sense that they fix different issues. 
However, they should be chained as every change (apart from the first one) is 
based on previous ones: https://reviews.llvm.org/D48716 -> 
https://reviews.llvm.org/D48718 -> https://reviews.llvm.org/D48719 -> 
https://reviews.llvm.org/D48720. I don't know how to chain them in Phabricator 
(I should probably leave some comments about what every change is based on 
though).

https://reviews.llvm.org/D48716 fixes the mechanism of counting parameters. 
This is an internal change though and doesn't influence formatting on its own 
(at the current state). Its lack would be visible after applying 
https://reviews.llvm.org/D48719. Therefore, I'm not aware of any formatting 
test that fails before applying this change and succeeds after. As far as I 
know internal functions/methods are not tested at all. Thus, the tests are part 
of https://reviews.llvm.org/D48719.

This is why initially I put everything into one change: 
https://reviews.llvm.org/D48352, but I agree that it was not readable at all.


Repository:
  rC Clang

https://reviews.llvm.org/D48716



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


[PATCH] D48821: [clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.

2018-07-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48821



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


[PATCH] D48716: [clang-format] Fix counting parameters/arguments for ObjC

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak updated this revision to Diff 153689.
jolesiak added a comment.

Fix grammar mistakes.


Repository:
  rC Clang

https://reviews.llvm.org/D48716

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -515,11 +515,23 @@
 }
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
+// FirstObjCSelectorName is set when a colon is found. This does
+// not work, however, when the method has no parameters.
+// Here, we set FirstObjCSelectorName when the end of the method call 
is
+// reached, in case it was not set already.
+if (!Contexts.back().FirstObjCSelectorName) {
+FormatToken* Previous = CurrentToken->getPreviousNonComment();
+if (Previous && Previous->is(TT_SelectorName)) {
+  Previous->ObjCSelectorNameParts = 1;
+  Contexts.back().FirstObjCSelectorName = Previous;
+}
+} else {
+  Left->ParameterCount =
+  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts;
+}
 if (Contexts.back().FirstObjCSelectorName) {
   Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
   Contexts.back().LongestObjCSelectorName;
-  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts =
-  Left->ParameterCount;
   if (Left->BlockParameterCount > 1)
 Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName = 0;
 }
@@ -539,11 +551,6 @@
  TT_DesignatedInitializerLSquare)) {
   Left->Type = TT_ObjCMethodExpr;
   StartsObjCMethodExpr = true;
-  // ParameterCount might have been set to 1 before expression was
-  // recognized as ObjCMethodExpr (as '1 + number of commas' formula is
-  // used for other expression types). Parameter counter has to be,
-  // therefore, reset to 0.
-  Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
 // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
@@ -617,12 +624,12 @@
   }
 
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
+// For ObjC methods, the number of parameters is calculated differently as
+// method declarations have a different structure (the parameters are not
+// inside a bracket scope).
 if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
   ++Left->BlockParameterCount;
-if (Left->Type == TT_ObjCMethodExpr) {
-  if (Current->is(tok::colon))
-++Left->ParameterCount;
-} else if (Current->is(tok::comma)) {
+if (Current->is(tok::comma)) {
   ++Left->ParameterCount;
   if (!Left->Role)
 Left->Role.reset(new CommaSeparatedList(Style));
@@ -712,6 +719,7 @@
Contexts.back().LongestObjCSelectorName)
 Contexts.back().LongestObjCSelectorName =
 Tok->Previous->ColumnWidth;
+  ++Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts;
 }
   } else if (Contexts.back().ColonIsForRangeExpr) {
 Tok->Type = TT_RangeBasedForLoopColon;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -243,8 +243,9 @@
   /// e.g. because several of them are block-type.
   unsigned LongestObjCSelectorName = 0;
 
-  /// How many parts ObjC selector have (i.e. how many parameters method
-  /// has).
+  /// If this is the first ObjC selector name in an ObjC method
+  /// definition or call, this contains the number of parts that the whole
+  /// selector consist of.
   unsigned ObjCSelectorNameParts = 0;
 
   /// Stores the number of required fake parentheses and the


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -515,11 +515,23 @@
 }
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
+// FirstObjCSelectorName is set when a colon is found. This does
+// not work, however, when the method has no parameters.
+// Here, we set FirstObjCSelectorName when the end of the method call is
+// reached, in case it was not set already.
+if (!Contexts.back().FirstObjCSelectorName) {
+FormatToken* Previous = CurrentToken->getPreviousNonComment();
+if (Previous && Previous->is(TT_SelectorName)) {
+  Previous->ObjCSelectorNameParts = 1;
+  Contexts.back().FirstObjCSelectorName = Previous;
+}
+} else {
+

[PATCH] D48718: [clang-format] Prohibit breaking after a bracket opening ObjC method expression

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.

In https://reviews.llvm.org/D48718#1146805, @benhamilton wrote:

> Can you add a test, please?


The test could look like:

  a = [a aa:aa
 aa:aa];

with appropriate column limit.
Right now, however, this would be formatted:

  a =
  [a aa:aa aa:aa];

This behavior is improved in https://reviews.llvm.org/D48719. To avoid adding

  a =
  [a aa:aa aa:aa];

test in this change and changing it to:

  a = [a aa:aa
 aa:aa];

in https://reviews.llvm.org/D48719 I decided to omit it altogether in this 
change.

Sorry for the confusion. If you prefer me to add this test and modify in later 
commit I'll do it.


Repository:
  rC Clang

https://reviews.llvm.org/D48718



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


[clang-tools-extra] r336094 - [clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.

2018-07-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul  2 04:13:16 2018
New Revision: 336094

URL: http://llvm.org/viewvc/llvm-project?rev=336094&view=rev
Log:
[clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.

Summary:
This provides more structured information that embedders can use for rendering.
ClangdLSPServer continues to call render(), so NFC.

The patch is:
 - trivial changes to ClangdServer/ClangdLSPServer
 - mostly-mechanical updates to CodeCompleteTests etc for the new API
 - new direct tests of render() in CodeCompleteTests
 - tiny cleanups to CodeCompletionItem (operator<< and missing initializers)

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=336094&r1=336093&r2=336094&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Jul  2 04:13:16 2018
@@ -320,11 +320,15 @@ void ClangdLSPServer::onCodeAction(CodeA
 
 void ClangdLSPServer::onCompletion(TextDocumentPositionParams &Params) {
   Server.codeComplete(Params.textDocument.uri.file(), Params.position, CCOpts,
-  [](llvm::Expected List) {
+  [this](llvm::Expected List) {
 if (!List)
   return replyError(ErrorCode::InvalidParams,
 llvm::toString(List.takeError()));
-reply(*List);
+CompletionList LSPList;
+LSPList.isIncomplete = List->HasMore;
+for (const auto &R : List->Completions)
+  LSPList.items.push_back(R.render(CCOpts));
+reply(std::move(LSPList));
   });
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=336094&r1=336093&r2=336094&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Jul  2 04:13:16 2018
@@ -146,7 +146,7 @@ void ClangdServer::removeDocument(PathRe
 
 void ClangdServer::codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions &Opts,
-Callback CB) {
+Callback CB) {
   // Copy completion options for passing them to async task handler.
   auto CodeCompleteOpts = Opts;
   if (!CodeCompleteOpts.Index) // Respect overridden index.
@@ -156,7 +156,7 @@ void ClangdServer::codeComplete(PathRef
   std::shared_ptr PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
   auto Task = [PCHs, Pos, FS,
-   CodeCompleteOpts](Path File, Callback CB,
+   CodeCompleteOpts](Path File, Callback CB,
  llvm::Expected IP) {
 if (!IP)
   return CB(IP.takeError());
@@ -169,11 +169,7 @@ void ClangdServer::codeComplete(PathRef
 File, IP->Command, PreambleData ? &PreambleData->Preamble : nullptr,
 PreambleData ? PreambleData->Inclusions : std::vector(),
 IP->Contents, Pos, FS, PCHs, CodeCompleteOpts);
-CompletionList LSPResult;
-LSPResult.isIncomplete = Result.HasMore;
-for (const auto &Completion : Result.Completions)
-  LSPResult.items.push_back(Completion.render(CodeCompleteOpts));
-CB(std::move(LSPResult));
+CB(std::move(Result));
   };
 
   WorkScheduler.runWithPreamble("CodeComplete", File,

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=336094&r1=336093&r2=336094&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Jul  2 04:13:16 2018
@@ -141,7 +141,7 @@ public:
   /// when codeComplete results become available.
   void codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions &Opts

[PATCH] D48821: [clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.

2018-07-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336094: [clangd] ClangdServer::codeComplete return 
CodeCompleteResult, not LSP struct. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48821

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/CodeComplete.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
  clang-tools-extra/trunk/unittests/clangd/SyncAPI.h

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -534,7 +534,7 @@
   // can't parse the file.
   EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Position(),
clangd::CodeCompleteOptions()))
-  .items,
+  .Completions,
   IsEmpty());
   auto SigHelp = runSignatureHelp(Server, FooCpp, Position());
   ASSERT_TRUE(bool(SigHelp)) << "signatureHelp returned an error";
Index: clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
@@ -68,10 +68,10 @@
 }
 } // namespace
 
-llvm::Expected
+llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts) {
-  llvm::Optional> Result;
+  llvm::Optional> Result;
   Server.codeComplete(File, Pos, Opts, capture(Result));
   return std::move(*Result);
 }
Index: clang-tools-extra/trunk/unittests/clangd/SyncAPI.h
===
--- clang-tools-extra/trunk/unittests/clangd/SyncAPI.h
+++ clang-tools-extra/trunk/unittests/clangd/SyncAPI.h
@@ -22,7 +22,7 @@
 void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
 WantDiagnostics WantDiags = WantDiagnostics::Auto);
 
-llvm::Expected
+llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
 clangd::CodeCompleteOptions Opts);
 
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -13,6 +13,7 @@
 #include "Compiler.h"
 #include "Matchers.h"
 #include "Protocol.h"
+#include "Quality.h"
 #include "SourceCode.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
@@ -43,70 +44,42 @@
 };
 
 // GMock helpers for matching completion items.
-MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
-MATCHER_P(Scope, Name, "") { return arg.SymbolScope == Name; }
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(Scope, S, "") { return arg.Scope == S; }
+MATCHER_P(Qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(Labeled, Label, "") {
-  std::string Indented;
-  if (!StringRef(Label).startswith(
-  CodeCompleteOptions().IncludeIndicator.Insert) &&
-  !StringRef(Label).startswith(
-  CodeCompleteOptions().IncludeIndicator.NoInsert))
-Indented =
-(Twine(CodeCompleteOptions().IncludeIndicator.NoInsert) + Label).str();
-  else
-Indented = Label;
-  return arg.label == Indented;
+  return arg.RequiredQualifier + arg.Name + arg.Signature == Label;
 }
 MATCHER_P(SigHelpLabeled, Label, "") { return arg.label == Label; }
-MATCHER_P(Kind, K, "") { return arg.kind == K; }
-MATCHER_P(Filter, F, "") { return arg.filterText == F; }
-MATCHER_P(Doc, D, "") { return arg.documentation == D; }
-MATCHER_P(Detail, D, "") { return arg.detail == D; }
+MATCHER_P(Kind, K, "") { return arg.Kind == K; }
+MATCHER_P(Doc, D, "") { return arg.Documentation == D; }
+MATCHER_P(ReturnType, D, "") { return arg.ReturnType == D; }
 MATCHER_P(InsertInclude, IncludeHeader, "") {
-  if (arg.additionalTextEdits.size() != 1)
-return false;
-  const auto &Edit = arg.additionalTextEdits[0];
-  if (Edit.range.start != Edit.range.end)
-return false;
-  SmallVector Matches;
-  llvm::Regex RE(R"(#include[ ]*(["<][^">]*[">]))");
-  return RE.match(Edit.newText, &Matches) && Matches[1] == IncludeHeader;
-}
-MATCHER_P(PlainText, Text, "") {
-  return arg.insertTextFormat == clangd::InsertTextFormat::PlainText &&
- arg.insertText == Text;
-}
-MATCHER_P(Snippet, Text, "") {
-  return arg.insertTextFormat == clangd::InsertTextFormat::Sni

[PATCH] D48827: [clang-format ]Extend IncludeCategories regex documentation

2018-07-02 Thread Wim Leflere via Phabricator via cfe-commits
WimLeflere created this revision.
WimLeflere added reviewers: krasimir, Typz.
Herald added a subscriber: cfe-commits.

Extend the Clang-Format IncludeCategories documentation by adding a link to the 
supported regular expression standard (POSIX).
And extenting the example with a system header regex.
bug 35041 


Repository:
  rC Clang

https://reviews.llvm.org/D48827

Files:
  docs/ClangFormatStyleOptions.rst


Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -1279,6 +1279,10 @@
 **IncludeCategories** (``std::vector``)
   Regular expressions denoting the different ``#include`` categories
   used for ordering ``#includes``.
+  
+  `POSIX extended
+  `_
+  regular expressions are supported.
 
   These regular expressions are matched against the filename of an include
   (including the <> or "") in order. The value belonging to the first
@@ -1302,6 +1306,8 @@
 Priority:2
   - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
 Priority:3
+  - Regex:   '<[[:alnum:].]+>'
+Priority:4
   - Regex:   '.*'
 Priority:1
 


Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -1279,6 +1279,10 @@
 **IncludeCategories** (``std::vector``)
   Regular expressions denoting the different ``#include`` categories
   used for ordering ``#includes``.
+  
+  `POSIX extended
+  `_
+  regular expressions are supported.
 
   These regular expressions are matched against the filename of an include
   (including the <> or "") in order. The value belonging to the first
@@ -1302,6 +1306,8 @@
 Priority:2
   - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
 Priority:3
+  - Regex:   '<[[:alnum:].]+>'
+Priority:4
   - Regex:   '.*'
 Priority:1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48781: [ms] Fix mangling of char16_t and char32_t to be compatible with MSVC.

2018-07-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm with nit




Comment at: clang/lib/AST/MicrosoftMangle.cpp:3262
+  // Enforce our 32 bytes max, except wchar_t which gets 32 chars instead.
+  unsigned MaxBytesToWrite = SL->isWide() ? 64U : 32U;
+  unsigned NumBytesToWrite = std::min(MaxBytesToWrite, SL->getByteLength());

was the change from Mangle to Write for the suffix intentional? Mangle seems 
more fitting.



Comment at: clang/test/CodeGenCXX/mangle-ms-string-literals.cpp:751
+const char16_t *MaxU16String = u"012345678901234";
+// CHECK: 
@"??_C@_0CA@NFEFHIFO@0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA?$AA?$AA@"
+const char32_t *MaxU32String = U"0123456";

Oh, your godbolt does u"0123456789012345" (extra 5 at end here). If I drop 
that, the manglings match.


https://reviews.llvm.org/D48781



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


r336097 - [ms] Fix mangling of char16_t and char32_t to be compatible with MSVC.

2018-07-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Jul  2 05:31:20 2018
New Revision: 336097

URL: http://llvm.org/viewvc/llvm-project?rev=336097&view=rev
Log:
[ms] Fix mangling of char16_t and char32_t to be compatible with MSVC.

MSVC limits char16_t and char32_t string literal names to 32 bytes of character
data, not to 32 characters. wchar_t string literal names on the other hand can
get up to 64 bytes of character data.

https://reviews.llvm.org/D48781

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-string-literals.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=336097&r1=336096&r2=336097&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jul  2 05:31:20 2018
@@ -3164,9 +3164,9 @@ MicrosoftMangleContextImpl::mangleDynami
 
 void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
  raw_ostream &Out) {
-  //  ::= 0   # char
-  // ::= 1   # wchar_t
-  // ::= ??? # char16_t/char32_t will need a mangling too...
+  //  ::= 0   # char, char16_t, char32_t
+  // # (little endian char data in mangling)
+  // ::= 1   # wchar_t (big endian char data in mangling)
   //
   //  ::=   # the length of the literal
   //
@@ -3228,8 +3228,8 @@ void MicrosoftMangleContextImpl::mangleS
   // scheme.
   Mangler.mangleNumber(JC.getCRC());
 
-  // : The mangled name also contains the first 32 _characters_
-  // (including null-terminator bytes) of the StringLiteral.
+  // : The mangled name also contains the first 32 bytes
+  // (including null-terminator bytes) of the encoded StringLiteral.
   // Each character is encoded by splitting them into bytes and then encoding
   // the constituent bytes.
   auto MangleByte = [&Mangler](char Byte) {
@@ -3258,17 +3258,17 @@ void MicrosoftMangleContextImpl::mangleS
 }
   };
 
-  // Enforce our 32 character max.
-  unsigned NumCharsToMangle = std::min(32U, SL->getLength());
-  for (unsigned I = 0, E = NumCharsToMangle * SL->getCharByteWidth(); I != E;
-   ++I)
+  // Enforce our 32 bytes max, except wchar_t which gets 32 chars instead.
+  unsigned MaxBytesToMangle = SL->isWide() ? 64U : 32U;
+  unsigned NumBytesToMangle = std::min(MaxBytesToMangle, SL->getByteLength());
+  for (unsigned I = 0; I != NumBytesToMangle; ++I)
 if (SL->isWide())
   MangleByte(GetBigEndianByte(I));
 else
   MangleByte(GetLittleEndianByte(I));
 
   // Encode the NUL terminator if there is room.
-  if (NumCharsToMangle < 32)
+  if (NumBytesToMangle < MaxBytesToMangle)
 for (unsigned NullTerminator = 0; NullTerminator < SL->getCharByteWidth();
  ++NullTerminator)
   MangleByte(0);

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-string-literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-string-literals.cpp?rev=336097&r1=336096&r2=336097&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms-string-literals.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-string-literals.cpp Mon Jul  2 05:31:20 
2018
@@ -719,9 +719,35 @@ const wchar_t *LongWideString = L"012345
 // CHECK: 
@"??_C@_1EK@KFPEBLPK@?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AAA?$AAB@"
 const wchar_t *UnicodeLiteral = L"\ud7ff";
 // CHECK: @"??_C@_13IIHIAFKH@?W?$PP?$AA?$AA@"
+
 const char *U8Literal = u8"hi";
 // CHECK: @"??_C@_02PCEFGMJL@hi?$AA@"
+const char *LongU8Literal = u8"012345678901234567890123456789ABCDEF";
+// CHECK: @"??_C@_0CF@LABBIIMO@012345678901234567890123456789AB@"
+
 const char16_t *U16Literal = u"hi";
 // CHECK: @"??_C@_05OMLEGLOC@h?$AAi?$AA?$AA?$AA@"
+// Note this starts with o instead of 0. Else LongWideString would have
+// the same initializer and CodeGenModule::ConstantStringMap would map them
+// to the same global with a shared mangling.
+// FIXME: ConstantStringMap probably shouldn't map things with the same data
+// but different manglings to the same variable.
+const char16_t *LongU16Literal = u"o12345678901234567890123456789ABCDEF";
+// CHECK: 
@"??_C@_0EK@FEAOBHPP@o?$AA1?$AA2?$AA3?$AA4?$AA5?$AA6?$AA7?$AA8?$AA9?$AA0?$AA1?$AA2?$AA3?$AA4?$AA5?$AA@"
+
 const char32_t *U32Literal = U"hi";
 // CHECK: @"??_C@_0M@GFNAJIPG@h?$AA?$AA?$AAi?$AA?$AA?$AA?$AA?$AA?$AA?$AA@"
+const char32_t *LongU32Literal = U"012345678901234567890123456789ABCDEF";
+// CHECK: 
@"??_C@_0JE@IMHFEDAA@0?$AA?$AA?$AA1?$AA?$AA?$AA2?$AA?$AA?$AA3?$AA?$AA?$AA4?$AA?$AA?$AA5?$AA?$AA?$AA6?$AA?$AA?$AA7?$AA?$AA?$AA@"
+
+// These all have just the right length that the trailing 0 just fits.
+const char *MaxASCIIString = "012345678901234567890123

[PATCH] D48781: [ms] Fix mangling of char16_t and char32_t to be compatible with MSVC.

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

Thanks, landed with nit addressed in r336097.


https://reviews.llvm.org/D48781



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


[PATCH] D48764: [Analyzer] Hotfix for iterator checkers: Mark left-hand side of `SymIntExpr` objects as live in the program state maps.

2018-07-02 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 153698.
baloghadamsoftware added a comment.

Updated according to the comments and assertions added to fail the tests 
without the fix.


https://reviews.llvm.org/D48764

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -488,14 +488,16 @@
   // alive
   auto RegionMap = State->get();
   for (const auto Reg : RegionMap) {
-const auto Pos = Reg.second;
-SR.markLive(Pos.getOffset());
+const auto Offset = Reg.second.getOffset();
+for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
+  SR.markLive(*i);
   }
 
   auto SymbolMap = State->get();
   for (const auto Sym : SymbolMap) {
-const auto Pos = Sym.second;
-SR.markLive(Pos.getOffset());
+const auto Offset = Sym.second.getOffset();
+for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
+  SR.markLive(*i);
   }
 
   auto ContMap = State->get();
@@ -1159,19 +1161,23 @@
   auto &SVB = State->getStateManager().getSValBuilder();
   const auto comparison =
   SVB.evalBinOp(State, BO_EQ, nonloc::SymbolVal(Pos1.getOffset()),
-nonloc::SymbolVal(Pos2.getOffset()), 
SVB.getConditionType())
-  .getAs();
-
-  if (comparison) {
-auto NewState = State->assume(*comparison, Equal);
-if (const auto CompSym = comparison->getAsSymbol()) {
-  return assumeNoOverflow(NewState, cast(CompSym)->getLHS(), 
2);
-}
-
-return NewState;
+nonloc::SymbolVal(Pos2.getOffset()),
+SVB.getConditionType());
+
+  assert(comparison.getAs() &&
+"Symbol comparison must by a `DefinedSVal`");
+
+  auto NewState = State->assume(comparison.castAs(), Equal);
+  if (const auto CompSym = comparison.getAsSymbol()) {
+assert(isa(CompSym) &&
+   "Symbol comparison must be a `SymIntExpr`");
+assert(BinaryOperator::isComparisonOp(
+   cast(CompSym)->getOpcode()) &&
+   "Symbol comparison must be a comparison");
+return assumeNoOverflow(NewState, cast(CompSym)->getLHS(), 2);
   }
 
-  return State;
+  return NewState;
 }
 
 bool isZero(ProgramStateRef State, const NonLoc &Val) {
@@ -1225,14 +1231,12 @@
   auto &SVB = State->getStateManager().getSValBuilder();
 
   const auto comparison =
-  SVB.evalBinOp(State, Opc, NL1, NL2, SVB.getConditionType())
-  .getAs();
+SVB.evalBinOp(State, Opc, NL1, NL2, SVB.getConditionType());
 
-  if (comparison) {
-return !State->assume(*comparison, false);
-  }
+  assert(comparison.getAs() &&
+"Symbol comparison must by a `DefinedSVal`");
 
-  return false;
+  return !State->assume(comparison.castAs(), false);
 }
 
 } // namespace


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -488,14 +488,16 @@
   // alive
   auto RegionMap = State->get();
   for (const auto Reg : RegionMap) {
-const auto Pos = Reg.second;
-SR.markLive(Pos.getOffset());
+const auto Offset = Reg.second.getOffset();
+for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
+  SR.markLive(*i);
   }
 
   auto SymbolMap = State->get();
   for (const auto Sym : SymbolMap) {
-const auto Pos = Sym.second;
-SR.markLive(Pos.getOffset());
+const auto Offset = Sym.second.getOffset();
+for (auto i = Offset->symbol_begin(); i != Offset->symbol_end(); ++i)
+  SR.markLive(*i);
   }
 
   auto ContMap = State->get();
@@ -1159,19 +1161,23 @@
   auto &SVB = State->getStateManager().getSValBuilder();
   const auto comparison =
   SVB.evalBinOp(State, BO_EQ, nonloc::SymbolVal(Pos1.getOffset()),
-nonloc::SymbolVal(Pos2.getOffset()), SVB.getConditionType())
-  .getAs();
-
-  if (comparison) {
-auto NewState = State->assume(*comparison, Equal);
-if (const auto CompSym = comparison->getAsSymbol()) {
-  return assumeNoOverflow(NewState, cast(CompSym)->getLHS(), 2);
-}
-
-return NewState;
+nonloc::SymbolVal(Pos2.getOffset()),
+SVB.getConditionType());
+
+  assert(comparison.getAs() &&
+"Symbol comparison must by a `DefinedSVal`");
+
+  auto NewState = State->assume(comparison.castAs(), Equal);
+  if (const auto CompSym = comparison.getAsSymbol()) {
+assert(isa(CompSym) &&
+   "Symbol comparison must be a `SymIntExpr`");
+assert(BinaryOperator::isComparisonOp(
+   cast(CompSym)->getOpcode()) &&
+   "Symbol comparison must be a comparison");
+return assumeNoOverflow(NewState, cast(CompSym)->getLHS(), 2);
   }
 
-  return State;
+  return NewState;
 }
 
 bool isZer

[PATCH] D48427: [Analyzer] Fix for D47417 to make the tests pass

2018-07-02 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Hmm, then the only solution that comes to my mind is to link iterator positions 
to container data instead of the container regions. I also have to store a link 
to the class definition of the container in the container data for the 
invalidation rules. Container data can then be detached from the container 
region until the last iterator to the container is clean up. Is it OK?


https://reviews.llvm.org/D48427



___
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-02 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added reviewers: SjoerdMeijer, jgreenhalgh, rengolin.
kosarev added a project: clang.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.

This patch adds support for vrndi_f32() and vrndiq_f32() intrinsics in AArch32 
mode and for vrndns_f32() intrinsic in AArch64 mode.


https://reviews.llvm.org/D48829

Files:
  include/clang/Basic/arm_neon.td
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/aarch64-neon-misc.c
  test/CodeGen/arm-neon-directed-rounding.c
  test/CodeGen/arm64-vrnd.c

Index: test/CodeGen/arm64-vrnd.c
===
--- test/CodeGen/arm64-vrnd.c
+++ test/CodeGen/arm64-vrnd.c
@@ -2,50 +2,21 @@
 
 #include 
 
-int32x2_t rnd1(float32x2_t a) { return vrnd_f32(a); }
-// CHECK: call <2 x float> @llvm.trunc.v2f32(<2 x float>
-int32x4_t rnd3(float32x4_t a) { return vrndq_f32(a); }
-// CHECK: call <4 x float> @llvm.trunc.v4f32(<4 x float>
 int64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
 // CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double>
 
-
-int32x2_t rnd7(float32x2_t a) { return vrndn_f32(a); }
-// CHECK: call <2 x float> @llvm.aarch64.neon.frintn.v2f32(<2 x float>
-int32x4_t rnd8(float32x4_t a) { return vrndnq_f32(a); }
-// CHECK: call <4 x float> @llvm.aarch64.neon.frintn.v4f32(<4 x float>
-int64x2_t rnd9(float64x2_t a) { return vrndnq_f64(a); }
-// CHECK: call <2 x double> @llvm.aarch64.neon.frintn.v2f64(<2 x double>
-int64x2_t rnd10(float64x2_t a) { return vrndnq_f64(a); }
+int64x2_t rnd9(float64x2_t a) { return vrndnq_f64(a); }
 // CHECK: call <2 x double> @llvm.aarch64.neon.frintn.v2f64(<2 x double>
 
-int32x2_t rnd11(float32x2_t a) { return vrndm_f32(a); }
-// CHECK: call <2 x float> @llvm.floor.v2f32(<2 x float>
-int32x4_t rnd12(float32x4_t a) { return vrndmq_f32(a); }
-// CHECK: call <4 x float> @llvm.floor.v4f32(<4 x float>
 int64x2_t rnd13(float64x2_t a) { return vrndmq_f64(a); }
 // CHECK: call <2 x double> @llvm.floor.v2f64(<2 x double>
-int64x2_t rnd14(float64x2_t a) { return vrndmq_f64(a); }
-// CHECK: call <2 x double> @llvm.floor.v2f64(<2 x double>
 
-int32x2_t rnd15(float32x2_t a) { return vrndp_f32(a); }
-// CHECK: call <2 x float> @llvm.ceil.v2f32(<2 x float>
-int32x4_t rnd16(float32x4_t a) { return vrndpq_f32(a); }
-// CHECK: call <4 x float> @llvm.ceil.v4f32(<4 x float>
 int64x2_t rnd18(float64x2_t a) { return vrndpq_f64(a); }
 // CHECK: call <2 x double> @llvm.ceil.v2f64(<2 x double>
 
-int32x2_t rnd19(float32x2_t a) { return vrnda_f32(a); }
-// CHECK: call <2 x float> @llvm.round.v2f32(<2 x float>
-int32x4_t rnd20(float32x4_t a) { return vrndaq_f32(a); }
-// CHECK: call <4 x float> @llvm.round.v4f32(<4 x float>
 int64x2_t rnd22(float64x2_t a) { return vrndaq_f64(a); }
 // CHECK: call <2 x double> @llvm.round.v2f64(<2 x double>
 
-int32x2_t rnd23(float32x2_t a) { return vrndx_f32(a); }
-// CHECK: call <2 x float> @llvm.rint.v2f32(<2 x float>
-int32x4_t rnd24(float32x4_t a) { return vrndxq_f32(a); }
-// CHECK: call <4 x float> @llvm.rint.v4f32(<4 x float>
 int64x2_t rnd25(float64x2_t a) { return vrndxq_f64(a); }
 // CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double>
 
Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,96 +1,128 @@
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
 // RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
-// RUN: opt -S -mem2reg | FileCheck %s
+// RUN: opt -S -mem2reg | FileCheck -check-prefixes=CHECK,CHECK-A32 %s
+// RUN: %clang_cc1 -triple arm64-linux-gnueabihf -target-feature +neon \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck -check-prefixes=CHECK,CHECK-A64 %s
 
 #include 
 
-// CHECK-LABEL: define <2 x float> @test_vrnda_f32(<2 x float> %a) #0 {
-// CHECK:   [[VRNDA_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrinta.v2f32(<2 x float> %a) #2
-// CHECK:   ret <2 x float> [[VRNDA_V1_I]]
+// CHECK-LABEL: define <2 x float> @test_vrnda_f32(<2 x float> %a)
+// CHECK-A32: [[VRNDA_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrinta.v2f32(<2 x float> %a)
+// CHECK-A64: [[VRNDA_V1_I:%.*]] = call <2 x float> @llvm.round.v2f32(<2 x float> %a)
+// CHECK: ret <2 x float> [[VRNDA_V1_I]]
 float32x2_t test_vrnda_f32(float32x2_t a) {
   return vrnda_f32(a);
 }
 
-// CHECK-LABEL: define <4 x float> @test_vrndaq_f32(<4 x float> %a) #0 {
-// CHECK:   [[VRNDAQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrinta.v4f32(<4 x float> %a) #2
-// CHECK:   ret <4 x float> [[VRNDAQ_V1_I]]
+// CHECK-LABEL: define <4 x float> @test_vrndaq_f32(<4 x float> %a)
+// CHECK-A32: [[VRNDAQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrinta.v4f32(<4 x float> %a)
+// CHECK-A64: [[VRNDAQ_V1_I:%.*]] = call <4 x float> @llvm.round.v4f32(<4 x float> %a)
+// CHECK: ret <4 x floa

[PATCH] D48720: [clang-format] Put ObjC method arguments into one line when they fit

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak updated this revision to Diff 153705.
jolesiak added a comment.

Improve condition.


Repository:
  rC Clang

https://reviews.llvm.org/D48720

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -678,6 +678,18 @@
   verifyFormat("[(id)foo bar:(id) ? baz : quux];");
   verifyFormat("4 > 4 ? (id)a : (id)baz;");
 
+  unsigned PreviousColumnLimit = Style.ColumnLimit;
+  Style.ColumnLimit = 50;
+  // Instead of:
+  // bool a =
+  // ([object a:42] == 0 || [object a:42
+  //b:42] == 0);
+  verifyFormat("bool a = ([object a:42] == 0 ||\n"
+   "  [object a:42 b:42] == 0);");
+  Style.ColumnLimit = PreviousColumnLimit;
+  verifyFormat("bool a = ([ a] == a ||\n"
+   "  [ a] == );");
+
   // This tests that the formatter doesn't break after "backing" but before ":",
   // which would be at 80 columns.
   verifyFormat(
@@ -754,11 +766,10 @@
   "[self a:aaa, aaa, aaa,\n"
   "aaa, aaa, aaa,\n"
   "aaa, aaa];");
+
   verifyFormat("[self // break\n"
"  a:a\n"
"aaa:aaa];");
-  verifyFormat("bool a = ([ a] == a ||\n"
-   "  [ a] == );");
 
   // Formats pair-parameters.
   verifyFormat("[I drawRectOn:surface ofSize:aa:bbb atOrigin:cc:dd];");
@@ -803,6 +814,54 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
+  Style.ColumnLimit = 20;
+  verifyFormat("a = [a aa:aa\n"
+   "   aa:aa];");
+  verifyFormat("aa = [aa aa:aa\n"
+   " aa:aa];");
+
+  // Message receiver taking multiple lines.
+  // Non-corner case.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] a:42 b:42];");
+  // Arguments just fit into one line.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42 b:42];");
+  // Arguments just over a column limit.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42\n"
+   "bb:42];");
+  // Arguments just fit into one line.
+  Style.ColumnLimit = 23;
+  verifyFormat("[[obj a:42\n"
+   "  b:42\n"
+   "  c:42\n"
+   "  d:42] e:42 f:42];");
+
+  // Arguments do not fit into one line with a receiver.
+  Style.ColumnLimit = 20;
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42];");
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42\n"
+   "c:42];");
+  verifyFormat("[[obj aa:42\n"
+   "   b:42]\n"
+   "cc:42\n"
+   " d:42];");
+
+  // Avoid breaking receiver expression.
+  Style.ColumnLimit = 30;
+  verifyFormat("fooo =\n"
+   "[[obj fooo] aaa:42\n"
+   "aaa:42];");
+  verifyFormat("[[[obj foo] bar] aa:42\n"
+   " bb:42\n"
+   " cc:42];");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -515,11 +515,23 @@
 }
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
+// FirstObjCSelectorName is set when a colon is found. This does
+// not work, however, when the method has no parameters.
+// Here, we set FirstObjCSelectorName when the end of the method call is
+// reached, in case it was not set already.
+if (!Contexts.back().FirstObjCSelectorName) {
+FormatToken* Previous = CurrentToken->getPreviousNonComment();
+if (Previous && Previous->is(TT_SelectorName)) {
+  Previous->ObjCSelectorNameParts = 1;
+  Contexts.back().FirstObjCSelectorName = Previous;
+}
+} else {
+  Left->ParameterCount =
+  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts;
+}
 if (Contexts.back().FirstObjCSelectorName) {
   Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
   Contexts.back().LongestObjCSelectorName;
-  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts =
-  Left->ParameterCount

[PATCH] D48720: [clang-format] Put ObjC method arguments into one line when they fit

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak updated this revision to Diff 153706.
jolesiak added a comment.

Rebase.


Repository:
  rC Clang

https://reviews.llvm.org/D48720

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -820,6 +820,48 @@
   verifyFormat("aa = [aa aa:aa\n"
" aa:aa];");
 
+  // Message receiver taking multiple lines.
+  // Non-corner case.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] a:42 b:42];");
+  // Arguments just fit into one line.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42 b:42];");
+  // Arguments just over a column limit.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42\n"
+   "bb:42];");
+  // Arguments just fit into one line.
+  Style.ColumnLimit = 23;
+  verifyFormat("[[obj a:42\n"
+   "  b:42\n"
+   "  c:42\n"
+   "  d:42] e:42 f:42];");
+
+  // Arguments do not fit into one line with a receiver.
+  Style.ColumnLimit = 20;
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42];");
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42\n"
+   "c:42];");
+  verifyFormat("[[obj aa:42\n"
+   "   b:42]\n"
+   "cc:42\n"
+   " d:42];");
+
+  // Avoid breaking receiver expression.
+  Style.ColumnLimit = 30;
+  verifyFormat("fooo =\n"
+   "[[obj fooo] aaa:42\n"
+   "aaa:42];");
+  verifyFormat("[[[obj foo] bar] aa:42\n"
+   " bb:42\n"
+   " cc:42];");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1398,6 +1398,30 @@
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
+  // Reevaluate whether ObjC message arguments fit into one line.
+  // If a receiver spans multiple lines, e.g.:
+  //   [[object block:^{
+  // return 42;
+  //   }] a:42 b:42];
+  // BreakBeforeParameter is calculated based on an incorrect assumption
+  // (it is checked whether the whole expression fits into one line without
+  // considering a line break inside a message receiver).
+  // We check whether arguements fit after receiver scope closer (into the same
+  // line).
+  if (State.Stack.back().BreakBeforeParameter && Current.MatchingParen &&
+  Current.MatchingParen->Previous) {
+const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
+if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
+CurrentScopeOpener.MatchingParen) {
+  int NecessarySpaceInLine =
+  getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
+  CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
+  if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
+  Style.ColumnLimit)
+State.Stack.back().BreakBeforeParameter = false;
+}
+  }
+
   if (Current.is(tok::r_square)) {
 // If this ends the array subscript expr, reset the corresponding value.
 const FormatToken *NextNonComment = Current.getNextNonComment();


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -820,6 +820,48 @@
   verifyFormat("aa = [aa aa:aa\n"
" aa:aa];");
 
+  // Message receiver taking multiple lines.
+  // Non-corner case.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] a:42 b:42];");
+  // Arguments just fit into one line.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42 b:42];");
+  // Arguments just over a column limit.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42\n"
+   "bb:42];");
+  // Arguments just fit into one line.
+  Style.ColumnLimit = 23;
+  verifyFormat("[[obj a:42\n"
+   "  b:42\n"
+   "  c:42\n"
+   "  d:42] e:42 f:42];");
+
+  // Arguments do not fit into one line with a receiver.
+  Style.ColumnLimit = 20;
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42];");
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42\n"
+   "c:42];");
+  verifyFormat("[[obj aa:42\n"
+   

[PATCH] D48720: [clang-format] Put ObjC method arguments into one line when they fit

2018-07-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak marked an inline comment as done.
jolesiak added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1411
+  // line).
+  if (Current.MatchingParen && Current.MatchingParen->Previous) {
+const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;

benhamilton wrote:
> Should we check if `State.Stack.back().BreakBeforeParameter` is `true` before 
> doing any of this?
I think that performance-wise it wouldn't be worth adding.
However, as this section is about "reevaluation" I think it's better to add 
this check, as what we mean is really "If we decided earlier that breaks are 
necessary, check once again".


Repository:
  rC Clang

https://reviews.llvm.org/D48720



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


[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-07-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

ping^3


Repository:
  rL LLVM

https://reviews.llvm.org/D47814



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


r336108 - Test commit access

2018-07-02 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Mon Jul  2 07:14:07 2018
New Revision: 336108

URL: http://llvm.org/viewvc/llvm-project?rev=336108&view=rev
Log:
Test commit access

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=336108&r1=336107&r2=336108&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Jul  2 07:14:07 2018
@@ -274,7 +274,7 @@ public:
 };
 
 // This class provides generic methods to write tests which can check internal
-// attributes of AST nodes like getPreviousDecl(), isVirtual(), etc.  Also,
+// attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. Also,
 // this fixture makes it possible to import from several "From" contexts.
 class ASTImporterTestBase : public ParameterizedTestsFixture {
 


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


Re: r336021 - PR33924: merge local declarations that have linkage of some kind within

2018-07-02 Thread Hans Wennborg via cfe-commits
Hi Richard,

This introduced test failures on Windows, but for some reason only in
32-bit builds: https://bugs.llvm.org/show_bug.cgi?id=38015

I don't know what's going on yet, just finished the bisection. Maybe
it reproduces in 32-bit linux builds too?

 - Hans

On Fri, Jun 29, 2018 at 11:58 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Fri Jun 29 14:58:50 2018
> New Revision: 336021
>
> URL: http://llvm.org/viewvc/llvm-project?rev=336021&view=rev
> Log:
> PR33924: merge local declarations that have linkage of some kind within
> merged function definitions; also merge functions with deduced return
> types.
>
> This seems like two independent fixes, but unfortunately they are hard
> to separate because it's challenging to reliably test either one of them
> without also testing the other.
>
> A complication arises with deduced return type support: we need the type
> of the function in order to know how to merge it, but we can't load the
> actual type of the function because it might reference an entity
> declared within the function (and we need to have already merged the
> function to correctly merge that entity, which we would need to do to
> determine if the function types match). So we instead compare the
> declared function type when merging functions, and defer loading the
> actual type of a function with a deduced type until we've finished
> loading and merging the function.
>
> Added:
> cfe/trunk/test/Modules/merge-deduced-return.cpp
> cfe/trunk/test/Modules/merge-lambdas.cpp
> cfe/trunk/test/Modules/merge-static-locals.cpp
> Modified:
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Serialization/ASTCommon.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=336021&r1=336020&r2=336021&view=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Jun 29 14:58:50 2018
> @@ -546,7 +546,7 @@ private:
>
>/// Mergeable declaration contexts that have anonymous declarations
>/// within them, and those anonymous declarations.
> -  llvm::DenseMap>
> +  llvm::DenseMap>
>  AnonymousDeclarationsForMerging;
>
>struct FileDeclsInfo {
>
> Modified: cfe/trunk/lib/Serialization/ASTCommon.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=336021&r1=336020&r2=336021&view=diff
> ==
> --- cfe/trunk/lib/Serialization/ASTCommon.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTCommon.cpp Fri Jun 29 14:58:50 2018
> @@ -419,9 +419,21 @@ bool serialization::needsAnonymousDeclar
>  return true;
>}
>
> -  // Otherwise, we only care about anonymous class members.
> +  // At block scope, we number everything that we need to deduplicate, since 
> we
> +  // can't just use name matching to keep things lined up.
> +  // FIXME: This is only necessary for an inline function or a template or
> +  // similar.
> +  if (D->getLexicalDeclContext()->isFunctionOrMethod()) {
> +if (auto *VD = dyn_cast(D))
> +  return VD->isStaticLocal();
> +// FIXME: What about CapturedDecls (and declarations nested within them)?
> +return isa(D) || isa(D);
> +  }
> +
> +  // Otherwise, we only care about anonymous class members / block-scope 
> decls.
> +  // FIXME: We need to handle lambdas and blocks within inline / templated
> +  // variables too.
>if (D->getDeclName() || !isa(D->getLexicalDeclContext()))
>  return false;
>return isa(D) || isa(D);
>  }
> -
>
> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=336021&r1=336020&r2=336021&view=diff
> ==
> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jun 29 14:58:50 2018
> @@ -87,7 +87,7 @@ namespace clang {
>
>  using RecordData = ASTReader::RecordData;
>
> -TypeID TypeIDForTypeDecl = 0;
> +TypeID DeferredTypeID = 0;
>  unsigned AnonymousDeclNumber;
>  GlobalDeclID NamedDeclForTagDecl = 0;
>  IdentifierInfo *TypedefNameForLinkage = nullptr;
> @@ -177,6 +177,8 @@ namespace clang {
>  void MergeDefinitionData(ObjCProtocolDecl *D,
>   struct ObjCProtocolDecl::DefinitionData 
> &&NewDD);
>
> +static DeclContext *getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC);
> +
>  static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
>   DeclContext *DC,
>   un

[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

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

I don't think that this is the intended behavior of the `#pragma clang loop`. 
it is better to ask the author of this pragma is this correct or not.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:

> I don't think that this is the intended behavior of the `#pragma clang loop`. 
> it is better to ask the author of this pragma is this correct or not.


It is the intended behavior that the memory accesses are independent with 
respect to the outer (annotated) loop (even if those accesses are within an 
inner loop). They're not independent with respect to the inner loop unless that 
loop is also annotated. Thus, this looks correct.

Michael, can you please add a test with two inner loops, one where more than 
one is annotated, and one where only the outer loop is annotated? It's not 
clear to me that I->setMetadata will do the right thing here in the former case.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:

> I don't think that this is the intended behavior of the `#pragma clang loop`. 
> it is better to ask the author of this pragma is this correct or not.


I understand it as the intended behavior of the `assume_safety` option (also 
used for `#pragma omp simd`).

@tyler.nowicki What is the intended behaviour?


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[PATCH] D48833: [Driver] Add PPC64 as supported for Scudo

2018-07-02 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad created this revision.
cryptoad added reviewers: eugenis, alekseyshl.

Scudo works on PPC64 as is, so mark the architecture as supported for it. This
will also require a change to config-ix.cmake on the compiler-rt side.

Update the tests accordingly.


Repository:
  rC Clang

https://reviews.llvm.org/D48833

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


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -670,6 +670,8 @@
 // RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
 // RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SCUDO
 // RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-SCUDO
+// RUN: %clang -target powerpc64-unknown-linux -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SCUDO
+// RUN: %clang -target powerpc64le-unknown-linux -fsanitize=scudo %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-SCUDO
 // CHECK-SCUDO: "-fsanitize=scudo"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SCUDO-PIE
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -931,7 +931,8 @@
 Res |= SanitizerKind::Efficiency;
   if (IsX86 || IsX86_64)
 Res |= SanitizerKind::Function;
-  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
+  IsPowerPC64)
 Res |= SanitizerKind::Scudo;
   if (IsX86_64 || IsAArch64) {
 Res |= SanitizerKind::HWAddress;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -670,6 +670,8 @@
 // RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
 // RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
 // RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
+// RUN: %clang -target powerpc64-unknown-linux -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
+// RUN: %clang -target powerpc64le-unknown-linux -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO
 // CHECK-SCUDO: "-fsanitize=scudo"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-PIE
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -931,7 +931,8 @@
 Res |= SanitizerKind::Efficiency;
   if (IsX86 || IsX86_64)
 Res |= SanitizerKind::Function;
-  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
+  IsPowerPC64)
 Res |= SanitizerKind::Scudo;
   if (IsX86_64 || IsAArch64) {
 Res |= SanitizerKind::HWAddress;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48159: [clangd] Implement hover for "auto" and "decltype"

2018-07-02 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 153737.
malaperle added a comment.

Tweak comment with FIXME.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48159

Files:
  clangd/XRefs.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -343,6 +343,13 @@
 
   OneTest Tests[] = {
   {
+  R"cpp(// No hover
+^int main() {
+}
+  )cpp",
+  "",
+  },
+  {
   R"cpp(// Local variable
 int main() {
   int bonjour;
@@ -637,16 +644,275 @@
   )cpp",
   "",
   },
+  {
+  R"cpp(// Simple initialization with auto
+void foo() {
+  ^auto i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const auto
+void foo() {
+  const ^auto i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const auto&
+void foo() {
+  const ^auto& i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with auto&
+void foo() {
+  ^auto& i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Auto with initializer list.
+namespace std
+{
+  template
+  class initializer_list {};
+}
+void foo() {
+  ^auto i = {1,2};
+}
+  )cpp",
+  "class std::initializer_list",
+  },
+  {
+  R"cpp(// User defined conversion to auto
+struct Bar {
+  operator ^auto() const { return 10; }
+};
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with decltype(auto)
+void foo() {
+  ^decltype(auto) i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const decltype(auto)
+void foo() {
+  const int j = 0;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "const int",
+  },
+  {
+  R"cpp(// Simple initialization with const& decltype(auto)
+void foo() {
+  int k = 0;
+  const int& j = k;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "const int &",
+  },
+  {
+  R"cpp(// Simple initialization with & decltype(auto)
+void foo() {
+  int k = 0;
+  int& j = k;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "int &",
+  },
+  {
+  R"cpp(// decltype with initializer list: nothing
+namespace std
+{
+  template
+  class initializer_list {};
+}
+void foo() {
+  ^decltype(auto) i = {1,2};
+}
+  )cpp",
+  "",
+  },
+  {
+  R"cpp(// auto function return with trailing type
+struct Bar {};
+^auto test() -> decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// trailing return type
+struct Bar {};
+auto test() -> ^decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// auto in function return
+struct Bar {};
+^auto test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// auto& in function return
+struct Bar {};
+^auto& test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// const auto& in function return
+struct Bar {};
+const ^auto& test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// decltype(auto) in function return
+struct Bar {};
+^decltype(auto) test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// decltype(auto) reference in function return
+struct Bar {};
+^decltype(auto) test() {
+  int a;
+  return (a);
+}
+  )cpp",
+  "int &",
+  },
+  {
+  R"cpp(// decltype lvalue reference
+void foo() {
+   

[PATCH] D48159: [clangd] Implement hover for "auto" and "decltype"

2018-07-02 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/XRefs.cpp:559
+  //- auto& i = 1;
+  bool VisitDeclaratorDecl(DeclaratorDecl *D) {
+if (!D->getTypeSourceInfo() ||

klimek wrote:
> klimek wrote:
> > malaperle wrote:
> > > klimek wrote:
> > > > sammccall wrote:
> > > > > malaperle wrote:
> > > > > > sammccall wrote:
> > > > > > > out of curiosity, why not implement `VisitTypeLoc` and handle all 
> > > > > > > the cases where it turns out to be `auto` etc?
> > > > > > > Even for `auto&` I'd expect the inner `auto` to have a `TypeLoc` 
> > > > > > > you could visit, saving the trouble of unwrapping.
> > > > > > > 
> > > > > > > (I'm probably wrong about all this, I don't know the AST well. 
> > > > > > > But I'd like to learn!)
> > > > > > From what I saw, there are actually two different AutoType* for 
> > > > > > each textual "auto". The AutoType* containing the deduced type does 
> > > > > > not get visited via a typeloc. It's not entirely clear to me why 
> > > > > > since I don't know the AST well either. I was thinking maybe the 
> > > > > > first is created when the type is not deduced yet and later on, 
> > > > > > then the rest of the function or expression is parsed, a second one 
> > > > > > with the actual type deduced is created. If I look at the code 
> > > > > > paths where they are created, it seems like this is roughly what's 
> > > > > > happening. The first one is created when the declarator is parsed 
> > > > > > (no deduced type yet) and the second is created when the expression 
> > > > > > of the initializer (or return statement) is evaluated and the type 
> > > > > > is then deduced. The visitor only visits the first one's typeloc. I 
> > > > > > don't think I'm knowledgeable enough to say whether or not that's a 
> > > > > > bug but it seems on purpose that it is modelled this way. Although 
> > > > > > it would be much nicer to only have to visit typelocs...
> > > > > > The AutoType* containing the deduced type does not get visited via 
> > > > > > a typeloc
> > > > > Ah, OK.
> > > > > Could you add a high level comment (maybe on the class) saying this 
> > > > > is the reason for the implementation? Otherwise as a reader I'll 
> > > > > think "this seems unneccesarily complicated" but not understand why.
> > > > > 
> > > > > @klimek Can you shed any light on this?
> > > > Can't you go from AutoTypeLoc -> AutoType -> getDeducedType()?
> > > The visitor doesn't visit the AutoTypeLoc that has the deduced type. In 
> > > fact, there are two AutoType* instances. I'm not sure that's is a bug 
> > > that there are two AutoType*, or if not visiting both AutoTypeLoc is a 
> > > bug...or neither.
> > +Richard Smith:
> > 
> > This is weird. If I just create a minimal example:
> >   int f() {
> > auto i = f();
> > return i;
> >   }
> > 
> > I only get the undeduced auto type - Richard, in which cases are auto-typed 
> > being deduced? The AST dump doens't give an indication that there was an 
> > auto involved at all. Is this the famous syntactic vs. smenatic form 
> > problem? Do we have a backlink between the AutoTypeLoc and the deduced type 
> > somewhere?
> Given that Richard is known to have ~1 month ping times now and then I think 
> it's fine to land this with a FIXME above to figure out how to represent this 
> better in the AST. I'd still say it's a missing feature in the AST :)
Thanks! I'm looking forward to simplifying this code when the AST is improved.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48159



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


[clang-tools-extra] r336119 - [clangd] Implement hover for "auto" and "decltype"

2018-07-02 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Mon Jul  2 09:28:34 2018
New Revision: 336119

URL: http://llvm.org/viewvc/llvm-project?rev=336119&view=rev
Log:
[clangd] Implement hover for "auto" and "decltype"

Summary:
This allows hovering on keywords that refer to deduced types.
This should cover most useful cases. Not covered:
- auto template parameters: Since this can be instantiated with many types,
it would not be practical to show the types.
- Structured binding: This could be done later to show multiple deduced types
in the hover.
- auto:: (part of concepts): Outside the scope of this patch.

Signed-off-by: Marc-Andre Laperle 

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.h
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=336119&r1=336118&r2=336119&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Mon Jul  2 09:28:34 2018
@@ -12,6 +12,7 @@
 #include "SourceCode.h"
 #include "URI.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/USRGeneration.h"
@@ -516,6 +517,18 @@ static Hover getHoverContents(const Decl
   return H;
 }
 
+/// Generate a \p Hover object given the type \p T.
+static Hover getHoverContents(QualType T, ASTContext &ASTCtx) {
+  Hover H;
+  std::string TypeText;
+  llvm::raw_string_ostream OS(TypeText);
+  PrintingPolicy Policy = PrintingPolicyForDecls(ASTCtx.getPrintingPolicy());
+  T.print(OS, Policy);
+  OS.flush();
+  H.contents.value += TypeText;
+  return H;
+}
+
 /// Generate a \p Hover object given the macro \p MacroInf.
 static Hover getHoverContents(StringRef MacroName) {
   Hover H;
@@ -526,6 +539,131 @@ static Hover getHoverContents(StringRef
   return H;
 }
 
+namespace {
+/// Computes the deduced type at a given location by visiting the relevant
+/// nodes. We use this to display the actual type when hovering over an "auto"
+/// keyword or "decltype()" expression.
+/// FIXME: This could have been a lot simpler by visiting AutoTypeLocs but it
+/// seems that the AutoTypeLocs that can be visited along with their AutoType 
do
+/// not have the deduced type set. Instead, we have to go to the appropriate
+/// DeclaratorDecl/FunctionDecl and work our back to the AutoType that does 
have
+/// a deduced type set. The AST should be improved to simplify this scenario.
+class DeducedTypeVisitor : public RecursiveASTVisitor {
+  SourceLocation SearchedLocation;
+  llvm::Optional DeducedType;
+
+public:
+  DeducedTypeVisitor(SourceLocation SearchedLocation)
+  : SearchedLocation(SearchedLocation) {}
+
+  llvm::Optional getDeducedType() { return DeducedType; }
+
+  // Handle auto initializers:
+  //- auto i = 1;
+  //- decltype(auto) i = 1;
+  //- auto& i = 1;
+  bool VisitDeclaratorDecl(DeclaratorDecl *D) {
+if (!D->getTypeSourceInfo() ||
+D->getTypeSourceInfo()->getTypeLoc().getLocStart() != SearchedLocation)
+  return true;
+
+auto DeclT = D->getType();
+// "auto &" is represented as a ReferenceType containing an AutoType
+if (const ReferenceType *RT = dyn_cast(DeclT.getTypePtr()))
+  DeclT = RT->getPointeeType();
+
+const AutoType *AT = dyn_cast(DeclT.getTypePtr());
+if (AT && !AT->getDeducedType().isNull()) {
+  // For auto, use the underlying type because the const& would be
+  // represented twice: written in the code and in the hover.
+  // Example: "const auto I = 1", we only want "int" when hovering on auto,
+  // not "const int".
+  //
+  // For decltype(auto), take the type as is because it cannot be written
+  // with qualifiers or references but its decuded type can be const-ref.
+  DeducedType = AT->isDecltypeAuto() ? DeclT : DeclT.getUnqualifiedType();
+}
+return true;
+  }
+
+  // Handle auto return types:
+  //- auto foo() {}
+  //- auto& foo() {}
+  //- auto foo() -> decltype(1+1) {}
+  //- operator auto() const { return 10; }
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (!D->getTypeSourceInfo())
+  return true;
+// Loc of auto in return type (c++14).
+auto CurLoc = D->getReturnTypeSourceRange().getBegin();
+// Loc of "auto" in operator auto()
+if (CurLoc.isInvalid() && dyn_cast(D))
+  CurLoc = D->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
+// Loc of "auto" in function with traling return type (c++11).
+if (CurLoc.isInvalid())
+  CurLoc = D->getSourceRange().getBegin();
+if (CurLoc != Searched

[PATCH] D48159: [clangd] Implement hover for "auto" and "decltype"

2018-07-02 Thread Marc-Andre Laperle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336119: [clangd] Implement hover for "auto" and 
"decltype" (authored by malaperle, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48159

Files:
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
  clang-tools-extra/trunk/unittests/clangd/TestTU.h
  clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -12,6 +12,7 @@
 #include "SourceCode.h"
 #include "URI.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/USRGeneration.h"
@@ -516,6 +517,18 @@
   return H;
 }
 
+/// Generate a \p Hover object given the type \p T.
+static Hover getHoverContents(QualType T, ASTContext &ASTCtx) {
+  Hover H;
+  std::string TypeText;
+  llvm::raw_string_ostream OS(TypeText);
+  PrintingPolicy Policy = PrintingPolicyForDecls(ASTCtx.getPrintingPolicy());
+  T.print(OS, Policy);
+  OS.flush();
+  H.contents.value += TypeText;
+  return H;
+}
+
 /// Generate a \p Hover object given the macro \p MacroInf.
 static Hover getHoverContents(StringRef MacroName) {
   Hover H;
@@ -526,6 +539,131 @@
   return H;
 }
 
+namespace {
+/// Computes the deduced type at a given location by visiting the relevant
+/// nodes. We use this to display the actual type when hovering over an "auto"
+/// keyword or "decltype()" expression.
+/// FIXME: This could have been a lot simpler by visiting AutoTypeLocs but it
+/// seems that the AutoTypeLocs that can be visited along with their AutoType do
+/// not have the deduced type set. Instead, we have to go to the appropriate
+/// DeclaratorDecl/FunctionDecl and work our back to the AutoType that does have
+/// a deduced type set. The AST should be improved to simplify this scenario.
+class DeducedTypeVisitor : public RecursiveASTVisitor {
+  SourceLocation SearchedLocation;
+  llvm::Optional DeducedType;
+
+public:
+  DeducedTypeVisitor(SourceLocation SearchedLocation)
+  : SearchedLocation(SearchedLocation) {}
+
+  llvm::Optional getDeducedType() { return DeducedType; }
+
+  // Handle auto initializers:
+  //- auto i = 1;
+  //- decltype(auto) i = 1;
+  //- auto& i = 1;
+  bool VisitDeclaratorDecl(DeclaratorDecl *D) {
+if (!D->getTypeSourceInfo() ||
+D->getTypeSourceInfo()->getTypeLoc().getLocStart() != SearchedLocation)
+  return true;
+
+auto DeclT = D->getType();
+// "auto &" is represented as a ReferenceType containing an AutoType
+if (const ReferenceType *RT = dyn_cast(DeclT.getTypePtr()))
+  DeclT = RT->getPointeeType();
+
+const AutoType *AT = dyn_cast(DeclT.getTypePtr());
+if (AT && !AT->getDeducedType().isNull()) {
+  // For auto, use the underlying type because the const& would be
+  // represented twice: written in the code and in the hover.
+  // Example: "const auto I = 1", we only want "int" when hovering on auto,
+  // not "const int".
+  //
+  // For decltype(auto), take the type as is because it cannot be written
+  // with qualifiers or references but its decuded type can be const-ref.
+  DeducedType = AT->isDecltypeAuto() ? DeclT : DeclT.getUnqualifiedType();
+}
+return true;
+  }
+
+  // Handle auto return types:
+  //- auto foo() {}
+  //- auto& foo() {}
+  //- auto foo() -> decltype(1+1) {}
+  //- operator auto() const { return 10; }
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (!D->getTypeSourceInfo())
+  return true;
+// Loc of auto in return type (c++14).
+auto CurLoc = D->getReturnTypeSourceRange().getBegin();
+// Loc of "auto" in operator auto()
+if (CurLoc.isInvalid() && dyn_cast(D))
+  CurLoc = D->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
+// Loc of "auto" in function with traling return type (c++11).
+if (CurLoc.isInvalid())
+  CurLoc = D->getSourceRange().getBegin();
+if (CurLoc != SearchedLocation)
+  return true;
+
+auto T = D->getReturnType();
+// "auto &" is represented as a ReferenceType containing an AutoType.
+if (const ReferenceType *RT = dyn_cast(T.getTypePtr()))
+  T = RT->getPointeeType();
+
+const AutoType *AT = dyn_cast(T.getTypePtr());
+if (AT && !AT->getDeducedType().isNull()) {
+  DeducedType = T.getUnqualifiedType();
+} else { // auto in a trailing return type just points to a DecltypeType.
+  const DecltypeType *DT = dyn_cast(T.getTypePtr());
+  if (!DT->getUnderlyingType().isNull())
+DeducedType = DT->getUnderlyingType();
+}
+return true;
+  }
+
+  // Handle non-auto decltype, e.g.:
+  // - auto foo() -> decltype(expr) {

[PATCH] D47846: [clangd] Implementation of textDocument/documentSymbol

2018-07-02 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 153742.
malaperle added a comment.

Rebased.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47846

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/symbols.test
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -43,6 +43,9 @@
 llvm::Expected>
 runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer &Server, PathRef File);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -117,5 +117,12 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer &Server, PathRef File) {
+  llvm::Optional>> Result;
+  Server.documentSymbols(File, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -22,6 +22,7 @@
 using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::ElementsAre;
+using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
 using ::testing::UnorderedElementsAre;
 
@@ -37,6 +38,7 @@
   return (arg.containerName + "::" + arg.name) == Name;
 }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+MATCHER_P(SymRange, Range, "") { return arg.location.range == Range; }
 
 ClangdServer::Options optsForTests() {
   auto ServerOpts = ClangdServer::optsForTest();
@@ -287,5 +289,274 @@
   EXPECT_THAT(getSymbols("foo"), ElementsAre(QName("foo")));
 }
 
+namespace {
+class DocumentSymbolsTest : public ::testing::Test {
+public:
+  DocumentSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+
+  std::vector getSymbols(PathRef File) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runDocumentSymbols(Server, File);
+EXPECT_TRUE(bool(SymbolInfos)) << "documentSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FilePath, StringRef Contents) {
+FSProvider.Files[FilePath] = Contents;
+Server.addDocument(FilePath, Contents);
+  }
+};
+} // namespace
+
+TEST_F(DocumentSymbolsTest, BasicSymbols) {
+  std::string FilePath = testPath("foo.cpp");
+  Annotations Main(R"(
+  class Foo;
+  class Foo {
+Foo() {}
+Foo(int a) {}
+void $decl[[f]]();
+friend void f1();
+friend class Friend;
+Foo& operator=(const Foo&);
+~Foo();
+class Nested {
+void f();
+};
+  };
+  class Friend {
+  };
+
+  void f1();
+  inline void f2() {}
+  static const int KInt = 2;
+  const char* kStr = "123";
+
+  void f1() {}
+
+  namespace foo {
+  // Type alias
+  typedef int int32;
+  using int32_t = int32;
+
+  // Variable
+  int v1;
+
+  // Namespace
+  namespace bar {
+  int v2;
+  }
+  // Namespace alias
+  namespace baz = bar;
+
+  // FIXME: using declaration is not supported as the IndexAction will ignore
+  // implicit declarations (the implicit using shadow declaration) by default,
+  // and there is no way to customize this behavior at the moment.
+  using bar::v2;
+  } // namespace foo
+)");
+
+  addFile(FilePath, Main.code());
+  EXPECT_THAT(getSymbols(FilePath),
+  ElementsAreArray(
+  {AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::f"), WithKind(SymbolKind::Method)),
+   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
+   AllOf(QName("Foo::operator="), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::~Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::Nested"), WithKind(SymbolKi

[PATCH] D48427: [Analyzer] Fix for D47417 to make the tests pass

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

That'd be a hell for you because when the container is updated you won't be 
able to easily find iterators all that iterate over it. Normally what you want 
to do is keep mapping iterators to container regions, and when the region dies, 
"freeze" the data (make sure it can no longer be mutated, through an assertion 
or, ideally, via the type system) and //re-map// the iterator to data directly.



I guess you need to track dead containers somehow anyway because you want to 
find bugs that consist in using iterators from different containers:

  void foo(vector x, vector y) {
vector::iterator i = x.begin(), e = y.end();   // Both containers are 
garbage-collected after this statement.
vector::iterator k = find(i, j, 123);  // Bug: 'i' and 'j' aren't 
from the same container.
  }

For that purpose i'm fine with tracking dead regions (as long as they aren't 
marked live, just stored). Or, for enforcing correctness, you could "anonymize" 
them (i.e., in the container data add an immutable int field that says "this is 
container #5" and use these ids for your check, then recover the original 
container region from the identifier in the bug visitor); but i don't think 
it's necessary.


https://reviews.llvm.org/D48427



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


[PATCH] D48716: [clang-format] Fix counting parameters/arguments for ObjC

2018-07-02 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D48716#1149293, @jolesiak wrote:

> General comment to changes https://reviews.llvm.org/D48716, 
> https://reviews.llvm.org/D48718, https://reviews.llvm.org/D48719, 
> https://reviews.llvm.org/D48720 (which are the split of 
> https://reviews.llvm.org/D48352):




> These changes are separate, in the sense that they fix different issues. 
> However, they should be chained as every change (apart from the first one) is 
> based on previous ones: https://reviews.llvm.org/D48716 -> 
> https://reviews.llvm.org/D48718 -> https://reviews.llvm.org/D48719 -> 
> https://reviews.llvm.org/D48720. I don't know how to chain them in 
> Phabricator (I should probably leave some comments about what every change is 
> based on though).

Phabricator has an `Edit Related Revisions` feature where you can tag other 
revisions as being dependencies of or depending upon the current revision:

F6560886: Screen Shot 2018-07-02 at 10.57.37 AM.png 


I went ahead and used it to link the revisions in the order you listed above. 
(I also like to edit the 1-line description and add `[1/x]` at the beginning — 
but that's up to you.)

> https://reviews.llvm.org/D48716 fixes the mechanism of counting parameters. 
> This is an internal change though and doesn't influence formatting on its own 
> (at the current state). Its lack would be visible after applying 
> https://reviews.llvm.org/D48719. Therefore, I'm not aware of any formatting 
> test that fails before applying this change and succeeds after. As far as I 
> know internal functions/methods are not tested at all. Thus, the tests are 
> part of https://reviews.llvm.org/D48719.

Great. Just mentioning that in the diff description should be fine.


Repository:
  rC Clang

https://reviews.llvm.org/D48716



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


[PATCH] D48718: [clang-format] Prohibit breaking after a bracket opening ObjC method expression

2018-07-02 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

> Sorry for the confusion. If you prefer me to add this test and modify in 
> later commit I'll do it.

I see. Just mentioning what you did in the diff description is probably OK.


Repository:
  rC Clang

https://reviews.llvm.org/D48718



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


[PATCH] D48072: Sema: Fix PR12350 destructor name lookup, addressing (some of) DR244

2018-07-02 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

Ping


Repository:
  rC Clang

https://reviews.llvm.org/D48072



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


r336124 - [analyzer] [tests] Pass clang executable path to prefix-less executor scripts.

2018-07-02 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Jul  2 10:10:40 2018
New Revision: 336124

URL: http://llvm.org/viewvc/llvm-project?rev=336124&view=rev
Log:
[analyzer] [tests] Pass clang executable path to prefix-less executor scripts.

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=336124&r1=336123&r2=336124&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Mon Jul  2 10:10:40 2018
@@ -303,6 +303,7 @@ def runScanBuild(Dir, SBOutputDir, PBuil
 if Command == NoPrefixCmd:
 SBPrefix = ""
 ExtraEnv['OUTPUT'] = SBOutputDir
+ExtraEnv['CC'] = Clang
 continue
 
 # If using 'make', auto imply a -jX argument


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


Re: [PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Tyler Nowicki via cfe-commits
Hi Michael, Hal,

Sorry it has been a while since I looked at this. My memory is a little
fuzzy. The intent of 'assume_safety' is to tell LAA to skip dependency
checking on loads and stores so the vectorizer doesn't stop as soon as it
sees both in a loop. At the time 'assume_safety' was implemented the
vectorizer was limited to inner-loops. I am not up-to-date but it seems to
have the ability to perform some vectorization of non-inner loop
instructions?

If we can vectorize non-inner loop instructions then what behavior would
make the most sense: 'assume_safety' applies to the same loop scope(s) as
the other loop pragmas, or it applies to all nested loops?

My opinion is that for consistency 'assume_safety' and similar options
apply to the same scope(s) as 'vectorize(enable)'. But I am open to
alternatives if others see it differently.

Tyler Nowicki

On Mon, Jul 2, 2018 at 10:44 AM Michael Kruse via Phabricator <
revi...@reviews.llvm.org> wrote:

> Meinersbur added a comment.
>
> In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:
>
> > I don't think that this is the intended behavior of the `#pragma clang
> loop`. it is better to ask the author of this pragma is this correct or not.
>
>
> I understand it as the intended behavior of the `assume_safety` option
> (also used for `#pragma omp simd`).
>
> @tyler.nowicki What is the intended behaviour?
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D48808
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In https://reviews.llvm.org/D48808#1149549, @hfinkel wrote:

> In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:
>
> >
>
>
> Michael, can you please add a test with two inner loops, one where more than 
> one is annotated, and one where only the outer loop is annotated? It's not 
> clear to me that I->setMetadata will do the right thing here in the former 
> case.


The test case `pragma-loop-safety-nested.cpp` check the case where the outer 
loop is annotated.

Iterating over `Active` will iterate from outer to inner loops, meaning 
`I->setMetadata` will overwrite the annotation of the outermost loop (which 
IMHO is the most useful behaviour). Since it not possible to add multiple 
`!llvm.mem.parallel_loop_access` annotation, we cannot annotate multiple loops.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[PATCH] D48722: [ASTImporter] Update isUsed flag at Decl import.

2018-07-02 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Gabor,

I have a strong feeling of duplication with attribute and flags merging move in 
https://reviews.llvm.org/D47632. Maybe it is better to be resolved in that 
review by using the same code for attr/flag merging for both newly-created and 
mapped decls?


Repository:
  rC Clang

https://reviews.llvm.org/D48722



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


[PATCH] D48722: [ASTImporter] Update isUsed flag at Decl import.

2018-07-02 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Whoops, sorry Balázs. Didn't look at the review author :(


Repository:
  rC Clang

https://reviews.llvm.org/D48722



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


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D48808#1149828, @Meinersbur wrote:

> In https://reviews.llvm.org/D48808#1149549, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:
> >
> > >
> >
> >
> > Michael, can you please add a test with two inner loops, one where more 
> > than one is annotated, and one where only the outer loop is annotated? It's 
> > not clear to me that I->setMetadata will do the right thing here in the 
> > former case.
>
>
> The test case `pragma-loop-safety-nested.cpp` check the case where the outer 
> loop is annotated.
>
> Iterating over `Active` will iterate from outer to inner loops, meaning 
> `I->setMetadata` will overwrite the annotation of the outermost loop (which 
> IMHO is the most useful behaviour). Since it not possible to add multiple 
> `!llvm.mem.parallel_loop_access` annotation, we cannot annotate multiple 
> loops.


We specifically defined the metadata to support nested loops. The LangRef says, 
"The llvm.mem.parallel_loop_access metadata refers to a loop identifier, or 
metadata containing a list of loop identifiers for nested loops." To handle 
nested loops, we need to make the instruction metadata point to a list of loop 
IDs.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


Re: [PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Hal Finkel via cfe-commits

On 07/02/2018 12:27 PM, Tyler Nowicki wrote:
> Hi Michael, Hal,
>
> Sorry it has been a while since I looked at this. My memory is a
> little fuzzy. The intent of 'assume_safety' is to tell LAA to
> skip dependency checking on loads and stores so the vectorizer doesn't
> stop as soon as it sees both in a loop. At the time 'assume_safety'
> was implemented the vectorizer was limited to inner-loops. I am not
> up-to-date but it seems to have the ability to perform some
> vectorization of non-inner loop instructions? 

The infrastructure to support outer loops is under active development.

>
> If we can vectorize non-inner loop instructions then what behavior
> would make the most sense: 'assume_safety' applies to the same loop
> scope(s) as the other loop pragmas, or it applies to all nested loops?
>
> My opinion is that for consistency 'assume_safety' and similar options
> apply to the same scope(s) as 'vectorize(enable)'. But I am open to
> alternatives if others see it differently.

I agree. Should apply to the entire single loop under the pragma. This
proposed change is consistent with that.

 -Hal

>
> Tyler Nowicki
>
> On Mon, Jul 2, 2018 at 10:44 AM Michael Kruse via Phabricator
> mailto:revi...@reviews.llvm.org>> wrote:
>
> Meinersbur added a comment.
>
> In https://reviews.llvm.org/D48808#1149534, @ABataev wrote:
>
> > I don't think that this is the intended behavior of the `#pragma
> clang loop`. it is better to ask the author of this pragma is this
> correct or not.
>
>
> I understand it as the intended behavior of the `assume_safety`
> option (also used for `#pragma omp simd`).
>
> @tyler.nowicki What is the intended behaviour?
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D48808
>
>
>

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

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


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In https://reviews.llvm.org/D48808#1149845, @hfinkel wrote:

> We specifically defined the metadata to support nested loops. The LangRef 
> says, "The llvm.mem.parallel_loop_access metadata refers to a loop 
> identifier, or metadata containing a list of loop identifiers for nested 
> loops." To handle nested loops, we need to make the instruction metadata 
> point to a list of loop IDs.


Thanks for pointing me to it. I've not seen parallel_loop_access pointing to a 
list, so I didn't know it was possible.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D48808#1149862, @Meinersbur wrote:

> In https://reviews.llvm.org/D48808#1149845, @hfinkel wrote:
>
> > We specifically defined the metadata to support nested loops. The LangRef 
> > says, "The llvm.mem.parallel_loop_access metadata refers to a loop 
> > identifier, or metadata containing a list of loop identifiers for nested 
> > loops." To handle nested loops, we need to make the instruction metadata 
> > point to a list of loop IDs.
>
>
> Thanks for pointing me to it. I've not seen parallel_loop_access pointing to 
> a list, so I didn't know it was possible.


Yea, well, we defined it to be possible. As to whether the backend will 
actually correctly read the metadata in that format, I don't know.


Repository:
  rC Clang

https://reviews.llvm.org/D48808



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


[libcxx] r336132 - Implement LWG 2946, 3075 and 3076. Reviewed as https://reviews.llvm.org/D48616

2018-07-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jul  2 11:41:15 2018
New Revision: 336132

URL: http://llvm.org/viewvc/llvm-project?rev=336132&view=rev
Log:
Implement LWG 2946, 3075 and 3076. Reviewed as https://reviews.llvm.org/D48616

Added:

libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
Modified:
libcxx/trunk/include/memory
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
libcxx/trunk/www/cxx2a_status.html

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=336132&r1=336131&r2=336132&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Mon Jul  2 11:41:15 2018
@@ -5638,15 +5638,15 @@ struct __temp_value {
 };
 #endif
 
-#if _LIBCPP_STD_VER > 14
-template
+template
 struct __is_allocator : false_type {};
 
 template
 struct __is_allocator<_Alloc,
- void_t().allocate(size_t{}))>>
+   typename __void_t::type,
+   typename 
__void_t().allocate(size_t(0)))>::type
+ >
: true_type {};
-#endif
 
 _LIBCPP_END_NAMESPACE_STD
 

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=336132&r1=336131&r2=336132&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Jul  2 11:41:15 2018
@@ -104,7 +104,8 @@ public:
  const Allocator& a = Allocator());
 template
 basic_string(const T& t, size_type pos, size_type n, const Allocator& 
a = Allocator()); // C++17
-explicit basic_string(const basic_string_view sv, const 
Allocator& a = Allocator());
+template 
+explicit basic_string(const T& t, const Allocator& a = Allocator()); 
// C++17
 basic_string(const value_type* s, const allocator_type& a = 
allocator_type());
 basic_string(const value_type* s, size_type n, const allocator_type& a = 
allocator_type());
 basic_string(size_type n, value_type c, const allocator_type& a = 
allocator_type());
@@ -120,7 +121,8 @@ public:
 operator basic_string_view() const noexcept;
 
 basic_string& operator=(const basic_string& str);
-basic_string& operator=(basic_string_view sv);
+template 
+basic_string& operator=(const T& t); // C++17
 basic_string& operator=(basic_string&& str)
 noexcept(
  allocator_type::propagate_on_container_move_assignment::value ||
@@ -164,13 +166,15 @@ public:
 reference   at(size_type n);
 
 basic_string& operator+=(const basic_string& str);
-basic_string& operato

[PATCH] D47299: [CodeGenCXX] Emit strip.invariant.group with -fstrict-vtable-pointers

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



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1647
+  }
+}
+

Prazek wrote:
> rsmith wrote:
> > Prazek wrote:
> > > rjmccall wrote:
> > > > Prazek wrote:
> > > > > rjmccall wrote:
> > > > > > Incidentally, how do you protect against code like this?
> > > > > > 
> > > > > >   A *ptr;
> > > > > >   reinterpret_cast(ptr) = new B();
> > > > > >   ptr->foo();
> > > > > > 
> > > > > > Presumably there needs to be a launder/strip here, but I guess it 
> > > > > > would have to be introduced by the middle-end when forwarding the 
> > > > > > store?  The way I've written this is an aliasing violation, but (1) 
> > > > > > I assume your pass isn't disabled whenever strict-aliasing is 
> > > > > > disabled and (2) you can do this with a memcpy and still pretty 
> > > > > > reliably expect that LLVM will be able to eventually forward the 
> > > > > > store.
> > > > > Can you add more info on what is A and B so I can make sure I 
> > > > > understand it correctly?
> > > > > Is the prefix of the layout the same for both, but they are not in 
> > > > > the hierarchy?
> > > > > 
> > > > > I haven't thought about the strict aliasing. I think the only sane 
> > > > > way would be to require strict aliasing for the strict vtable 
> > > > > pointers.
> > > > It's whatever case you're worried about such that you have to launder 
> > > > member accesses and bitcasts.
> > > > 
> > > > And like I mentioned, relying on strict aliasing isn't enough because 
> > > > you can do it legally with memcpy.  Maybe it's okay to consider it UB?  
> > > > I'm not sure about that.
> > > AFAIK reinterpreting one class as another is UB if they are not in 
> > > hierarchy (especially calling virtual function on reinterpreted class), 
> > > not sure if strict aliasing should allow it anyway (if it would be a hand 
> > > written custom vptr then it should be ok with strict aliasing turned off, 
> > > but with vptr I don't think it is legal).
> > > @rsmith Can you comment on that?
> > OK, here's how I think about what we're doing here:
> > 
> > We view the IR-level pointer value for a pointer to a dynamic class type as 
> > being a fat pointer, containing the actual pointer value and also a tag 
> > indicating the dynamic type of the object (only notionally, though -- the 
> > actual bit representation of the pointer doesn't include the extra 
> > information, but we don't ever emit IR that inspects the bit representation 
> > of the fat pointer to avoid exposing that fact). In that model, if you try 
> > to type pun between a pointer to a dynamic class type and a pointer to a 
> > non-dynamic-class type, that can't be expected to work because the 
> > (notional) value is different, much as type punning between a derived and 
> > base class pointer wouldn't work for a pointer to something other than a 
> > base class at offset zero.
> > 
> > I think @rjmccall's example is OK, because both `A` and `B` would need to 
> > be dynamic class types in a hierarchy to work, and that means we'd be using 
> > the same notional pointer representation. A slight variation of that 
> > example:
> > 
> > ```
> > struct A {};
> > struct B : A { virtual void f(); };
> > struct C : B { void f(); } c;
> > A *p = &c;
> > B *q;
> > memcpy(&q, &p, sizeof(B*)); // or q = std::bit_cast(p);
> > q->f();
> > ```
> > 
> > ... would be UB, because the representation of an `A*` and a `B*` are 
> > different (a `B*` contains a tag and an `A*` does not).
> Does this answer satisfy you John? Can I push it to trunk?
Yeah, Richard's answer makes sense to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D47299



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

2018-07-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: test/Sema/attr-min-vector-width.c:8
+
+void f3(void) __attribute__((__min_vector_width__(128), 
__min_vector_width__(256))); /* expected-warning {{attribute 
'__min_vector_width__' is already applied with different parameters}} */

aaron.ballman wrote:
> Also missing tests for applying the attribute to the wrong subject and with 
> the incorrect number of arguments.
How many possible subjects are there? And how many wrong subjects do you want 
me to test?


https://reviews.llvm.org/D48617



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

2018-07-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 153763.
craig.topper added a comment.

-Rebase the intrinsic headers and builtins file
-Add documentation for the attribute. Open to feedback on improvements here
-Add tests for wrong number of arguments to the attribute.


https://reviews.llvm.org/D48617

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Headers/__wmmintrin_aes.h
  lib/Headers/ammintrin.h
  lib/Headers/avx2intrin.h
  lib/Headers/avx512bitalgintrin.h
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512cdintrin.h
  lib/Headers/avx512dqintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512ifmaintrin.h
  lib/Headers/avx512ifmavlintrin.h
  lib/Headers/avx512vbmi2intrin.h
  lib/Headers/avx512vbmiintrin.h
  lib/Headers/avx512vbmivlintrin.h
  lib/Headers/avx512vlbitalgintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlcdintrin.h
  lib/Headers/avx512vldqintrin.h
  lib/Headers/avx512vlintrin.h
  lib/Headers/avx512vlvbmi2intrin.h
  lib/Headers/avx512vlvnniintrin.h
  lib/Headers/avx512vnniintrin.h
  lib/Headers/avx512vpopcntdqintrin.h
  lib/Headers/avx512vpopcntdqvlintrin.h
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  lib/Headers/f16cintrin.h
  lib/Headers/fma4intrin.h
  lib/Headers/fmaintrin.h
  lib/Headers/gfniintrin.h
  lib/Headers/mm3dnow.h
  lib/Headers/mmintrin.h
  lib/Headers/pmmintrin.h
  lib/Headers/shaintrin.h
  lib/Headers/smmintrin.h
  lib/Headers/tmmintrin.h
  lib/Headers/vaesintrin.h
  lib/Headers/xmmintrin.h
  lib/Headers/xopintrin.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/function-min-vector-width.c
  test/CodeGen/x86-builtins-vector-width.c
  test/Sema/attr-min-vector-width.c



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

2018-07-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: include/clang/Basic/Attr.td:1949
+  let Args = [UnsignedArgument<"VectorWidth">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];

aaron.ballman wrote:
> Should this apply to Objective-C methods? What about other function-like 
> interfaces such as function pointers?
I think maybe it should apply to objective-C. but I"m not sure because it 
doesn't look like the target attribute applies there?


https://reviews.llvm.org/D48617



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

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



Comment at: test/Sema/attr-min-vector-width.c:8
+
+void f3(void) __attribute__((__min_vector_width__(128), 
__min_vector_width__(256))); /* expected-warning {{attribute 
'__min_vector_width__' is already applied with different parameters}} */

craig.topper wrote:
> aaron.ballman wrote:
> > Also missing tests for applying the attribute to the wrong subject and with 
> > the incorrect number of arguments.
> How many possible subjects are there? And how many wrong subjects do you want 
> me to test?
Lots of possible subjects, but testing just one will suffice as a failure test 
case (you already covered the successful subject test cases). We've had issues 
in the past where lacking this test coverage caused problems that cost a lot of 
time to track down, so it's a checklist test item for me.


https://reviews.llvm.org/D48617



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


[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2018-07-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D48342#1148751, @mclow.lists wrote:

> I want to point out that this code (not -necessarily- this patch, but where 
> it lives) needs to be rewritten.
>
> There is no prohibition on users specializing `allocator_traits` for their 
> allocators, and yet libc++'s vector depends on the existence of 
> `allocator_traits::__construct_range_forward` (among other things).


Marshall, do you agree to have such rewrite to be done separately? It seems to 
me fairly involved and I don't want it to block other changes. And for this 
change I suggest observing how it develops. If it is fairly small and isolated, 
I think it would be useful to have it before the more substantial 
`allocator_traits` rewrite.


https://reviews.llvm.org/D48342



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


[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2018-07-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai planned changes to this revision.
vsapsai added inline comments.



Comment at: libcxx/include/memory:1479
+struct __has_construct_missing
+: false_type
+{

vsapsai wrote:
> vsapsai wrote:
> > erik.pilkington wrote:
> > > vsapsai wrote:
> > > > erik.pilkington wrote:
> > > > > Shouldn't this be true_type?
> > > > I see this is confusing and I'm still struggling how to express it. The 
> > > > issue is that in C++03 `__has_construct` should be something like 
> > > > unknown, so that neither `__has_construct` nor `! __has_construct` 
> > > > evaluate to true because we don't really know if allocator has 
> > > > construct. This case is covered by the added test, in C++03 the memcpy 
> > > > specialization was enabled when
> > > > 
> > > > ```
> > > > is_same >
> > > >   || !false_type
> > > > ```
> > > > 
> > > > So `is_same` check had no effect and we were using memcpy to convert 
> > > > between int and float.
> > > > 
> > > > I was considering using something like
> > > > 
> > > > ```lang=c++
> > > > typename enable_if
> > > > <
> > > > (is_same
> > > >  <
> > > > typename _VSTD::remove_const > > > allocator_type::value_type>::type,
> > > > typename _VSTD::remove_const<_SourceTp>::type
> > > >  >::value
> > > > #ifndef _LIBCPP_CXX03_LANG
> > > > || !__has_construct > > > _SourceTp>::value
> > > > #endif
> > > > ) &&
> > > >  is_trivially_move_constructible<_DestTp>::value,
> > > > void
> > > > >::type
> > > > ```
> > > > 
> > > > But that doesn't look readable to me, so I've introduced ad-hoc ternary 
> > > > logic with `__has_construct_missing`.
> > > Oh I see, yikes! That's a pretty bad bug. I agree that this fix is best 
> > > then, but can you add a comment explaining this to 
> > > `__has_construct_missing` for future casual readers? Also, I think we 
> > > should move the __has_construct_missing bugfix into a different 
> > > (prerequisite) patch. Seems unrelated to the `const` related optimization 
> > > below.
> > The bug as I described isn't really present now because function signature
> > 
> > __construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, 
> > _Tp*& __begin2)
> > 
> > works as implicit `is_same` for `__begin1` and `__begin2` types. I think it 
> > is worth fixing separately and there is a bug with C++03 and custom 
> > allocators.
> Instead of `__has_construct_missing` I've implemented real `__has_construct` 
> in D48753. But it is stricter in C++03 than in C++11 and later. So it made me 
> think that absence of `construct` with exact signature isn't a good reason to 
> use memcpy.
I was wrong. Now I think the logic for using memcpy should be

if types are the same modulo constness
and
(
using default allocator
or
using custom allocator without `construct`
)
and
is_trivially_move_constructible

The purpose of the allocator check is to cover cases when `static construct` 
would end up calling not user's code but libc++ code that we know can be 
replaced with memcpy.


https://reviews.llvm.org/D48342



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


r336137 - [CodeGenCXX] Emit strip.invariant.group with -fstrict-vtable-pointers

2018-07-02 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Mon Jul  2 12:21:36 2018
New Revision: 336137

URL: http://llvm.org/viewvc/llvm-project?rev=336137&view=rev
Log:
[CodeGenCXX] Emit strip.invariant.group with -fstrict-vtable-pointers

Summary:
Emmiting new intrinsic that strips invariant.groups to make
devirtulization sound, as described in RFC: Devirtualization v2.

Reviewers: rjmccall, rsmith, amharc, kuhar

Subscribers: llvm-commits, cfe-commits

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

Co-authored-by: Krzysztof Pszeniczny 

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=336137&r1=336136&r2=336137&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Jul  2 12:21:36 2018
@@ -790,6 +790,18 @@ public:
 return data().Polymorphic || data().NumVBases != 0;
   }
 
+  /// @returns true if class is dynamic or might be dynamic because the
+  /// definition is incomplete of dependent.
+  bool mayBeDynamicClass() const {
+return !hasDefinition() || isDynamicClass() || hasAnyDependentBases();
+  }
+
+  /// @returns true if class is non dynamic or might be non dynamic because the
+  /// definition is incomplete of dependent.
+  bool mayBeNonDynamicClass() const {
+return !hasDefinition() || !isDynamicClass() || hasAnyDependentBases();
+  }
+
   void setIsParsingBaseSpecifiers() { data().IsParsingBaseSpecifiers = true; }
 
   bool isParsingBaseSpecifiers() const {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=336137&r1=336136&r2=336137&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jul  2 12:21:36 2018
@@ -810,6 +810,13 @@ public:
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext &Context) const;
 
+
+  /// Returns true if it is a class and it might be dynamic.
+  bool mayBeDynamicClass() const;
+
+  /// Returns true if it is not a class or if the class might not be dynamic.
+  bool mayBeNotDynamicClass() const;
+
   // Don't promise in the API that anything besides 'const' can be
   // easily added.
 

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=336137&r1=336136&r2=336137&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Jul  2 12:21:36 2018
@@ -88,6 +88,16 @@ const IdentifierInfo* QualType::getBaseT
   return nullptr;
 }
 
+bool QualType::mayBeDynamicClass() const {
+  const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
+  return ClassDecl && ClassDecl->mayBeDynamicClass();
+}
+
+bool QualType::mayBeNotDynamicClass() const {
+  const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
+  return !ClassDecl || ClassDecl->mayBeNonDynamicClass();
+}
+
 bool QualType::isConstant(QualType T, const ASTContext &Ctx) {
   if (T.isConstQualified())
 return true;

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=336137&r1=336136&r2=336137&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul  2 12:21:36 2018
@@ -3870,6 +3870,18 @@ LValue CodeGenFunction::EmitLValueForFie
   }
 
   Address addr = base.getAddress();
+  if (auto *ClassDef = dyn_cast(rec)) {
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+ClassDef->isDynamicClass()) {
+  // Getting to any field of dynamic object requires stripping dynamic
+  // information provided by invariant.group.  This is because accessing
+  // fields may leak the real address of dynamic object, which could result
+  // in miscompilation when leaked pointer would be compared.
+  auto *stripped = Builder.CreateStripInvariantGroup(addr.getPointer());
+  addr = Address(stripped, addr.getAlignment());
+}
+  }
+
   unsigned RecordCVR = base.getVRQualifiers();
   if (rec->isUnion()) {
 // For unions, there is no pointer adjustment.

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=336137&r1=336136&r2=336137&view=diff
==
--- cfe/trunk/lib

[PATCH] D47299: [CodeGenCXX] Emit strip.invariant.group with -fstrict-vtable-pointers

2018-07-02 Thread Piotr Padlewski 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 rC336137: [CodeGenCXX] Emit strip.invariant.group with 
-fstrict-vtable-pointers (authored by Prazek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47299?vs=151575&id=153767#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47299

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3870,6 +3870,18 @@
   }
 
   Address addr = base.getAddress();
+  if (auto *ClassDef = dyn_cast(rec)) {
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+ClassDef->isDynamicClass()) {
+  // Getting to any field of dynamic object requires stripping dynamic
+  // information provided by invariant.group.  This is because accessing
+  // fields may leak the real address of dynamic object, which could result
+  // in miscompilation when leaked pointer would be compared.
+  auto *stripped = Builder.CreateStripInvariantGroup(addr.getPointer());
+  addr = Address(stripped, addr.getAlignment());
+}
+  }
+
   unsigned RecordCVR = base.getVRQualifiers();
   if (rec->isUnion()) {
 // For unions, there is no pointer adjustment.
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1621,6 +1621,24 @@
   CE->getLocStart());
 }
 
+if (CGF.CGM.getCodeGenOpts().StrictVTablePointers) {
+  const QualType SrcType = E->getType();
+
+  if (SrcType.mayBeNotDynamicClass() && DestTy.mayBeDynamicClass()) {
+// Casting to pointer that could carry dynamic information (provided by
+// invariant.group) requires launder.
+Src = Builder.CreateLaunderInvariantGroup(Src);
+  } else if (SrcType.mayBeDynamicClass() && DestTy.mayBeNotDynamicClass()) {
+// Casting to pointer that does not carry dynamic information (provided
+// by invariant.group) requires stripping it.  Note that we don't do it
+// if the source could not be dynamic type and destination could be
+// dynamic because dynamic information is already laundered.  It is
+// because launder(strip(src)) == launder(src), so there is no need to
+// add extra strip before launder.
+Src = Builder.CreateStripInvariantGroup(Src);
+  }
+}
+
 return Builder.CreateBitCast(Src, DstTy);
   }
   case CK_AddressSpaceConversion: {
@@ -1757,12 +1775,31 @@
 llvm::Value* IntResult =
   Builder.CreateIntCast(Src, MiddleTy, InputSigned, "conv");
 
-return Builder.CreateIntToPtr(IntResult, DestLLVMTy);
+auto *IntToPtr = Builder.CreateIntToPtr(IntResult, DestLLVMTy);
+
+if (CGF.CGM.getCodeGenOpts().StrictVTablePointers) {
+  // Going from integer to pointer that could be dynamic requires reloading
+  // dynamic information from invariant.group.
+  if (DestTy.mayBeDynamicClass())
+IntToPtr = Builder.CreateLaunderInvariantGroup(IntToPtr);
+}
+return IntToPtr;
   }
-  case CK_PointerToIntegral:
+  case CK_PointerToIntegral: {
 assert(!DestTy->isBooleanType() && "bool should use PointerToBool");
-return Builder.CreatePtrToInt(Visit(E), ConvertType(DestTy));
+auto *PtrExpr = Visit(E);
+
+if (CGF.CGM.getCodeGenOpts().StrictVTablePointers) {
+  const QualType SrcType = E->getType();
 
+  // Casting to integer requires stripping dynamic information as it does
+  // not carries it.
+  if (SrcType.mayBeDynamicClass())
+PtrExpr = Builder.CreateStripInvariantGroup(PtrExpr);
+}
+
+return Builder.CreatePtrToInt(PtrExpr, ConvertType(DestTy));
+  }
   case CK_ToVoid: {
 CGF.EmitIgnoredExpr(E);
 return nullptr;
@@ -3241,6 +3278,23 @@
   Result = Builder.CreateICmp(SICmpOpc, LHS, RHS, "cmp");
 } else {
   // Unsigned integers and pointers.
+
+  if (CGF.CGM.getCodeGenOpts().StrictVTablePointers &&
+  !isa(LHS) &&
+  !isa(RHS)) {
+
+// Dynamic information is required to be stripped for comparisons,
+// because it could leak the dynamic information.  Based on comparisons
+// of pointers to dynamic objects, the optimizer can replace one pointer
+// with another, which might be incorrect in presence of invariant
+// groups. Comparison with null is safe because null does not carry any
+// dynamic information.
+if (LHSTy.mayBeDynamicClass())
+  LHS = Builder.CreateStripInvariantGroup(LHS);
+if (RHSTy.mayBeDynamicClass())
+  RHS = Builder.CreateStripInv

[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 153769.
Meinersbur added a comment.

- Allow multiple parallel annotations


Repository:
  rC Clang

https://reviews.llvm.org/D48808

Files:
  lib/CodeGen/CGLoopInfo.cpp
  test/CodeGenCXX/pragma-loop-safety-nested.cpp
  test/CodeGenCXX/pragma-loop-safety-outer.cpp


Index: test/CodeGenCXX/pragma-loop-safety-outer.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-outer.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_outer_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+for (int j = 0; j < 2; j += 1)
+  List[i + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: test/CodeGenCXX/pragma-loop-safety-nested.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-nested.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; ++i) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+for (int j = 0; j < Length; ++j)
+  List[i * Length + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[PARALLEL_LIST:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID:[0-9]+]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[PARALLEL_LIST]] = !{![[OUTER_LOOPID]], ![[INNER_LOOPID]]}
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: lib/CodeGen/CGLoopInfo.cpp
===
--- lib/CodeGen/CGLoopInfo.cpp
+++ lib/CodeGen/CGLoopInfo.cpp
@@ -300,6 +300,15 @@
 return;
   }
 
-  if (L.getAttributes().IsParallel && I->mayReadOrWriteMemory())
-I->setMetadata("llvm.mem.parallel_loop_access", L.getLoopID());
+  SmallVector ParallelLoopIDs;
+  for (const LoopInfo &AL : Active)
+if (AL.getAttributes().IsParallel && I->mayReadOrWriteMemory())
+  ParallelLoopIDs.push_back(AL.getLoopID());
+
+  MDNode *ParallelMD = nullptr;
+  if (ParallelLoopIDs.size() == 1)
+ParallelMD = cast(ParallelLoopIDs[0]);
+  else if (ParallelLoopIDs.size() >= 2)
+ParallelMD = MDNode::get(I->getContext(), ParallelLoopIDs);
+  I->setMetadata("llvm.mem.parallel_loop_access", ParallelMD);
 }


Index: test/CodeGenCXX/pragma-loop-safety-outer.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-outer.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_outer_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+for (int j = 0; j < 2; j += 1)
+  List[i + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access ![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: test/CodeGenCXX/pragma-loop-safety-nested.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-nested.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; ++i) {
+#pr

[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

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



Comment at: include/clang/Basic/Attr.td:1949
+  let Args = [UnsignedArgument<"VectorWidth">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];

craig.topper wrote:
> aaron.ballman wrote:
> > Should this apply to Objective-C methods? What about other function-like 
> > interfaces such as function pointers?
> I think maybe it should apply to objective-C. but I"m not sure because it 
> doesn't look like the target attribute applies there?
I don't have strong opinions on the question, I just wasn't sure if this 
attribute would be something an ObjC method would want to make use of. If 
that's unlikely, it's reasonable to leave it off until a use case appears.



Comment at: include/clang/Basic/AttrDocs.td:1502
+  let Content = [{
+clang support the ``__attribute__((min_vector_width(width)))`` attribute. This
+attribute may be attached to a function and informs that backend that this

clang support -> Clang supports



Comment at: include/clang/Basic/AttrDocs.td:1503
+clang support the ``__attribute__((min_vector_width(width)))`` attribute. This
+attribute may be attached to a function and informs that backend that this
+function desires vectors of at least this width to be generated. Target 
specific

that backend -> the backend



Comment at: include/clang/Basic/AttrDocs.td:1504
+attribute may be attached to a function and informs that backend that this
+function desires vectors of at least this width to be generated. Target 
specific
+maximum vector widths still apply. This is attribute it meant to be a hint to

Target specific -> Target-specific



Comment at: include/clang/Basic/AttrDocs.td:1505
+function desires vectors of at least this width to be generated. Target 
specific
+maximum vector widths still apply. This is attribute it meant to be a hint to
+control target heuristics that may generate narrower vectors than what the

"Apply" how?

I don't see any logic that diagnoses the situation where the user requests 
something larger than the maximum vector width or smaller than the minimum 
vector width supported by the target. I would expect the attribute to be 
diagnosed and dropped in that case; is there a reason not to do that?

This is attribute it -> This attribute is



Comment at: include/clang/Basic/AttrDocs.td:1511
+vectors to be limited to using 256-bit vectors to avoid frequency penalties.
+This attribute can be used to override this behavior on certain functions.
+}];

This suggests to me that the user can override the attribute on the builtins if 
you want a different behavior; is that correct?



Comment at: lib/Basic/Builtins.cpp:119-122
+
+  assert(::strchr(WidthPos, ':') &&
+ "Vector width specifier must be end with a ':'");
+  return ::strtol(WidthPos, nullptr, 10);

I think you want to use the ending position from `strtol()` to assert that it 
ended on the : and not some other random character. e.g., I think this will 
parse just fine: `V:1e28:` and run into issues elsewhere.



Comment at: lib/CodeGen/CodeGenFunction.cpp:449
+
+  // Add the required-vector-width attribute
+  if (LargestVectorWidth != 0)

Missing full stop at the end of the comment.



Comment at: lib/CodeGen/CodeGenFunction.cpp:1198
+  if (CurFuncDecl)
+if (auto *VecWidth = CurFuncDecl->getAttr())
+  LargestVectorWidth = VecWidth->getVectorWidth();

`const auto *`



Comment at: lib/CodeGen/CodeGenFunction.h:1466
 
+  /// Largest vector with used in ths function. Will be used to create a
+  /// function attribute.

with -> width


https://reviews.llvm.org/D48617



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


[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

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



Comment at: libcxx/include/memory:1479
+struct __has_construct_missing
+: false_type
+{

vsapsai wrote:
> vsapsai wrote:
> > vsapsai wrote:
> > > erik.pilkington wrote:
> > > > vsapsai wrote:
> > > > > erik.pilkington wrote:
> > > > > > Shouldn't this be true_type?
> > > > > I see this is confusing and I'm still struggling how to express it. 
> > > > > The issue is that in C++03 `__has_construct` should be something like 
> > > > > unknown, so that neither `__has_construct` nor `! __has_construct` 
> > > > > evaluate to true because we don't really know if allocator has 
> > > > > construct. This case is covered by the added test, in C++03 the 
> > > > > memcpy specialization was enabled when
> > > > > 
> > > > > ```
> > > > > is_same >
> > > > >   || !false_type
> > > > > ```
> > > > > 
> > > > > So `is_same` check had no effect and we were using memcpy to convert 
> > > > > between int and float.
> > > > > 
> > > > > I was considering using something like
> > > > > 
> > > > > ```lang=c++
> > > > > typename enable_if
> > > > > <
> > > > > (is_same
> > > > >  <
> > > > > typename _VSTD::remove_const > > > > allocator_type::value_type>::type,
> > > > > typename _VSTD::remove_const<_SourceTp>::type
> > > > >  >::value
> > > > > #ifndef _LIBCPP_CXX03_LANG
> > > > > || !__has_construct > > > > _SourceTp>::value
> > > > > #endif
> > > > > ) &&
> > > > >  is_trivially_move_constructible<_DestTp>::value,
> > > > > void
> > > > > >::type
> > > > > ```
> > > > > 
> > > > > But that doesn't look readable to me, so I've introduced ad-hoc 
> > > > > ternary logic with `__has_construct_missing`.
> > > > Oh I see, yikes! That's a pretty bad bug. I agree that this fix is best 
> > > > then, but can you add a comment explaining this to 
> > > > `__has_construct_missing` for future casual readers? Also, I think we 
> > > > should move the __has_construct_missing bugfix into a different 
> > > > (prerequisite) patch. Seems unrelated to the `const` related 
> > > > optimization below.
> > > The bug as I described isn't really present now because function signature
> > > 
> > > __construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* 
> > > __end1, _Tp*& __begin2)
> > > 
> > > works as implicit `is_same` for `__begin1` and `__begin2` types. I think 
> > > it is worth fixing separately and there is a bug with C++03 and custom 
> > > allocators.
> > Instead of `__has_construct_missing` I've implemented real 
> > `__has_construct` in D48753. But it is stricter in C++03 than in C++11 and 
> > later. So it made me think that absence of `construct` with exact signature 
> > isn't a good reason to use memcpy.
> I was wrong. Now I think the logic for using memcpy should be
> 
> if types are the same modulo constness
> and
> (
> using default allocator
> or
> using custom allocator without `construct`
> )
> and
> is_trivially_move_constructible
> 
> The purpose of the allocator check is to cover cases when `static construct` 
> would end up calling not user's code but libc++ code that we know can be 
> replaced with memcpy.
I'd like to request the spelling `__has_trivial_construct_and_destroy` as described here: https://www.youtube.com/watch?v=MWBfmmg8-Yo&t=21m45s
I have an implementation in my fork that might be useful for comparison, 
although even it doesn't add that last `T&&` parameter.
https://github.com/Quuxplusone/libcxx/commit/34eb0b5c8f03880b94d53b877cbca384783ad65a

What we're *really* interested in, in most cases, is 
`__has_trivial_construct && __has_trivial_destroy`. We don't 
care if there happens to exist an obscure overload such as `A::construct(T*, 
Widget, Gadget)` as long as it is not selected. This is particularly relevant 
to `scoped_allocator_adaptor`, whose `construct` is trivial for primitive types 
but non-trivial for allocator-aware types.

Also, when we write out the template type parameters we care about, we can do 
the decltype stuff really easily, without having to "fudge" the metaprogramming 
and possibly get it wrong. For example, if `A::construct` is an overload set, 
in which case the `&_Xp::construct` on this patch's line 1492 will be 
ill-formed even though a non-trivial `construct` does actually exist.


https://reviews.llvm.org/D48342



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


[PATCH] D48601: Added -fcrash-diagnostics-dir flag

2018-07-02 Thread Chijioke Kamanu via Phabricator via cfe-commits
j10kay updated this revision to Diff 153773.
j10kay marked 3 inline comments as done.
j10kay added a comment.

Implemented the code review changes


Repository:
  rL LLVM

https://reviews.llvm.org/D48601

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c


Index: clang/test/Driver/crash-diagnostics-dir.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: 
{{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1291,12 +1291,13 @@
   // Assume associated files are based off of the first temporary file.
   CrashReportInfo CrashInfo(TempFiles[0], VFS);
 
-  std::string Script = CrashInfo.Filename.rsplit('.').first.str() + ".sh";
+  llvm::SmallString<128> Script(CrashInfo.Filename);
+  llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
   llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
-<< "Error generating run script: " + Script + " " + EC.message();
+<< "Error generating run script: " << Script << " " << EC.message();
   } else {
 ScriptOS << "# Crash reproducer for " << getClangFullVersion() << "\n"
  << "# Driver args: ";
@@ -1308,7 +1309,7 @@
   ScriptOS << "\n# Additional information: " << AdditionalInformation
<< "\n";
 if (Report)
-  Report->TemporaryFiles.push_back(Script);
+  Report->TemporaryFiles.push_back(Script.str());
 Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
   }
 
@@ -4036,8 +4037,22 @@
   CCGenDiagnostics) {
 StringRef Name = llvm::sys::path::filename(BaseInput);
 std::pair Split = Name.split('.');
-std::string TmpName = GetTemporaryPath(
-Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
+SmallString<128> TmpName;
+const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
+Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
+if (CCGenDiagnostics && A) {
+  SmallString<128> CrashDirectory(A->getValue());
+  llvm::sys::path::append(CrashDirectory, Split.first);
+  const char *Middle = Suffix ? "-%%." : "-%%";
+  std::error_code EC =
+  llvm::sys::fs::createUniqueFile(CrashDirectory + Middle + Suffix, 
TmpName);
+  if (EC) {
+Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+return "";
+  }
+} else {
+  TmpName = GetTemporaryPath(Split.first, Suffix);
+}
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -798,6 +798,7 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused]>;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 def fcxx_exceptions: Flag<["-"], "fcxx-exceptions">, Group,
   HelpText<"Enable C++ exceptions">, Flags<[CC1Option]>;


Index: clang/test/Driver/crash-diagnostics-dir.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: {{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1291,12 +1291,13 @@
   // Assume associated files are based off of the first temporary file.
   CrashReportInfo CrashInfo(TempFiles[0], VFS);
 
-  std::string Script = CrashInfo.Filename.rsplit('.').first.str() + ".sh";
+  llvm::SmallString<128> Script(CrashInfo.Filename);
+  llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
   llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::

[PATCH] D48749: [Win32] Overload ==, != for locale_t and long long

2018-07-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX336141: [Win32] Overload ==, != for locale_t and long long 
(authored by pirama, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48749?vs=153411&id=153778#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D48749

Files:
  include/support/win32/locale_win32.h


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r336141 - [Win32] Overload ==, != for locale_t and long long

2018-07-02 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Mon Jul  2 13:11:15 2018
New Revision: 336141

URL: http://llvm.org/viewvc/llvm-project?rev=336141&view=rev
Log:
[Win32] Overload ==, != for locale_t and long long

Summary:
_is_chartype_l (needed for isxdigit_l) in MinGW compares locale_t and NULL.
NULL is 'long long' for 64-bit, and this results in ambiguous overloads when
compiled with Clang.  Define a concrete overload for the operators to fix the
ambiguity.

Reviewers: mstorsjo, EricWF, srhines, danalbert

Subscribers: christof, cfe-commits, ldionne

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

Modified:
libcxx/trunk/include/support/win32/locale_win32.h

Modified: libcxx/trunk/include/support/win32/locale_win32.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/locale_win32.h?rev=336141&r1=336140&r2=336141&view=diff
==
--- libcxx/trunk/include/support/win32/locale_win32.h (original)
+++ libcxx/trunk/include/support/win32/locale_win32.h Mon Jul  2 13:11:15 2018
@@ -46,6 +46,10 @@ public:
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@ public:
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }


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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

2018-07-02 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

FWIW, I looked at an early version of this patch and am generally happy with 
the target-specific / IR-specific behavior aspects of it. Totally leaving the 
detailed review of the attribute stuff to you Aaron, as you're already doing an 
amazing job there. Minor clarification on use cases below.




Comment at: include/clang/Basic/Attr.td:1949
+  let Args = [UnsignedArgument<"VectorWidth">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];

aaron.ballman wrote:
> craig.topper wrote:
> > aaron.ballman wrote:
> > > Should this apply to Objective-C methods? What about other function-like 
> > > interfaces such as function pointers?
> > I think maybe it should apply to objective-C. but I"m not sure because it 
> > doesn't look like the target attribute applies there?
> I don't have strong opinions on the question, I just wasn't sure if this 
> attribute would be something an ObjC method would want to make use of. If 
> that's unlikely, it's reasonable to leave it off until a use case appears.
Should it in theory? Yes.

But if/when we want to make good on that in practice, we would need to do the 
same for the target attribute as Craig mentions. I think it would be good to 
defer doing anything here to that point -- we don't need these to be *more* 
powerful than the target attribute in that regard.


https://reviews.llvm.org/D48617



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

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



Comment at: include/clang/Basic/Attr.td:1949
+  let Args = [UnsignedArgument<"VectorWidth">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [Undocumented];

chandlerc wrote:
> aaron.ballman wrote:
> > craig.topper wrote:
> > > aaron.ballman wrote:
> > > > Should this apply to Objective-C methods? What about other 
> > > > function-like interfaces such as function pointers?
> > > I think maybe it should apply to objective-C. but I"m not sure because it 
> > > doesn't look like the target attribute applies there?
> > I don't have strong opinions on the question, I just wasn't sure if this 
> > attribute would be something an ObjC method would want to make use of. If 
> > that's unlikely, it's reasonable to leave it off until a use case appears.
> Should it in theory? Yes.
> 
> But if/when we want to make good on that in practice, we would need to do the 
> same for the target attribute as Craig mentions. I think it would be good to 
> defer doing anything here to that point -- we don't need these to be *more* 
> powerful than the target attribute in that regard.
Strong agreement; that was the conclusion @craig.topper and I came to on IRC as 
well.


https://reviews.llvm.org/D48617



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


[PATCH] D48617: [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it.

2018-07-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 153786.
craig.topper marked 4 inline comments as done.
craig.topper added a comment.

-Added a negative test
-Hopefully fixed all the grammatical/spelling errors.
-Attempted to clarify some more about prefer-vector-width and builtins.


https://reviews.llvm.org/D48617

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Headers/__wmmintrin_aes.h
  lib/Headers/ammintrin.h
  lib/Headers/avx2intrin.h
  lib/Headers/avx512bitalgintrin.h
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512cdintrin.h
  lib/Headers/avx512dqintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512ifmaintrin.h
  lib/Headers/avx512ifmavlintrin.h
  lib/Headers/avx512vbmi2intrin.h
  lib/Headers/avx512vbmiintrin.h
  lib/Headers/avx512vbmivlintrin.h
  lib/Headers/avx512vlbitalgintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlcdintrin.h
  lib/Headers/avx512vldqintrin.h
  lib/Headers/avx512vlintrin.h
  lib/Headers/avx512vlvbmi2intrin.h
  lib/Headers/avx512vlvnniintrin.h
  lib/Headers/avx512vnniintrin.h
  lib/Headers/avx512vpopcntdqintrin.h
  lib/Headers/avx512vpopcntdqvlintrin.h
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  lib/Headers/f16cintrin.h
  lib/Headers/fma4intrin.h
  lib/Headers/fmaintrin.h
  lib/Headers/gfniintrin.h
  lib/Headers/mm3dnow.h
  lib/Headers/mmintrin.h
  lib/Headers/pmmintrin.h
  lib/Headers/shaintrin.h
  lib/Headers/smmintrin.h
  lib/Headers/tmmintrin.h
  lib/Headers/vaesintrin.h
  lib/Headers/xmmintrin.h
  lib/Headers/xopintrin.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/function-min-vector-width.c
  test/CodeGen/x86-builtins-vector-width.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-min-vector-width.c
  unittests/AST/ASTImporterTest.cpp



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


[PATCH] D48341: [clang-doc] Adding a second reduce pass

2018-07-02 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 153787.
juliehockett marked 12 inline comments as done.
juliehockett added a comment.

Refactoring second reduce code into the library, and adding bitcode 
reader/writer support


https://reviews.llvm.org/D48341

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeReader.h
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-comments.cpp
  clang-tools-extra/test/clang-doc/yaml-namespace.cpp
  clang-tools-extra/test/clang-doc/yaml-record.cpp

Index: clang-tools-extra/test/clang-doc/yaml-record.cpp
===
--- clang-tools-extra/test/clang-doc/yaml-record.cpp
+++ clang-tools-extra/test/clang-doc/yaml-record.cpp
@@ -1,250 +1,301 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
-// RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
-// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
-// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
-// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
-// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
-// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
-// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
-// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
-// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
-// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
-// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
-// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
-// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
-// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
-
-union A { int X; int Y; };
-
-// CHECK-A: ---
-// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
-// CHECK-A-NEXT: Name:'A'
-// CHECK-A-NEXT: DefLocation: 
-// CHECK-A-NEXT:   LineNumber:  21
-// CHECK-A-NEXT:   Filename:'{{.*}}'
-// CHECK-A-NEXT: TagType: Union
-// CHECK-A-NEXT: Members: 
-// CHECK-A-NEXT:   - Type:
-// CHECK-A-NEXT:   Name:'int'
-// CHECK-A-NEXT: Name:'X'
-// CHECK-A-NEXT:   - Type:
-// CHECK-A-NEXT:   Name:'int'
-// CHECK-A-NEXT: Name:'Y'
-// CHECK-A-NEXT: ...
+// RUN: cp "%s" "%t/{{.*}}.cpp"
+// RUN: clang-doc -doxygen -p %t %t/{{.*}}.cpp -output=%t/docs
+// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/Records.yaml | FileCheck %s --check-prefix=CHECK-R
+// RUN: cat %t/docs/Records/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Records/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/Records/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Records/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Records/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Records/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/Records/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
 
+namespace Records {
 
-enum B { X, Y };
+union A {
+  int X;
+  int Y;
+};
 
-// CHECK-B: ---
-// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
-// CHECK-B-NEXT: Name:'B'
-// CHECK-B-NEXT: DefLocation: 
-// CHECK-B-NEXT:   LineNumber:  40
-// CHECK-B-NEXT:   Filename:'{{.*}}'
-// CHECK-B-NEXT: Members: 
-// CHECK-B-NEXT:   - 'X'
-// CHECK-B-NEXT:   - 'Y'
-// CHECK-B-NEXT: ...
+//CHECK-A: ---
+//CHECK-A-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+//CHECK-A-NEXT: Name:'A'
+//CHECK-A-NEXT: Namespace:   
+//CHECK-A-NEXT:   - Type:Namespace
+//CHECK-A-NEXT: Name:'Records'
+//CHECK-A-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][

[PATCH] D48395: Added PublicOnly flag

2018-07-02 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 153790.
anniecherk added a comment.

Updated the tests to more accurately check that the files that we expect to not 
be generated by clang-doc with the public flag are in fact not being created.

The tests now run clang-doc over the test files with and without the public 
flag, outputting yaml files into two different directories. 
File-check then diffs those directories and verifies that the files we expect 
to be absent in the directory created from running clang-doc with the public 
flag are in fact absent.


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-records.cpp

Index: clang-tools-extra/test/clang-doc/yaml-public-records.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-public-records.cpp
@@ -0,0 +1,361 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs-without-flag
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Class/publicMethod.yaml| FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Class.yaml| FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Class/protectedMethod.yaml| FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/named.yaml| FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/named/NamedClass.yaml| FileCheck %s --check-prefix=CHECK-I
+// RUN: cat %t/docs/named/namedFunction.yaml| FileCheck %s --check-prefix=CHECK-J
+// RUN: cat %t/docs/named/namedInlineFunction.yaml| FileCheck %s --check-prefix=CHECK-K
+// RUN: cat %t/docs/named/NamedClass/namedPublicMethod.yaml| FileCheck %s --check-prefix=CHECK-L
+// RUN: cat %t/docs/named/NamedClass/namedProtectedMethod.yaml| FileCheck %s --check-prefix=CHECK-M
+// RUN: (diff -qry %t/docs-without-flag %t/docs | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-N
+
+
+void function(int x);
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'E789672E987C6FCE95B1BB760CB9A6998C4584A9'
+// CHECK-A-NEXT: Name:'function'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  24
+// CHECK-A-NEXT: Filename:'test'
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'void'
+// CHECK-A-NEXT: ...
+
+
+inline int inlinedFunction(int x);
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '9BDA332A65B254CC1F5FF736E8815A1CD3668A87'
+// CHECK-B-NEXT: Name:'inlinedFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  42
+// CHECK-B-NEXT: Filename:'test'
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+
+
+int functionWithInnerClass(int x){
+class InnerClass { //NoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: 'D7C0B43D134C4D904A64AB58AD050312E0F52B42'
+// CHECK-C-NEXT: Name:'functionWithInnerClass'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  61
+// CHECK-C-NEXT:   Filename:'test'
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'x'
+// CHECK-C-NEXT: ReturnType:
+// CHECK-C-NEXT:   Type:
+// CHECK-C-NEXT: Name:'int'
+// CHECK-C-NEXT: ...
+
+
+
+
+inline int inlinedFunctionWithInnerClass(int x){
+class InnerClass { //VisibleNoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '346651

[PATCH] D48341: [clang-doc] Adding a second reduce pass

2018-07-02 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:249
+if (EnclosingScope.get().RefType == doc::InfoType::IT_function)
+  continue;
+

ioeric wrote:
> Are symbols declared in functions indexed by the tool? If not, this should 
> probably assert or at least emit a warning message.
They are currently, but I'm planning to eliminate that in a future patch and 
will add the appropriate assertion then.


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] D48681: [CFG] [analyzer] Add construction contexts for function arguments.

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



Comment at: include/clang/Analysis/ConstructionContext.h:90
 assert(Other);
 return (Trigger == Other->Trigger);
   }

Uhm. Will fix.


Repository:
  rC Clang

https://reviews.llvm.org/D48681



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


[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu created this revision.
steven_wu added reviewers: arphaman, dexonsmith.

When clang required to infer target os version from --target option and
the os version is not specified in targets, check the host triple. If the
host and target are both macOS, use host triple to infer target os
version.

rdar://problem/41651999


Repository:
  rC Clang

https://reviews.llvm.org/D48849

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/clang-g-opts.c


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,22 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX()) {
+  unsigned Major, Minor, Micro;
+  Triple.getOSVersion(Major, Minor, Micro);
+  if (Major == 0)
+return DarwinPlatform::createFromArch(
+OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+}
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,22 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX()) {
+  unsigned Major, Minor, Micro;
+  Triple.getOSVersion(Major, Minor, Micro);
+  if (Major == 0)
+return DarwinPlatform::createFromArch(
+OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+}
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,
__

[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Unfortunately, I wasn't able to write a test for this because the host triple 
in the configuration can either be x86_64-apple-darwin* or 
x86_64-apple-macosx*, but the one used passed by driver is always macosx one. I 
can't reliably compare those two.


Repository:
  rC Clang

https://reviews.llvm.org/D48849



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


[PATCH] D48395: Added PublicOnly flag

2018-07-02 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a reviewer: ioeric.
juliehockett added inline comments.



Comment at: clang-tools-extra/clang-doc/ClangDoc.h:27
 
+struct ClangDocContext {
+tooling::ExecutionContext *ECtx;

Can we put this in `Representation.h`? Here, you have a potential circular 
include with `Mapper.h`.



Comment at: clang-tools-extra/clang-doc/Mapper.cpp:37-40
  serialize::emitInfo(D, getComment(D, D->getASTContext()),
  getLine(D, D->getASTContext()),
- getFile(D, D->getASTContext(;
+ getFile(D, D->getASTContext()),
+ CDCtx.PublicOnly));

Since the emitInfos are returning `""` if they're being passed over, the 
results container is still storing them -- move the emission outside of this 
call, and only report if it returns a non-empty string.



Comment at: clang-tools-extra/clang-doc/Mapper.h:23
 #include "clang/Tooling/Execution.h"
+#include "ClangDoc.h"
 

See above, I don't love the potential for circular includes (since `Mapper.h` 
is included in the implementation file for `ClangDoc`



Comment at: clang-tools-extra/clang-doc/Serialize.cpp:174
 
-static void parseFields(RecordInfo &I, const RecordDecl *D) {
+static bool shouldNotBePublic(const clang::AccessSpecifier as, const 
clang::Linkage link){
+if(as == clang::AccessSpecifier::AS_private)

For readability, it's usually better to use positives (i.e. `isPublic`). Then, 
if we ever want to check for internal only, `isPublic()` is much more readable 
than `!shouldNotBePublic()`.



Comment at: clang-tools-extra/clang-doc/Serialize.cpp:311-313
+  bool nonPublicNamespace = (D->isAnonymousNamespace()) ||
+shouldNotBePublic(D->getAccess(), D->getLinkageInternal());
+  if(PublicOnly && nonPublicNamespace){

You can inline this.



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:69
+"public",
+llvm::cl::desc("Document only public structures."),
+llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));

s/structures/declarations



Comment at: clang-tools-extra/test/clang-doc/yaml-module.cpp:14
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '4429AA8706EF483A44B1DCE2D956BF0FEF82A9B7'
+// CHECK-A-NEXT: Name:'moduleFunction'

I'm working on making these less brittle (so changing the USR schema doesn't 
require changing all these tests and just check the length with a regex, so 
let's just do that here (see D48341's tests for an example).



Comment at: clang-tools-extra/test/clang-doc/yaml-module.cpp:18
+// CHECK-A-NEXT:   - LineNumber:  12
+// CHECK-A-NEXT: Filename:'test'
+// CHECK-A-NEXT: Params:

To be system-agnostic, make this `{{.*}}` to match regardless of from where the 
test is run.



Comment at: clang-tools-extra/test/clang-doc/yaml-public-module.cpp:11-15
+
+
+
+
+

Unnecessary whitespace


https://reviews.llvm.org/D48395



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


[PATCH] D48852: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %tu/%td on Darwin

2018-07-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: jfb.
Herald added a subscriber: dexonsmith.

The '%tu'/'%td' as formatting specifiers have been used to print out the 
NSInteger/NSUInteger values for a long time. Typically their ABI matches (i.e. 
ptrdiff_t = NSInteger), but that's not the case on watchOS (ptrdiff_t = long, 
NSInteger = int). These specifiers trigger -Wformat warnings only for watchOS 
builds, which is really inconvenient for cross-platform code.

This patch avoids this `-Wformat` warning for '%tu'/'%td' and NS[U]Integer 
only, and instead uses the new `-Wformat-pedantic` warning that JF introduced 
in https://reviews.llvm.org/D47290. This is acceptable because Darwin 
guarantees that, despite the watchOS ABI differences, sizeof(ptrdiff_t) == 
sizeof(NS[U]Integer), so the warning is therefore noisy for pedantic reasons. 
Once this is in I'll update public documentation.

rdar://41739204


Repository:
  rC Clang

https://reviews.llvm.org/D48852

Files:
  include/clang/Analysis/Analyses/FormatString.h
  lib/Analysis/PrintfFormatString.cpp
  lib/Sema/SemaChecking.cpp
  test/SemaObjC/format-size-spec-nsinteger.m

Index: test/SemaObjC/format-size-spec-nsinteger.m
===
--- test/SemaObjC/format-size-spec-nsinteger.m
+++ test/SemaObjC/format-size-spec-nsinteger.m
@@ -1,16 +1,25 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat %s
 // RUN: %clang_cc1 -triple thumbv7-apple-ios -Wno-objc-root-class -fsyntax-only -verify -Wformat-pedantic -DPEDANTIC %s
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify -Wformat-pedantic -DPEDANTIC %s
 
 #if !defined(PEDANTIC)
 // expected-no-diagnostics
 #endif
 
 #if __LP64__
 typedef unsigned long NSUInteger;
 typedef long NSInteger;
+typedef long ptrdiff_t;
 #else
 typedef unsigned int NSUInteger;
 typedef int NSInteger;
+#if __is_target_os(watchos)
+  // Watch ABI uses long for ptrdiff_t.
+  typedef long ptrdiff_t;
+#else
+  typedef int ptrdiff_t;
+#endif
 #endif
 
 @class NSString;
@@ -28,3 +37,16 @@
   // expected-warning@-4 {{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
 #endif
 }
+
+void testPtrdiffSpecifier(ptrdiff_t x) {
+  NSInteger i = 0;
+  NSUInteger j = 0;
+
+  NSLog(@"ptrdiff_t NSUinteger: %tu", j);
+  NSLog(@"ptrdiff_t NSInteger: %td", i);
+  NSLog(@"ptrdiff_t %tu, %td", x, x);
+#if __is_target_os(watchos) && defined(PEDANTIC)
+  // expected-warning@-4 {{values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead}}
+  // expected-warning@-4 {{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+#endif
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6885,10 +6885,11 @@
 QualType CastTy;
 std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, IntendedTy, E);
 if (!CastTy.isNull()) {
-  // %zi/%zu are OK to use for NSInteger/NSUInteger of type int
+  // %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int
   // (long in ASTContext). Only complain to pedants.
   if ((CastTyName == "NSInteger" || CastTyName == "NSUInteger") &&
-  AT.isSizeT() && AT.matchesType(S.Context, CastTy))
+  (AT.isSizeT() || AT.isPtrdiffT()) &&
+  AT.matchesType(S.Context, CastTy))
 Pedantic = true;
   IntendedTy = CastTy;
   ShouldNotPrintDirectly = true;
Index: lib/Analysis/PrintfFormatString.cpp
===
--- lib/Analysis/PrintfFormatString.cpp
+++ lib/Analysis/PrintfFormatString.cpp
@@ -472,7 +472,8 @@
? ArgType(Ctx.LongLongTy, "__int64")
: ArgType(Ctx.IntTy, "__int32");
   case LengthModifier::AsPtrDiff:
-return ArgType(Ctx.getPointerDiffType(), "ptrdiff_t");
+return ArgType::makePtrdiffT(
+ArgType(Ctx.getPointerDiffType(), "ptrdiff_t"));
   case LengthModifier::AsAllocate:
   case LengthModifier::AsMAllocate:
   case LengthModifier::AsWide:
@@ -505,7 +506,8 @@
? ArgType(Ctx.UnsignedLongLongTy, "unsigned __int64")
: ArgType(Ctx.UnsignedIntTy, "unsigned __int32");
   case LengthModifier::AsPtrDiff:
-return ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t");
+return ArgType::makePtrdiffT(
+ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t"));
   case LengthModifier::AsAllocate:
   case LengthModifier::AsMAllocate:
   case LengthModifier::AsWide:
Index: include/clang/Analysis/Analyses/FormatStri

[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.

2018-07-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 153803.
Meinersbur added a comment.

- Adapt test file message.


Repository:
  rC Clang

https://reviews.llvm.org/D48808

Files:
  lib/CodeGen/CGLoopInfo.cpp
  test/CodeGenCXX/pragma-loop-safety-nested.cpp
  test/CodeGenCXX/pragma-loop-safety-outer.cpp


Index: test/CodeGenCXX/pragma-loop-safety-outer.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-outer.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_outer_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+for (int j = 0; j < 2; j += 1)
+  List[i + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: test/CodeGenCXX/pragma-loop-safety-nested.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-nested.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | 
FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the inner and outer loop using a list.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; ++i) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+for (int j = 0; j < Length; ++j)
+  List[i * Length + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access 
![[PARALLEL_LIST:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID:[0-9]+]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[PARALLEL_LIST]] = !{![[OUTER_LOOPID]], ![[INNER_LOOPID]]}
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: lib/CodeGen/CGLoopInfo.cpp
===
--- lib/CodeGen/CGLoopInfo.cpp
+++ lib/CodeGen/CGLoopInfo.cpp
@@ -300,6 +300,15 @@
 return;
   }
 
-  if (L.getAttributes().IsParallel && I->mayReadOrWriteMemory())
-I->setMetadata("llvm.mem.parallel_loop_access", L.getLoopID());
+  SmallVector ParallelLoopIDs;
+  for (const LoopInfo &AL : Active)
+if (AL.getAttributes().IsParallel && I->mayReadOrWriteMemory())
+  ParallelLoopIDs.push_back(AL.getLoopID());
+
+  MDNode *ParallelMD = nullptr;
+  if (ParallelLoopIDs.size() == 1)
+ParallelMD = cast(ParallelLoopIDs[0]);
+  else if (ParallelLoopIDs.size() >= 2)
+ParallelMD = MDNode::get(I->getContext(), ParallelLoopIDs);
+  I->setMetadata("llvm.mem.parallel_loop_access", ParallelMD);
 }


Index: test/CodeGenCXX/pragma-loop-safety-outer.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-outer.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_outer_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+for (int j = 0; j < 2; j += 1)
+  List[i + j] = (i + j) * 2;
+  }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access ![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: test/CodeGenCXX/pragma-loop-safety-nested.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-nested.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the inner and outer loop using a list.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+  for 

[PATCH] D45898: [SemaCXX] Mark destructor as referenced

2018-07-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 153779.
ahatanak added a comment.
Herald added a subscriber: dexonsmith.

Implement the new rule defined here: http://wg21.link/p0968r0#2227. Produce a 
diagnostic if a class is initialized with aggregate initialization and one of 
its element's destructor is not accessible.


Repository:
  rC Clang

https://reviews.llvm.org/D45898

Files:
  lib/Sema/SemaInit.cpp
  test/CodeGenObjCXX/arc-list-init-destruct.mm
  test/SemaCXX/aggregate-initialization.cpp


Index: test/SemaCXX/aggregate-initialization.cpp
===
--- test/SemaCXX/aggregate-initialization.cpp
+++ test/SemaCXX/aggregate-initialization.cpp
@@ -186,3 +186,15 @@
   // amount of time.
   struct A { int n; int arr[1000 * 1000 * 1000]; } a = {1, {2}};
 }
+
+namespace ElementDestructor {
+  // The destructor for each element of class type is potentially invoked
+  // (15.4 [class.dtor]) from the context where the aggregate initialization
+  // occurs. Produce a diagnostic if an element's destructor isn't accessible.
+
+  class X { ~X(); }; // expected-note {{implicitly declared private here}}
+  struct Y { X x; };
+  void test() {
+auto *y = new Y {}; // expected-error {{temporary of type 
'ElementDestructor::X' has private destructor}}
+  }
+}
Index: test/CodeGenObjCXX/arc-list-init-destruct.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-list-init-destruct.mm
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc 
-fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck 
%s
+
+// CHECK: %[[V0:.*]] = type opaque
+// CHECK: %[[STRUCT_CLASS1:.*]] = type { %[[V0]]* }
+
+@interface Class0;
+@end
+
+struct Class1 {
+  Class0 *f;
+};
+
+struct Container {
+  Class1 a;
+  bool b;
+};
+
+bool getBool() {
+  return false;
+}
+
+Class0 *g;
+
+// CHECK: define {{.*}} @_Z4testv()
+// CHECK: invoke zeroext i1 @_Z7getBoolv()
+// CHECK: landingpad { i8*, i32 }
+// CHECK: call void @_ZN6Class1D1Ev(%[[STRUCT_CLASS1]]* %{{.*}})
+// CHECK: br label
+
+// CHECK: define linkonce_odr void @_ZN6Class1D1Ev(
+
+Container test() {
+  return {{g}, getBool()};
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7083,6 +7083,28 @@
 
   InitListExpr *StructuredInitList =
   PerformInitList.getFullyStructuredList();
+
+  // The destructor for each element of class type is potentially invoked
+  // (15.4 [class.dtor]) from the context where the aggregate
+  // initialization occurs.
+  if (StructuredInitList)
+if (const auto *RD =
+StructuredInitList->getType()->getAsCXXRecordDecl()) {
+  for (const FieldDecl *FD : RD->fields()) {
+QualType FT = FD->getType();
+if (auto *FRD = FT->getAsCXXRecordDecl()) {
+  CXXDestructorDecl *Destructor = S.LookupDestructor(FRD);
+  S.CheckDestructorAccess(CurInit.get()->getLocStart(), Destructor,
+  S.PDiag(diag::err_access_dtor_temp)
+  << FT);
+  S.MarkFunctionReferenced(CurInit.get()->getLocStart(),
+   Destructor);
+  if (S.DiagnoseUseOfDecl(Destructor, 
CurInit.get()->getLocStart()))
+return ExprError();
+}
+  }
+}
+
   CurInit.get();
   CurInit = shouldBindAsTemporary(InitEntity)
   ? S.MaybeBindToTemporary(StructuredInitList)


Index: test/SemaCXX/aggregate-initialization.cpp
===
--- test/SemaCXX/aggregate-initialization.cpp
+++ test/SemaCXX/aggregate-initialization.cpp
@@ -186,3 +186,15 @@
   // amount of time.
   struct A { int n; int arr[1000 * 1000 * 1000]; } a = {1, {2}};
 }
+
+namespace ElementDestructor {
+  // The destructor for each element of class type is potentially invoked
+  // (15.4 [class.dtor]) from the context where the aggregate initialization
+  // occurs. Produce a diagnostic if an element's destructor isn't accessible.
+
+  class X { ~X(); }; // expected-note {{implicitly declared private here}}
+  struct Y { X x; };
+  void test() {
+auto *y = new Y {}; // expected-error {{temporary of type 'ElementDestructor::X' has private destructor}}
+  }
+}
Index: test/CodeGenObjCXX/arc-list-init-destruct.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-list-init-destruct.mm
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc -fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: %[[V0:.*]] = type opaque
+// CHECK: %[[STRUCT_CLASS1:.*]] = type { %[[V0]]* }
+
+@interface Class0;
+@end
+
+struct Cla

[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
Herald added a reviewer: george.karpenkov.
Herald added subscribers: cfe-commits, a.sidorin.

This gives better coverage to the check as ExprMutationAnalyzer is more
accurate comparing to isOnlyUsedAsConst.

Majority of wins come from const usage of member field, e.g.:
for (auto widget : container) { // copy of loop variable

  if (widget.type == BUTTON) { // const usage only recognized by 
ExprMutationAnalyzer
// ...
  }

}


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48854

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  test/clang-tidy/performance-for-range-copy.cpp


Index: test/clang-tidy/performance-for-range-copy.cpp
===
--- test/clang-tidy/performance-for-range-copy.cpp
+++ test/clang-tidy/performance-for-range-copy.cpp
@@ -117,6 +117,11 @@
   ~Mutable() {}
 };
 
+struct Point {
+  ~Point() {}
+  int x, y;
+};
+
 Mutable& operator<<(Mutable &Out, bool B) {
   Out.setBool(B);
   return Out;
@@ -214,6 +219,15 @@
   }
 }
 
+void positiveOnlyAccessedFieldAsConst() {
+  for (auto UsedAsConst : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]
+// CHECK-FIXES: for (const auto& UsedAsConst : View>()) {
+use(UsedAsConst.x);
+use(UsedAsConst.y);
+  }
+}
+
 void positiveOnlyUsedInCopyConstructor() {
   for (auto A : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]
Index: clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,7 +8,7 @@
 
//===--===//
 
 #include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
 
@@ -79,8 +79,8 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
-   Context))
+  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar))
 return false;
   diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "


Index: test/clang-tidy/performance-for-range-copy.cpp
===
--- test/clang-tidy/performance-for-range-copy.cpp
+++ test/clang-tidy/performance-for-range-copy.cpp
@@ -117,6 +117,11 @@
   ~Mutable() {}
 };
 
+struct Point {
+  ~Point() {}
+  int x, y;
+};
+
 Mutable& operator<<(Mutable &Out, bool B) {
   Out.setBool(B);
   return Out;
@@ -214,6 +219,15 @@
   }
 }
 
+void positiveOnlyAccessedFieldAsConst() {
+  for (auto UsedAsConst : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
+// CHECK-FIXES: for (const auto& UsedAsConst : View>()) {
+use(UsedAsConst.x);
+use(UsedAsConst.y);
+  }
+}
+
 void positiveOnlyUsedInCopyConstructor() {
   for (auto A : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
Index: clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,7 +8,7 @@
 //===--===//
 
 #include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/TypeTraits.h"
 
@@ -79,8 +79,8 @@
   utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
 return false;
-  if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
-   Context))
+  if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+  .isMutated(&LoopVar))
 return false;
   diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/

[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 153814.
steven_wu added a comment.

Update patch. Use a better API.


Repository:
  rC Clang

https://reviews.llvm.org/D48849

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/clang-g-opts.c


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,20 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX()) {
+  if (!Triple.getOSMajorVersion())
+return DarwinPlatform::createFromArch(
+OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+}
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,20 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX()) {
+  if (!Triple.getOSMajorVersion())
+return DarwinPlatform::createFromArch(
+OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+}
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

2018-07-02 Thread Francois JEAN via Phabricator via cfe-commits
Wawha updated this revision to Diff 153813.
Wawha added a comment.

Here the third version to manage break with lambda in Allman.
I implement the modification propose by klimek.
If a lambda is detected, the BlockParameterCount and ParameterCount are 
increment one more time in order to avoid extra line parsing after. It's lead 
to less code and less computation time, so I prefer this modification too.
Thank to klimek for this great remark :).

I hope that the patch is now ok for a submission. If there is other needs or 
remarks, tell me.


Repository:
  rC Clang

https://reviews.llvm.org/D44609

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10461,6 +10461,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterExternBlock);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);
@@ -11403,6 +11404,49 @@
   "> {\n"
   "  //\n"
   "});");
+
+  // Check option "BraceWrapping.BeforeLambdaBody"
+  FormatStyle LLVMWithBeforeLambdaBody = getLLVMStyle();
+  LLVMWithBeforeLambdaBody.BreakBeforeBraces = FormatStyle::BS_Custom;
+  LLVMWithBeforeLambdaBody.BraceWrapping.BeforeLambdaBody = true;
+  verifyFormat("FunctionWithOneParam(\n"
+   "[]()\n"
+   "{\n"
+   "  // A cool function...\n"
+   "  return 43;\n"
+   "},\n"
+   "87);",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("FunctionWithTwoParams(\n"
+   "[]()\n"
+   "{\n"
+   "  // A cool function...\n"
+   "  return 43;\n"
+   "},\n"
+   "87);",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("FunctionWithOneNestedLambdas(\n"
+   "[]()\n"
+   "{\n"
+   "  return 17;\n"
+   "});",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("TwoNestedLambdas(\n"
+   "[]()\n"
+   "{\n"
+   "  return Call(\n"
+   "  []()\n"
+   "  {\n"
+   "return 17;\n"
+   "  });\n"
+   "});",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("auto array = {[]()\n"
+   "  {\n"
+   "return 43;\n"
+   "  },\n"
+   "  MyFunctor};",
+   LLVMWithBeforeLambdaBody);
 }
 
 TEST_F(FormatTest, EmptyLinesInLambdas) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1404,6 +1404,7 @@
   return true;
 }
   }
+  FormatTok->Type = TT_LambdaLBrace;
   LSquare.Type = TT_LambdaLSquare;
   parseChildBlock();
   return true;
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -624,6 +624,10 @@
 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) {
   Left->ParameterCount = 1;
 }
+if(Style.BraceWrapping.BeforeLambdaBody && Current->is(TT_LambdaLSquare)) {
+++Left->BlockParameterCount;
+++Left->ParameterCount;
+}
   }
 
   bool parseConditional() {
@@ -1108,11 +1112,11 @@
 
 // Reset token type in case we have already looked at it and then
 // recovered from an error (e.g. failure to find the matching >).
-if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
-   TT_FunctionLBrace, TT_ImplicitStringLiteral,
-   TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
-   TT_OverloadedOperator, TT_RegexLiteral,
-   TT_TemplateString, TT_ObjCStringLiteral))
+if (!CurrentToken->isOneOf(
+TT_LambdaLSquare, TT_LambdaLBrace, TT_ForEachMacro,
+TT_FunctionLBrace, TT_ImplicitStringLiteral, TT_InlineASMBrace,
+TT_JsFatArrow, TT_LambdaArrow, TT_OverloadedOperator,
+TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral))
   CurrentToken->Type = T

[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 153816.
steven_wu added a comment.

Rebase the commit correctly


Repository:
  rC Clang

https://reviews.llvm.org/D48849

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/clang-g-opts.c


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,18 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX() && !Triple.getOSMajorVersion())
+  return DarwinPlatform::createFromArch(
+  OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,


Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,18 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX() && !Triple.getOSMajorVersion())
+  return DarwinPlatform::createFromArch(
+  OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Hmm, the driver should not call `inferDeploymentTargetFromArch` when `-target` 
is passed. Or am I missing something?


Repository:
  rC Clang

https://reviews.llvm.org/D48849



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


[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In https://reviews.llvm.org/D48849#1150246, @arphaman wrote:

> Hmm, the driver should not call `inferDeploymentTargetFromArch` when 
> `-target` is passed. Or am I missing something?


Good call. This only handles the *-apple-darwin case. Maybe the same should 
happen to *-apple-macosx.


Repository:
  rC Clang

https://reviews.llvm.org/D48849



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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-07-02 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 153821.
leonardchan marked 10 inline comments as done.
leonardchan edited the summary of this revision.
leonardchan added a comment.

- Added tests
- Moved all conversion logic into `convert`
- Saturation is checked by checking the bits above the sign bit in the 
destination type


Repository:
  rC Clang

https://reviews.llvm.org/D48661

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/FixedPoint.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/FixedPoint.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_declarations.c
  unittests/Basic/CMakeLists.txt
  unittests/Basic/FixedPointTest.cpp

Index: unittests/Basic/FixedPointTest.cpp
===
--- /dev/null
+++ unittests/Basic/FixedPointTest.cpp
@@ -0,0 +1,599 @@
+//===- unittests/Basic/FixedPointTest.cpp -- fixed point number tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Basic/FixedPoint.h"
+#include "llvm/ADT/APSInt.h"
+#include "gtest/gtest.h"
+
+using clang::APFixedPoint;
+using clang::fixedPointSemantics;
+using llvm::APInt;
+using llvm::APSInt;
+
+namespace {
+
+struct fixedPointSemantics Saturated(struct fixedPointSemantics Sema) {
+  Sema.isSaturated = true;
+  return Sema;
+}
+
+struct fixedPointSemantics getSAccSema() {
+  return {/*width=*/16, /*scale=*/7, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getAccSema() {
+  return {/*width=*/32, /*scale=*/15, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getLAccSema() {
+  return {/*width=*/64, /*scale=*/31, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getSFractSema() {
+  return {/*width=*/8, /*scale=*/7, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getFractSema() {
+  return {/*width=*/16, /*scale=*/15, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getLFractSema() {
+  return {/*width=*/32, /*scale=*/31, /*isSigned=*/true,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getUSAccSema() {
+  return {/*width=*/16, /*scale=*/8, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getUAccSema() {
+  return {/*width=*/32, /*scale=*/16, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getULAccSema() {
+  return {/*width=*/64, /*scale=*/32, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getUSFractSema() {
+  return {/*width=*/8, /*scale=*/8, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getUFractSema() {
+  return {/*width=*/16, /*scale=*/16, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getULFractSema() {
+  return {/*width=*/32, /*scale=*/32, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/false};
+}
+
+struct fixedPointSemantics getPadUSAccSema() {
+  return {/*width=*/16, /*scale=*/7, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+struct fixedPointSemantics getPadUAccSema() {
+  return {/*width=*/32, /*scale=*/15, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+struct fixedPointSemantics getPadULAccSema() {
+  return {/*width=*/64, /*scale=*/31, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+struct fixedPointSemantics getPadUSFractSema() {
+  return {/*width=*/8, /*scale=*/7, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+struct fixedPointSemantics getPadUFractSema() {
+  return {/*width=*/16, /*scale=*/15, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+struct fixedPointSemantics getPadULFractSema() {
+  return {/*width=*/32, /*scale=*/31, /*isSigned=*/false,
+  /*isSaturated=*/false, /*hasUnsignedPadding=*/true};
+}
+
+void CheckUnpaddedMax(const fixedPointSemantics &Sema) {
+  ASSERT_EQ(APFixedPoint::getMax(Sema).getValue(),
+APSInt::getMaxValue(Sema.width, !Sema.isSigned));
+}
+
+void CheckPaddedMax(const fixedPointSemantics &Sema) {
+  ASSERT_EQ(APFixedPoint::getMax(Sema).getValue(),

[PATCH] D48616: Implement LWG 2946, 3075 and 3076

2018-07-02 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as revision 336132.


https://reviews.llvm.org/D48616



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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-07-02 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: include/clang/Basic/FixedPoint.h:31
+  SatNoPadding,
+};
+

ebevhan wrote:
> rjmccall wrote:
> > I figured you'd want this to be a struct which include the scale, width, 
> > signed-ness, and saturating-ness; and then `APFixedPoint` can just store 
> > one of these next to a bare `APInt`.
> That's what I was expecting too, similar to the APFloat version.
> 
> What width would it contain? The width with or without padding? Probably the 
> one with padding as the APInt itself has the width without padding.
Woops my bad, I thought you were referring to the `APFloatSemantics`. I 
actually didn't know about `fltSemantics` until now.



Comment at: lib/Basic/FixedPoint.cpp:20
+
+llvm::APSInt ShrToZero(const llvm::APSInt &Val, unsigned Amt) {
+  if (Val < 0)

ebevhan wrote:
> I'm unsure if this operation is useful for anything but converting 
> fixed-point to integer. Make this a member of APFixedPoint, drop the 
> arguments and give it a name that makes it clearer that it is a round-to-zero 
> integer conversion? `toIntegerRoundToZero`?
You're right. Removed it altogether.



Comment at: lib/Basic/FixedPoint.cpp:53
+// We can overflow here
+unsigned ShiftAmt = DstScale - Scale;
+if (Val < 0 && Val.countLeadingOnes() >= ShiftAmt)

ebevhan wrote:
> ebevhan wrote:
> > I think saturation can be modeled a bit better. It should be possible to do 
> > the overflow check/saturation once instead of twice, and also have it fit 
> > in better with the other conversions.
> > 
> > Saturation on a value is essentially checking whether all bits above and 
> > including a certain bit are all the same, and 'clamping' to either the 
> > minimum (the mask) or maximum (inverse of the mask) if not.
> > ```
> > // Saturate Value to SatWidth. This will clamp Value at the signed min/max 
> > of a value that is SatWidth long.
> > Saturate(SatWidth):
> >   Mask = highBits(Width, SatWidth + 1)
> >   Masked = Value & Mask
> >   Result = Value
> >   if (Masked == Mask || Masked == 0) {
> > if (Masked.isNegative())
> >   Result = Mask
> > else
> >   Result = ~Mask
> >   }
> > ```
> > This cannot be done on the value in the source scale, since upscaling after 
> > clamping would produce an incorrect value - we would shift in 0's from the 
> > right even though we should have saturated all bits completely. Also, we 
> > cannot upscale without first extending or we might shift out bits on the 
> > left that could affect saturation.
> > 
> > One thing to note is that (I'm ***pretty sure*** this is the case) 
> > fractional bits cannot affect saturation. This means that we can find a 
> > common scale, then perform the saturation operation, and then resize, and 
> > the value should just fall into place. Basically:
> >   # Upscale if necessary, but extend first to ensure that we don't drop any 
> > bits on the left. Do this by resizing to `SrcWidth - SrcScale + 
> > std::max(SrcScale, DstScale)` and then upscaling normally by `DstScale - 
> > SrcScale`.
> >   # Downscale if necessary by `SrcScale - DstScale`. (I think; in our 
> > downstream, we saturate first and then downscale, but we also assume that 
> > saturation can only occur on _Fract, and doing saturation first makes the 
> > saturation width calculation a bit messier because it will be a `max` 
> > expression. I'm unsure if the order can be changed.)
> >   # At this point, the scale of the value should be `DstScale`. Saturate 
> > with `Saturate(DstWidth)`.
> >   # Now the value should be in range for the new width, and will be at the 
> > right scale as well. Resize with `extOrTrunc(DstWidth)`.
> >   # (Also; if the result was negative and the dest type is unsigned, just 
> > make the result zero here instead.)
> > 
> > Note that the order of operations is different than what I've mentioned 
> > before with non-saturated conversion (downscale if needed, resize, upscale 
> > if needed), but it works because we only do the upscale as a 
> > resize+upscale. Somewhere in here you also need to change the signedness of 
> > the value, but I'm not entirely certain where. Likely after 4.
> > 
> > Everything I've mentioned here is semi-conjectural, since our 
> > implementation has different type widths than the defaults in this one, we 
> > can only saturate on _Fract, and our unsigned types have padding. It's 
> > possible that there are some assumptions that cause this method to fail for 
> > unsigned without padding, or perhaps for some other type conversion, but I 
> > haven't come up with a counterexample yet.
> Now that I think about it a bit more, it's clear that the Saturate routine 
> does not work for unsigned fixed-point without padding. That would need to be 
> taken into consideration, but the rest should work.
Thanks for the deeper explanation. The implementation is essentially the same 
and catching the uns

[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 153822.
steven_wu added a comment.

handle *-apple-macosx target option


Repository:
  rC Clang

https://reviews.llvm.org/D48849

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/clang-g-opts.c
  test/Driver/target-triple-deployment.c


Index: test/Driver/target-triple-deployment.c
===
--- test/Driver/target-triple-deployment.c
+++ test/Driver/target-triple-deployment.c
@@ -1,5 +1,5 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
 // RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
 // RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
 //
Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1512,9 +1512,18 @@
   else if (MachOArchName == "armv7k")
 OSTy = llvm::Triple::WatchOS;
   else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-   MachOArchName != "armv7em")
+   MachOArchName != "armv7em") {
+// Default to macOS for other architectures.
 OSTy = llvm::Triple::MacOSX;
 
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+if (SystemTriple.isMacOSX() && !Triple.getOSMajorVersion())
+  return DarwinPlatform::createFromArch(
+  OSTy, getOSVersion(OSTy, SystemTriple, TheDriver));
+  }
+
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
   return DarwinPlatform::createFromArch(OSTy,
@@ -1529,7 +1538,17 @@
   if (Triple.getOS() == llvm::Triple::Darwin ||
   Triple.getOS() == llvm::Triple::UnknownOS)
 return None;
-  std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
+
+  // If the host and target are both macos, and the OS version is not set in
+  // the target, infer the os version from host triple.
+  std::string OSVersion;
+  llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+  if (Triple.isMacOSX() && SystemTriple.isMacOSX() &&
+  !Triple.getOSMajorVersion())
+OSVersion = getOSVersion(SystemTriple.getOS(), SystemTriple, TheDriver);
+  else
+OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
+
   return DarwinPlatform::createFromTarget(Triple, OSVersion,
   
Args.getLastArg(options::OPT_target));
 }


Index: test/Driver/target-triple-deployment.c
===
--- test/Driver/target-triple-deployment.c
+++ test/Driver/target-triple-deployment.c
@@ -1,5 +1,5 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
 // RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
 // RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
 //
Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: 

[PATCH] D48395: Added PublicOnly flag

2018-07-02 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 153825.
anniecherk marked 4 inline comments as done.
anniecherk added a comment.

Addressed Julie's comments


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-records.cpp

Index: clang-tools-extra/test/clang-doc/yaml-public-records.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-public-records.cpp
@@ -0,0 +1,339 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs-without-flag
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Class/publicMethod.yaml| FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Class.yaml| FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Class/protectedMethod.yaml| FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/named.yaml| FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/named/NamedClass.yaml| FileCheck %s --check-prefix=CHECK-I
+// RUN: cat %t/docs/named/namedFunction.yaml| FileCheck %s --check-prefix=CHECK-J
+// RUN: cat %t/docs/named/namedInlineFunction.yaml| FileCheck %s --check-prefix=CHECK-K
+// RUN: cat %t/docs/named/NamedClass/namedPublicMethod.yaml| FileCheck %s --check-prefix=CHECK-L
+// RUN: cat %t/docs/named/NamedClass/namedProtectedMethod.yaml| FileCheck %s --check-prefix=CHECK-M
+// RUN: (diff -qry %t/docs-without-flag %t/docs | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-N
+
+void function(int x);
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-A-NEXT: Name:'function'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  23
+// CHECK-A-NEXT: Filename:{{.*}}
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'void'
+// CHECK-A-NEXT: ...
+
+inline int inlinedFunction(int x);
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-B-NEXT: Name:'inlinedFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  40
+// CHECK-B-NEXT: Filename:{{.*}}
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+int functionWithInnerClass(int x){
+class InnerClass { //NoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-C-NEXT: Name:'functionWithInnerClass'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  57
+// CHECK-C-NEXT:   Filename:{{.*}}
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:  

[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.

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



Comment at: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp:68
 : IILockGuard(nullptr), IIUniqueLock(nullptr),
-  LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"),
-  FgetsFn("fgets"), ReadFn("read"), RecvFn("recv"),
-  PthreadLockFn("pthread_mutex_lock"),
-  PthreadTryLockFn("pthread_mutex_trylock"),
-  PthreadUnlockFn("pthread_mutex_unlock"),
-  MtxLock("mtx_lock"),
-  MtxTimedLock("mtx_timedlock"),
-  MtxTryLock("mtx_trylock"),
-  MtxUnlock("mtx_unlock"),
+  LockFn({"lock"}), UnlockFn({"unlock"}), SleepFn({"sleep"}), 
GetcFn({"getc"}),
+  FgetsFn({"fgets"}), ReadFn({"read"}), RecvFn({"recv"}),

I wish the old syntax for simple C functions was preserved.

This could be accidentally achieved by using `ArrayRef` instead of 
`std::vector` for your constructor's argument.



Comment at: lib/StaticAnalyzer/Core/CallEvent.cpp:273-280
+std::string Regex = "^::(.*)?";
+Regex += llvm::join(CD.QualifiedName, "(.*)?::(.*)?") + "(.*)?$";
+
+auto Matches = match(namedDecl(matchesName(Regex)).bind("Regex"), *ND,
+ LCtx->getAnalysisDeclContext()->getASTContext());
+
+if (Matches.empty())

Uhm, i think we don't need to flatten the class name to a string and then regex 
to do this.

We can just unwrap the declaration and see if the newly unwrapped layer matches 
the expected name on every step, until all expected names have been found.


Repository:
  rC Clang

https://reviews.llvm.org/D48027



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


r336153 - Per C++ [over.match.copy]p1, direct-initialization of a reference can

2018-07-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jul  2 16:25:22 2018
New Revision: 336153

URL: http://llvm.org/viewvc/llvm-project?rev=336153&view=rev
Log:
Per C++ [over.match.copy]p1, direct-initialization of a reference can
only invoke converting constructors of the reference's underlying type.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=336153&r1=336152&r2=336153&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jul  2 16:25:22 2018
@@ -4224,9 +4224,11 @@ static OverloadingResult TryRefInitWithC
   OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet();
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByUserDefinedConversion);
 
-  // Determine whether we are allowed to call explicit constructors or
-  // explicit conversion operators.
-  bool AllowExplicit = Kind.AllowExplicit();
+  // Determine whether we are allowed to call explicit conversion operators.
+  // Note that none of [over.match.copy], [over.match.conv], nor
+  // [over.match.ref] permit an explicit constructor to be chosen when
+  // initializing a reference, not even for direct-initialization.
+  bool AllowExplicitCtors = false;
   bool AllowExplicitConvs = 
Kind.allowExplicitConversionFunctionsInRefBinding();
 
   const RecordType *T1RecordType = nullptr;
@@ -4242,7 +4244,7 @@ static OverloadingResult TryRefInitWithC
 continue;
 
   if (!Info.Constructor->isInvalidDecl() &&
-  Info.Constructor->isConvertingConstructor(AllowExplicit)) {
+  Info.Constructor->isConvertingConstructor(AllowExplicitCtors)) {
 if (Info.ConstructorTmpl)
   S.AddTemplateOverloadCandidate(Info.ConstructorTmpl, Info.FoundDecl,
  /*ExplicitArgs*/ nullptr,

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp?rev=336153&r1=336152&r2=336153&view=diff
==
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp Mon Jul  2 
16:25:22 2018
@@ -61,3 +61,12 @@ namespace test3 {
 unsigned &t9 = (a->bitY += 3); // expected-error {{non-const reference 
cannot bind to bit-field 'bitY'}}
   }
 }
+
+namespace explicit_ctor {
+  struct A {};
+  struct B { // expected-note 2{{candidate}}
+explicit B(const A&);
+  };
+  A a;
+  const B &b(a); // expected-error {{no viable conversion}}
+}


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


[PATCH] D48831: alpha.unix.cstring.OutOfBounds checker enable/disable fix

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

Uhm, so we had an alpha checker enabled all along? Thanks for patching this up!




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:308
 // These checks are either enabled by the CString out-of-bounds checker
-// explicitly or the "basic" CStringNullArg checker support that Malloc
-// checker enables.
-assert(Filter.CheckCStringOutOfBounds || Filter.CheckCStringNullArg);
+// explicitly or implicitly by the  Malloc checker.
+// In the latter case we only do modeling but do not emit warning.

Accidental double space.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:311
+if (!Filter.CheckCStringOutOfBounds)
+  return StOutBound;
 

Could we preserve the other portion of the assertion on this branch? I.e., 
`assert(Filter.CheckCStringNullArg)`.

Additionally, do you really want to continue analysis on this path? Maybe 
`return nullptr` to sink?


Repository:
  rC Clang

https://reviews.llvm.org/D48831



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


[PATCH] D48322: [Sema] Discarded statment should be an evaluatable context

2018-07-02 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In https://reviews.llvm.org/D48322#1148424, @rsmith wrote:

> Hmm, so this will mean that we can have internal linkage declarations marked 
> `Used` for which there is no definition, and we need to not warn on that.
>
> I think it might be better to avoid marking things used in this case (even 
> though they're still technically odr-used).


We already return `false` for discarded statements in `isOdrUseContext`, so 
neither `MarkVarDeclReferenced` nor `MarkFunctionReferenced` will set `Used`. 
With or without this patch, clang doesn't emit -Wundefined-internal for the 
following code:

  static int p();
  int main() {
if constexpr (false) p();
  }

Is this what you were concerned about?


Repository:
  rC Clang

https://reviews.llvm.org/D48322



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


[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Nit: Could you please try to extract the shared code into a function, e.g.

  Optional overrideMacOSTripleDefaultVersion(const llvm::Triple 
&Triple, ... OSTy, ... TheDriver) {
  if (Triple.getOSMajorVersion())
return None;
  llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
  if (SystemTriple.isMacOSX())
return getOSVersion(OSTy, SystemTriple, TheDriver));
 return None;
  }


Repository:
  rC Clang

https://reviews.llvm.org/D48849



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


Buildbot numbers for the week of 6/17/2018 - 6/23/2018

2018-07-02 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 6/17/2018 - 6/23/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 clang-x64-ninja-win7 | 76:31:47
 clang-cmake-x86_64-sde-avx512-linux  | 70:19:54
 lldb-x86_64-ubuntu-14.04-android | 34:38:50
 lldb-windows7-android| 20:04:31
 clang-lld-x86_64-2stage  | 19:08:40
 clang-with-lto-ubuntu| 12:41:17
 sanitizer-x86_64-linux-android   | 11:52:04
 sanitizer-x86_64-linux-bootstrap-ubsan   | 10:12:08
 clang-s390x-linux-multistage | 09:37:54
 clang-s390x-linux-lnt| 08:34:55
 clang-s390x-linux| 08:24:38
 clang-ppc64be-linux-lnt  | 08:05:16
 sanitizer-x86_64-linux   | 07:31:39
 clang-cmake-thumbv7-full-sh  | 07:11:15
 clang-cmake-armv7-selfhost-neon  | 07:02:23
 clang-cmake-armv7-selfhost   | 07:02:11
 llvm-clang-x86_64-expensive-checks-win   | 07:01:17
 sanitizer-x86_64-linux-bootstrap-msan| 07:00:40
 clang-cmake-aarch64-lld  | 06:37:34
 clang-cmake-armv8-selfhost-neon  | 06:30:33
 sanitizer-x86_64-linux-bootstrap | 06:15:57
 sanitizer-x86_64-linux-fast  | 05:59:08
 lldb-amd64-ninja-netbsd8 | 05:40:27
 clang-ppc64le-linux-multistage   | 05:26:29
 sanitizer-ppc64le-linux  | 05:24:35
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 04:45:07
 clang-ppc64be-linux-multistage   | 04:12:53
 clang-ppc64le-linux-lnt  | 03:45:15
 clang-cmake-armv7-full   | 03:41:43
 clang-with-thin-lto-ubuntu   | 03:40:48
 clang-bpf-build  | 03:32:35
 clang-cmake-x86_64-avx2-linux| 03:18:11
 clang-cmake-x86_64-avx2-linux-perf   | 03:17:54
 clang-cmake-aarch64-global-isel  | 03:06:24
 clang-ppc64be-linux  | 03:03:39
 sanitizer-windows| 02:57:25
 clang-cmake-armv7-global-isel| 02:53:24
 reverse-iteration| 02:41:02
 clang-cmake-armv8-full   | 02:36:28
 clang-cmake-armv7-quick  | 02:29:23
 clang-cuda-build | 02:20:00
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 02:14:21
 clang-cmake-aarch64-quick| 02:10:04
 clang-x86_64-debian-fast | 02:03:08
 clang-hexagon-elf| 01:56:48
 llvm-hexagon-elf | 01:54:46
 lldb-x86_64-darwin-13.4  | 01:43:29
 sanitizer-ppc64be-linux  | 01:33:49
 clang-ppc64le-linux  | 01:32:59
 clang-cmake-armv8-quick  | 01:32:40
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 01:28:46
 lld-perf-testsuite   | 01:14:39
 clang-x86_64-linux-abi-test  | 01:14:32
 sanitizer-x86_64-linux-fuzzer| 01:11:43
 lld-x86_64-freebsd   | 01:10:08
 lld-x86_64-darwin13  | 01:09:06
 lldb-x86_64-ubuntu-14.04-buildserver | 01:06:08
 lldb-x86-windows-msvc2015| 00:56:41
 clang-cmake-armv8-global-isel| 00:50:46
 polly-amd64-linux| 00:50:30
 clang-cmake-armv8-lnt| 00:47:03
 polly-arm-linux  | 00:45:37
 lldb-x86_64-ubuntu-14.04-cmake   | 00:40:38
 sanitizer-x86_64-linux-autoconf  | 00:28:50
 lldb-amd64-ninja-freebsd11   | 00:27:30
(65 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| status_change_ratio
-

Buildbot numbers for the week of 6/24/2018 - 6/30/2018

2018-07-02 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 6/24/2018 - 6/30/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 aosp-O3-polly-before-vectorizer-unprofitable | 119:46:56
 clang-cmake-armv7-full   | 71:47:45
 clang-cmake-armv8-full   | 67:26:26
 sanitizer-x86_64-linux-android   | 59:56:32
 clang-x64-ninja-win7 | 39:11:09
 lldb-x86_64-darwin-13.4  | 33:54:55
 clang-with-lto-ubuntu| 27:38:34
 clang-cmake-aarch64-lld  | 25:07:28
 reverse-iteration| 23:38:49
 clang-with-thin-lto-ubuntu   | 23:38:00
 clang-hexagon-elf| 23:34:05
 llvm-clang-x86_64-expensive-checks-win   | 23:27:31
 clang-cmake-armv8-quick  | 23:04:14
 clang-x86_64-linux-abi-test  | 22:43:02
 clang-cmake-armv7-quick  | 22:27:30
 clang-cmake-armv7-global-isel| 21:48:05
 clang-cmake-armv8-global-isel| 21:45:22
 lld-x86_64-win7  | 17:53:30
 sanitizer-x86_64-linux   | 17:29:35
 clang-s390x-linux-lnt| 16:37:45
 lldb-windows7-android| 14:52:12
 lldb-x86_64-ubuntu-14.04-android | 14:45:50
 lldb-x86_64-ubuntu-14.04-cmake   | 13:13:03
 clang-lld-x86_64-2stage  | 12:21:31
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 11:57:44
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 10:44:36
 clang-ppc64le-linux-multistage   | 09:28:52
 sanitizer-x86_64-linux-bootstrap-ubsan   | 08:22:17
 clang-cmake-armv7-selfhost-neon  | 07:55:43
 clang-cmake-armv7-selfhost   | 07:55:38
 clang-cmake-aarch64-full | 06:17:36
 clang-s390x-linux-multistage | 05:59:33
 clang-cmake-thumbv8-full-sh  | 05:14:26
 sanitizer-ppc64le-linux  | 04:36:42
 llvm-hexagon-elf | 04:04:30
 polly-arm-linux  | 03:56:08
 polly-amd64-linux| 03:32:07
 sanitizer-x86_64-linux-bootstrap | 03:31:55
 sanitizer-x86_64-linux-bootstrap-msan| 03:01:01
 lldb-amd64-ninja-netbsd8 | 03:00:45
 clang-cmake-aarch64-quick| 02:58:43
 clang-cmake-armv8-selfhost-neon  | 02:53:20
 clang-cmake-aarch64-global-isel  | 02:52:16
 clang-bpf-build  | 02:48:29
 clang-x86_64-debian-fast | 02:47:05
 sanitizer-ppc64be-linux  | 02:42:44
 clang-cmake-x86_64-avx2-linux| 02:39:05
 clang-cmake-x86_64-sde-avx512-linux  | 02:29:49
 clang-cuda-build | 02:29:08
 clang-ppc64be-linux-multistage   | 02:20:54
 clang-ppc64be-linux  | 02:15:41
 clang-ppc64be-linux-lnt  | 02:10:36
 clang-ppc64le-linux-lnt  | 02:06:32
 sanitizer-x86_64-linux-fast  | 01:51:11
 clang-ppc64le-linux  | 01:44:39
 lld-x86_64-freebsd   | 01:43:42
 clang-cmake-x86_64-avx2-linux-perf   | 01:43:13
 lld-x86_64-darwin13  | 01:41:11
 lldb-x86-windows-msvc2015| 01:39:16
 clang-s390x-linux| 01:38:42
 sanitizer-windows| 01:34:15
 lld-perf-testsuite   | 01:14:33
 lldb-x86_64-ubuntu-14.04-buildserver | 00:56:46
 sanitizer-x86_64-linux-autoconf  | 00:50:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 00:37:16
 sanitizer-x86_64-linux-fuzzer| 00:36:07
 clang-aarch64-linux-build-cache  | 00:25:48
 clang-armv7-linux-build-cache| 00:23:18
 llvm-sphinx-docs | 00:11:11
 lldb-amd64-ninja-freebsd11

[PATCH] D48721: Patch to fix pragma metadata for do-while loops

2018-07-02 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I tried running

  /clang -cc1 -O3 -funroll-loops -S -emit-llvm pragma-do-while-unroll.cpp -o - 
-mllvm -print-after-all

and I get this

  ...
  !2 = distinct !{!2, !3}
  !3 = !{!"llvm.loop.unroll.count", i32 3}
  !4 = !{!5, !5, i64 0}
  !5 = !{!"int", !6, i64 0}
  !6 = !{!"omnipotent char", !7, i64 0}
  !7 = !{!"Simple C/C++ TBAA"}
  !8 = distinct !{!8, !9}
  !9 = !{!"llvm.loop.unroll.count", i32 5}
  *** IR Dump After Combine redundant instructions ***
  ; Function Attrs: nounwind
  define i32 @test(i32* %a, i32 %n) local_unnamed_addr #0 {
  entry:
br label %do.body, !llvm.loop !2
  
  do.body:  ; preds = %do.body, %entry
%i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
%sum.0 = phi i32 [ 0, %entry ], [ %add5, %do.body ]
%0 = zext i32 %i.0 to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %0
%1 = load i32, i32* %arrayidx, align 4, !tbaa !4
%add = add nsw i32 %1, 1
store i32 %add, i32* %arrayidx, align 4, !tbaa !4
%add5 = add nsw i32 %sum.0, %add
%inc = add nuw nsw i32 %i.0, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %do.body, label %do.end, !llvm.loop !2
  
  do.end:   ; preds = %do.body
br label %do.body6, !llvm.loop !8
  
  do.body6: ; preds = %do.body6, %do.end
%i.1 = phi i32 [ 0, %do.end ], [ %inc15, %do.body6 ]
%sum.1 = phi i32 [ %add5, %do.end ], [ %add14, %do.body6 ]
%2 = zext i32 %i.1 to i64
%arrayidx8 = getelementptr inbounds i32, i32* %a, i64 %2
%3 = load i32, i32* %arrayidx8, align 4, !tbaa !4
%add9 = add nsw i32 %3, 1
store i32 %add9, i32* %arrayidx8, align 4, !tbaa !4
%add14 = add nsw i32 %sum.1, %add9
%inc15 = add nuw nsw i32 %i.1, 1
%cmp17 = icmp slt i32 %inc15, %n
br i1 %cmp17, label %do.body6, label %do.end18, !llvm.loop !8
  
  do.end18: ; preds = %do.body6
ret i32 %add14
  }
  *** IR Dump After Simplify the CFG ***
  ; Function Attrs: nounwind
  define i32 @test(i32* %a, i32 %n) local_unnamed_addr #0 {
  entry:
br label %do.body, !llvm.loop !2
  
  do.body:  ; preds = %do.body, %entry
%i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
%sum.0 = phi i32 [ 0, %entry ], [ %add5, %do.body ]
%0 = zext i32 %i.0 to i64
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %0
%1 = load i32, i32* %arrayidx, align 4, !tbaa !4
%add = add nsw i32 %1, 1
store i32 %add, i32* %arrayidx, align 4, !tbaa !4
%add5 = add nsw i32 %sum.0, %add
%inc = add nuw nsw i32 %i.0, 1
%cmp = icmp slt i32 %inc, %n
br i1 %cmp, label %do.body, label %do.body6, !llvm.loop !8
  
  do.body6: ; preds = %do.body, 
%do.body6
%i.1 = phi i32 [ %inc15, %do.body6 ], [ 0, %do.body ]
%sum.1 = phi i32 [ %add14, %do.body6 ], [ %add5, %do.body ]
%2 = zext i32 %i.1 to i64
%arrayidx8 = getelementptr inbounds i32, i32* %a, i64 %2
%3 = load i32, i32* %arrayidx8, align 4, !tbaa !4
%add9 = add nsw i32 %3, 1
store i32 %add9, i32* %arrayidx8, align 4, !tbaa !4
%add14 = add nsw i32 %sum.1, %add9
%inc15 = add nuw nsw i32 %i.1, 1
%cmp17 = icmp slt i32 %inc15, %n
br i1 %cmp17, label %do.body6, label %do.end18, !llvm.loop !8
  
  do.end18: ; preds = %do.body6
ret i32 %add14
  }
  ...

So up until simplifyCFG I think things look pretty good with different 
loop-metadata for the two loops. But when simplifyCFG is tranforming

br i1 %cmp, label %do.body, label %do.end, !llvm.loop !2
  
  do.end:   ; preds = %do.body
br label %do.body6, !llvm.loop !8

into

  br i1 %cmp, label %do.body, label %do.body6, !llvm.loop !8

we get incorrect metadata for one branch target.

Is the fault that the metadata only should be put on the back edge, not the 
branch in the preheader?


Repository:
  rC Clang

https://reviews.llvm.org/D48721



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


[libcxxabi] r336157 - [demangler] Fix a MSVC alignment warning.

2018-07-02 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Jul  2 17:23:18 2018
New Revision: 336157

URL: http://llvm.org/viewvc/llvm-project?rev=336157&view=rev
Log:
[demangler] Fix a MSVC alignment warning.

This should fix llvm.org/PR37944

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=336157&r1=336156&r2=336157&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Jul  2 17:23:18 2018
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1890,7 +1891,7 @@ class BumpPointerAllocator {
   static constexpr size_t AllocSize = 4096;
   static constexpr size_t UsableAllocSize = AllocSize - sizeof(BlockMeta);
 
-  alignas(16) char InitialBuffer[AllocSize];
+  alignas(std::max_align_t) char InitialBuffer[AllocSize];
   BlockMeta* BlockList = nullptr;
 
   void grow() {


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


[libcxxabi] r336159 - Some buildbots were choking on std::max_align_t, try using the global alias.

2018-07-02 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Jul  2 17:48:27 2018
New Revision: 336159

URL: http://llvm.org/viewvc/llvm-project?rev=336159&view=rev
Log:
Some buildbots were choking on std::max_align_t, try using the global alias.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=336159&r1=336158&r2=336159&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Jul  2 17:48:27 2018
@@ -1891,7 +1891,7 @@ class BumpPointerAllocator {
   static constexpr size_t AllocSize = 4096;
   static constexpr size_t UsableAllocSize = AllocSize - sizeof(BlockMeta);
 
-  alignas(std::max_align_t) char InitialBuffer[AllocSize];
+  alignas(max_align_t) char InitialBuffer[AllocSize];
   BlockMeta* BlockList = nullptr;
 
   void grow() {


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


[PATCH] D48849: [Driver][Darwin] Use Host Triple to infer target os version

2018-07-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 153836.
steven_wu added a comment.

It is easier and cleaner if I just fold everything into getOSVersion.


Repository:
  rC Clang

https://reviews.llvm.org/D48849

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/clang-g-opts.c
  test/Driver/target-triple-deployment.c


Index: test/Driver/target-triple-deployment.c
===
--- test/Driver/target-triple-deployment.c
+++ test/Driver/target-triple-deployment.c
@@ -1,5 +1,5 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
 // RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
 // RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
 //
Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1472,10 +1472,16 @@
 std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
  const Driver &TheDriver) {
   unsigned Major, Minor, Micro;
+  llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
   switch (OS) {
   case llvm::Triple::Darwin:
   case llvm::Triple::MacOSX:
-if (!Triple.getMacOSXVersion(Major, Minor, Micro))
+// If there is no version specified on triple, and both host and target are
+// macos, use the host triple to infer OS version.
+if (Triple.isMacOSX() && SystemTriple.isMacOSX() &&
+!Triple.getOSMajorVersion())
+  SystemTriple.getMacOSXVersion(Major, Minor, Micro);
+else if (!Triple.getMacOSXVersion(Major, Minor, Micro))
   TheDriver.Diag(diag::err_drv_invalid_darwin_version)
   << Triple.getOSName();
 break;


Index: test/Driver/target-triple-deployment.c
===
--- test/Driver/target-triple-deployment.c
+++ test/Driver/target-triple-deployment.c
@@ -1,5 +1,5 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
 // RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
 // RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
 //
Index: test/Driver/clang-g-opts.c
===
--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -21,7 +21,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1472,10 +1472,16 @@
 std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
   

  1   2   >