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

2019-12-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1209
 // FIXME: Print template instantiation parameters.
-HI.Name = "initializer_list";
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;

Hang on, I think we're going round in circles with this design.

IIRC the idea was that `Name` doesn't include template parameters, signature, 
etc, so clients control rendering.

Isn't it easy to reconstitute this from the template argument list in the hover 
info?


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] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rsmith, rjmccall, rnk, Mordante.
Herald added a project: clang.

GCC 7 and earlier, when targeting MinGW, seems to have a bug in layout/size of 
bitfield structs if they contain a nested enum, making the size of the struct 8 
bytes, while we have a static assert requiring it to be 4 bytes or less.

While this clearly is a GCC bug, the workaround (moving the enum out of the 
bitfield) also is very nonintrusive and matches other existing enums there.

Testcase:

  $ cat bitfield.cpp
  struct MyStruct {
unsigned a : 1;
enum { SomeValue = 42 };
unsigned b : 1;
  };  
  int StructSize = sizeof(struct MyStruct);
  $ x86_64-w64-mingw32-g++ -S -o - bitfield.cpp | grep -C 2 StructSize 
  .file   "bitfield.cpp"
  .text
  .globl  StructSize
  .data
  .align 4
  StructSize:
  .long   8 
  .ident  "GCC: (GNU) 7.3-win32 20180312"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71650

Files:
  clang/include/clang/AST/Decl.h


Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -900,6 +900,8 @@
 DAK_Normal
   };
 
+  enum { NumScopeDepthOrObjCQualsBits = 7 };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -922,8 +924,6 @@
 /// Whether this parameter is an ObjC method parameter or not.
 unsigned IsObjCMethodParam : 1;
 
-enum { NumScopeDepthOrObjCQualsBits = 7 };
-
 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
 /// Otherwise, the number of function parameter scopes enclosing
 /// the function parameter scope in which this parameter was
@@ -1654,7 +1654,7 @@
   }
 
   static constexpr unsigned getMaxFunctionScopeDepth() {
-return (1u << ParmVarDeclBitfields::NumScopeDepthOrObjCQualsBits) - 1;
+return (1u << NumScopeDepthOrObjCQualsBits) - 1;
   }
 
   /// Returns the index of this parameter in its prototype or method scope.


Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -900,6 +900,8 @@
 DAK_Normal
   };
 
+  enum { NumScopeDepthOrObjCQualsBits = 7 };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -922,8 +924,6 @@
 /// Whether this parameter is an ObjC method parameter or not.
 unsigned IsObjCMethodParam : 1;
 
-enum { NumScopeDepthOrObjCQualsBits = 7 };
-
 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
 /// Otherwise, the number of function parameter scopes enclosing
 /// the function parameter scope in which this parameter was
@@ -1654,7 +1654,7 @@
   }
 
   static constexpr unsigned getMaxFunctionScopeDepth() {
-return (1u << ParmVarDeclBitfields::NumScopeDepthOrObjCQualsBits) - 1;
+return (1u << NumScopeDepthOrObjCQualsBits) - 1;
   }
 
   /// Returns the index of this parameter in its prototype or method scope.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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



Comment at: clang-tools-extra/clangd/XRefs.cpp:687
 
-  const Decl *D = Decls[0];
+  const Decl *D = nullptr;
+  for (const Decl *Candidate : Decls) {

maybe just
```
const Decl *D = Decls.front()
for(const auto *C : Decls) {
  if(isa(C)) {
D = C;
break;
  }
}
```



Comment at: clang-tools-extra/clangd/XRefs.cpp:773
+  // specializations, so if we have one, use the template pattern instead.
+  if (auto *CTSD = dyn_cast(CXXRD)) {
+CXXRD = CTSD->getTemplateInstantiationPattern();

nit: no need for braces



Comment at: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp:418
+  EXPECT_THAT(*Result,
+  AllOf(WithName("S<0>"), WithKind(SymbolKind::Struct), 
Parents()));
 }

what about making use of template pattern in case of invalid instantiations?

as type hierarchy tries to provide information regarding `bases` and 
`children`, I think it is more important to show those instead of template 
instantiation arguments.



Comment at: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp:464
 
+TEST(TypeHierarchy, DeriveFromImplicitSpec) {
+  Annotations Source(R"cpp(

can you also add a case for deriving from explicit (partial) specialization and 
type hierarchy on instantiation of a different pattern?
e.g.

```
template  class X {};
template  class X {};

struct Child : X {};

X fo^o;
```


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] D71554: [llvm-ranlib] Handle -D and -U command line flag

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

Also handle -h/-v as short options. Does the adjusted test look okay?


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/test/tools/llvm-ranlib/help-message.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
+  -v --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,33 @@
 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 if (arg.front() == 'h') {
+printHelpMessage();
+return 0;
+} else if (arg.front() == 'v') {
+cl::PrintVersionMessage();
+return 0;
+} 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/help-message.test
===
--- llvm/test/tools/llvm-ranlib/help-message.test
+++ llvm/test/tools/llvm-ranlib/help-message.test
@@ -1,8 +1,17 @@
 ## Show that the help message for llvm-ranlib can be printed with either the
 ## long flag -help.
 
-# RUN: llvm-ranlib -h | FileCheck %s
-# RUN: llvm-ranlib -help | FileCheck %s
-# RUN: llvm-ranlib --help | FileCheck %s
+# RUN: llvm-ranlib -h | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib -help | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib --help | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib --version | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -version | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -v | FileCheck %s --check-prefix=VERSION
 
-# CHECK: USAGE: llvm-ranlib
+## Also check combined options (first -h/-v flag wins)
+# RUN: llvm-ranlib -Dh | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib -Dvh | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -Dhv | FileCheck %s --check-prefix=HELP
+
+# HELP: USAGE: llvm-ranlib
+# VERSION: LLVM version
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-VALU

[PATCH] D71615: [clang] [cmake] Fix gen_ast_dump_json_test.py binary dir

2019-12-18 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson accepted this revision.
arichardson added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D71615



___
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-18 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_timedmutex_requirements/thread_timedmutex_class/lock.pass.cpp

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

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

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 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] D71596: [clangd] Improve documentation for auto and implicit specs

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

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596

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
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "AST.h"
 #include "Annotations.h"
 #include "Hover.h"
 #include "TestIndex.h"
@@ -1271,6 +1272,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto function return with trailing type";
   }},
   {
   R"cpp(// trailing return type
@@ -1282,6 +1284,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "trailing return type";
   }},
   {
   R"cpp(// auto in function return
@@ -1293,6 +1296,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto in function return";
   }},
   {
   R"cpp(// auto& in function return
@@ -1305,6 +1309,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto& in function return";
   }},
   {
   R"cpp(// auto* in function return
@@ -1317,6 +1322,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto* in function return";
   }},
   {
   R"cpp(// const auto& in function return
@@ -1329,6 +1335,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "const auto& in function return";
   }},
   {
   R"cpp(// decltype(auto) in function return
@@ -1340,6 +1347,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "decltype(auto) in function return";
   }},
   {
   R"cpp(// decltype(auto) reference in function return
@@ -1404,6 +1412,8 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation =
+"decltype of function with trailing return type.";
   }},
   {
   R"cpp(// decltype of var with decltype.
@@ -1449,6 +1459,7 @@
   [](HoverInfo &HI) {
 HI.Name = "cls";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto on alias";
   }},
   {
   R"cpp(// auto on alias
@@ -1459,6 +1470,7 @@
   [](HoverInfo &HI) {
 HI.Name = "templ";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto on alias";
   }},
   };
 
@@ -1503,6 +1515,87 @@
   }
 }
 
