Re: [PATCH] D71414: [clangd] Introduce codeblocks

2019-12-16 Thread Yvan Roux via cfe-commits
Hi, it is still broken on AArch64 bots, logs are available here:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21251/steps/ninja%20check%201/logs/stdio

Thanks,
Yvan

On Sat, 14 Dec 2019 at 16:15, Nico Weber via Phabricator via
cfe-commits  wrote:
>
> thakis added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp:126
> +test
> +```
> +bar)md");
> 
> Older (but still supported) gccs can't handle multiline raw strings in macro 
> arguments, see e.g. 
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21230/steps/ninja%20check%201/logs/stdio
>
> I fixed this for you in 687e98d294c4f77e. It's been broken for 3 days, please 
> watch bots and your inbox after committing.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D71414/new/
>
> https://reviews.llvm.org/D71414
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D71414: [clangd] Introduce codeblocks

2019-12-16 Thread Kadir Çetinkaya via cfe-commits
I was actually watching for buildbots(sent out
6b8ff5e43b405d255259196b6a53a3b5671aa5c7 for fixing some breakages for
example) but somehow this breakage mail didn't arrive. buildbots were in
bad shape on friday it might've skipped because of that :/

Thanks for fixing this.

On Sat, Dec 14, 2019 at 4:15 PM Nico Weber via Phabricator <
revi...@reviews.llvm.org> wrote:

> thakis added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp:126
> +test
> +```
> +bar)md");
> 
> Older (but still supported) gccs can't handle multiline raw strings in
> macro arguments, see e.g.
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21230/steps/ninja%20check%201/logs/stdio
>
> I fixed this for you in 687e98d294c4f77e. It's been broken for 3 days,
> please watch bots and your inbox after committing.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D71414/new/
>
> https://reviews.llvm.org/D71414
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61549: Fix use of 'is' operator for comparison

2019-12-16 Thread Jim Lin via Phabricator via cfe-commits
Jim added a comment.

@j-carl Could you give a Python 3.8 syntax reference for this change.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61549



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


[clang-tools-extra] 0f959c8 - [clangd] Get rid of raw string literals in macro calls

2019-12-16 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2019-12-16T09:17:36+01:00
New Revision: 0f959c87cc7867beb67bfab2d5e3cf90708b2f98

URL: 
https://github.com/llvm/llvm-project/commit/0f959c87cc7867beb67bfab2d5e3cf90708b2f98
DIFF: 
https://github.com/llvm/llvm-project/commit/0f959c87cc7867beb67bfab2d5e3cf90708b2f98.diff

LOG: [clangd] Get rid of raw string literals in macro calls

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FormattedStringTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp 
b/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
index 89ffab6aac0c..06f43d390349 100644
--- a/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -102,8 +102,8 @@ TEST(Paragraph, ExtraSpaces) {
   Paragraph P;
   P.appendText("foo\n   \t   baz");
   P.appendCode(" bar\n");
-  EXPECT_EQ(P.asMarkdown(), R"md(foo baz `bar`)md");
-  EXPECT_EQ(P.asPlainText(), R"pt(foo baz bar)pt");
+  EXPECT_EQ(P.asMarkdown(), "foo baz `bar`");
+  EXPECT_EQ(P.asPlainText(), "foo baz bar");
 }
 
 TEST(Paragraph, NewLines) {
@@ -111,8 +111,8 @@ TEST(Paragraph, NewLines) {
   Paragraph P;
   P.appendText(" \n foo\nbar\n ");
   P.appendCode(" \n foo\nbar \n ");
-  EXPECT_EQ(P.asMarkdown(), R"md(foo bar `foo bar`)md");
-  EXPECT_EQ(P.asPlainText(), R"pt(foo bar foo bar)pt");
+  EXPECT_EQ(P.asMarkdown(), "foo bar `foo bar`");
+  EXPECT_EQ(P.asPlainText(), "foo bar foo bar");
 }
 
 TEST(Document, Separators) {
@@ -149,32 +149,41 @@ TEST(CodeBlock, Render) {
   Document D;
   // Code blocks preserves any extra spaces.
   D.addCodeBlock("foo\n  bar\n  baz");
-  EXPECT_EQ(D.asMarkdown(), R"md(```cpp
+
+  llvm::StringRef ExpectedMarkdown =
+  R"md(```cpp
 foo
   bar
   baz
-```)md");
-  EXPECT_EQ(D.asPlainText(), R"pt(foo
+```)md";
+  llvm::StringRef ExpectedPlainText =
+  R"pt(foo
   bar
-  baz)pt");
+  baz)pt";
+  EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
+  EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
   D.addCodeBlock("foo");
-  EXPECT_EQ(D.asMarkdown(), R"md(```cpp
+  ExpectedMarkdown =
+  R"md(```cpp
 foo
   bar
   baz
 ```
 ```cpp
 foo
-```)md");
+```)md";
+  EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
   // FIXME: we shouldn't have 2 empty lines in between. A solution might be
   // having a `verticalMargin` method for blocks, and let container insert new
   // lines according to that before/after blocks.
-  EXPECT_EQ(D.asPlainText(), R"pt(foo
+  ExpectedPlainText =
+  R"pt(foo
   bar
   baz
 
 
-foo)pt");
+foo)pt";
+  EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
 
 } // namespace



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


Re: [PATCH] D71414: [clangd] Introduce codeblocks

2019-12-16 Thread Kadir Çetinkaya via cfe-commits
sent out 0f959c87cc7867beb67bfab2d5e3cf90708b2f98

On Mon, Dec 16, 2019 at 9:08 AM Yvan Roux  wrote:

> Hi, it is still broken on AArch64 bots, logs are available here:
>
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21251/steps/ninja%20check%201/logs/stdio
>
> Thanks,
> Yvan
>
> On Sat, 14 Dec 2019 at 16:15, Nico Weber via Phabricator via
> cfe-commits  wrote:
> >
> > thakis added inline comments.
> >
> >
> > 
> > Comment at:
> clang-tools-extra/clangd/unittests/FormattedStringTests.cpp:126
> > +test
> > +```
> > +bar)md");
> > 
> > Older (but still supported) gccs can't handle multiline raw strings in
> macro arguments, see e.g.
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21230/steps/ninja%20check%201/logs/stdio
> >
> > I fixed this for you in 687e98d294c4f77e. It's been broken for 3 days,
> please watch bots and your inbox after committing.
> >
> >
> > Repository:
> >   rG LLVM Github Monorepo
> >
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D71414/new/
> >
> > https://reviews.llvm.org/D71414
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71201: [ObjC][DWARF] Emit DW_AT_APPLE_objc_direct for methods marked as __attribute__((objc_direct))

2019-12-16 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 233998.
teemperor added a comment.

- Further reduced test case.


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

https://reviews.llvm.org/D71201

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenObjC/debug-info-direct-method.m
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/X86/objc_direct.ll

Index: llvm/test/DebugInfo/X86/objc_direct.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/objc_direct.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v %t | FileCheck %s
+
+; Source code to regenerate:
+; __attribute__((objc_root_class))
+; @interface Root
+; - (int)direct_method __attribute__((objc_direct));
+; @end
+;
+; @implementation Root
+; - (int)direct_method __attribute__((objc_direct)) {
+;   return 42;
+; }
+; @end
+;
+; clang -O0 -g -gdwarf-5 direct.m -c
+
+; CHECK: DW_TAG_subprogram [3]
+; CHECK: DW_AT_APPLE_objc_direct
+; CHECK-SAME: DW_FORM_flag_present
+; CHECK: DW_TAG_formal_parameter [4]
+
+; ModuleID = 'direct.bc'
+source_filename = "direct.m"
+
+%0 = type opaque
+
+define hidden i32 @"\01-[Root direct_method]"(%0* %self, i8* %_cmd) {
+entry:
+  %retval = alloca i32, align 4
+  %0 = load i32, i32* %retval, align 4
+  ret i32 %0
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!19, !20}
+!llvm.ident = !{}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project d6b2f33e2b6338d24cf756ba220939aecc81210d)", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
+!1 = !DIFile(filename: "direct.m", directory: "/", checksumkind: CSK_MD5, checksum: "6b49fad130344b0011fc0eef65949390")
+!2 = !{}
+!3 = !{!4}
+!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "Root", scope: !1, file: !1, line: 2, flags: DIFlagObjcClassComplete, elements: !5, runtimeLang: DW_LANG_ObjC)
+!5 = !{!6}
+!6 = !DISubprogram(name: "-[Root direct_method]", scope: !4, file: !1, line: 7, type: !7, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagObjCDirect, retainedNodes: !2)
+!7 = !DISubroutineType(types: !8)
+!8 = !{!9, !10, !11}
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "SEL", file: !1, baseType: !12, flags: DIFlagArtificial)
+!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
+!13 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_selector", file: !1, flags: DIFlagFwdDecl)
+!19 = !{i32 7, !"Dwarf Version", i32 5}
+!20 = !{i32 2, !"Debug Info Version", i32 3}
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1233,6 +1233,9 @@
Language == dwarf::DW_LANG_ObjC))
 addFlag(SPDie, dwarf::DW_AT_prototyped);
 
+  if (SP->isObjCDirect())
+addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
+
   unsigned CC = 0;
   DITypeRefArray Args;
   if (const DISubroutineType *SPTy = SP->getType()) {
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1758,6 +1758,7 @@
   bool isPure() const { return getSPFlags() & SPFlagPure; }
   bool isElemental() const { return getSPFlags() & SPFlagElemental; }
   bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
+  bool isObjCDirect() const { return getSPFlags() & SPFlagObjCDirect; }
 
   /// Check if this is deleted member function.
   ///
Index: llvm/include/llvm/IR/DebugInfoFlags.def
===
--- llvm/include/llvm/IR/DebugInfoFlags.def
+++ llvm/include/llvm/IR/DebugInfoFlags.def
@@ -90,11 +90,12 @@
 // May also utilize this Flag in future, when adding support
 // for defaulted functions
 HANDLE_DISP_FLAG((1u << 9), Deleted)
+HANDLE_DISP_FLAG((1u << 11), ObjCDirect)
 
 #ifdef DISP_FLAG_LARGEST_NEEDED
 // Intended to be used with ADT/BitmaskEnum.h.
 // NOTE: Always must be equal to largest flag, check this when adding new flags.
-HANDLE_DISP_FLAG((1 << 9), Largest)
+HANDLE_DISP_FLAG((1 << 11), Largest)
 #undef DISP_FLAG_LARGEST_NEEDED
 #endif
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -421,6 +421,7 @@
 HANDLE_DW_AT(0x3feb, APPLE_property_attribute, 0, APPLE)
 HANDLE_DW

[PATCH] D71533: [clangd] Show template arguments in type hierarchy when possible

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a reviewer: kadircet.
kadircet added a comment.

I think this requires changes in other places too, for example when querying 
index for the children we rather want to query using the symbolid of template 
pattern, not the instantiation.




Comment at: clang-tools-extra/clangd/XRefs.cpp:682
   DeclRelationSet Relations =
-  DeclRelation::TemplatePattern | DeclRelation::Underlying;
+  DeclRelation::TemplateInstantiation | DeclRelation::Underlying;
   auto Decls = getDeclAtPosition(AST, SourceLocationBeg, Relations);

instead of doing the traversal twice, can we just sent both pattern and 
instantiation here, and then prefer the `specializationdecl` instead of just 
selecting `decls[0]` below ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71533



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-16 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.

In D70157#1768338 , @annita.zhang 
wrote:

> In D70157#1768319 , @chandlerc wrote:
>
> > I'm seeing lots of updates to fix bugs, but no movement for many days on 
> > both my meta comments and (in some ways more importantly) James's meta 
> > comments. (And thanks Philip for chiming in too!)
> >
> > Meanwhile, we really, really need to get this functionality in place. The 
> > entire story for minimizing the new microcode performance hit hinges on 
> > these patches, and I'm really worried by how little progress we're seeing 
> > here.
>
>
> Sorry for belated response. We're working hard to go through some paper work 
> to get the performance data ready. I think maybe it's better to open a 
> mailing thread in llvm-dev to post those performance data and discuss those 
> suggestions.
>
> The first data was posted in 
> http://lists.llvm.org/pipermail/llvm-dev/2019-December/137413.html.
>
> Thanks,
> Annita


More performance data was posted on 
http://lists.llvm.org/pipermail/llvm-dev/2019-December/137609.html and 
http://lists.llvm.org/pipermail/llvm-dev/2019-December/137610.html. Let's move 
on based on the data.


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

https://reviews.llvm.org/D70157



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


[PATCH] D71455: [NFC] Fix typos in Clangd and Clang

2019-12-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 234001.
kbobyrev added a comment.

Rebase on top of master, fix the build and apply formatting.


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

https://reviews.llvm.org/D71455

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/Transport.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang/include/clang/Index/IndexDataConsumer.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/tools/c-index-test/core_main.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/tools/libclang/CXIndexDataConsumer.h
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -74,9 +74,9 @@
 IndexDataConsumer::initialize(Ctx);
   }
 
-  bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
-   ArrayRef, SourceLocation Loc,
-   ASTNodeInfo) override {
+  bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
+ArrayRef, SourceLocation Loc,
+ASTNodeInfo) override {
 const auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return true;
@@ -91,8 +91,8 @@
 return true;
   }
 
-  bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI,
-SymbolRoleSet Roles, SourceLocation Loc) override {
+  bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI,
+ SymbolRoleSet Roles, SourceLocation Loc) override {
 TestSymbol S;
 S.SymInfo = getSymbolInfoForMacro(*MI);
 S.QName = Name->getName();
Index: clang/tools/libclang/CXIndexDataConsumer.h
===
--- clang/tools/libclang/CXIndexDataConsumer.h
+++ clang/tools/libclang/CXIndexDataConsumer.h
@@ -431,13 +431,13 @@
   static bool isTemplateImplicitInstantiation(const Decl *D);
 
 private:
-  bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-   ArrayRef Relations,
-   SourceLocation Loc, ASTNodeInfo ASTNode) override;
+  bool handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
+ArrayRef Relations,
+SourceLocation Loc, ASTNodeInfo ASTNode) override;
 
-  bool handleModuleOccurence(const ImportDecl *ImportD, const Module *Mod,
- index::SymbolRoleSet Roles,
- SourceLocation Loc) override;
+  bool handleModuleOccurrence(const ImportDecl *ImportD, const Module *Mod,
+  index::SymbolRoleSet Roles,
+  SourceLocation Loc) override;
 
   void finish() override;
 
Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -154,7 +154,7 @@
 }
 }
 
-bool CXIndexDataConsumer::handleDeclOccurence(
+bool CXIndexDataConsumer::handleDeclOccurrence(
 const Decl *D, SymbolRoleSet Roles, ArrayRef Relations,
 SourceLocation Loc, ASTNodeInfo ASTNode) {
   Loc = getASTContext().getSourceManager().getFileLoc(Loc);
@@ -220,10 +220,10 @@
   return !shouldAbort();
 }
 
-bool CXIndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD,
-const Module *Mod,
-SymbolRoleSet Roles,
-SourceLocation Loc) {
+bool CXIndexDataConsumer::handleModuleOccurrence(const ImportDecl *ImportD,
+ const Module *Mod,
+ SymbolRoleSet Roles,
+ SourceLocation Loc) {
   if (Roles & (SymbolRoleSet)SymbolRole::Declaration)
 IndexingDeclVisitor(*this, SourceLocation(), nullptr).Visit(ImportD);
   return !shouldAbort();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -94,9 +94,9 @@
 this->PP = std::move(PP);
   }
 
-  bool handleDeclOc

[PATCH] D70527: [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths

2019-12-16 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70527



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


[PATCH] D66839: Fix stack address builtin for negative numbers

2019-12-16 Thread Jim Lin via Phabricator via cfe-commits
Jim added a comment.

I think this checking should be implemented in lib/Sema/SemaChecking.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66839



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


[PATCH] D71455: [NFC] Fix typos in Clangd and Clang

2019-12-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b9715cb2193: [NFC] Fix typos in Clangd and Clang (authored 
by kbobyrev).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71455

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/Transport.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang/include/clang/Index/IndexDataConsumer.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/tools/c-index-test/core_main.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/tools/libclang/CXIndexDataConsumer.h
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -74,9 +74,9 @@
 IndexDataConsumer::initialize(Ctx);
   }
 
-  bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
-   ArrayRef, SourceLocation Loc,
-   ASTNodeInfo) override {
+  bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
+ArrayRef, SourceLocation Loc,
+ASTNodeInfo) override {
 const auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return true;
@@ -91,8 +91,8 @@
 return true;
   }
 
-  bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI,
-SymbolRoleSet Roles, SourceLocation Loc) override {
+  bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI,
+ SymbolRoleSet Roles, SourceLocation Loc) override {
 TestSymbol S;
 S.SymInfo = getSymbolInfoForMacro(*MI);
 S.QName = Name->getName();
Index: clang/tools/libclang/CXIndexDataConsumer.h
===
--- clang/tools/libclang/CXIndexDataConsumer.h
+++ clang/tools/libclang/CXIndexDataConsumer.h
@@ -431,13 +431,13 @@
   static bool isTemplateImplicitInstantiation(const Decl *D);
 
 private:
-  bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
-   ArrayRef Relations,
-   SourceLocation Loc, ASTNodeInfo ASTNode) override;
+  bool handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
+ArrayRef Relations,
+SourceLocation Loc, ASTNodeInfo ASTNode) override;
 
-  bool handleModuleOccurence(const ImportDecl *ImportD, const Module *Mod,
- index::SymbolRoleSet Roles,
- SourceLocation Loc) override;
+  bool handleModuleOccurrence(const ImportDecl *ImportD, const Module *Mod,
+  index::SymbolRoleSet Roles,
+  SourceLocation Loc) override;
 
   void finish() override;
 
Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -154,7 +154,7 @@
 }
 }
 
-bool CXIndexDataConsumer::handleDeclOccurence(
+bool CXIndexDataConsumer::handleDeclOccurrence(
 const Decl *D, SymbolRoleSet Roles, ArrayRef Relations,
 SourceLocation Loc, ASTNodeInfo ASTNode) {
   Loc = getASTContext().getSourceManager().getFileLoc(Loc);
@@ -220,10 +220,10 @@
   return !shouldAbort();
 }
 
-bool CXIndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD,
-const Module *Mod,
-SymbolRoleSet Roles,
-SourceLocation Loc) {
+bool CXIndexDataConsumer::handleModuleOccurrence(const ImportDecl *ImportD,
+ const Module *Mod,
+ SymbolRoleSet Roles,
+ SourceLocation Loc) {
   if (Roles & (SymbolRoleSet)SymbolRole::Declaration)
 IndexingDeclVisitor(*this, SourceLocation(), nullptr).Visit(ImportD);
   return !shouldAbort();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c

Re: [PATCH] D71414: [clangd] Introduce codeblocks

2019-12-16 Thread Yvan Roux via cfe-commits
Thanks Kadir, bots are back to green :)

On Mon, 16 Dec 2019 at 09:18, Kadir Çetinkaya  wrote:
>
> sent out 0f959c87cc7867beb67bfab2d5e3cf90708b2f98
>
> On Mon, Dec 16, 2019 at 9:08 AM Yvan Roux  wrote:
>>
>> Hi, it is still broken on AArch64 bots, logs are available here:
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21251/steps/ninja%20check%201/logs/stdio
>>
>> Thanks,
>> Yvan
>>
>> On Sat, 14 Dec 2019 at 16:15, Nico Weber via Phabricator via
>> cfe-commits  wrote:
>> >
>> > thakis added inline comments.
>> >
>> >
>> > 
>> > Comment at: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp:126
>> > +test
>> > +```
>> > +bar)md");
>> > 
>> > Older (but still supported) gccs can't handle multiline raw strings in 
>> > macro arguments, see e.g. 
>> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/21230/steps/ninja%20check%201/logs/stdio
>> >
>> > I fixed this for you in 687e98d294c4f77e. It's been broken for 3 days, 
>> > please watch bots and your inbox after committing.
>> >
>> >
>> > Repository:
>> >   rG LLVM Github Monorepo
>> >
>> > CHANGES SINCE LAST ACTION
>> >   https://reviews.llvm.org/D71414/new/
>> >
>> > https://reviews.llvm.org/D71414
>> >
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 3b9715c - [NFC] Fix typos in Clangd and Clang

2019-12-16 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2019-12-16T10:54:40+01:00
New Revision: 3b9715cb219352fb831af144fd68e14e8fd275b4

URL: 
https://github.com/llvm/llvm-project/commit/3b9715cb219352fb831af144fd68e14e8fd275b4
DIFF: 
https://github.com/llvm/llvm-project/commit/3b9715cb219352fb831af144fd68e14e8fd275b4.diff

LOG: [NFC] Fix typos in Clangd and Clang