+TEST(Hover, DocsFromIndex) {
+  Annotations T(R"cpp(
+  template  class X {};
+  void foo() {
+au^to t = X();
+X^ w;
+(void)w;
+  })cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &D : AST.getDiagnostics())
+ADD_FAILURE() << D;
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+
+  Symbol IndexSym;
+  IndexSym.ID = *getSymbolID(&findDecl(AST, "X"));
+  IndexSym.Documentation = "comment from index";
+  SymbolSlab::Builder Symbols;
+  Symbols.insert(IndexSym);
+  auto Index =
+  MemIndex::build(std::move(Symbols).build(), RefSlab(), RelationSlab());
+
+  for (const auto &P : T.points()) {
+auto H = getHover(AST, P, format::getLLVMStyle(), Index.get());
+ASSERT_TRUE(H);
+EXPECT_EQ(H->Documentation, IndexSym.Documentation);
+  }
+}
+
+TEST(Hover, DocsFromAST) {
+  Annotations T(R"cpp(
+  // doc
+  template  class X {};
+  void foo() {
+au^to t = X();
+X^ w;
+(void)w;
+  })cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &D : AST.getDiagnostics())
+ADD_FAILURE() << D;
+  ASSERT_TRUE(AST.getDiagnostics().empty());
+
+  for (const auto &P : T.points()) {
+auto H = getHover(AST, P, format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+EXPECT_EQ(H->Documentation, "doc");
+  }
+}
+
+TEST(Hover, DocsFromMostSpecial) {
+  Annotations T(R"cpp(
+  // doc1
+  template  class X {};
+  // doc2
+  template <> class X {};
+  // doc3
+  template  class X {};
+  void foo(

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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



Comment at: clang-tools-extra/clangd/Hover.cpp:188
+// returns D.
+const NamedDecl *getExplicitSpec(const NamedDecl *D) {
+  if (auto *CTSD = llvm::dyn_cast(D)) {

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > What's the purpose of this function?
> > > I don't think its description has semantic meaning in C++, "implicit 
> > > instantiations" do not have an "explicit specialization"...
> > > 
> > > It seems to be doing something to change a decl into something that could 
> > > be used to query the index. If that's the case, we could probably have a 
> > > name that's closer to the described goal.
> > yeah naming is hard :/
> > 
> > it is not just something that can be used to query index, but also for AST, 
> > as the decl of instantiation doesn't contain comments attached to 
> > specialization.
> > this is basically returning the explicit specialization used to instantiate 
> > `D`.
> > 
> > any suggestions for the name ?
> I would go with the following (a different comment is welcome, just quickly 
> came up with something):
> ```
> /// Returns a decl that should be used to produce hover, i.e. the one
> /// we should query for documentation comment and use in index queries.
> Decl *getDeclForHoverInfo(Decl *D) 
> ```
> 
> The name is not smart and one would definitely need to read the comment to 
> understand why we need it in the first place, but at least it would make sure 
> we avoid confusion.
the problem is, this is not the decl used to produce hover exactly (for example 
we want to make use of implicit instantiation for printing the name).
we only want to make use of it for comment retrieval, modifying according to 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


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

2019-12-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1209
 // FIXME: Print template instantiation parameters.
-HI.Name = "initializer_list";
+HI.Name = "initializer_list";
 HI.Kind = index::SymbolKind::Class;

sammccall wrote:
> Hang on, I think we're going round in circles with this design.
> 
> IIRC the idea was that `Name` doesn't include template parameters, signature, 
> etc, so clients control rendering.
> 
> Isn't it easy to reconstitute this from the template argument list in the 
> hover info?
we were only storing template parameters, not arguments. they've always been 
the part of the name, they had disappeared after a previous patch, as an 
intermediate state and this was introducing them back.

i am planning to move template arguments into a different field though, as 
template parameters, which should also help with dropping default arguments.


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] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-18 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Another bug report for this: https://bugs.llvm.org/show_bug.cgi?id=44331 Please 
close when landing this.


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

https://reviews.llvm.org/D71378



___
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(NOP padding)

2019-12-18 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 234488.
skan edited the summary of this revision.
skan added a comment.

**Simplify**

Drop the subtype of `MCBoundaryAlignFragment` and add data member `EmitNops` to 
indicate whether NOPs should be emitted.


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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s

Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,63 @@
+# Check no nop or prefix is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:3: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:6: 89 d1movl%edx, %ecx
+# CHECK-NEXT:8: 31 c0xorl%eax, %eax
+# CHECK-NEXT:a: 31 c8xorl%ecx, %eax
+# CHECK-NEXT:c: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:f: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   12: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   15: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   18: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   1b: f3 abrep stosl%eax, %es:(%rdi)
+# CHECK-NEXT:   1d: 75 e4jne {{.*}}
+# CHECK-NEXT:   1f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   21: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   24: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   27: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   2a: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   2c: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   2e: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   31: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   34: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   37: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   3a: e8 00 00 00 00   callq   {{.*}}
+# CHECK-NEXT:   3f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   41: 75 e1jne {{.*}}
+
+.text
+.p2align 4,,15
+foo:
+shrl$2, %ecx
+.L1:
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+xorl%ecx, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+rep stosl
+jne.L1
+xorl%eax, %eax
+shrl$2, %ecx
+.L2:
+shrl$2, %ecx
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+callbar
+xorl%eax, %eax
+jne.L2
Index: llvm/test/MC/X86/align-branch-64-4a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-4a.s
@@ -0,0 +1,63 @@
+# Check rets are not aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s | llvm-objdump -d  - >%t2
+# RUN: cmp %t %t2
+
+# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d 

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:188
+// returns D.
+const NamedDecl *getExplicitSpec(const NamedDecl *D) {
+  if (auto *CTSD = llvm::dyn_cast(D)) {

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > What's the purpose of this function?
> > > > I don't think its description has semantic meaning in C++, "implicit 
> > > > instantiations" do not have an "explicit specialization"...
> > > > 
> > > > It seems to be doing something to change a decl into something that 
> > > > could be used to query the index. If that's the case, we could probably 
> > > > have a name that's closer to the described goal.
> > > yeah naming is hard :/
> > > 
> > > it is not just something that can be used to query index, but also for 
> > > AST, as the decl of instantiation doesn't contain comments attached to 
> > > specialization.
> > > this is basically returning the explicit specialization used to 
> > > instantiate `D`.
> > > 
> > > any suggestions for the name ?
> > I would go with the following (a different comment is welcome, just quickly 
> > came up with something):
> > ```
> > /// Returns a decl that should be used to produce hover, i.e. the one
> > /// we should query for documentation comment and use in index queries.
> > Decl *getDeclForHoverInfo(Decl *D) 
> > ```
> > 
> > The name is not smart and one would definitely need to read the comment to 
> > understand why we need it in the first place, but at least it would make 
> > sure we avoid confusion.
> the problem is, this is not the decl used to produce hover exactly (for 
> example we want to make use of implicit instantiation for printing the name).
> we only want to make use of it for comment retrieval, modifying according to 
> that.
If it's just for the comment, `getDeclForComment` is perfect :-)



Comment at: clang-tools-extra/clangd/Hover.cpp:189
+const NamedDecl *getDeclForComment(const NamedDecl *D) {
+  // Return explicit specialization for implicit instantiations, as comments 
are
+  // attached to that.

There's no such thing as `explicit specialization for implicit instantiations`.
Maybe remove this comment? It merely duplicates the code and it doesn't really 
matter what happens there, as long as we get the comment in hover.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

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

  failed: lit.lit/shtest-format.py

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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



Comment at: clang-tools-extra/clangd/Hover.cpp:191
+  // attached to that.
+  if (auto *CTSD = llvm::dyn_cast(D)) {
+if (!CTSD->isExplicitInstantiationOrSpecialization())

You might need to do the same for specializations of functions and variables.
Maybe add corresponding tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[clang] 308b8b7 - [OpenCL] Add builtin function extension handling

2019-12-18 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-18T10:13:51Z
New Revision: 308b8b76ceee805c964faf9f2176e3e05532a45b

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

LOG: [OpenCL] Add builtin function extension handling

Provide a mechanism to attach OpenCL extension information to builtin
functions, so that their use can be restricted according to the
extension(s) the builtin is part of.

Patch by Pierre Gondois and Sven van Haastregt.

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

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 353e0c1d8c8d..37f317823933 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -40,6 +40,21 @@ def ConstantAS   : 
AddressSpace<"clang::LangAS::opencl_constant">;
 def LocalAS  : AddressSpace<"clang::LangAS::opencl_local">;
 def GenericAS: AddressSpace<"clang::LangAS::opencl_generic">;
 
+// OpenCL language extension.
+class AbstractExtension {
+  // One or more OpenCL extensions, space separated.  Each extension must be
+  // a valid extension name for the opencl extension pragma.
+  string ExtName = _Ext;
+}
+
+// Extension associated to a builtin function.
+class FunctionExtension : AbstractExtension<_Ext>;
+
+// FunctionExtension definitions.
+def FuncExtNone  : FunctionExtension<"">;
+def FuncExtKhrSubgroups  : 
FunctionExtension<"cl_khr_subgroups">;
+def FuncExtKhrGlobalInt32BaseAtomics : 
FunctionExtension<"cl_khr_global_int32_base_atomics">;
+def FuncExtKhrGlobalInt32ExtendedAtomics : 
FunctionExtension<"cl_khr_global_int32_extended_atomics">;
 
 // Qualified Type.  These map to ASTContext::QualType.
 class QualType {
@@ -198,14 +213,14 @@ class Builtin _Signature, 
list _Attributes = Attr.
   // the following are the arguments. The list must have at least one element
   // (the return type).
   list Signature = _Signature;
-  // OpenCL Extension to which the function belongs (cl_khr_subgroups, ...)
-  string Extension = "";
   // Function attribute __attribute__((pure))
   bit IsPure = _Attributes[0];
   // Function attribute __attribute__((const))
   bit IsConst = _Attributes[1];
   // Function attribute __attribute__((convergent))
   bit IsConv = _Attributes[2];
+  // OpenCL extensions to which the function belongs.
+  FunctionExtension Extension = FuncExtNone;
   // Version of OpenCL from which the function is available (e.g.: CL10).
   // MinVersion is inclusive.
   Version MinVersion = CL10;
@@ -862,17 +877,19 @@ foreach name = ["prefetch"] in {
 // Functions that use memory_order and cl_mem_fence_flags enums are not
 // declared here as the TableGen backend does not handle enums.
 
-// OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers.
+// OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers
 // --- Table 9.1 ---
-foreach Type = [Int, UInt] in {
-  foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
-def : Builtin, GlobalAS>, 
Type]>;
-  }
-  foreach name = ["atom_inc", "atom_dec"] in {
-def : Builtin, GlobalAS>]>;
-  }
-  foreach name = ["atom_cmpxchg"] in {
-def : Builtin, GlobalAS>, 
Type, Type]>;
+let Extension = FuncExtKhrGlobalInt32BaseAtomics in {
+  foreach Type = [Int, UInt] in {
+foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
+  def : Builtin, GlobalAS>, 
Type]>;
+}
+foreach name = ["atom_inc", "atom_dec"] in {
+  def : Builtin, GlobalAS>]>;
+}
+foreach name = ["atom_cmpxchg"] in {
+  def : Builtin, GlobalAS>, 
Type, Type]>;
+}
   }
 }
 
@@ -1077,7 +1094,7 @@ let MinVersion = CL20 in {
 
 // OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
 let MinVersion = CL20 in {
-  let Extension = "cl_khr_subgroups" in {
+  let Extension = FuncExtKhrSubgroups in {
 def get_sub_group_size : Builtin<"get_sub_group_size", [UInt]>;
 def get_max_sub_group_size : Builtin<"get_max_sub_group_size", [UInt]>;
 def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>;

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d9b6cb6a9215..0ed51de0cc13 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -739,6 +739,18 @@ static void GetOpenCLBuiltinFctOverloads(
   }
 }
 
+/// Add extensions to the function declaration.
+/// \param S (in/out) The Sema instance.
+/// \param BIDecl (in) Description of the builtin.
+/// \param FDecl (in/out) FunctionDecl instance.
+static void AddOpenCLExtensions(Sema &S, const OpenCLBuiltinStru

[PATCH] D71476: [OpenCL] Add builtin function extension handling

2019-12-18 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG308b8b76ceee: [OpenCL] Add builtin function extension 
handling (authored by svenvh).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D71476?vs=233826&id=234491#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71476

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -26,6 +26,11 @@
 //
 //  * Structs and enums to represent types and function signatures.
 //
+//  * const char *FunctionExtensionTable[]
+//List of space-separated OpenCL extensions.  A builtin references an
+//entry in this table when the builtin requires a particular (set of)
+//extension(s) to be enabled.
+//
 //  * OpenCLTypeStruct TypeTable[]
 //Type information for return types and arguments.
 //
@@ -133,6 +138,9 @@
   // function names.
   void GroupBySignature();
 
+  // Emit the FunctionExtensionTable that lists all function extensions.
+  void EmitExtensionTable();
+
   // Emit the TypeTable containing all types used by OpenCL builtins.
   void EmitTypeTable();
 
@@ -150,12 +158,13 @@
   // each function, and is a struct OpenCLBuiltinDecl.
   // E.g.:
   // // 891 convert_float2_rtn
-  //   { 58, 2, 100, 0 },
+  //   { 58, 2, 3, 100, 0 },
   // This means that the signature of this convert_float2_rtn overload has
   // 1 argument (+1 for the return type), stored at index 58 in
-  // the SignatureTable.  The last two values represent the minimum (1.0) and
-  // maximum (0, meaning no max version) OpenCL version in which this overload
-  // is supported.
+  // the SignatureTable.  This prototype requires extension "3" in the
+  // FunctionExtensionTable.  The last two values represent the minimum (1.0)
+  // and maximum (0, meaning no max version) OpenCL version in which this
+  // overload is supported.
   void EmitBuiltinTable();
 
   // Emit a StringMatcher function to check whether a function name is an
@@ -191,6 +200,10 @@
   // Contains the map of OpenCL types to their index in the TypeTable.
   MapVector TypeMap;
 
+  // List of OpenCL function extensions mapping extension strings to
+  // an index into the FunctionExtensionTable.
+  StringMap FunctionExtensionIndex;
+
   // List of OpenCL type names in the same order as in enum OpenCLTypeID.
   // This list does not contain generic types.
   std::vector TypeList;
@@ -227,16 +240,18 @@
   // Emit enums and structs.
   EmitDeclarations();
 
+  // Parse the Records to populate the internal lists.
   GetOverloads();
   GroupBySignature();
 
   // Emit tables.
+  EmitExtensionTable();
   EmitTypeTable();
   EmitSignatureTable();
   EmitBuiltinTable();
 
+  // Emit functions.
   EmitStringMatcher();
-
   EmitQualTypeFinder();
 }
 
@@ -323,6 +338,8 @@
   const bool IsConst;
   // Function attribute __attribute__((convergent))
   const bool IsConv;
+  // OpenCL extension(s) required for this overload.
+  const unsigned short Extension;
   // First OpenCL version in which this overload was introduced (e.g. CL20).
   const unsigned short MinVersion;
   // First OpenCL version in which this overload was removed (e.g. CL20).
@@ -413,6 +430,23 @@
   }
 }
 
+void BuiltinNameEmitter::EmitExtensionTable() {
+  OS << "static const char *FunctionExtensionTable[] = {\n";
+  unsigned Index = 0;
+  std::vector FuncExtensions =
+  Records.getAllDerivedDefinitions("FunctionExtension");
+
+  for (const auto &FE : FuncExtensions) {
+// Emit OpenCL extension table entry.
+OS << "  // " << Index << ": " << FE->getName() << "\n"
+   << "  \"" << FE->getValueAsString("ExtName") << "\",\n";
+
+// Record index of this extension.
+FunctionExtensionIndex[FE->getName()] = Index++;
+  }
+  OS << "};\n\n";
+}
+
 void BuiltinNameEmitter::EmitTypeTable() {
   OS << "static const OpenCLTypeStruct TypeTable[] = {\n";
   for (const auto &T : TypeMap) {
@@ -463,11 +497,13 @@
 OS << "\n";
 
 for (const auto &Overload : SLM.second.Signatures) {
+  StringRef ExtName = Overload.first->getValueAsDef("Extension")->getName();
   OS << "  { " << Overload.second << ", "
  << Overload.first->getValueAsListOfDefs("Signature").size() << ", "
  << (Overload.first->getValueAsBit("IsPure")) << ", "
  << (Overload.first->getValueAsBit("IsConst")) << ", "
  << (Overload.first->getValueAsBit("IsConv")) << ", "
+ << FunctionExtensionIndex[ExtName] << ", "
  << Overload.first->getValueAsDef("MinVersion")->getValueAsInt("ID")
  << ", "
  << Overload

[PATCH] D71652: [clangd] Replace shortenNamespace with getQualification

2019-12-18 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.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71652

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

Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -25,29 +25,6 @@
 namespace clangd {
 namespace {
 
-TEST(ShortenNamespace, All) {
-  ASSERT_EQ("TestClass", shortenNamespace("TestClass", ""));
-
-  ASSERT_EQ("TestClass", shortenNamespace(
-  "testnamespace::TestClass", "testnamespace"));
-
-  ASSERT_EQ(
-  "namespace1::TestClass",
-  shortenNamespace("namespace1::TestClass", "namespace2"));
-
-  ASSERT_EQ("TestClass",
-shortenNamespace("testns1::testns2::TestClass",
- "testns1::testns2"));
-
-  ASSERT_EQ(
-  "testns2::TestClass",
-  shortenNamespace("testns1::testns2::TestClass", "testns1"));
-
-  ASSERT_EQ("TestClass",
-shortenNamespace(
-"testns1::TestClass", "testns1"));
-}
-
 TEST(GetDeducedType, KwAutoExpansion) {
   struct Test {
 StringRef AnnotatedCode;
@@ -166,8 +143,8 @@
   Case.Qualifications[I]);
   } else {
 EXPECT_EQ(getQualification(AST.getASTContext(),
-   D->getLexicalDeclContext(), D->getBeginLoc(),
-   TargetDecl, Case.VisibleNamespaces),
+   D->getLexicalDeclContext(), TargetDecl,
+   Case.VisibleNamespaces),
   Case.Qualifications[I]);
   }
 }
Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -80,19 +80,7 @@
 
 /// Returns a QualType as string. The result doesn't contain unwritten scopes
 /// like annoymous/inline namespace.
-std::string printType(const QualType QT, const DeclContext &Context);
-
-/// Try to shorten the OriginalName by removing namespaces from the left of
-/// the string that are redundant in the CurrentNamespace. This way the type
-/// idenfier become shorter and easier to read.
-/// Limitation: It only handles the qualifier of the type itself, not that of
-/// templates.
-/// FIXME: change type of parameter CurrentNamespace to DeclContext ,
-/// take in to account using directives etc
-/// Example: shortenNamespace("ns1::MyClass", "ns1")
-///--> "MyClass"
-std::string shortenNamespace(const llvm::StringRef OriginalName,
- const llvm::StringRef CurrentNamespace);
+std::string printType(const QualType QT, const DeclContext &CurContext);
 
 /// Indicates if \p D is a template instantiation implicitly generated by the
 /// compiler, e.g.
@@ -157,7 +145,7 @@
 /// present in \p VisibleNamespaces, no matter whether it is from ns1:: or ns2::
 std::string getQualification(ASTContext &Context,
  const DeclContext *DestContext,
- SourceLocation InsertionPoint, const NamedDecl *ND,
+ const NamedDecl *ND,
  llvm::ArrayRef VisibleNamespaces);
 
 } // namespace clangd
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -299,32 +299,17 @@
   return SymbolID(USR);
 }
 
-std::string shortenNamespace(const llvm::StringRef OriginalName,
- const llvm::StringRef CurrentNamespace) {
-  llvm::SmallVector OriginalParts;
-  llvm::SmallVector CurrentParts;
-  llvm::SmallVector Result;
-  OriginalName.split(OriginalParts, "::");
-  CurrentNamespace.split(CurrentParts, "::");
-  auto MinLength = std::min(CurrentParts.size(), OriginalParts.size());
-
-  unsigned DifferentAt = 0;
-  while (DifferentAt < MinLength &&
- CurrentParts[DifferentAt] == OriginalParts[DifferentAt]) {
-DifferentAt++;
-  }
-
-  for (unsigned i = DifferentAt; i < OriginalParts.size(); ++i) {
-Result.push_back(OriginalParts[i]);
-  }
-  return join(Result, "::");
-}
-
-std::string printType(const QualType QT, const DeclContext &Context) {
-  PrintingPolicy PP(Context.getParentASTContext().getPrintingPolicy());
-  PP.SuppressUnwrittenScope = 1;
-  PP.SuppressTagKeyword = 1;
-  return shortenNamespace(QT.getAsString(PP), printNamespaceScope(Context));
+std::string printType(const QualType QT, const DeclContext &CurContext) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  if (auto *TD = QT->getAsTagDecl())
+OS << getQualification(CurContext.getPa

[PATCH] D71652: [clangd] Replace shortenNamespace with getQualification

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

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

  failed: lit.lit/shtest-format.py

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71652



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


[PATCH] D64573: [Syntax] Allow to mutate syntax trees

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 234494.
ilya-biryukov marked 6 inline comments as done.
ilya-biryukov added a comment.

- Fix a header guard
- Make firstLeaf and lastLeaf methods inside Tree
- Mark non-modifiable nodes with I (for immutable)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/include/clang/Tooling/Syntax/Mutations.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/ComputeReplacements.cpp
  clang/lib/Tooling/Syntax/Mutations.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,14 +9,24 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -24,6 +34,15 @@
 using namespace clang;
 
 namespace {
+static llvm::ArrayRef tokens(syntax::Node *N) {
+  assert(N->isOriginal() && "tokens of modified node are not well-defined");
+  if (auto *L = dyn_cast(N))
+return llvm::makeArrayRef(L->token(), 1);
+  auto *T = cast(N);
+  return llvm::makeArrayRef(T->firstLeaf()->token(),
+T->lastLeaf()->token() + 1);
+}
+
 class SyntaxTreeTest : public ::testing::Test {
 protected:
   // Build a syntax tree for the code.
@@ -80,13 +99,13 @@
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
   "-fsyntax-only", FileName};
-auto CI = createInvocationFromCommandLine(Args, Diags, FS);
-assert(CI);
-CI->getFrontendOpts().DisableFree = false;
-CI->getPreprocessorOpts().addRemappedFile(
+Invocation = createInvocationFromCommandLine(Args, Diags, FS);
+assert(Invocation);
+Invocation->getFrontendOpts().DisableFree = false;
+Invocation->getPreprocessorOpts().addRemappedFile(
 FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
 CompilerInstance Compiler;
-Compiler.setInvocation(std::move(CI));
+Compiler.setInvocation(Invocation);
 Compiler.setDiagnostics(Diags.get());
 Compiler.setFileManager(FileMgr.get());
 Compiler.setSourceManager(SourceMgr.get());
@@ -108,6 +127,27 @@
 }
   }
 
+  /// Finds the deepest node in the tree that covers exactly \p R.
+  /// FIXME: implement this efficiently and move to public syntax tree API.
+  syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root) {
+llvm::ArrayRef Toks = tokens(Root);
+
+if (Toks.front().location().isFileID() &&
+Toks.back().location().isFileID() &&
+syntax::Token::range(*SourceMgr, Toks.front(), Toks.back()) ==
+syntax::FileRange(SourceMgr->getMainFileID(), R.Begin, R.End))
+  return Root;
+
+auto *T = dyn_cast(Root);
+if (!T)
+  return nullptr;
+for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling()) {
+  if (auto *Result = nodeByRange(R, C))
+return Result;
+}
+return nullptr;
+  }
+
   // Data fields.
   llvm::IntrusiveRefCntPtr Diags =
   new DiagnosticsEngine(new DiagnosticIDs, new DiagnosticOptions);
@@ -117,6 +157,7 @@
   new FileManager(FileSystemOptions(), FS);
   llvm::IntrusiveRefCntPtr SourceMgr =
   new SourceManager(*Diags, *FileMgr);
+  std::shared_ptr Invocation;
   // Set after calling buildTree().
   std::unique_ptr Arena;
 };
@@ -695,6 +736,39 @@
   | `-;
   `-}
)txt"},
+  // Some nodes are non-modifiable, they are marked with 'I:'.
+  {R"cpp(
+#define HALF_IF if (1+
+#define HALF_IF_2 1) {}
+void test() {
+  HALF_IF HALF_IF_2 else {}
+})cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-test
+  |-(
+  |-)
+  `-Comp

[PATCH] D64573: [Syntax] Allow to mutate syntax trees

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as not done.
ilya-biryukov added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:57
+  return nullptr;
+}
+

gribozavr2 wrote:
> Seems like these first/last helpers should be methods on `syntax::Node`.
Good point. Done.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:66
+  syntax::Leaf *Last = lastLeaf(T);
+  return llvm::makeArrayRef(First->token(), Last->token() + 1);
+}

gribozavr2 wrote:
> The first and the last tokens are not necessarily from the same buffer...
They are for nodes with `isOriginal() == true`. I've added an assertion.
Exactly the reason why this method is not a good fit for public API, but ok to 
have in tests.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:528
+void test() {
+  HALF_IF HALF_IF_2 else {}
+})cpp",

gribozavr2 wrote:
> Could you also do something like:
> 
> ```
> #define OPEN {
> #define CLOSE }
> 
> void test1() {
>   OPEN
> 1;
>   CLOSE
> }
> void test1() {
>   OPEN
> 1;
>   }
> }
> ```
Funnily enough, this causes an assertion failure, because binary-searching with 
`isBeforeInTranslationUnit` finds `{` expanded from `OPEN` instead of `1` when 
building a syntax tree.

I'll make use of a hash table for searching tokens by location and add the test 
in the follow-up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573



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


[clang] bc5b7e2 - recommit: [ASTImporter] Friend class decl should not be visible in its context

2019-12-18 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2019-12-18T11:43:46+01:00
New Revision: bc5b7e21e32b23603f4d6148adeb88cd34dd287e

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

LOG: recommit: [ASTImporter] Friend class decl should not be visible in its 
context

Summary:
In the past we had to use DeclContext::makeDeclVisibleInContext to make
friend declarations available for subsequent lookup calls and this way
we could chain (redecl) the structurally equivalent decls.
By doing this we created an AST that improperly made declarations
visible in some contexts, so the AST was malformed.
Since we use the importer specific lookup this is no longer necessary,
because with that we can find every previous nodes.

Reviewers: balazske, a_sidorin, a.sidorin, shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 414092f33c47..b75a689ec275 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -298,6 +298,48 @@ namespace clang {
   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(ToD);
+  DeclContextLookupResult FromLookup =
+  FromDC->lookup(FromNamed->getDeclName());
+  for (NamedDecl *ND : FromLookup)
+if (ND == FromNamed) {
+  ToDC->makeDeclVisibleInContext(ToNamed);
+  break;
+}
+}
+  }
+}
+
   public:
 explicit ASTNodeImporter(ASTImporter &Importer) : Importer(Importer) {}
 
@@ -2737,11 +2779,7 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl 
*D) {
 D2 = D2CXX;
 D2->setAccess(D->getAccess());
 D2->setLexicalDeclContext(LexicalDC);
-if (!DCXX->getDescribedClassTemplate() || DCXX->isImplicit())
-  LexicalDC->addDeclInternal(D2);
-
-if (LexicalDC != DC && D->isInIdentifierNamespace(Decl::IDNS_TagFriend))
-  DC->makeDeclVisibleInContext(D2);
+addDeclToContexts(D, D2);
 
 if (ClassTemplateDecl *FromDescribed =
 DCXX->getDescribedClassTemplate()) {
@@ -2807,7 +2845,7 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl 
*D) {
 Name.getAsIdentifierInfo(), PrevDecl))
   return D2;
 D2->setLexicalDeclContext(LexicalDC);
-LexicalDC->addDeclInternal(D2);
+addDeclToContexts(D, D2);
   }
 
   if (auto BraceRangeOrErr = import(D->getBraceRange()))
@@ -3386,23 +3424,7 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   if (Error Err = ImportTemplateInformation(D, ToFunction))
 return std::move(Err);
 
-  bool IsFriend = D->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend);
-
-  // TODO Can we generalize this approach to other AST nodes as well?
-  if (D->getDeclContext()->containsDeclAndLoad(D))
-DC->addDeclInternal(ToFunction);
-  if (DC != LexicalDC && D->getLexicalDeclContext()->containsDeclAndLoad(D))
-LexicalDC->addDeclInternal(ToFunction);
-
-  // Friend declaration's lexical context is the befriending class, but the
-  // semantic context is the enclosing scope of the befriending class.
-  // We want the friend functions to be found in the semantic context by 
lookup.
-  // FIXME should we handle this generically in VisitFriendDecl?
-  // In Other cases when LexicalDC != DC we don't want it to be added,
-  // e.

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

2019-12-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Recommited in bc5b7e21e32 
 . I 
changed `llvm:is_contained` to a simple for loop over the lookup result. This 
way the copy assignment of the iterator is avoided even if windows STL is used.


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: [PATCH] D71545: [clangd] Improve hover for auto on template instantiations

2019-12-18 Thread Sam McCall via cfe-commits
Ok, sorry for getting the wrong end of the stick re the history.

Arguments vs parameters - are we sure this is a distinction worth surfacing
to users/uis? I guess modeling both using the same struct is awkward.

On Wed, Dec 18, 2019, 10:57 AM Kadir Cetinkaya via Phabricator <
revi...@reviews.llvm.org> wrote:

> kadircet marked an inline comment as done.
> kadircet added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1209
>  // FIXME: Print template instantiation parameters.
> -HI.Name = "initializer_list";
> +HI.Name = "initializer_list";
>  HI.Kind = index::SymbolKind::Class;
> 
> sammccall wrote:
> > Hang on, I think we're going round in circles with this design.
> >
> > IIRC the idea was that `Name` doesn't include template parameters,
> signature, etc, so clients control rendering.
> >
> > Isn't it easy to reconstitute this from the template argument list in
> the hover info?
> we were only storing template parameters, not arguments. they've always
> been the part of the name, they had disappeared after a previous patch, as
> an intermediate state and this was introducing them back.
>
> i am planning to move template arguments into a different field though, as
> template parameters, which should also help with dropping default arguments.
>
>
> 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] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2019-12-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Somewhat related: https://reviews.llvm.org/D40854
This is a check that tried to enforce not mixing any signed/unsigned 
arithmetic. there was no feedback from the cppcoreguideline-ppl on how to 
proceed with edge cases and occassion where mixing is not avoidable (e.g. 
`unsigned short + unsigned short + unsigned short`, because of integer 
promotion).
Just to inform you as it might help with testing or anything like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-18 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

In D71460#1783390 , @asavonic wrote:

> What about `get_image_num_mip_levels` functions defined in the extension 
> specification?
>
> Edit: I mean, should the `get_image_num_mip_levels(write_only img)` function 
> be only available if `cl_khr_mipmap_image_writes` extension is supported, or 
> `cl_khr_mipmap_image` is enough?


I think `cl_khr_mipmap_image` is enough, because "the 
`cl_khr_mipmap_image_writes` extension adds built-in functions that can be used 
to **write** a mip-mapped image", while `get_image_num_mip_levels(write_only 
img)` only retrieve a property of the image.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71460



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


[clang] 1ad1504 - [Syntax] Allow to mutate syntax trees

2019-12-18 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-12-18T12:19:03+01:00
New Revision: 1ad15046dcf6ff8bafc4a1ea13f214f8d6ba7de6

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

LOG: [Syntax] Allow to mutate syntax trees

Summary:
This patch adds facilities to mutate the syntax trees and produce
corresponding text replacements.

The public interface of the syntax library now includes facilities to:
1. perform type-safe modifications of syntax trees,
2. compute textual replacements to apply the modifications,
3. create syntax trees not backed by the source code.

For each of the three, we only add a few example transformations in this
patch to illustrate the idea, support for more kinds of nodes and
transformations will be done in follow-up patches.

The high-level mutation operations are implemented on top of operations
that allow to arbitrarily change the trees. They are considered to be
implementation details and are not available to the users of the
library.

Reviewers: sammccall, gribozavr2

Reviewed By: gribozavr2

Subscribers: merge_guards_bot, mgorny, cfe-commits

Tags: #clang

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

Added: 
clang/include/clang/Tooling/Syntax/Mutations.h
clang/lib/Tooling/Syntax/ComputeReplacements.cpp
clang/lib/Tooling/Syntax/Mutations.cpp
clang/lib/Tooling/Syntax/Synthesis.cpp

Modified: 
clang/include/clang/Tooling/Syntax/BuildTree.h
clang/include/clang/Tooling/Syntax/Tokens.h
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/CMakeLists.txt
clang/lib/Tooling/Syntax/Tokens.cpp
clang/lib/Tooling/Syntax/Tree.cpp
clang/unittests/Tooling/Syntax/CMakeLists.txt
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/BuildTree.h 
b/clang/include/clang/Tooling/Syntax/BuildTree.h
index 055d6462eabd..b7ad50c941d1 100644
--- a/clang/include/clang/Tooling/Syntax/BuildTree.h
+++ b/clang/include/clang/Tooling/Syntax/BuildTree.h
@@ -11,7 +11,9 @@
 #define LLVM_CLANG_TOOLING_SYNTAX_TREE_H
 
 #include "clang/AST/Decl.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tree.h"
 
 namespace clang {
 namespace syntax {
@@ -19,6 +21,13 @@ namespace syntax {
 /// Build a syntax tree for the main file.
 syntax::TranslationUnit *buildSyntaxTree(Arena &A,
  const clang::TranslationUnitDecl &TU);
+
+// Create syntax trees from subtrees not backed by the source code.
+
+clang::syntax::Leaf *createPunctuation(clang::syntax::Arena &A,
+   clang::tok::TokenKind K);
+clang::syntax::EmptyStatement *createEmptyStatement(clang::syntax::Arena &A);
+
 } // namespace syntax
 } // namespace clang
 #endif

diff  --git a/clang/include/clang/Tooling/Syntax/Mutations.h 
b/clang/include/clang/Tooling/Syntax/Mutations.h
new file mode 100644
index ..8fd58ae34fff
--- /dev/null
+++ b/clang/include/clang/Tooling/Syntax/Mutations.h
@@ -0,0 +1,37 @@
+//===- Mutations.h - mutate syntax trees *- C++ 
---*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Defines high-level APIs for transforming syntax trees and producing the
+// corresponding textual replacements.
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_MUTATIONS_H
+#define LLVM_CLANG_TOOLING_SYNTAX_MUTATIONS_H
+
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tree.h"
+
+namespace clang {
+namespace syntax {
+
+/// Computes textual replacements required to mimic the tree modifications made
+/// to the syntax tree.
+tooling::Replacements computeReplacements(const Arena &A,
+  const syntax::TranslationUnit &TU);
+
+/// Removes a statement or replaces it with an empty statement where one is
+/// required syntactically. E.g., in the following example:
+/// if (cond) { foo(); } else bar();
+/// One can remove `foo();` completely and to remove `bar();` we would need to
+/// replace it with an empty statement.
+/// EXPECTS: S->canModify() == true
+void removeStatement(syntax::Arena &A, syntax::Statement *S);
+
+} // namespace syntax
+} // namespace clang
+
+#endif

diff  --git a/clang/include/clang/Tooling/Syntax/Tokens.h 
b/clang/include/clang/Tooling/Syntax/Tokens.h
index 0dcb6a1b2c9f..1f9eeae20

[clang] 038f538 - [Syntax] Uppercase the first letter of the test name. NFC

2019-12-18 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-12-18T12:20:30+01:00
New Revision: 038f53882e7cc25da0a71018d1c7f9b4706675c2

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

LOG: [Syntax] Uppercase the first letter of the test name. NFC

To match naming style of other tests.

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp 
b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index e440993aac52..b2ad3859104a 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -770,7 +770,7 @@ TEST_F(TokenBufferTest, TokensToFileRange) {
   // We don't test assertion failures because death tests are slow.
 }
 
-TEST_F(TokenBufferTest, macroExpansions) {
+TEST_F(TokenBufferTest, MacroExpansions) {
   llvm::Annotations Code(R"cpp(
 #define FOO B
 #define FOO2 BA



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


[PATCH] D64573: [Syntax] Allow to mutate syntax trees

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ad15046dcf6: [Syntax] Allow to mutate syntax trees 
(authored by ilya-biryukov).

Changed prior to commit:
  https://reviews.llvm.org/D64573?vs=234494&id=234496#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/include/clang/Tooling/Syntax/Mutations.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/ComputeReplacements.cpp
  clang/lib/Tooling/Syntax/Mutations.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -9,14 +9,24 @@
 #include "clang/Tooling/Syntax/Tree.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Mutations.h"
 #include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -24,6 +34,15 @@
 using namespace clang;
 
 namespace {
+static llvm::ArrayRef tokens(syntax::Node *N) {
+  assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
+  if (auto *L = dyn_cast(N))
+return llvm::makeArrayRef(L->token(), 1);
+  auto *T = cast(N);
+  return llvm::makeArrayRef(T->firstLeaf()->token(),
+T->lastLeaf()->token() + 1);
+}
+
 class SyntaxTreeTest : public ::testing::Test {
 protected:
   // Build a syntax tree for the code.
@@ -80,13 +99,13 @@
 // Prepare to run a compiler.
 std::vector Args = {"syntax-test", "-std=c++11",
   "-fsyntax-only", FileName};
-auto CI = createInvocationFromCommandLine(Args, Diags, FS);
-assert(CI);
-CI->getFrontendOpts().DisableFree = false;
-CI->getPreprocessorOpts().addRemappedFile(
+Invocation = createInvocationFromCommandLine(Args, Diags, FS);
+assert(Invocation);
+Invocation->getFrontendOpts().DisableFree = false;
+Invocation->getPreprocessorOpts().addRemappedFile(
 FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
 CompilerInstance Compiler;
-Compiler.setInvocation(std::move(CI));
+Compiler.setInvocation(Invocation);
 Compiler.setDiagnostics(Diags.get());
 Compiler.setFileManager(FileMgr.get());
 Compiler.setSourceManager(SourceMgr.get());
@@ -108,6 +127,27 @@
 }
   }
 
+  /// Finds the deepest node in the tree that covers exactly \p R.
+  /// FIXME: implement this efficiently and move to public syntax tree API.
+  syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root) {
+llvm::ArrayRef Toks = tokens(Root);
+
+if (Toks.front().location().isFileID() &&
+Toks.back().location().isFileID() &&
+syntax::Token::range(*SourceMgr, Toks.front(), Toks.back()) ==
+syntax::FileRange(SourceMgr->getMainFileID(), R.Begin, R.End))
+  return Root;
+
+auto *T = dyn_cast(Root);
+if (!T)
+  return nullptr;
+for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling()) {
+  if (auto *Result = nodeByRange(R, C))
+return Result;
+}
+return nullptr;
+  }
+
   // Data fields.
   llvm::IntrusiveRefCntPtr Diags =
   new DiagnosticsEngine(new DiagnosticIDs, new DiagnosticOptions);
@@ -117,6 +157,7 @@
   new FileManager(FileSystemOptions(), FS);
   llvm::IntrusiveRefCntPtr SourceMgr =
   new SourceManager(*Diags, *FileMgr);
+  std::shared_ptr Invocation;
   // Set after calling buildTree().
   std::unique_ptr Arena;
 };
@@ -695,6 +736,39 @@
   | `-;
   `-}
)txt"},
+  // Some nodes are non-modifiable, they are marked with 'I:'.
+  {R"cpp(
+#define HALF_IF if (1+
+#define HALF_IF_2 1) {}
+void test() {
+  HALF_IF HALF_IF_2 else {}
+})cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-test
+  |-(
+  |-)
+  `

[clang] c1bbefe - [Syntax] Use a hash table to search for tokens by their location

2019-12-18 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-12-18T12:24:00+01:00
New Revision: c1bbefef9d36e84e469513374ef404b9e354b262

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

LOG: [Syntax] Use a hash table to search for tokens by their location

This is both more efficient and avoids corner cases in
`SourceManager::isBeforeInTranslationUnit`.

The change is trivial and clearly a performance improvement on the hot
path of building the syntax tree, so sending without review.

Added: 


Modified: 
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 6f8a42a1ff13..f61c5ff39e1c 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -51,7 +51,10 @@ static bool isImplicitExpr(clang::Expr *E) { return 
E->IgnoreImplicit() != E; }
 /// Call finalize() to finish building the tree and consume the root node.
 class syntax::TreeBuilder {
 public:
-  TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) {}
+  TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) {
+for (const auto &T : Arena.tokenBuffer().expandedTokens())
+  LocationToToken.insert({T.location().getRawEncoding(), &T});
+  }
 
   llvm::BumpPtrAllocator &allocator() { return Arena.allocator(); }
 
@@ -304,6 +307,9 @@ class syntax::TreeBuilder {
   std::string str() { return Pending.str(Arena); }
 
   syntax::Arena &Arena;
+  /// To quickly find tokens by their start location.
+  llvm::DenseMap
+  LocationToToken;
   Forest Pending;
   llvm::DenseSet DeclsWithoutSemicolons;
 };
@@ -641,14 +647,9 @@ void syntax::TreeBuilder::markExprChild(Expr *Child, 
NodeRole Role) {
 }
 
 const syntax::Token *syntax::TreeBuilder::findToken(SourceLocation L) const {
-  auto Tokens = Arena.tokenBuffer().expandedTokens();
-  auto &SM = Arena.sourceManager();
-  auto It = llvm::partition_point(Tokens, [&](const syntax::Token &T) {
-return SM.isBeforeInTranslationUnit(T.location(), L);
-  });
-  assert(It != Tokens.end());
-  assert(It->location() == L);
-  return &*It;
+  auto It = LocationToToken.find(L.getRawEncoding());
+  assert(It != LocationToToken.end());
+  return It->second;
 }
 
 syntax::TranslationUnit *

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index bcc6f29c6468..4de353091cdc 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -767,6 +767,46 @@ void test() {
 | `-CompoundStatement
 |   |-{
 |   `-}
+`-}
+   )txt"},
+  // All nodes can be mutated.
+  {R"cpp(
+#define OPEN {
+#define CLOSE }
+
+void test() {
+  OPEN
+1;
+  CLOSE
+
+  OPEN
+2;
+  }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-test
+  |-(
+  |-)
+  `-CompoundStatement
+|-{
+|-CompoundStatement
+| |-{
+| |-ExpressionStatement
+| | |-UnknownExpression
+| | | `-1
+| | `-;
+| `-}
+|-CompoundStatement
+| |-{
+| |-ExpressionStatement
+| | |-UnknownExpression
+| | | `-2
+| | `-;
+| `-}
 `-}
)txt"},
   };



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


[PATCH] D64573: [Syntax] Allow to mutate syntax trees

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:528
+void test() {
+  HALF_IF HALF_IF_2 else {}
+})cpp",

ilya-biryukov wrote:
> gribozavr2 wrote:
> > Could you also do something like:
> > 
> > ```
> > #define OPEN {
> > #define CLOSE }
> > 
> > void test1() {
> >   OPEN
> > 1;
> >   CLOSE
> > }
> > void test1() {
> >   OPEN
> > 1;
> >   }
> > }
> > ```
> Funnily enough, this causes an assertion failure, because binary-searching 
> with `isBeforeInTranslationUnit` finds `{` expanded from `OPEN` instead of 
> `1` when building a syntax tree.
> 
> I'll make use of a hash table for searching tokens by location and add the 
> test in the follow-up patch.
c1bbefef9d36e84e469513374ef404b9e354b262 adds the corresponding test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-18 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

Anastasia wrote:
> Do we actually need pragma for this extension? I.e. does it need to activate 
> any special mode in the compiler?
I'm not aware of any special mode required for this extension. These begin/end 
pragma lines were added to disable the extension by default as it is [[ 
https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
 | required ]] by the OpenCL extension spec. Is there any other mechanism which 
should be used for this purpose?
Probably, we should do the same for `cl_khr_mipmap_image`(and maybe others?), 
because with the current compiler, built-ins from this extension can be 
compiled successfully even if `#pragma OPENCL EXTENSION cl_khr_mipmap_image : 
disable` is specified. See https://godbolt.org/z/fNEWuG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71460



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-12-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 234501.
serge-sans-paille added a comment.

Patch rebased, validation ongoing. I'll merge that once I'm back from holidays, 
don't feel like commiting that 3h before holidays.

Thanks **a lot** @Meinersbur for all the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/examples/Bye/Bye.cpp
  llvm/examples/Bye/CMakeLists.txt
  llvm/examples/CMakeLists.txt
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/Feature/load_extension.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O0-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/include/polly/RegisterPasses.h
  polly/lib/CMakeLists.txt
  polly/lib/Plugin/Polly.cpp
  polly/lib/Polly.cpp
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_

[PATCH] D70568: [Support] Possibly use exception handler in the Crash Recovery Context in the same way as global exceptions

2019-12-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I looked over this again, and also studied CrashRecoveryContext some more.

I don't really understand why this patch needs to modify the code for how the 
CRC is enabled and installed, etc.

I thought all we need for in-process-cc1 is to add the 
DumpStackAndCleanupOnFailure flag and behavior, nothing more.

Do you think this is possible, or am I missing something?


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

https://reviews.llvm.org/D70568



___
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-18 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 234506.
arichardson added a comment.

clang-format


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/test/tools/llvm-ranlib/help-message.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
+  -v --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,33 @@
 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 if (arg.front() == 'h') {
+  printHelpMessage();
+  return 0;
+} else if (arg.front() == 'v') {
+  cl::PrintVersionMessage();
+  return 0;
+} 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/help-message.test
===
--- llvm/test/tools/llvm-ranlib/help-message.test
+++ llvm/test/tools/llvm-ranlib/help-message.test
@@ -1,8 +1,17 @@
 ## Show that the help message for llvm-ranlib can be printed with either the
 ## long flag -help.
 
-# RUN: llvm-ranlib -h | FileCheck %s
-# RUN: llvm-ranlib -help | FileCheck %s
-# RUN: llvm-ranlib --help | FileCheck %s
+# RUN: llvm-ranlib -h | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib -help | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib --help | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib --version | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -version | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -v | FileCheck %s --check-prefix=VERSION
 
-# CHECK: USAGE: llvm-ranlib
+## Also check combined options (first -h/-v flag wins)
+# RUN: llvm-ranlib -Dh | FileCheck %s --check-prefix=HELP
+# RUN: llvm-ranlib -Dvh | FileCheck %s --check-prefix=VERSION
+# RUN: llvm-ranlib -Dhv | FileCheck %s --check-prefix=HELP
+
+# HELP: USAGE: llvm-ranlib
+# VERSION: LLVM version
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 sing

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

- Address comments
- Extend handling to:
  - var and function templates
  - non-auto case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596

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
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "AST.h"
 #include "Annotations.h"
 #include "Hover.h"
 #include "TestIndex.h"
@@ -130,12 +131,9 @@
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
- HI.Name = "vector";
+ HI.Name = "vector";
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},
   // Class template
   {R"cpp(
@@ -181,21 +179,10 @@
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Definition =
- R"cpp(template  class C, typename = char, int = 0,
-  bool Q = false, class... Ts>
-void foo())cpp";
+ HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
  HI.Parameters.emplace();
- HI.TemplateParameters = {
- {std::string("template  class"),
-  std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
- };
}},
   // Function decl
   {R"cpp(
@@ -1116,14 +1103,13 @@
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Function;
 HI.NamespaceScope = "";
-HI.Type = "T ()";
-HI.Definition = "template  T foo()";
+HI.Type = "int ()";
+HI.Definition = "template <> int foo()";
 HI.Documentation = "Templated function";
-HI.ReturnType = "T";
+HI.ReturnType = "int";
 HI.Parameters = std::vector{};
-HI.TemplateParameters = {
-{std::string("typename"), std::string("T"), llvm::None},
-};
+// FIXME: We should populate template parameters with arguments in
+// case of instantiations.
   }},
   {
   R"cpp(// Anonymous union
@@ -1271,6 +1257,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto function return with trailing type";
   }},
   {
   R"cpp(// trailing return type
@@ -1282,6 +1269,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "trailing return type";
   }},
   {
   R"cpp(// auto in function return
@@ -1293,6 +1281,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto in function return";
   }},
   {
   R"cpp(// auto& in function return
@@ -1305,6 +1294,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto& in function return";
   }},
   {
   R"cpp(// auto* in function return
@@ -1317,6 +1307,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto* in function return";
   }},
   {
   R"cpp(// const auto& in function return
@@ -1329,6 +1320,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "const auto& in function return";
   }},
   {
   R"cpp(// decltype(auto) in function return
@@ -1340,6 +1332,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "decltype(auto) in function return";
   }},
   {
   R"cpp(// decltype(auto) reference in function return
@@ -1404,6 +1397,8 @@
   [](HoverInfo &

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

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

  failed: Clangd Unit Tests._/ClangdTests/Hover.DocsFromMostSpecial
  failed: lit.lit/shtest-format.py

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



___
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(NOP padding)

2019-12-18 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 234515.
skan added a comment.

1. rename `MCBoundaryAlignFragment::hasEmitNop()` to 
`MCBoundaryAlignFragment::canEmitNop()`

2. reduce the number of `MCBoundaryAlignFragment` emitted as possible


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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s

Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,63 @@
+# Check no nop or prefix is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:3: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:6: 89 d1movl%edx, %ecx
+# CHECK-NEXT:8: 31 c0xorl%eax, %eax
+# CHECK-NEXT:a: 31 c8xorl%ecx, %eax
+# CHECK-NEXT:c: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:f: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   12: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   15: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   18: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   1b: f3 abrep stosl%eax, %es:(%rdi)
+# CHECK-NEXT:   1d: 75 e4jne {{.*}}
+# CHECK-NEXT:   1f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   21: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   24: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   27: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   2a: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   2c: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   2e: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   31: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   34: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   37: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   3a: e8 00 00 00 00   callq   {{.*}}
+# CHECK-NEXT:   3f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   41: 75 e1jne {{.*}}
+
+.text
+.p2align 4,,15
+foo:
+shrl$2, %ecx
+.L1:
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+xorl%ecx, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+rep stosl
+jne.L1
+xorl%eax, %eax
+shrl$2, %ecx
+.L2:
+shrl$2, %ecx
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+callbar
+xorl%eax, %eax
+jne.L2
Index: llvm/test/MC/X86/align-branch-64-4a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-4a.s
@@ -0,0 +1,63 @@
+# Check rets are not aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s | llvm-objdump -d  - >%t2
+# RUN: cmp %t %t2
+
+# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d  - | FileChec

[PATCH] D64573: [Syntax] Allow to mutate syntax trees

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

Updated version LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64573



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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



Comment at: clang-tools-extra/clangd/Hover.cpp:188
+// Returns the decl that should be used for querying comments, either from 
index
+// or ast.
+const NamedDecl *getDeclForComment(const NamedDecl *D) {

NIT: AST



Comment at: clang-tools-extra/clangd/Hover.cpp:205
   const SymbolIndex *Index) {
-  if (!Index || !llvm::isa(D))
-return;
-  const NamedDecl &ND = *cast(D);
   // We only add documentation, so don't bother if we already have some.
+  if (!Hover.Documentation.empty() || !Index)

NIT: maybe add `assert(&ND == getDeclForComment(&ND))`?



Comment at: clang-tools-extra/clangd/Hover.cpp:377
 
-  if (HI.Name.empty()) {
+const auto *ND = getDeclForComment(D);
+HI.Documentation = getDeclComment(ASTCtx, *ND);

NIT: `ND` suggests it's the same as `D` with a different type.
I'd use a different name, even if it's larger, e.g. `CommentD`



Comment at: clang-tools-extra/clangd/Hover.cpp:418
+const Decl *preferInstantiation(llvm::iterator_range Range) {
+  if (Range.empty())
+return nullptr;

This seems to be doing exactly the same thing as `explicitReferenceTargets` 
from `FindTarget.cpp`

WDYT about exposing the latter in `FindTarget.h` and using it here?
It seems to be pretty well-defined and useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



___
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(NOP padding)

2019-12-18 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 234520.
skan added a comment.

Fix a typo in `MCFragment::dump()`


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

https://reviews.llvm.org/D70157

Files:
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCAssembler.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-64-1a.s
  llvm/test/MC/X86/align-branch-64-1b.s
  llvm/test/MC/X86/align-branch-64-1c.s
  llvm/test/MC/X86/align-branch-64-1d.s
  llvm/test/MC/X86/align-branch-64-2a.s
  llvm/test/MC/X86/align-branch-64-2b.s
  llvm/test/MC/X86/align-branch-64-2c.s
  llvm/test/MC/X86/align-branch-64-3a.s
  llvm/test/MC/X86/align-branch-64-4a.s
  llvm/test/MC/X86/align-branch-64-5a.s

Index: llvm/test/MC/X86/align-branch-64-5a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-5a.s
@@ -0,0 +1,63 @@
+# Check no nop or prefix is inserted if no branch cross or is against the boundary
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp+indirect+call+ret  %s | llvm-objdump -d  - > %t1
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t2
+# RUN: cmp %t1 %t2
+# RUN: FileCheck --input-file=%t1 %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:3: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:6: 89 d1movl%edx, %ecx
+# CHECK-NEXT:8: 31 c0xorl%eax, %eax
+# CHECK-NEXT:a: 31 c8xorl%ecx, %eax
+# CHECK-NEXT:c: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:f: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   12: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   15: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   18: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   1b: f3 abrep stosl%eax, %es:(%rdi)
+# CHECK-NEXT:   1d: 75 e4jne {{.*}}
+# CHECK-NEXT:   1f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   21: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   24: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   27: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   2a: 89 d1movl%edx, %ecx
+# CHECK-NEXT:   2c: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   2e: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   31: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   34: c1 e9 02 shrl$2, %ecx
+# CHECK-NEXT:   37: f6 c2 02 testb   $2, %dl
+# CHECK-NEXT:   3a: e8 00 00 00 00   callq   {{.*}}
+# CHECK-NEXT:   3f: 31 c0xorl%eax, %eax
+# CHECK-NEXT:   41: 75 e1jne {{.*}}
+
+.text
+.p2align 4,,15
+foo:
+shrl$2, %ecx
+.L1:
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+xorl%ecx, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+rep stosl
+jne.L1
+xorl%eax, %eax
+shrl$2, %ecx
+.L2:
+shrl$2, %ecx
+shrl$2, %ecx
+movl%edx, %ecx
+xorl%eax, %eax
+shrl$2, %ecx
+shrl$2, %ecx
+shrl$2, %ecx
+testb$2, %dl
+callbar
+xorl%eax, %eax
+jne.L2
Index: llvm/test/MC/X86/align-branch-64-4a.s
===
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-4a.s
@@ -0,0 +1,63 @@
+# Check rets are not aligned with option --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -d  - > %t
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc+jmp %s | llvm-objdump -d  - >%t2
+# RUN: cmp %t %t2
+
+# Check only rets are aligned with option --x86-align-branch-boundary=32 --x86-align-branch=ret
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-objdump -d  - | FileCheck %s
+
+# CHECK:  foo:
+# CHECK-NEXT:0: 64 89 04 25 01 00 00 00  movl%eax, %fs:1
+# CHECK-NEXT

[PATCH] D69223: WDocumentation: Implement the \anchor.

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

LGTM, feel free to push.




Comment at: clang/lib/AST/TextNodeDumper.cpp:493
+  case comments::InlineCommandComment::RenderAnchor:
+OS << " RenderAnchor";
+break;

Mordante wrote:
> Mordante wrote:
> > gribozavr2 wrote:
> > > Please add a test for this one to 
> > > clang/test/Index/comment-to-html-xml-conversion.cpp (search for 
> > > RenderEmphasized in that file).
> > I already added a test to 
> > `clang/test/Index/comment-to-html-xml-conversion.cpp`. I forgot to add a 
> > test to `clang/test/AST/ast-dump-comment.cpp`, is this the file you meant?
> @gribozavr2 In case you missed the question above, could you have a look at 
> the question?
Sorry, I probably missed your edit to 
`clang/test/Index/comment-to-html-xml-conversion.cpp` when typing that comment. 
`ast-dump-comment.cpp` is not as extensive, so I'm not concerned about having 
to add the test there. If you want to -- feel free, but I think that is 
optional.


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

https://reviews.llvm.org/D69223



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

- Expose explicitReferenceTargets


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  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
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "AST.h"
 #include "Annotations.h"
 #include "Hover.h"
 #include "TestIndex.h"
@@ -130,12 +131,9 @@
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
- HI.Name = "vector";
+ HI.Name = "vector";
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},
   // Class template
   {R"cpp(
@@ -181,21 +179,10 @@
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Definition =
- R"cpp(template  class C, typename = char, int = 0,
-  bool Q = false, class... Ts>
-void foo())cpp";
+ HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
  HI.Parameters.emplace();
- HI.TemplateParameters = {
- {std::string("template  class"),
-  std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
- };
}},
   // Function decl
   {R"cpp(
@@ -464,8 +451,6 @@
  HI.Type = "enum Color";
  HI.Value = "GREEN (1)"; // Symbolic when hovering on an expression.
}},
-  // FIXME: We should use the Decl referenced, even if from an implicit
-  // instantiation. Then the scope would be Add<1, 2>.
   {R"cpp(
 template struct Add {
   static constexpr int result = a + b;
@@ -474,11 +459,11 @@
 )cpp",
[](HoverInfo &HI) {
  HI.Name = "result";
- HI.Definition = "static constexpr int result = a + b";
+ HI.Definition = "static constexpr int result = 1 + 2";
  HI.Kind = index::SymbolKind::StaticProperty;
  HI.Type = "const int";
  HI.NamespaceScope = "";
- HI.LocalScope = "Add::";
+ HI.LocalScope = "Add<1, 2>::";
  HI.Value = "3";
}},
   {R"cpp(
@@ -1116,14 +1101,13 @@
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Function;
 HI.NamespaceScope = "";
-HI.Type = "T ()";
-HI.Definition = "template  T foo()";
+HI.Type = "int ()";
+HI.Definition = "template <> int foo()";
 HI.Documentation = "Templated function";
-HI.ReturnType = "T";
+HI.ReturnType = "int";
 HI.Parameters = std::vector{};
-HI.TemplateParameters = {
-{std::string("typename"), std::string("T"), llvm::None},
-};
+// FIXME: We should populate template parameters with arguments in
+// case of instantiations.
   }},
   {
   R"cpp(// Anonymous union
@@ -1271,6 +1255,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto function return with trailing type";
   }},
   {
   R"cpp(// trailing return type
@@ -1282,6 +1267,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "trailing return type";
   }},
   {
   R"cpp(// auto in function return
@@ -1293,6 +1279,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto in function return";
   }},
   {
   R"cpp(// auto& in function return
@@ -1305,6 +1292,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto& in function return";
   }},
   {
   R"cpp(// auto* in function return
@@ -

[PATCH] D70856: [Syntax] Build nodes for simple cases of top level declarations

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

Updated version LGTM, thanks!




Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:346
+/// static_assert(, )
+/// static_assert()
+class StaticAssertDeclaration final : public Declaration {

ilya-biryukov wrote:
> gribozavr2 wrote:
> > Why no semicolon, here and in other newly-added comments below? Seems like 
> > these syntax nodes cover the semicolon as implemented.
> I was torn on this...
> In the statement position, this semicolon is not consumed by declarations 
> (instead, it's consumed by `DeclarationStatement`). However, it **is** 
> consumed at the namespace and TU level.
> 
> I've decided to punt on this until we add accessors for the semicolon and add 
> a comment to the corresponding accessors, explaining the percularities of its 
> placement.
> 
> Decided to keep it out from the comment, since it's not present **sometimes**.
> 
> Don't have a strong opinion here, can add it back
It is fine to punt until later.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:378
+
+/// namespace  {  }
+class NamespaceDefinition final : public Declaration {

ilya-biryukov wrote:
> gribozavr2 wrote:
> > Isn't it a "nested name specifier" since C++17?
> nested-name-specifier is a qualifier
> it's actually something like `? `. Which 
> is quite verbose, so decided decided to go with `` to keep it small for 
> now.
> 
> May have to change to something more suitable when we actually start building 
> syntax trees for names.
> 
> Does keeping `` make sense for now? Do you think we should be more 
> precise from the start?
> 
> Happy to go in either direction, actually.
"name" != "identifier" so it is technically correct. Once we have accessors, 
they should have comments about what the actual options for the name are, and 
with that, I don't mind having just "name" here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70856



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

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

  failed: lit.lit/shtest-format.py

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D70568: [Support] Possibly use exception handler in the Crash Recovery Context in the same way as global exceptions

2019-12-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D70568#1789527 , @hans wrote:

> I looked over this again, and also studied CrashRecoveryContext some more.
>
> I don't really understand why this patch needs to modify the code for how the 
> CRC is enabled and installed, etc.
>
> I thought all we need for in-process-cc1 is to add the 
> DumpStackAndCleanupOnFailure flag and behavior, nothing more.
>
> Do you think this is possible, or am I missing something?


Hi Hans,
Sorry for taking time to respond.
The way `Enable()/Disable()` is currently implemented will not work when the 
tool executes jobs in parallel (ie. llvm-buildozer 
 I presented at LLVM conference; 
or our re-implementation of /MP 

 which I haven't published yet). It needs refcounting, otherwise one instance 
might disable the CRC while other threads are running, which effectively 
disables the crash handlers.
But we can discuss that in a separate review if you prefer. I'll remove it from 
this patch unless you say otherwise.


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

https://reviews.llvm.org/D70568



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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-12-18 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

As a follow up to my previous post, I have sent patches to clean up all of the 
warnings that I see in the Linux kernel. However, I found one that I do believe 
is a false positive:

  ../drivers/staging/uwb/allocator.c:353:3: warning: misleading indentation; 
statement is not part of the previous 'else' [-Wmisleading-indentation]
alloc_found:
^
  ../drivers/staging/uwb/allocator.c:350:2: note: previous statement is here
  else
  ^
  1 warning generated.

Corresponding to 
https://github.com/torvalds/linux/blob/2187f215ebaac73ddbd814696d7c7fa34f0c3de0/drivers/staging/uwb/allocator.c#L346-L353.

Simplified:

  $ cat test.c
  int a(int b, int c) {
if (b)
goto label;
  
if (c)
return 0;
  
label:
return 1;
  }
  
  $ clang -Wmisleading-indentation -o /dev/null -c test.c
  test.c:8:3: warning: misleading indentation; statement is not part of the 
previous 'if' [-Wmisleading-indentation]
label:
^
  test.c:5:2: note: previous statement is here
  if (c)
  ^
  1 warning generated.

goto labels are unaffected by indentation so there should be no warning here. 
While I think that the labels should be unindented for style, the driver is 
marked as obsolete and is scheduled to be deleted so I am not sure such a patch 
would be welcomed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638



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


[clang] d129aa1 - Add an -fno-temp-file flag for compilation

2019-12-18 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2019-12-18T15:07:43+01:00
New Revision: d129aa1d5369781deff6c6b854cb612e160d3fb2

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

LOG: Add an -fno-temp-file flag for compilation

Our build system does not handle randomly named files created during
the build well. We'd prefer to write compilation output directly
without creating a temporary file. Function parameters already
existed to control this behavior but were not exposed all the way out
to the command line.

Patch by Zachary Henkel!

Differential revision: https://reviews.llvm.org/D70615

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 38504d6330da..2a72b87355d0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1563,6 +1563,9 @@ def fno_strict_enums : Flag<["-"], "fno-strict-enums">, 
Group;
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 70eb3425b0da..305a66006218 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@ class FrontendOptions {
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5bf0efcf0503..5febd55cc0d6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5029,6 +5029,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 05ecc3f447cc..688f21dd0908 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@ CompilerInstance::createDefaultOutputFile(bool Binary, 
StringRef InFile,
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8631536e8f60..d68244dce5c4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,6 +1887,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index aeea63ca323f..1dbfad06a710 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@ G

[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D70615#1789142 , @zahen wrote:

> Any additional changes required?  If not could someone please submit on my 
> behalf?  @rnk, @hans, @thakis ?


Sorry, this got lost in my email. I've committed it as 
d129aa1d5369781deff6c6b854cb612e160d3fb2 
.


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

https://reviews.llvm.org/D70615



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


[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd129aa1d5369 (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70615

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -588,3 +588,6 @@
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-GOOD-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled
+
+// RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-TEMP-FILE %s
+// CHECK-NO-TEMP-FILE: "-fno-temp-file"
\ No newline at end of file
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
   /*RemoveFileOnSignal=*/false, InFile,
-  /*Extension=*/"", /*UseTemporary=*/true);
+  /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
   if (!OS)
 return nullptr;
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,6 +1887,7 @@
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5029,6 +5029,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1563,6 +1563,9 @@
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_

[PATCH] D71659: Adde new option to allow setting spaces before and after the operator

2019-12-18 Thread Luis Pinto via Phabricator via cfe-commits
Luis created this revision.
Luis added reviewers: djasper, klimek, owenpan, mitchell-stellar.
Luis added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The new option is called SpaceBeforeAndAfterArrows

True:
(pointer instance) -> (member)

False:
(pointer instance)->(member)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71659

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp

Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3045,8 +3045,11 @@
 return Right.is(TT_TemplateCloser) && Left.is(TT_TemplateCloser) &&
(Style.Standard < FormatStyle::LS_Cpp11 || Style.SpacesInAngles);
   }
-  if (Right.isOneOf(tok::arrow, tok::arrowstar, tok::periodstar) ||
-  Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
+  if (Left.is(tok::arrow) || Right.is(tok::arrow)) {
+return Style.SpaceBeforeAndAfterArrows;
+  }
+  if (Right.isOneOf(tok::arrowstar, tok::periodstar) ||
+  Left.isOneOf(tok::period, tok::arrowstar, tok::periodstar) ||
   (Right.is(tok::period) && Right.isNot(TT_DesignatedInitializerPeriod)))
 return false;
   if (!Style.SpaceBeforeAssignmentOperators && Left.isNot(TT_TemplateCloser) &&
@@ -3058,7 +3061,8 @@
   if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
 // Generally don't remove existing spaces between an identifier and "::".
 // The identifier might actually be a macro name such as ALWAYS_INLINE. If
-// this turns out to be too lenient, add analysis of the identifier itself.
+// this turns out to be too lenient, add analysis of the identifier
+// itself.
 return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd();
   if (Right.is(tok::coloncolon) &&
   !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
@@ -3098,7 +3102,8 @@
   return spaceRequiredBetween(Line, Left, Right);
 }
 
-// Returns 'true' if 'Tok' is a brace we'd want to break before in Allman style.
+// Returns 'true' if 'Tok' is a brace we'd want to break before in Allman
+// style.
 static bool isAllmanBrace(const FormatToken &Tok) {
   return Tok.is(tok::l_brace) && Tok.BlockKind == BK_Block &&
  !Tok.isOneOf(TT_ObjCBlockLBrace, TT_LambdaLBrace, TT_DictLiteral);
@@ -3122,8 +3127,9 @@
 // kw_var/kw_let are pseudo-tokens that are tok::identifier, so match
 // above.
 !Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let))
-  // Object literals on the top level of a file are treated as "enum-style".
-  // Each key/value pair is put on a separate line, instead of bin-packing.
+  // Object literals on the top level of a file are treated as
+  // "enum-style". Each key/value pair is put on a separate line, instead
+  // of bin-packing.
   return true;
 if (Left.is(tok::l_brace) && Line.Level == 0 &&
 (Line.startsWith(tok::kw_enum) ||
@@ -3155,8 +3161,8 @@
   }
 
   // If the last token before a '}', ']', or ')' is a comma or a trailing
-  // comment, the intention is to insert a line break after it in order to make
-  // shuffling around entries easier. Import statements, especially in
+  // comment, the intention is to insert a line break after it in order to
+  // make shuffling around entries easier. Import statements, especially in
   // JavaScript, can be an exception to this rule.
   if (Style.JavaScriptWrapImports || Line.Type != LT_ImportStatement) {
 const FormatToken *BeforeClosingBrace = nullptr;
@@ -3261,18 +3267,17 @@
   if (Right.is(TT_ProtoExtensionLSquare))
 return true;
 
-  // In text proto instances if a submessage contains at least 2 entries and at
-  // least one of them is a submessage, like A { ... B { ... } ... },
-  // put all of the entries of A on separate lines by forcing the selector of
-  // the submessage B to be put on a newline.
+  // In text proto instances if a submessage contains at least 2 entries and
+  // at least one of them is a submessage, like A { ... B { ... } ... }, put
+  // all of the entries of A on separate lines by forcing the selector of the
+  // submessage B to be put on a newline.
   //
   // Example: these can stay on one line:
   // a { scalar_1: 1 scalar_2: 2 }
   // a { b { key: value } }
   //
-  // and these entries need to be on a new line even if putting them all in one
-  // line is under the column limit:
-  // a {
+  // and these entries need to be on a new line even if putting them all in
+  // one line is under the column limit: a {
   //   scalar: 1
   //   b { key: value }
   // }
@@ -3281,11 +3286,12 @@
   // siblings, *and* breaking before a field that follows a submessage field.
   //
   // Be careful to exclude the case  [proto.ext] { ... } since the `]` is
-  // the TT_SelectorName there, but we don't 

[PATCH] D71659: [clang-format] Added new option to allow setting spaces before and after the operator

2019-12-18 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar requested changes to this revision.
mitchell-stellar added a comment.
This revision now requires changes to proceed.

This feature is missing unit tests. Also, what is the reason for all the 
comment changes? I don't think the changed comment lines originally exceeded 80 
characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71659



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


[PATCH] D71463: Implement VectorType conditional operator GNU extension.

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

Ping :)


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

https://reviews.llvm.org/D71463



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


[PATCH] D71661: I broke clangd

2019-12-18 Thread Mikhail Goncharov via Phabricator via cfe-commits
goncharov created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
goncharov removed subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, 
kadircet, usaxena95, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71661

Files:
  clang-tools-extra/clangd/CompileCommands.cpp


Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,13 +7,13 @@
 
//===--===//
 
 #include "CompileCommands.h"
-#include "Logger.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "Logger.h"
 #include "llvm/Support/Program.h"
 
 namespace clang {
@@ -34,9 +34,7 @@
   llvm::Optional Redirects[3] = {
   /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
   vlog("Invoking {0} to find clang installation", *Xcrun);
-  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
-  /*Env=*/llvm::None, Redirects,
-  /*SecondsToWait=*/10);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv, /*Env=*/llvm::None, 
Redirects, /*SecondsToWait=*/10);
   if (Ret != 0) {
 log("xcrun exists but failed with code {0}. "
 "If you have a non-apple toolchain, this is OK. "
@@ -84,7 +82,7 @@
   // because cc1 (not the driver!) will find libc++ relative to argv[0].
 #ifdef __APPLE__
   if (auto MacClang = queryXcrun({"xcrun", "--find", "clang"}))
-return resolve(std::move(*MacClang));
+return resolve(std::move(*McCree));
 #endif
   // On other platforms, just look for compilers on the PATH.
   for (const char *Name : {"clang", "gcc", "cc"})


Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,13 +7,13 @@
 //===--===//
 
 #include "CompileCommands.h"
-#include "Logger.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "Logger.h"
 #include "llvm/Support/Program.h"
 
 namespace clang {
@@ -34,9 +34,7 @@
   llvm::Optional Redirects[3] = {
   /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
   vlog("Invoking {0} to find clang installation", *Xcrun);
-  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
-  /*Env=*/llvm::None, Redirects,
-  /*SecondsToWait=*/10);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv, /*Env=*/llvm::None, Redirects, /*SecondsToWait=*/10);
   if (Ret != 0) {
 log("xcrun exists but failed with code {0}. "
 "If you have a non-apple toolchain, this is OK. "
@@ -84,7 +82,7 @@
   // because cc1 (not the driver!) will find libc++ relative to argv[0].
 #ifdef __APPLE__
   if (auto MacClang = queryXcrun({"xcrun", "--find", "clang"}))
-return resolve(std::move(*MacClang));
+return resolve(std::move(*McCree));
 #endif
   // On other platforms, just look for compilers on the PATH.
   for (const char *Name : {"clang", "gcc", "cc"})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70568: [Support] Possibly use exception handler in the Crash Recovery Context in the same way as global exceptions

2019-12-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> The way `Enable()/Disable()` is currently implemented will not work when the 
> tool executes jobs in parallel (ie. llvm-buildozer 
>  I presented at LLVM conference; 
> or our re-implementation of /MP 
> 
>  which I haven't published yet). It needs refcounting, otherwise one instance 
> might disable the CRC while other threads are running, which effectively 
> disables the crash handlers.
>  But we can discuss that in a separate review if you prefer. I'll remove it 
> from this patch unless you say otherwise.

Yes, I think it would be good to deal with that separately, to allow for 
incremental progress.


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

https://reviews.llvm.org/D70568



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


[PATCH] D71594: testing clang-tidy

2019-12-18 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D71594#1789275 , @goncharov wrote:

> In D71594#1788194 , @Eugene.Zelenko 
> wrote:
>
> > Where set of Clang-tidy checks come from? .clang-tidy? Could stricter set 
> > of custom rules be used?
>
>
> Yes, clang-tidy uses the .clang-tidy. Do you want to enable additional rules 
> for a subproject?


It really depends on state of each project. There are a lot of legacy issues, 
but it makes sense to treat new code with more demands, for example with 
respect to modernize checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71594



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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



Comment at: clang-tools-extra/clangd/FindTarget.h:194
+llvm::SmallVector
+explicitReferenceTargets(ast_type_traits::DynTypedNode N,
+ DeclRelationSet Mask = {});

No need to fix this.

The name could probably be better, but we can fix this later. Don't have any 
good ideas.



Comment at: clang-tools-extra/clangd/FindTarget.h:195
+explicitReferenceTargets(ast_type_traits::DynTypedNode N,
+ DeclRelationSet Mask = {});
 } // namespace clangd

Could you document `Mask` can't have `TemplatePattern` and 
`TemplateInstantiation` bits?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:136
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},

Is this the intended behavior?
I would've interepreted `Definition` as something that was written in the 
source code, but this one here is definitely synthesized by the compiler.

I'm happy to go either way, just wanted to make sure this is our conscious 
choice and understand why we're doing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D71652: [clangd] Replace shortenNamespace with getQualification

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



Comment at: clang-tools-extra/clangd/AST.cpp:305
+  llvm::raw_string_ostream OS(Result);
+  if (auto *TD = QT->getAsTagDecl())
+OS << getQualification(CurContext.getParentASTContext(), &CurContext, TD,

Why not use `explicitTargetReferences` here? This should handle typedefs (and 
potentially other things) as well.
I'm not sure we can tests those, as `auto` might have all typedefs stripped of, 
though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71652



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


[PATCH] D71659: [clang-format] Added new option to allow setting spaces before and after the operator

2019-12-18 Thread Luis Pinto via Phabricator via cfe-commits
Luis added a comment.

In D71659#1789694 , @mitchell-stellar 
wrote:

> This feature is missing unit tests. Also, what is the reason for all the 
> comment changes? I don't think the changed comment lines originally exceeded 
> 80 characters.


Yup, I will add the unit-test when I have time, regarding the comments, it's 
really weird because I'm using clang-format to format the file on save, I'll 
double check and try to revert those comment changes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71659



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


[PATCH] D71615: [clang] [cmake] Fix gen_ast_dump_json_test.py binary dir

2019-12-18 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6207b060ad80: [clang] [cmake] Fix gen_ast_dump_json_test.py 
binary dir (authored by mgorny).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71615

Files:
  clang/test/CMakeLists.txt


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -138,7 +138,8 @@
 
 # Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
 # it without having to pass the --clang= argument
-configure_file(AST/gen_ast_dump_json_test.py 
${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)
+configure_file(AST/gen_ast_dump_json_test.py
+  ${CLANG_BINARY_DIR}/bin/gen_ast_dump_json_test.py COPYONLY)
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -138,7 +138,8 @@
 
 # Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
 # it without having to pass the --clang= argument
-configure_file(AST/gen_ast_dump_json_test.py ${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)
+configure_file(AST/gen_ast_dump_json_test.py
+  ${CLANG_BINARY_DIR}/bin/gen_ast_dump_json_test.py COPYONLY)
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

2019-12-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 2 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:136
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},

ilya-biryukov wrote:
> Is this the intended behavior?
> I would've interepreted `Definition` as something that was written in the 
> source code, but this one here is definitely synthesized by the compiler.
> 
> I'm happy to go either way, just wanted to make sure this is our conscious 
> choice and understand why we're doing this.
I also wasn't sure about this one, but thought this would be more useful to 
users.

Because shows more semantic information about the symbol under the cursor, and 
we want to achieve that with Hover.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

- Document limitation on Mask parameter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  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
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "AST.h"
 #include "Annotations.h"
 #include "Hover.h"
 #include "TestIndex.h"
@@ -130,12 +131,9 @@
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
- HI.Name = "vector";
+ HI.Name = "vector";
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},
   // Class template
   {R"cpp(
@@ -181,21 +179,10 @@
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Definition =
- R"cpp(template  class C, typename = char, int = 0,
-  bool Q = false, class... Ts>
-void foo())cpp";
+ HI.Definition = "template <> void foo>()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
  HI.Parameters.emplace();
- HI.TemplateParameters = {
- {std::string("template  class"),
-  std::string("C"), llvm::None},
- {std::string("typename"), llvm::None, std::string("char")},
- {std::string("int"), llvm::None, std::string("0")},
- {std::string("bool"), std::string("Q"), std::string("false")},
- {std::string("class..."), std::string("Ts"), llvm::None},
- };
}},
   // Function decl
   {R"cpp(
@@ -464,8 +451,6 @@
  HI.Type = "enum Color";
  HI.Value = "GREEN (1)"; // Symbolic when hovering on an expression.
}},
-  // FIXME: We should use the Decl referenced, even if from an implicit
-  // instantiation. Then the scope would be Add<1, 2>.
   {R"cpp(
 template struct Add {
   static constexpr int result = a + b;
@@ -474,11 +459,11 @@
 )cpp",
[](HoverInfo &HI) {
  HI.Name = "result";
- HI.Definition = "static constexpr int result = a + b";
+ HI.Definition = "static constexpr int result = 1 + 2";
  HI.Kind = index::SymbolKind::StaticProperty;
  HI.Type = "const int";
  HI.NamespaceScope = "";
- HI.LocalScope = "Add::";
+ HI.LocalScope = "Add<1, 2>::";
  HI.Value = "3";
}},
   {R"cpp(
@@ -1116,14 +1101,13 @@
 HI.Name = "foo";
 HI.Kind = index::SymbolKind::Function;
 HI.NamespaceScope = "";
-HI.Type = "T ()";
-HI.Definition = "template  T foo()";
+HI.Type = "int ()";
+HI.Definition = "template <> int foo()";
 HI.Documentation = "Templated function";
-HI.ReturnType = "T";
+HI.ReturnType = "int";
 HI.Parameters = std::vector{};
-HI.TemplateParameters = {
-{std::string("typename"), std::string("T"), llvm::None},
-};
+// FIXME: We should populate template parameters with arguments in
+// case of instantiations.
   }},
   {
   R"cpp(// Anonymous union
@@ -1271,6 +1255,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto function return with trailing type";
   }},
   {
   R"cpp(// trailing return type
@@ -1282,6 +1267,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "trailing return type";
   }},
   {
   R"cpp(// auto in function return
@@ -1293,6 +1279,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto in function return";
   }},
   {
   R"cpp(// auto& in function return
@@ -1305,6 +1292,7 @@
   [](HoverInfo &HI) {
 HI.Name = "Bar";
 HI.Kind = index::SymbolKind::Struct;
+HI.Documentation = "auto& in function return";
   }},
   {
   R"cpp(// auto* in function retur

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

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

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

  failed: lit.lit/shtest-format.py

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



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


[PATCH] D71598: [clangd] Filter implicit references from index while renaming

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



Comment at: clang-tools-extra/clangd/SourceCode.cpp:217
 
+SourceLocation positionToSourceLoc(const SourceManager &SM, Position Pos,
+   StringRef Filename) {

this one isn't used anywhere?



Comment at: clang-tools-extra/clangd/SourceCode.cpp:1136
 
+std::vector filterRenameRanges(const SourceManager &SM,
+  StringRef Filename,

SM doesn't seem to be necessary, as `lex` already provides that in the callback.



Comment at: clang-tools-extra/clangd/SourceCode.h:301
 
+/// Removes ranges with implicit references to the renamed symbol (e.g. in 
macro
+/// expansions).

i don't think it is necessary for this function to be made public, it should be 
OK for it to leave in rename.cpp as a helper.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:368
+// Filter out possible implicit references returned from the index.
+const auto FilteredRanges = filterRenameRanges(
+SM, FileAndOccurrences.first(),

this one should go after `adjustRenameRanges`



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:368
+// Filter out possible implicit references returned from the index.
+const auto FilteredRanges = filterRenameRanges(
+SM, FileAndOccurrences.first(),

kadircet wrote:
> this one should go after `adjustRenameRanges`
both this and `adjustRenameRanges` seems to be lexing the source code to get 
identifier locations.

can we lex the file only a single time instead and make use of the result in 
both of the functions?
I would suggest moving `collectIdentifierRanges` into here and passing the 
result as a parameter to both of the functions.

as for implementation of `filterRenameRanges` you might wanna return 
intersection of `RenameRanges` and result of `collectIdentifierRanges`


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

https://reviews.llvm.org/D71598



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 234554.
lildmh marked 3 inline comments as done.
lildmh added a comment.

Address Alexey's comments to change mapper function size and refactor code


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

https://reviews.llvm.org/D67833

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.

[clang] b19d87b - Revert "Add an -fno-temp-file flag for compilation"

2019-12-18 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2019-12-18T09:05:09-08:00
New Revision: b19d87b16f81e7c0a22a0a103c867c1b844eb8bc

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

LOG: Revert "Add an -fno-temp-file flag for compilation"

This reverts commit d129aa1d5369781deff6c6b854cb612e160d3fb2.

This broke the MSan buildbots. More information available in the
original PR: https://reviews.llvm.org/D70615

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a72b87355d0..38504d6330da 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1563,9 +1563,6 @@ def fno_strict_enums : Flag<["-"], "fno-strict-enums">, 
Group;
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
-def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
-  Flags<[CC1Option, CoreOption]>, HelpText<
-  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 305a66006218..70eb3425b0da 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -294,9 +294,6 @@ class FrontendOptions {
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
-  /// Should a temporary file be used during compilation.
-  unsigned UseTemporary : 1;
-
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5febd55cc0d6..5bf0efcf0503 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5029,7 +5029,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
-  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 688f21dd0908..05ecc3f447cc 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@ CompilerInstance::createDefaultOutputFile(bool Binary, 
StringRef InFile,
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  getFrontendOpts().UseTemporary);
+  /*UseTemporary=*/true);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d68244dce5c4..8631536e8f60 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,7 +1887,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
-  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 1dbfad06a710..aeea63ca323f 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@ GeneratePCHAction::CreateOutputFile(CompilerInstance &CI, 
StringRef InFile,
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
  

[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

This change broke the sanitizer buildbots: 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/37446

Reverted in `b19d87b16f81e7c0a22a0a103c867c1b844eb8bc`

   TEST 'Clang-Unit :: 
Frontend/./FrontendTests/PCHPreambleTest.ParseWithBom' FAILED 

  Note: Google Test filter = PCHPreambleTest.ParseWithBom
  [==] Running 1 test from 1 test case.
  [--] Global test environment set-up.
  [--] 1 test from PCHPreambleTest
  [ RUN  ] PCHPreambleTest.ParseWithBom
  ==39360==WARNING: MemorySanitizer: use-of-uninitialized-value
  #0 0x149ea6f in 
clang::CompilerInstance::createOutputFile(llvm::StringRef, 
std::__1::error_code&, bool, bool, llvm::StringRef, llvm::StringRef, bool, 
bool, std::__1::basic_string, 
std::__1::allocator >*, std::__1::basic_string, std::__1::allocator >*) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:730:7
  #1 0x149bbb4 in 
clang::CompilerInstance::createOutputFile(llvm::StringRef, bool, bool, 
llvm::StringRef, llvm::StringRef, bool, bool) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:689:43
  #2 0x15a6240 in 
clang::GeneratePCHAction::CreateOutputFile(clang::CompilerInstance&, 
llvm::StringRef, std::__1::basic_string, 
std::__1::allocator >&) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendActions.cpp:141:10
  #3 0x1673eed in (anonymous 
namespace)::PrecompilePreambleAction::CreateASTConsumer(clang::CompilerInstance&,
 llvm::StringRef) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/PrecompiledPreamble.cpp:208:10
  #4 0x158cc44 in 
clang::FrontendAction::CreateWrappedASTConsumer(clang::CompilerInstance&, 
llvm::StringRef) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:152:43
  #5 0x1596d7c in 
clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, 
clang::FrontendInputFile const&) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:825:9
  #6 0x166b40e in 
clang::PrecompiledPreamble::Build(clang::CompilerInvocation const&, 
llvm::MemoryBuffer const*, clang::PreambleBounds, clang::DiagnosticsEngine&, 
llvm::IntrusiveRefCntPtr, 
std::__1::shared_ptr, bool, 
clang::PreambleCallbacks&) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/PrecompiledPreamble.cpp:345:13
  #7 0x1454602 in 
clang::ASTUnit::getMainBufferWithPrecompiledPreamble(std::__1::shared_ptr,
 clang::CompilerInvocation&, llvm::IntrusiveRefCntPtr, 
bool, unsigned int) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1378:54
  #8 0x145a5a5 in 
clang::ASTUnit::LoadFromCompilerInvocation(std::__1::shared_ptr,
 unsigned int, llvm::IntrusiveRefCntPtr) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1677:9
  #9 0x145bf13 in 
clang::ASTUnit::LoadFromCompilerInvocation(std::__1::shared_ptr,
 std::__1::shared_ptr, 
llvm::IntrusiveRefCntPtr, clang::FileManager*, bool, 
clang::CaptureDiagsKind, unsigned int, clang::TranslationUnitKind, bool, bool, 
bool) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Frontend/ASTUnit.cpp:1722:12
  #10 0x5d14d4 in (anonymous 
namespace)::PCHPreambleTest::ParseAST(std::__1::basic_string, std::__1::allocator > const&) 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/unittests/Frontend/PCHPreambleTest.cpp:98:36
  #11 0x5da805 in (anonymous 
namespace)::PCHPreambleTest_ParseWithBom_Test::TestBody() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/unittests/Frontend/PCHPreambleTest.cpp:230:32
  #12 0x790d1f in HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc
  #13 0x790d1f in testing::Test::Run() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
  #14 0x7937c3 in testing::TestInfo::Run() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
  #15 0x794d0f in testing::TestCase::Run() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
  #16 0x7b16d9 in testing::internal::UnitTestImpl::RunAllTests() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
  #17 0x7b03e7 in 
HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc
  #18 0x7b03e7 in testing::UnitTest::Run() 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
  #19 0x77b994 in RUN_ALL_TESTS 
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
  #20 0x77b994 in main 

[PATCH] D71666: [clang-tidy] Fix readability-const-return-type identifying the wrong `const` token

2019-12-18 Thread Ilya Mirsky via Phabricator via cfe-commits
ilya created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Replace tidy::utils::lexer::getConstQualifyingToken with a corrected and also
generalized to other qualifiers variant - getQualifyingToken.

Fixes: http://llvm.org/PR44326


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71666

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -37,6 +37,9 @@
 template 
 typename std::add_const::type n15(T v) { return v; }
 
+template 
+struct MyStruct {};
+
 template 
 class Klazz {
 public:
@@ -128,10 +131,46 @@
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz'
 // CHECK-FIXES: Klazz p12() {}
 
+const Klazz> p33() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz<
+// CHECK-FIXES: Klazz> p33() {}
+
 const Klazz* const p13() {}
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
 // CHECK-FIXES: const Klazz* p13() {}
 
+const Klazz* const volatile p14() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
+// CHECK-FIXES: const Klazz* volatile p14() {}
+
+const MyStruct<0 < 1> p34() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const MyStruct<0 < 1>'
+// CHECK-FIXES: MyStruct<0 < 1> p34() {}
+
+MyStruct<0 < 1> const p35() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const MyStruct<0 < 1>'
+// CHECK-FIXES: MyStruct<0 < 1> p35() {}
+
+Klazz const> const p36() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz const> p36() {}
+
+const Klazz const> *const p37() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz const> *p37() {}
+
+Klazz> const p38() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz> p38() {}
+
+const Klazz> p39() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz<
+// CHECK-FIXES: Klazz> p39() {}
+
+const Klazz 1)>> p40() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz 1)>> p40() {}
+
 // re-declaration of p15.
 const int p15();
 // CHECK-FIXES: int p15();
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.h
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.h
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.h
@@ -96,9 +96,14 @@
 /// token in ``Range`` that is responsible for const qualification. ``Range``
 /// must be valid with respect to ``SM``.  Returns ``None`` if no ``const``
 /// tokens are found.
-llvm::Optional getConstQualifyingToken(CharSourceRange Range,
-  const ASTContext &Context,
-  const SourceManager &SM);
+///
+/// Similar to ``getConstQualifyingToken`` above, but generalized to any
+/// of the following qualifier tokens: kw_const, kw_volatile, kw_restrict,
+/// kw___cm, kw___lpm.
+llvm::Optional getQualifyingToken(tok::TokenKind TK,
+ CharSourceRange Range,
+ const ASTContext &Context,
+ const SourceManager &SM);
 
 } // namespace lexer
 } // namespace utils
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -102,15 +102,20 @@
   return false;
 }
 
-llvm::Optional getConstQualifyingToken(CharSourceRange Range,
-  const ASTContext &Context,
-  const SourceManager &SM) {
+llvm::Optional getQualifyingToken(tok::TokenKind TK,
+ CharSourceRange Range,
+ const ASTContext &Context,
+ const SourceManager &SM) {
+  assert((TK == tok::kw_const || TK == tok::kw_volatile ||
+  TK == tok::kw_restrict) &&
+ "TK is not a qualifier keyword");
   std::pair LocInfo = SM.getDecomposedLoc(Range.getBegin());
   StringRef File = SM.getBufferData(LocInfo.first);
   Lexer RawLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(),
  File.begin(), File.data() + LocInfo.second, File.end());
-  llvm::Optional FirstConstTok;
-  Token LastTokInRange;
+  llvm::Optional LastMatchBeforeTemplate;
+  llvm::Optional La

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Looks much better in general, need to resolve last one issue with number of 
elements/size and you're ready.




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

So, we're still going to use number of elements for mappers? And pass it in the 
same parameter that in other cases is used as size in bytes? If so, point to it 
explicitly in the review for the runtime part so all are informed about it.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9244
+llvm::Function *
+CGOpenMPRuntime::getUserDefinedMapperFunc(const OMPDeclareMapperDecl *D) {
+  auto I = UDMMap.find(D);

`getOrEmitUserDefinedMapperFunc`?


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

https://reviews.llvm.org/D67833



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Wow, that's novel.  Please add a comment explaining that this is a compiler 
workaround, but otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Sorry for the breakage, and thanks for reverting! I'll try to follow up and fix 
this tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70615



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


RE: [PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Zachary Henkel via cfe-commits
Sorry about that!  I'll have a corrected patch ready later today.

-Original Message-
From: Hans Wennborg via Phabricator  
Sent: Wednesday, December 18, 2019 11:27 AM
To: Zachary Henkel ; rich...@metafoo.co.uk; 
r...@google.com; ztur...@roblox.com
Cc: mitchphill...@outlook.com; cfe-commits@lists.llvm.org; 
mlek...@skidmore.edu; blitzrak...@gmail.com; shen...@google.com; 
peter.wal...@arm.com
Subject: [PATCH] D70615: Add an -fno-temp-file flag for compilation

hans added a comment.

Sorry for the breakage, and thanks for reverting! I'll try to follow up and fix 
this tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70615%2Fnew%2F&data=02%7C01%7Czachary.henkel%40microsoft.com%7C8c9f4230a3e1425f5d3c08d783df770a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637122868116414326&sdata=w5Cos7SMZzeCzZP%2BEWmhPudY76WF8gGN4NibQWaXS5o%3D&reserved=0

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70615&data=02%7C01%7Czachary.henkel%40microsoft.com%7C8c9f4230a3e1425f5d3c08d783df770a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637122868116424324&sdata=SK5IxGgmlqvGmmZoa%2B5%2BkjwtpoeW26LpHXFu8lchqvA%3D&reserved=0



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


[PATCH] D71666: [clang-tidy] Fix readability-const-return-type identifying the wrong `const` token

2019-12-18 Thread Ilya Mirsky via Phabricator via cfe-commits
ilya updated this revision to Diff 234560.
ilya added a comment.

Fix documentation in LexerUtils.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71666

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -37,6 +37,9 @@
 template 
 typename std::add_const::type n15(T v) { return v; }
 
+template 
+struct MyStruct {};
+
 template 
 class Klazz {
 public:
@@ -128,10 +131,46 @@
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz'
 // CHECK-FIXES: Klazz p12() {}
 
+const Klazz> p33() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz<
+// CHECK-FIXES: Klazz> p33() {}
+
 const Klazz* const p13() {}
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
 // CHECK-FIXES: const Klazz* p13() {}
 
+const Klazz* const volatile p14() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
+// CHECK-FIXES: const Klazz* volatile p14() {}
+
+const MyStruct<0 < 1> p34() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const MyStruct<0 < 1>'
+// CHECK-FIXES: MyStruct<0 < 1> p34() {}
+
+MyStruct<0 < 1> const p35() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const MyStruct<0 < 1>'
+// CHECK-FIXES: MyStruct<0 < 1> p35() {}
+
+Klazz const> const p36() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz const> p36() {}
+
+const Klazz const> *const p37() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz const> *p37() {}
+
+Klazz> const p38() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz> p38() {}
+
+const Klazz> p39() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz<
+// CHECK-FIXES: Klazz> p39() {}
+
+const Klazz 1)>> p40() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz 1)>> p40() {}
+
 // re-declaration of p15.
 const int p15();
 // CHECK-FIXES: int p15();
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.h
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.h
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.h
@@ -92,13 +92,14 @@
  const SourceManager &SM,
  const LangOptions &LangOpts);
 
-/// Assuming that ``Range`` spans a const-qualified type, returns the ``const``
-/// token in ``Range`` that is responsible for const qualification. ``Range``
-/// must be valid with respect to ``SM``.  Returns ``None`` if no ``const``
+/// Assuming that ``Range`` spans a CVR-qualified type, returns the
+/// token in ``Range`` that is responsible for the qualification. ``Range``
+/// must be valid with respect to ``SM``.  Returns ``None`` if no qualifying
 /// tokens are found.
-llvm::Optional getConstQualifyingToken(CharSourceRange Range,
-  const ASTContext &Context,
-  const SourceManager &SM);
+llvm::Optional getQualifyingToken(tok::TokenKind TK,
+ CharSourceRange Range,
+ const ASTContext &Context,
+ const SourceManager &SM);
 
 } // namespace lexer
 } // namespace utils
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -102,15 +102,20 @@
   return false;
 }
 
-llvm::Optional getConstQualifyingToken(CharSourceRange Range,
-  const ASTContext &Context,
-  const SourceManager &SM) {
+llvm::Optional getQualifyingToken(tok::TokenKind TK,
+ CharSourceRange Range,
+ const ASTContext &Context,
+ const SourceManager &SM) {
+  assert((TK == tok::kw_const || TK == tok::kw_volatile ||
+  TK == tok::kw_restrict) &&
+ "TK is not a qualifier keyword");
   std::pair LocInfo = SM.getDecomposedLoc(Range.getBegin());
   StringRef File = SM.getBufferData(LocInfo.first);
   Lexer RawLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(),
  File.begin(), File.data() 

[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Zachary Henkel via Phabricator via cfe-commits
zahen reopened this revision.
zahen added a comment.
This revision is now accepted and ready to land.

Sorry about that I'll add a corrected patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70615



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked 2 inline comments as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> So, we're still going to use number of elements for mappers? And pass it in 
> the same parameter that in other cases is used as size in bytes? If so, point 
> to it explicitly in the review for the runtime part so all are informed about 
> it.
From interface, the mapper function uses size in bytes now. Inside, it needs 
number of elements to iterate through all elements. This has no impact on the 
runtime part, since it looks like normal mapping from the interface. All 
conversion happens inside the mapper function which is completely generated by 
the compiler.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9244
+llvm::Function *
+CGOpenMPRuntime::getUserDefinedMapperFunc(const OMPDeclareMapperDecl *D) {
+  auto I = UDMMap.find(D);

ABataev wrote:
> `getOrEmitUserDefinedMapperFunc`?
I guess `getUserDefinedMapperFunc` is a better name? Because the user uses this 
function to get the mapper function. Emitting a mapper function is a side 
effect.


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

https://reviews.llvm.org/D67833



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


[PATCH] D70615: Add an -fno-temp-file flag for compilation

2019-12-18 Thread Zachary Henkel via Phabricator via cfe-commits
zahen updated this revision to Diff 234563.
zahen added a comment.

Fixed MemorySanitizer: use-of-uninitialized-value warning


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

https://reviews.llvm.org/D70615

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -571,3 +571,6 @@
 // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-GOOD-NOT: hasn't been enabled
 // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled
+
+// RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-TEMP-FILE %s
+// CHECK-NO-TEMP-FILE: "-fno-temp-file"
\ No newline at end of file
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
   /*RemoveFileOnSignal=*/false, InFile,
-  /*Extension=*/"", /*UseTemporary=*/true);
+  /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
   if (!OS)
 return nullptr;
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1886,6 +1886,7 @@
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
+  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  /*UseTemporary=*/true);
+  getFrontendOpts().UseTemporary);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4688,6 +4688,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
+  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -294,6 +294,9 @@
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
+  /// Should a temporary file be used during compilation.
+  unsigned UseTemporary : 1;
+
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.
@@ -442,7 +445,7 @@
 UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
 ASTDumpDecls(false), ASTDumpLookups(false),
 BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
-IncludeTimestamps(true), TimeTraceGranularity(500) {}
+IncludeTimestamps(true), UseTemporary(true), TimeTraceGranularity(500) 
{}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1559,6 +1559,9 @@
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
+def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
+  Flags<[CC1Option, CoreOption]>, HelpText<
+  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compil

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9244
+llvm::Function *
+CGOpenMPRuntime::getUserDefinedMapperFunc(const OMPDeclareMapperDecl *D) {
+  auto I = UDMMap.find(D);

lildmh wrote:
> ABataev wrote:
> > `getOrEmitUserDefinedMapperFunc`?
> I guess `getUserDefinedMapperFunc` is a better name? Because the user uses 
> this function to get the mapper function. Emitting a mapper function is a 
> side effect.
I meant something like `getOrCreate...` but it is up to you.


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

https://reviews.llvm.org/D67833



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

lildmh wrote:
> ABataev wrote:
> > So, we're still going to use number of elements for mappers? And pass it in 
> > the same parameter that in other cases is used as size in bytes? If so, 
> > point to it explicitly in the review for the runtime part so all are 
> > informed about it.
> From interface, the mapper function uses size in bytes now. Inside, it needs 
> number of elements to iterate through all elements. This has no impact on the 
> runtime part, since it looks like normal mapping from the interface. All 
> conversion happens inside the mapper function which is completely generated 
> by the compiler.
Ok. Then why do we need to convert size in bytes to number of elements here?


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

https://reviews.llvm.org/D67833



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


[PATCH] D71652: [clangd] Replace shortenNamespace with getQualification

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

- Use explicitTargetReferences
- Added some testing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71652

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

Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/DeclBase.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -25,29 +26,6 @@
 namespace clangd {
 namespace {
 
-TEST(ShortenNamespace, All) {
-  ASSERT_EQ("TestClass", shortenNamespace("TestClass", ""));
-
-  ASSERT_EQ("TestClass", shortenNamespace(
-  "testnamespace::TestClass", "testnamespace"));
-
-  ASSERT_EQ(
-  "namespace1::TestClass",
-  shortenNamespace("namespace1::TestClass", "namespace2"));
-
-  ASSERT_EQ("TestClass",
-shortenNamespace("testns1::testns2::TestClass",
- "testns1::testns2"));
-
-  ASSERT_EQ(
-  "testns2::TestClass",
-  shortenNamespace("testns1::testns2::TestClass", "testns1"));
-
-  ASSERT_EQ("TestClass",
-shortenNamespace(
-"testns1::TestClass", "testns1"));
-}
-
 TEST(GetDeducedType, KwAutoExpansion) {
   struct Test {
 StringRef AnnotatedCode;
@@ -166,14 +144,70 @@
   Case.Qualifications[I]);
   } else {
 EXPECT_EQ(getQualification(AST.getASTContext(),
-   D->getLexicalDeclContext(), D->getBeginLoc(),
-   TargetDecl, Case.VisibleNamespaces),
+   D->getLexicalDeclContext(), TargetDecl,
+   Case.VisibleNamespaces),
   Case.Qualifications[I]);
   }
 }
   }
 }
 
+TEST(ClangdAST, PrintType) {
+  const struct {
+llvm::StringRef Test;
+std::vector Types;
+  } Cases[] = {
+  {
+  R"cpp(
+namespace ns1 { namespace ns2 { class Foo {}; } }
+void insert(); // ns1::ns2::Foo
+namespace ns1 {
+  void insert(); // ns2::Foo
+  namespace ns2 {
+void insert(); // Foo
+  }
+}
+  )cpp",
+  {"ns1::ns2::Foo", "ns2::Foo", "Foo"},
+  },
+  {
+  R"cpp(
+namespace ns1 {
+  typedef int Foo;
+}
+void insert(); // ns1::Foo
+namespace ns1 {
+  void insert(); // Foo
+}
+  )cpp",
+  {"ns1::Foo", "Foo"},
+  },
+  };
+  for (const auto &Case : Cases) {
+Annotations Test(Case.Test);
+TestTU TU = TestTU::withCode(Test.code());
+ParsedAST AST = TU.build();
+std::vector InsertionPoints;
+const TypeDecl *TargetDecl = nullptr;
+findDecl(AST, [&](const NamedDecl &ND) {
+  if (ND.getNameAsString() == "Foo") {
+if (const auto *TD = llvm::dyn_cast(&ND)) {
+  TargetDecl = TD;
+  return true;
+}
+  } else if (ND.getNameAsString() == "insert")
+InsertionPoints.push_back(ND.getDeclContext());
+  return false;
+});
+
+ASSERT_EQ(InsertionPoints.size(), Case.Types.size());
+for (size_t I = 0, E = InsertionPoints.size(); I != E; ++I) {
+  const auto *DC = InsertionPoints[I];
+  EXPECT_EQ(printType(AST.getASTContext().getTypeDeclType(TargetDecl), *DC),
+Case.Types[I]);
+}
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -80,19 +80,7 @@
 
 /// Returns a QualType as string. The result doesn't contain unwritten scopes
 /// like annoymous/inline namespace.
-std::string printType(const QualType QT, const DeclContext &Context);
-
-/// Try to shorten the OriginalName by removing namespaces from the left of
-/// the string that are redundant in the CurrentNamespace. This way the type
-/// idenfier become shorter and easier to read.
-/// Limitation: It only handles the qualifier of the type itself, not that of
-/// templates.
-/// FIXME: change type of parameter CurrentNamespace to DeclContext ,
-/// take in to account using directives etc
-/// Example: shortenNamespace("ns1::MyClass", "ns1")
-///--> "MyClass"
-std::string shortenNamespace(const llvm::StringRef OriginalName,
- const llvm::StringRef CurrentNamespace);
+std::string printType(const QualType QT, const DeclContext &CurContext);
 
 /// Indicates if \p 

[PATCH] D71596: [clangd] Improve documentation for auto and implicit specs

2019-12-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:136
  HI.Kind = index::SymbolKind::Class;
- HI.Definition = "template  class vector {}";
- HI.TemplateParameters = {
- {std::string("typename"), std::string("T"), llvm::None},
- };
+ HI.Definition = "template <> class vector {}";
}},

kadircet wrote:
> ilya-biryukov wrote:
> > Is this the intended behavior?
> > I would've interepreted `Definition` as something that was written in the 
> > source code, but this one here is definitely synthesized by the compiler.
> > 
> > I'm happy to go either way, just wanted to make sure this is our conscious 
> > choice and understand why we're doing this.
> I also wasn't sure about this one, but thought this would be more useful to 
> users.
> 
> Because shows more semantic information about the symbol under the cursor, 
> and we want to achieve that with Hover.
I actually think it would be more useful to say `vector` in `Name` (or 
`Name` + `TemplateArguments` per Sam's comments) and have definition reflect 
what's written in the source code.

But up to you, can also keep as is.
We can always tweak it later if users complain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71596



___
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-18 Thread Brian Gesiak via Phabricator via cfe-commits
modocache requested changes to this revision.
modocache added a comment.
This revision now requires changes to proceed.

Great minds think alike! This looks like the patch I sent in November, D70579 
.  I only just committed it two days ago in 
rG376cf43 
, but I 
ought to have updated the bug report. Thanks for pointing this out!

Unfortunately we duplicated some work here, and so I'm not sure this patch is 
needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71542



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked 2 inline comments as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > So, we're still going to use number of elements for mappers? And pass it 
> > > in the same parameter that in other cases is used as size in bytes? If 
> > > so, point to it explicitly in the review for the runtime part so all are 
> > > informed about it.
> > From interface, the mapper function uses size in bytes now. Inside, it 
> > needs number of elements to iterate through all elements. This has no 
> > impact on the runtime part, since it looks like normal mapping from the 
> > interface. All conversion happens inside the mapper function which is 
> > completely generated by the compiler.
> Ok. Then why do we need to convert size in bytes to number of elements here?
This is used to 1) see if we are going to map an array of elements with mapper, 
and 2) iterate all to map them individually.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9244
+llvm::Function *
+CGOpenMPRuntime::getUserDefinedMapperFunc(const OMPDeclareMapperDecl *D) {
+  auto I = UDMMap.find(D);

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > `getOrEmitUserDefinedMapperFunc`?
> > I guess `getUserDefinedMapperFunc` is a better name? Because the user uses 
> > this function to get the mapper function. Emitting a mapper function is a 
> > side effect.
> I meant something like `getOrCreate...` but it is up to you.
Okay, sounds good


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

https://reviews.llvm.org/D67833



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


[PATCH] D71652: [clangd] Replace shortenNamespace with getQualification

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

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71652



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > So, we're still going to use number of elements for mappers? And pass 
> > > > it in the same parameter that in other cases is used as size in bytes? 
> > > > If so, point to it explicitly in the review for the runtime part so all 
> > > > are informed about it.
> > > From interface, the mapper function uses size in bytes now. Inside, it 
> > > needs number of elements to iterate through all elements. This has no 
> > > impact on the runtime part, since it looks like normal mapping from the 
> > > interface. All conversion happens inside the mapper function which is 
> > > completely generated by the compiler.
> > Ok. Then why do we need to convert size in bytes to number of elements here?
> This is used to 1) see if we are going to map an array of elements with 
> mapper, and 2) iterate all to map them individually.
Could you point where we have this kind of analysis here? Because I don't see 
anything affected by this change in the patch.


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

https://reviews.llvm.org/D67833



___
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-18 Thread Eric Astor via Phabricator via cfe-commits
epastor updated this revision to Diff 234567.
epastor added a comment.

- Removing accidental artifacts of local testing...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71436

Files:
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CodeGen/ms-inline-asm-64.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  clang/test/Parser/ms-inline-asm.c
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/TableGen/TGParser.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
===
--- llv

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

2019-12-18 Thread Philippe Daouadi via Phabricator via cfe-commits
blastrock abandoned this revision.
blastrock added a comment.

Indeed, I'm closing this then, I haven't tested your patch yet but the fix 
seems to be the exact same. You seem to have a better idea of what you are 
doing and your patch reflects that ^^

Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71542



___
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-18 Thread Eric Astor via Phabricator via cfe-commits
epastor updated this revision to Diff 234566.
epastor marked 2 inline comments as done.
epastor added a comment.

Fix issues around enum values and labels

- Only rewrite variables as offset operands; fixes crash due to conflicting 
rewrites for labels
- Recognize inline assembly references to enum values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71436

Files:
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CodeGen/ms-inline-asm-64.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  clang/test/Parser/ms-inline-asm.c
  llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/TableGen/TGParser.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;
+

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

2019-12-18 Thread Eric Astor via Phabricator via cfe-commits
epastor added inline comments.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1821
+getParser().parsePrimaryExpr(Val, End))
+  return Error(Start, "unexpected token!");
+  } else if (ParseIntelInlineAsmIdentifier(Val, ID, Info, false, End, true)) {

epastor wrote:
> rnk wrote:
> > Please test this corner case, I imagine it looks like:
> >   mov eax, offset 3
> Interesting. This corner case didn't trigger in that scenario; we get an 
> "expected identifier" error message with good source location, followed by 
> another error "use of undeclared label '3'" in debug builds... and in release 
> builds, we instead get a crash. On tracing the crash, it's a AsmStrRewrite 
> applying to a SMLoc not coming from the same string...
> 
> As near as I can tell, the issue is that we end up trying to parse "3" as a 
> not-yet-declared label, as such expand it to `__MSASMLABEL_.${:uid}__3`, and 
> then end up in a bad state because the operand rewrite is applying to the 
> expanded symbol... which isn't in the same AsmString. If you use an actual 
> undeclared label, you hit the same crash in release builds.
> 
> This is going to take some work; I'll get back to it in a day or two.
Fixed; we now get the same errors in this scenario as we do in the current LLVM 
trunk, reporting "expected identifier" and "use of undeclared label '3'".

On the other hand, I'm still working on finding a scenario that DOES trigger 
this corner case.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1825
+  } else if (Info.isKind(InlineAsmIdentifierInfo::IK_EnumVal)) {
+return Error(Start, "offset operator cannot yet handle constants");
+  }

epastor wrote:
> rnk wrote:
> > Please add a test for this corner case, I'm curious to see if the error 
> > reporting really works.
> This error reporting doesn't work, in fact. We instead get "cannot take the 
> address of an rvalue of type 'int'", with bad source location. Will 
> investigate why we end up there.
Turns out Sema wasn't successfully recognizing inline-assembly references to 
enum values, so we were processing them through as labels, and only recognizing 
the problem late in processing. Fixed now, with accurate error reporting; test 
added.


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] D71436: [X86][AsmParser] re-introduce 'offset' operator

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

{icon question-circle color=gray} Unit tests: unknown.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

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

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 



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] D71436: [X86][AsmParser] re-introduce 'offset' operator

2019-12-18 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-tidy: fail. Please fix clang-tidy findings 
.

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

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 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] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked 2 inline comments as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8986
   CGM.getTypes().ConvertTypeForMem(C.getPointerType(PtrTy)));
   llvm::Value *PtrEnd = MapperCGF.Builder.CreateGEP(PtrBegin, Size);
   llvm::Value *MapType = MapperCGF.EmitLoadOfScalar(

`Size` is used to compute the last element position, which is used as the loop 
boundary.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9207
   llvm::Value *IsArray = MapperCGF.Builder.CreateICmpSGE(
   Size, MapperCGF.Builder.getInt64(1), "omp.arrayinit.isarray");
   MapperCGF.Builder.CreateCondBr(IsArray, IsDeleteBB, ExitBB);

`Size` is used to see if this is an array.


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

https://reviews.llvm.org/D67833



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


[PATCH] D71669: [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

2019-12-18 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Let the "mnop-mcount" function attribute simply be present or non-present.

Update SystemZ backend as well to use hasFnAttribute() instead.


https://reviews.llvm.org/D71669

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/mnop-mcount.c
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
  llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
  llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
  llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll


Index: llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
===
--- llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
@@ -7,5 +7,4 @@
   ret void
 }
 
-attributes #0 = { "instrument-function-entry-inlined"="mcount" 
"mnop-mcount"="true" }
-
+attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount" }
Index: llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
===
--- llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
@@ -22,5 +22,5 @@
 }
 
 attributes #0 = { "fentry-call"="true" }
-attributes #1 = { "fentry-call"="true" "mnop-mcount"="true" }
+attributes #1 = { "fentry-call"="true" "mnop-mcount" }
 
Index: llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
===
--- llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -347,7 +347,7 @@
 
   bool runOnMachineFunction(MachineFunction &MF) override {
 const Function &F = MF.getFunction();
-if (F.getFnAttribute("mnop-mcount").getValueAsString() == "true" &&
+if (F.hasFnAttribute("mnop-mcount") &&
 F.getFnAttribute("fentry-call").getValueAsString() != "true")
   report_fatal_error("mnop-mcount only supported with fentry-call");
 
Index: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
===
--- llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -553,8 +553,7 @@
 void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
  SystemZMCInstLower &Lower) {
   MCContext &Ctx = MF->getContext();
-  if (MF->getFunction().getFnAttribute("mnop-mcount")
-   .getValueAsString() == "true") {
+  if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
 EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
 return;
   }
Index: clang/test/CodeGen/mnop-mcount.c
===
--- clang/test/CodeGen/mnop-mcount.c
+++ clang/test/CodeGen/mnop-mcount.c
@@ -17,9 +17,9 @@
   return foo();
 }
 
-//CHECK: attributes #0 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //CHECK: attributes #1 = { {{.*}} }
-//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"="true"{{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOMFENTRY: error: option '-mnop-mcount' cannot be specified without 
'-mfentry'
 //NOPG-NOT: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -966,7 +966,7 @@
 if (!CGM.getCodeGenOpts().CallFEntry)
   CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
 << "-mnop-mcount" << "-mfentry";
-Fn->addFnAttr("mnop-mcount", "true");
+Fn->addFnAttr("mnop-mcount");
   }
 }
   }


Index: llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
===
--- llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-02.ll
@@ -7,5 +7,4 @@
   ret void
 }
 
-attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount"="true" }
-
+attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount" }
Index: llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
===
--- llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
+++ llvm/test/CodeGen/SystemZ/mnop-mcount-01.ll
@@ -22,5 +22,5 @@
 }
 
 attributes #0 = { "fentry-call"="true" }
-attributes #1 = { "fentry-call"="true" "mnop-mcount"="true" }
+attributes #1 = { "fentry-call"="true" "mnop-mcount" }
 
Index: llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
===
--- llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -347,7 +347,7 @@
 
   bool runOnMachineFunction(MachineFunction &MF) override {

[clang] a85f5ef - Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

2019-12-18 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2019-12-18T10:41:12-08:00
New Revision: a85f5efd9597d0036f5c347b362cb873bdf51f16

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

LOG: Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

Summary:
This adds parsing of the qualifiers __ptr32, __ptr64, __sptr, and __uptr and
lowers them to the corresponding address space pointer for 32-bit and 64-bit 
pointers.
(32/64-bit pointers added in https://reviews.llvm.org/D69639)

A large part of this patch is making these pointers ignore the address space
when doing things like overloading and casting.

https://bugs.llvm.org/show_bug.cgi?id=42359

Reviewers: rnk, rsmith

Subscribers: jholewinski, jvesely, nhaehnle, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/ms-mixed-ptr-sizes.c
clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AddressSpaces.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/X86.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/MicrosoftExtensions.c
clang/test/SemaTemplate/address_space-dependent.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4e1d4a44bd8c..92f81eb55ed7 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1155,6 +1155,10 @@ class ASTContext : public RefCountedBase {
   /// attribute.
   QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const;
 
+  /// Remove the existing address space on the type if it is a pointer size
+  /// address space and return the type with qualifiers intact.
+  QualType removePtrSizeAddrSpace(QualType T) const;
+
   /// Return the uniqued reference to the type for a \c restrict
   /// qualified type.
   ///
@@ -1209,6 +1213,15 @@ class ASTContext : public RefCountedBase {
const FunctionProtoType::ExceptionSpecInfo &ESI,
bool AsWritten = false);
 
+  /// Get a function type and produce the equivalent function type where
+  /// pointer size address spaces in the return type and parameter tyeps are
+  /// replaced with the default address space.
+  QualType getFunctionTypeWithoutPtrSizes(QualType T);
+
+  /// Determine whether two function types are the same, ignoring pointer sizes
+  /// in the return type and parameter types.
+  bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U);
+
   /// Return the uniqued reference to the type for a complex
   /// number with the specified element type.
   QualType getComplexType(QualType T) const;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 2968efa9b276..942564756c93 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -477,7 +477,10 @@ class Qualifiers {
 return A == B ||
// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
// for __constant can be used as __generic.
-   (A == LangAS::opencl_generic && B != LangAS::opencl_constant);
+   (A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
+   // Consider pointer size address spaces to be equivalent to default.
+   ((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
+(isPtrSizeAddressSpace(B) || B == LangAS::Default));
   }
 
   /// Returns true if the address space in these qualifiers is equal to or

diff  --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index 2cc67474c121..faf7f303aa2d 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -42,6 +42,11 @@ enum class LangAS : unsigned {
   cuda_constant,
   cuda_shared,
 
+  // Pointer size and extension address spaces.
+  ptr32_sptr,
+  ptr32_uptr,
+  ptr64,
+
   // This denotes the count of language-specific address spaces and also
   // the offset added to the target-specific address spaces, which are usually
   // specified by address space attributes __attribute__(address_space(n))).
@@ -68,6 +73,11 @@ inline LangAS getLangASFromTargetAS(unsigned TargetAS) {
  (unsigned)LangAS::FirstTargetAddressSpace);
 }
 
+inline bo

[PATCH] D71612: [analyzer] Add PlacementNewChecker

2019-12-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I wonder if this checker will find any misuses of placement into 
`llvm::TrailingObjects`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71612



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


[PATCH] D71039: Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.

2019-12-18 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa85f5efd9597: Add support for the MS qualifiers __ptr32, 
__ptr64, __sptr, __uptr. (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71039

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/ms-mixed-ptr-sizes.c
  clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388598)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388595)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x76>();
+  correct<0x73>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -150,6 +150,20 @@
 void ptr_func2(int * __sptr __ptr32 i) {}  // expected-note {{previous definition is here}}
 void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
 
+// Check for warning when return types have the type attribute.
+void *__ptr32 ptr_func3() { return 0; } // expected-note {{previous definition is here}}
+void *__ptr64 ptr_func3() { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
+
+// Test that __ptr32/__ptr64 can be passed as arguments with other address
+// spaces.
+void ptr_func4(int *i);
+void ptr_func5(int *__ptr32 i);
+void test_ptr_arguments() {
+  int *__ptr64 i64;
+  ptr_func4(i64);
+  ptr_func5(i64);
+}
+
 int * __sptr __ptr32 __sptr wrong4; // expected-warning {{attribute '__sptr' is already applied}}
 
 __ptr32 int *wrong5; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
Index: clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mangle-ptr-size-address-space.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -triple x86_64-windows-msvc -o - %s | FileCheck %s --check-prefixes=WIN
+
+// CHECK-LABEL: define {{.*}}void @_Z2f0PU10ptr32_sptri
+// WIN-LABEL: define {{.*}}void @"?f0@@YAXPAH@Z"
+void f0(int * __ptr32 p) {}
+
+// CHECK-LABEL: define {{.*}}i8 addrspace(271)* @_Z2f1PU10ptr32_sptri
+// WIN-LABEL: define {{.*}}i8 addrspace(271)* @"?f1@@YAPAXPAH@Z"
+void * __ptr32 __uptr f1(int * __ptr32 p) { return 0; }
+
+// CHECK-LABEL: define {{.*}}void @_Z2f2Pi
+// WIN-LABEL: define {{.*}}void @"?f2@@YAXPEAH@Z"
+void f2(int * __ptr64 p) {}
+
+  // CHECK-LABEL: define {{.*}}i8* @_Z2f3Pi
+// WIN-LABEL: define {{.*}}i8* @"?f3@@YAPEAXPEAH@Z"
+void * __ptr64 f3(int * __ptr64 p) { return 0; }
Index: clang/test/CodeGen/ms-mixed-ptr-sizes.c
===
--- /dev/null
+++ clang/test/CodeGen/ms-mixed-ptr-sizes.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 \
+// RUN:   < %s | FileCheck %s --check-prefixes=X64,CHECK
+// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 \
+// RUN:   < %s | FileCheck %s --check-prefixes=X86,CHECK
+
+struct Foo {
+  int * __ptr32 p32;
+  int * __ptr64 p64;
+};
+void use_foo(struct Foo *f);
+void test_sign_ext(struct Foo *f, int * __ptr32 __sptr i) {
+// X64-

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > So, we're still going to use number of elements for mappers? And pass 
> > > > > it in the same parameter that in other cases is used as size in 
> > > > > bytes? If so, point to it explicitly in the review for the runtime 
> > > > > part so all are informed about it.
> > > > From interface, the mapper function uses size in bytes now. Inside, it 
> > > > needs number of elements to iterate through all elements. This has no 
> > > > impact on the runtime part, since it looks like normal mapping from the 
> > > > interface. All conversion happens inside the mapper function which is 
> > > > completely generated by the compiler.
> > > Ok. Then why do we need to convert size in bytes to number of elements 
> > > here?
> > This is used to 1) see if we are going to map an array of elements with 
> > mapper, and 2) iterate all to map them individually.
> Could you point where we have this kind of analysis here? Because I don't see 
> anything affected by this change in the patch.
Is this a bug fix in the previous implementation?


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

https://reviews.llvm.org/D67833



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 234579.
lildmh added a comment.

Change the function name


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

https://reviews.llvm.org/D67833

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cp

[PATCH] D69990: Populate CUDA flags on FreeBSD too, as many other toolchains do.

2019-12-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> ... I'm curious if it's particularly useful. Last time I checked NVIDIA 
> didn't ship libcudart for FreeBSD and without it it's rather cumbersome to 
> use CUDA in practice.

FYI, I've just got our internal proof-of-concept runtime support library which 
may get CUDA apps run on FreeBSD:
https://github.com/google/gpu-runtime

It's somewhat old and misses few glue functions needed by CUDA-10, but it 
should work well enough for CUDA-9.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69990



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2019-12-18 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8981-8982
+  // Convert the size in bytes into the number of array elements.
+  Size = MapperCGF.Builder.CreateExactUDiv(
+  Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(

ABataev wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > So, we're still going to use number of elements for mappers? And 
> > > > > > pass it in the same parameter that in other cases is used as size 
> > > > > > in bytes? If so, point to it explicitly in the review for the 
> > > > > > runtime part so all are informed about it.
> > > > > From interface, the mapper function uses size in bytes now. Inside, 
> > > > > it needs number of elements to iterate through all elements. This has 
> > > > > no impact on the runtime part, since it looks like normal mapping 
> > > > > from the interface. All conversion happens inside the mapper function 
> > > > > which is completely generated by the compiler.
> > > > Ok. Then why do we need to convert size in bytes to number of elements 
> > > > here?
> > > This is used to 1) see if we are going to map an array of elements with 
> > > mapper, and 2) iterate all to map them individually.
> > Could you point where we have this kind of analysis here? Because I don't 
> > see anything affected by this change in the patch.
> Is this a bug fix in the previous implementation?
The previous implementation assumes the size is the number of elements, and it 
works correctly under that assumption. Since we change the meaning of size 
here, I add this line of code so the previous implementation can work correctly 
in the new assumption that the size is the size in bytes.


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

https://reviews.llvm.org/D67833



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


[PATCH] D71669: [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.

2019-12-18 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D71669



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


[PATCH] D71650: [AST] Fix compilation with GCC < 8 for MinGW

2019-12-18 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D71650#1789897 , @rjmccall wrote:

> Wow, that's novel.  Please add a comment explaining that this is a compiler 
> workaround, but otherwise LGTM.


The post-patch form doesn't look that odd to me (and we wouldn't want one 
comment for every one of the existing enums that already are outside of the 
structs where they are used for bitfield sizes), but do you think a comment is 
warranted here on this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71650



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


  1   2   >