Reviewed by: Jim

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FormattedString.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/Transport.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/refactor/Rename.cpp
clang/include/clang/Index/IndexDataConsumer.h
clang/lib/Index/IndexingAction.cpp
clang/lib/Index/IndexingContext.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/libclang/CXIndexDataConsumer.cpp
clang/tools/libclang/CXIndexDataConsumer.h
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 65fdecc9e1ae..6aa02a7454dc 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -377,7 +377,7 @@ class DeducedTypeVisitor : public 
RecursiveASTVisitor {
 // 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).
+// Loc of "auto" in function with trailing return type (c++11).
 if (CurLoc.isInvalid())
   CurLoc = D->getSourceRange().getBegin();
 if (CurLoc != SearchedLocation)

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index a858680d4067..c71a8a0d566b 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -466,7 +466,7 @@ void ClangdServer::locateSymbolAt(PathRef File, Position 
Pos,
 
 void ClangdServer::switchSourceHeader(
 PathRef Path, Callback> CB) {
-  // We want to return the result as fast as possible, stragety is:
+  // We want to return the result as fast as possible, strategy is:
   //  1) use the file-only heuristic, it requires some IO but it is much
   // faster than building AST, but it only works when .h/.cc files are in
   // the same directory.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 4ef9842a381c..4e54b1a43e55 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -395,7 +395,7 @@ struct CodeCompletionBuilder {
 std::string ReturnType;
   };
 
-  // If all BundledEntrys have the same value for a property, return it.
+  // If all BundledEntries have the same value for a property, return it.
   template 
   const std::string *onlyValue() const {
 auto B = Bundled.begin(), E = Bundled.end();
@@ -499,7 +499,7 @@ llvm::Optional getSymbolID(const 
CodeCompletionResult &R,
   llvm_unreachable("unknown CodeCompletionResult kind");
 }
 
-// Scopes of the paritial identifier we're trying to complete.
+// Scopes of the partial identifier we're trying to complete.
 // It is used when we query the index for more completion results.
 struct SpecifiedScope {
   // The scopes we should look in, determined by Sema.
@@ -874,7 +874,7 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
   // Function Template.
   // - High score is better.
   // - Shorter signature is better.
-  // - Alphebatically smaller is better.
+  // - Alphabetically smaller is better.
   if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters)
 return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters;
   if (L.Quality.NumberOfOptionalParameters !=
@@ -1510,7 +1510,7 @@ class CodeCompleteFlow {
   }
 
   // Merges Sema and Index results where possible, to form 
CompletionCandidates.
-  // \p Identifiers is raw idenfiers that can also be completion condidates.
+  // \p Identifiers is raw idenfiers that can also be completion candidates.
   // Identifiers are not merged with results from index or sema.
   // Groups overloads if desired, to form CompletionCandidate::Bundles. The
   // bundles are scored and top results are returned, best to worst.

diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 0670de087e2f..

[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2019-12-16 Thread Jano Simas via Phabricator via cfe-commits
janosimas updated this revision to Diff 234005.
janosimas added a comment.
Herald added a subscriber: mgehre.
Herald added a project: clang.

I reviewed the code over the discussion with the `--` option,
I also changed the `-p` optin to `-strip` to avoid confusion with the 
`clang-tidy` option.

sorry for taking so long ;-)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D49864

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -17,9 +17,9 @@
 detect clang-tidy regressions in the lines touched by a specific patch.
 Example usage for git/svn users:
 
-  git diff -U0 HEAD^ | clang-tidy-diff.py -p1
+  git diff -U0 HEAD^ | clang-tidy-diff.py -strip 1 -- -fix -checks=-*,modernize-use-override
   svn diff --diff-cmd=diff -x-U0 | \
-  clang-tidy-diff.py -fix -checks=-*,modernize-use-override
+  clang-tidy-diff.py -- -fix -checks=-*,modernize-use-override
 
 """
 
@@ -118,12 +118,13 @@
   parser = argparse.ArgumentParser(description=
'Run clang-tidy against changed files, and '
'output diagnostics only for modified '
-   'lines.')
+   'lines.'
+   '\nclang-tidy arguments should be passed after a \'--\' .')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
   default='clang-tidy',
   help='path to clang-tidy binary')
-  parser.add_argument('-p', metavar='NUM', default=0,
-  help='strip the smallest prefix containing P slashes')
+  parser.add_argument('-strip', metavar='NUM', default=0,
+  help='strip the smallest prefix containing N slashes')
   parser.add_argument('-regex', metavar='PATTERN', default=None,
   help='custom pattern selecting file paths to check '
   '(case sensitive, overrides -iregex)')
@@ -135,32 +136,15 @@
   help='number of tidy instances to be run in parallel.')
   parser.add_argument('-timeout', type=int, default=None,
   help='timeout per each file in seconds.')
-  parser.add_argument('-fix', action='store_true', default=False,
-  help='apply suggested fixes')
-  parser.add_argument('-checks',
-  help='checks filter, when not specified, use clang-tidy '
-  'default',
-  default='')
-  parser.add_argument('-path', dest='build_path',
-  help='Path used to read a compile command database.')
   if yaml:
 parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
 help='Create a yaml file to store suggested fixes in, '
 'which can be applied with clang-apply-replacements.')
-  parser.add_argument('-extra-arg', dest='extra_arg',
-  action='append', default=[],
-  help='Additional argument to append to the compiler '
-  'command line.')
-  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
-  action='append', default=[],
-  help='Additional argument to prepend to the compiler '
-  'command line.')
-  parser.add_argument('-quiet', action='store_true', default=False,
-  help='Run clang-tidy in quiet mode')
+
   clang_tidy_args = []
   argv = sys.argv[1:]
   if '--' in argv:
-clang_tidy_args.extend(argv[argv.index('--'):])
+clang_tidy_args.extend(argv[argv.index('--')+1:])
 argv = argv[:argv.index('--')]
 
   args = parser.parse_args(argv)
@@ -169,7 +153,7 @@
   filename = None
   lines_by_file = {}
   for line in sys.stdin:
-match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
+match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.strip, line)
 if match:
   filename = match.group(2)
 if filename is None:
@@ -216,19 +200,6 @@
 
   # Form the common args list.
   common_clang_tidy_args = []
-  if args.fix:
-common_clang_tidy_args.append('-fix')
-  if args.checks != '':
-common_clang_tidy_args.append('-checks=' + args.checks)
-  if args.quiet:
-common_clang_tidy_args.append('-quiet')
-  if args.build_path is not None:
-common_clang_tidy_args.append('-p=%s' % args.build_path)
-  for arg in args.extra_arg:
-common_clang_tidy_args.append('-extra-arg=%s' % arg)
-  for arg in args.extra_arg_before:
-common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
-
   for name in lines_by_file:
 line_filter_json = json.dumps(
   [{"n

[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2019-12-16 Thread Jano Simas via Phabricator via cfe-commits
janosimas added a comment.

I also noticed there is a `clang-format-diff` that also has the `-p` option, it 
would be nice to update it for consistency.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D49864



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


[PATCH] D71535: [clang][AST] Make 'getPartialSpecializations' const-qualified in DeclTemplate

2019-12-16 Thread Twice via Phabricator via cfe-commits
PragmaTwice created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I found that `ClassTemplateDecl::getSpecializations` is const-qualified, but 
`ClassTemplateDecl::getPartialSpecializations`is not, which has very similar 
implementation to the former method.
So there is a patch to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71535

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


Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -403,7 +403,7 @@
 }
 
 llvm::FoldingSetVector &
-ClassTemplateDecl::getPartialSpecializations() {
+ClassTemplateDecl::getPartialSpecializations() const {
   LoadLazySpecializations();
   return getCommonPtr()->PartialSpecializations;
 }
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2093,7 +2093,7 @@
   /// Retrieve the set of partial specializations of this class
   /// template.
   llvm::FoldingSetVector &
-  getPartialSpecializations();
+  getPartialSpecializations() const;
 
   ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
 DeclarationName Name, TemplateParameterList *Params,


Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -403,7 +403,7 @@
 }
 
 llvm::FoldingSetVector &
-ClassTemplateDecl::getPartialSpecializations() {
+ClassTemplateDecl::getPartialSpecializations() const {
   LoadLazySpecializations();
   return getCommonPtr()->PartialSpecializations;
 }
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2093,7 +2093,7 @@
   /// Retrieve the set of partial specializations of this class
   /// template.
   llvm::FoldingSetVector &
-  getPartialSpecializations();
+  getPartialSpecializations() const;
 
   ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
 DeclarationName Name, TemplateParameterList *Params,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70527: [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths

2019-12-16 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added a comment.

Personally, I would prefer to see the file name and path to be changed as 
little as possible because that would help to recognize the files better. We 
cannot use `remove_dots()` on POSIX OSes to simplify paths, because it may 
return an invalid path; thus we have to use `getRealPath()`. If I understand it 
right, there is no similar problem with the file name itself.

So, which issues this patch is going to solve?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70527



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-12-16 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill marked an inline comment as done.
lewis-revill added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:667
+.addExternalSymbol(SpillLibCall, RISCVII::MO_CALL)
+.setMIFlag(MachineInstr::FrameSetup);
+

shiva0217 wrote:
> There is a case may trigger an assertion when compile with -O3 -g 
> -msave-restore if the libcall has FrameSetup flag.
>   int main(int a, char* argv[]) {
> exit(0);
> return 0;
>   }
Think I've found the cause of this. When 'DIFlagAllCallsDescribed' is set for 
the module LLVM attempts to provide call entry info DIEs for all calls, 
//including// this one that has been added by us. One detail of this is 
attempting to calculate the return PC value or offset for the call using a 
label that was assumed to be inserted after the call instruction.

However, while the attempt to add the call entry info doesn't check for the 
FrameSetup flag, the label was never inserted, since that code //does// check 
for the flag. Adding the missing check to avoid adding call entry info for 
calls marked as FrameSetup fixed this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14323
+Result = Builder.CreateIntrinsic(
+Intrinsic::ptrmask, {Args.SrcType, SrcForMask->getType(), 
Args.IntType},
+{SrcForMask, NegatedMask}, nullptr, "aligned_result");

lebedev.ri wrote:
> arichardson wrote:
> > lebedev.ri wrote:
> > > Is sufficient amount of passes, analyses know about this intrinsic?
> > Good question. In the simple test cases that I looked at the code 
> > generation was equivalent. 
> > 
> > In our fork we still use ptrtoint+inttoptr since I implemented them before 
> > the new intrinsic existed. But since the ptrmask instrinsic exists now I 
> > thought I'd use it for upstreaming.
> > I'll investigate if this results in worse codegen for more complex uses.
> > 
> (TLDR: before producing it in more cases in clang, i think it should be first 
> ensured
> that everything in middle-end is fully aware of said intrinsic. (i.e. using 
> it vs it's
> exploded form results in no differences in final assembly on a sufficient 
> test coverage))
> I'll investigate if this results in worse codegen for more complex uses.

The findings would be interesting indeed. 

One thing to watch out for is that ptrmask should give better alias analysis 
results than ptrtoint/inttoptr. Also, IIRC some instcombine transformations for 
ptrtoint/inttoptr are not strictly valid according to the LangRef. Not sure if 
that changed yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-16 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D68362



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


[PATCH] D71541: [Clang]: fix spelling mistake in assert message

2019-12-16 Thread Kiva via Phabricator via cfe-commits
imkiva created this revision.
imkiva added reviewers: clang, pcc.
imkiva added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D71541

Files:
  lib/AST/VTableBuilder.cpp


Index: lib/AST/VTableBuilder.cpp
===
--- lib/AST/VTableBuilder.cpp
+++ lib/AST/VTableBuilder.cpp
@@ -487,7 +487,7 @@
 bool VCallOffsetMap::MethodsCanShareVCallOffset(const CXXMethodDecl *LHS,
 const CXXMethodDecl *RHS) {
   assert(LHS->isVirtual() && "LHS must be virtual!");
-  assert(RHS->isVirtual() && "LHS must be virtual!");
+  assert(RHS->isVirtual() && "RHS must be virtual!");
 
   // A destructor can share a vcall offset with another destructor.
   if (isa(LHS))


Index: lib/AST/VTableBuilder.cpp
===
--- lib/AST/VTableBuilder.cpp
+++ lib/AST/VTableBuilder.cpp
@@ -487,7 +487,7 @@
 bool VCallOffsetMap::MethodsCanShareVCallOffset(const CXXMethodDecl *LHS,
 const CXXMethodDecl *RHS) {
   assert(LHS->isVirtual() && "LHS must be virtual!");
-  assert(RHS->isVirtual() && "LHS must be virtual!");
+  assert(RHS->isVirtual() && "RHS must be virtual!");
 
   // A destructor can share a vcall offset with another destructor.
   if (isa(LHS))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread David Chisnall via Phabricator via cfe-commits
theraven added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14323
+Result = Builder.CreateIntrinsic(
+Intrinsic::ptrmask, {Args.SrcType, SrcForMask->getType(), 
Args.IntType},
+{SrcForMask, NegatedMask}, nullptr, "aligned_result");

fhahn wrote:
> lebedev.ri wrote:
> > arichardson wrote:
> > > lebedev.ri wrote:
> > > > Is sufficient amount of passes, analyses know about this intrinsic?
> > > Good question. In the simple test cases that I looked at the code 
> > > generation was equivalent. 
> > > 
> > > In our fork we still use ptrtoint+inttoptr since I implemented them 
> > > before the new intrinsic existed. But since the ptrmask instrinsic exists 
> > > now I thought I'd use it for upstreaming.
> > > I'll investigate if this results in worse codegen for more complex uses.
> > > 
> > (TLDR: before producing it in more cases in clang, i think it should be 
> > first ensured
> > that everything in middle-end is fully aware of said intrinsic. (i.e. using 
> > it vs it's
> > exploded form results in no differences in final assembly on a sufficient 
> > test coverage))
> > I'll investigate if this results in worse codegen for more complex uses.
> 
> The findings would be interesting indeed. 
> 
> One thing to watch out for is that ptrmask should give better alias analysis 
> results than ptrtoint/inttoptr. Also, IIRC some instcombine transformations 
> for ptrtoint/inttoptr are not strictly valid according to the LangRef. Not 
> sure if that changed yet.
There is currently an open review on the semantics of inttoptr / ptrtoint.  The 
current LangRef underspecifies it.  On most architectures, both are bitcasts.  
On CHERI (including ARM's Morello system), it is not safe to round trip a 
pointer via an integer at the IR or machine-code level (in C, `[u]intptr_t` is 
represented as `i8*` in the IR).  A few architectures do some arithmetic to 
cast between pointer and integer.  The mid-level optimisers are slowly getting 
better at avoiding the patterns that rely on the underspecified behaviour, but 
removing this need for them would be a benefit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D71387: pass -mabi to LTO linker only in RISC-V targets, enable RISC-V LTO

2019-12-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

Nice! I think this is the correct way of implementing this, and I don't think 
it will have any issue with other backends.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71387



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


[PATCH] D71542: [coroutines][PR41909] don't build dependent coroutine statements if the coroutine still has a dependent promise type

2019-12-16 Thread Philippe Daouadi via Phabricator via cfe-commits
blastrock created this revision.
blastrock added reviewers: GorNishanov, EricWF, lewissbaker, tks2103, 
modocache, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
blastrock edited the summary of this revision.

This started with bug https://bugs.llvm.org/show_bug.cgi?id=41909 which was 
fixed by https://reviews.llvm.org/D62550 . In the last comment of the bug 
report , Pavel A. Lebedev gives 
a code snippet that now makes clang trigger an ICE. This code was broken by 
that very commit.

I am no expert, but I tried to follow this comment 
. We now build the dependent 
statements only if the promise type is not dependent anymore. If it still is, I 
guess dependent statements are built in a later pass when all templates are 
instantiated.

I have added the second code snippet from the bug and the godbolt snippet from 
modocache's answer on the review, this patch seems to fix them all.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71542

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/coroutines.cpp


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -734,6 +734,26 @@
 }
 template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in 
instantiation of function template specialization 
'ok_generic_lambda_coawait_PR41909' requested here}}
 
+void ok_generic_lambda_coawait_PR41909_2() {
+  [](auto &arg) -> coro { // expected-warning {{expression 
result unused}}
+co_await 12;
+  };
+  [](auto &arg) -> coro {
+co_await 24;
+  }("argument");
+}
+
+template 
+void ok_generic_lambda_coawait_PR41909_3() {
+  [](auto &arg) -> coro { // expected-warning {{expression 
result unused}}
+[]() -> coro {
+  co_await 12;
+};
+co_await 24;
+  };
+}
+template void ok_generic_lambda_coawait_PR41909_3(); // expected-note 
{{in instantiation of function template specialization 
'ok_generic_lambda_coawait_PR41909_3' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -7229,16 +7229,7 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-// PR41909: We may find a generic coroutine lambda definition within a
-// template function that is being instantiated. In this case, the lambda
-// will have a dependent promise type, until it is used in an expression
-// that creates an instantiation with a non-dependent promise type. We
-// should not assert or build coroutine dependent statements for such a
-// generic lambda.
-auto *MD = dyn_cast_or_null(FD);
-if (!MD || !MD->getParent()->isGenericLambda()) {
-  assert(!Promise->getType()->isDependentType() &&
- "the promise type must no longer be dependent");
+if (!Promise->getType()->isDependentType()) {
   assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
  !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
  "these nodes should not have been built yet");


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -734,6 +734,26 @@
 }
 template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909' requested here}}
 
+void ok_generic_lambda_coawait_PR41909_2() {
+  [](auto &arg) -> coro { // expected-warning {{expression result unused}}
+co_await 12;
+  };
+  [](auto &arg) -> coro {
+co_await 24;
+  }("argument");
+}
+
+template 
+void ok_generic_lambda_coawait_PR41909_3() {
+  [](auto &arg) -> coro { // expected-warning {{expression result unused}}
+[]() -> coro {
+  co_await 12;
+};
+co_await 24;
+  };
+}
+template void ok_generic_lambda_coawait_PR41909_3(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909_3' requested here}}
+
 template<> struct std::experimental::coroutine_traits
 { using promise_type = promise; };
 
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -7229,16 +7229,7 @@
   Builder.ReturnValue = Res.get();
 
   if (S->hasDependentPromiseType()) {
-// PR41909: We may find a generic coroutine lambda definition within a
-// template function that is being instantiated. In this case, the lambda
-// will have a dependent promise type, until it is used in

[PATCH] D71543: [clangd] Fix handling of inline and anon namespaces in hover

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Clangd normally skips printing of inline and anon namespaces while
printing nested name specifiers.

There was a bug causing us to print innermost inline/anon namespace, this patch
fixes that by skipping those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71543

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -104,7 +104,7 @@
   }}
   )cpp",
[](HoverInfo &HI) {
- HI.NamespaceScope = "ns1::(anonymous)::";
+ HI.NamespaceScope = "ns1::";
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
@@ -362,7 +362,8 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class (lambda)";
+ // FIXME: Special case lambdas.
+ HI.Name = "(anonymous class)";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on template instantiation
@@ -373,7 +374,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on specialized template
@@ -385,7 +386,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
 
@@ -524,6 +525,25 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "boom::";
}},
+  {
+  R"cpp(// Should not print inline or anon namespaces.
+  namespace ns {
+inline namespace in_ns {
+  namespace {
+inline namespace in_ns2 {
+  class Foo {};
+} // in_ns2
+  } // anon
+} // in_ns
+  } // ns
+  void foo() {
+[[au^to]] x = ns::Foo();
+  }
+  )cpp",
+  [](HoverInfo &HI) {
+HI.Name = "Foo";
+HI.Kind = index::SymbolKind::Class;
+  }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -895,7 +915,7 @@
   [](HoverInfo &HI) {
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Variable;
-HI.NamespaceScope = "ns::(anonymous)::";
+HI.NamespaceScope = "ns::";
 HI.Type = "int";
 HI.Definition = "int foo";
   }},
@@ -1173,7 +1193,8 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "class std::initializer_list";
+// FIXME: Print template instantiation parameters.
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;
   }},
   {
@@ -1231,7 +1252,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1242,7 +1263,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1253,7 +1274,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1265,7 +1286,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1277,7 +1298,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1289,7 +1310,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1300,7 +1321,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1364,7 +1385,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
 

[PATCH] D71529: [Sema] Fixes -Wrange-loop-analysis warnings

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71529



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


[PATCH] D71544: [clangd] Improve printing of lambda names

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Clangd was printing lambdas as `(anonymous class)` before, we can
improve it by at least printing `(lambda)` instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71544

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -362,8 +362,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- // FIXME: Special case lambdas.
- HI.Name = "(anonymous class)";
+ HI.Name = "(lambda)";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on template instantiation
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -223,8 +223,11 @@
 // Come up with a presentation for an anonymous entity.
 if (isa(ND))
   return "(anonymous namespace)";
-if (auto *Cls = llvm::dyn_cast(&ND))
+if (auto *Cls = llvm::dyn_cast(&ND)) {
+  if (Cls->isLambda())
+return "(lambda)";
   return ("(anonymous " + Cls->getKindName() + ")").str();
+}
 if (isa(ND))
   return "(anonymous enum)";
 return "(anonymous)";


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -362,8 +362,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- // FIXME: Special case lambdas.
- HI.Name = "(anonymous class)";
+ HI.Name = "(lambda)";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on template instantiation
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -223,8 +223,11 @@
 // Come up with a presentation for an anonymous entity.
 if (isa(ND))
   return "(anonymous namespace)";
-if (auto *Cls = llvm::dyn_cast(&ND))
+if (auto *Cls = llvm::dyn_cast(&ND)) {
+  if (Cls->isLambda())
+return "(lambda)";
   return ("(anonymous " + Cls->getKindName() + ")").str();
+}
 if (isa(ND))
   return "(anonymous enum)";
 return "(anonymous)";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71543: [clangd] Fix handling of inline/anon namespaces and names of deduced types in hover

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60932 tests passed, 0 failed 
and 726 were skipped.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71543



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Do we have a similar problem if the filespec has an embedded ./ or ../ in it?  
I'm thinking some broader canonicalization ought to be done here.
$ clang ./dir1/dir2/../dir3/file.c
should resolve to dir1/dir3/file.c shouldn't it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D71406: [clangd] Add xref for macros to FileIndex.

2019-12-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/URI.h:115
+// the SourceManager.
+URI toURI(llvm::StringRef Path, const SourceManager &SM,
+  const std::string &FallbackDir);

This function does a very specialized form of path-to-uri conversion (fallback 
dirs, traversing schemes, etc.)
I'm afraid that naming it `toURI` will mean everyone will find and use it 
without giving it too much thought.

Another concern is layering. `URI.h` currently does not depend on 
`SourceManager` and, arguably, it should stay that way. We define an interface 
to extend the URI schemes that clangd supports, there's no reason for it to 
depend on `SourceManager`.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:86
+// Add macro references.
+for (const auto &IDToRefs : MacroRefsToIndex->MacroRefs) {
+  for (const auto &Range : IDToRefs.second) {

This is trying to emulate existing logic in `SymbolCollector::finish`. Is there 
a way we could share this?
Would avoid creating extra copies of reference slabs and allow to keep the code 
in one place, rather than scattering it between `FileIndex.cpp` and 
`SymbolCollector.cpp`. Would also allow to keep `toURI` private, meaning we 
don't have to worry about naming it and the fact it's exposed in the public 
interface.

One potential way to do this is to have an alternative version of 
`handleMacroOccurence`, which would fill `SymbolCollector::MacroRefs` directly 
and call this right after `indexTopLevelDecls`.
Would that work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71406



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


[PATCH] D71544: [clangd] Improve printing of lambda names

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60959 tests passed, 0 failed 
and 726 were skipped.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71544



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


[PATCH] D71543: [clangd] Fix handling of inline/anon namespaces and names of deduced types in hover

2019-12-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

My biggest concern is that we seem to make output for template instantiation 
worse.
There should be a way to stop showing anonymous namespace without introducing 
such regressions.




Comment at: clang-tools-extra/clangd/Hover.cpp:353
 /// Generate a \p Hover object given the type \p T.
 HoverInfo getHoverContents(QualType T, const Decl *D, ASTContext &ASTCtx,
+   const SymbolIndex *Index) {

Not related to this patch, but what is `D` here? Is this getting hover contents 
for a type or for a decl?



Comment at: clang-tools-extra/clangd/Hover.cpp:356
   HoverInfo HI;
-  llvm::raw_string_ostream OS(HI.Name);
-  PrintingPolicy Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
-  T.print(OS, Policy);
-  OS.flush();
-
-  if (D) {
+  auto FillInHover = [&HI, Index, &ASTCtx](const Decl *D) {
+if (const auto *ND = llvm::dyn_cast(D))

NIT: could be simplified to
```
if (!D)
  D = T->getAsTagDecl();
if (!D)
  return HI;

// ... body of FillInHover goes here
```



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:365
[](HoverInfo &HI) {
- HI.Name = "class (lambda)";
+ // FIXME: Special case lambdas.
+ HI.Name = "(anonymous class)";

NIT: could you give an example how you want the output to look like?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:377
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;

`Foo` actually looked better. Do you consider this a regression or is this 
intended?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:389
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;

Why does this give different output from the previous example?
I would argue they should both be consistent. Users shouldn't care if there's 
an explicit specialization or not.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:533
+  namespace {
+inline namespace in_ns2 {
+  class Foo {};

What if anon/inline namespace are interleaves with named ones?
What would it print?

```
namespace a { inline namespace inl {  namespace b { namespace { namespace c { 
namespace {
struct X {};
}}
```
Could we test this?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1196
   [](HoverInfo &HI) {
-HI.Name = "class std::initializer_list";
+// FIXME: Print template instantiation parameters.
+HI.Name = "initializer_list";

This looks like a regression. What's stopping us from fixing this right away?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71543



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


[clang-tools-extra] 079ef78 - Revert "[clangd] Implement "textDocument/documentLink" protocol support"

2019-12-16 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2019-12-16T15:21:51+01:00
New Revision: 079ef783dd5530b5f87beefe624b9179547ded7e

URL: 
https://github.com/llvm/llvm-project/commit/079ef783dd5530b5f87beefe624b9179547ded7e
DIFF: 
https://github.com/llvm/llvm-project/commit/079ef783dd5530b5f87beefe624b9179547ded7e.diff

LOG: Revert "[clangd] Implement "textDocument/documentLink" protocol support"

This reverts commit d6417f5584aa7673fa0212029a96cc9cacb1aad5. The tests
depend on builtin headers, which is not intentionally supported in
clangd tests; these tests are broken in some build environments.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 
clang-tools-extra/clangd/test/document-link.test



diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 69b4308a1c9e..bd9c31d3844b 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -566,10 +566,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
 {"declarationProvider", true},
 {"definitionProvider", true},
 {"documentHighlightProvider", true},
-{"documentLinkProvider",
- llvm::json::Object{
- {"resolveProvider", false},
- }},
 {"hoverProvider", true},
 {"renameProvider", std::move(RenameProvider)},
 {"selectionRangeProvider", true},
@@ -1204,25 +1200,6 @@ void ClangdLSPServer::onSelectionRange(
   });
 }
 
-void ClangdLSPServer::onDocumentLink(
-const DocumentLinkParams &Params,
-Callback> Reply) {
-
-  // TODO(forster): This currently resolves all targets eagerly. This is slow,
-  // because it blocks on the preamble/AST being built. We could respond to the
-  // request faster by using string matching or the lexer to find the includes
-  // and resolving the targets lazily.
-  Server->documentLinks(
-  Params.textDocument.uri.file(),
-  [Reply = std::move(Reply)](
-  llvm::Expected> Links) mutable {
-if (!Links) {
-  return Reply(Links.takeError());
-}
-return Reply(std::move(Links));
-  });
-}
-
 ClangdLSPServer::ClangdLSPServer(
 class Transport &Transp, const FileSystemProvider &FSProvider,
 const clangd::CodeCompleteOptions &CCOpts,
@@ -1266,7 +1243,6 @@ ClangdLSPServer::ClangdLSPServer(
   MsgHandler->bind("textDocument/typeHierarchy", 
&ClangdLSPServer::onTypeHierarchy);
   MsgHandler->bind("typeHierarchy/resolve", 
&ClangdLSPServer::onResolveTypeHierarchy);
   MsgHandler->bind("textDocument/selectionRange", 
&ClangdLSPServer::onSelectionRange);
-  MsgHandler->bind("textDocument/documentLink", 
&ClangdLSPServer::onDocumentLink);
   // clang-format on
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 9650b6a7dbb2..f1ed317f6bad 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -111,8 +111,6 @@ class ClangdLSPServer : private DiagnosticsConsumer {
 Callback>);
   void onSelectionRange(const SelectionRangeParams &,
 Callback>);
-  void onDocumentLink(const DocumentLinkParams &,
-  Callback>);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic &D);
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index c71a8a0d566b..40fa28ae140a 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -611,17 +611,6 @@ void ClangdServer::semanticRanges(PathRef File, Position 
Pos,
   WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
 }
 
-void ClangdServer::documentLinks(PathRef File,
- Callback> CB) {
-  auto Action =
-  [CB = std::move(CB)](llvm::Expected InpAST) mutable {
-if (!InpAST)
-  return CB(InpAST.takeError());
-CB(clangd::getDocumentLinks(InpAST->AST));
-  };
-  WorkScheduler.runWithAST("DocumentLinks", File, std::move(Action));
-}
-
 std::vector>
 ClangdServer::getUsedBytesPerFile() const {
   return WorkScheduler.getUsedBytesPerFile();

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 4574d6c35034..499340808765 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/Clan

[PATCH] D71545: [clangd] Improve hover for auto on template instantiations

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.
kadircet added a parent revision: D71544: [clangd] Improve printing of lambda 
names.

Follow-up to D71543 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71545

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -373,7 +373,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on specialized template
@@ -543,6 +543,19 @@
 HI.Name = "Foo";
 HI.Kind = index::SymbolKind::Class;
   }},
+  {
+  R"cpp(
+  template  class Foo {};
+  class X;
+  void foo() {
+[[^auto]] x = Foo();
+  }
+  )cpp",
+  [](HoverInfo &HI) {
+// FIXME: Drop default arguments.
+HI.Name = "Foo";
+HI.Kind = index::SymbolKind::Class;
+  }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -1193,7 +1206,7 @@
   )cpp",
   [](HoverInfo &HI) {
 // FIXME: Print template instantiation parameters.
-HI.Name = "initializer_list";
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;
   }},
   {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -416,11 +417,22 @@
 
   if (auto Deduced = getDeducedType(AST.getASTContext(), SourceLocationBeg)) {
 // Find the corresponding decl to populate kind and fetch documentation.
-DeclRelationSet Rel = DeclRelation::TemplatePattern | DeclRelation::Alias;
+DeclRelationSet Rel = DeclRelation::TemplateInstantiation |
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
 auto Decls =
 targetDecl(ast_type_traits::DynTypedNode::create(*Deduced), Rel);
-HI = getHoverContents(*Deduced, Decls.empty() ? nullptr : Decls.front(),
-  AST.getASTContext(), Index);
+// Select the target decl, biased towards instantiations.
+auto *D = [&Decls]() -> const Decl * {
+  if (Decls.empty())
+return nullptr;
+  auto *Spec = llvm::find_if(Decls, [](const Decl *D) {
+return llvm::isa(D);
+  });
+  if (Spec != Decls.end())
+return *Spec;
+  return Decls.front();
+}();
+HI = getHoverContents(*Deduced, D, AST.getASTContext(), Index);
   } else if (auto M = locateMacroAt(SourceLocationBeg, AST.getPreprocessor())) 
{
 HI = getHoverContents(*M, AST);
   } else {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -373,7 +373,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on specialized template
@@ -543,6 +543,19 @@
 HI.Name = "Foo";
 HI.Kind = index::SymbolKind::Class;
   }},
+  {
+  R"cpp(
+  template  class Foo {};
+  class X;
+  void foo() {
+[[^auto]] x = Foo();
+  }
+  )cpp",
+  [](HoverInfo &HI) {
+// FIXME: Drop default arguments.
+HI.Name = "Foo";
+HI.Kind = index::SymbolKind::Class;
+  }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -1193,7 +1206,7 @@
   )cpp",
   [](HoverInfo &HI) {
 // FIXME: Print template instantiation parameters.
-HI.Name = "initializer_list";
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;
   }},
   {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Index/IndexSymbol.h"

[PATCH] D70872: [clangd] Implement "textDocument/documentLink" protocol support

2019-12-16 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Sorry, I reverted this change in 079ef783dd5530b5f87beefe624b9179547ded7e 
. The 
tests depend on builtin headers, which is not intentionally supported in clangd 
tests; these tests are broken in some build environments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70872



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


[PATCH] D71544: [clangd] Improve printing of lambda names

2019-12-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71544



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


[clang] 4c4f4dd - Silence an MSVC "not all control paths" diagnostic; NFC.

2019-12-16 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-12-16T09:35:15-05:00
New Revision: 4c4f4dd3f894a0f7a20df8b9696ffe22ab388821

URL: 
https://github.com/llvm/llvm-project/commit/4c4f4dd3f894a0f7a20df8b9696ffe22ab388821
DIFF: 
https://github.com/llvm/llvm-project/commit/4c4f4dd3f894a0f7a20df8b9696ffe22ab388821.diff

LOG: Silence an MSVC "not all control paths" diagnostic; NFC.

Added: 


Modified: 
clang/include/clang/AST/TypeProperties.td

Removed: 




diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 8fa4e4bc1bcb..caa5835911c5 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -691,6 +691,7 @@ let Class = BuiltinType in {
 
def : Creator<[{
switch (kind) {
+default: llvm_unreachable("unreachable builtin case");
 #define IMAGE_TYPE(IMGTYPE, ID, SINGLETON_ID, ACCESS, SUFFIX) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/OpenCLImageTypes.def"



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


[PATCH] D71543: [clangd] Fix handling of inline/anon namespaces and names of deduced types in hover

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 234050.
kadircet marked 9 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71543

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -104,7 +104,7 @@
   }}
   )cpp",
[](HoverInfo &HI) {
- HI.NamespaceScope = "ns1::(anonymous)::";
+ HI.NamespaceScope = "ns1::";
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
@@ -362,7 +362,8 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class (lambda)";
+ // FIXME: Special case lambdas.
+ HI.Name = "(anonymous class)";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on template instantiation
@@ -373,7 +374,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
   // auto on specialized template
@@ -385,7 +386,7 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;
}},
 
@@ -524,6 +525,32 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "boom::";
}},
+  {
+  R"cpp(// Should not print inline or anon namespaces.
+  namespace ns {
+inline namespace in_ns {
+  namespace a {
+namespace {
+  namespace b {
+inline namespace in_ns2 {
+  class Foo {};
+} // in_ns2
+  } // b
+} // anon
+  } // a
+} // in_ns
+  } // ns
+  void foo() {
+ns::a::b::[[F^oo]] x;
+(void)x;
+  }
+  )cpp",
+  [](HoverInfo &HI) {
+HI.Name = "Foo";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "ns::a::b::";
+HI.Definition = "class Foo {}";
+  }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -895,7 +922,7 @@
   [](HoverInfo &HI) {
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Variable;
-HI.NamespaceScope = "ns::(anonymous)::";
+HI.NamespaceScope = "ns::";
 HI.Type = "int";
 HI.Definition = "int foo";
   }},
@@ -1173,7 +1200,8 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "class std::initializer_list";
+// FIXME: Print template instantiation parameters.
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;
   }},
   {
@@ -1231,7 +1259,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1242,7 +1270,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1253,7 +1281,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1265,7 +1293,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1277,7 +1305,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1289,7 +1317,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1300,7 +1328,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
   }},
   {
@@ -1364,7 +1392,7 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "struct Bar";
+HI.Name = "Bar";

[PATCH] D70872: [clangd] Implement "textDocument/documentLink" protocol support

2019-12-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D70872#1785797 , @gribozavr2 wrote:

> which is intentionally not supported in clangd tests


Not intentionally as far as I'm aware :-)
Do you have a link or details for some failing environment? I'm OOO but I'd 
like to follow up and sort this out (ideally by making the builtins available)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70872



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


[clang-tools-extra] 7dc388b - [clangd] Make Tweak::Selection movable. NFC

2019-12-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-16T15:46:57+01:00
New Revision: 7dc388bd9596bbf42633f8a8e450224e39740b60

URL: 
https://github.com/llvm/llvm-project/commit/7dc388bd9596bbf42633f8a8e450224e39740b60
DIFF: 
https://github.com/llvm/llvm-project/commit/7dc388bd9596bbf42633f8a8e450224e39740b60.diff

LOG: [clangd] Make Tweak::Selection movable. NFC

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Tweak.cpp
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Tweak.cpp 
b/clang-tools-extra/clangd/refactor/Tweak.cpp
index 2dc091ed762a..435c36e91efa 100644
--- a/clang-tools-extra/clangd/refactor/Tweak.cpp
+++ b/clang-tools-extra/clangd/refactor/Tweak.cpp
@@ -47,7 +47,7 @@ void validateRegistry() {
 
 Tweak::Selection::Selection(const SymbolIndex *Index, ParsedAST &AST,
 unsigned RangeBegin, unsigned RangeEnd)
-: Index(Index), AST(AST), SelectionBegin(RangeBegin),
+: Index(Index), AST(&AST), SelectionBegin(RangeBegin),
   SelectionEnd(RangeEnd),
   ASTSelection(AST.getASTContext(), AST.getTokens(), RangeBegin, RangeEnd) 
{
   auto &SM = AST.getSourceManager();

diff  --git a/clang-tools-extra/clangd/refactor/Tweak.h 
b/clang-tools-extra/clangd/refactor/Tweak.h
index 69ac4ad612e9..14f9ffca4437 100644
--- a/clang-tools-extra/clangd/refactor/Tweak.h
+++ b/clang-tools-extra/clangd/refactor/Tweak.h
@@ -53,8 +53,8 @@ class Tweak {
 llvm::StringRef Code;
 /// The Index for handling codebase related queries.
 const SymbolIndex *Index = nullptr;
-/// Parsed AST of the active file.
-ParsedAST &AST;
+/// The parsed active file. Never null. (Pointer so Selection is movable).
+ParsedAST *AST;
 /// A location of the cursor in the editor.
 // FIXME: Cursor is redundant and should be removed
 SourceLocation Cursor;

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
index 2d4d2ac24ea6..8e3eba35b004 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -44,18 +44,18 @@ Expected AnnotateHighlightings::apply(const 
Selection &Inputs) {
 // Now we hit the TUDecl case where commonAncestor() returns null
 // intendedly. We only annotate tokens in the main file, so use the default
 // traversal scope (which is the top level decls of the main file).
-HighlightingTokens = getSemanticHighlightings(Inputs.AST);
+HighlightingTokens = getSemanticHighlightings(*Inputs.AST);
   } else {
 // Store the existing scopes.
-const auto &BackupScopes = Inputs.AST.getASTContext().getTraversalScope();
+const auto &BackupScopes = Inputs.AST->getASTContext().getTraversalScope();
 // Narrow the traversal scope to the selected node.
-Inputs.AST.getASTContext().setTraversalScope(
+Inputs.AST->getASTContext().setTraversalScope(
 {const_cast(CommonDecl)});
-HighlightingTokens = getSemanticHighlightings(Inputs.AST);
+HighlightingTokens = getSemanticHighlightings(*Inputs.AST);
 // Restore the traversal scope.
-Inputs.AST.getASTContext().setTraversalScope(BackupScopes);
+Inputs.AST->getASTContext().setTraversalScope(BackupScopes);
   }
-  auto &SM = Inputs.AST.getSourceManager();
+  auto &SM = Inputs.AST->getSourceManager();
   tooling::Replacements Result;
   llvm::StringRef FilePath = SM.getFilename(Inputs.Cursor);
   for (const auto &Token : HighlightingTokens) {

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
index 57690ee3d684..9db7e302ce6c 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
@@ -438,15 +438,15 @@ class DefineInline : public Tweak {
 
 // Check if the decls referenced in function body are visible in the
 // declaration location.
-if (!checkDeclsAreVisible(getNonLocalDeclRefs(Sel.AST, Source), Ta

[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234051.
arichardson marked 6 inline comments as done.
arichardson added a comment.

- Add support for constant-evaluating pointer values
- Add errors messages for constant evaluation
- Extend tests for constant evaluation
- Use ptrtoint+inttoptr instead of ptrmask as suggested by @lebedev.ri
- Fix SemaChecking.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/Sema/builtin-align.c
  clang/test/SemaCXX/builtin-align-cxx.cpp

Index: clang/test/SemaCXX/builtin-align-cxx.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-align-cxx.cpp
@@ -0,0 +1,237 @@
+// C++-specific checks for the alignment builtins
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -std=c++11 -o - %s -fsyntax-only -verify
+
+// Check that we don't crash when using dependent types in __builtin_align:
+template 
+void *c(void *d) { // expected-note{{candidate template ignored}}
+  return __builtin_align_down(d, b);
+}
+
+struct x {};
+x foo;
+void test(void *value) {
+  c(value);
+  c(value); // expected-error{{no matching function for call to 'c'}}
+}
+
+template 
+void test_templated_arguments() {
+  T array[ArraySize];   // expected-error{{variable has incomplete type 'fwddecl'}}
+  static_assert(__is_same(decltype(__builtin_align_up(array, Alignment)), T *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, Alignment)), T *),
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, Alignment)), bool),
+"return type should be bool");
+  T *x1 = __builtin_align_up(array, Alignment);
+  T *x2 = __builtin_align_down(array, Alignment);
+  bool x3 = __builtin_align_up(array, Alignment);
+}
+
+void test() {
+  test_templated_arguments(); // fine
+  test_templated_arguments();
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+  // expected-note@-2{{forward declaration of 'fwddecl'}}
+  test_templated_arguments(); // invalid alignment value
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+}
+
+template 
+void test_incorrect_alignment_without_instatiation(T value) {
+  int array[32];
+  static_assert(__is_same(decltype(__builtin_align_up(array, 31)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, 7)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, -1)), bool), // expected-error{{requested alignment must be 1 or greater}}
+"return type should be bool");
+  __builtin_align_up(array);   // expected-error{{too few arguments to function call, expected 2, have 1}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_down(array, 31); // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(value, 31);   // This shouldn't want since the type is dependent
+  __builtin_align_up(value);   // Same here
+}
+
+// The original fix for the issue above broke some legitimate code.
+// Here is a regression test:
+typedef __SIZE_TYPE__ size_t;
+void *allocate_impl(size_t size);
+template 
+T *allocate() {
+  constexpr size_t allocation_size =
+  __builtin_align_up(sizeof(T), sizeof(void *));
+  return static_cast(
+  __builtin_assume_aligned(allocate_impl(allocation_size), sizeof(void *)));
+}
+struct Foo {
+  int value;
+};
+void *test2() {
+  return allocate();
+}
+
+// Check that pointers-to-members cannot be used
+class MemPtr {
+public:
+  int data;
+  void func();
+  virtual void vfunc();
+};
+void test_member_ptr() {
+  __builtin_align_up(&MemPtr::data, 64);// expected-error{{operand of type 'int MemPtr::*' where arithmetic or pointer type is required}}
+  __builtin_align_down(&MemPtr::func, 64);  // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer 

[PATCH] D71545: [clangd] Improve hover for auto on template instantiations

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60957 tests passed, 0 failed 
and 726 were skipped.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71545



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


[PATCH] D71543: [clangd] Fix handling of inline/anon namespaces and names of deduced types in hover

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D71543#1785785 , @ilya-biryukov 
wrote:

> My biggest concern is that we seem to make output for template instantiation 
> worse.
>  There should be a way to stop showing anonymous namespace without 
> introducing such regressions.


I've got D71545  to reduce that regression.




Comment at: clang-tools-extra/clangd/Hover.cpp:353
 /// Generate a \p Hover object given the type \p T.
 HoverInfo getHoverContents(QualType T, const Decl *D, ASTContext &ASTCtx,
+   const SymbolIndex *Index) {

ilya-biryukov wrote:
> Not related to this patch, but what is `D` here? Is this getting hover 
> contents for a type or for a decl?
it represents the deduced decl for Type, if any.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:365
[](HoverInfo &HI) {
- HI.Name = "class (lambda)";
+ // FIXME: Special case lambdas.
+ HI.Name = "(anonymous class)";

ilya-biryukov wrote:
> NIT: could you give an example how you want the output to look like?
See D71544



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:377
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;

ilya-biryukov wrote:
> `Foo` actually looked better. Do you consider this a regression or is 
> this intended?
See  D71545



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:389
[](HoverInfo &HI) {
- HI.Name = "class Foo";
+ HI.Name = "Foo";
  HI.Kind = index::SymbolKind::Class;

ilya-biryukov wrote:
> Why does this give different output from the previous example?
> I would argue they should both be consistent. Users shouldn't care if there's 
> an explicit specialization or not.
i totally agree. this one has a different output because of explicit 
specializations having a template pattern.
this is a temporary regression that should be fixed by D71545 (i am planning to 
land those patches as a whole)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71543



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


[PATCH] D71543: [clangd] Fix handling of inline/anon namespaces and names of deduced types in hover

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 60930 tests passed, 2 failed 
and 726 were skipped.

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/lock.pass.cpp
  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/try_lock.pass.cpp

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71543



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


[clang-tools-extra] 2500a8d - [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

2019-12-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-16T15:55:16+01:00
New Revision: 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d

URL: 
https://github.com/llvm/llvm-project/commit/2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d
DIFF: 
https://github.com/llvm/llvm-project/commit/2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.diff

LOG: [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor 
if token-after-cursor fails.

This reverts commit f0604e73a4daa35a10eb17a998657d6c4bd0e971
The issue with movability of Tweak::Selection was addressed in 
7dc388bd9596bbf42633f8a8e450224e39740b60

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Tweak.cpp
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TweakTesting.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 40fa28ae140a..90bdc68e374b 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -374,7 +374,8 @@ void ClangdServer::rename(PathRef File, Position Pos, 
llvm::StringRef NewName,
   WorkScheduler.runWithAST("Rename", File, std::move(Action));
 }
 
-static llvm::Expected
+// May generate several candidate selections, due to SelectionTree ambiguity.
+static llvm::Expected>
 tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto Begin = positionToOffset(AST.Inputs.Contents, Sel.start);
   if (!Begin)
@@ -382,7 +383,15 @@ tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto End = positionToOffset(AST.Inputs.Contents, Sel.end);
   if (!End)
 return End.takeError();
-  return Tweak::Selection(AST.Inputs.Index, AST.AST, *Begin, *End);
+  std::vector Result;
+  SelectionTree::createEach(AST.AST.getASTContext(), AST.AST.getTokens(),
+*Begin, *End, [&](SelectionTree T) {
+  Result.emplace_back(AST.Inputs.Index, AST.AST,
+  *Begin, *End, std::move(T));
+  return false;
+});
+  assert(!Result.empty() && "Expected at least one SelectionTree");
+  return Result;
 }
 
 void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
@@ -391,12 +400,21 @@ void ClangdServer::enumerateTweaks(PathRef File, Range 
Sel,
  this](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selection = tweakSelection(Sel, *InpAST);
-if (!Selection)
-  return CB(Selection.takeError());
+auto Selections = tweakSelection(Sel, *InpAST);
+if (!Selections)
+  return CB(Selections.takeError());
 std::vector Res;
-for (auto &T : prepareTweaks(*Selection, TweakFilter))
-  Res.push_back({T->id(), T->title(), T->intent()});
+// Don't allow a tweak to fire more than once across ambiguous selections.
+llvm::DenseSet PreparedTweaks;
+auto Filter = [&](const Tweak &T) {
+  return TweakFilter(T) && !PreparedTweaks.count(T.id());
+};
+for (const auto &Sel : *Selections) {
+  for (auto &T : prepareTweaks(Sel, Filter)) {
+Res.push_back({T->id(), T->title(), T->intent()});
+PreparedTweaks.insert(T->id());
+  }
+}
 
 CB(std::move(Res));
   };
@@ -411,21 +429,30 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, 
StringRef TweakID,
FS = FSProvider.getFileSystem()](Expected InpAST) mutable 
{
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selection = tweakSelection(Sel, *InpAST);
-if (!Selection)
-  return CB(Selection.takeError());
-auto A = prepareTweak(TweakID, *Selection);
-if (!A)
-  return CB(A.takeError());
-auto Effect = (*A)->apply(*Selection);
-if (!Effect)
-  return CB(Effect.takeError());
-for (auto &It : Effect->ApplyEdits) {
-  Edit &E = It.second;
-  format::FormatStyle Style =
-  getFormatStyleForFile(File, E.InitialCode, FS.get());
-  if (llvm::Error Err = reformatEdit(E, Style))
-elog("Failed to format {0}: {1}", It.first(), std::move(Err));
+auto Selections = tweakSelection(Sel, *InpAST);
+if (!Selections)
+  return CB(Selections.takeError());
+llvm::Optional> Effect;
+// Try each selection, take the first 

[clang-tools-extra] 8f876d5 - Revert "[clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails."

2019-12-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-16T15:57:43+01:00
New Revision: 8f876d5105507f874c0fb86bc779c9853eab3fe2

URL: 
https://github.com/llvm/llvm-project/commit/8f876d5105507f874c0fb86bc779c9853eab3fe2
DIFF: 
https://github.com/llvm/llvm-project/commit/8f876d5105507f874c0fb86bc779c9853eab3fe2.diff

LOG: Revert "[clangd] Reapply b60896fad926 Fall back to selecting 
token-before-cursor if token-after-cursor fails."

This reverts commit 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Tweak.cpp
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TweakTesting.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 90bdc68e374b..40fa28ae140a 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -374,8 +374,7 @@ void ClangdServer::rename(PathRef File, Position Pos, 
llvm::StringRef NewName,
   WorkScheduler.runWithAST("Rename", File, std::move(Action));
 }
 
-// May generate several candidate selections, due to SelectionTree ambiguity.
-static llvm::Expected>
+static llvm::Expected
 tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto Begin = positionToOffset(AST.Inputs.Contents, Sel.start);
   if (!Begin)
@@ -383,15 +382,7 @@ tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto End = positionToOffset(AST.Inputs.Contents, Sel.end);
   if (!End)
 return End.takeError();
-  std::vector Result;
-  SelectionTree::createEach(AST.AST.getASTContext(), AST.AST.getTokens(),
-*Begin, *End, [&](SelectionTree T) {
-  Result.emplace_back(AST.Inputs.Index, AST.AST,
-  *Begin, *End, std::move(T));
-  return false;
-});
-  assert(!Result.empty() && "Expected at least one SelectionTree");
-  return Result;
+  return Tweak::Selection(AST.Inputs.Index, AST.AST, *Begin, *End);
 }
 
 void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
@@ -400,21 +391,12 @@ void ClangdServer::enumerateTweaks(PathRef File, Range 
Sel,
  this](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selections = tweakSelection(Sel, *InpAST);
-if (!Selections)
-  return CB(Selections.takeError());
+auto Selection = tweakSelection(Sel, *InpAST);
+if (!Selection)
+  return CB(Selection.takeError());
 std::vector Res;
-// Don't allow a tweak to fire more than once across ambiguous selections.
-llvm::DenseSet PreparedTweaks;
-auto Filter = [&](const Tweak &T) {
-  return TweakFilter(T) && !PreparedTweaks.count(T.id());
-};
-for (const auto &Sel : *Selections) {
-  for (auto &T : prepareTweaks(Sel, Filter)) {
-Res.push_back({T->id(), T->title(), T->intent()});
-PreparedTweaks.insert(T->id());
-  }
-}
+for (auto &T : prepareTweaks(*Selection, TweakFilter))
+  Res.push_back({T->id(), T->title(), T->intent()});
 
 CB(std::move(Res));
   };
@@ -429,30 +411,21 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, 
StringRef TweakID,
FS = FSProvider.getFileSystem()](Expected InpAST) mutable 
{
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selections = tweakSelection(Sel, *InpAST);
-if (!Selections)
-  return CB(Selections.takeError());
-llvm::Optional> Effect;
-// Try each selection, take the first one that prepare()s.
-// If they all fail, Effect will hold get the last error.
-for (const auto &Selection : *Selections) {
-  auto T = prepareTweak(TweakID, Selection);
-  if (T) {
-Effect = (*T)->apply(Selection);
-break;
-  }
-  Effect = T.takeError();
-}
-assert(Effect.hasValue() && "Expected at least one selection");
-if (*Effect) {
-  // Tweaks don't apply clang-format, do that centrally here.
-  for (auto &It : (*Effect)->ApplyEdits) {
-Edit &E = It.second;
-format::FormatStyle Style =
-getFormatStyleForFile(File, E.InitialCode, FS.get());
-if (llvm::Error Err = reformatEdit(E, Sty

[clang-tools-extra] a0ff8cd - [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

2019-12-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-16T15:58:51+01:00
New Revision: a0ff8cd631add513423fc2d8afa49e9650d01fe3

URL: 
https://github.com/llvm/llvm-project/commit/a0ff8cd631add513423fc2d8afa49e9650d01fe3
DIFF: 
https://github.com/llvm/llvm-project/commit/a0ff8cd631add513423fc2d8afa49e9650d01fe3.diff

LOG: [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor 
if token-after-cursor fails.

This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Tweak.cpp
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TweakTesting.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 40fa28ae140a..90bdc68e374b 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -374,7 +374,8 @@ void ClangdServer::rename(PathRef File, Position Pos, 
llvm::StringRef NewName,
   WorkScheduler.runWithAST("Rename", File, std::move(Action));
 }
 
-static llvm::Expected
+// May generate several candidate selections, due to SelectionTree ambiguity.
+static llvm::Expected>
 tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto Begin = positionToOffset(AST.Inputs.Contents, Sel.start);
   if (!Begin)
@@ -382,7 +383,15 @@ tweakSelection(const Range &Sel, const InputsAndAST &AST) {
   auto End = positionToOffset(AST.Inputs.Contents, Sel.end);
   if (!End)
 return End.takeError();
-  return Tweak::Selection(AST.Inputs.Index, AST.AST, *Begin, *End);
+  std::vector Result;
+  SelectionTree::createEach(AST.AST.getASTContext(), AST.AST.getTokens(),
+*Begin, *End, [&](SelectionTree T) {
+  Result.emplace_back(AST.Inputs.Index, AST.AST,
+  *Begin, *End, std::move(T));
+  return false;
+});
+  assert(!Result.empty() && "Expected at least one SelectionTree");
+  return Result;
 }
 
 void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
@@ -391,12 +400,21 @@ void ClangdServer::enumerateTweaks(PathRef File, Range 
Sel,
  this](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selection = tweakSelection(Sel, *InpAST);
-if (!Selection)
-  return CB(Selection.takeError());
+auto Selections = tweakSelection(Sel, *InpAST);
+if (!Selections)
+  return CB(Selections.takeError());
 std::vector Res;
-for (auto &T : prepareTweaks(*Selection, TweakFilter))
-  Res.push_back({T->id(), T->title(), T->intent()});
+// Don't allow a tweak to fire more than once across ambiguous selections.
+llvm::DenseSet PreparedTweaks;
+auto Filter = [&](const Tweak &T) {
+  return TweakFilter(T) && !PreparedTweaks.count(T.id());
+};
+for (const auto &Sel : *Selections) {
+  for (auto &T : prepareTweaks(Sel, Filter)) {
+Res.push_back({T->id(), T->title(), T->intent()});
+PreparedTweaks.insert(T->id());
+  }
+}
 
 CB(std::move(Res));
   };
@@ -411,21 +429,30 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, 
StringRef TweakID,
FS = FSProvider.getFileSystem()](Expected InpAST) mutable 
{
 if (!InpAST)
   return CB(InpAST.takeError());
-auto Selection = tweakSelection(Sel, *InpAST);
-if (!Selection)
-  return CB(Selection.takeError());
-auto A = prepareTweak(TweakID, *Selection);
-if (!A)
-  return CB(A.takeError());
-auto Effect = (*A)->apply(*Selection);
-if (!Effect)
-  return CB(Effect.takeError());
-for (auto &It : Effect->ApplyEdits) {
-  Edit &E = It.second;
-  format::FormatStyle Style =
-  getFormatStyleForFile(File, E.InitialCode, FS.get());
-  if (llvm::Error Err = reformatEdit(E, Style))
-elog("Failed to format {0}: {1}", It.first(), std::move(Err));
+auto Selections = tweakSelection(Sel, *InpAST);
+if (!Selections)
+  return CB(Selections.takeError());
+llvm::Optional> Effect;
+// Try each selection, take the first one that prepare()s.
+// If they all fail, Effect will hold get the last error.
+for (co

[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60961 tests passed, 0 failed 
and 726 were skipped.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or apply this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2019-12-16 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@efriedma validation passes without the checks you were pointed out, see 
https://github.com/serge-sans-paille/llvm-project/pull/4/checks
Thanks for making the code simpler!




Comment at: clang/lib/AST/Decl.cpp:3019
+if (SL.isValid())
+  return SM.isInSystemHeader(SL);
+  }

serge-sans-paille wrote:
> efriedma wrote:
> > I'm a little concerned about this; we're subtly changing our generated code 
> > based on the "system-headerness" of the definition.  We generally avoid 
> > depending on this for anything other than warnings. It could lead to weird 
> > results with preprocessed source, or if someone specifies their include 
> > paths incorrectly.
> With the extra check on builtin status, it may no longer be necessary, let me 
> check that.
@efriedma I confirm this test is no longer needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[clang] 9f99aba - [clang][SystemZ] Add support for -march=native

2019-12-16 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2019-12-16T16:11:32+01:00
New Revision: 9f99aba1cfeb603f368c45ef78ba9795bab16d47

URL: 
https://github.com/llvm/llvm-project/commit/9f99aba1cfeb603f368c45ef78ba9795bab16d47
DIFF: 
https://github.com/llvm/llvm-project/commit/9f99aba1cfeb603f368c45ef78ba9795bab16d47.diff

LOG: [clang][SystemZ] Add support for -march=native

Handle -march=native in systemz::getSystemZTargetCPU, similar to
how this is done on other platforms.  Also change the return type
to std::string instead of const char *.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
clang/lib/Driver/ToolChains/Arch/SystemZ.h
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp 
b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index ca60b85cf8a0..2b77d59fdc66 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -9,15 +9,27 @@
 #include "SystemZ.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
-const char *systemz::getSystemZTargetCPU(const ArgList &Args) {
-  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ))
-return A->getValue();
+std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+llvm::StringRef CPUName = A->getValue();
+
+if (CPUName == "native") {
+  std::string CPU = llvm::sys::getHostCPUName();
+  if (!CPU.empty() && CPU != "generic")
+return CPU;
+  else
+return "";
+}
+
+return CPUName;
+  }
   return "z10";
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h 
b/clang/lib/Driver/ToolChains/Arch/SystemZ.h
index 11d77fa01cc8..77dcbc47be5c 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Option.h"
+#include 
 #include 
 
 namespace clang {
@@ -18,7 +19,7 @@ namespace driver {
 namespace tools {
 namespace systemz {
 
-const char *getSystemZTargetCPU(const llvm::opt::ArgList &Args);
+std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args);
 
 void getSystemZTargetFeatures(const llvm::opt::ArgList &Args,
   std::vector &Features);

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 250e924fb84c..7c0bcdcaf074 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -862,7 +862,7 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
&C,
   case llvm::Triple::systemz: {
 // Always pass an -march option, since our default of z10 is later
 // than the GNU assembler's default.
-StringRef CPUName = systemz::getSystemZTargetCPU(Args);
+std::string CPUName = systemz::getSystemZTargetCPU(Args);
 CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
 break;
   }



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I have to wonder if we're not being too eager to produce the debug info.  It 
seems that the undeduced type problem arises because we're trying to produce 
debug info before we've really finished instantiating `value` here.  But 
how Clang works pretty much always confuses me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70537



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


[PATCH] D71422: [clangd] Introduce bulletlists

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FormattedString.h:95
 
+  /// Causes every line of the document to be indented by 2 spaces. Except the
+  /// first line, it is containers responsibility to adjust padding for first

sammccall wrote:
> Why is it the responsibility of this class to keep track of its indentation 
> within the parent?
> This seems like it should be a parameter to the render functions, rather than 
> state.
> 
> BTW, it appears to be legal to write lists as:
> ```
> -
>   this is the
>   first item
> -
>   second item
> ```
> Which is much easier/more regular to generate, because it doesn't require 
> `Document` to special-case the first line.
moved indentation logic into bullet list.

but that wouldn't look nice when rendering plain text? also I wouldn't call 
that special casing, as it just generates trimmed output, like rest of the APIs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71422



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


[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2019-12-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D71467#1784398 , @erichkeane wrote:

> In D71467#1784338 , @craig.topper 
> wrote:
>
> > In D71467#1784286 , @rjmccall 
> > wrote:
> >
> > > The bug with `__builtin_isless` should be a really easy fix; the builtin 
> > > just needs to be flagged as having custom type-checking, and then we need 
> > > to make sure we do appropriate promotions on the arguments (but we 
> > > probably do).
> >
> >
> > I think I convinced @erichkeane to look at it on Monday.
>
>
> Everything but fpclassify is pretty trivial, I just needed to write a test 
> but needed to go home. I'll commit that Monday when I get to it. Fpclassify 
> will take a touch longer since the int arguments need to be dealt with, but 
> that shouldn't be more than a little work.


I did the compare operators that didn't work right, and will do a separate 
patch for the fp-classification type ones: 
f02d6dd6c7afc08f871a623c0411f2d77ed6acf8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71467



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


[PATCH] D61549: Fix use of 'is' operator for comparison

2019-12-16 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D61549#1785369 , @Jim wrote:

> @j-carl Could you give a Python 3.8 syntax reference for this change.


This is not a language change in Python 3.8. AFAICT, the behaviour of `is` has 
been the same as long as Python has been in use.
CPython 3.8 only added the warning for incorrect usages where the result is 
always `False`, as in this case.

It's unclear to me why @j-carl thinks this change might resolve this. This 
behaviour should be consistent across at least Python 2.7–3.8.

I'm also unsure why this has yet to be reviewed and how might I get someone to 
do that.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61549



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


[PATCH] D71422: [clangd] Introduce bulletlists

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 234059.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Move indentation logic into bulletlist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71422

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp

Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -186,6 +186,71 @@
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
 
+TEST(BulletList, Render) {
+  BulletList L;
+  // Flat list
+  L.addItem().addParagraph().appendText("foo");
+  EXPECT_EQ(L.asMarkdown(), "- foo");
+  EXPECT_EQ(L.asPlainText(), "- foo");
+
+  L.addItem().addParagraph().appendText("bar");
+  EXPECT_EQ(L.asMarkdown(), R"md(- foo
+- bar)md");
+  EXPECT_EQ(L.asPlainText(), R"pt(- foo
+- bar)pt");
+
+  // Nested list, with a single item.
+  Document &D = L.addItem();
+  // First item with foo\nbaz
+  D.addParagraph().appendText("foo");
+  D.addParagraph().appendText("baz");
+
+  // Nest one level.
+  Document &Inner = D.addBulletList().addItem();
+  Inner.addParagraph().appendText("foo");
+
+  // Nest one more level.
+  BulletList &InnerList = Inner.addBulletList();
+  // Single item, baz\nbaz
+  Document &DeepDoc = InnerList.addItem();
+  DeepDoc.addParagraph().appendText("baz");
+  DeepDoc.addParagraph().appendText("baz");
+  EXPECT_EQ(L.asMarkdown(), R"md(- foo
+- bar
+- foo
+  baz
+  - foo
+- baz
+  baz)md");
+  EXPECT_EQ(L.asPlainText(), R"pt(- foo
+- bar
+- foo
+  baz
+  - foo
+- baz
+  baz)pt");
+
+  // Termination
+  Inner.addParagraph().appendText("after");
+  EXPECT_EQ(L.asMarkdown(), R"md(- foo
+- bar
+- foo
+  baz
+  - foo
+- baz
+  baz
+
+after)md");
+  EXPECT_EQ(L.asPlainText(), R"pt(- foo
+- bar
+- foo
+  baz
+  - foo
+- baz
+  baz
+after)pt");
+}
+
 } // namespace
 } // namespace markup
 } // namespace clangd
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -62,6 +62,19 @@
   std::vector Chunks;
 };
 
+/// Represents a sequence of one or more documents. Knows how to print them in a
+/// list like format, e.g. by prepending with "- " and indentation.
+class BulletList : public Block {
+public:
+  void renderMarkdown(llvm::raw_ostream &OS) const override;
+  void renderPlainText(llvm::raw_ostream &OS) const override;
+
+  class Document &addItem();
+
+private:
+  std::vector Documents;
+};
+
 /// A format-agnostic representation for structured text. Allows rendering into
 /// markdown and plaintext.
 class Document {
@@ -74,13 +87,14 @@
   /// text representation, the code block will be surrounded by newlines.
   void addCodeBlock(std::string Code, std::string Language = "cpp");
 
+  BulletList &addBulletList();
+
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
 private:
   std::vector> Children;
 };
-
 } // namespace markup
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FormattedString.cpp
===
--- clang-tools-extra/clangd/FormattedString.cpp
+++ clang-tools-extra/clangd/FormattedString.cpp
@@ -150,6 +150,20 @@
   std::string Contents;
   std::string Language;
 };
+
+// Inserts two spaces after each `\n` to indent each line. First line is not
+// indented.
+std::string indentLines(llvm::StringRef Input) {
+  std::string IndentedR;
+  // We'll add 2 spaces after each new line.
+  IndentedR.reserve(Input.size() + Input.count('\n') * 2);
+  for (char C : Input) {
+IndentedR += C;
+if (C == '\n')
+  IndentedR.append("  ");
+  }
+  return IndentedR;
+}
 } // namespace
 
 std::string Block::asMarkdown() const {
@@ -194,6 +208,24 @@
   OS << '\n';
 }
 
+void BulletList::renderMarkdown(llvm::raw_ostream &OS) const {
+  for (auto &D : Documents) {
+// Instead of doing this we might prefer passing Indent to children to get
+// rid of the copies, if it turns out to be a bottleneck.
+OS << "- " << indentLines(D.asMarkdown()) << '\n';
+  }
+  // We need a new line after list to terminate it in markdown.
+  OS << '\n';
+}
+
+void BulletList::renderPlainText(llvm::raw_ostream &OS) const {
+  for (auto &D : Documents) {
+// Instead of doing this we might prefer passing Indent to children to get
+// rid of the copies, if it turns out to be a bottleneck.
+OS << "- " << indentLines(D.asPlainText()) << '\n';
+  }
+}
+
 Paragraph &Paragraph::appendText(std::string Text) {
   Text = canonicalizeSpaces(std::move(Text));
   if

[clang] f02d6dd - Fix floating point builtins to not promote float->double

2019-12-16 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2019-12-16T07:20:29-08:00
New Revision: f02d6dd6c7afc08f871a623c0411f2d77ed6acf8

URL: 
https://github.com/llvm/llvm-project/commit/f02d6dd6c7afc08f871a623c0411f2d77ed6acf8
DIFF: 
https://github.com/llvm/llvm-project/commit/f02d6dd6c7afc08f871a623c0411f2d77ed6acf8.diff

LOG: Fix floating point builtins to not promote float->double

As brought up in D71467, a group of floating point builtins
automatically promoted floats to doubles because they used the variadic
builtin tag to support an overload set. The result is that the
parameters were treated as a variadic pack, which always promots
float->double.

This resulted in the wrong answer being given in cases with certain
values of NaN.

Added: 
clang/test/CodeGen/builtin_float.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/test/CodeGen/arm-float-helpers.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 8a102744700f..29dec78e4b96 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -391,12 +391,12 @@ BUILTIN(__builtin_ctanhf, "XfXf", "Fne")
 BUILTIN(__builtin_ctanhl, "XLdXLd", "Fne")
 
 // FP Comparisons.
-BUILTIN(__builtin_isgreater , "i.", "Fnc")
-BUILTIN(__builtin_isgreaterequal, "i.", "Fnc")
-BUILTIN(__builtin_isless, "i.", "Fnc")
-BUILTIN(__builtin_islessequal   , "i.", "Fnc")
-BUILTIN(__builtin_islessgreater , "i.", "Fnc")
-BUILTIN(__builtin_isunordered   , "i.", "Fnc")
+BUILTIN(__builtin_isgreater , "i.", "Fnct")
+BUILTIN(__builtin_isgreaterequal, "i.", "Fnct")
+BUILTIN(__builtin_isless, "i.", "Fnct")
+BUILTIN(__builtin_islessequal   , "i.", "Fnct")
+BUILTIN(__builtin_islessgreater , "i.", "Fnct")
+BUILTIN(__builtin_isunordered   , "i.", "Fnct")
 
 // Unary FP classification
 BUILTIN(__builtin_fpclassify, "ii.", "Fnc")

diff  --git a/clang/test/CodeGen/arm-float-helpers.c 
b/clang/test/CodeGen/arm-float-helpers.c
index 30363304bcf9..b2e65805cc7c 100644
--- a/clang/test/CodeGen/arm-float-helpers.c
+++ b/clang/test/CodeGen/arm-float-helpers.c
@@ -79,7 +79,7 @@ int fcmpgt(float a, float b) { return a > b; }
 int fcmpun(float a, float b) { return __builtin_isunordered(a, b); }
 // CHECK-LABEL: define i32 @fcmpun(float %a, float %b)
 // CHECK-NOT: __aeabi_fcmpun
-// CHECK: %cmp = fcmp uno double %conv, %conv1
+// CHECK: %cmp = fcmp uno float {{.*}}, {{.*}}
 
 double dadd(double a, double b) { return a + b; }
 // CHECK-LABEL: define double @dadd(double %a, double %b)

diff  --git a/clang/test/CodeGen/builtin_float.c 
b/clang/test/CodeGen/builtin_float.c
new file mode 100644
index ..b97cf1be348f
--- /dev/null
+++ b/clang/test/CodeGen/builtin_float.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// test to ensure that these builtins don't do the variadic promotion of 
float->double.
+void test_floats(float f1, float f2) {
+  (void)__builtin_isgreater(f1, f2);
+  // CHECK: fcmp ogt float
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isgreaterequal(f1, f2);
+  // CHECK: fcmp oge float
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isless(f1, f2);
+  // CHECK: fcmp olt float
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessequal(f1, f2);
+  // CHECK: fcmp ole float
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessgreater(f1, f2);
+  // CHECK: fcmp one float
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isunordered(f1, f2);
+  // CHECK: fcmp uno float
+  // CHECK-NEXT: zext i1
+}
+
+void test_doubles(double d1, double f2) {
+  (void)__builtin_isgreater(d1, f2);
+  // CHECK: fcmp ogt double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isgreaterequal(d1, f2);
+  // CHECK: fcmp oge double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isless(d1, f2);
+  // CHECK: fcmp olt double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessequal(d1, f2);
+  // CHECK: fcmp ole double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessgreater(d1, f2);
+  // CHECK: fcmp one double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isunordered(d1, f2);
+  // CHECK: fcmp uno double
+  // CHECK-NEXT: zext i1
+}
+
+void test_mixed(double d1, float f2) {
+  (void)__builtin_isgreater(d1, f2);
+  // CHECK: fpext float {{.*}} to double
+  // CHECK-NEXT: fcmp ogt double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isgreaterequal(d1, f2);
+  // CHECK: fpext float {{.*}} to double
+  // CHECK-NEXT: fcmp oge double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isless(d1, f2);
+  // CHECK: fpext float {{.*}} to double
+  // CHECK-NEXT: fcmp olt double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessequal(d1, f2);
+  // CHECK: fpext float {{.*}} to double
+  // CHECK-NEXT: fcmp ole double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_islessgreater(d1, f2);
+  // CHECK: fpext float {{.*}} to double
+  // CHECK-NEXT: fcmp one double
+  // CHECK-NEXT: zext i1
+  (void)__builtin_isunordered(d1

[PATCH] D71422: [clangd] Introduce bulletlists

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60933 tests passed, 0 failed 
and 726 were skipped.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71422



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


[clang] fd0c91b - [OPENMP50]Add if clause in target teams distribute parallel for simd directive.

2019-12-16 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-16T10:33:56-05:00
New Revision: fd0c91bab184e50e548b9daca4b8cfb0719ff959

URL: 
https://github.com/llvm/llvm-project/commit/fd0c91bab184e50e548b9daca4b8cfb0719ff959
DIFF: 
https://github.com/llvm/llvm-project/commit/fd0c91bab184e50e548b9daca4b8cfb0719ff959.diff

LOG: [OPENMP50]Add if clause in target teams distribute parallel for simd 
directive.

According to OpenMP 5.0, if clause can be used in for simd directive. If
condition in the if clause if false, the non-vectorized version of the
loop must be executed.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index e02c1c591dff..9033997afff5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4778,6 +4778,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
 AllowedNameModifiers.push_back(OMPD_target);
 AllowedNameModifiers.push_back(OMPD_parallel);
+if (LangOpts.OpenMP >= 50)
+  AllowedNameModifiers.push_back(OMPD_simd);
 break;
   case OMPD_target_teams_distribute_simd:
 Res = ActOnOpenMPTargetTeamsDistributeSimdDirective(
@@ -10762,8 +10764,14 @@ static OpenMPDirectiveKind 
getOpenMPCaptureRegionForClause(
   if (NameModifier == OMPD_unknown || NameModifier == OMPD_parallel)
 CaptureRegion = OMPD_target;
   break;
-case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
+  if (OpenMPVersion >= 50 &&
+  (NameModifier == OMPD_unknown || NameModifier == OMPD_simd)) {
+CaptureRegion = OMPD_parallel;
+break;
+  }
+  LLVM_FALLTHROUGH;
+case OMPD_target_teams_distribute_parallel_for:
   // If this clause applies to the nested 'parallel' region, capture within
   // the 'teams' region, otherwise do not capture.
   if (NameModifier == OMPD_unknown || NameModifier == OMPD_parallel)

diff  --git 
a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp 
b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
index 79ae4fe29a68..8a8d64e36f8d 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
@@ -1,10 +1,16 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix OMP50
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix SIMD-ONLY
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 
-fopenmp-targets=powerpc64le-ibm-linu

[PATCH] D71020: [ASTImporter] Friend class decl should not be visible in its context

2019-12-16 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 234062.
martong marked an inline comment as done.
martong added a comment.

Simplify getRecordDeclOfFriend() further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71020

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -247,6 +247,11 @@
   return cast(ET->getNamedType().getTypePtr())->getDecl();
 }
 
+static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) {
+  QualType Ty = FD->getFriendType()->getType().getCanonicalType();
+  return cast(Ty)->getDecl();
+}
+
 struct ImportExpr : TestImportBase {};
 struct ImportType : TestImportBase {};
 struct ImportDecl : TestImportBase {};
@@ -2707,7 +2712,7 @@
   EXPECT_FALSE(To0->isInIdentifierNamespace(Decl::IDNS_Ordinary));
 }
 
-TEST_P(ImportFriendFunctions, DISABLED_LookupWithProtoAfter) {
+TEST_P(ImportFriendFunctions, LookupWithProtoAfter) {
   auto FunctionPattern = functionDecl(hasName("f"));
   auto ClassPattern = cxxRecordDecl(hasName("X"));
 
@@ -3778,6 +3783,44 @@
   EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern));
 }
 
+TEST_P(ImportFriendClasses, UndeclaredFriendClassShouldNotBeVisible) {
+  Decl *FromTu = getTuDecl("class X { friend class Y; };", Lang_CXX, "from.cc");
+  auto *FromX = FirstDeclMatcher().match(
+  FromTu, cxxRecordDecl(hasName("X")));
+  auto *FromFriend = FirstDeclMatcher().match(FromTu, friendDecl());
+  RecordDecl *FromRecordOfFriend =
+  const_cast(getRecordDeclOfFriend(FromFriend));
+
+  ASSERT_EQ(FromRecordOfFriend->getDeclContext(), cast(FromTu));
+  ASSERT_EQ(FromRecordOfFriend->getLexicalDeclContext(),
+cast(FromX));
+  ASSERT_FALSE(
+  FromRecordOfFriend->getDeclContext()->containsDecl(FromRecordOfFriend));
+  ASSERT_FALSE(FromRecordOfFriend->getLexicalDeclContext()->containsDecl(
+  FromRecordOfFriend));
+  ASSERT_FALSE(FromRecordOfFriend->getLookupParent()
+   ->lookup(FromRecordOfFriend->getDeclName())
+   .empty());
+
+  auto *ToX = Import(FromX, Lang_CXX);
+  ASSERT_TRUE(ToX);
+
+  Decl *ToTu = ToX->getTranslationUnitDecl();
+  auto *ToFriend = FirstDeclMatcher().match(ToTu, friendDecl());
+  RecordDecl *ToRecordOfFriend =
+  const_cast(getRecordDeclOfFriend(ToFriend));
+
+  ASSERT_EQ(ToRecordOfFriend->getDeclContext(), cast(ToTu));
+  ASSERT_EQ(ToRecordOfFriend->getLexicalDeclContext(), cast(ToX));
+  EXPECT_FALSE(
+  ToRecordOfFriend->getDeclContext()->containsDecl(ToRecordOfFriend));
+  EXPECT_FALSE(ToRecordOfFriend->getLexicalDeclContext()->containsDecl(
+  ToRecordOfFriend));
+  EXPECT_FALSE(ToRecordOfFriend->getLookupParent()
+   ->lookup(ToRecordOfFriend->getDeclName())
+   .empty());
+}
+
 TEST_P(ImportFriendClasses, ImportOfRecursiveFriendClassTemplate) {
   Decl *FromTu = getTuDecl(
   R"(
@@ -4477,11 +4520,6 @@
   ASSERT_EQ(Res.size(), 0u);
 }
 
-static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) {
-  QualType Ty = FD->getFriendType()->getType().getCanonicalType();
-  return cast(Ty)->getDecl();
-}
-
 TEST_P(ASTImporterLookupTableTest,
LookupFindsFwdFriendClassDeclWithElaboratedType) {
   TranslationUnitDecl *ToTU = getToTuDecl(
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -298,6 +298,45 @@
   return nullptr;
 }
 
+void addDeclToContexts(Decl *FromD, Decl *ToD) {
+  if (Importer.isMinimalImport()) {
+// In minimal import case the decl must be added even if it is not
+// contained in original context, for LLDB compatibility.
+// FIXME: Check if a better solution is possible.
+if (!FromD->getDescribedTemplate() &&
+FromD->getFriendObjectKind() == Decl::FOK_None)
+  ToD->getLexicalDeclContext()->addDeclInternal(ToD);
+return;
+  }
+
+  DeclContext *FromDC = FromD->getDeclContext();
+  DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
+  DeclContext *ToDC = ToD->getDeclContext();
+  DeclContext *ToLexicalDC = ToD->getLexicalDeclContext();
+
+  bool Visible = false;
+  if (FromDC->containsDeclAndLoad(FromD)) {
+ToDC->addDeclInternal(ToD);
+Visible = true;
+  }
+  if (ToDC != ToLexicalDC && FromLexicalDC->containsDeclAndLoad(FromD)) {
+ToLexicalDC->addDeclInternal(ToD);
+Visible = true;
+  }
+
+  // If the Decl was added to any context, it was made already visible.
+  // Otherwise it is still possible that it should be visible.
+  if (!Visible) {
+if (auto *FromNamed = dyn_cast(FromD)) {
+  auto *ToNamed = cast(T

[PATCH] D71020: [ASTImporter] Friend class decl should not be visible in its context

2019-12-16 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:252
+  QualType Ty = FD->getFriendType()->getType().getCanonicalType();
+  if (isa(Ty))
+Ty = cast(Ty)->getNamedType();

a_sidorin wrote:
> I wonder if ElaboratedType can be a canonical type because it is only a sugar 
> type itself. Do we need to handle this case?
You are right, I removed this case. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71020



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


RE: [clang] f978ea4 - [clang][clang-scan-deps] Aggregate the full dependency information.

2019-12-16 Thread Nemanja Ivanovic via cfe-commits
Hi Michael,
this turns out to be an assert failure:
 
clang/tools/clang-scan-deps/ClangScanDeps.cpp:340: const clang::tooling::dependencies::ModuleDeps& FullDeps::lookupModuleDeps(clang::tooling::dependencies::ClangModuleDep): Assertion `I != Modules.end()' failed.
 
Does this help with debugging at all?
 
Nemanja IvanovicLLVM PPC Backend DevelopmentIBM Toronto LabEmail: neman...@ca.ibm.comPhone: 905-413-3388
 
 
- Original message -From: Michael Spencer To: Nemanja Ivanovic Cc: cfe-commits@lists.llvm.org, LLVM on Power Subject: [EXTERNAL] Re: [clang] f978ea4 - [clang][clang-scan-deps] Aggregate the full dependency information.Date: Fri, Dec 13, 2019 4:44 PM 
On Thu, Dec 12, 2019 at 4:23 AM Nemanja Ivanovic  wrote:
Hi Michael,
We are happy to help troubleshoot the issue this caused on our bot. Unfortunately, this bot is not one where we can give you access so we'll have to try and work together to debug this.
Can you provide the link to the failing build so we can see which test case it was that caused the problem and we can start debugging from there?
 
Here's one of the failures: http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/21884
 
It looks like it failed on every ppc64 linux bot (both be and le), but no other bots.
 
- Michael Spencer
 
 
Nemanja IvanovicLLVM PPC Backend DevelopmentIBM Toronto LabEmail: neman...@ca.ibm.comPhone: 905-413-3388
 
 
- Original message -From: Michael Spencer To: powerl...@ca.ibm.comCc: cfe-commits@lists.llvm.orgSubject: [EXTERNAL] Re: [clang] f978ea4 - [clang][clang-scan-deps] Aggregate the full dependency information.Date: Wed, Dec 11, 2019 7:34 PM 
On Wed, Dec 11, 2019 at 2:41 PM Michael Spencer via cfe-commits  wrote:
Author: Michael SpencerDate: 2019-12-11T14:40:51-08:00New Revision: f978ea498309adaebab8fbf1cd6e520e7e0e11f1URL: https://github.com/llvm/llvm-project/commit/f978ea498309adaebab8fbf1cd6e520e7e0e11f1DIFF: https://github.com/llvm/llvm-project/commit/f978ea498309adaebab8fbf1cd6e520e7e0e11f1.diffLOG: [clang][clang-scan-deps] Aggregate the full dependency information.Differential Revision: https://reviews.llvm.org/D70268Added:Modified:    clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h    clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h    clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp    clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp    clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp    clang/test/ClangScanDeps/Inputs/modules_cdb.json    clang/test/ClangScanDeps/modules-full.cpp    clang/tools/clang-scan-deps/ClangScanDeps.cpp
 
 
Looks like this broke clang-ppc64be-linux. Is there a good way to debug this? It's not failing anywhere else, and none of the code should care about endianness.
 
I'll revert for now.
 
- Michael Spencer
 
 
 

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


[PATCH] D71320: [IR] Split out target specific intrinsic enums into separate headers

2019-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D71320#1784726 , @thakis wrote:

> I think this broke the reverse-iteration bot: 
> http://lab.llvm.org:8011/builders/reverse-iteration/builds/15619


Looks like I forgot to build polly, and @aheejin fixed it. Thanks! I usually 
enable polly when testing these kinds of change, but I often disable it due to 
warnings in isl and then forget to re-enable it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71320



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234064.
arichardson added a comment.

Fix align32array[0] -> &align32array[0] typo in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/Sema/builtin-align.c
  clang/test/SemaCXX/builtin-align-cxx.cpp

Index: clang/test/SemaCXX/builtin-align-cxx.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-align-cxx.cpp
@@ -0,0 +1,236 @@
+// C++-specific checks for the alignment builtins
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -std=c++11 -o - %s -fsyntax-only -verify
+
+// Check that we don't crash when using dependent types in __builtin_align:
+template 
+void *c(void *d) { // expected-note{{candidate template ignored}}
+  return __builtin_align_down(d, b);
+}
+
+struct x {};
+x foo;
+void test(void *value) {
+  c(value);
+  c(value); // expected-error{{no matching function for call to 'c'}}
+}
+
+template 
+void test_templated_arguments() {
+  T array[ArraySize];   // expected-error{{variable has incomplete type 'fwddecl'}}
+  static_assert(__is_same(decltype(__builtin_align_up(array, Alignment)), T *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, Alignment)), T *),
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, Alignment)), bool),
+"return type should be bool");
+  T *x1 = __builtin_align_up(array, Alignment);
+  T *x2 = __builtin_align_down(array, Alignment);
+  bool x3 = __builtin_align_up(array, Alignment);
+}
+
+void test() {
+  test_templated_arguments(); // fine
+  test_templated_arguments();
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+  // expected-note@-2{{forward declaration of 'fwddecl'}}
+  test_templated_arguments(); // invalid alignment value
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+}
+
+template 
+void test_incorrect_alignment_without_instatiation(T value) {
+  int array[32];
+  static_assert(__is_same(decltype(__builtin_align_up(array, 31)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, 7)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, -1)), bool), // expected-error{{requested alignment must be 1 or greater}}
+"return type should be bool");
+  __builtin_align_up(array);   // expected-error{{too few arguments to function call, expected 2, have 1}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_down(array, 31); // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(value, 31);   // This shouldn't want since the type is dependent
+  __builtin_align_up(value);   // Same here
+}
+
+// The original fix for the issue above broke some legitimate code.
+// Here is a regression test:
+typedef __SIZE_TYPE__ size_t;
+void *allocate_impl(size_t size);
+template 
+T *allocate() {
+  constexpr size_t allocation_size =
+  __builtin_align_up(sizeof(T), sizeof(void *));
+  return static_cast(
+  __builtin_assume_aligned(allocate_impl(allocation_size), sizeof(void *)));
+}
+struct Foo {
+  int value;
+};
+void *test2() {
+  return allocate();
+}
+
+// Check that pointers-to-members cannot be used
+class MemPtr {
+public:
+  int data;
+  void func();
+  virtual void vfunc();
+};
+void test_member_ptr() {
+  __builtin_align_up(&MemPtr::data, 64);// expected-error{{operand of type 'int MemPtr::*' where arithmetic or pointer type is required}}
+  __builtin_align_down(&MemPtr::func, 64);  // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+  __builtin_is_aligned(&MemPtr::vfunc, 64); // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+}
+
+void test_references(Foo &i) {
+  // Check that the 

[PATCH] D71436: [X86][AsmParser] re-introduce 'offset' operator

2019-12-16 Thread Eric Astor via Phabricator via cfe-commits
epastor updated this revision to Diff 234067.
epastor added a comment.

- Apply formatting fixes where reasonable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71436

Files:
  clang/test/CodeGen/ms-inline-asm-64.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86Operand.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/test/CodeGen/X86/ms-inline-asm.ll
  llvm/test/CodeGen/X86/offset-operator.ll
  llvm/test/MC/X86/pr32530.s

Index: llvm/test/MC/X86/pr32530.s
===
--- /dev/null
+++ llvm/test/MC/X86/pr32530.s
@@ -0,0 +1,13 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel %s | FileCheck %s
+
+.text
+// CHECK: movq$msg, %rsi
+// CHECK: movq$msg+314159, %rax
+// CHECK: movq$msg-89793, msg-6535(%rax,%rbx,2)
+  mov rsi,  offset msg
+	mov rax,  offset "msg" + 314159
+	mov qword ptr [rax + 2*rbx + offset msg - 6535],  offset msg - 89793
+.data
+msg:
+  .ascii "Hello, world!\n"
+
Index: llvm/test/CodeGen/X86/offset-operator.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/offset-operator.ll
@@ -0,0 +1,15 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-asm-syntax=intel -relocation-model=static < %s | FileCheck %s
+
+; Test we are emitting the 'offset' operator upon an immediate reference of a label:
+; The emitted 'att-equivalent' of this one is "movl $.L.str, %eax"
+
+@.str = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
+
+define i8* @test_offset_operator() {
+; CHECK-LABEL: test_offset_operator:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mov eax, offset .L.str
+; CHECK-NEXT:ret
+entry:
+  ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
+}
Index: llvm/test/CodeGen/X86/ms-inline-asm.ll
===
--- llvm/test/CodeGen/X86/ms-inline-asm.ll
+++ llvm/test/CodeGen/X86/ms-inline-asm.ll
@@ -92,7 +92,7 @@
 ; CHECK-LABEL: t30:
 ; CHECK: {{## InlineAsm Start|#APP}}
 ; CHECK: .intel_syntax
-; CHECK: lea edi, dword ptr [{{_?}}results]
+; CHECK: lea edi, dword ptr [offset {{_?}}results]
 ; CHECK: .att_syntax
 ; CHECK: {{## InlineAsm End|#NO_APP}}
 ; CHECK: {{## InlineAsm Start|#APP}}
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -220,8 +220,16 @@
 
   case MachineOperand::MO_ConstantPoolIndex:
   case MachineOperand::MO_GlobalAddress: {
-if (IsATT)
+switch (MI->getInlineAsmDialect()) {
+default:
+  llvm_unreachable("unknown assembly dialect!");
+case InlineAsm::AD_ATT:
   O << '$';
+  break;
+case InlineAsm::AD_Intel:
+  O << "offset ";
+  break;
+}
 PrintSymbolOperand(MO, O);
 break;
   }
Index: llvm/lib/Target/X86/AsmParser/X86Operand.h
===
--- llvm/lib/Target/X86/AsmParser/X86Operand.h
+++ llvm/lib/Target/X86/AsmParser/X86Operand.h
@@ -52,6 +52,7 @@
 
   struct ImmOp {
 const MCExpr *Val;
+bool LocalRef;
   };
 
   struct MemOp {
@@ -278,13 +279,9 @@
 return isImmUnsignedi8Value(CE->getValue());
   }
 
-  bool isOffsetOf() const override {
-return OffsetOfLoc.getPointer();
-  }
+  bool isOffsetOfLocal() const override { return isImm() && Imm.LocalRef; }
 
-  bool needAddressOf() const override {
-return AddressOf;
-  }
+  bool needAddressOf() const override { return AddressOf; }
 
   bool isMem() const override { return Kind == Memory; }
   bool isMemUnsized() const {
@@ -613,9 +610,16 @@
   }
 
   static std::unique_ptr CreateImm(const MCExpr *Val,
-   SMLoc StartLoc, SMLoc EndLoc) {
+   SMLoc StartLoc, SMLoc EndLoc,
+   StringRef SymName = StringRef(),
+   void *OpDecl = nullptr,
+   bool GlobalRef = true) {
 auto Res = std::make_unique(Immediate, StartLoc, EndLoc);
-Res->Imm.Val = Val;
+Res->Imm.Val  = Val;
+Res->Imm.LocalRef = !GlobalRef;
+Res->SymName  = SymName;
+Res->OpDecl   = OpDecl;
+Res->AddressOf= true;
 return Res;
   }
 
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -134,7 +134,6 

[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60963 tests passed, 0 failed 
and 726 were skipped.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or apply this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D71436: [X86][AsmParser] re-introduce 'offset' operator

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60854 tests passed, 0 failed 
and 726 were skipped.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or apply this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71436



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


[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-16 Thread Mitchell Horne via Phabricator via cfe-commits
mhorne added a comment.
Herald added a subscriber: arichardson.

Thanks Sam and Luis for the review. Could I ask that one of you commit this if 
you are able?


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

https://reviews.llvm.org/D68362



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


[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2019-12-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary marked 3 inline comments as done.
lenary added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1525
   unsigned TwoXLenInBytes = (2 * XLen) / 8;
   if (!IsFixed && ArgFlags.getOrigAlign() == TwoXLenInBytes &&
   DL.getTypeAllocSize(OrigTy) == TwoXLenInBytes) {

shiva0217 wrote:
> lenary wrote:
> > shiva0217 wrote:
> > > The variadic argument for ilp32e doesn't need to align to even register. 
> > > We could also add a test line in vararg.ll.
> > I'm not sure I agree with this interpretation of the psABI. The [[ 
> > https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#ilp32e-calling-convention
> >  | ILP32E Section ]] makes no exception for variadic arguments, and the 
> > base calling convention is only defined in relation to `XLEN`, not in terms 
> > of stack alignment.
> > 
> > I will add a test to `vararg.ll` so the behaviour is at least tested. 
> It seems to be the current GCC behavior and the following case could observe 
> that double will not align to even pair.
>   #include 
>   void va_double (int n, ...) {
> va_list args;
> va_start (args, n);
> if (va_arg (args, double) != 2.0)
>   abort ();
> va_end (args);
>}
>int main (int a) {
> va_double (1, 2.0);
> return a;
>}
> 
> In a second thought, it seems that non-fixed double arguments may generate 
> incorrect code, even with align even pair.
> For ilp32 or lp64 ABI with feature D, stack alignment will be 16, so even 
> pair can make sure when pushing/popping the non-fixed double to/from the 
> stack, it will be 8-byte alignment. For ilp32e with 4-byte alignment, even 
> pair can not guarantee the double will be pushed to stack with 8-byte 
> alignment.
Ah, I see the issue.

It's not clear that choosing to spill to a register pair where the first 
register is a multiple of 4 would solve the problem either, right? The problem 
is that we actually need to realign the spill slots for these register pairs.

I'm not sure how we achieve this. I will investigate further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401



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


[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Yeah, will do.


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

https://reviews.llvm.org/D68362



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


[clang] 081f736 - Fixing a -Wcovered-switch diagnostic and changing tabs to spaces; NFC.

2019-12-16 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2019-12-16T11:38:30-05:00
New Revision: 081f736157dea53735f098165d750abfbbcd96dd

URL: 
https://github.com/llvm/llvm-project/commit/081f736157dea53735f098165d750abfbbcd96dd
DIFF: 
https://github.com/llvm/llvm-project/commit/081f736157dea53735f098165d750abfbbcd96dd.diff

LOG: Fixing a -Wcovered-switch diagnostic and changing tabs to spaces; NFC.

Added: 


Modified: 
clang/include/clang/AST/TypeProperties.td

Removed: 




diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index caa5835911c5..76404c8df764 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -690,24 +690,24 @@ let Class = BuiltinType in {
   }
 
def : Creator<[{
-   switch (kind) {
-default: llvm_unreachable("unreachable builtin case");
+  switch (kind) {
 #define IMAGE_TYPE(IMGTYPE, ID, SINGLETON_ID, ACCESS, SUFFIX) \
-   case BuiltinType::ID: return ctx.SINGLETON_ID;
+  case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/OpenCLImageTypes.def"
 
 #define EXT_OPAQUE_TYPE(EXTTYPE, ID, EXT) \
-   case BuiltinType::ID: return ctx.ID##Ty;
+  case BuiltinType::ID: return ctx.ID##Ty;
 #include "clang/Basic/OpenCLExtensionTypes.def"
 
 #define SVE_TYPE(NAME, ID, SINGLETON_ID) \
-   case BuiltinType::ID: return ctx.SINGLETON_ID;
+  case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/Basic/AArch64SVEACLETypes.def"
 
 #define BUILTIN_TYPE(ID, SINGLETON_ID) \
-   case BuiltinType::ID: return ctx.SINGLETON_ID;
+  case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/AST/BuiltinTypes.def"
-   }
+  }
+  llvm_unreachable("unreachable builtin case");
}]>;
 }
 



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


[libunwind] ce3d1c6 - [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-16 Thread Sam Elliott via cfe-commits

Author: Sam Elliott
Date: 2019-12-16T16:36:56Z
New Revision: ce3d1c6d61dcd96f44492516f8b613bbcadaeb8e

URL: 
https://github.com/llvm/llvm-project/commit/ce3d1c6d61dcd96f44492516f8b613bbcadaeb8e
DIFF: 
https://github.com/llvm/llvm-project/commit/ce3d1c6d61dcd96f44492516f8b613bbcadaeb8e.diff

LOG: [libunwind][RISCV] Add 64-bit RISC-V support

Summary:
Add unwinding support for 64-bit RISC-V.

This is from the FreeBSD implementation with the following minor
changes:

- Renamed and renumbered DWARF registers to match the RISC-V ABI [1]
- Use the ABI mneumonics in getRegisterName() instead of the exact
   register names
- Include checks for __riscv_xlen == 64 to facilitate adding the 32-bit
   ABI in the future.

[1] https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md

Patch by Mitchell Horne (mhorne)

Reviewers: lenary, luismarques, compnerd, phosek

Reviewed By: lenary, luismarques

Subscribers: arichardson, sameer.abuasal, abidh, asb, aprantl, krytarowski, 
simoncook, kito-cheng, christof, shiva0217, rogfer01, rkruppe, PkmX, psnobl, 
benna, lenary, s.egerton, luismarques, emaste, cfe-commits

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

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/include/libunwind.h
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/config.h
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 6e7e5e6f7f86..4d03bd83d8c6 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -23,6 +23,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV 64
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__i386__)
@@ -118,6 +119,15 @@
   #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
   #define _LIBUNWIND_CONTEXT_SIZE 16
   #define _LIBUNWIND_CURSOR_SIZE 23
+# elif defined(__riscv)
+#  if __riscv_xlen == 64
+#define _LIBUNWIND_TARGET_RISCV 1
+#define _LIBUNWIND_CONTEXT_SIZE 64
+#define _LIBUNWIND_CURSOR_SIZE 76
+#  else
+#error "Unsupported RISC-V ABI"
+#  endif
+# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV
 # else
 #  error "Unsupported architecture."
 # endif
@@ -132,6 +142,7 @@
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
 # define _LIBUNWIND_TARGET_SPARC 1
+# define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

diff  --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index d06724d3c31f..1a501b867dda 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -832,4 +832,75 @@ enum {
   UNW_SPARC_I7 = 31,
 };
 
+// RISC-V registers. These match the DWARF register numbers defined by section
+// 4 of the RISC-V ELF psABI specification, which can be found at:
+//
+// https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md
+enum {
+  UNW_RISCV_X0  = 0,
+  UNW_RISCV_X1  = 1,
+  UNW_RISCV_X2  = 2,
+  UNW_RISCV_X3  = 3,
+  UNW_RISCV_X4  = 4,
+  UNW_RISCV_X5  = 5,
+  UNW_RISCV_X6  = 6,
+  UNW_RISCV_X7  = 7,
+  UNW_RISCV_X8  = 8,
+  UNW_RISCV_X9  = 9,
+  UNW_RISCV_X10 = 10,
+  UNW_RISCV_X11 = 11,
+  UNW_RISCV_X12 = 12,
+  UNW_RISCV_X13 = 13,
+  UNW_RISCV_X14 = 14,
+  UNW_RISCV_X15 = 15,
+  UNW_RISCV_X16 = 16,
+  UNW_RISCV_X17 = 17,
+  UNW_RISCV_X18 = 18,
+  UNW_RISCV_X19 = 19,
+  UNW_RISCV_X20 = 20,
+  UNW_RISCV_X21 = 21,
+  UNW_RISCV_X22 = 22,
+  UNW_RISCV_X23 = 23,
+  UNW_RISCV_X24 = 24,
+  UNW_RISCV_X25 = 25,
+  UNW_RISCV_X26 = 26,
+  UNW_RISCV_X27 = 27,
+  UNW_RISCV_X28 = 28,
+  UNW_RISCV_X29 = 29,
+  UNW_RISCV_X30 = 30,
+  UNW_RISCV_X31 = 31,
+  UNW_RISCV_F0  = 32,
+  UNW_RISCV_F1  = 33,
+  UNW_RISCV_F2  = 34,
+  UNW_RISCV_F3  = 35,
+  UNW_RISCV_F4  = 36,
+  UNW_RISCV_F5  = 37,
+  UNW_RISCV_F6  = 38,
+  UNW_RISCV_F7  = 39,
+  UNW_RISCV_F8  = 40,
+  UNW_RISCV_F9  = 41,
+  UNW_RISCV_F10 = 42,
+  UNW_RISCV_F11 = 43,
+  UNW_RISCV_F12 = 44,
+  UNW_RISCV_F13 = 45,
+  UNW_RISCV_F14 = 46,
+  UNW_RISCV_F15 = 47,
+  UNW_RISCV_F16 = 48,
+  UNW_RISCV_F17 = 49,
+  UNW_RISCV_F18 = 50,
+  UNW_RISCV_F19 = 51,
+  UNW_RISCV_F20 = 52,
+  UNW_RISCV_F21 = 53,
+  UNW_RISCV_F22 = 54,
+  UNW_RISCV_F23 = 55,
+  UNW_RISCV_F24 = 56,
+  UNW_RISCV_F25 = 57,
+  UNW_RISCV_F26 = 58,
+  UNW_RISCV_F27 = 59,
+  UNW_RISCV_F28 = 60,
+  UNW_RISCV_F29 = 61,
+  UNW_RISCV_F30 = 62,
+  UNW_RISCV_F31 = 63,
+};
+
 #endif

diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
in

[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-16 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.

> More performance data was posted on 
> http://lists.llvm.org/pipermail/llvm-dev/2019-December/137609.html and 
> http://lists.llvm.org/pipermail/llvm-dev/2019-December/137610.html. Let's 
> move on based on the data.

Based on the SPEC data, we observed 2.6% and 1.3% performance effect in INTRATE 
and FPRATE geomean respectively. Performance effect on individual components 
were observed up to 5.1%.

The tool SW mitigation can recover the geomean to within 99% of the original 
performance with prefix padding to jcc+jmp+fused. The maximum performance loss 
was reduced to within 2.2% of the original one.

The prefix padding can provide better performance as 0.3%~0.5% in geomean than 
nop padding on system with micro update. In individual cases, we observed up to 
1.4% performance improvement in prefix padding. On a system w/o micro update, 
we observed 0.7% better performance of prefix padding on INTRATE geomean.

In this SPEC test, the prefix padding to jcc+jmp+fused and prefix padding to 
all branches has almost the same performance. However, we observed the latter 
prefix padding had a little bit better performance than the previous one in 
some cases at the cost of code size.

Since the performance delta in prefix padding and nop padding is incremental, 
starting from nop padding may be easier to implement as a first step, with 
additional prefix padding options to explore for additional performance 
optimizations.

And since the current update enables a relatively simple and general solution 
to mitigate JCC microcode update (MCU) performance effects to both C/C++ and 
Assembly without any source code change, we recommend it as a starting point. 
Then, the proposal for compiler to generate directives could enable further 
enhancements.


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

https://reviews.llvm.org/D70157



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


[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2019-12-16 Thread Scott Egerton via Phabricator via cfe-commits
s.egerton created this revision.
s.egerton added reviewers: asb, simoncook, lewis-revill, PaoloS, lenary.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, johnrusso, rbar.
Herald added a project: clang.

This adds the __riscv_bitmanip macro and the 'b' target feature to enable it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71553

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,6 +331,9 @@
 case 'c':
   Features.push_back("+c");
   break;
+case 'b':
+  Features.push_back("+b");
+  break;
 }
   }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -30,11 +30,12 @@
   bool HasF;
   bool HasD;
   bool HasC;
+  bool HasB;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false) {
+HasD(false), HasC(false), HasB(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -125,6 +125,10 @@
 
   if (HasC)
 Builder.defineMacro("__riscv_compressed");
+
+  if (HasB) {
+Builder.defineMacro("__riscv_bitmanip");
+  }
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -139,6 +143,7 @@
   .Case("f", HasF)
   .Case("d", HasD)
   .Case("c", HasC)
+  .Case("b", HasB)
   .Default(false);
 }
 
@@ -156,6 +161,8 @@
   HasD = true;
 else if (Feature == "+c")
   HasC = true;
+else if (Feature == "+b")
+  HasB = true;
   }
 
   return true;


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,6 +331,9 @@
 case 'c':
   Features.push_back("+c");
   break;
+case 'b':
+  Features.push_back("+b");
+  break;
 }
   }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -30,11 +30,12 @@
   bool HasF;
   bool HasD;
   bool HasC;
+  bool HasB;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false) {
+HasD(false), HasC(false), HasB(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -125,6 +125,10 @@
 
   if (HasC)
 Builder.defineMacro("__riscv_compressed");
+
+  if (HasB) {
+Builder.defineMacro("__riscv_bitmanip");
+  }
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -139,6 +143,7 @@
   .Case("f", HasF)
   .Case("d", HasD)
   .Case("c", HasC)
+  .Case("b", HasB)
   .Default(false);
 }
 
@@ -156,6 +161,8 @@
   HasD = true;
 else if (Feature == "+c")
   HasC = true;
+else if (Feature == "+b")
+  HasB = true;
   }
 
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added a reviewer: rupprecht.
Herald added subscribers: llvm-commits, cfe-commits, krytarowski, emaste.
Herald added projects: clang, LLVM.
arichardson updated this revision to Diff 234082.
arichardson added a comment.

Drop unrelated change


I have been trying to build CheriBSD (a fork for FreeBSD for the CHERI
CPU) with LLVM binutils instead of the default elftoolchain utilities.
I noticed that building static archives was failing because ranlib is
invoked with the -D flag. This failed with llvm-ranlib since it parses
the -D flag as the archive path and reports an error that more than one
archive has been passed.

This fixes https://llvm.org/PR41707


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71554

Files:
  llvm/test/tools/llvm-ranlib/D-flag.test
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -64,8 +64,10 @@
 USAGE: llvm-ranlib 
 
 OPTIONS:
-  -h --help - Display available options
-  --version - Display the version of this program
+  -h --help - Display available options
+  --version - Display the version of this program
+  -D- Use zero for timestamps and uids/gids (default)
+  -U- Use actual timestamps and uids/gids
 )";
 
 const char ArHelp[] = R"(OVERVIEW: LLVM Archiver
@@ -1156,13 +1158,27 @@
 static int ranlib_main(int argc, char **argv) {
   bool ArchiveSpecified = false;
   for (int i = 1; i < argc; ++i) {
-if (handleGenericOption(argv[i])) {
+StringRef arg(argv[i]);
+if (handleGenericOption(arg)) {
   return 0;
+} else if (arg.consume_front("-")) {
+  // Handle the -D/-U flag
+  while (!arg.empty()) {
+if (arg.front() == 'D') {
+  Deterministic = true;
+} else if (arg.front() == 'U') {
+  Deterministic = false;
+} else {
+  // TODO: GNU ranlib also supports a -t flag
+  fail("Invalid option: '-" + arg + "'");
+}
+arg = arg.drop_front(1);
+  }
 } else {
   if (ArchiveSpecified)
 fail("exactly one archive should be specified");
   ArchiveSpecified = true;
-  ArchiveName = argv[i];
+  ArchiveName = arg.str();
 }
   }
   if (!ArchiveSpecified) {
Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- /dev/null
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -0,0 +1,47 @@
+## Test the -D and -U flags of llvm-ranlib
+## Create an archive with timestamps but without symbol table
+# RUN: yaml2obj %S/../llvm-ar/Inputs/add-lib1.yaml -o %t.o
+# RUN: rm -f %t.a %t-no-index.a && llvm-ar cqSU %t-no-index.a %t.o
+
+## Check that the intial listing has real values:
+# RUN: llvm-ar tv %t-no-index.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that the -D flag clears the timestamps:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
+# RUN: llvm-ar tv %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+
+## Check that the -U flag maintains the timestamps:
+# RUN: llvm-ar tv %t-no-index.a | FileCheck %s --check-prefix=REAL-VALUES
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that we accept multiple values and the last one wins:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+
+## Check arguments can be passed before and after the file name
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a -D -U
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that the -D/-U option is only accepted with a single dash. This 
matches
+## the GNU ranlib behaviour.
+# RUN: not llvm-ranlib --D %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-D
+# BAD-OPT-D: llvm-ranlib: error: Invalid option: '--D'
+# RUN: not llvm-ranlib --U %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-U
+# BAD-OPT-U: llvm-ranlib: error: Invalid option: '--U'
+# RUN: not llvm-ranlib -x %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# BAD-OPT-x: llvm-ranlib: error: Invalid option: '-x'
+
+## If the first argument starts with value flags, the error message only shows
+## the remainder of the parsed string:
+# RUN: not llvm-ranlib -Dx %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
+# BAD-OPT-xD: llvm-ranlib: error: Invalid option: '-xD'
+
+# DETERMINISTIC-VALUES: rw-r--r-- 0/0712 Jan  1 01:00 1970 
D-flag.test.tmp.o
+# REAL-VALUES: rw-r--r-- {{[0-9]+}}/{{[0-9]+}} 712
+# REAL-VALUES-NOT: 197

[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234082.
arichardson added a comment.

Drop unrelated change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554

Files:
  llvm/test/tools/llvm-ranlib/D-flag.test
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -64,8 +64,10 @@
 USAGE: llvm-ranlib 
 
 OPTIONS:
-  -h --help - Display available options
-  --version - Display the version of this program
+  -h --help - Display available options
+  --version - Display the version of this program
+  -D- Use zero for timestamps and uids/gids (default)
+  -U- Use actual timestamps and uids/gids
 )";
 
 const char ArHelp[] = R"(OVERVIEW: LLVM Archiver
@@ -1156,13 +1158,27 @@
 static int ranlib_main(int argc, char **argv) {
   bool ArchiveSpecified = false;
   for (int i = 1; i < argc; ++i) {
-if (handleGenericOption(argv[i])) {
+StringRef arg(argv[i]);
+if (handleGenericOption(arg)) {
   return 0;
+} else if (arg.consume_front("-")) {
+  // Handle the -D/-U flag
+  while (!arg.empty()) {
+if (arg.front() == 'D') {
+  Deterministic = true;
+} else if (arg.front() == 'U') {
+  Deterministic = false;
+} else {
+  // TODO: GNU ranlib also supports a -t flag
+  fail("Invalid option: '-" + arg + "'");
+}
+arg = arg.drop_front(1);
+  }
 } else {
   if (ArchiveSpecified)
 fail("exactly one archive should be specified");
   ArchiveSpecified = true;
-  ArchiveName = argv[i];
+  ArchiveName = arg.str();
 }
   }
   if (!ArchiveSpecified) {
Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- /dev/null
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -0,0 +1,47 @@
+## Test the -D and -U flags of llvm-ranlib
+## Create an archive with timestamps but without symbol table
+# RUN: yaml2obj %S/../llvm-ar/Inputs/add-lib1.yaml -o %t.o
+# RUN: rm -f %t.a %t-no-index.a && llvm-ar cqSU %t-no-index.a %t.o
+
+## Check that the intial listing has real values:
+# RUN: llvm-ar tv %t-no-index.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that the -D flag clears the timestamps:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
+# RUN: llvm-ar tv %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+
+## Check that the -U flag maintains the timestamps:
+# RUN: llvm-ar tv %t-no-index.a | FileCheck %s --check-prefix=REAL-VALUES
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that we accept multiple values and the last one wins:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+
+## Check arguments can be passed before and after the file name
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a -D -U
+# RUN: llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that the -D/-U option is only accepted with a single dash. This 
matches
+## the GNU ranlib behaviour.
+# RUN: not llvm-ranlib --D %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-D
+# BAD-OPT-D: llvm-ranlib: error: Invalid option: '--D'
+# RUN: not llvm-ranlib --U %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-U
+# BAD-OPT-U: llvm-ranlib: error: Invalid option: '--U'
+# RUN: not llvm-ranlib -x %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# BAD-OPT-x: llvm-ranlib: error: Invalid option: '-x'
+
+## If the first argument starts with value flags, the error message only shows
+## the remainder of the parsed string:
+# RUN: not llvm-ranlib -Dx %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
+# BAD-OPT-xD: llvm-ranlib: error: Invalid option: '-xD'
+
+# DETERMINISTIC-VALUES: rw-r--r-- 0/0712 Jan  1 01:00 1970 
D-flag.test.tmp.o
+# REAL-VALUES: rw-r--r-- {{[0-9]+}}/{{[0-9]+}} 712
+# REAL-VALUES-NOT: 1970
+# REAL-VALUES-SAME: D-flag.test.tmp.o


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -64,8 +64,10 @@
 USAGE: llvm-ranlib 
 
 OPTIONS:
-  -h --help - Display available options
-  --version - Display the version of this program
+  -h --help - Display available options
+  --version - Display the version of this program
+  -D   

[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-16 Thread Sam Elliott via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce3d1c6d61dc: [libunwind][RISCV] Add 64-bit RISC-V support 
(authored by lenary).
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68362

Files:
  libunwind/include/__libunwind_config.h
  libunwind/include/libunwind.h
  libunwind/src/Registers.hpp
  libunwind/src/UnwindCursor.hpp
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/UnwindRegistersSave.S
  libunwind/src/config.h
  libunwind/src/libunwind.cpp

Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -58,6 +58,8 @@
 # warning The MIPS architecture is not supported with this ABI and environment!
 #elif defined(__sparc__)
 # define REGISTER_KIND Registers_sparc
+#elif defined(__riscv) && __riscv_xlen == 64
+# define REGISTER_KIND Registers_riscv
 #else
 # error Architecture not supported
 #endif
Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -103,7 +103,8 @@
 defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) ||\
 (!defined(__APPLE__) && defined(__arm__)) ||   \
 (defined(__arm64__) || defined(__aarch64__)) ||\
-defined(__mips__)
+defined(__mips__) ||   \
+defined(__riscv)
 #if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif
Index: libunwind/src/UnwindRegistersSave.S
===
--- libunwind/src/UnwindRegistersSave.S
+++ libunwind/src/UnwindRegistersSave.S
@@ -974,6 +974,86 @@
   std %i6, [%o0 + 120]
   jmp %o7
clr %o0   // return UNW_ESUCCESS
+
+#elif defined(__riscv) && __riscv_xlen == 64
+
+#
+# extern int __unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0
+#
+DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+  // x0 is zero
+  sdx1, (8 * 1)(a0)
+  sdx2, (8 * 2)(a0)
+  sdx3, (8 * 3)(a0)
+  sdx4, (8 * 4)(a0)
+  sdx5, (8 * 5)(a0)
+  sdx6, (8 * 6)(a0)
+  sdx7, (8 * 7)(a0)
+  sdx8, (8 * 8)(a0)
+  sdx9, (8 * 9)(a0)
+  sdx10, (8 * 10)(a0)
+  sdx11, (8 * 11)(a0)
+  sdx12, (8 * 12)(a0)
+  sdx13, (8 * 13)(a0)
+  sdx14, (8 * 14)(a0)
+  sdx15, (8 * 15)(a0)
+  sdx16, (8 * 16)(a0)
+  sdx17, (8 * 17)(a0)
+  sdx18, (8 * 18)(a0)
+  sdx19, (8 * 19)(a0)
+  sdx20, (8 * 20)(a0)
+  sdx21, (8 * 21)(a0)
+  sdx22, (8 * 22)(a0)
+  sdx23, (8 * 23)(a0)
+  sdx24, (8 * 24)(a0)
+  sdx25, (8 * 25)(a0)
+  sdx26, (8 * 26)(a0)
+  sdx27, (8 * 27)(a0)
+  sdx28, (8 * 28)(a0)
+  sdx29, (8 * 29)(a0)
+  sdx30, (8 * 30)(a0)
+  sdx31, (8 * 31)(a0)
+
+#if defined(__riscv_flen) && __riscv_flen == 64
+  fsdf0, (8 * 32 + 8 * 0)(a0)
+  fsdf1, (8 * 32 + 8 * 1)(a0)
+  fsdf2, (8 * 32 + 8 * 2)(a0)
+  fsdf3, (8 * 32 + 8 * 3)(a0)
+  fsdf4, (8 * 32 + 8 * 4)(a0)
+  fsdf5, (8 * 32 + 8 * 5)(a0)
+  fsdf6, (8 * 32 + 8 * 6)(a0)
+  fsdf7, (8 * 32 + 8 * 7)(a0)
+  fsdf8, (8 * 32 + 8 * 8)(a0)
+  fsdf9, (8 * 32 + 8 * 9)(a0)
+  fsdf10, (8 * 32 + 8 * 10)(a0)
+  fsdf11, (8 * 32 + 8 * 11)(a0)
+  fsdf12, (8 * 32 + 8 * 12)(a0)
+  fsdf13, (8 * 32 + 8 * 13)(a0)
+  fsdf14, (8 * 32 + 8 * 14)(a0)
+  fsdf15, (8 * 32 + 8 * 15)(a0)
+  fsdf16, (8 * 32 + 8 * 16)(a0)
+  fsdf17, (8 * 32 + 8 * 17)(a0)
+  fsdf18, (8 * 32 + 8 * 18)(a0)
+  fsdf19, (8 * 32 + 8 * 19)(a0)
+  fsdf20, (8 * 32 + 8 * 20)(a0)
+  fsdf21, (8 * 32 + 8 * 21)(a0)
+  fsdf22, (8 * 32 + 8 * 22)(a0)
+  fsdf23, (8 * 32 + 8 * 23)(a0)
+  fsdf24, (8 * 32 + 8 * 24)(a0)
+  fsdf25, (8 * 32 + 8 * 25)(a0)
+  fsdf26, (8 * 32 + 8 * 26)(a0)
+  fsdf27, (8 * 32 + 8 * 27)(a0)
+  fsdf28, (8 * 32 + 8 * 28)(a0)
+  fsdf29, (8 * 32 + 8 * 29)(a0)
+  fsdf30, (8 * 32 + 8 * 30)(a0)
+  fsdf31, (8 * 32 + 8 * 31)(a0)
+#endif
+
+  li a0, 0  // return UNW_ESUCCESS
+  ret   // jump to ra
 #endif
 
   WEAK_ALIAS(__unw_getcontext, unw_getcontext)
Index: libunwind/src/UnwindRegistersRestore.S
===
--- libunwind/src/UnwindRegistersRestore.S
+++ libunwind/src/UnwindRegistersRestore.S
@@ -1029,6 +1029,87 @@
   jmp %o7
nop
 
+#elif defined(__riscv) && __riscv_xlen == 64
+
+//
+// void libunwind::Registers_riscv::jumpto()
+//
+// On entry:
+//  thread_state pointer is in a0
+//
+  .p2align 2
+DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv)
+#if defined(__riscv_flen) && __riscv_flen ==

[PATCH] D71555: [clangd] Refurbish HoverInfo::present

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Improves basic hover presentation logic to include more info.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71555

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/test/hover.test
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1439,6 +1439,207 @@
   }
 }
 
+TEST(Hover, Present) {
+  struct {
+const std::function Builder;
+llvm::StringRef ExpectedRender;
+  } Cases[] = {
+  // Basic coverage tests.
+  {
+  [](HoverInfo &HI) { HI.Kind = index::SymbolKind::Unknown; },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+  },
+  R"pt(Class foo)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::NamespaceAlias;
+HI.Name = "foo";
+  },
+  R"pt(Namespace Alias foo)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Type = "type";
+  },
+  R"pt(Class type)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+HI.Type = "type";
+  },
+  R"pt(Class foo : type)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+HI.Type = "type";
+HI.ReturnType = "ret_type";
+  },
+  R"pt(Class foo
+Returns: ret_type)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Parameters.emplace(); },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Parameters.emplace();
+HoverInfo::Param P;
+HI.Parameters->push_back(P);
+P.Type = "type";
+HI.Parameters->push_back(P);
+P.Name = "foo";
+HI.Parameters->push_back(P);
+P.Default = "default";
+HI.Parameters->push_back(P);
+  },
+  R"pt(
+- 
+- type
+- type foo
+- type foo = default)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Value = "value"; },
+  R"pt(
+Value: value)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Documentation = "doc"; },
+  R"pt(
+doc)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.NamespaceScope = ""; },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Definition = "def"; },
+  R"pt(
+
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "";
+  },
+  R"pt(
+
+// global namespace
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "ns::";
+  },
+  R"pt(
+
+// namespace ns
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "";
+HI.LocalScope = "test::bar::";
+  },
+  R"pt(
+
+// In test::bar
+def)pt",
+  },
+  // Behaviour checks.
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "Foo";
+HI.NamespaceScope = "";
+HI.TemplateParameters = {
+{std::string("typename"), std::string("T"), llvm::None},
+{std::string("typename"), std::string("C"),
+ std::string("bool")},
+};
+HI.Definition =
+"template  class Foo {}";
+  },
+  R"pt(Class Foo
+
+// global namespace
+template  class Foo {})pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::InstanceMethod;
+HI.Name = "baz";
+HI.NamespaceScope = "";
+HI.LocalScope = "Foo::";
+HI.Parameters = {
+{std::string("int"), std::string("foo"), std::string("3")},
+};
+HI.ReturnType = "int";
+HI.Definition = "constexpr int baz(int foo = 3)";
+  },
+  R"pt(Instance Method baz
+Returns: int
+- int foo = 3
+
+// In Foo
+constexpr int baz(int foo = 3))pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Parameter;
+HI.Name = "foo";
+HI.NamespaceScope = "";
+HI.LocalScope = "Fo

[PATCH] D71555: [clangd] Refurbish HoverInfo::present

2019-12-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 234087.
kadircet added a comment.

- Get rid of irrelevant change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71555

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1439,6 +1439,207 @@
   }
 }
 
+TEST(Hover, Present) {
+  struct {
+const std::function Builder;
+llvm::StringRef ExpectedRender;
+  } Cases[] = {
+  // Basic coverage tests.
+  {
+  [](HoverInfo &HI) { HI.Kind = index::SymbolKind::Unknown; },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+  },
+  R"pt(Class foo)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::NamespaceAlias;
+HI.Name = "foo";
+  },
+  R"pt(Namespace Alias foo)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Type = "type";
+  },
+  R"pt(Class type)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+HI.Type = "type";
+  },
+  R"pt(Class foo : type)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "foo";
+HI.Type = "type";
+HI.ReturnType = "ret_type";
+  },
+  R"pt(Class foo
+Returns: ret_type)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Parameters.emplace(); },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Parameters.emplace();
+HoverInfo::Param P;
+HI.Parameters->push_back(P);
+P.Type = "type";
+HI.Parameters->push_back(P);
+P.Name = "foo";
+HI.Parameters->push_back(P);
+P.Default = "default";
+HI.Parameters->push_back(P);
+  },
+  R"pt(
+- 
+- type
+- type foo
+- type foo = default)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Value = "value"; },
+  R"pt(
+Value: value)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Documentation = "doc"; },
+  R"pt(
+doc)pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.NamespaceScope = ""; },
+  R"pt()pt",
+  },
+  {
+  [](HoverInfo &HI) { HI.Definition = "def"; },
+  R"pt(
+
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "";
+  },
+  R"pt(
+
+// global namespace
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "ns::";
+  },
+  R"pt(
+
+// namespace ns
+def)pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Definition = "def";
+HI.NamespaceScope = "";
+HI.LocalScope = "test::bar::";
+  },
+  R"pt(
+
+// In test::bar
+def)pt",
+  },
+  // Behaviour checks.
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Class;
+HI.Name = "Foo";
+HI.NamespaceScope = "";
+HI.TemplateParameters = {
+{std::string("typename"), std::string("T"), llvm::None},
+{std::string("typename"), std::string("C"),
+ std::string("bool")},
+};
+HI.Definition =
+"template  class Foo {}";
+  },
+  R"pt(Class Foo
+
+// global namespace
+template  class Foo {})pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::InstanceMethod;
+HI.Name = "baz";
+HI.NamespaceScope = "";
+HI.LocalScope = "Foo::";
+HI.Parameters = {
+{std::string("int"), std::string("foo"), std::string("3")},
+};
+HI.ReturnType = "int";
+HI.Definition = "constexpr int baz(int foo = 3)";
+  },
+  R"pt(Instance Method baz
+Returns: int
+- int foo = 3
+
+// In Foo
+constexpr int baz(int foo = 3))pt",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Parameter;
+HI.Name = "foo";
+HI.NamespaceScope = "";
+HI.LocalScope = "Foo::baz";
+HI.Type = "int";
+HI.Value = "3";
+HI.Definition = "int foo = 3";
+  },
+

[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 60962 tests passed, 1 failed 
and 726 were skipped.

  failed: LLVM.tools/llvm-ranlib/D-flag.test

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554



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


[PATCH] D71555: [clangd] Refurbish HoverInfo::present

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71555



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


[PATCH] D71555: [clangd] Refurbish HoverInfo::present

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71555



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-12-16 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill marked an inline comment as done.
lewis-revill added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:289
   unsigned CFIIndex = MF.addFrameInst(
   MCCFIInstruction::createDefCfaOffset(nullptr, -StackSize));
   BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION))

shiva0217 wrote:
> Should the -StackSize be -RealStackSize?
Looks like it, good catch.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:668
+.setMIFlag(MachineInstr::FrameSetup);
+
+// Add registers spilled in libcall as liveins.

shiva0217 wrote:
> GCC will generate stack adjustment and GPR callee saved CFIs for the save 
> libcalls. Should we do the same?
I'm not familiar with the use of the CFI offset stuff, though just to be sure, 
you're saying that in addition to the manually-added `.cfi_offset`s in the 
libcalls themselves we would want to add them in our frame too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 60962 tests passed, 1 failed 
and 726 were skipped.

  failed: LLVM.tools/llvm-ranlib/D-flag.test

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D71508#1785767 , @probinson wrote:

> Do we have a similar problem if the filespec has an embedded ./ or ../ in it?


problems  occur only when filespec starts with ./ otherwise it's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234088.
arichardson added a comment.

Force UTC timezone for reproducible results


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554

Files:
  llvm/test/tools/llvm-ranlib/D-flag.test
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -64,8 +64,10 @@
 USAGE: llvm-ranlib 
 
 OPTIONS:
-  -h --help - Display available options
-  --version - Display the version of this program
+  -h --help - Display available options
+  --version - Display the version of this program
+  -D- Use zero for timestamps and uids/gids (default)
+  -U- Use actual timestamps and uids/gids
 )";
 
 const char ArHelp[] = R"(OVERVIEW: LLVM Archiver
@@ -1156,13 +1158,27 @@
 static int ranlib_main(int argc, char **argv) {
   bool ArchiveSpecified = false;
   for (int i = 1; i < argc; ++i) {
-if (handleGenericOption(argv[i])) {
+StringRef arg(argv[i]);
+if (handleGenericOption(arg)) {
   return 0;
+} else if (arg.consume_front("-")) {
+  // Handle the -D/-U flag
+  while (!arg.empty()) {
+if (arg.front() == 'D') {
+  Deterministic = true;
+} else if (arg.front() == 'U') {
+  Deterministic = false;
+} else {
+  // TODO: GNU ranlib also supports a -t flag
+  fail("Invalid option: '-" + arg + "'");
+}
+arg = arg.drop_front(1);
+  }
 } else {
   if (ArchiveSpecified)
 fail("exactly one archive should be specified");
   ArchiveSpecified = true;
-  ArchiveName = argv[i];
+  ArchiveName = arg.str();
 }
   }
   if (!ArchiveSpecified) {
Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- /dev/null
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -0,0 +1,45 @@
+## Test the -D and -U flags of llvm-ranlib
+## Create an archive with timestamps but without symbol table
+## Important: all `llvm-ar tv` calls must use TZ=UTC to produce identical 
values
+# RUN: yaml2obj %S/../llvm-ar/Inputs/add-lib1.yaml -o %t.o
+# RUN: env TZ=UTC touch -t 21020304 %t.o
+# RUN: rm -f %t.a %t-no-index.a && llvm-ar cqSU %t-no-index.a %t.o
+
+## Check that the intial listing has real values:
+# RUN: env TZ=UTC llvm-ar tv %t-no-index.a | FileCheck %s 
--check-prefix=REAL-VALUES
+
+## Check that the -D flag clears the timestamps:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
+# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+
+## Check that the -U flag maintains the timestamps:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
+# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that we accept multiple values and the last one wins:
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a
+# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
+# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+
+## Check arguments can be passed before and after the file name
+# RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a -D -U
+# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
+
+## Check that the -D/-U option is only accepted with a single dash. This 
matches
+## the GNU ranlib behaviour.
+# RUN: not llvm-ranlib --D %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-D
+# BAD-OPT-D: llvm-ranlib: error: Invalid option: '--D'
+# RUN: not llvm-ranlib --U %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-U
+# BAD-OPT-U: llvm-ranlib: error: Invalid option: '--U'
+# RUN: not llvm-ranlib -x %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# BAD-OPT-x: llvm-ranlib: error: Invalid option: '-x'
+
+## If the first argument starts with value flags, the error message only shows
+## the remainder of the parsed string:
+# RUN: not llvm-ranlib -Dx %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-x
+# RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
+# BAD-OPT-xD: llvm-ranlib: error: Invalid option: '-xD'
+
+# DETERMINISTIC-VALUES: rw-r--r-- 0/0712 Jan  1 00:00 1970 
D-flag.test.tmp.o
+# REAL-VALUES: rw-r--r-- {{[0-9]+}}/{{[0-9]+}} 712 Jan  2 03:04 2000 
D-flag.test.tmp.o


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -64,8 +64,10 @@
 USAGE: llvm-ranlib 
 
 OPTIONS:
-  -h --help - Display available options
-  --version - Display the version of this program
+  -h --help - Display

[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2019-12-16 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

Thanks Scott, it should be relatively easy to add tests for this in 
'clang/test/Preprocessor/riscv-target-features.c' if you could.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71553



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-12-16 Thread James Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:668
+.setMIFlag(MachineInstr::FrameSetup);
+
+// Add registers spilled in libcall as liveins.

lewis-revill wrote:
> shiva0217 wrote:
> > GCC will generate stack adjustment and GPR callee saved CFIs for the save 
> > libcalls. Should we do the same?
> I'm not familiar with the use of the CFI offset stuff, though just to be 
> sure, you're saying that in addition to the manually-added `.cfi_offset`s in 
> the libcalls themselves we would want to add them in our frame too?
Yes. The CFI use is completely ignorant of any control flow. It goes to the 
start of the function, and walks forward, executing every `.cfi_*` directive 
until reaching the current point in the code. Since the libcalls (and thus 
their CFI directives) are not inline in the function, they are completely 
invisible to the CFI machinery. Thus, their side-effects must be duplicated 
straight after the calls to them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[clang] 878ab6d - [TLI] Support for per-Function TLI that overrides available libfuncs

2019-12-16 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2019-12-16T09:19:30-08:00
New Revision: 878ab6df033d44430939c02075ee00800995dc3b

URL: 
https://github.com/llvm/llvm-project/commit/878ab6df033d44430939c02075ee00800995dc3b
DIFF: 
https://github.com/llvm/llvm-project/commit/878ab6df033d44430939c02075ee00800995dc3b.diff

LOG: [TLI] Support for per-Function TLI that overrides available libfuncs

Summary:

Follow-on to D66428 and D71193, to build the TLI per-function so
that -fno-builtin* handling can be migrated to use function attributes.
See discussion on D61634 for background. This is an enabler for fixing
handling of these options for LTO, for example.

With D71193, the -fno-builtin* flags are converted to function
attributes, so we can now set this information per-function on the TLI.

In this patch, the TLI constructor is changed to take a Function, which
can be used to override the available builtins. The TLI is augmented
with an array that can be used to specify which builtins are not
available for the corresponding function. The available function checks
are changed to consult this override before checking the underlying
module level baseline TLII. New code is added to set this override
array based on the attributes.

I also removed the code that sets availability in the TLII in clang from
the options, which is no longer needed.

I removed a per-Triple caching of TLII objects in the analysis object,
as it is based on the Module's Triple which is the same for all
functions in any case. Is there a case where we would be compiling
multiple Modules with different Triples in one compilation?

Finally, I have changed the legacy analysis wrapper to create and use
the new PM analysis class (TargetLibraryAnalysis) in getTLI. This is
consistent with the behavior of getTTI for the legacy
TargetTransformInfo analysis. This change means that getTLI now creates
a new TLI on each call (although that should be very cheap as we cache
the module level TLII, and computing the per-function
attribute based availability should also be reasonably efficient).
I measured the compile time for a large C++ file with tens of thousands
of functions and as expected there was no increase.

Reviewers: chandlerc, hfinkel, gchatelet

Subscribers: mehdi_amini, dexonsmith, llvm-commits

Tags: #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Analysis/TargetLibraryInfo.h
llvm/lib/Analysis/TargetLibraryInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7cf6041bea91..9b1e91788346 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -339,15 +339,6 @@ static void addDataFlowSanitizerPass(const 
PassManagerBuilder &Builder,
 static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
  const CodeGenOptions &CodeGenOpts) {
   TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
-  if (!CodeGenOpts.SimplifyLibCalls)
-TLII->disableAllFunctions();
-  else {
-// Disable individual libc/libm calls in TargetLibraryInfo.
-LibFunc F;
-for (auto &FuncName : CodeGenOpts.getNoBuiltinFuncs())
-  if (TLII->getLibFunc(FuncName, F))
-TLII->setUnavailable(F);
-  }
 
   switch (CodeGenOpts.getVecLib()) {
   case CodeGenOptions::Accelerate:

diff  --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h 
b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index be6c8cd084ec..1bd9db756bb3 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Triple.h"
@@ -212,20 +213,50 @@ class TargetLibraryInfo {
   friend class TargetLibraryAnalysis;
   friend class TargetLibraryInfoWrapperPass;
 
+  /// The global (module level) TLI info.
   const TargetLibraryInfoImpl *Impl;
 
+  /// Support for -fno-builtin* options as function attributes, overrides
+  /// information in global TargetLibraryInfoImpl.
+  BitVector OverrideAsUnavailable;
+
 public:
-  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl) : Impl(&Impl) 
{}
+  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl,
+ Optional F = None)
+  : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
+if (!F)
+  return;
+if ((*F)->hasFnAttribute("no-builtins"))
+  disableAllFunctions();
+else {
+  // Disable individual libc/libm calls in TargetLibraryInfo.
+  LibFunc LF;
+  AttributeSet FnAttrs = (*F)->getAttributes().getFnAttributes();
+  for (const Attribute &Attr : FnAttrs) {
+if (!Attr.isStringAttribute(

[PATCH] D67923: [TLI] Support for per-Function TLI that overrides available libfuncs

2019-12-16 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 234090.
tejohnson added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67923

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp

Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1588,22 +1588,12 @@
   return I->ScalarFnName;
 }
 
-TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
+TargetLibraryInfo TargetLibraryAnalysis::run(const Function &F,
  FunctionAnalysisManager &) {
-  if (PresetInfoImpl)
-return TargetLibraryInfo(*PresetInfoImpl);
-
-  return TargetLibraryInfo(
-  lookupInfoImpl(Triple(F.getParent()->getTargetTriple(;
-}
-
-TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
-  std::unique_ptr &Impl =
-  Impls[T.normalize()];
-  if (!Impl)
-Impl.reset(new TargetLibraryInfoImpl(T));
-
-  return *Impl;
+  if (!BaselineInfoImpl)
+BaselineInfoImpl =
+TargetLibraryInfoImpl(Triple(F.getParent()->getTargetTriple()));
+  return TargetLibraryInfo(*BaselineInfoImpl, &F);
 }
 
 unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
@@ -1614,18 +1604,18 @@
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
-: ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
+: ImmutablePass(ID), TLA(TargetLibraryInfoImpl()) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
-: ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
+: ImmutablePass(ID), TLA(TargetLibraryInfoImpl(T)) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
 const TargetLibraryInfoImpl &TLIImpl)
-: ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
+: ImmutablePass(ID), TLA(TLIImpl) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
Index: llvm/include/llvm/Analysis/TargetLibraryInfo.h
===
--- llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Triple.h"
@@ -212,20 +213,50 @@
   friend class TargetLibraryAnalysis;
   friend class TargetLibraryInfoWrapperPass;
 
+  /// The global (module level) TLI info.
   const TargetLibraryInfoImpl *Impl;
 
+  /// Support for -fno-builtin* options as function attributes, overrides
+  /// information in global TargetLibraryInfoImpl.
+  BitVector OverrideAsUnavailable;
+
 public:
-  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl) : Impl(&Impl) {}
+  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl,
+ Optional F = None)
+  : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
+if (!F)
+  return;
+if ((*F)->hasFnAttribute("no-builtins"))
+  disableAllFunctions();
+else {
+  // Disable individual libc/libm calls in TargetLibraryInfo.
+  LibFunc LF;
+  AttributeSet FnAttrs = (*F)->getAttributes().getFnAttributes();
+  for (const Attribute &Attr : FnAttrs) {
+if (!Attr.isStringAttribute())
+  continue;
+auto AttrStr = Attr.getKindAsString();
+if (!AttrStr.consume_front("no-builtin-"))
+  continue;
+if (getLibFunc(AttrStr, LF))
+  setUnavailable(LF);
+  }
+}
+  }
 
   // Provide value semantics.
-  TargetLibraryInfo(const TargetLibraryInfo &TLI) : Impl(TLI.Impl) {}
-  TargetLibraryInfo(TargetLibraryInfo &&TLI) : Impl(TLI.Impl) {}
+  TargetLibraryInfo(const TargetLibraryInfo &TLI)
+  : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
+  TargetLibraryInfo(TargetLibraryInfo &&TLI)
+  : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
   TargetLibraryInfo &operator=(const TargetLibraryInfo &TLI) {
 Impl = TLI.Impl;
+OverrideAsUnavailable = TLI.OverrideAsUnavailable;
 return *this;
   }
   TargetLibraryInfo &operator=(TargetLibraryInfo &&TLI) {
 Impl = TLI.Impl;
+OverrideAsUnavailable = TLI.OverrideAsUnavailable;
 return *this;
   }
 
@@ -248,9 +279,27 @@
getLibFunc(*(CS.getCalledFunction()), F);
   }
 
+  /// Disables all builtins.
+  ///
+  /// This can be used for options like -fno-builtin.
+  void disableAllFunctions() LLVM_ATTRIBUTE_UNUSED {
+OverrideAsUnavailable.se

[PATCH] D71556: [AArch64][SVE] Implement intrinsic for non-faulting loads

2019-12-16 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, paulwalker-arm, efriedma, dancgr, 
mgudim.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Adds the llvm.aarch64.sve.ldnf1 intrinsic, adding a new
flag to MachineMemOperand (MONonFaulting)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71556

Files:
  llvm/include/llvm/CodeGen/MachineMemOperand.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define  @ldnf1b( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b:
+; CHECK: ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldnf1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_h:
+; CHECK: ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_h:
+; CHECK: ldnf1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldnf1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldnf1h_f16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+define  @ldnf1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_s:
+; CHECK: ldnf1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_s:
+; CHECK: ldnf1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_s:
+; CHECK: ldnf1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_s:
+; CHECK: ldnf1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldnf1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldnf1w_f32:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldnf1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_d:
+; CHECK: ldnf1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_d:
+; CHECK: ldnf1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_d:
+; CHECK: ldnf1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_d:
+; CHECK: ldnf1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w_d:
+; CHECK: ldnf1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1sw_d:
+; CHECK: ldnf1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1d( %pg, i64* %a) {
+; CHECK-LABEL: ldnf1d:
+;

[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 60963 tests passed, 0 failed 
and 726 were skipped.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D71508#1786122 , @kamleshbhalui 
wrote:

> In D71508#1785767 , @probinson wrote:
>
> > Do we have a similar problem if the filespec has an embedded ./ or ../ in 
> > it?
>
>
> problems  occur only when filespec starts with ./ otherwise it's fine.


So do other kinds of paths get canonicalized elsewhere?  I'm thinking if 
there's already a place that undoes embedded .. then it should handle leading . 
as well.

Is a leading .. okay or a problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D67923: [TLI] Support for per-Function TLI that overrides available libfuncs

2019-12-16 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG878ab6df033d: [TLI] Support for per-Function TLI that 
overrides available libfuncs (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67923

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp

Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1588,22 +1588,12 @@
   return I->ScalarFnName;
 }
 
-TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
+TargetLibraryInfo TargetLibraryAnalysis::run(const Function &F,
  FunctionAnalysisManager &) {
-  if (PresetInfoImpl)
-return TargetLibraryInfo(*PresetInfoImpl);
-
-  return TargetLibraryInfo(
-  lookupInfoImpl(Triple(F.getParent()->getTargetTriple(;
-}
-
-TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
-  std::unique_ptr &Impl =
-  Impls[T.normalize()];
-  if (!Impl)
-Impl.reset(new TargetLibraryInfoImpl(T));
-
-  return *Impl;
+  if (!BaselineInfoImpl)
+BaselineInfoImpl =
+TargetLibraryInfoImpl(Triple(F.getParent()->getTargetTriple()));
+  return TargetLibraryInfo(*BaselineInfoImpl, &F);
 }
 
 unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
@@ -1614,18 +1604,18 @@
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
-: ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
+: ImmutablePass(ID), TLA(TargetLibraryInfoImpl()) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
-: ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
+: ImmutablePass(ID), TLA(TargetLibraryInfoImpl(T)) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
 const TargetLibraryInfoImpl &TLIImpl)
-: ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
+: ImmutablePass(ID), TLA(TLIImpl) {
   initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
 }
 
Index: llvm/include/llvm/Analysis/TargetLibraryInfo.h
===
--- llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 #define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Triple.h"
@@ -212,20 +213,50 @@
   friend class TargetLibraryAnalysis;
   friend class TargetLibraryInfoWrapperPass;
 
+  /// The global (module level) TLI info.
   const TargetLibraryInfoImpl *Impl;
 
+  /// Support for -fno-builtin* options as function attributes, overrides
+  /// information in global TargetLibraryInfoImpl.
+  BitVector OverrideAsUnavailable;
+
 public:
-  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl) : Impl(&Impl) {}
+  explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl,
+ Optional F = None)
+  : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
+if (!F)
+  return;
+if ((*F)->hasFnAttribute("no-builtins"))
+  disableAllFunctions();
+else {
+  // Disable individual libc/libm calls in TargetLibraryInfo.
+  LibFunc LF;
+  AttributeSet FnAttrs = (*F)->getAttributes().getFnAttributes();
+  for (const Attribute &Attr : FnAttrs) {
+if (!Attr.isStringAttribute())
+  continue;
+auto AttrStr = Attr.getKindAsString();
+if (!AttrStr.consume_front("no-builtin-"))
+  continue;
+if (getLibFunc(AttrStr, LF))
+  setUnavailable(LF);
+  }
+}
+  }
 
   // Provide value semantics.
-  TargetLibraryInfo(const TargetLibraryInfo &TLI) : Impl(TLI.Impl) {}
-  TargetLibraryInfo(TargetLibraryInfo &&TLI) : Impl(TLI.Impl) {}
+  TargetLibraryInfo(const TargetLibraryInfo &TLI)
+  : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
+  TargetLibraryInfo(TargetLibraryInfo &&TLI)
+  : Impl(TLI.Impl), OverrideAsUnavailable(TLI.OverrideAsUnavailable) {}
   TargetLibraryInfo &operator=(const TargetLibraryInfo &TLI) {
 Impl = TLI.Impl;
+OverrideAsUnavailable = TLI.OverrideAsUnavailable;
 return *this;
   }
   TargetLibraryInfo &operator=(TargetLibraryInfo &&TLI) {
 Impl = TLI.Impl;
+OverrideAsUnavailable = TLI.OverrideAsUnavailable;
 return *this;
   }
 
@@ -248,9 +279,27 @@
getLibFunc(*(CS.getCalledFunction()), F);
   }
 
+  /// Disables all builtins.
+  ///
+  /// This can be used for op

[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread Ed Maste via Phabricator via cfe-commits
emaste added inline comments.



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:69
+  --version - Display the version of this program
+  -D- Use zero for timestamps and uids/gids (default)
+  -U- Use actual timestamps and uids/gids

file mode made reproducible too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554



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


[PATCH] D71554: [llvm-ranlib] Handle -D and -U command line flag

2019-12-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson marked an inline comment as done.
arichardson added inline comments.



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:69
+  --version - Display the version of this program
+  -D- Use zero for timestamps and uids/gids (default)
+  -U- Use actual timestamps and uids/gids

emaste wrote:
> file mode made reproducible too?
Does not seem like it, if I run chmod 400 on the .o file it still reports 
`r` with -D.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71554



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


[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2019-12-16 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand updated this revision to Diff 234096.
uweigand added a comment.

Added float (f32) test cases.


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

https://reviews.llvm.org/D71467

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  llvm/include/llvm/IR/IRBuilder.h

Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -1161,6 +1161,18 @@
 return MetadataAsValue::get(Context, ExceptMDS);
   }
 
+  Value *getConstrainedFPPredicate(CmpInst::Predicate Predicate) {
+assert(CmpInst::isFPPredicate(Predicate) &&
+   Predicate != CmpInst::FCMP_FALSE &&
+   Predicate != CmpInst::FCMP_TRUE &&
+   "Invalid constrained FP comparison predicate!");
+
+StringRef PredicateStr = CmpInst::getPredicateName(Predicate);
+auto *PredicateMDS = MDString::get(Context, PredicateStr);
+
+return MetadataAsValue::get(Context, PredicateMDS);
+  }
+
 public:
   Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "",
bool HasNUW = false, bool HasNSW = false) {
@@ -2308,12 +2320,41 @@
 
   Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
 const Twine &Name = "", MDNode *FPMathTag = nullptr) {
+if (IsFPConstrained)
+  return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmp,
+P, LHS, RHS, Name);
+
+if (auto *LC = dyn_cast(LHS))
+  if (auto *RC = dyn_cast(RHS))
+return Insert(Folder.CreateFCmp(P, LC, RC), Name);
+return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
+  }
+
+  Value *CreateFCmpS(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ const Twine &Name = "", MDNode *FPMathTag = nullptr) {
+if (IsFPConstrained)
+  return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmps,
+P, LHS, RHS, Name);
+
 if (auto *LC = dyn_cast(LHS))
   if (auto *RC = dyn_cast(RHS))
 return Insert(Folder.CreateFCmp(P, LC, RC), Name);
 return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), Name);
   }
 
+  CallInst *CreateConstrainedFPCmp(
+  Intrinsic::ID ID, CmpInst::Predicate P, Value *L, Value *R,
+  const Twine &Name = "",
+  Optional Except = None) {
+Value *PredicateV = getConstrainedFPPredicate(P);
+Value *ExceptV = getConstrainedFPExcept(Except);
+
+CallInst *C = CreateIntrinsic(ID, {L->getType()},
+  {L, R, PredicateV, ExceptV}, nullptr, Name);
+setConstrainedFPCallAttr(C);
+return C;
+  }
+
   //======//
   // Instruction creation methods: Other Instructions
   //======//
Index: clang/test/CodeGen/fpconstrained-cmp-float.c
===
--- /dev/null
+++ clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -0,0 +1,151 @@
+// RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP
+// RUN: %clang_cc1 -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
+// RUN: %clang_cc1 -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
+
+_Bool QuietEqual(float f1, float f2) {
+  // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2)
+
+  // FCMP: fcmp oeq float %{{.*}}, %{{.*}}
+  // IGNORE: call i1 @llvm.experimental.constrained.fcmp.f32(float %{{.*}}, float %{{.*}}, metadata !"oeq", metadata !"fpexcept.ignore")
+  // EXCEPT: call i1 @llvm.experimental.constrained.fcmp.f32(float %{{.*}}, float %{{.*}}, metadata !"oeq", metadata !"fpexcept.strict")
+  // MAYTRAP: call i1 @llvm.experimental.constrained.fcmp.f32(float %{{.*}}, float %{{.*}}, metadata !"oeq", metadata !"fpexcept.maytrap")
+  return f1 == f2;
+
+  // CHECK: ret
+}
+
+_Bool QuietNotEqual(float f1, float f2) {
+  // CHECK-LABEL: define {{.*}}i1 @QuietNotEqual(float %f1, float %f2)
+
+  // FCMP: fcmp une float %{{.*}}, %{{.*}}
+  // IGNORE: call i1 @llvm.experimental.constrained.fcmp.f32(float %{{.*}}, float %{{.*}}, metadata !"une", metadata !"fpexcept.ignore")
+  // EXCEPT: call i1 @llvm.experimental.con

[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7424
+ ParsedAttr &Attr) {
+  if (CurType->isFunctionType()) {
+State.getSema().Diag(Attr.getLoc(), diag::warn_type_attribute_wrong_type)

aaron.ballman wrote:
> aaron.ballman wrote:
> > NoQ wrote:
> > > xazax.hun wrote:
> > > > aaron.ballman wrote:
> > > > > xazax.hun wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > Is this correct, or should it be `if 
> > > > > > > > (!CurType->isFunctionType())`?
> > > > > > > I see now that this is only incorrect for the acquire attribute, 
> > > > > > > but not the other two.
> > > > > > I think we might consider it incorrect for the acquire as well. 
> > > > > > Because if we let the user put acquire on the function, it is 
> > > > > > ambiguous where to put the annotation. If we do not let them put on 
> > > > > > the function they are always forced to put on the return type to 
> > > > > > express this. But in case this kind of ambiguity is a feature and 
> > > > > > not a bug I can change the behavior.
> > > > > I guess I was considering the semantics as being acquire on a 
> > > > > function type applies to the non-void return value being the handle 
> > > > > and release on a function type applies to the only parameter being 
> > > > > passed to the function.
> > > > > 
> > > > > I don't think it makes sense to apply acquire or release semantics to 
> > > > > a handle type itself because that's not really part of the type 
> > > > > identity itself (it's not an "acquiring handle" or a "releasing 
> > > > > handle" -- I would think it's *both* at the same time), so I think 
> > > > > that's been throwing me for a loop with the latest round of patches 
> > > > > here. What I was imagining was that you should mark any place a 
> > > > > handle is created or released, which works almost-fine for parameters 
> > > > > (because you can mark the parameter declarations with an attribute). 
> > > > > It doesn't quite work for function pointers, however, because those 
> > > > > don't have parameters. e.g., `void (*fp)([[clang::acquire_handle]] 
> > > > > int &)` won't do what you expect, I believe. However, for functions 
> > > > > which return the acquired handle, there is no good place to write the 
> > > > > attribute except on the function itself (because, again, it's not a 
> > > > > property of the return type, but of the specific function's return 
> > > > > type). For those cases, I imagine you want the function *type* to be 
> > > > > what codifies that a handle is returned, because then it will work 
> > > > > with function pointers. For *using* a handle, I'm not certain what 
> > > > > the benefit is to having an attribute on each use -- that seems 
> > > > > likely for a user to forget to add an annotation somewhere and get 
> > > > > incorrect behavior. I would normally suggest that the attribute be 
> > > > > applied to the type declaration of the handle (e.g., through a 
> > > > > typedef), but if you want this to work with handles coming from 
> > > > > system headers (like file descriptors or sockets, etc) then will this 
> > > > > approach work?
> > > > Hmm. The problem is that a function might do multiple things with 
> > > > multiple handles, for example in Fuchsia there are functions that 
> > > > replacing a handle with another one. So I am afraid naively putting the 
> > > > attributes on the function type might end up being ambiguous sometimes. 
> > > > I totally agree with your argument about the annotation not being part 
> > > > of the type identity. If we do want to put this on the function type 
> > > > maybe we could do something similar to `nonnull` and enumerate 
> > > > parameter indices? What do you think? 
> > > > 
> > > > The `use` annotation might be a bit misleading. The user does not 
> > > > necessarily need to annotate all uses.
> > > > Let's consider the following function and a call:
> > > > ```
> > > > void f(int *handle);
> > > > close_handle(handle);
> > > > f(&handle); // What will this do?
> > > > ```
> > > > 
> > > > The function `f` would be free to do anything, like store the address 
> > > > of the handle in a global data structure, overwrite the closed handle 
> > > > and so on. The purpose of the `use` annotation is to tell the analyzer 
> > > > that none of this will happen, so we can safely diagnose a use after 
> > > > release. So the original idea was to annotate those functions that are 
> > > > guaranteed to never close, overwrite etc the handle.
> > > > For unannotated functions the analyzer will be conservative and assume 
> > > > that the code is OK. 
> > > I heard that type attributes are relatively scary and require a lot of 
> > > work to implement, and `nonnull`/`_Nonnull` is definitely one of the 
> > > historical examples of why they're scary. Like, you don't want to mess 
> > > w

Re: [clang-tools-extra] a0ff8cd - [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if token-after-cursor fails.

2019-12-16 Thread Ulrich Weigand via cfe-commits


Sam McCall wrote:

>LOG: [clangd] Reapply b60896fad926 Fall back to selecting
token-before-cursor if token-after-cursor fails.
>
>This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.

I believe this has caused a significant number of build bot failures,
with error messages along these lines:
(see
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/28908/steps/build%20stage%201/logs/stdio
)


In file included from /usr/include/c++/7/memory:64:0,

from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/llvm/include/llvm/ADT/Optional.h:22,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/../clang-tidy/ClangTidyOptions.h:13,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:12,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/usr/include/c++/7/bits/stl_construct.h: In instantiation of 'void
std::_Construct(_T1*, _Args&& ...) [with _T1 =
clang::clangd::Tweak::Selection; _Args = {const
clang::clangd::Tweak::Selection&}]':
/usr/include/c++/7/bits/stl_uninitialized.h:83:18:   required from 'static
_ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy
(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator =
__gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*; bool _TrivialValueTypes = false]'
/usr/include/c++/7/bits/stl_uninitialized.h:134:15:   required from
'_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*]'
/usr/include/c++/7/bits/stl_uninitialized.h:289:37:   required from
'_ForwardIterator std::__uninitialized_copy_a(_InputIterator,
_InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with
_InputIterator = __gnu_cxx::__normal_iterator >; _ForwardIterator =
clang::clangd::Tweak::Selection*; _Tp = clang::clangd::Tweak::Selection]'
/usr/include/c++/7/bits/stl_vector.h:331:31:   required from
'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with
_Tp = clang::clangd::Tweak::Selection; _Alloc =
std::allocator]'
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/llvm/include/llvm/Support/Error.h:483:5:
   required from 'llvm::Expected::Expected(OtherT&&, typename
std::enable_if::value>::type*) [with OtherT
= std::vector&; T =
std::vector; typename
std::enable_if::value>::type = void]'
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:394:10:
   required from here
/usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted
function 'clang::clangd::Tweak::Selection::Selection(const
clang::clangd::Tweak::Selection&)'
 { ::new(static_cast(__p)) _T1(std::forward<_Args>
(__args)...); }
   ^~
In file included
from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10:
 note: 'clang::clangd::Tweak::Selection::Selection(const
clang::clangd::Tweak::Selection&)' is implicitly deleted because the
default definition would be ill-formed:
   struct Selection {
  ^
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10:
 error: use of deleted function
'clang::clangd::SelectionTree::SelectionTree(const
clang::clangd::SelectionTree&)'
In file included
from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.h:28,


from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9:

/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang-tools-extra/clangd/Selection.h:96:3:
 note: declared here
   SelectionTree(const SelectionTree &) = delete;
   ^


Bye,
Ulrich
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2019-12-16 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D71467#1785943 , @erichkeane wrote:

> I did the compare operators that didn't work right, and will do a separate 
> patch for the fp-classification type ones: 
> f02d6dd6c7afc08f871a623c0411f2d77ed6acf8 
> 


Thanks!  Now I'm getting the correct output for the float test cases as well, 
and I've added them to the patch.

As to fp-classification, I think there is an additional complication here:  
according to IEEE and the proposed C2x standard, these builtins should 
**never** raise any exception, not even when receiving a signaling NaN as 
input.  Strictly speaking, this means that they cannot possibly be implemented 
in terms of any comparison operation.

Now, on SystemZ (and many other platforms, I think) there are in fact 
specialized instructions that will implement the required semantics without 
raising any exceptions, but there seems to be no way to represent those at the 
LLVM IR level.  We'll probably need some extensions here (some new IR-level 
builtins?) ...

(But I'd say that problem is unrelated to this patch, so I'd prefer to decouple 
that problem from the question of whether **this** patch is the right solution 
for comparisons.)


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

https://reviews.llvm.org/D71467



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


  1   2   3   >