[PATCH] D89670: [clangd] Store the containing symbol for refs

2020-11-04 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 302759.
nridge marked 4 inline comments as done.
nridge added a comment.

Address final review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89670

Files:
  clang-tools-extra/clangd/index/Ref.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -70,21 +70,16 @@
 MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
   return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
 }
+bool rangesMatch(const SymbolLocation &Loc, const Range &R) {
+  return std::make_tuple(Loc.Start.line(), Loc.Start.column(), Loc.End.line(),
+ Loc.End.column()) ==
+ std::make_tuple(R.start.line, R.start.character, R.end.line,
+ R.end.character);
+}
 MATCHER_P(DeclRange, Pos, "") {
-  return std::make_tuple(arg.CanonicalDeclaration.Start.line(),
- arg.CanonicalDeclaration.Start.column(),
- arg.CanonicalDeclaration.End.line(),
- arg.CanonicalDeclaration.End.column()) ==
- std::make_tuple(Pos.start.line, Pos.start.character, Pos.end.line,
- Pos.end.character);
-}
-MATCHER_P(DefRange, Pos, "") {
-  return std::make_tuple(
- arg.Definition.Start.line(), arg.Definition.Start.column(),
- arg.Definition.End.line(), arg.Definition.End.column()) ==
- std::make_tuple(Pos.start.line, Pos.start.character, Pos.end.line,
- Pos.end.character);
+  return rangesMatch(arg.CanonicalDeclaration, Pos);
 }
+MATCHER_P(DefRange, Pos, "") { return rangesMatch(arg.Definition, Pos); }
 MATCHER_P(RefCount, R, "") { return int(arg.References) == R; }
 MATCHER_P(ForCodeCompletion, IsIndexedForCodeCompletion, "") {
   return static_cast(arg.Flags & Symbol::IndexedForCodeCompletion) ==
@@ -100,10 +95,7 @@
 MATCHER(RefRange, "") {
   const Ref &Pos = ::testing::get<0>(arg);
   const Range &Range = ::testing::get<1>(arg);
-  return std::make_tuple(Pos.Location.Start.line(), Pos.Location.Start.column(),
- Pos.Location.End.line(), Pos.Location.End.column()) ==
- std::make_tuple(Range.start.line, Range.start.character,
- Range.end.line, Range.end.character);
+  return rangesMatch(Pos.Location, Range);
 }
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
@@ -738,6 +730,76 @@
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "FUNC").ID, _;
 }
 
+TEST_F(SymbolCollectorTest, RefContainers) {
+  Annotations Code(R"cpp(
+int $toplevel1[[f1]](int);
+void f2() {
+  (void) $ref1a[[f1]](1);
+  auto fptr = &$ref1b[[f1]];
+}
+int $toplevel2[[v1]] = $ref2[[f1]](2);
+void f3(int arg = $ref3[[f1]](3));
+struct S1 {
+  int $classscope1[[member1]] = $ref4[[f1]](4);
+  int $classscope2[[member2]] = 42;
+};
+constexpr int f4(int x) { return x + 1; }
+template  struct S2 {};
+S2<$ref6[[f4]](0)> v2;
+S2<$ref7a[[f4]](0)> f5(S2<$ref7b[[f4]](0)>);
+namespace N {
+  void $namespacescope1[[f6]]();
+  int $namespacescope2[[v3]];
+}
+  )cpp");
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMainFileRefs = true;
+  runSymbolCollector("", Code.code());
+  auto FindRefWithRange = [&](Range R) -> Optional {
+for (auto &Entry : Refs) {
+  for (auto &Ref : Entry.second) {
+if (rangesMatch(Ref.Location, R))
+  return Ref;
+  }
+}
+return llvm::None;
+  };
+  auto Container = [&](llvm::StringRef RangeName) {
+auto Ref = FindRefWithRange(Code.range(RangeName));
+EXPECT_TRUE(bool(Ref));
+return Ref->Container;
+  };
+  EXPECT_EQ(Container("ref1a"),
+findSymbol(Symbols, "f2").ID); // function body (call)
+  EXPECT_EQ(Container("ref1b"),
+findSymbol(Symbols, "f2").ID); // function body (address-of)
+  EXPECT_EQ(Container("ref2"),
+findSymbol(Symbols, "v1").ID); // variable initializer
+  EXPECT_EQ(Container("ref3"),
+findSymbol(Symbols, "f3").ID); // function parameter default value
+  EXPECT_EQ(Container("ref4"),
+findSymbol(Symbols, "S1::member1").ID); // member initializer
+  EXPECT_EQ(Container("ref5"),
+findSymbol(Symbols, "S2").ID); // template parameter default value
+  EXPECT_EQ(Container("ref6"),
+findSymbol(Symbols, "v2").ID); // type of variable
+  EXPECT_EQ(Container("ref7a"),
+fi

[clang-tools-extra] 3bec07f - [clangd] Store the containing symbol for refs

2020-11-04 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-11-04T03:21:45-05:00
New Revision: 3bec07f91fb1aea7a53ebc760f0511be1b5409f4

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

LOG: [clangd] Store the containing symbol for refs

This is needed to implement call hierarchy.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Ref.h
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Ref.h 
b/clang-tools-extra/clangd/index/Ref.h
index 577db7525442..060d7c971c38 100644
--- a/clang-tools-extra/clangd/index/Ref.h
+++ b/clang-tools-extra/clangd/index/Ref.h
@@ -88,13 +88,19 @@ struct Ref {
   /// The source location where the symbol is named.
   SymbolLocation Location;
   RefKind Kind = RefKind::Unknown;
+  /// The ID of the symbol whose definition contains this reference.
+  /// For example, for a reference inside a function body, this would
+  /// be that function. For top-level definitions this isNull().
+  SymbolID Container;
 };
 
 inline bool operator<(const Ref &L, const Ref &R) {
-  return std::tie(L.Location, L.Kind) < std::tie(R.Location, R.Kind);
+  return std::tie(L.Location, L.Kind, L.Container) <
+ std::tie(R.Location, R.Kind, R.Container);
 }
 inline bool operator==(const Ref &L, const Ref &R) {
-  return std::tie(L.Location, L.Kind) == std::tie(R.Location, R.Kind);
+  return std::tie(L.Location, L.Kind, L.Container) ==
+ std::tie(R.Location, R.Kind, R.Container);
 }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Ref &);

diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index e7f65f087b1c..6f65bf024c4e 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -345,6 +345,7 @@ void writeRefs(const SymbolID &ID, llvm::ArrayRef Refs,
   for (const auto &Ref : Refs) {
 OS.write(static_cast(Ref.Kind));
 writeLocation(Ref.Location, Strings, OS);
+OS << Ref.Container.raw();
   }
 }
 
@@ -356,6 +357,7 @@ readRefs(Reader &Data, llvm::ArrayRef 
Strings) {
   for (auto &Ref : Result.second) {
 Ref.Kind = static_cast(Data.consume8());
 Ref.Location = readLocation(Data, Strings);
+Ref.Container = Data.consumeID();
   }
   return Result;
 }

diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 511b5a2c6047..a7a6bd992f8b 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -344,7 +344,8 @@ bool SymbolCollector::handleDeclOccurrence(
   !isa(ND) &&
   (Opts.RefsInHeaders ||
SM.getFileID(SM.getFileLoc(Loc)) == SM.getMainFileID()))
-DeclRefs[ND].emplace_back(SM.getFileLoc(Loc), Roles);
+DeclRefs[ND].push_back(
+SymbolRef{SM.getFileLoc(Loc), Roles, ASTNode.Parent});
   // Don't continue indexing if this is a mere reference.
   if (IsOnlyRef)
 return true;
@@ -422,7 +423,8 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
   // Do not store references to main-file macros.
   if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileOnly &&
   (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
-MacroRefs[ID].push_back({Loc, Roles});
+// FIXME: Populate container information for macro references.
+MacroRefs[ID].push_back({Loc, Roles, /*Container=*/nullptr});
 
   // Collect symbols.
   if (!Opts.CollectMacro)
@@ -579,24 +581,22 @@ void SymbolCollector::finish() {
 }
 return Found->second;
   };
-  auto CollectRef =
-  [&](SymbolID ID,
-  const std::pair &LocAndRole,
-  bool Spelled = false) {
-auto FileID = SM.getFileID(LocAndRole.first);
-// FIXME: use the result to filter out references.
-shouldIndexFile(FileID);
-if (auto FileURI = GetURI(FileID)) {
-  auto Range =
-  getTokenRange(LocAndRole.first, SM, ASTCtx->getLangOpts());
-  Ref R;
-  R.Location.Start = Range.first;
-  R.Location.End = Range.second;
-  R.Location.FileURI = FileURI->c_str();
-  R.Kind = toRefKind(LocAndRole.second, Spelled);
-  Refs.insert(ID, R);
-}
-  };
+  auto CollectRef = [&](SymbolID ID, const SymbolRef &LocAndRole,
+bool Spelled = false) {
+auto FileID = SM.getFileID(LocAndRole.Loc);
+// FIXME: use the result to filter out references.
+shouldIndexFile(FileID);

[PATCH] D89670: [clangd] Store the containing symbol for refs

2020-11-04 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3bec07f91fb1: [clangd] Store the containing symbol for refs 
(authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89670

Files:
  clang-tools-extra/clangd/index/Ref.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -70,21 +70,16 @@
 MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
   return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
 }
+bool rangesMatch(const SymbolLocation &Loc, const Range &R) {
+  return std::make_tuple(Loc.Start.line(), Loc.Start.column(), Loc.End.line(),
+ Loc.End.column()) ==
+ std::make_tuple(R.start.line, R.start.character, R.end.line,
+ R.end.character);
+}
 MATCHER_P(DeclRange, Pos, "") {
-  return std::make_tuple(arg.CanonicalDeclaration.Start.line(),
- arg.CanonicalDeclaration.Start.column(),
- arg.CanonicalDeclaration.End.line(),
- arg.CanonicalDeclaration.End.column()) ==
- std::make_tuple(Pos.start.line, Pos.start.character, Pos.end.line,
- Pos.end.character);
-}
-MATCHER_P(DefRange, Pos, "") {
-  return std::make_tuple(
- arg.Definition.Start.line(), arg.Definition.Start.column(),
- arg.Definition.End.line(), arg.Definition.End.column()) ==
- std::make_tuple(Pos.start.line, Pos.start.character, Pos.end.line,
- Pos.end.character);
+  return rangesMatch(arg.CanonicalDeclaration, Pos);
 }
+MATCHER_P(DefRange, Pos, "") { return rangesMatch(arg.Definition, Pos); }
 MATCHER_P(RefCount, R, "") { return int(arg.References) == R; }
 MATCHER_P(ForCodeCompletion, IsIndexedForCodeCompletion, "") {
   return static_cast(arg.Flags & Symbol::IndexedForCodeCompletion) ==
@@ -100,10 +95,7 @@
 MATCHER(RefRange, "") {
   const Ref &Pos = ::testing::get<0>(arg);
   const Range &Range = ::testing::get<1>(arg);
-  return std::make_tuple(Pos.Location.Start.line(), Pos.Location.Start.column(),
- Pos.Location.End.line(), Pos.Location.End.column()) ==
- std::make_tuple(Range.start.line, Range.start.character,
- Range.end.line, Range.end.character);
+  return rangesMatch(Pos.Location, Range);
 }
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
@@ -738,6 +730,76 @@
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "FUNC").ID, _;
 }
 
+TEST_F(SymbolCollectorTest, RefContainers) {
+  Annotations Code(R"cpp(
+int $toplevel1[[f1]](int);
+void f2() {
+  (void) $ref1a[[f1]](1);
+  auto fptr = &$ref1b[[f1]];
+}
+int $toplevel2[[v1]] = $ref2[[f1]](2);
+void f3(int arg = $ref3[[f1]](3));
+struct S1 {
+  int $classscope1[[member1]] = $ref4[[f1]](4);
+  int $classscope2[[member2]] = 42;
+};
+constexpr int f4(int x) { return x + 1; }
+template  struct S2 {};
+S2<$ref6[[f4]](0)> v2;
+S2<$ref7a[[f4]](0)> f5(S2<$ref7b[[f4]](0)>);
+namespace N {
+  void $namespacescope1[[f6]]();
+  int $namespacescope2[[v3]];
+}
+  )cpp");
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMainFileRefs = true;
+  runSymbolCollector("", Code.code());
+  auto FindRefWithRange = [&](Range R) -> Optional {
+for (auto &Entry : Refs) {
+  for (auto &Ref : Entry.second) {
+if (rangesMatch(Ref.Location, R))
+  return Ref;
+  }
+}
+return llvm::None;
+  };
+  auto Container = [&](llvm::StringRef RangeName) {
+auto Ref = FindRefWithRange(Code.range(RangeName));
+EXPECT_TRUE(bool(Ref));
+return Ref->Container;
+  };
+  EXPECT_EQ(Container("ref1a"),
+findSymbol(Symbols, "f2").ID); // function body (call)
+  EXPECT_EQ(Container("ref1b"),
+findSymbol(Symbols, "f2").ID); // function body (address-of)
+  EXPECT_EQ(Container("ref2"),
+findSymbol(Symbols, "v1").ID); // variable initializer
+  EXPECT_EQ(Container("ref3"),
+findSymbol(Symbols, "f3").ID); // function parameter default value
+  EXPECT_EQ(Container("ref4"),
+findSymbol(Symbols, "S1::member1").ID); // member initializer
+  EXPECT_EQ(Container("ref5"),
+findSymbol(Symbols, "S2").ID); // template parameter default value
+  EXPECT_EQ(Container("ref6"),
+findSymbo

[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-04 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 302769.
LiuChen3 added a comment.



1. Address comments;
2. Only support parsing vex/vex2/vex3/evex prefix for MASM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

Files:
  clang/test/CodeGen/X86/ms-inline-asm-prefix.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp


Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2847,7 +2847,33 @@
   }
   continue;
 }
-
+// Parse MASM style pseudo prefixes.
+// FIXME: This prefix should only be used for MASM, not for intel-syntax.
+if (isParsingIntelSyntax()) {
+  bool IsPrefix = false;
+  if (Name == "vex") {
+ForcedVEXEncoding = VEXEncoding_VEX;
+IsPrefix = true;
+  } else if (Name == "vex2") {
+ForcedVEXEncoding = VEXEncoding_VEX2;
+IsPrefix = true;
+  } else if (Name == "vex3") {
+ForcedVEXEncoding = VEXEncoding_VEX3;
+IsPrefix = true;
+  } else if (Name == "evex") {
+ForcedVEXEncoding = VEXEncoding_EVEX;
+IsPrefix = true;
+  }
+  if (IsPrefix) {
+NameLoc = Parser.getTok().getLoc();
+if (getLexer().isNot(AsmToken::Identifier))
+  return Error(Parser.getTok().getLoc(), "Expected identifier");
+// FIXME: The mnemonic won't match correctly if its not in lower case.
+Name = Parser.getTok().getString();
+Parser.Lex();
+continue;
+  }
+}
 break;
   }
 
@@ -4153,10 +4179,16 @@
 
   MCInst Inst;
 
-  // If VEX3 encoding is forced, we need to pass the USE_VEX3 flag to the
-  // encoder.
-  if (ForcedVEXEncoding == VEXEncoding_VEX3)
+  // If VEX/EVEX encoding is forced, we need to pass the USE_* flag to the
+  // encoder and printer.
+  if (ForcedVEXEncoding == VEXEncoding_VEX)
+Prefixes |= X86::IP_USE_VEX;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX2)
+Prefixes |= X86::IP_USE_VEX2;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX3)
 Prefixes |= X86::IP_USE_VEX3;
+  else if (ForcedVEXEncoding == VEXEncoding_EVEX)
+Prefixes |= X86::IP_USE_EVEX;
 
   // Set encoded flags for {disp8} and {disp32}.
   if (ForcedDispEncoding == DispEncoding_Disp8)
Index: clang/test/CodeGen/X86/ms-inline-asm-prefix.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/ms-inline-asm-prefix.c
@@ -0,0 +1,20 @@
+// REQUIRES: x86-registered-target
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=intel -S -o -  | FileCheck %s 
-check-prefix=INTEL
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=att -S -o -  | FileCheck %s 
-check-prefix=ATT
+
+void check_inline_prefix(void) {
+  __asm {
+// INTEL: {vex} vcvtps2pd   xmm0, xmm1
+// INTEL: {vex2}vcvtps2pd   xmm0, xmm1
+// INTEL: {vex3}vcvtps2pd   xmm0, xmm1
+// INTEL: {evex}vcvtps2pd   xmm0, xmm1
+// ATT:   {vex}   vcvtps2pd   %xmm1, %xmm0
+// ATT:   {vex2}  vcvtps2pd   %xmm1, %xmm0
+// ATT:   {vex3}  vcvtps2pd   %xmm1, %xmm0
+// ATT:   {evex}  vcvtps2pd   %xmm1, %xmm0
+vex vcvtps2pd xmm0, xmm1
+vex2 vcvtps2pd xmm0, xmm1
+vex3 vcvtps2pd xmm0, xmm1
+evex vcvtps2pd xmm0, xmm1
+  }
+}


Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2847,7 +2847,33 @@
   }
   continue;
 }
-
+// Parse MASM style pseudo prefixes.
+// FIXME: This prefix should only be used for MASM, not for intel-syntax.
+if (isParsingIntelSyntax()) {
+  bool IsPrefix = false;
+  if (Name == "vex") {
+ForcedVEXEncoding = VEXEncoding_VEX;
+IsPrefix = true;
+  } else if (Name == "vex2") {
+ForcedVEXEncoding = VEXEncoding_VEX2;
+IsPrefix = true;
+  } else if (Name == "vex3") {
+ForcedVEXEncoding = VEXEncoding_VEX3;
+IsPrefix = true;
+  } else if (Name == "evex") {
+ForcedVEXEncoding = VEXEncoding_EVEX;
+IsPrefix = true;
+  }
+  if (IsPrefix) {
+NameLoc = Parser.getTok().getLoc();
+if (getLexer().isNot(AsmToken::Identifier))
+  return Error(Parser.getTok().getLoc(), "Expected identifier");
+// FIXME: The mnemonic won't match correctly if its not in lower case.
+Name = Parser.getTok().getString();
+Parser.Lex();
+continue;
+  }
+}
 

[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-04 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/test/CodeGen/X86/ms-inline-asm-prefix.c:1
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-widows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=intel -S -o -  | FileCheck %s -check-prefix 
CHECK
+

LiuChen3 wrote:
> epastor wrote:
> > epastor wrote:
> > > pengfei wrote:
> > > > pengfei wrote:
> > > > > pengfei wrote:
> > > > > > Maybe need `// REQUIRES: x86-registered-target`
> > > > > You may need add att check too since you modified the att code.
> > > > Should it be avalible only when `-fms-compatibility`
> > > The triple is misspelled; it should be `x86_64-pc-windows-msvc` (the "n" 
> > > in windows is missing)
> > A broader question: As written, this applies to anything in Intel syntax. 
> > Is this an Intel syntax feature, or a MASM feature?
> Thanks for your review. After checking with the people of MSVC, I found that 
> prefix without braces is not intel syntax. Actually, we don't know if there 
> any document says what the prefix should be. At least, gcc does have the "{}" 
> in intel syntax, so does clang. We currently decide to only support parsing 
> the prefix without MSVC.
I am not sure. But I think -fasm-blocks, -fms-extensions  also support MASM.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2851
+// Parse MASM style pseudo prefixes.
+// FIXME: This prefix should only be used for MASM, not for intel-syntax.
+if (isParsingIntelSyntax()) {

I tried to limit to MASM. But I found that the  'isParsingMSInlineAsm()' is not 
accurate.  And then I tried to transmit 'ParsingMSInlineAsm' information 
correctly in AsmPrinterInlineAsm.cpp (according to the '-fasm-blocks' option). 
But I was surprised to find that isParsingMSInlineAsm() is actually used as the 
argument of 'MatchingInlineAsm' in 'MatchAndEmitInstruction()'. This makes me 
confused. Should that 'MatchingInlineAsm' be 'MatchingMSInlineAsm' ?Is this 
MatchingInlineAsm only used by llvm-ml.
It difficult to limit this to MASM at the moment. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-04 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 302773.
david-arm marked an inline comment as done.
david-arm edited the summary of this revision.

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

https://reviews.llvm.org/D89031

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/CodeGenCXX/pragma-scalable-loop.cpp

Index: clang/test/CodeGenCXX/pragma-scalable-loop.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pragma-scalable-loop.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify do loop is performing scalable vectorization
+void for_test_scalable(int *List, int Length) {
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
+List[i] = i * 2;
+  }
+}
+
+// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_SCALABLE:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[DISTRIBUTE_DISABLE]] = !{!"llvm.loop.distribute.enable", i1 false}
+// CHECK: ![[WIDTH_16_SCALABLE]] = !{!"llvm.loop.vectorize.width", ![[ELEMENT_COUNT_16_SCALABLE:.*]]}
+// CHECK: ![[ELEMENT_COUNT_16_SCALABLE]] = !{i32 16, i1 true}
+// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
+// CHECK: ![[VECTORIZE_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true}
Index: clang/test/CodeGenCXX/pragma-loop.cpp
===
--- clang/test/CodeGenCXX/pragma-loop.cpp
+++ clang/test/CodeGenCXX/pragma-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s 2>%t | FileCheck %s
+// RUN: FileCheck --check-prefix=CHECK-SCALABLE %s < %t
 
 // Verify while loop is recognized after sequence of pragma clang loop directives.
 void while_test(int *List, int Length) {
@@ -158,6 +159,26 @@
   for_template_constant_expression_test(List, Length);
 }
 
+// Verify for loop is performing fixed width vectorization
+void for_test_fixed(int *List, int Length) {
+#pragma clang loop vectorize_width(16, fixed) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_15:.*]]
+List[i] = i * 2;
+  }
+}
+
+// Verify for loop rejects scalable vectorization due to lack of target support
+// CHECK-SCALABLE: ignoring scalable vectorize_width flag due to lack of target support
+void for_test_scalable(int *List, int Length) {
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_16:.*]]
+// CHECK-SVE: br label {{.*}}, !llvm.loop ![[LOOP_16_SVE:.*]]
+List[i] = i * 2;
+  }
+}
+
 // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
 // CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
 
@@ -215,3 +236,8 @@
 
 // CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[WIDTH_10:.*]], ![[VECTORIZE_ENABLE]]}
 // CHECK: ![[WIDTH_10]] = !{!"llvm.loop.vectorize.width", i32 10}
+
+// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_FIXED]] = !{!"llvm.loop.vectorize.width", i32 16}
+
+// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -14,6 +14,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ScopeInfo.h"
@@ -139,10 +140,21 @@
LoopHintAttr::PipelineInitiationInterval)
  .Case("distribute", LoopHintAttr::Distribute)
  .Default(LoopHintAttr::Vectorize);
-if (Option == LoopHintAttr::VectorizeWidth ||
- 

[clang-tools-extra] a57550d - [clangd] Pass parameters to config apply functions

2020-11-04 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-04T10:29:24+01:00
New Revision: a57550def15e77e33dd6a4de22c83885c8fdc6f1

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

LOG: [clangd] Pass parameters to config apply functions

This will enable some fragments to apply their features selectively.

Depends on D90270.

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigCompile.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index f73db45d3ab5..e2823894dd11 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -63,7 +63,8 @@ struct CompiledFragmentImpl {
   std::vector> Conditions;
   // Mutations that this fragment will apply to the configuration.
   // These are invoked only if the conditions are satisfied.
-  std::vector> Apply;
+  std::vector>
+  Apply;
 
   bool operator()(const Params &P, Config &C) const {
 for (const auto &C : Conditions) {
@@ -74,7 +75,7 @@ struct CompiledFragmentImpl {
 }
 dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
 for (const auto &A : Apply)
-  A(C);
+  A(P, C);
 return true;
   }
 };
@@ -211,7 +212,7 @@ struct FragmentCompiler {
   for (auto &A : F.Remove)
 Remove->strip(*A);
   Out.Apply.push_back([Remove(std::shared_ptr(
-  std::move(Remove)))](Config &C) {
+  std::move(Remove)))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back(
 [Remove](std::vector &Args) {
   Remove->process(Args);
@@ -223,7 +224,7 @@ struct FragmentCompiler {
   std::vector Add;
   for (auto &A : F.Add)
 Add.push_back(std::move(*A));
-  Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back([Add](std::vector &Args) {
   Args.insert(Args.end(), Add.begin(), Add.end());
 });
@@ -238,7 +239,8 @@ struct FragmentCompiler {
  .map("Build", Config::BackgroundPolicy::Build)
  .map("Skip", Config::BackgroundPolicy::Skip)
  .value())
-Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+Out.Apply.push_back(
+[Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
   }
 
@@ -253,7 +255,8 @@ struct FragmentCompiler {
 FullyQualifiedNamespaces.push_back(Namespace.str());
   }
   Out.Apply.push_back([FullyQualifiedNamespaces(
-  std::move(FullyQualifiedNamespaces))](Config &C) 
{
+  std::move(FullyQualifiedNamespaces))](
+  const Params &, Config &C) {
 C.Style.FullyQualifiedNamespaces.insert(
 C.Style.FullyQualifiedNamespaces.begin(),
 FullyQualifiedNamespaces.begin(), FullyQualifiedNamespaces.end());



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


[PATCH] D90455: [clangd] Pass parameters to config apply functions

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa57550def15e: [clangd] Pass parameters to config apply 
functions (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90455

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


Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -63,7 +63,8 @@
   std::vector> Conditions;
   // Mutations that this fragment will apply to the configuration.
   // These are invoked only if the conditions are satisfied.
-  std::vector> Apply;
+  std::vector>
+  Apply;
 
   bool operator()(const Params &P, Config &C) const {
 for (const auto &C : Conditions) {
@@ -74,7 +75,7 @@
 }
 dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
 for (const auto &A : Apply)
-  A(C);
+  A(P, C);
 return true;
   }
 };
@@ -211,7 +212,7 @@
   for (auto &A : F.Remove)
 Remove->strip(*A);
   Out.Apply.push_back([Remove(std::shared_ptr(
-  std::move(Remove)))](Config &C) {
+  std::move(Remove)))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back(
 [Remove](std::vector &Args) {
   Remove->process(Args);
@@ -223,7 +224,7 @@
   std::vector Add;
   for (auto &A : F.Add)
 Add.push_back(std::move(*A));
-  Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back([Add](std::vector &Args) {
   Args.insert(Args.end(), Add.begin(), Add.end());
 });
@@ -238,7 +239,8 @@
  .map("Build", Config::BackgroundPolicy::Build)
  .map("Skip", Config::BackgroundPolicy::Skip)
  .value())
-Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+Out.Apply.push_back(
+[Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
   }
 
@@ -253,7 +255,8 @@
 FullyQualifiedNamespaces.push_back(Namespace.str());
   }
   Out.Apply.push_back([FullyQualifiedNamespaces(
-  std::move(FullyQualifiedNamespaces))](Config &C) 
{
+  std::move(FullyQualifiedNamespaces))](
+  const Params &, Config &C) {
 C.Style.FullyQualifiedNamespaces.insert(
 C.Style.FullyQualifiedNamespaces.begin(),
 FullyQualifiedNamespaces.begin(), FullyQualifiedNamespaces.end());


Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -63,7 +63,8 @@
   std::vector> Conditions;
   // Mutations that this fragment will apply to the configuration.
   // These are invoked only if the conditions are satisfied.
-  std::vector> Apply;
+  std::vector>
+  Apply;
 
   bool operator()(const Params &P, Config &C) const {
 for (const auto &C : Conditions) {
@@ -74,7 +75,7 @@
 }
 dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
 for (const auto &A : Apply)
-  A(C);
+  A(P, C);
 return true;
   }
 };
@@ -211,7 +212,7 @@
   for (auto &A : F.Remove)
 Remove->strip(*A);
   Out.Apply.push_back([Remove(std::shared_ptr(
-  std::move(Remove)))](Config &C) {
+  std::move(Remove)))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back(
 [Remove](std::vector &Args) {
   Remove->process(Args);
@@ -223,7 +224,7 @@
   std::vector Add;
   for (auto &A : F.Add)
 Add.push_back(std::move(*A));
-  Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back([Add](std::vector &Args) {
   Args.insert(Args.end(), Add.begin(), Add.end());
 });
@@ -238,7 +239,8 @@
  .map("Build", Config::BackgroundPolicy::Build)
  .map("Skip", Config::BackgroundPolicy::Skip)
  .value())
-Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+Out.Apply.push_back(
+[Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
   }
 
@@ -253,7 +255,8 @@
 FullyQualifiedNamespaces.push_back(Namespace.str());
   }
   Out.Apply.push_back([FullyQualifiedNamespaces(
-  std::m

[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-11-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 302778.
balazske added a comment.

Updated according to comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-handler.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-sig30-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s cert-sig30-c %t -- -- -isystem %S/Inputs/Headers
+
+#include "signal.h"
+#include "stdio.h"
+#include "stdlib.h"
+
+// The function should be classified as system call even if there is
+// declaration the in source file.
+// FIXME: The detection works only if the first declaration is in system
+// header.
+int printf(const char *, ...);
+typedef void (*sighandler_t)(int);
+sighandler_t signal(int signum, sighandler_t handler);
+
+void handler_abort(int) {
+  abort();
+}
+
+void handler__Exit(int) {
+  _Exit(0);
+}
+
+void handler_quick_exit(int) {
+  quick_exit(0);
+}
+
+void handler_other(int) {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void handler_signal(int) {
+  // FIXME: It is only OK to call signal with the current signal number.
+  signal(0, SIG_DFL);
+}
+
+void f_ok() {
+  abort();
+}
+
+void f_bad() {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void f_extern();
+
+void handler_ok(int) {
+  f_ok();
+}
+
+void handler_bad(int) {
+  f_bad();
+}
+
+void handler_extern(int) {
+  f_extern();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void test() {
+  signal(SIGINT, handler_abort);
+  signal(SIGINT, handler__Exit);
+  signal(SIGINT, handler_quick_exit);
+  signal(SIGINT, handler_signal);
+  signal(SIGINT, handler_other);
+
+  signal(SIGINT, handler_ok);
+  signal(SIGINT, handler_bad);
+  signal(SIGINT, handler_extern);
+
+  signal(SIGINT, quick_exit);
+  signal(SIGINT, other_call);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+
+  signal(SIGINT, SIG_IGN);
+  signal(SIGINT, SIG_DFL);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
@@ -0,0 +1,18 @@
+//===--- stdlib.h - Stub header for tests ---*- 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
+//
+//===--===//
+
+#ifndef _STDLIB_H_
+#define _STDLIB_H_
+
+void abort(void);
+void _Exit(int);
+void quick_exit(int);
+
+void other_call(int);
+
+#endif // _STDLIB_H_
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
@@ -0,0 +1,22 @@
+//===--- signal.h - Stub header for tests ---*- 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
+//
+//===--===//
+
+#ifndef _SIGNAL_H_
+#define _SIGNAL_H_
+
+void _sig_ign(int);
+void _sig_dfl(int);
+
+#define SIGINT 1
+#define SIG_IGN _sig_ign
+#define SIG_DFL _sig_dfl
+
+typedef void (*sighandler_t)(int);
+sighandler_t signal(int, sighandler_t);
+
+#endif // _SIGNAL_H_
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===

[PATCH] D90593: [Clang] Add more fp128 math library function builtins

2020-11-04 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7faf62a80bfc: [Clang] Add more fp128 math library function 
builtins (authored by qiucf).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D90593?vs=302227&id=302781#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90593

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/math-builtins.c

Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -7,23 +7,27 @@
 // Test attributes and codegen of math builtins.
 
 void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
-  f = __builtin_fmod(f,f);f = __builtin_fmodf(f,f);   f =  __builtin_fmodl(f,f);
+  f = __builtin_fmod(f,f);f = __builtin_fmodf(f,f);   f =  __builtin_fmodl(f,f);  f = __builtin_fmodf128(f,f);
 
 // NO__ERRNO: frem double
 // NO__ERRNO: frem float
 // NO__ERRNO: frem x86_fp80
+// NO__ERRNO: frem fp128
 // HAS_ERRNO: declare double @fmod(double, double) [[NOT_READNONE:#[0-9]+]]
 // HAS_ERRNO: declare float @fmodf(float, float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @fmodf128(fp128, fp128) [[NOT_READNONE]]
 
-  __builtin_atan2(f,f);__builtin_atan2f(f,f) ;  __builtin_atan2l(f, f);
+  __builtin_atan2(f,f);__builtin_atan2f(f,f) ;  __builtin_atan2l(f, f); __builtin_atan2f128(f,f);
 
 // NO__ERRNO: declare double @atan2(double, double) [[READNONE:#[0-9]+]]
 // NO__ERRNO: declare float @atan2f(float, float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[READNONE]]
+// NO__ERRNO: declare fp128 @atan2f128(fp128, fp128) [[READNONE]]
 // HAS_ERRNO: declare double @atan2(double, double) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @atan2f(float, float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @atan2f128(fp128, fp128) [[NOT_READNONE]]
 
   __builtin_copysign(f,f); __builtin_copysignf(f,f); __builtin_copysignl(f,f); __builtin_copysignf128(f,f);
 
@@ -47,14 +51,16 @@
 // HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
 
-  __builtin_frexp(f,i);__builtin_frexpf(f,i);   __builtin_frexpl(f,i);
+  __builtin_frexp(f,i);__builtin_frexpf(f,i);   __builtin_frexpl(f,i); __builtin_frexpf128(f,i);
 
 // NO__ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE:#[0-9]+]]
 // NO__ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
 // NO__ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare fp128 @frexpf128(fp128, i32*) [[NOT_READNONE]]
 // HAS_ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @frexpf128(fp128, i32*) [[NOT_READNONE]]
 
   __builtin_huge_val();__builtin_huge_valf();   __builtin_huge_vall(); __builtin_huge_valf128();
 
@@ -70,23 +76,27 @@
 // HAS_ERRNO-NOT: .inf
 // HAS_ERRNO-NOT: @inf
 
-  __builtin_ldexp(f,f);__builtin_ldexpf(f,f);   __builtin_ldexpl(f,f);  
+  __builtin_ldexp(f,f);__builtin_ldexpf(f,f);   __builtin_ldexpl(f,f);  __builtin_ldexpf128(f,f);
 
 // NO__ERRNO: declare double @ldexp(double, i32) [[READNONE]]
 // NO__ERRNO: declare float @ldexpf(float, i32) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[READNONE]]
+// NO__ERRNO: declare fp128 @ldexpf128(fp128, i32) [[READNONE]]
 // HAS_ERRNO: declare double @ldexp(double, i32) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @ldexpf(float, i32) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @ldexpf128(fp128, i32) [[NOT_READNONE]]
 
-  __builtin_modf(f,d);   __builtin_modff(f,fp);  __builtin_modfl(f,l); 
+  __builtin_modf(f,d);   __builtin_modff(f,fp);  __builtin_modfl(f,l); __builtin_modff128(f,l);
 
 // NO__ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
 // NO__ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
 // NO__ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
+// NO__ERRNO: declare fp128 @modff128(fp128, fp128*) [[NOT_READNONE]]
 // HAS_ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @modff128(fp128, f

[clang] 7faf62a - [Clang] Add more fp128 math library function builtins

2020-11-04 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2020-11-04T17:58:42+08:00
New Revision: 7faf62a80bfc3a9dfe34133681fcc31f8e8d658b

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

LOG: [Clang] Add more fp128 math library function builtins

Since glibc has supported math library functions conforming IEEE 128-bit
floating point types on some platform (like ppc64le), we can fix clang's
math builtins missing this type.

Reviewed By: bkramer

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

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/constrained-math-builtins.c
clang/test/CodeGen/math-builtins.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 45ea7d9a3551..ab1b5866c8a7 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -115,6 +115,7 @@
 BUILTIN(__builtin_atan2 , "ddd"  , "Fne")
 BUILTIN(__builtin_atan2f, "fff"  , "Fne")
 BUILTIN(__builtin_atan2l, "LdLdLd", "Fne")
+BUILTIN(__builtin_atan2f128, "LLdLLdLLd", "Fne")
 BUILTIN(__builtin_abs  , "ii"  , "ncF")
 BUILTIN(__builtin_copysign, "ddd", "ncF")
 BUILTIN(__builtin_copysignf, "fff", "ncF")
@@ -130,9 +131,11 @@ BUILTIN(__builtin_fmod , "ddd"  , "Fne")
 BUILTIN(__builtin_fmodf, "fff"  , "Fne")
 BUILTIN(__builtin_fmodf16, "hhh"  , "Fne")
 BUILTIN(__builtin_fmodl, "LdLdLd", "Fne")
+BUILTIN(__builtin_fmodf128, "LLdLLdLLd", "Fne")
 BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
 BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
 BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
+BUILTIN(__builtin_frexpf128, "LLdLLdi*", "Fn")
 BUILTIN(__builtin_huge_val, "d", "nc")
 BUILTIN(__builtin_huge_valf, "f", "nc")
 BUILTIN(__builtin_huge_vall, "Ld", "nc")
@@ -146,9 +149,11 @@ BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
 BUILTIN(__builtin_ldexp , "ddi"  , "Fne")
 BUILTIN(__builtin_ldexpf, "ffi"  , "Fne")
 BUILTIN(__builtin_ldexpl, "LdLdi", "Fne")
+BUILTIN(__builtin_ldexpf128, "LLdLLdi", "Fne")
 BUILTIN(__builtin_modf , "ddd*"  , "Fn")
 BUILTIN(__builtin_modff, "fff*"  , "Fn")
 BUILTIN(__builtin_modfl, "LdLdLd*", "Fn")
+BUILTIN(__builtin_modff128, "LLdLLdLLd*", "Fn")
 BUILTIN(__builtin_nan,  "dcC*" , "FnU")
 BUILTIN(__builtin_nanf, "fcC*" , "FnU")
 BUILTIN(__builtin_nanl, "LdcC*", "FnU")
@@ -164,167 +169,216 @@ BUILTIN(__builtin_pow , "ddd"  , "Fne")
 BUILTIN(__builtin_powf, "fff"  , "Fne")
 BUILTIN(__builtin_powf16, "hhh"  , "Fne")
 BUILTIN(__builtin_powl, "LdLdLd", "Fne")
+BUILTIN(__builtin_powf128, "LLdLLdLLd", "Fne")
 
 // Standard unary libc/libm functions with double/float/long double variants:
 BUILTIN(__builtin_acos , "dd"  , "Fne")
 BUILTIN(__builtin_acosf, "ff"  , "Fne")
 BUILTIN(__builtin_acosl, "LdLd", "Fne")
+BUILTIN(__builtin_acosf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_acosh , "dd"  , "Fne")
 BUILTIN(__builtin_acoshf, "ff"  , "Fne")
 BUILTIN(__builtin_acoshl, "LdLd", "Fne")
+BUILTIN(__builtin_acoshf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_asin , "dd"  , "Fne")
 BUILTIN(__builtin_asinf, "ff"  , "Fne")
 BUILTIN(__builtin_asinl, "LdLd", "Fne")
+BUILTIN(__builtin_asinf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_asinh , "dd"  , "Fne")
 BUILTIN(__builtin_asinhf, "ff"  , "Fne")
 BUILTIN(__builtin_asinhl, "LdLd", "Fne")
+BUILTIN(__builtin_asinhf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_atan , "dd"  , "Fne")
 BUILTIN(__builtin_atanf, "ff"  , "Fne")
 BUILTIN(__builtin_atanl, "LdLd", "Fne")
+BUILTIN(__builtin_atanf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_atanh , "dd", "Fne")
 BUILTIN(__builtin_atanhf, "ff", "Fne")
 BUILTIN(__builtin_atanhl, "LdLd", "Fne")
+BUILTIN(__builtin_atanhf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_cbrt , "dd", "Fnc")
 BUILTIN(__builtin_cbrtf, "ff", "Fnc")
 BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
+BUILTIN(__builtin_cbrtf128, "LLdLLd", "Fnc")
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceilf16, "hh"  , "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
+BUILTIN(__builtin_ceilf128, "LLdLLd", "Fnc")
 BUILTIN(__builtin_cos , "dd"  , "Fne")
 BUILTIN(__builtin_cosf, "ff"  , "Fne")
 BUILTIN(__builtin_cosf16, "hh"  , "Fne")
 BUILTIN(__builtin_cosh , "dd"  , "Fne")
 BUILTIN(__builtin_coshf, "ff"  , "Fne")
 BUILTIN(__builtin_coshl, "LdLd", "Fne")
+BUILTIN(__builtin_coshf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_cosl, "LdLd", "Fne")
+BUILTIN(__builtin_cosf128, "LLdLLd"  , "Fne")
 BUILTIN(__builtin_erf , "dd", "Fne")
 BUILTIN(__builtin_erff, "ff", "Fne")
 BUILTIN(__builtin_erfl, "LdLd", "Fne")
+BUILTIN(__builtin_erff128, "LLdLLd", "Fne")
 BUILTIN(__builtin_erfc , "dd", "Fne")
 BUILTIN(__builtin_erfcf, "ff", "Fne")
 BUILTIN(__builtin_erfcl, "LdLd", "Fne")
+BUILTIN(__builtin_erfcf128, "LLdLLd", "Fne")
 BUILTIN(__builtin_exp , "dd"  , "Fn

[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgorny.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

RemoteIndexClient implementations only depends on clangdSupport for
logging functionality and has no dependence on clangDeamon itself. This clears
out that link time dependency and enables depending on it in clangDeamon itself,
so that we can have other index implementations that makes use of the
RemoteIndex.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90746

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt


Index: clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
@@ -6,6 +6,5 @@
   UnimplementedClient.cpp
 
   LINK_LIBS
-  clangDaemon
   clangdSupport
-  )
+)
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -11,7 +11,6 @@
 #include "Client.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
-#include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,16 +18,14 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-
 protobuf
 grpc++
-clangDaemon
 clangdSupport
 
 DEPENDS
 RemoteIndexProto
 RemoteIndexServiceProto
-)
+  )
 
   add_subdirectory(marshalling)
   add_subdirectory(server)
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -112,6 +112,7 @@
   refactor/Tweak.cpp
 
   LINK_LIBS
+  clangdRemoteIndex
   clangdSupport
   clangTidy
   ${LLVM_PTHREAD_LIB}


Index: clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
@@ -6,6 +6,5 @@
   UnimplementedClient.cpp
 
   LINK_LIBS
-  clangDaemon
   clangdSupport
-  )
+)
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -11,7 +11,6 @@
 #include "Client.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
-#include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,16 +18,14 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-
 protobuf
 grpc++
-clangDaemon
 clangdSupport
 
 DEPENDS
 RemoteIndexProto
 RemoteIndexServiceProto
-)
+  )
 
   add_subdirectory(marshalling)
   add_subdirectory(server)
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -112,6 +112,7 @@
   refactor/Tweak.cpp
 
   LINK_LIBS
+  clangdRemoteIndex
   clangdSupport
   clangTidy
   ${LLVM_PTHREAD_LIB}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90747: [clangd] Mark AsyncTaskRunner::runAsync as const

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

RunAsync performs a write that's internally synchronized, so in theory
it shouldn't introduce any data-races. This will enable spawning async tasks in
const contexts.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90747

Files:
  clang-tools-extra/clangd/support/Threading.cpp
  clang-tools-extra/clangd/support/Threading.h


Index: clang-tools-extra/clangd/support/Threading.h
===
--- clang-tools-extra/clangd/support/Threading.h
+++ clang-tools-extra/clangd/support/Threading.h
@@ -110,12 +110,13 @@
   void wait() const { (void)wait(Deadline::infinity()); }
   LLVM_NODISCARD bool wait(Deadline D) const;
   // The name is used for tracing and debugging (e.g. to name a spawned 
thread).
-  void runAsync(const llvm::Twine &Name, llvm::unique_function Action);
+  void runAsync(const llvm::Twine &Name,
+llvm::unique_function Action) const;
 
 private:
   mutable std::mutex Mutex;
   mutable std::condition_variable TasksReachedZero;
-  std::size_t InFlightTasks = 0;
+  mutable std::size_t InFlightTasks = 0;
 };
 
 /// Runs \p Action asynchronously with a new std::thread. The context will be
Index: clang-tools-extra/clangd/support/Threading.cpp
===
--- clang-tools-extra/clangd/support/Threading.cpp
+++ clang-tools-extra/clangd/support/Threading.cpp
@@ -70,7 +70,7 @@
 }
 
 void AsyncTaskRunner::runAsync(const llvm::Twine &Name,
-   llvm::unique_function Action) {
+   llvm::unique_function Action) const {
   {
 std::lock_guard Lock(Mutex);
 ++InFlightTasks;


Index: clang-tools-extra/clangd/support/Threading.h
===
--- clang-tools-extra/clangd/support/Threading.h
+++ clang-tools-extra/clangd/support/Threading.h
@@ -110,12 +110,13 @@
   void wait() const { (void)wait(Deadline::infinity()); }
   LLVM_NODISCARD bool wait(Deadline D) const;
   // The name is used for tracing and debugging (e.g. to name a spawned thread).
-  void runAsync(const llvm::Twine &Name, llvm::unique_function Action);
+  void runAsync(const llvm::Twine &Name,
+llvm::unique_function Action) const;
 
 private:
   mutable std::mutex Mutex;
   mutable std::condition_variable TasksReachedZero;
-  std::size_t InFlightTasks = 0;
+  mutable std::size_t InFlightTasks = 0;
 };
 
 /// Runs \p Action asynchronously with a new std::thread. The context will be
Index: clang-tools-extra/clangd/support/Threading.cpp
===
--- clang-tools-extra/clangd/support/Threading.cpp
+++ clang-tools-extra/clangd/support/Threading.cpp
@@ -70,7 +70,7 @@
 }
 
 void AsyncTaskRunner::runAsync(const llvm::Twine &Name,
-   llvm::unique_function Action) {
+   llvm::unique_function Action) const {
   {
 std::lock_guard Lock(Mutex);
 ++InFlightTasks;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90748: [clangd] Introduce config parsing for External blocks

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Enable configuration of remote and static indexes through config files
in addition to command line arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90748

Files:
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -9,7 +9,9 @@
 #include "Annotations.h"
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
+#include "Features.inc"
 #include "Protocol.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
@@ -124,6 +126,34 @@
   ASSERT_THAT(Results, IsEmpty());
 }
 
+TEST(ParseYAML, ExternalBlock) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+Index:
+  External:
+File: "foo"
+Server: ^"bar"
+MountPoint: "baz"
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_EQ(Results.size(), 1u);
+  ASSERT_TRUE(Results[0].Index.External);
+  EXPECT_THAT(*Results[0].Index.External->File, Val("foo"));
+  EXPECT_THAT(*Results[0].Index.External->MountPoint, Val("baz"));
+#if CLANGD_ENABLE_REMOTE
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(*Results[0].Index.External->Server, Val("bar"));
+#else
+  EXPECT_FALSE(Results[0].Index.External->Server);
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(AllOf(
+  DiagMessage("Remote index support isn't enabled for this clangd."),
+  DiagPos(YAML.point()), DiagKind(llvm::SourceMgr::DK_Warning;
+#endif
+}
+
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -5,8 +5,8 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===--===//
-
 #include "ConfigFragment.h"
+#include "Features.inc"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -86,6 +86,25 @@
 DictParser Dict("Index", this);
 Dict.handle("Background",
 [&](Node &N) { F.Background = scalarValue(N, "Background"); });
+Dict.handle("External", [&](Node &N) {
+  F.External.emplace();
+  parse(*F.External, N);
+});
+Dict.parse(N);
+  }
+
+  void parse(Fragment::IndexBlock::ExternalBlock &F, Node &N) {
+DictParser Dict("External", this);
+Dict.handle("File", [&](Node &N) { F.File = scalarValue(N, "File"); });
+Dict.handle("Server", [&](Node &N) {
+#if CLANGD_ENABLE_REMOTE
+  F.Server = scalarValue(N, "Server");
+#else
+  warning("Remote index support isn't enabled for this clangd.", N);
+#endif
+});
+Dict.handle("MountPoint",
+[&](Node &N) { F.MountPoint = scalarValue(N, "MountPoint"); });
 Dict.parse(N);
   }
 
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -162,6 +162,23 @@
 /// This is checked for translation units only, not headers they include.
 /// Legal values are "Build" or "Skip".
 llvm::Optional> Background;
+/// Configuration information for an external index. If both File and Server
+/// are set, Server will be ignored. This will be used by index
+/// implementations to distribute queries to different index sources based
+/// on the file.
+struct ExternalBlock {
+  /// Path to a monolithic index on disk. Absolute in case of a global
+  /// config, relative to location the config file containing the fragment
+  /// otherwise.
+  llvm::Optional> File;
+  /// Address and port number for a remote-index. e.g. `123.1.1.1:13337`.
+  llvm::Optional> Server;
+  /// Source root governed by this index. None implies current config file
+  /// location. Absolute in case of user config and relative otherwise.
+  /// Should always use forward-slashes.
+  llvm::Optional> MountPoint;
+};
+llvm::Optional External;
   };
   IndexBlock Index;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90749: [clangd] Introduce config compilation for External blocks

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: ormris, MaskRay, ilya-biryukov.

Compilation logic for External blocks. A few of the high level points:

- Requires exactly one-of File/Server at a time:
  - Server is ignored in case of both, with a warning.
  - Having none is an error, would render ExternalBlock void.
- Ensures mountpoint is an absolute path:
  - Interprets it as relative to FragmentDirectory.
  - Defaults to FragmentDirectory when empty.
- Marks Background as Skip.

Depends on D90748 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90749

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -10,8 +10,11 @@
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
 #include "TestFS.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -20,6 +23,8 @@
 namespace clangd {
 namespace config {
 namespace {
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::SizeIs;
@@ -176,6 +181,97 @@
 ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   }
 }
+
+TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
+  Fragment::IndexBlock::ExternalBlock External;
+  External.File.emplace("");
+  External.Server.emplace("");
+  Frag.Index.External = std::move(External);
+  compileAndApply();
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  Contains(
+  AllOf(DiagMessage("Both File and Server specified, ignoring Server."),
+DiagKind(llvm::SourceMgr::DK_Warning;
+}
+
+TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) {
+  Frag.Index.External.emplace();
+  compileAndApply();
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  Contains(AllOf(
+  DiagMessage("At least one of File or Server must be specified."),
+  DiagKind(llvm::SourceMgr::DK_Error;
+}
+
+TEST_F(ConfigCompileTests, ExternalBlockDisablesBackgroundIndex) {
+  Parm.Path = "/foo/bar/baz.h";
+  Frag.Index.Background.emplace("Build");
+  Fragment::IndexBlock::ExternalBlock External;
+  External.File.emplace("/foo");
+  External.MountPoint.emplace("/foo/bar");
+  Frag.Index.External = std::move(External);
+  compileAndApply();
+  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Skip);
+}
+
+TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
+  auto GetFrag = [](llvm::StringRef Directory,
+llvm::Optional MountPoint) {
+Fragment Frag;
+Frag.Source.Directory = Directory.str();
+Fragment::IndexBlock::ExternalBlock External;
+External.File.emplace("/foo");
+if (MountPoint)
+  External.MountPoint.emplace(*MountPoint);
+Frag.Index.External = std::move(External);
+return Frag;
+  };
+
+  Parm.Path = "/foo/bar.h";
+  // Non-absolute MountPoint without a directory raises an error.
+  Frag = GetFrag("", "foo");
+  compileAndApply();
+  ASSERT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(AllOf(DiagMessage("MountPoint must be an absolute path."),
+DiagKind(llvm::SourceMgr::DK_Error;
+  EXPECT_THAT(Conf.Index.External.MountPoint, IsEmpty());
+
+  // Ok when relative.
+  Frag = GetFrag("/", "foo");
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Conf.Index.External.MountPoint, "/foo");
+
+  // None defaults to ".".
+  Frag = GetFrag("/", llvm::None);
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Conf.Index.External.MountPoint, "/");
+
+  // Without a file, external index is empty.
+  Parm.Path = "";
+  Frag = GetFrag("", "/foo");
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Conf.Index.External.MountPoint, IsEmpty());
+
+  // File outside MountPoint, no index.
+  Parm.Path = "/bar/baz.h";
+  Frag = GetFrag("", "/foo");
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Conf.Index.External.MountPoint, IsEmpty());
+
+  // File under MountPoint, index should be set.
+  Parm.Path = "/foo/baz.h";
+  Frag = GetFrag("", "/foo");
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Conf.Index.External.MountPoint, "/foo");
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/ConfigCompile

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgorny.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

An index implementation that can dispatch to a variety of indexes
depending on the file path. Enables clangd to work with multiple indexes in the
same instance, configured via config files.

Depends on D90749 , D90746 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90750

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -0,0 +1,7 @@
+//===-- ProjectAwareIndexTests.cpp  ---*- 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
+//
+//===--===//
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@
   PathMappingTests.cpp
   PreambleTests.cpp
   PrintASTTests.cpp
+  ProjectAwareIndexTests.cpp
   QualityTests.cpp
   RenameTests.cpp
   RIFFTests.cpp
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -0,0 +1,59 @@
+//===--- ProjectAware.h --*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+
+#include "Config.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/Merge.h"
+#include "index/Serialization.h"
+#include "index/remote/Client.h"
+#include "support/Threading.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+namespace clang {
+namespace clangd {
+
+class ProjectAwareIndex : public SymbolIndex {
+public:
+  size_t estimateMemoryUsage() const override;
+
+  void lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const override;
+
+  bool refs(const RefsRequest &Req,
+llvm::function_ref Callback) const override;
+
+  bool
+  fuzzyFind(const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const override;
+
+  void relations(const RelationsRequest &Req,
+ llvm::function_ref
+ Callback) const override;
+
+private:
+  SymbolIndex *getIndex() const;
+
+  Memoize> IndexForProject;
+  mutable std::mutex Mu;
+  mutable std::list> IndexStorage;
+  AsyncTaskRunner Tasks;
+};
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/index/ProjectAware.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -0,0 +1,88 @@
+//===--- ProjectAware.h --*- 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
+//
+//===--===//
+
+#include "ProjectAware.h"
+#include "support/Logger.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace clangd {
+size_t ProjectAwareIndex::estimateMemoryUsage() const {
+  size_t Total = 0;
+  std::lock_guard Lock(Mu);
+  for (auto &Idx : IndexStorage)
+Total += Idx->estimateMemoryUsage();
+  return Total;
+}
+
+void ProjectAwareIndex::lookup(
+const LookupRequest &Req,
+llvm::function_ref Callback) const {
+  if (auto *Idx = getIndex())
+Idx->lookup(Req, Callback);
+}
+
+bool ProjectAwareIndex::refs(
+const RefsRequest &Req,
+llvm::function_ref Callback) const {
+  if (auto *Idx = getIndex())

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet planned changes to this revision.
kadircet added a comment.

This is a WIP patch. Provided as a way to demonstrate how `ExternalBlock` will 
be used in an index implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[PATCH] D90540: [Syntax] Add minimal TableGen for syntax nodes. NFC

2020-11-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:9
+//
+// The C++ grammatical structure modeled by libSyntax is quite regular.
+//





Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:20
+//These are modeled as abstract types with inheritance (e.g. Declaration).
+//In future, we may model some as variants to avoid multiple-inheritance.
+//

I'd suggest to add this point later if we decide to do it.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:41
+
+// FIXME: add sequence, list, and alternative archetypes.

List is already defined in Nodes.td FWIW.



Comment at: clang/utils/TableGen/ClangSyntaxEmitter.cpp:19
+//
+// In future, the class definitions themselves will be moved produced by
+// additional backends.

I personally usually avoid writing about plans in comments, but up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90540

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


[PATCH] D90751: [clangd] Use ProjectAwareIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Put project-aware-index between command-line specified static index and
ClangdServer indexes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90751

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,6 +13,9 @@
 #include "Protocol.h"
 #include "Transport.h"
 #include "index/Background.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/ProjectAware.h"
 #include "index/Serialization.h"
 #include "index/remote/Client.h"
 #include "refactor/Rename.h"
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef _WIN32
 #include 
@@ -726,6 +730,7 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   Opts.CollectMainFileRefs = CollectMainFileRefs;
+  std::vector> IdxStack;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !IndexFile.empty()) {
@@ -757,7 +762,15 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  Opts.StaticIndex = StaticIdx.get();
+  ProjectAwareIndex PAI;
+  if (StaticIdx) {
+IdxStack.emplace_back(std::move(StaticIdx));
+IdxStack.emplace_back(
+std::make_unique(&PAI, IdxStack.back().get()));
+Opts.StaticIndex = IdxStack.back().get();
+  } else {
+Opts.StaticIndex = &PAI;
+  }
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
   Opts.PreserveRecoveryASTType = RecoveryASTType;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,6 +13,9 @@
 #include "Protocol.h"
 #include "Transport.h"
 #include "index/Background.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/ProjectAware.h"
 #include "index/Serialization.h"
 #include "index/remote/Client.h"
 #include "refactor/Rename.h"
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef _WIN32
 #include 
@@ -726,6 +730,7 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   Opts.CollectMainFileRefs = CollectMainFileRefs;
+  std::vector> IdxStack;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !IndexFile.empty()) {
@@ -757,7 +762,15 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  Opts.StaticIndex = StaticIdx.get();
+  ProjectAwareIndex PAI;
+  if (StaticIdx) {
+IdxStack.emplace_back(std::move(StaticIdx));
+IdxStack.emplace_back(
+std::make_unique(&PAI, IdxStack.back().get()));
+Opts.StaticIndex = IdxStack.back().get();
+  } else {
+Opts.StaticIndex = &PAI;
+  }
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
   Opts.PreserveRecoveryASTType = RecoveryASTType;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90540: [Syntax] Add minimal TableGen for syntax nodes. NFC

2020-11-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:31
+
+// NodeType is the root of the archetype hierarchy.
+class NodeType {

"Records derived from NodeType correspond to syntax tree node types."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90540

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


[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

> e.g. we may introduce abstract bases like "loop" that the grammar doesn't 
> care about in order to model is-a concepts that might make refactorings more 
> expressive. This is less natural in a grammar-like idiom.

Loop can be an alternative rule in the grammar, I'm not sure what is less 
natural about it:

  Statement ::=
IfStatement | LoopStatement | BreakStatement | ...
  
  LoopStatement ::=
ForLoopStatement | WhileLoopStatement | ...




Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:36
+  // Documentation for this Node subclass.
+  string documentation;
 }

I think it would be best to make documentation mandatory, and for nodes that 
are currently lacking it, add a FIXME so that we clearly see where the tech 
debt is.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:48
+
+// An abstract node type which merely serves as a base for more specific types.
+class Alternatives : NodeType { let base = base_; }

+
```
It corresponds to an alternative rule in the grammar, for example:
Statement ::=
  IfStatement | ForStatement | ...

`Statement` should be modeled with `Alternatives<>`. `IfStatement` and 
`ForStatement` are derived from `Statement`.
`



Comment at: clang/utils/TableGen/ClangSyntaxEmitter.cpp:147-148
+
+// Format a documentation string as a C++ comment.
+// This has special whitespace handling as comments may appear in *.td as:
+//documentation = [{




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90543

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


[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:115
   LINK_LIBS
+  clangdRemoteIndex
   clangdSupport

If we're moving `clangdRemoteIndex` to `clangDaemon` there is no need to link 
`clangd` itself to `clangdRemoteIndex` anymore (in `tool/CMakeLists.txt`).



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:30
 RemoteIndexServiceProto
-)
 

I think changing it is inconsistent with LLVM CMake style. Having closing paren 
on the same indentation level as the items is awkward but that's what we do :(



Comment at: 
clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt:11
   clangdSupport
-  )

same here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90746

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


[PATCH] D90659: [Syntax] Tablegen Sequence classes. NFC

2020-11-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.td:123
+Role<"CloseParen", Token<"r_paren">>,
+  ];
+}

The reason why in my prototype the grammar rules are separate is to allow 
expressing rules that depend on each other in a circular fashion. Seems like 
you avoided the problem right now by removing the need for Expression to refer 
to all subclasses, but it would come back, in, for example, LambdaExpression -- 
which is an expression that needs to refer to CompoundStatement that is defined 
later in this file, while CompoundStatement will need to refer to Expression. 
Maybe there is also a way to break circularity there by careful ordering -- but 
we would be mixing the order of expressions and statements.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:70
+//
+// Each child is characterized by a unique role and an allowed base type.
+// The role sequence and role/type match are enforced invariants of the class.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90659

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


[PATCH] D90754: [analyzer][NFCi] Mark CallEvent::getOriginExpr virtual, some cleanup

2020-11-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, martong, ASDenysPetrov, Szelethus.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

Previously we just shadowed the original implementation with a virtual
declaration - which is really bugprone in a long run.

This patch marks `CallEvent::getOriginExpr` virtual to let subclasses
//override// it's behavior.
At the same time, I checked all //virtual// functions of this class hierarchy
 to make sure we don't suffer from this elsewhere. 
Removes redundant declarations of `virtual` if `override` is already present.

In theory, this patch is a //functional change//, but no tests were broken.
I suspect that there were no //meaningful// changes in behavior in the
subclasses compared to the shadowed `CallEvent::getOriginExpr`.

That being said, I had a hard time coming up with unit-tests covering this.

Motivation: https://reviews.llvm.org/D74735#2370909


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90754

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h

Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -225,7 +225,7 @@
 
   /// Returns the expression whose value will be the result of this call.
   /// May be null.
-  const Expr *getOriginExpr() const {
+  virtual const Expr *getOriginExpr() const {
 return Origin.dyn_cast();
   }
 
@@ -530,7 +530,7 @@
   }
 
 public:
-  virtual const CallExpr *getOriginExpr() const {
+  const CallExpr *getOriginExpr() const override {
 return cast(AnyFunctionCall::getOriginExpr());
   }
 
@@ -543,9 +543,7 @@
   }
 
   Kind getKind() const override { return CE_Function; }
-  virtual StringRef getKindAsString() const override {
-return "SimpleFunctionCall";
-  }
+  StringRef getKindAsString() const override { return "SimpleFunctionCall"; }
 
   static bool classof(const CallEvent *CA) {
 return CA->getKind() == CE_Function;
@@ -570,7 +568,7 @@
  RegionAndSymbolInvalidationTraits *ETraits) const override;
 
 public:
-  virtual const CallExpr *getOriginExpr() const {
+  const CallExpr *getOriginExpr() const override {
 return cast(CallEvent::getOriginExpr());
   }
 
@@ -653,7 +651,7 @@
   ArrayRef parameters() const override;
 
   Kind getKind() const override { return CE_Block; }
-  virtual StringRef getKindAsString() const override { return "BlockCall"; }
+  StringRef getKindAsString() const override { return "BlockCall"; }
 
   static bool classof(const CallEvent *CA) { return CA->getKind() == CE_Block; }
 };
@@ -708,7 +706,7 @@
   void cloneTo(void *Dest) const override { new (Dest) CXXMemberCall(*this); }
 
 public:
-  virtual const CXXMemberCallExpr *getOriginExpr() const {
+  const CXXMemberCallExpr *getOriginExpr() const override {
 return cast(CXXInstanceCall::getOriginExpr());
   }
 
@@ -727,7 +725,7 @@
   RuntimeDefinition getRuntimeDefinition() const override;
 
   Kind getKind() const override { return CE_CXXMember; }
-  virtual StringRef getKindAsString() const override { return "CXXMemberCall"; }
+  StringRef getKindAsString() const override { return "CXXMemberCall"; }
 
   static bool classof(const CallEvent *CA) {
 return CA->getKind() == CE_CXXMember;
@@ -752,7 +750,7 @@
   }
 
 public:
-  virtual const CXXOperatorCallExpr *getOriginExpr() const {
+  const CXXOperatorCallExpr *getOriginExpr() const override {
 return cast(CXXInstanceCall::getOriginExpr());
   }
 
@@ -767,9 +765,7 @@
   const Expr *getCXXThisExpr() const override;
 
   Kind getKind() const override { return CE_CXXMemberOperator; }
-  virtual StringRef getKindAsString() const override {
-return "CXXMemberOperatorCall";
-  }
+  StringRef getKindAsString() const override { return "CXXMemberOperatorCall"; }
 
   static bool classof(const CallEvent *CA) {
 return CA->getKind() == CE_CXXMemberOperator;
@@ -838,9 +834,7 @@
   }
 
   Kind getKind() const override { return CE_CXXDestructor; }
-  virtual StringRef getKindAsString() const override {
-return "CXXDestructorCall";
-  }
+  StringRef getKindAsString() const override { return "CXXDestructorCall"; }
 
   static bool classof(const CallEvent *CA) {
 return CA->getKind() == CE_CXXDestructor;
@@ -898,7 +892,7 @@
   void cloneTo(void *Dest) const override { new (Dest) CXXConstructorCall(*this); }
 
 public:
-  virtual const CXXConstructExpr *getOriginExpr() const {
+  const CXXConstructExpr *getOriginExpr() const override {
 return cast(AnyFunctionCall::getOriginExpr());
   }
 
@@ -913,9 +907,7 @@
   }
 
   Kind getKind() const override { return CE_CXXConstructor; 

[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-11-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:916-918
+  virtual const CXXInheritedCtorInitExpr *getOriginExpr() const {
+return cast(AnyFunctionCall::getOriginExpr());
+  }

NoQ wrote:
> steakhal wrote:
> > Why is this function virtual?
> > If we want such behavior we should mark the `CallEvent::getOriginExpr` 
> > virtual and just //override// it here.
> > As-of-now, this just hides the previous implementation, causing potential 
> > problems.
> > 
> > This code-smell occures several times across this class hierachy.
> > 
> > Is this the expected behavior @NoQ?
> I think you're right, it should have been virtual from the start. Weird. 
> Probably the only reason this works is that all overrides do literally the 
> same thing, just cast to different types. But if even one of them doesn't 
> we're in trouble. Yeah this needs to be fixed.
D90754 aims to fix this. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74735

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


[PATCH] D87360: clang-cl: Alias /wd4101 to -Wno-unused-variable

2020-11-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D87360

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


[PATCH] D87364: clang-cl: Alias /wd4238 to -Wno-address-of-temporary

2020-11-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87364

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-11-04 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

Sorry, I don't think it's worth reverting and resubmitting the same changes in 
such a case. Commit attribution is correct and there is link to this code 
review.
After all, most clang-tidy users will never read commit messages and will only 
use `--help` for discovering this feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D87981: [X86] AMX programming model prototype.

2020-11-04 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/test/CodeGen/X86/ipra-reg-usage.ll:6
 define preserve_allcc void @foo()#0 {
-; CHECK: foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $fpcw 
$fpsw $fs $gs $hip $ip $mxcsr $rip $riz $ss $ssp $bnd0 $bnd1 $bnd2 $bnd3 $cr0 
$cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 $cr14 
$cr15 $dr0 $dr1 $dr2 $dr3 $dr4 $dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 $dr13 
$dr14 $dr15 $fp0 $fp1 $fp2 $fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 $k5 $k6 
$k7 $mm0 $mm1 $mm2 $mm3 $mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 $st4 $st5 
$st6 $st7 $tmm0 $tmm1 $tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 $xmm17 $xmm18 
$xmm19 $xmm20 $xmm21 $xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 $xmm28 $xmm29 
$xmm30 $xmm31 $ymm0 $ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 $ymm8 $ymm9 
$ymm10 $ymm11 $ymm12 $ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 $ymm19 $ymm20 
$ymm21 $ymm22 $ymm23 $ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 $ymm30 $ymm31 
$zmm0 $zmm1 $zmm2 $zmm3 $zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 $zmm10 $zmm11 
$zmm12 $zmm13 $zmm14 $zmm15 $zmm16 $zmm17 $zmm18 $zmm19 $zmm20 $zmm21 $zmm22 
$zmm23 $zmm24 $zmm25 $zmm26 $zmm27 $zmm28 $zmm29 $zmm30 $zmm31 $r11b $r11bh 
$r11d $r11w $r11wh
+; CHECK: foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $fpcw 
$fpsw $fs $gs $hip $ip $mxcsr $rip $riz $ss $ssp $tmmcfg $bnd0 $bnd1 $bnd2 
$bnd3 $cr0 $cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 
$cr14 $cr15 $dr0 $dr1 $dr2 $dr3 $dr4 $dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 
$dr13 $dr14 $dr15 $fp0 $fp1 $fp2 $fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 
$k5 $k6 $k7 $mm0 $mm1 $mm2 $mm3 $mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 
$st4 $st5 $st6 $st7 $tmm0 $tmm1 $tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 
$xmm17 $xmm18 $xmm19 $xmm20 $xmm21 $xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 
$xmm28 $xmm29 $xmm30 $xmm31 $ymm0 $ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 
$ymm8 $ymm9 $ymm10 $ymm11 $ymm12 $ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 
$ymm19 $ymm20 $ymm21 $ymm22 $ymm23 $ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 
$ymm30 $ymm31 $zmm0 $zmm1 $zmm2 $zmm3 $zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 
$zmm10 $zmm11 $zmm12 $zmm13 $zmm14 $zmm15 $zmm16 $zmm17 $zmm18 $zmm19 $zmm20 
$zmm21 $zmm22 $zmm23 $zmm24 $zmm25 $zmm26 $zmm27 $zmm28 $zmm29 $zmm30 $zmm31 
$r11b $r11bh $r11d $r11w $r11wh $k0_k1 $k2_k3 $k4_k5 $k6_k7
   call void @bar1()

LuoYuanke wrote:
> pengfei wrote:
> > Why this patch affects the k registers?
> This looks wired to me too.  The patch only add "tmmcfg". I'll look into it 
> later.
I check the test case without my patch the k pair registers are clobbered. But 
FileCheck only match the strings, so the test passes. I can also remove "$k0_k1 
$k2_k3 $k4_k5 $k6_k7" from the checking.

$ llc -enable-ipra -print-regusage test/CodeGen/X86/ipra-reg-usage.ll
foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $fpcw $fpsw $fs $gs 
$hip $ip $mxcsr $rip $riz $ss $ssp $bnd0 $bnd1 $bnd2 $bnd3 $cr0 $cr1 $cr2 $cr3 
$cr4 $cr5 $cr6
$cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 $cr14 $cr15 $dr0 $dr1 $dr2 $dr3 $dr4 
$dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 $dr13 $dr14 $dr15 $fp0 $fp1 $fp2 
$fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 $k5 $k6 $k7 $mm0 $mm1 $mm2 $mm3 
$mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 $st4 $st5 $st6 $st7 $tmm0 $tmm1 
$tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 $xmm17 $xmm18 $xmm19 $xmm20 $xmm21 
$xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 $xmm28 $xmm29 $xmm30 $xmm31 $ymm0 
$ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 $ymm8 $ymm9 $ymm10 $ymm11 $ymm12 
$ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 $ymm19 $ymm20 $ymm21 $ymm22 $ymm23 
$ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 $ymm30 $ymm31 $zmm0 $zmm1 $zmm2 $zmm3
$zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 $zmm10 $zmm11 $zmm12 $zmm13 $zmm14 $zmm15 
$zmm16 $zmm17 $zmm18 $zmm19 $zmm20 $zmm21 $zmm22 $zmm23 $zmm24 $zmm25 $zmm26 
$zmm27 $zmm28 $zmm29 $zmm30 $zmm31 $r11b $r11bh $r11d $r11w $r11wh $k0_k1 
$k2_k3 $k4_k5 $k6_k7



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D52957: [analyzer] Teach CallEvent about C++17 aligned new.

2020-11-04 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.
Herald added subscribers: ASDenysPetrov, martong, Charusso, dkrupp.

I'm not sure if this implementation is correct.

I'm expecting this checker code not to crash:

  const auto *alloc = dyn_cast(&Call);
  if (!alloc)
return;
  
  const int NumImpArgs = alloc->getNumImplicitArgs();
  errs() << "alloc->getNumImplicitArgs(): " << NumImpArgs << '\n'; // prints 1
  for (int i = 0; i < NumImpArgs; ++i)
errs() << "> " << alloc->getPlacementArgExpr(i) << '\n'; // crash: 
assertion violated
  
  const int NumArgs = alloc->getNumArgs();
  errs() << "alloc->getNumArgs(): " << NumArgs << '\n';
  for (int i = NumImpArgs; i < NumArgs; ++i)
errs() << "> " << alloc->getArgExpr(i) << '\n';

Analyzed code:

  void foo() {
int *p = new int;
  }

Assertion:

  clang: ../../clang/include/clang/AST/ExprCXX.h:2272: clang::Expr* 
clang::CXXNewExpr::getPlacementArg(unsigned int): Assertion `(I < 
getNumPlacementArgs()) && "Index out of range!"' failed.



---

I'm planning to improve the `MallocChecker` using `CallEvent`s directly, 
instead of using the underlaying `CallExpr` or `CXXNewExpr` objects in 
`MallocChecker::checkCXXNewOrCXXDelete`.
Am I misusing something? @NoQ


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52957

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


[PATCH] D90531: [clangd] Add clang-tidy options to config

2020-11-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 302818.
njames93 added a comment.

Rebase and make apply take reference to Params.
Fix fragments checks being applied on top of each other instead of overwriting 
the current config checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90531

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -35,6 +35,14 @@
   return false;
 }
 
+MATCHER_P2(PairVal, Value1, Value2, "") {
+  if (*arg.first == Value1 && *arg.second == Value2)
+return true;
+  *result_listener << "values are [" << *arg.first << ", " << *arg.second
+   << "]";
+  return false;
+}
+
 TEST(ParseYAML, SyntacticForms) {
   CapturedDiags Diags;
   const char *YAML = R"yaml(
@@ -50,10 +58,18 @@
 ---
 Index:
   Background: Skip
+---
+ClangTidy: { Enable: true }
+---
+ClangTidy: 
+  Enable: 0
+  CheckOptions: 
+IgnoreMacros: true
+example-check.ExampleOption: 0
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 3u);
+  ASSERT_EQ(Results.size(), 5u);
   EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
   EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
   EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), Val("bar")));
@@ -62,6 +78,13 @@
 
   ASSERT_TRUE(Results[2].Index.Background);
   EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
+  ASSERT_TRUE(Results[3].ClangTidy.Enable);
+  EXPECT_TRUE(**Results[3].ClangTidy.Enable);
+  ASSERT_TRUE(Results[4].ClangTidy.Enable);
+  EXPECT_FALSE(**Results[4].ClangTidy.Enable);
+  EXPECT_THAT(Results[4].ClangTidy.CheckOptions,
+  ElementsAre(PairVal("IgnoreMacros", "true"),
+  PairVal("example-check.ExampleOption", "0")));
 }
 
 TEST(ParseYAML, Locations) {
@@ -84,26 +107,36 @@
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
 If:
-  [[UnknownCondition]]: "foo"
+  $unknown[[UnknownCondition]]: "foo"
 CompileFlags:
   Add: 'first'
 ---
-CompileFlags: {^
+ClangTidy:
+  Enable: $notBool[[NotABool]]
+---
+CompileFlags: {$unexpected^
 )yaml");
   auto Results =
   Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
 
   ASSERT_THAT(
   Diags.Diagnostics,
-  ElementsAre(AllOf(DiagMessage("Unknown If key UnknownCondition"),
-DiagKind(llvm::SourceMgr::DK_Warning),
-DiagPos(YAML.range().start), DiagRange(YAML.range())),
-  AllOf(DiagMessage("Unexpected token. Expected Key, Flow "
-"Entry, or Flow Mapping End."),
-DiagKind(llvm::SourceMgr::DK_Error),
-DiagPos(YAML.point()), DiagRange(llvm::None;
+  ElementsAre(
+  AllOf(DiagMessage("Unknown If key UnknownCondition"),
+DiagKind(llvm::SourceMgr::DK_Warning),
+DiagPos(YAML.range("unknown").start),
+DiagRange(YAML.range("unknown"))),
+  AllOf(
+  DiagMessage("Couldn't parse 'NotABool' as a boolean for Enable"),
+  DiagKind(llvm::SourceMgr::DK_Warning),
+  DiagPos(YAML.range("notBool").start),
+  DiagRange(YAML.range("notBool"))),
+  AllOf(DiagMessage("Unexpected token. Expected Key, Flow "
+"Entry, or Flow Mapping End."),
+DiagKind(llvm::SourceMgr::DK_Error),
+DiagPos(YAML.point("unexpected")), DiagRange(llvm::None;
 
-  ASSERT_EQ(Results.size(), 1u); // invalid fragment discarded.
+  ASSERT_EQ(Results.size(), 2u); // invalid fragment discarded.
   EXPECT_THAT(Results.front().CompileFlags.Add, ElementsAre(Val("first")));
   EXPECT_TRUE(Results.front().If.HasUnrecognizedCondition);
 }
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -176,6 +176,25 @@
 ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   }
 }
+
+TEST_F(ConfigCompileTests, Tidy) {
+  Frag.ClangTidy.Add.emplace_back("bugprone-use-after-move");
+  Frag.ClangTidy.Add.emplace_back("llvm-*");
+  Frag.ClangTidy.Remove.emplace_back("llvm-include-order");
+  Frag.ClangTidy.Remove.emplace_back("readability-*");
+  Frag.ClangTidy.Che

[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:115
   LINK_LIBS
+  clangdRemoteIndex
   clangdSupport

kbobyrev wrote:
> If we're moving `clangdRemoteIndex` to `clangDaemon` there is no need to link 
> `clangd` itself to `clangdRemoteIndex` anymore (in `tool/CMakeLists.txt`).
All of the libraries linked to clangDeamon are explicitly being linked again to 
clangd. Even though the ones coming from clang and clangTooling are marked as 
private here, others like clangdSupport and clangTidy are linked with "default" 
(whatever that means) visibility. Hence I kept the linking on the clangd side 
as well.

I suppose moving these to PRIVATE libraries and keeping the extra linking in 
ClangdMain is the more consistent thing. As ClangdMain still calls 
`remote::getClient`. Let me know if you disagree or I am missing something.



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:30
 RemoteIndexServiceProto
-)
 

kbobyrev wrote:
> I think changing it is inconsistent with LLVM CMake style. Having closing 
> paren on the same indentation level as the items is awkward but that's what 
> we do :(
*sigh*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90746

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


[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 302820.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Revert indentation changes
- Move all libraries to private to be consistent on what we link in ClangdMain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90746

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
  clang-tools-extra/clangd/tool/CMakeLists.txt

Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -28,12 +28,14 @@
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
-  clangdRemoteIndex
   )
+
 target_link_libraries(clangd
   PRIVATE
   clangTidy
+
   clangDaemon
+  clangdRemoteIndex
   clangdSupport
   ${CLANGD_XPC_LIBS}
   )
Index: clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
@@ -6,6 +6,5 @@
   UnimplementedClient.cpp
 
   LINK_LIBS
-  clangDaemon
   clangdSupport
   )
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -11,7 +11,6 @@
 #include "Client.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
-#include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,10 +18,8 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-
 protobuf
 grpc++
-clangDaemon
 clangdSupport
 
 DEPENDS
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -28,7 +28,7 @@
   FrontendOpenMP
   Option
   )
-  
+
 include(${CMAKE_CURRENT_SOURCE_DIR}/quality/CompletionModel.cmake)
 gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel clang::clangd::Example)
 
@@ -111,12 +111,6 @@
   refactor/Rename.cpp
   refactor/Tweak.cpp
 
-  LINK_LIBS
-  clangdSupport
-  clangTidy
-  ${LLVM_PTHREAD_LIB}
-  ${ALL_CLANG_TIDY_CHECKS}
-
   DEPENDS
   omp_gen
   )
@@ -145,6 +139,17 @@
   clangToolingSyntax
   )
 
+target_link_libraries(clangDaemon
+  PRIVATE
+  ${LLVM_PTHREAD_LIB}
+
+  clangTidy
+  ${ALL_CLANG_TIDY_CHECKS}
+
+  clangdSupport
+  clangdRemoteIndex
+  )
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87368: clang-cl: Alias /wd5054 to -Wno-deprecated-anon-enum-enum-conversion

2020-11-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87368

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


[PATCH] D87372: clang-cl: Ignore /Zc:externConstexpr and /Zc:throwingNew

2020-11-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I'm not sure ignoring these is the right thing to do.  Maybe they should be 
"Unsupported but parsed options" instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87372

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


[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang-tools-extra/clangd/CMakeLists.txt:115
   LINK_LIBS
+  clangdRemoteIndex
   clangdSupport

kadircet wrote:
> kbobyrev wrote:
> > If we're moving `clangdRemoteIndex` to `clangDaemon` there is no need to 
> > link `clangd` itself to `clangdRemoteIndex` anymore (in 
> > `tool/CMakeLists.txt`).
> All of the libraries linked to clangDeamon are explicitly being linked again 
> to clangd. Even though the ones coming from clang and clangTooling are marked 
> as private here, others like clangdSupport and clangTidy are linked with 
> "default" (whatever that means) visibility. Hence I kept the linking on the 
> clangd side as well.
> 
> I suppose moving these to PRIVATE libraries and keeping the extra linking in 
> ClangdMain is the more consistent thing. As ClangdMain still calls 
> `remote::getClient`. Let me know if you disagree or I am missing something.
I see, makes sense, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90746

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


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-04 Thread Eric Astor via Phabricator via cfe-commits
epastor added inline comments.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2851
+// Parse MASM style pseudo prefixes.
+// FIXME: This prefix should only be used for MASM, not for intel-syntax.
+if (isParsingIntelSyntax()) {

LiuChen3 wrote:
> I tried to limit to MASM. But I found that the  'isParsingMSInlineAsm()' is 
> not accurate.  And then I tried to transmit 'ParsingMSInlineAsm' information 
> correctly in AsmPrinterInlineAsm.cpp (according to the '-fasm-blocks' 
> option). But I was surprised to find that isParsingMSInlineAsm() is actually 
> used as the argument of 'MatchingInlineAsm' in 'MatchAndEmitInstruction()'. 
> This makes me confused. Should that 'MatchingInlineAsm' be 
> 'MatchingMSInlineAsm' ?Is this MatchingInlineAsm only used by llvm-ml.
> It difficult to limit this to MASM at the moment. 
llvm-ml attempts not to touch **anything** involving inline assembly so far. 
The signal that MasmParser.cpp is involved is `Parser.isParsingMasm()`. 
However... while I can't answer the majority of this without more research, I 
suspect you're correct that `MatchingInlineAsm` is misnamed. We need to check 
this, and if so, we should rename it to avoid confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-11-04 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D90275#2371813 , @jdoerfert wrote:

> As noted by the GCC docs, it doesn't mean anything on a definition so that 
> you can safely merge TUs. I want us to forbid `leaf` on IR function 
> definitions for that reason, it would not mean anything and be only confusing.

Okay, I see.
I agree that having this attribute at definitions is slightly dangerous..!

But I am not still 100% sure about the safety of merging... I see that it is 
okay when `leaf` is on a definition, but what about declaration?

  // a.ll
  define void f1() { f2(); }
  define void g() { x = 3; }
  // b.ll
  define void f2() { leaf(); }
  declare leaf void @leaf() ; If @leaf() was actually calling @g(), is merging 
a.ll and b.ll valid?



> It is not a memory thing. However, the "almost" matching memory property is 
> called `inaccesiblememonly` so that is why I wanted to call this 
> `inaccessiblecodeonly`.

Eh, actually my question was more like a question to gcc people about why 
`leaf` was defined that way. Maybe my question is not relevant in this thread. 
Thank you for answering though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90275

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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-11-04 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi!

I found a new problem after this was turned on again in 51ff04567b2f 
.
With

  opt -S -o - bbi-49235.ll -memoryssa -gvn -dse -verify-memoryssa

I hit

  opt: ../lib/Analysis/MemorySSA.cpp:2063: void 
llvm::MemorySSA::verifyOrderingDominationAndDefUses(llvm::Function &) const: 
Assertion `&*ALI == *AAI && "Not the same accesses in the same order"' failed.

with bbi-49235.ll being

  define void @k() {
  entry:
%tobool = icmp ne i16 1, 0
%0 = xor i1 %tobool, true
call void @llvm.assume(i1 %0)
call void @f()
ret void
  }
  
  declare void @f() local_unnamed_addr
  
  ; Function Attrs: nofree nosync nounwind willreturn
  declare void @llvm.assume(i1 noundef) #0
  
  attributes #0 = { nofree nosync nounwind willreturn }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D86559: [Sema, CodeGen] Allow [[likely]] and [[unlikely]] on labels

2020-11-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D86559#2371581 , @Mordante wrote:

> In D86559#2371058 , @aaron.ballman 
> wrote:
>
>> In D86559#2369317 , @Mordante wrote:
>>
>>> Then me try to clear up the confusion.
>>>
 However, I could imagine there being cases when we might want a helper 
 function on `LabelDecl` that looks for attributes on the associated 
 `LabelStmt` and returns results about it if that helps ease implementation 
 or refactoring burdens.
>>>
>>> If we want that we need to change the `LabelDecl` to point to either a 
>>> `LabelStmt` or an `AttributedStmt`. This was the approach I thought I had 
>>> to take, but I found this solution. We can still take that direction if 
>>> wanted. But then we need to place `DeclAttr` in an `AttributedStmt`, not 
>>> sure how well that works and how much additional code needs to change to 
>>> find the attributes there. Since in that case we to call this helper 
>>> function at the appropriate places.
>>
>> Ah, I was thinking of something slightly different here. I was thinking that 
>> `LabelDecl` would hold a `Stmt*` so that it could be either a label 
>> statement or an attribute statement.
>
> Yes I wanted to take that route. While investigating that route I found the 
> current solution and it seemed less intrusive. So that's why I went for the 
> current approach.
>
>> The helper functions would give you access to the attributes of the 
>> statement and to the `LabelStmt` itself (stripping off any attributed 
>> statements). Then in Attr.td, we'd move attributes off the label 
>> declarations and onto the label statements. At the end of the day, all 
>> attributes on labels would appertain to the statement at the AST level, but 
>> you'd have an easier time transitioning in some places if you could get to 
>> the attributes if the only thing you have is the `LabelDecl`. (So this 
>> doesn't mix statement and declaration attributes together, it shifts the 
>> model to putting all attributes on labels on the statement level rather than 
>> having a somewhat odd split between decl and statement.)
>
> If we go that route, then we need to think about attributes that are normally 
> allowed on declarations. For example
>
>   def Unused : InheritableAttr {
> let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
>  C2x<"", "maybe_unused", 201904>];
> let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, 
> Label,
> Field, ObjCMethod, FunctionLike]>;
> let Documentation = [WarnMaybeUnusedDocs];
>   }

Yup, `annotate` is another such attribute, to some degree. I was envisioning 
that these tablegen definitions would have to change slightly to allow for 
writing on a statement for the label case.

> It also seems attributes on the `LabelDecl` aren't visible in the AST at the 
> moment. If I modify the example posted yesterday to:
>
>   void foo() {
> [[likely, clang::annotate("foo")]] lbl:;
>   }
>
> The AST will become:
>
>   `-FunctionDecl 0x5607f7dbb7a8  line:1:6 foo 'void 
> ()'
> `-CompoundStmt 0x5607f7dbba60 
>   `-AttributedStmt 0x5607f7dbba48 
> |-LikelyAttr 0x5607f7dbba20 
> `-LabelStmt 0x5607f7dbba08  'lbl'
>   `-NullStmt 0x5607f7dbb928 
>
> Maybe it would be a good idea to see whether the `LabelDecl` needs to be 
> visible in the AST even if we proceed with the current approach.

Good catch, I hadn't noticed that before. I agree, we should figure that out. 
Some simple testing shows clang-query also doesn't match label declarations 
with the `decl()` matcher, so the issue is wider than just dumping the AST.

>>> Does this clear your confusion?
>>> Do you agree with this approach or do you think changing the `LabelDecl` is 
>>> the better solution?
>>
>> Thank you for the explanations, I understand your design better now. I'm not 
>> certain what the right answer is yet, but thinking out loud about my 
>> concerns: I worry that making a distinction between a label statement and a 
>> label declaration (at least for attributes) generates heat without light. 
>> Making the attribute author decide "which label construct should my 
>> attribute appertain to" adds extra burden on attribute authors and I'm not 
>> sure I have any advice for them on whether to use the decl or the statement 
>> -- it seems entirely arbitrary. Coupled with the fact that the standard 
>> defines labels as being statements, that suggests to me that putting all of 
>> the attributes on the statement level is the right decision -- it's one 
>> place (removes confusion about where it goes), it's the "obvious" place 
>> (matches where the standard suggests that attributes live), and we should 
>> have all the machinery in place to make it possible within the compiler 
>> (given that you can reach the `LabelStmt` from the `Labe

[PATCH] D90570: [mips] Add a -mmips3d command line option to clang

2020-11-04 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

My bad, I missed that you implemented passing the option to backend.

Could you add some improvements to the patch?

1. As far as I know GCC does not accept `-mmips3d` option. It uses `-mips3d`. 
We need do the same.

2. Add test cases. For the reference you might take a look at the -mdspr2 
option in the following tests:

  test/Driver/mips-as.c
  test/Driver/mips-features.c
  test/Driver/mips-integrated-as.c

3. GCC defines `#define __mips3d 1` macro when the `-mips3d` option is 
provided. Take a look at the `MipsTargetInfo::getTargetDefines()` as a point 
for implementation.

4. As far as I remember MIPS 3D requires 64-bit floating-point registers. We 
need to check that 64-bit is enabled and show an error otherwise like GCC does.

3 and 4 need test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90570

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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-11-04 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D87163#2373580 , @uabelho wrote:

> Hi!
>
> I found a new problem after this was turned on again in 51ff04567b2f 
> .

I wrote https://bugs.llvm.org/show_bug.cgi?id=48072 about it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D90634: Implement Lambda Conversion Operators for All CCs for MSVC.

2020-11-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 302827.
erichkeane added a comment.

Added test for +lambda as @rsmith requested.


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

https://reviews.llvm.org/D90634

Files:
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp

Index: clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
===
--- clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
+++ clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,LIN64
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-linux-gnu -DCC="__attribute__((vectorcall))" | FileCheck %s --check-prefixes=CHECK,VECCALL
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-windows-pc -DWIN32 | FileCheck %s --check-prefixes=WIN32
+// RUN: %clang_cc1 -emit-llvm %s -o - -fms-compatibility -triple=i386-windows-pc -DWIN32 | FileCheck %s --check-prefixes=WIN32
 
 #ifndef CC
 #define CC
@@ -10,20 +10,36 @@
   auto lambda = [](int i, float f, double d) CC { return i + f + d; };
 
   double (*CC fp)(int, float, double) = lambda;
-  fp(0, 1.1, 2.2);
 #ifdef WIN32
   double (*__attribute__((thiscall)) fp2)(int, float, double) = lambda;
+  double (*__attribute__((stdcall)) fp3)(int, float, double) = lambda;
+  double (*__attribute__((fastcall)) fp4)(int, float, double) = lambda;
+  double (*__attribute__((vectorcall)) fp5)(int, float, double) = lambda;
+#endif // WIN32
+  fp(0, 1.1, 2.2);
+#ifdef WIN32
   fp2(0, 1.1, 2.2);
+  fp3(0, 1.1, 2.2);
+  fp4(0, 1.1, 2.2);
+  fp5(0, 1.1, 2.2);
 #endif // WIN32
+
+  auto x = +lambda;
 }
 
-// void usage function, calls convrsion operator.
+// void usage function, calls conversion operator.
 // LIN64: define void @_Z5usagev()
 // VECCALL: define void @_Z5usagev()
 // WIN32: define dso_local void @"?usage@@YAXXZ"()
 // CHECK: call double (i32, float, double)* @"_ZZ5usagevENK3$_0cvPFdifdEEv"
 // WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6A?A?@@HMN@ZXZ"
 // WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6E?A?@@HMN@ZXZ"
+// WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6G?A?@@HMN@ZXZ"
+// WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6I?A?@@HMN@ZXZ"
+// WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6Q?A?@@HMN@ZXZ"
+// Operator+ calls 'default' calling convention.
+// CHECK: call double (i32, float, double)* @"_ZZ5usagevENK3$_0cvPFdifdEEv"
+// WIN32: call x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6A?A?@@HMN@ZXZ"
 //
 // Conversion operator, returns __invoke.
 // CHECK: define internal double (i32, float, double)* @"_ZZ5usagevENK3$_0cvPFdifdEEv"
@@ -32,6 +48,12 @@
 // WIN32: ret double (i32, float, double)* @"?__invoke@@?0??usage@@YAXXZ@CA?A?@@HMN@Z"
 // WIN32: define internal x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6E?A?@@HMN@ZXZ"
 // WIN32: ret double (i32, float, double)* @"?__invoke@@?0??usage@@YAXXZ@CE?A?@@HMN@Z"
+// WIN32: define internal x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6G?A?@@HMN@ZXZ"
+// WIN32: ret double (i32, float, double)* @"?__invoke@@?0??usage@@YAXXZ@CG?A?@@HMN@Z"
+// WIN32: define internal x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6I?A?@@HMN@ZXZ"
+// WIN32: ret double (i32, float, double)* @"?__invoke@@?0??usage@@YAXXZ@CI?A?@@HMN@Z"
+// WIN32: define internal x86_thiscallcc double (i32, float, double)* @"??B@?0??usage@@YAXXZ@QBEP6Q?A?@@HMN@ZXZ"
+// WIN32: ret double (i32, float, double)* @"?__invoke@@?0??usage@@YAXXZ@CQ?A?@@HMN@Z"
 //
 // __invoke function, calls operator(). Win32 should call both.
 // LIN64: define internal double @"_ZZ5usagevEN3$_08__invokeEifd"
@@ -42,3 +64,9 @@
 // WIN32: call x86_thiscallcc double @"??R@?0??usage@@YAXXZ@QBE?A?@@HMN@Z"
 // WIN32: define internal x86_thiscallcc double @"?__invoke@@?0??usage@@YAXXZ@CE?A?@@HMN@Z"
 // WIN32: call x86_thiscallcc double @"??R@?0??usage@@YAXXZ@QBE?A?@@HMN@Z"
+// WIN32: define internal x86_stdcallcc double @"?__invoke@@?0??usage@@YAXXZ@CG?A?@@HMN@Z"
+// WIN32: call x86_thiscallcc double @"??R@?0??usage@@YAXXZ@QBE?A?@@HMN@Z"
+// WIN32: define internal x86_fastcallcc double @"?__invoke@@?0??usage@@YAXXZ@CI?A?@@HMN@Z"
+// WIN32: call x86_thiscallcc double @"??R@?0??usage@@YAXXZ@QBE?A?@@HMN@Z"
+// WIN32: define internal x86_vectorcallcc double @"?__invoke@@?0??usage@@YAXXZ@CQ?A?@@HMN@Z"
+// WIN32: call x86_thiscallcc double @"??R@?0??usage@@YAXXZ@QBE?A?@@HMN@Z"
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1272,6 +1272,34 @@
   CallOpProto.isVariadic(), /*IsCXXMethod=*/true);
   Calli

[PATCH] D87981: [X86] AMX programming model prototype.

2020-11-04 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

You may still need to change the format according to the Lint suggestions.




Comment at: clang/lib/Headers/amxintrin.h:227
+
+/// This is new intrinsic interface
+typedef int _tile_data __attribute__((__vector_size__(1024), __aligned__(64)));

The comment is useless.



Comment at: clang/lib/Headers/amxintrin.h:243
+_tile_stored_internal(unsigned short m, unsigned short n, void *base,
+  int stride, _tile_data tile) {
+  return __builtin_ia32_tilestored64_internal(m, n, base,

The type is inconsistent with `__tile_stored`



Comment at: clang/lib/Headers/amxintrin.h:255
+__DEFAULT_FN_ATTRS_INT8
+void __tile_loadd(__tile *dst, const void *base, long long stride) {
+  dst->tile = _tile_loadd_internal(dst->row, dst->col, base, stride);

Why not use `size_t`?



Comment at: clang/lib/Headers/amxintrin.h:266
+__DEFAULT_FN_ATTRS_INT8
+void __tile_stored(void *base, long long stride, __tile src) {
+  _tile_stored_internal(src.row, src.col, base, stride, src.tile);

The same here.



Comment at: clang/test/CodeGen/X86/amx_api.c:13
+  //CHECK-LABEL: @test_api
+  //CHECK: call <256 x i32> @llvm.x86.tileloadd64.internal
+  //CHECK: call <256 x i32> @llvm.x86.tdpbssd.internal

Shoud it check for 3 and only 3 `llvm.x86.tileloadd64.internal`?



Comment at: llvm/include/llvm/CodeGen/Passes.h:494
+
+  FunctionPass *createX86LowerAMXTypePass();
 } // End llvm namespace

Comments?



Comment at: llvm/include/llvm/CodeGen/TileShapeInfo.h:47
+  return true;
+if ((RowImm != InvalidImmShape) && (Shape.getRowImm() != InvalidImmShape) 
&&
+(ColImm != InvalidImmShape) && (Shape.getColImm() != InvalidImmShape)) 
{

You just need to check
`RowImm != InvalidImmShape && ColImm != InvalidImmShape`



Comment at: llvm/lib/Target/X86/X86TileConfig.cpp:117
+   FrameIdx, Offset)
+  .addImm(Imm);
+}

The format looks strange, I wonder why Lint didn't report it.



Comment at: llvm/test/CodeGen/X86/ipra-reg-usage.ll:6
 define preserve_allcc void @foo()#0 {
-; CHECK: foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $fpcw 
$fpsw $fs $gs $hip $ip $mxcsr $rip $riz $ss $ssp $bnd0 $bnd1 $bnd2 $bnd3 $cr0 
$cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 $cr14 
$cr15 $dr0 $dr1 $dr2 $dr3 $dr4 $dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 $dr13 
$dr14 $dr15 $fp0 $fp1 $fp2 $fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 $k5 $k6 
$k7 $mm0 $mm1 $mm2 $mm3 $mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 $st4 $st5 
$st6 $st7 $tmm0 $tmm1 $tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 $xmm17 $xmm18 
$xmm19 $xmm20 $xmm21 $xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 $xmm28 $xmm29 
$xmm30 $xmm31 $ymm0 $ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 $ymm8 $ymm9 
$ymm10 $ymm11 $ymm12 $ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 $ymm19 $ymm20 
$ymm21 $ymm22 $ymm23 $ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 $ymm30 $ymm31 
$zmm0 $zmm1 $zmm2 $zmm3 $zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 $zmm10 $zmm11 
$zmm12 $zmm13 $zmm14 $zmm15 $zmm16 $zmm17 $zmm18 $zmm19 $zmm20 $zmm21 $zmm22 
$zmm23 $zmm24 $zmm25 $zmm26 $zmm27 $zmm28 $zmm29 $zmm30 $zmm31 $r11b $r11bh 
$r11d $r11w $r11wh
+; CHECK: foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $fpcw 
$fpsw $fs $gs $hip $ip $mxcsr $rip $riz $ss $ssp $tmmcfg $bnd0 $bnd1 $bnd2 
$bnd3 $cr0 $cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 
$cr14 $cr15 $dr0 $dr1 $dr2 $dr3 $dr4 $dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 
$dr13 $dr14 $dr15 $fp0 $fp1 $fp2 $fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 
$k5 $k6 $k7 $mm0 $mm1 $mm2 $mm3 $mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 
$st4 $st5 $st6 $st7 $tmm0 $tmm1 $tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 
$xmm17 $xmm18 $xmm19 $xmm20 $xmm21 $xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 
$xmm28 $xmm29 $xmm30 $xmm31 $ymm0 $ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 
$ymm8 $ymm9 $ymm10 $ymm11 $ymm12 $ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 
$ymm19 $ymm20 $ymm21 $ymm22 $ymm23 $ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 
$ymm30 $ymm31 $zmm0 $zmm1 $zmm2 $zmm3 $zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 
$zmm10 $zmm11 $zmm12 $zmm13 $zmm14 $zmm15 $zmm16 $zmm17 $zmm18 $zmm19 $zmm20 
$zmm21 $zmm22 $zmm23 $zmm24 $zmm25 $zmm26 $zmm27 $zmm28 $zmm29 $zmm30 $zmm31 
$r11b $r11bh $r11d $r11w $r11wh $k0_k1 $k2_k3 $k4_k5 $k6_k7
   call void @bar1()

LuoYuanke wrote:
> LuoYuanke wrote:
> > pengfei wrote:
> > > Why this patch affects the k registers?
> > This looks wired to me too.  The patch only add "tmmcfg". I'll look into it 
> > later.
> I check the test case without my patch the k pair registers are clobbered. 
> But FileCheck only match the strings, so the test passes. I can also remove 
> "$k0_k1 $k2_k3 $k4_k5 $k6_k7" f

[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:3801
+/// error.
+class UnresolvedUsingIfExistsDecl final : public NamedDecl {
+  UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc,

erik.pilkington wrote:
> aaron.ballman wrote:
> > Why is this inheriting from a `NamedDecl` rather than a `UsingDecl`? Given 
> > that this is a type of using declaration, I guess I would have expected it 
> > to appear as such in the AST hierarchy. For instance, should people using 
> > AST matchers be able to match one of these as a using declaration or are 
> > they so different semantically that they need to be sibling AST nodes?
> This node isn't a kind of using declaration, it is a declaration that gets 
> inserted into the scope via a usual UsingDecl & UsingShadowDecl mechanism 
> that Sema knows to error out on if it is ever used. So presumably existing 
> AST users would still recognize that this is a UsingDecl that adds a single 
> declaration into the current context, but wouldn't really know anything about 
> that declaration. I updated the doc comment above to make that more clear.
So given code like this:
```
using empty_namespace::does_not_exist __attribute__((using_if_exists)); 
```
would you expect this AST matcher to match or not?
```
usingDecl()
```
(I hope the answer is "yes" because otherwise the behavior is rather 
inexplicable to me.)



Comment at: clang/include/clang/Basic/AttrDocs.td:5273
+  namespace empty_namespace {};
+  using empty_namespace::does_not_exist __attribute__((using_if_exists)); // 
no error!
+

erik.pilkington wrote:
> Mordante wrote:
> > Mordante wrote:
> > > Can you add an example using `[[clang::using_if_exists]]` or use that 
> > > instead of this attribute?
> > Why is the attribute placed here? I would expect the attribute before the 
> > declaration `[[clang::using_if_exists]] using 
> > empty_namespace::does_not_exist;`
> The attribute is written like that because clang rejects C++ style attributes 
> on using declarations, and only accepts attributes in that position. I think 
> this is the first attribute we actually support on using-declarations, so 
> maybe we should consider supporting it.
> I think this is the first attribute we actually support on 
> using-declarations, so maybe we should consider supporting it.

This isn't the first attribute we *should* be supporting on using declarations. 
Any attribute that appertains to a `NamedDecl` should apply as should the 
annotate attribute.

However:
```
[[clang::whatever]] using foo::bar; // Correct to reject, #1
using foo::bar [[clang::whatever]]; // Correct to reject, #2
```
#1 is rejected because it's a declaration-statement and those cannot have a 
leading attribute-specifier-seq (http://eel.is/c++draft/stmt.stmt#stmt.pre-1). 
#2 is rejected because the using-declaration cannot have a trailing 
attribute-specifier-seq 
(http://eel.is/c++draft/namespace.udecl#nt:using-declaration).

This seems like a case where we may want to explore an extension to C++ that we 
propose to WG21.



Comment at: clang/lib/Sema/SemaDecl.cpp:1177
 
+  if (auto *EmptyD = dyn_cast(FirstDecl)) {
+Diag(NameLoc, diag::err_use_of_empty_using_if_exists);

erik.pilkington wrote:
> aaron.ballman wrote:
> > `const auto *`
> This would lead to a bit of a `const`-goosechase in DiagnoseUseOfDecl. I 
> thought we generally weren't too interested in `const` on AST nodes since 
> they're assumed to be immutable anyways, so it doesn't really show much 
> intent.
Ah, then don't bother with the goose chase. We don't require `const` 
correctness because of these kinds of goose chases, but we usually strive for 
`const` correctness when it's cheap to do so.


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

https://reviews.llvm.org/D90188

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


[clang] 7e2edf9 - [compiler-rt][AIX]: Link compiler-rt profile library when -fprofile-generate is specified

2020-11-04 Thread via cfe-commits

Author: etiotto
Date: 2020-11-04T09:54:54-05:00
New Revision: 7e2edf973b64b3554404e527f506ad5bc44d9cba

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

LOG: [compiler-rt][AIX]: Link compiler-rt profile library when 
-fprofile-generate is specified

This patch enhances the clang driver to link the runtime profile
library on AIX when the -fprofile-generate option is used.

Reviewed By: phosek

Differentail Revision: https://reviews.llvm.org/D90641

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index b833ebaebf92..47ce99a7c625 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -151,6 +151,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+  ToolChain.addProfileRTLibs(Args, CmdArgs);
 
   if (getToolChain().ShouldLinkCXXStdlib(Args))
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);



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


[PATCH] D90763: Traverse-ignore explicit template instantiations

2020-11-04 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
steveire requested review of this revision.

Continue to dump and match on explicit template specializations, but
omit explicit instantiation declarations and definitions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90763

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2214,6 +2214,23 @@
   (void)timesTwo(2);
 }
 
+template class TemplStruct;
+
+extern template class TemplStruct;
+
+template<> class TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+  void boolSpecializationMethodOnly() {}
+private:
+  bool m_t;
+};
+
+template float timesTwo(float);
+template<> bool timesTwo(bool){
+  return true;
+}
 )cpp";
   {
 auto M = cxxRecordDecl(hasName("TemplStruct"),
@@ -2241,6 +2258,57 @@
 EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
 EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
+  {
+auto M =
+functionDecl(hasName("timesTwo"),
+ hasParameter(0, parmVarDecl(hasType(asString("float");
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = functionDecl(hasName("timesTwo"),
+  hasParameter(0, parmVarDecl(hasType(booleanType();
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = classTemplateSpecializationDecl(
+hasName("TemplStruct"),
+hasTemplateArgument(0,
+templateArgument(refersToType(asString("float");
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+// The template argument is matchable, but the instantiation is not:
+auto M = classTemplateSpecializationDecl(
+hasName("TemplStruct"),
+hasTemplateArgument(0,
+templateArgument(refersToType(asString("float",
+has(cxxConstructorDecl(hasName("TemplStruct";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+// The template argument is matchable, but the instantiation is not:
+auto M = classTemplateSpecializationDecl(
+hasName("TemplStruct"),
+hasTemplateArgument(0,
+templateArgument(refersToType(asString("long",
+has(cxxConstructorDecl(hasName("TemplStruct";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+// Explicit specialization is written in source and it matches
+auto M = classTemplateSpecializationDecl(
+hasName("TemplStruct"),
+hasTemplateArgument(0, templateArgument(refersToType(booleanType(,
+has(cxxConstructorDecl(hasName("TemplStruct"))),
+has(cxxMethodDecl(hasName("boolSpecializationMethodOnly";
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
 }
 
 template 
@@ -3249,10 +3317,9 @@
   EXPECT_TRUE(matches(
 code,
 cxxThrowExpr(hasDescendant(integerLiteral();
-  EXPECT_TRUE(notMatches(code, 
-cxxThrowExpr(allOf(
-  hasDescendant(integerLiteral()),
-  has(integerLiteral());
+  EXPECT_TRUE(
+  notMatches(code, cxxThrowExpr(allOf(hasDescendant(integerLiteral()),
+  has(integerLiteral());
 }
 TEST(HasAncestor, MatchesAllAncestors) {
   EXPECT_TRUE(matches(
Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -1075,6 +1075,26 @@
   (void)timesTwo(2);
   (void)timesTwo(2);
 }
+
+template class TemplStruct;
+
+extern template class TemplStruct;
+
+template<> class TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+  void foo() {}
+private:
+  bool m_t;
+};
+
+// Explicit instantiation of template functions do not appear in the AST
+template float timesTwo(float);
+
+template<> bool timesTwo(bool) {
+  return true;
+}
 )cpp");
   {
 auto

[clang-tools-extra] 45e0f65 - Add a floating-point suffix to silence warnings; NFC

2020-11-04 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-11-04T10:09:51-05:00
New Revision: 45e0f651623d5507a0ea85533c960956573533d7

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

LOG: Add a floating-point suffix to silence warnings; NFC

This silences about 6000 warnings about truncating from double to float
with Visual Studio.

Added: 


Modified: 
clang-tools-extra/clangd/quality/CompletionModelCodegen.py

Removed: 




diff  --git a/clang-tools-extra/clangd/quality/CompletionModelCodegen.py 
b/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
index a1f0cb78037a..f27e8f6a28a3 100644
--- a/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
+++ b/clang-tools-extra/clangd/quality/CompletionModelCodegen.py
@@ -40,7 +40,7 @@ def header_guard(filename):
 
 def boost_node(n, label, next_label):
 """Returns code snippet for a leaf/boost node."""
-return "%s: return %s;" % (label, n['score'])
+return "%s: return %sf;" % (label, n['score'])
 
 
 def if_greater_node(n, label, next_label):



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


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2958-2970
+auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+if (PerDevice != OffloadEntriesTargetRegion.end()) {
+  auto PerFile = PerDevice->second.find(FileID);
+  if (PerFile != PerDevice->second.end()) {
+auto PerParentName = PerFile->second.find(ParentName);
+if (PerParentName != PerFile->second.end()) {
+  auto PerLine = PerParentName->second.find(LineNum);

Just:
```
if (hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
  return;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90570: [mips] Add a -mmips3d command line option to clang

2020-11-04 Thread Michael Roe via Phabricator via cfe-commits
michael-roe added a comment.

Thanks!

I agree with those changes; I'll implement them and then resubmit a patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90570

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


[PATCH] D90765: [ARM][AArch64] Adding Neoverse V1 CPU support

2020-11-04 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
pratlucas requested review of this revision.

Add support for the Neoverse V1 CPU to the ARM and AArch64 backends.

This is based on patches from Mark Murray and Victor Campos.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90765

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/MC/SubtargetFeature.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -274,6 +274,12 @@
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
  ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
+ ARM::AEK_DOTPROD,
+ "8.4-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -322,7 +328,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 89;
+static constexpr unsigned NumARMCPUArchs = 90;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -881,6 +887,14 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS,
   "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "neoverse-v1", "armv8.4-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
+  AArch64::AEK_RCPC | AArch64::AEK_CRC | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_CRYPTO,
+  "8.4-A"));
   EXPECT_TRUE(testAArch64CPU(
  "cortex-r82", "armv8-r", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
@@ -1034,7 +1048,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 43;
+static constexpr unsigned NumAArch64CPUArchs = 44;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -20,6 +20,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-x1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-e1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n1 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-v1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m3 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m4 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m5 2>&1 | FileCheck %s
Index: llvm/lib/Target/ARM/ARMSubtarget.h
===
--- llvm/lib/Target/ARM/ARMSubtarget.h
+++ llvm/lib/Target/ARM/ARMSubtarget.h
@@ -76,7 +76,8 @@
 Krait,
 Kryo,
 NeoverseN1,
-Swift
+Swift,
+NeoverseV1,
   };
   enum ARMProcClassEnum {
 None,
Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -321,6 +321,8 @@
 PreISelOperandLatencyAdjustment = 1;
 PartialUpdateClearance = 12;
 break;
+  case NeoverseV1:
+break;
   }
 }
 
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -601,6 +601,9 @@
 def ProcX1  : SubtargetFeature<"cortex-x1", "ARMProcFamily", "CortexX1",
"Cortex-X1 ARM processors", []>;
 
+def ProcNeoverseV1 : SubtargetFeature<"neoverse-v1", "ARMProcFamily",
+ 

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-11-04 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:130
 m(ObjcIvar) \
+m(HungarianNotation) \
 

njames93 wrote:
> Is this line needed?
I will remove it. Thank you.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:241
+  // Options
+  const static llvm::StringMap Options = {
+  {"TreatStructAsClass", "false"}};

njames93 wrote:
> As you never use map like access for this, shouldn't it be an array.
> The same goes for all the other StringMaps in this function
Thank you. I will change it.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:368
+
+  std::vector HNOpts = {"TreatStructAsClass"};
+  for (auto const &Opt : HNOpts) {

njames93 wrote:
> However for this I can see that its mapping the same options as `Options` in 
> `getHungarianNotationDefaultConfig()`.
> Maybe `HNOpts` should be removed from here, `Option` from 
> `getHungarianNotationDefaultConfig()` taken out of function scope and iterate 
> over that array below. 
> 
> A similar approach could be made with HNDerviedTypes
I will move `HNOpts` and `HNDerviedTypes` outward to the top of the 
`getHungarianNotationDefaultConfig()` function. If the arrays are defined as 
static, is there any difference btw inside or outside of function, or did I 
misunderstand your meaning?  



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:369-370
+  std::vector HNOpts = {"TreatStructAsClass"};
+  for (auto const &Opt : HNOpts) {
+std::string Key = Section + "General." + Opt;
+std::string Val = Options.get(Key, "");

njames93 wrote:
> Building these temporary strings is expensive. Better off having a 
> SmallString contsructed outside the loop and fill the string for each 
> iteration, saved on allocations.
> The same buffer can be reused below for the other loops
Good idea, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[clang-tools-extra] d1b2a52 - [clang-tidy] Add signal-handler-check for SEI CERT rule SIG30-C

2020-11-04 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-11-04T16:42:30+01:00
New Revision: d1b2a523191e22806aee381d54015b94b9dcad7a

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

LOG: [clang-tidy] Add signal-handler-check for SEI CERT rule SIG30-C

SIG30-C. Call only asynchronous-safe functions within signal handlers

First version of this check, only minimal list of functions is allowed
("strictly conforming" case), for C only.

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

Added: 
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-handler.rst
clang-tools-extra/docs/clang-tidy/checks/cert-sig30-c.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 1556a2924f59..7f4d40f97011 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -40,6 +40,7 @@
 #include "PosixReturnCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
+#include "SignalHandlerCheck.h"
 #include "SignedCharMisuseCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
@@ -133,6 +134,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-posix-return");
 CheckFactories.registerCheck(
 "bugprone-reserved-identifier");
+
CheckFactories.registerCheck("bugprone-signal-handler");
 CheckFactories.registerCheck(
 "bugprone-signed-char-misuse");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 169e0529d872..b3684a5c101b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModule
   PosixReturnCheck.cpp
   RedundantBranchConditionCheck.cpp
   ReservedIdentifierCheck.cpp
+  SignalHandlerCheck.cpp
   SignedCharMisuseCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
new file mode 100644
index ..81d5fbb1565b
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -0,0 +1,186 @@
+//===--- SignalHandlerCheck.cpp - clang-tidy 
--===//
+//
+// 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
+//
+//===--===//
+
+#include "SignalHandlerCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CallGraph.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include 
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+static bool isSystemCall(const FunctionDecl *FD) {
+  // Find a possible redeclaration in system header.
+  // FIXME: Looking at the canonical declaration is not the most exact way
+  // to do this.
+
+  // Most common case will be inclusion directly from a header.
+  // This works fine by using canonical declaration.
+  // a.c
+  // #include 
+
+  // Next most common case will be extern declaration.
+  // Can't catch this with either approach.
+  // b.c
+  // extern void sysfunc(void);
+
+  // Canonical declaration is the first found declaration, so this works.
+  // c.c
+  // #include 
+  // extern void sysfunc(void); // redecl won't matter
+
+  // This does not work with canonical declaration.
+  // Probably this is not a frequently used case but may happen (the first
+  // declaration can be in a non-system header for example).
+  // d.c
+  // extern void sysfunc(void); // Canonical declaration, not in system header.

[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-11-04 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1b2a523191e: [clang-tidy] Add signal-handler-check for SEI 
CERT rule SIG30-C (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D87449?vs=302778&id=302841#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-handler.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-sig30-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s cert-sig30-c %t -- -- -isystem %S/Inputs/Headers
+
+#include "signal.h"
+#include "stdio.h"
+#include "stdlib.h"
+
+// The function should be classified as system call even if there is
+// declaration the in source file.
+// FIXME: The detection works only if the first declaration is in system
+// header.
+int printf(const char *, ...);
+typedef void (*sighandler_t)(int);
+sighandler_t signal(int signum, sighandler_t handler);
+
+void handler_abort(int) {
+  abort();
+}
+
+void handler__Exit(int) {
+  _Exit(0);
+}
+
+void handler_quick_exit(int) {
+  quick_exit(0);
+}
+
+void handler_other(int) {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void handler_signal(int) {
+  // FIXME: It is only OK to call signal with the current signal number.
+  signal(0, SIG_DFL);
+}
+
+void f_ok() {
+  abort();
+}
+
+void f_bad() {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void f_extern();
+
+void handler_ok(int) {
+  f_ok();
+}
+
+void handler_bad(int) {
+  f_bad();
+}
+
+void handler_extern(int) {
+  f_extern();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+}
+
+void test() {
+  signal(SIGINT, handler_abort);
+  signal(SIGINT, handler__Exit);
+  signal(SIGINT, handler_quick_exit);
+  signal(SIGINT, handler_signal);
+  signal(SIGINT, handler_other);
+
+  signal(SIGINT, handler_ok);
+  signal(SIGINT, handler_bad);
+  signal(SIGINT, handler_extern);
+
+  signal(SIGINT, quick_exit);
+  signal(SIGINT, other_call);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c]
+
+  signal(SIGINT, SIG_IGN);
+  signal(SIGINT, SIG_DFL);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
@@ -0,0 +1,18 @@
+//===--- stdlib.h - Stub header for tests ---*- 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
+//
+//===--===//
+
+#ifndef _STDLIB_H_
+#define _STDLIB_H_
+
+void abort(void);
+void _Exit(int);
+void quick_exit(int);
+
+void other_call(int);
+
+#endif // _STDLIB_H_
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
@@ -0,0 +1,22 @@
+//===--- signal.h - Stub header for tests ---*- 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
+//
+//===--===//
+
+#ifndef _SIGNAL_H_
+#define _SIGNAL_H_
+
+void _sig_ign(int);
+void _sig_dfl(int);
+
+#define SIGINT 1
+#define SIG_IGN _sig_ign
+#define SIG_DFL _sig_dfl
+
+ty

[PATCH] D90409: [HIP] Math Headers to use type promotion

2020-11-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D90409#2372183 , @tra wrote:

> In D90409#2372042 , @yaxunl wrote:
>
>>> Practically the behavior is the same since they all promote integer types 
>>> to double. This matches the C++ behavior. However the HIP change will make 
>>> it conform to C++ for a target supporting long double whereas the previous 
>>> header did not.
>>
>> Sorry I mean the change can make the header extendable to `long double` 
>> easily although it does not yet. Another thing is that it allows resolution 
>> of mixed argument types with _Float16.
>
> OK. This makes more sense now. Thank you for the explanation.
>
> While this does solve one particular instance of the issue, we can't jsut 
> copy/paste bits of the standard library forever. We need something more 
> robust.
> NVIDIA now has their own fork of the standard library 
> https://github.com/NVIDIA/libcudacxx and that may be a good starting point.
> I think at some point we (HIP & CUDA owners) need to talk to libc++ 
> maintainers and see if we can find a better way to extend the standard 
> library to CUDA/HIP.

Agree. A seamless native libc++ support for CUDA/HIP is very attractive. Even 
if just partial support. At least math functions to start with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90409

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-04 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:939
+def warn_pragma_attribute_scalable_unused : Warning<
+  "ignoring scalable vectorize_width flag due to lack of target support">,
+  InGroup;

From what I can see, the vectorize_width flag is not ignored, only the scalable 
property is. That means this should be:
  'scalable' not supported by the target so assuming 'fixed' instead.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:148
+  if (StateLoc && StateLoc->Ident && StateLoc->Ident->isStr("scalable")) {
+if (!S.Context.getTargetInfo().supportsScalableVectors()) {
+  S.Diag(St->getBeginLoc(), 
diag::warn_pragma_attribute_scalable_unused);

If the target does not support scalable vectors, it currently assumes 
`"fixed"`. If we want to stick with that approach, the diagnostic message 
should be changed (see my other comment). The alternative is dropping the hint 
entirely by returning `nullptr` and changing the diagnostic message to say the 
hint is ignored. I could live with both options. @fhahn do you have a 
preference here?

nit: to reduce nesting, can you hoist this out one level, e.g.
  if (StateLoc && StateLoc->Ident & ...)
State = LoopHintAttr::ScalableNumeric;
  else
State = LoopHintAttr::Numeric;

  if (State == LoopHintAttr::ScalableNumeric &&
  !S.Context.getTargetInfo().supportsScalableVectors()) {
S.Diag();
State = LoopHintAttr::Numeric;
  }


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

https://reviews.llvm.org/D89031

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


[PATCH] D90766: [OpenCL] Support vec_step in C++ for OpenCL mode

2020-11-04 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: dexonsmith, yaxunl.
svenvh requested review of this revision.

For compatibility with OpenCL C, enable the `vec_step` builtin in C++ for 
OpenCL mode.


https://reviews.llvm.org/D90766

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/test/CodeGenOpenCLCXX/constexpr.cl


Index: clang/test/CodeGenOpenCLCXX/constexpr.cl
===
--- clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -52,3 +52,13 @@
 kernel void vecEval2(global int2 *x) {
   *x = fromConstexprFunc;
 }
+
+// Test evaluation of vec_step
+// CHECK-LABEL: define spir_kernel void @vec_step_test
+// CHECK: store i32 6
+constexpr int vsize1 = vec_step(fromConstexprFunc);
+constexpr int vsize2 = vec_step(int4);
+
+kernel void vec_step_test(global int *x) {
+  *x = vsize1 + vsize2;
+}
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -586,7 +586,7 @@
 ALIAS("read_write", __read_write, KEYOPENCLC | KEYOPENCLCXX)
 // OpenCL builtins
 KEYWORD(__builtin_astype, KEYOPENCLC | KEYOPENCLCXX)
-UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYALTIVEC | 
KEYZVECTOR)
+UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYOPENCLCXX | 
KEYALTIVEC | KEYZVECTOR)
 #define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | 
KEYOPENCLCXX)
 #include "clang/Basic/OpenCLImageTypes.def"
 KEYWORD(pipe, KEYOPENCLC | KEYOPENCLCXX)


Index: clang/test/CodeGenOpenCLCXX/constexpr.cl
===
--- clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -52,3 +52,13 @@
 kernel void vecEval2(global int2 *x) {
   *x = fromConstexprFunc;
 }
+
+// Test evaluation of vec_step
+// CHECK-LABEL: define spir_kernel void @vec_step_test
+// CHECK: store i32 6
+constexpr int vsize1 = vec_step(fromConstexprFunc);
+constexpr int vsize2 = vec_step(int4);
+
+kernel void vec_step_test(global int *x) {
+  *x = vsize1 + vsize2;
+}
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -586,7 +586,7 @@
 ALIAS("read_write", __read_write, KEYOPENCLC | KEYOPENCLCXX)
 // OpenCL builtins
 KEYWORD(__builtin_astype, KEYOPENCLC | KEYOPENCLCXX)
-UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYALTIVEC | KEYZVECTOR)
+UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYOPENCLCXX | KEYALTIVEC | KEYZVECTOR)
 #define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | KEYOPENCLCXX)
 #include "clang/Basic/OpenCLImageTypes.def"
 KEYWORD(pipe, KEYOPENCLC | KEYOPENCLCXX)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2958-2970
+auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+if (PerDevice != OffloadEntriesTargetRegion.end()) {
+  auto PerFile = PerDevice->second.find(FileID);
+  if (PerFile != PerDevice->second.end()) {
+auto PerParentName = PerFile->second.find(ParentName);
+if (PerParentName != PerFile->second.end()) {
+  auto PerLine = PerParentName->second.find(LineNum);

ABataev wrote:
> Just:
> ```
> if (hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
>   return;
> ```
Actually, even better to do something like this:
```
if (Flags == OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion && 
hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
  return;
assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) && 
"Target region entry already registered!");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90766: [OpenCL] Support vec_step in C++ for OpenCL mode

2020-11-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Good spot!


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

https://reviews.llvm.org/D90766

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


[clang-tools-extra] ed424b4 - [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-04T16:58:11+01:00
New Revision: ed424b42880e256f579d4bc9fb13d2156d8e8eb4

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

LOG: [clangd] Cleanup dependencies around RemoteIndex

RemoteIndexClient implementations only depends on clangdSupport for
logging functionality and has no dependence on clangDeamon itself. This clears
out that link time dependency and enables depending on it in clangDeamon itself,
so that we can have other index implementations that makes use of the
RemoteIndex.

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

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
clang-tools-extra/clangd/tool/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 9d2ab5be222a..0ea925b033ea 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -28,7 +28,7 @@ set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Option
   )
-  
+
 include(${CMAKE_CURRENT_SOURCE_DIR}/quality/CompletionModel.cmake)
 gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel 
clang::clangd::Example)
 
@@ -111,12 +111,6 @@ add_clang_library(clangDaemon
   refactor/Rename.cpp
   refactor/Tweak.cpp
 
-  LINK_LIBS
-  clangdSupport
-  clangTidy
-  ${LLVM_PTHREAD_LIB}
-  ${ALL_CLANG_TIDY_CHECKS}
-
   DEPENDS
   omp_gen
   )
@@ -145,6 +139,17 @@ clang_target_link_libraries(clangDaemon
   clangToolingSyntax
   )
 
+target_link_libraries(clangDaemon
+  PRIVATE
+  ${LLVM_PTHREAD_LIB}
+
+  clangTidy
+  ${ALL_CLANG_TIDY_CHECKS}
+
+  clangdSupport
+  clangdRemoteIndex
+  )
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.

diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index a07dd994b5a3..8625fa8f351e 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,10 +18,8 @@ if (CLANGD_ENABLE_REMOTE)
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-
 protobuf
 grpc++
-clangDaemon
 clangdSupport
 
 DEPENDS

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index ef5c6ce430f6..4980a4bee74e 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -11,7 +11,6 @@
 #include "Client.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
-#include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"

diff  --git 
a/clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
index 5d223ad3c8b3..5729017813d5 100644
--- a/clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
@@ -6,6 +6,5 @@ add_clang_library(clangdRemoteIndex
   UnimplementedClient.cpp
 
   LINK_LIBS
-  clangDaemon
   clangdSupport
   )

diff  --git a/clang-tools-extra/clangd/tool/CMakeLists.txt 
b/clang-tools-extra/clangd/tool/CMakeLists.txt
index 65e0aa35f265..da9d2060f700 100644
--- a/clang-tools-extra/clangd/tool/CMakeLists.txt
+++ b/clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -28,12 +28,14 @@ clang_target_link_libraries(clangd
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
-  clangdRemoteIndex
   )
+
 target_link_libraries(clangd
   PRIVATE
   clangTidy
+
   clangDaemon
+  clangdRemoteIndex
   clangdSupport
   ${CLANGD_XPC_LIBS}
   )



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


[PATCH] D90746: [clangd] Cleanup dependencies around RemoteIndex

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed424b42880e: [clangd] Cleanup dependencies around 
RemoteIndex (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90746

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
  clang-tools-extra/clangd/tool/CMakeLists.txt

Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -28,12 +28,14 @@
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
-  clangdRemoteIndex
   )
+
 target_link_libraries(clangd
   PRIVATE
   clangTidy
+
   clangDaemon
+  clangdRemoteIndex
   clangdSupport
   ${CLANGD_XPC_LIBS}
   )
Index: clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/unimplemented/CMakeLists.txt
@@ -6,6 +6,5 @@
   UnimplementedClient.cpp
 
   LINK_LIBS
-  clangDaemon
   clangdSupport
   )
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -11,7 +11,6 @@
 #include "Client.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
-#include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,10 +18,8 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-
 protobuf
 grpc++
-clangDaemon
 clangdSupport
 
 DEPENDS
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -28,7 +28,7 @@
   FrontendOpenMP
   Option
   )
-  
+
 include(${CMAKE_CURRENT_SOURCE_DIR}/quality/CompletionModel.cmake)
 gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/quality/model CompletionModel clang::clangd::Example)
 
@@ -111,12 +111,6 @@
   refactor/Rename.cpp
   refactor/Tweak.cpp
 
-  LINK_LIBS
-  clangdSupport
-  clangTidy
-  ${LLVM_PTHREAD_LIB}
-  ${ALL_CLANG_TIDY_CHECKS}
-
   DEPENDS
   omp_gen
   )
@@ -145,6 +139,17 @@
   clangToolingSyntax
   )
 
+target_link_libraries(clangDaemon
+  PRIVATE
+  ${LLVM_PTHREAD_LIB}
+
+  clangTidy
+  ${ALL_CLANG_TIDY_CHECKS}
+
+  clangdSupport
+  clangdRemoteIndex
+  )
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-04 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington marked 3 inline comments as done.
erik.pilkington added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:3801
+/// error.
+class UnresolvedUsingIfExistsDecl final : public NamedDecl {
+  UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc,

aaron.ballman wrote:
> erik.pilkington wrote:
> > aaron.ballman wrote:
> > > Why is this inheriting from a `NamedDecl` rather than a `UsingDecl`? 
> > > Given that this is a type of using declaration, I guess I would have 
> > > expected it to appear as such in the AST hierarchy. For instance, should 
> > > people using AST matchers be able to match one of these as a using 
> > > declaration or are they so different semantically that they need to be 
> > > sibling AST nodes?
> > This node isn't a kind of using declaration, it is a declaration that gets 
> > inserted into the scope via a usual UsingDecl & UsingShadowDecl mechanism 
> > that Sema knows to error out on if it is ever used. So presumably existing 
> > AST users would still recognize that this is a UsingDecl that adds a single 
> > declaration into the current context, but wouldn't really know anything 
> > about that declaration. I updated the doc comment above to make that more 
> > clear.
> So given code like this:
> ```
> using empty_namespace::does_not_exist __attribute__((using_if_exists)); 
> ```
> would you expect this AST matcher to match or not?
> ```
> usingDecl()
> ```
> (I hope the answer is "yes" because otherwise the behavior is rather 
> inexplicable to me.)
Yeah, the answer is "yes". The AST representation for a using_if_exists 
declaration that failed to lookup anything would look something like this:

```
|-UsingDecl 0x7fa42b84a3a0  col:9 ::X
|-UsingShadowDecl 0x7fa42b84a3f8  col:9 implicit UnresolvedUsingIfExists 
0x7fa42b84a370 'X'
```

So its still using the typical UsingDecl machinery, its just that the 
declaration thats being imported is different.



Comment at: clang/include/clang/Basic/AttrDocs.td:5273
+  namespace empty_namespace {};
+  using empty_namespace::does_not_exist __attribute__((using_if_exists)); // 
no error!
+

aaron.ballman wrote:
> erik.pilkington wrote:
> > Mordante wrote:
> > > Mordante wrote:
> > > > Can you add an example using `[[clang::using_if_exists]]` or use that 
> > > > instead of this attribute?
> > > Why is the attribute placed here? I would expect the attribute before the 
> > > declaration `[[clang::using_if_exists]] using 
> > > empty_namespace::does_not_exist;`
> > The attribute is written like that because clang rejects C++ style 
> > attributes on using declarations, and only accepts attributes in that 
> > position. I think this is the first attribute we actually support on 
> > using-declarations, so maybe we should consider supporting it.
> > I think this is the first attribute we actually support on 
> > using-declarations, so maybe we should consider supporting it.
> 
> This isn't the first attribute we *should* be supporting on using 
> declarations. Any attribute that appertains to a `NamedDecl` should apply as 
> should the annotate attribute.
> 
> However:
> ```
> [[clang::whatever]] using foo::bar; // Correct to reject, #1
> using foo::bar [[clang::whatever]]; // Correct to reject, #2
> ```
> #1 is rejected because it's a declaration-statement and those cannot have a 
> leading attribute-specifier-seq 
> (http://eel.is/c++draft/stmt.stmt#stmt.pre-1). #2 is rejected because the 
> using-declaration cannot have a trailing attribute-specifier-seq 
> (http://eel.is/c++draft/namespace.udecl#nt:using-declaration).
> 
> This seems like a case where we may want to explore an extension to C++ that 
> we propose to WG21.
> This isn't the first attribute we *should* be supporting on using 
> declarations. Any attribute that appertains to a NamedDecl should apply as 
> should the annotate attribute.

Yeah, agreed. Its just that Sema was failing to call ProcessDeclAttributeList 
for UsingDecls, so no attributes were actually getting applied in practice.

Okay, if our policy is to only parse C++-style attributes in places that the 
C++ grammar allows them then I agree that this would be an issue for the 
standards committee. 


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

https://reviews.llvm.org/D90188

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


[PATCH] D90767: Add new matchers for dependent names in templates

2020-11-04 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
steveire requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90767

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -17,7 +17,6 @@
 
 namespace clang {
 namespace ast_matchers {
-
 TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesInFile) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
@@ -1629,6 +1628,80 @@
  Constructor1Arg));
 }
 
+TEST(ASTMatchersTest, NamesMember_CXXDependentScopeMemberExpr) {
+
+  // Member functions:
+  {
+auto Code = "template  struct S{ void mem(); }; template "
+" void x() { S s; s.mem(); }";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(cxxMethodDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+  }
+
+  // Member variables:
+  {
+auto Code = "template  struct S{ int mem; }; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(fieldDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+  }
+
+  // static member variables:
+  {
+auto Code = "template  struct S{ static int mem; }; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(varDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+  }
+
+  // other named decl:
+  {
+auto Code = "template  struct S{ static int mem; }; struct "
+"mem{}; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(matches(
+Code,
+translationUnitDecl(has(cxxRecordDecl(hasName("mem"))),
+hasDescendant(cxxDependentScopeMemberExpr();
+
+EXPECT_FALSE(matches(
+Code,
+translationUnitDecl(has(cxxRecordDecl(hasName("mem")).bind("templMem")),
+hasDescendant(cxxDependentScopeMemberExpr(
+memberHasSameNameAsBoundNode("templMem"));
+  }
+}
+
+TEST(ASTMatchersTest, NamesMember_UnresolvedMemberExpr) {}
+
 TEST(ASTMatchersTest, ArgumentCountIs_CXXUnresolvedConstructExpr) {
   const auto *Code =
   "template  struct S{}; template  void "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -302,6 +302,7 @@
   REGISTER_MATCHER(hasLocalStorage);
   REGISTER_MATCHER(hasLoopInit);
   REGISTER_MATCHER(hasLoopVariable);
+  REGISTER_MATCHER(hasMemberName);
   REGISTER_MATCHER(hasMethod);
   REGISTER_MATCHER(hasName);
   REGISTER_MATCHER(hasNullSelector);
@@ -443,6 +444,7 @@
   REGISTER_MATCHER(materializeTemporaryExpr);
   REGISTER_MATCHER(member);
   REGISTER_MATCHER(memberExpr);
+  REGISTER_MATCHER(memberHasSameNameAsBoundNode);
   REGISTER_MATCHER(memberPointerType);
   REGISTER_MATCHER(namedDecl);
   REGISTER_MATCHER(namesType);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2835,6 +2835,82 @@
 StringRef, internal::hasAnyOverloadedOperatorNameFunc>
 hasAnyOverloadedOperatorName;
 
+/// Matches template-dependent, but known, member names
+///
+/// In template declarations, dependent members are not resolved and so can
+/// not be matched to partic

[PATCH] D90767: Add new matchers for dependent names in templates

2020-11-04 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 302852.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90767

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -17,7 +17,6 @@
 
 namespace clang {
 namespace ast_matchers {
-
 TEST_P(ASTMatchersTest, IsExpandedFromMacro_MatchesInFile) {
   StringRef input = R"cc(
 #define MY_MACRO(a) (4 + (a))
@@ -1629,6 +1628,78 @@
  Constructor1Arg));
 }
 
+TEST(ASTMatchersTest, NamesMember_CXXDependentScopeMemberExpr) {
+
+  // Member functions:
+  {
+auto Code = "template  struct S{ void mem(); }; template "
+" void x() { S s; s.mem(); }";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(cxxMethodDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+  }
+
+  // Member variables:
+  {
+auto Code = "template  struct S{ int mem; }; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(fieldDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+  }
+
+  // static member variables:
+  {
+auto Code = "template  struct S{ static int mem; }; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(
+matches(Code, cxxDependentScopeMemberExpr(hasMemberName("mem";
+
+EXPECT_TRUE(matches(
+Code,
+cxxDependentScopeMemberExpr(
+hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
+hasDeclaration(classTemplateDecl(has(cxxRecordDecl(
+has(varDecl(hasName("mem")).bind("templMem")),
+memberHasSameNameAsBoundNode("templMem";
+  }
+
+  // other named decl:
+  {
+auto Code = "template  struct S{ static int mem; }; struct "
+"mem{}; template "
+" void x() { S s; s.mem; }";
+
+EXPECT_TRUE(matches(
+Code,
+translationUnitDecl(has(cxxRecordDecl(hasName("mem"))),
+hasDescendant(cxxDependentScopeMemberExpr();
+
+EXPECT_FALSE(matches(
+Code,
+translationUnitDecl(has(cxxRecordDecl(hasName("mem")).bind("templMem")),
+hasDescendant(cxxDependentScopeMemberExpr(
+memberHasSameNameAsBoundNode("templMem"));
+  }
+}
+
 TEST(ASTMatchersTest, ArgumentCountIs_CXXUnresolvedConstructExpr) {
   const auto *Code =
   "template  struct S{}; template  void "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -302,6 +302,7 @@
   REGISTER_MATCHER(hasLocalStorage);
   REGISTER_MATCHER(hasLoopInit);
   REGISTER_MATCHER(hasLoopVariable);
+  REGISTER_MATCHER(hasMemberName);
   REGISTER_MATCHER(hasMethod);
   REGISTER_MATCHER(hasName);
   REGISTER_MATCHER(hasNullSelector);
@@ -443,6 +444,7 @@
   REGISTER_MATCHER(materializeTemporaryExpr);
   REGISTER_MATCHER(member);
   REGISTER_MATCHER(memberExpr);
+  REGISTER_MATCHER(memberHasSameNameAsBoundNode);
   REGISTER_MATCHER(memberPointerType);
   REGISTER_MATCHER(namedDecl);
   REGISTER_MATCHER(namesType);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2835,6 +2835,82 @@
 StringRef, internal::hasAnyOverloadedOperatorNameFunc>
 hasAnyOverloadedOperatorName;
 
+/// Matches template-dependent, but known, member names
+///
+/// In template declarations, dependent members are not resolved and so can
+/// not be matched to particular named declarations.
+///
+/// This matcher allows to match on the known name of members.
+///
+///

[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-11-04 Thread Hiral via Phabricator via cfe-commits
Hiralo added a comment.

Got it. No worries :)
Thanks @DmitryPolukhin for your help.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:3801
+/// error.
+class UnresolvedUsingIfExistsDecl final : public NamedDecl {
+  UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc,

erik.pilkington wrote:
> aaron.ballman wrote:
> > erik.pilkington wrote:
> > > aaron.ballman wrote:
> > > > Why is this inheriting from a `NamedDecl` rather than a `UsingDecl`? 
> > > > Given that this is a type of using declaration, I guess I would have 
> > > > expected it to appear as such in the AST hierarchy. For instance, 
> > > > should people using AST matchers be able to match one of these as a 
> > > > using declaration or are they so different semantically that they need 
> > > > to be sibling AST nodes?
> > > This node isn't a kind of using declaration, it is a declaration that 
> > > gets inserted into the scope via a usual UsingDecl & UsingShadowDecl 
> > > mechanism that Sema knows to error out on if it is ever used. So 
> > > presumably existing AST users would still recognize that this is a 
> > > UsingDecl that adds a single declaration into the current context, but 
> > > wouldn't really know anything about that declaration. I updated the doc 
> > > comment above to make that more clear.
> > So given code like this:
> > ```
> > using empty_namespace::does_not_exist __attribute__((using_if_exists)); 
> > ```
> > would you expect this AST matcher to match or not?
> > ```
> > usingDecl()
> > ```
> > (I hope the answer is "yes" because otherwise the behavior is rather 
> > inexplicable to me.)
> Yeah, the answer is "yes". The AST representation for a using_if_exists 
> declaration that failed to lookup anything would look something like this:
> 
> ```
> |-UsingDecl 0x7fa42b84a3a0  col:9 ::X
> |-UsingShadowDecl 0x7fa42b84a3f8  col:9 implicit 
> UnresolvedUsingIfExists 0x7fa42b84a370 'X'
> ```
> 
> So its still using the typical UsingDecl machinery, its just that the 
> declaration thats being imported is different.
Awesome, thank you for clarifying!


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

https://reviews.llvm.org/D90188

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


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2851
+// Parse MASM style pseudo prefixes.
+// FIXME: This prefix should only be used for MASM, not for intel-syntax.
+if (isParsingIntelSyntax()) {

epastor wrote:
> LiuChen3 wrote:
> > I tried to limit to MASM. But I found that the  'isParsingMSInlineAsm()' is 
> > not accurate.  And then I tried to transmit 'ParsingMSInlineAsm' 
> > information correctly in AsmPrinterInlineAsm.cpp (according to the 
> > '-fasm-blocks' option). But I was surprised to find that 
> > isParsingMSInlineAsm() is actually used as the argument of 
> > 'MatchingInlineAsm' in 'MatchAndEmitInstruction()'. This makes me confused. 
> > Should that 'MatchingInlineAsm' be 'MatchingMSInlineAsm' ?Is this 
> > MatchingInlineAsm only used by llvm-ml.
> > It difficult to limit this to MASM at the moment. 
> llvm-ml attempts not to touch **anything** involving inline assembly so far. 
> The signal that MasmParser.cpp is involved is `Parser.isParsingMasm()`. 
> However... while I can't answer the majority of this without more research, I 
> suspect you're correct that `MatchingInlineAsm` is misnamed. We need to check 
> this, and if so, we should rename it to avoid confusion.
MS inline assembly is parsed twice. Once by  clang to find names of C/C++ 
variables. And again in the backend. GNU inline assembly is only parsed in the 
backend since variable names are bound explicitly and not referenced in the 
assembly text.

IsParsingInlineAsm is set during the clang parsing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[PATCH] D90174: [HIP] Fix regressions due to fp contract change

2020-11-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D90174#2371577 , @rjmccall wrote:

> Hmm.  Do we actually want this behavior of `fast` overriding pragmas?  What 
> do other compilers do here?  It might be reasonable to just treat this as a 
> bug.

I think clang is just trying to follow gcc's behavior. However, this is 
undesirable in certain cases. Introducing 'faststd' gives us more choices to 
avoid the undesirable behavior.


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

https://reviews.llvm.org/D90174

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-11-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Update for review comments.




Comment at: clang/test/CodeGen/builtin_float_strictfp.c:1
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-pc 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
+// RUN: %clang_cc1 -emit-llvm -triple ppc64-be -ffp-exception-behavior=maytrap 
-o - %s | FileCheck %s --check-prefixes=CHECK,NOFP16

sepavloff wrote:
> Part of this test, namely functions `test_floats`, `test_doubles` and 
> `tests_halves` must pass on unpatched compiler, because they don't contain 
> conversion nodes. Maybe they can be extracted into separate patch, on which 
> this one would depend? 
I deleted `test_floats` and `test_doubles` because of that lack of conversion 
nodes. But `test_half` does have implicit conversions and I added checks for 
more of them.



Comment at: clang/test/CodeGen/complex-math-strictfp.c:1
+// RUN: %clang_cc1 %s -ffp-exception-behavior=maytrap -O0 -emit-llvm -triple 
x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+

sepavloff wrote:
> Throughout this test the only operation that involves complex is construction 
> of complex value from real part. It does not use any conversion node, so this 
> test must with unpatched compiler.
That's valid. The conversion from float to "_Complex float" does get an 
ImplicitCastExpr, but it shouldn't result in constrained intrinsics. So the 
test isn't needed. I'll nuke it.



Comment at: clang/test/CodeGen/complex-strictfp.c:92-95
+  double _Complex a = 5;
+  double _Complex b = 42;
+
+  return a * b != b * a;

sepavloff wrote:
> This function generated complicated code, which is hard to check and easy to 
> break. Can this function be split into smaller functions which would test 
> only one operation? It could allow to use more compact checks. I think these 
> tests should pass on unpatched compiler.
I'll pull this out and put it in a subsequent patch. It shows we have work to 
do, but isn't needed for this patch.



Comment at: clang/test/CodeGen/complex-strictfp.c:131
+//
+void test2(int c) {
+  _Complex double X;

sepavloff wrote:
> This function does not produce constrained intrinsics at all.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:239
+//
+void test3() {
+  g1 = g1 + g2;

sepavloff wrote:
> Can it be split into smaller functions?
Sure, can do.



Comment at: clang/test/CodeGen/complex-strictfp.c:397
+void t3() {
+  __complex__ long long v = 2;
+}

sepavloff wrote:
> Integer-only arithmetic.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:421
+void t5() {
+  float _Complex x = t4();
+}

sepavloff wrote:
> No floating point operations, only moves.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:469-472
+  g1++;
+  g1--;
+  ++g1;
+  --g1;

sepavloff wrote:
> Only these operations involve FP operations, but none produces constrained 
> intrinsics. And they don't produce cast nodes. Besides, these inc/dec 
> operations are represented in IR as add/sub, does it makes sense to test them 
> separately?
Yes, a separate patch for those would be better.



Comment at: clang/test/CodeGen/exprs-strictfp.c:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s 
-ffp-exception-behavior=maytrap -emit-llvm -o - | FileCheck %s

kpn wrote:
> sepavloff wrote:
> > No FP casts.
> There's an implied cast in the AST, and I'm pretty sure the bits from that 
> are used when simplifying this into the fcmp. I'll doublecheck.
Confirmed. In `CodeGenFunction::EvaluateExprAsBool()` we set the constrained 
metadata and then call down eventually to 
`ScalarExprEmitter::EmitFloatToBoolConversion()`.

The node we get the metadata from is a "`ImplicitCastExpr 0x80fe2b338 'double' 
 FPExceptionMode=2`".



Comment at: clang/test/CodeGen/incdec-strictfp.c:22
+
+  printf("%lf %lf\n", A, B);
+}

sepavloff wrote:
> This line and corresponding function declaration seem unnecessary?
This whole test is better left to a subsequent patch. It's another holdover 
from my previous attempt at the code changes.



Comment at: clang/test/CodeGen/ubsan-conditional-strictfp.c:1
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -fsanitize=float-divide-by-zero -o - 
| FileCheck %s
+

kpn wrote:
> sepavloff wrote:
> > What is the effect of `-fsanitize=float-divide-by-zero`? If it absents does 
> > the test change behavior?
> An earlier version of this patch did try passing bits all the way down to the 
> calls to the IRBuilder. In this version of the patch the sanitizer was 
> require

[PATCH] D90531: [clangd] Add clang-tidy options to config

2020-11-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thank you!

This design looks really good, just have some nits on comments, possible 
simplifications etc.

(Sorry about the delay getting to these, on it now!)




Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:268
 
+  void checkAdjuster(std::string &Adjuster, const Located &Arg,
+ bool IsPositive) {

nit: method name is confusing because it uses "check" as a noun where you'd 
expect it to be a verb (this method validates `Adjuster`)

Maybe `appendTidyCheckSpec`?



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:272
+StringRef Str = *Arg;
+StringRef Type(IsPositive ? "Add" : "Remove");
+// Don't support negating here, its handled if the item is in the Add or

nit: I think this code is going to too much trouble to produce a precise error 
message
- not sure "Add check item can't start with '-'" is clearer than without the 
word "add". Errors show the error location/range.
- "check name" would be clearer than "check item" (even if wildcards are 
allowed, IMO)
- it feels a bit weird to be really specific about - and , - these are 
references to a fixed list of checks, so all that really matters is that it's 
not the name of a check. I'd consider just returning fixed "Invalid clang-tidy 
check name" for both cases



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:275
+// Remove list.
+if (Str[0] == '-') {
+  diag(Error,

Str.startswith("-") - we haven't checked that it's empty (and shouldn't bother 
IMO)



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:301
+
+std::string Checks;
+for (auto &CheckGlob : F.Add)

nit: I'd suggest *including" the leading comma in these
e.g. Checks is ",foo,bar". (Maybe call it ChecksSuffix)

Then when applying,
`C.ClangTidy.Checks.append(Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/1 
: 0);`

advantages:
- marginally simplifies checkAdjuster (no need to conditionally add the comma)
- the Apply step (which is somewhat performance-sensitive) is at most a single 
allocation (which is awkward to achieve otherwise)



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:236-237
+StringRef Type(IsPositive ? "Add" : "Remove");
+// Don't support negating here, its handled if the item is in the Add or
+// Remove list.
+if (Str[0] == '-') {

njames93 wrote:
> Is this the direction we want to go, the first draft paper on this seems to 
> suggest so.
Yeah it looks like a good solution to me. It's not as powerful as an ordered 
list of globs, but it's simple and consistent with the other settings we have. 
`.clang-tidy` is still the right thing for full control.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:178
+
+  /// This section controls how clang-tidy will run over the code base
+  ///

nit: drop "this section" and add trailing period, consistent with other 
sections.

I think "code" would be clearer than codebase.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:183
+  struct ClangTidyBlock {
+llvm::Optional> Enable;
+/// List of checks to enable or disable, can use wildcards.

I wonder if it's worth having this when we support `Remove: *`.

technically this does something slightly different:
 - it still runs the machinery just with no actual checks
 - you can enable: true later to override it, without losing the previously 
configured list of checks

Is one of these important? Is there some other benefit?
(I'm not opposed to having this if you want it, but I'm curious)



Comment at: clang-tools-extra/clangd/ConfigFragment.h:184
+llvm::Optional> Enable;
+/// List of checks to enable or disable, can use wildcards.
+/// \ref Add checks get ran first, then \ref Remove checks. This lets you

nit: we should document each separately.

e.g. "/// List of checks to enable - can be wildcards like "readability-*".



Comment at: clang-tools-extra/clangd/ConfigFragment.h:185
+/// List of checks to enable or disable, can use wildcards.
+/// \ref Add checks get ran first, then \ref Remove checks. This lets you
+/// enable all checks from a module apart from a few specific checks,

nit: "get ran" is confusing - this doesn't affect the order in which checks 
*run*, just which overrrides which.
And this text/example could probably be a little more compact.

I'd suggest:

```
List of checks to disable.
Takes precedence over Add. To enable all llvm checks except include order:
  Add: llvm-*
  Remove: llvm-include-onder
```



Comment at: clang-tools-extra/clangd/ConfigFragment.h:188
+/// Example:
+///   Add: llvm-
+///   Remove: llvm-include-order

should this be llvm-*?



Com

[PATCH] D90486: [NewPM] Add OptimizationLevel param to TargetMachine::registerPassBuilderCallbacks()

2020-11-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/lib/Target/BPF/BPFTargetMachine.cpp:129
 bool DebugPassManager) {
   PB.registerPipelineStartEPCallback([=](ModulePassManager &MPM) {
 FunctionPassManager FPM(DebugPassManager);

Maybe I missed something. Except for PipelineStartEPCallback, all the other EP 
callbacks already take `OptimizationLevel` as input, do we only need to extend 
PipelineStartEPCallback to also take `OptimizationLevel` as input?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90486

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


[PATCH] D90552: [clangd] Set the User option for clang-tidy to mimick its behaviour

2020-11-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:812
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USEUSERNAMER");

do you think we should #ifdef this for windows?

maybe like
```
User = llvm::sys::Process::GetEnv(
#ifdef _WIN32
"USERNAME"
#else
"USER"
)
```

(or maybe always query USER but only query USERNAME on windows, or something 
else?)



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:813
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USEUSERNAMER");
 tidy::ClangTidyOptions OverrideClangTidyOptions;

I think this is meant to be USERNAME?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90552

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


[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

> Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy and
> less like a grammar. (E.g. variants list the Alternatives parent rather than
> vice versa).



> e.g. we may introduce abstract bases like "loop" that the grammar doesn't 
> care about in order to model is-a concepts that might make refactorings more 
> expressive. This is less natural in a grammar-like idiom.

Do you have a concrete example of such abstract base -- loop is in the grammar 
 ? And in the case 
such an example appear, in my mind we would just change "our grammar" to have 
an alternative for this "loop" abstract base.

> e.g. we're likely to have to model some alternatives as variants and others 
> as class hierarchies, the choice will probably be based on natural is-a 
> relationships.

I agree, alternatives and the two ways to model them are a tricky subject...

> it reduces the cognitive load of switching from editing *.td to working with 
> code that uses the generated classes

I think we should consider reading prior to editing.
A grammar is how we represent syntax, and syntax trees model syntax, as such I 
think we should rather consider the cognitive load of switching between the 
grammar and the definition of syntax trees.

I have a lot to improve in my writing skills, so I don't know if I could 
express all my thoughts. We could have a call if you want ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90543

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-11-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I went through all the comments here, plus looked at the code myself.  I 
believe all of the comments by other reviewers have been fixed/answered 
acceptably. I don't have any additional comments to add, therefore I think it 
is appropriate to accept this revision.

@jfb: Please give this a day or two before committing to give the other 
reviewers a chance to speak up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

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


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2958-2970
+auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+if (PerDevice != OffloadEntriesTargetRegion.end()) {
+  auto PerFile = PerDevice->second.find(FileID);
+  if (PerFile != PerDevice->second.end()) {
+auto PerParentName = PerFile->second.find(ParentName);
+if (PerParentName != PerFile->second.end()) {
+  auto PerLine = PerParentName->second.find(LineNum);

ABataev wrote:
> ABataev wrote:
> > Just:
> > ```
> > if (hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
> >   return;
> > ```
> Actually, even better to do something like this:
> ```
> if (Flags == OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion && 
> hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
>   return;
> assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) && 
> "Target region entry already registered!");
> ```
I tried this code but found that `hasTargetRegionEntryInfo` is not doing what 
we want since we need the below code to return true in 
`hasTargetRegionEntryInfo`.
```
if (PerLine->second.getAddress() || PerLine->second.getID()) {
  return false;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90552: [clangd] Set the User option for clang-tidy to mimick its behaviour

2020-11-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 302871.
njames93 marked an inline comment as done.
njames93 added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90552

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -809,6 +809,9 @@
   if (EnableClangTidy) {
 auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
 EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USERNAME");
 tidy::ClangTidyOptions OverrideClangTidyOptions;
 if (!ClangTidyChecks.empty())
   OverrideClangTidyOptions.Checks = ClangTidyChecks;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -809,6 +809,9 @@
   if (EnableClangTidy) {
 auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
 EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USERNAME");
 tidy::ClangTidyOptions OverrideClangTidyOptions;
 if (!ClangTidyChecks.empty())
   OverrideClangTidyOptions.Checks = ClangTidyChecks;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90552: [clangd] Set the User option for clang-tidy to mimick its behaviour

2020-11-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:812
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USEUSERNAMER");

sammccall wrote:
> do you think we should #ifdef this for windows?
> 
> maybe like
> ```
> User = llvm::sys::Process::GetEnv(
> #ifdef _WIN32
> "USERNAME"
> #else
> "USER"
> )
> ```
> 
> (or maybe always query USER but only query USERNAME on windows, or something 
> else?)
I'm not too sure how nicely that would play when using clang with mingw. given 
there is no harm in calling both I'd rather ere on the safe side.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:813
+if (!EmptyDefaults.User)
+  EmptyDefaults.User = llvm::sys::Process::GetEnv("USEUSERNAMER");
 tidy::ClangTidyOptions OverrideClangTidyOptions;

sammccall wrote:
> I think this is meant to be USERNAME?
Bad copy and paste error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90552

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


[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-04 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:5273
+  namespace empty_namespace {};
+  using empty_namespace::does_not_exist __attribute__((using_if_exists)); // 
no error!
+

erik.pilkington wrote:
> aaron.ballman wrote:
> > erik.pilkington wrote:
> > > Mordante wrote:
> > > > Mordante wrote:
> > > > > Can you add an example using `[[clang::using_if_exists]]` or use that 
> > > > > instead of this attribute?
> > > > Why is the attribute placed here? I would expect the attribute before 
> > > > the declaration `[[clang::using_if_exists]] using 
> > > > empty_namespace::does_not_exist;`
> > > The attribute is written like that because clang rejects C++ style 
> > > attributes on using declarations, and only accepts attributes in that 
> > > position. I think this is the first attribute we actually support on 
> > > using-declarations, so maybe we should consider supporting it.
> > > I think this is the first attribute we actually support on 
> > > using-declarations, so maybe we should consider supporting it.
> > 
> > This isn't the first attribute we *should* be supporting on using 
> > declarations. Any attribute that appertains to a `NamedDecl` should apply 
> > as should the annotate attribute.
> > 
> > However:
> > ```
> > [[clang::whatever]] using foo::bar; // Correct to reject, #1
> > using foo::bar [[clang::whatever]]; // Correct to reject, #2
> > ```
> > #1 is rejected because it's a declaration-statement and those cannot have a 
> > leading attribute-specifier-seq 
> > (http://eel.is/c++draft/stmt.stmt#stmt.pre-1). #2 is rejected because the 
> > using-declaration cannot have a trailing attribute-specifier-seq 
> > (http://eel.is/c++draft/namespace.udecl#nt:using-declaration).
> > 
> > This seems like a case where we may want to explore an extension to C++ 
> > that we propose to WG21.
> > This isn't the first attribute we *should* be supporting on using 
> > declarations. Any attribute that appertains to a NamedDecl should apply as 
> > should the annotate attribute.
> 
> Yeah, agreed. Its just that Sema was failing to call ProcessDeclAttributeList 
> for UsingDecls, so no attributes were actually getting applied in practice.
> 
> Okay, if our policy is to only parse C++-style attributes in places that the 
> C++ grammar allows them then I agree that this would be an issue for the 
> standards committee. 
I would be in favour to implement this as an extension and propose it to the 
committee. I wonder whether it's not allowed because the committee objected or 
nobody wrote a paper. (Attributes are already allowed on using namespace 
directives http://eel.is/c++draft/namespace.udir.)


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

https://reviews.llvm.org/D90188

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


[PATCH] D88298: Fix MaterializeTemporaryExpr's type when its an incomplete array.

2020-11-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping! This was requested in post-commit on the last patch, so I'm hoping it 
shouldn't be too controversial.


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

https://reviews.llvm.org/D88298

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


[PATCH] D90174: [HIP] Fix regressions due to fp contract change

2020-11-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D90174#2373829 , @yaxunl wrote:

> In D90174#2371577 , @rjmccall wrote:
>
>> Hmm.  Do we actually want this behavior of `fast` overriding pragmas?  What 
>> do other compilers do here?  It might be reasonable to just treat this as a 
>> bug.
>
> I think clang is just trying to follow gcc's behavior. However, this is 
> undesirable in certain cases. Introducing 'faststd' gives us more choices to 
> avoid the undesirable behavior.

For other compilers:

MSVC respects pragma with /fp:fast option:

https://godbolt.org/z/3rja55

Intel compiler also respects fp_contract pragma with -fp-model fast={1|2} 
option:

https://godbolt.org/z/fez86h

nvcc by default always fuse across statements and does not support pragmas to 
control fp contract

https://docs.nvidia.com/cuda/floating-point/index.html#controlling-fused-multiply-add


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

https://reviews.llvm.org/D90174

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


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2958-2970
+auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+if (PerDevice != OffloadEntriesTargetRegion.end()) {
+  auto PerFile = PerDevice->second.find(FileID);
+  if (PerFile != PerDevice->second.end()) {
+auto PerParentName = PerFile->second.find(ParentName);
+if (PerParentName != PerFile->second.end()) {
+  auto PerLine = PerParentName->second.find(LineNum);

cchen wrote:
> ABataev wrote:
> > ABataev wrote:
> > > Just:
> > > ```
> > > if (hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
> > >   return;
> > > ```
> > Actually, even better to do something like this:
> > ```
> > if (Flags == OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion 
> > && hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
> >   return;
> > assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) && 
> > "Target region entry already registered!");
> > ```
> I tried this code but found that `hasTargetRegionEntryInfo` is not doing what 
> we want since we need the below code to return true in 
> `hasTargetRegionEntryInfo`.
> ```
> if (PerLine->second.getAddress() || PerLine->second.getID()) {
>   return false;
> }
> ```
Do we want to create a new helper function like hasTargetRegionEntryInfo or 
something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2958-2970
+auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
+if (PerDevice != OffloadEntriesTargetRegion.end()) {
+  auto PerFile = PerDevice->second.find(FileID);
+  if (PerFile != PerDevice->second.end()) {
+auto PerParentName = PerFile->second.find(ParentName);
+if (PerParentName != PerFile->second.end()) {
+  auto PerLine = PerParentName->second.find(LineNum);

cchen wrote:
> cchen wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > Just:
> > > > ```
> > > > if (hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
> > > >   return;
> > > > ```
> > > Actually, even better to do something like this:
> > > ```
> > > if (Flags == 
> > > OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion && 
> > > hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
> > >   return;
> > > assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) 
> > > && "Target region entry already registered!");
> > > ```
> > I tried this code but found that `hasTargetRegionEntryInfo` is not doing 
> > what we want since we need the below code to return true in 
> > `hasTargetRegionEntryInfo`.
> > ```
> > if (PerLine->second.getAddress() || PerLine->second.getID()) {
> >   return false;
> > }
> > ```
> Do we want to create a new helper function like hasTargetRegionEntryInfo or 
> something?
Better to extend the old one, I think. Add a new parameter to check if we need 
to check for address and id


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90240: [SyntaxTree] Add reverse links to syntax Nodes.

2020-11-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

As we discussed offline we will probably not provide `replaceChildRange` in the 
public mutations API anymore.

As a result I don't think we should be chaining changes related to 
`replaceChildRange` in this patch, and thus it should be ready to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90240

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


[PATCH] D90240: [SyntaxTree] Add reverse links to syntax Nodes.

2020-11-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 302879.
eduucaldas added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90240

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Mutations.cpp
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -57,8 +57,9 @@
 }
 
 syntax::Node::Node(NodeKind Kind)
-: Parent(nullptr), NextSibling(nullptr), Kind(static_cast(Kind)),
-  Role(0), Original(false), CanModify(false) {
+: Parent(nullptr), NextSibling(nullptr), PreviousSibling(nullptr),
+  Kind(static_cast(Kind)), Role(0), Original(false),
+  CanModify(false) {
   this->setRole(NodeRole::Detached);
 }
 
@@ -74,6 +75,30 @@
   return N->getKind() > NodeKind::Leaf;
 }
 
+void syntax::Tree::appendChildLowLevel(Node *Child, NodeRole Role) {
+  assert(Child->getRole() == NodeRole::Detached);
+  assert(Role != NodeRole::Detached);
+
+  Child->setRole(Role);
+  appendChildLowLevel(Child);
+}
+
+void syntax::Tree::appendChildLowLevel(Node *Child) {
+  assert(Child->Parent == nullptr);
+  assert(Child->NextSibling == nullptr);
+  assert(Child->PreviousSibling == nullptr);
+  assert(Child->getRole() != NodeRole::Detached);
+
+  Child->Parent = this;
+  if (this->LastChild) {
+Child->PreviousSibling = this->LastChild;
+this->LastChild->NextSibling = Child;
+  } else
+this->FirstChild = Child;
+
+  this->LastChild = Child;
+}
+
 void syntax::Tree::prependChildLowLevel(Node *Child, NodeRole Role) {
   assert(Child->getRole() == NodeRole::Detached);
   assert(Role != NodeRole::Detached);
@@ -85,22 +110,26 @@
 void syntax::Tree::prependChildLowLevel(Node *Child) {
   assert(Child->Parent == nullptr);
   assert(Child->NextSibling == nullptr);
+  assert(Child->PreviousSibling == nullptr);
   assert(Child->getRole() != NodeRole::Detached);
 
   Child->Parent = this;
-  Child->NextSibling = this->FirstChild;
+  if (this->FirstChild) {
+Child->NextSibling = this->FirstChild;
+this->FirstChild->PreviousSibling = Child;
+  } else
+this->LastChild = Child;
+
   this->FirstChild = Child;
 }
 
-void syntax::Tree::replaceChildRangeLowLevel(Node *BeforeBegin, Node *End,
+void syntax::Tree::replaceChildRangeLowLevel(Node *Begin, Node *End,
  Node *New) {
-  assert((!BeforeBegin || BeforeBegin->Parent == this) &&
- "`BeforeBegin` is not a child of `this`.");
+  assert((!Begin || Begin->Parent == this) &&
+ "`Begin` is not a child of `this`.");
   assert((!End || End->Parent == this) && "`End` is not a child of `this`.");
   assert(canModify() && "Cannot modify `this`.");
 
-  Node *&Begin = BeforeBegin ? BeforeBegin->NextSibling : FirstChild;
-
 #ifndef NDEBUG
   for (auto *N = New; N; N = N->NextSibling) {
 assert(N->Parent == nullptr);
@@ -116,9 +145,8 @@
 return true;
 return false;
   };
-  assert(Reachable(FirstChild, BeforeBegin) &&
- "`BeforeBegin` is not reachable.");
-  assert(Reachable(Begin, End) && "`End` is not after `BeforeBegin`.");
+  assert(Reachable(FirstChild, Begin) && "`Begin` is not reachable.");
+  assert(Reachable(Begin, End) && "`End` is not after `Begin`.");
 #endif
 
   if (!New && Begin == End)
@@ -128,6 +156,10 @@
   for (auto *T = this; T && T->Original; T = T->Parent)
 T->Original = false;
 
+  // Save the node before the range to be removed. Later we insert the `New`
+  // range after this node.
+  auto *BeforeBegin = Begin ? Begin->PreviousSibling : LastChild;
+
   // Detach old nodes.
   for (auto *N = Begin; N != End;) {
 auto *Next = N->NextSibling;
@@ -135,24 +167,33 @@
 N->setRole(NodeRole::Detached);
 N->Parent = nullptr;
 N->NextSibling = nullptr;
+N->PreviousSibling = nullptr;
 if (N->Original)
   traverse(N, [](Node *C) { C->Original = false; });
 
 N = Next;
   }
 
+  // Attach new range.
+  auto *&NewFirst = BeforeBegin ? BeforeBegin->NextSibling : FirstChild;
+  auto *&NewLast = End ? End->PreviousSibling : LastChild;
+
   if (!New) {
-Begin = End;
+NewFirst = End;
+NewLast = BeforeBegin;
 return;
   }
-  // Attach new nodes.
-  Begin = New;
-  auto *Last = New;
+
+  New->PreviousSibling = BeforeBegin;
+  NewFirst = New;
+
+  Node *LastInNew;
   for (auto *N = New; N != nullptr; N = N->NextSibling) {
-Last = N;
+LastInNew = N;
 N->Parent = this;
   }
-  Last->NextSibling = End;
+  LastInNew->NextSibling = End;
+  NewLast = LastInNew;
 }
 
 namespace {
@@ -248,6 +289,11 @@
   assert(C.isOriginal());
 assert(!C.isDetached());
 assert(C.getParent() == T);
+const auto *Next = C.getNextSibling();
+assert(!Next || &C == Next->

[PATCH] D90221: Include more attribute details when dumping AST in JSON

2020-11-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.



In D90221#2358469 , @aronsky wrote:

> In D90221#2357060 , @aaron.ballman 
> wrote:
>
>> In D90221#2356110 , @aronsky wrote:
>>
>>> In D90221#2356062 , @lebedev.ri 
>>> wrote:
>>>
 Are there tests missing?
>>>
>>> Quite possible. I followed the trail of the existing functions to figure 
>>> out the difference between JSON and textual dumping, and tried replicating 
>>> everything in a manner similar to the existing code. I haven't run into any 
>>> tests, but that's probably because I wasn't looking for those. I'll add the 
>>> appropriate tests ASAP.
>>
>> FWIW, the tests for dumping JSON live in `clang\test\AST` and typically have 
>> a `-json` extension on them. There is a helper script named 
>> `gen_ast_dump_json_test.py` that can be used to generate the expected output 
>> from the test.
>
> Thanks, I'll take a look at the Python script, that'll be helpful!
>
> Those functions do look out of place, but they are actually called via 
> polymorphism (I wish I could point to the exact location - it wasn't easy 
> figuring that out in the first place, and the actual work was done about a 
> month ago, I just got to publishing the PR yesterday). The code that calls 
> these functions is emitted at `writeDump` (in 
> `clang/utils/TableGen/ClangAttrEmitter.cpp`) - which, in turn, is called by 
> `EmitClangAttrJSONNodeDump` and `EmitClangAttrTextNodeDump` in the same file.

It seems surprising to me that you'd have to add those declarations; I think 
that's a layering violation. There's something somewhat strange going on here 
that I think is related. Given:

  [[clang::annotate("testing")]] void func1();
  [[gnu::visibility("hidden")]] void func2();

I get:

  {
"id": "0x2527bc0",
"kind": "FunctionDecl",
"loc": {
  "offset": 36,
  "file": "F:\\Aaron Ballman\\Desktop\\test.cpp",
  "line": 1,
  "col": 37,
  "tokLen": 5
},
"range": {
  "begin": {
"offset": 31,
"col": 32,
"tokLen": 4
  },
  "end": {
"offset": 42,
"col": 43,
"tokLen": 1
  }
},
"name": "func1",
"mangledName": "?func1@@YAXXZ",
"type": {
  "qualType": "void ()"
},
"inner": [
  {
"id": "0x2527c60",
"kind": "AnnotateAttr",
"range": {
  "begin": {
"offset": 2,
"col": 3,
"tokLen": 5
  },
  "end": {
"offset": 27,
"col": 28,
"tokLen": 1
  }
},
"args": [
  " \"testing\""
],
"inner": [
  {
"id": "0x24bcfd8",
"kind": "StringLiteral",
"range": {
  "begin": {
"offset": 18,
"col": 19,
"tokLen": 9
  },
  "end": {
"offset": 18,
"col": 19,
"tokLen": 9
  }
},
"type": {
  "qualType": "const char [8]"
},
"valueCategory": "lvalue",
"value": "\"testing\""
  }
]
  }
]
  },
  {
"id": "0x2527de8",
"kind": "FunctionDecl",
"loc": {
  "offset": 81,
  "line": 2,
  "col": 36,
  "tokLen": 5
},
"range": {
  "begin": {
"offset": 76,
"col": 31,
"tokLen": 4
  },
  "end": {
"offset": 87,
"col": 42,
"tokLen": 1
  }
},
"name": "func2",
"mangledName": "?func2@@YAXXZ",
"type": {
  "qualType": "void ()"
},
"inner": [
  {
"id": "0x2527e88",
"kind": "VisibilityAttr",
"range": {
  "begin": {
"offset": 48,
"col": 3,
"tokLen": 3
  },
  "end": {
"offset": 72,
"col": 27,
"tokLen": 1
  }
},
"args": [
  " Hidden"
]
  }
]
  }

Notice how the annotate attribute has an `inner` array with the argument inside 
of it while the visibility attribute does not? Ideally, we'd either use `args` 
or `inner` but not a mixture of the two.

I was imagining the design here to be that the JSON node dumper for attributes 
would open a new JSON attribute named "args" whose value is an array of 
arguments, then you'd loop over the arguments and `Visit` each one in turn as 
the arguments are children of the attribute AST node in some respects. For 
instance, consider dumping the arguments for the `enable_if` attribute, which 
accepts arbitrary expressions -- dumping a type or a bare decl ref is 
insufficient.




Comment at: clang/test/AST/ast-dump-stmt-json.cpp:1465
+// CHECK-NEXT:"args": [
+// CHECK-NEXT: " Default"
+// CH

[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 302882.
cchen edited the summary of this revision.
cchen added a comment.

Fix based on feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK1
+
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i64] [i64 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+// CK1: [[MTYPE02:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+
+void add_one(float *b, int dm)
+{
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE02]]
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+#pragma omp target data map(tofrom:b[:1]) use_device_ptr(b) if(dm == 0)
+  {
+#pragma omp target is_device_ptr(b)
+  {
+b[0] += 1;
+  }
+  }
+}
+
+#endif
+#endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -613,7 +613,8 @@
 /// Return true if a target region entry with the provided information
 /// exists.
 bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum) const;
+  StringRef ParentName, unsigned LineNum,
+  bool Registered=true) const;
 /// brief Applies action \a Action on all registered entries.
 typedef llvm::function_ref
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CG

[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 302884.
cchen added a comment.

Fix coding style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK1
+
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i64] [i64 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+// CK1: [[MTYPE02:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+
+void add_one(float *b, int dm)
+{
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE02]]
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+#pragma omp target data map(tofrom:b[:1]) use_device_ptr(b) if(dm == 0)
+  {
+#pragma omp target is_device_ptr(b)
+  {
+b[0] += 1;
+  }
+  }
+}
+
+#endif
+#endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -613,7 +613,8 @@
 /// Return true if a target region entry with the provided information
 /// exists.
 bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum) const;
+  StringRef ParentName, unsigned LineNum,
+  bool Registered = true) const;
 /// brief Applies action \a Action on all registered entries.
 typedef llvm::function_ref
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2955,6 +2955,12 @@
 

[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:5273
+  namespace empty_namespace {};
+  using empty_namespace::does_not_exist __attribute__((using_if_exists)); // 
no error!
+

Mordante wrote:
> erik.pilkington wrote:
> > aaron.ballman wrote:
> > > erik.pilkington wrote:
> > > > Mordante wrote:
> > > > > Mordante wrote:
> > > > > > Can you add an example using `[[clang::using_if_exists]]` or use 
> > > > > > that instead of this attribute?
> > > > > Why is the attribute placed here? I would expect the attribute before 
> > > > > the declaration `[[clang::using_if_exists]] using 
> > > > > empty_namespace::does_not_exist;`
> > > > The attribute is written like that because clang rejects C++ style 
> > > > attributes on using declarations, and only accepts attributes in that 
> > > > position. I think this is the first attribute we actually support on 
> > > > using-declarations, so maybe we should consider supporting it.
> > > > I think this is the first attribute we actually support on 
> > > > using-declarations, so maybe we should consider supporting it.
> > > 
> > > This isn't the first attribute we *should* be supporting on using 
> > > declarations. Any attribute that appertains to a `NamedDecl` should apply 
> > > as should the annotate attribute.
> > > 
> > > However:
> > > ```
> > > [[clang::whatever]] using foo::bar; // Correct to reject, #1
> > > using foo::bar [[clang::whatever]]; // Correct to reject, #2
> > > ```
> > > #1 is rejected because it's a declaration-statement and those cannot have 
> > > a leading attribute-specifier-seq 
> > > (http://eel.is/c++draft/stmt.stmt#stmt.pre-1). #2 is rejected because the 
> > > using-declaration cannot have a trailing attribute-specifier-seq 
> > > (http://eel.is/c++draft/namespace.udecl#nt:using-declaration).
> > > 
> > > This seems like a case where we may want to explore an extension to C++ 
> > > that we propose to WG21.
> > > This isn't the first attribute we *should* be supporting on using 
> > > declarations. Any attribute that appertains to a NamedDecl should apply 
> > > as should the annotate attribute.
> > 
> > Yeah, agreed. Its just that Sema was failing to call 
> > ProcessDeclAttributeList for UsingDecls, so no attributes were actually 
> > getting applied in practice.
> > 
> > Okay, if our policy is to only parse C++-style attributes in places that 
> > the C++ grammar allows them then I agree that this would be an issue for 
> > the standards committee. 
> I would be in favour to implement this as an extension and propose it to the 
> committee. I wonder whether it's not allowed because the committee objected 
> or nobody wrote a paper. (Attributes are already allowed on using namespace 
> directives http://eel.is/c++draft/namespace.udir.)
I wouldn't be opposed to adding an extension for parsing C++-style attributes 
on parts of a using declaration so long as we diagnosed them as an extension to 
alert people to portability issues. I would say that the attribute should be 
written as a prefix attribute (similar to the using-directive grammar) and 
after the using-declarator. This would allow you to do:
```
[[]] using foo::bar;
using foo::bar [[]];
using foo::bar [[]], baz::quux;
```


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

https://reviews.llvm.org/D90188

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-11-04 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 302886.
Conanap marked 5 inline comments as done.
Conanap added a comment.

Addressed some formatting problems as well as corrected incorrect arguments for 
Hi case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90173

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll

Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -118,3 +118,25 @@
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
 }
+
+define dso_local <2 x double> @test_xxsplti32dx_8() {
+; CHECK-LABEL: test_xxsplti32dx_8
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 1082660167
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 1082660167
+; CHECK: blr
+entry:
+  ret <2 x double> 
+}
+
+define dso_local <8 x i16> @test_xxsplti32dx_9() {
+; CHECK-LABEL: test_xxsplti32dx_9
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 23855277
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 19070977
+; CHECK: blr
+entry:
+  ret <8 x i16> 
+}
Index: llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
@@ -1,32 +1,41 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
-; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
+; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
-; RUN: --check-prefix=CHECK-NOPCREL
+; RUN: --check-prefixes=CHECK-NOPCREL-BE,CHECK-NOPCREL,CHECK-NO-COMMON
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-pcrelative-memops -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPCREL-LE,CHECK-NOPCREL,CHECK-NO-COMMON
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-prefix-instrs -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPREFIX,CHECK-NO-COMMON
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -target-abi=elfv2 -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s
+; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 define dso_local <2 x double> @testDoubleToDoubleFail() local_unnamed_addr {
 ; CHECK-LABEL: testDoubleToDoubleFail:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI0_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT: xxsplti32dx vs34, 1, 1081435463
+; CHECK-BE-NEXT: xxsplti32dx vs34, 0, 1081435463
 ; CHECK-NEXT:blr
 ;
 ; CHECK-NOPCREL-LABEL: testDoubleToDoubleFail:
 ; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI0_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI0_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPCREL-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT: xxsplti32dx vs34, 1, 1081435463
+; CHECK-NOPCREL-BE-NEXT: xxsplti32dx vs34, 0, 1081435463
 ; CHECK-NOPCREL-NEXT:blr
 
+; CHECK-NOPREFIX-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPREFIX:   # %bb.0: # %entry
+; CHECK-NOPREFIX-NEXT:addis r3, r2, .LCPI0_0@toc@ha
+; CHECK-NOPREFIX-NEXT:addi r3, r3, .LCPI0_0@toc@l
+; CHECK-NOPREFIX-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPREFIX-NEXT:blr
+
 entry:
   ret <2 x double> 
 }
@@ -34,16 +43,25 @@
 define dso_local <2 x double> @testFloatDenormToDouble() local_unnamed_addr {
 ; CHECK-LABEL: testFloatDenormToDouble:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI1_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT: xxsplti32dx vs34, 1, 940259579
+; CHECK-BE-NEXT: xxsplti32dx vs34, 0, 940259579
 ; CHECK-NEXT:blr
 ;
 ; CHECK-NOPCREL-LABEL: testFloatDenormToDouble:
 ; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI1_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI1_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPCREL-NEXT:   xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT:xxsplti32d

[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-11-04 Thread Albion Fung via Phabricator via cfe-commits
Conanap marked an inline comment as done.
Conanap added a comment.

The unrelated change no longer shows as diff, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90173

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


[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:617
+  StringRef ParentName, unsigned LineNum,
+  bool Registered = true) const;
 /// brief Applies action \a Action on all registered entries.

`IgnoreAddressId` maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-11-04 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 302894.
Conanap marked an inline comment as done.
Conanap added a comment.

Updated a test file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90173

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll

Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -118,3 +118,25 @@
   %vecins1 = shufflevector <4 x i32> , <4 x i32> %a, <4 x i32> 
   ret <4 x i32> %vecins1
 }
+
+define dso_local <2 x double> @test_xxsplti32dx_8() {
+; CHECK-LABEL: test_xxsplti32dx_8
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 1082660167
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 1082660167
+; CHECK: blr
+entry:
+  ret <2 x double> 
+}
+
+define dso_local <8 x i16> @test_xxsplti32dx_9() {
+; CHECK-LABEL: test_xxsplti32dx_9
+; CHECK-LE: xxlxor vs34, vs34, vs34
+; CHECK-LE: xxsplti32dx vs34, 1, 23855277
+; CHECK-BE: xxlxor vs34, vs34, vs34
+; CHECK-BE: xxsplti32dx vs34, 0, 19070977
+; CHECK: blr
+entry:
+  ret <8 x i16> 
+}
Index: llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
@@ -1,114 +1,216 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
-; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s
+; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s --check-prefixes=CHECK-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
-; RUN: --check-prefix=CHECK-NOPCREL
+; RUN: --check-prefixes=CHECK-NOPCREL-BE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-pcrelative-memops -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPCREL-LE
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
 ; RUN: -mattr=-prefix-instrs -ppc-asm-full-reg-names -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s --check-prefix=CHECK-NOPCREL
+; RUN: FileCheck %s --check-prefixes=CHECK-NOPREFIX
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
 ; RUN: -ppc-asm-full-reg-names -target-abi=elfv2 -mcpu=pwr10 < %s | \
-; RUN: FileCheck %s
+; RUN: FileCheck %s --check-prefixes=CHECK-BE
 
 define dso_local <2 x double> @testDoubleToDoubleFail() local_unnamed_addr {
-; CHECK-LABEL: testDoubleToDoubleFail:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI0_0@PCREL(0), 1
-; CHECK-NEXT:blr
-;
-; CHECK-NOPCREL-LABEL: testDoubleToDoubleFail:
-; CHECK-NOPCREL:   # %bb.0: # %entry
-; CHECK-NOPCREL-NEXT:addis r3, r2, .LCPI0_0@toc@ha
-; CHECK-NOPCREL-NEXT:addi r3, r3, .LCPI0_0@toc@l
-; CHECK-NOPCREL-NEXT:lxvx vs34, 0, r3
-; CHECK-NOPCREL-NEXT:blr
-
+; CHECK-LE-LABEL: testDoubleToDoubleFail:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-LE-NEXT:xxsplti32dx vs34, 1, 1081435463
+; CHECK-LE-NEXT:blr
+;
+; CHECK-NOPCREL-BE-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPCREL-BE:   # %bb.0: # %entry
+; CHECK-NOPCREL-BE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-BE-NEXT:xxsplti32dx vs34, 0, 1081435463
+; CHECK-NOPCREL-BE-NEXT:blr
+;
+; CHECK-NOPCREL-LE-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPCREL-LE:   # %bb.0: # %entry
+; CHECK-NOPCREL-LE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NOPCREL-LE-NEXT:xxsplti32dx vs34, 1, 1081435463
+; CHECK-NOPCREL-LE-NEXT:blr
+;
+; CHECK-NOPREFIX-LABEL: testDoubleToDoubleFail:
+; CHECK-NOPREFIX:   # %bb.0: # %entry
+; CHECK-NOPREFIX-NEXT:addis r3, r2, .LCPI0_0@toc@ha
+; CHECK-NOPREFIX-NEXT:addi r3, r3, .LCPI0_0@toc@l
+; CHECK-NOPREFIX-NEXT:lxvx vs34, 0, r3
+; CHECK-NOPREFIX-NEXT:blr
+;
+; CHECK-BE-LABEL: testDoubleToDoubleFail:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-BE-NEXT:xxsplti32dx vs34, 0, 1081435463
+; CHECK-BE-NEXT:blr
 entry:
   ret <2 x double> 
 }
 
 define dso_local <2 x double> @testFloatDenormToDouble() local_unnamed_addr {
-; CHECK-LABEL: testFloatDenormToDouble:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI1_0@PCREL(0), 1
-; CHECK-NEXT:blr
-;
-; CHECK-NOPCREL-LABEL: testFloatDenormToDouble:
-; CHE

[PATCH] D90775: [clangd] ExternalIndex turns off BackgroundIndex only if it isn't set

2020-11-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: ormris, MaskRay, ilya-biryukov.

This will enable users to have a `Background: Build` in their in-project
configs, while having an external index specification in their user
config file.

Depends on D90749 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90775

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -117,7 +117,7 @@
   Frag = {};
   Frag.Index.Background.emplace("Foo");
   EXPECT_TRUE(compileAndApply());
-  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Build)
+  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Auto)
   << "by default";
   EXPECT_THAT(
   Diags.Diagnostics,
@@ -205,13 +205,27 @@
   DiagKind(llvm::SourceMgr::DK_Error;
 }
 
-TEST_F(ConfigCompileTests, ExternalBlockDisablesBackgroundIndex) {
+TEST_F(ConfigCompileTests, ExternalBlockAndBackgroundIndex) {
   Parm.Path = "/foo/bar/baz.h";
-  Frag.Index.Background.emplace("Build");
-  Fragment::IndexBlock::ExternalBlock External;
-  External.File.emplace("/foo");
-  External.MountPoint.emplace("/foo/bar");
-  Frag.Index.External = std::move(External);
+  auto CreateFragWithBackground = [](llvm::StringRef Background) {
+Fragment::IndexBlock::ExternalBlock External;
+External.File.emplace("/foo");
+External.MountPoint.emplace("/foo/bar");
+
+Fragment Frag;
+Frag.Index.External = std::move(External);
+if (!Background.empty())
+  Frag.Index.Background.emplace(Background.str());
+return Frag;
+  };
+
+  // Preserves when explicitly mentioned.
+  Frag = CreateFragWithBackground("Build");
+  compileAndApply();
+  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Build);
+
+  // Overwrites to Skip otherwise.
+  Frag = CreateFragWithBackground("");
   compileAndApply();
   EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Skip);
 }
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -302,10 +302,10 @@
   else
 C.Index.External.Server.emplace(std::move(**External.Server));
 
-  // Disable background indexing for the files under the mountpoint.
-  // Note that this will overwrite statements in any previous fragments
-  // (including the current one).
-  C.Index.Background = Config::BackgroundPolicy::Skip;
+  // Disable background indexing for the files under the mountpoint. If
+  // user didn't take any explicit actions.
+  if (C.Index.Background == Config::BackgroundPolicy::Auto)
+C.Index.Background = Config::BackgroundPolicy::Skip;
 });
   }
 
Index: clang-tools-extra/clangd/Config.h
===
--- clang-tools-extra/clangd/Config.h
+++ clang-tools-extra/clangd/Config.h
@@ -57,11 +57,11 @@
 Edits;
   } CompileFlags;
 
-  enum class BackgroundPolicy { Build, Skip };
+  enum class BackgroundPolicy { Auto, Build, Skip };
   /// Controls background-index behavior.
   struct {
 /// Whether this TU should be indexed.
-BackgroundPolicy Background = BackgroundPolicy::Build;
+BackgroundPolicy Background = BackgroundPolicy::Auto;
 /// Describes an external index configuration. At most one of Server or 
File
 /// will be set at a time.
 struct {


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -117,7 +117,7 @@
   Frag = {};
   Frag.Index.Background.emplace("Foo");
   EXPECT_TRUE(compileAndApply());
-  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Build)
+  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Auto)
   << "by default";
   EXPECT_THAT(
   Diags.Diagnostics,
@@ -205,13 +205,27 @@
   DiagKind(llvm::SourceMgr::DK_Error;
 }
 
-TEST_F(ConfigCompileTests, ExternalBlockDisablesBackgroundIndex) {
+TEST_F(ConfigCompileTests, ExternalBlockAndBackgroundIndex) {
   Parm.Path = "/foo/bar/baz.h";
-  Frag.Index.Background.emplace("Build");
-  Fragment::IndexBlock::ExternalBlock External;
-  External.File.emplace("/foo");
-  External.MountPoint.emp

[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 302898.
cchen added a comment.

Refactor


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK1
+
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i64] [i64 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+// CK1: [[MTYPE02:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+
+void add_one(float *b, int dm)
+{
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE02]]
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+#pragma omp target data map(tofrom:b[:1]) use_device_ptr(b) if(dm == 0)
+  {
+#pragma omp target is_device_ptr(b)
+  {
+b[0] += 1;
+  }
+  }
+}
+
+#endif
+#endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -613,7 +613,8 @@
 /// Return true if a target region entry with the provided information
 /// exists.
 bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum) const;
+  StringRef ParentName, unsigned LineNum,
+  bool IgnoreAddressId = false) const;
 /// brief Applies action \a Action on all registered entries.
 typedef llvm::function_ref
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2955,6 +2955,13 @@
 En

[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

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


[clang] d0d43b5 - [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread via cfe-commits

Author: cchen
Date: 2020-11-04T12:36:57-06:00
New Revision: d0d43b58b109c2945e30d0bfabe77d3dcf1e4ad5

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

LOG: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger 
asserts

Clang now asserts for the below case:
```
void clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata(): 
Assertion `std::get<0>(E) && "All ordered entries must exist!"' failed.
```

The reason why Clang hit the assert is because in
`emitTargetDataCalls`, both `BeginThenGen` and `BeginElseGen` call
`registerTargetRegionEntryInfo` and try to register the Entry in
OffloadEntriesTargetRegion with same key. If changing the expression in
if clause to any constant expression, then the assert disappear. 
(https://godbolt.org/z/TW7haj)

The assert itself is to avoid
user from accessing elements out of bound inside `OrderedEntries` in
`createOffloadEntriesAndInfoMetadata`.

In this patch, I add a check in `registerTargetRegionEntryInfo` to avoid
register the target region more than once.

A test case that triggers assert: https://godbolt.org/z/4cnGW8

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index f62b64795f8d..05a987bb04f1 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2955,6 +2955,13 @@ void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
 Entry.setID(ID);
 Entry.setFlags(Flags);
   } else {
+if (Flags ==
+OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion &&
+hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
+ /*IgnoreAddressId*/ true))
+  return;
+assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) &&
+   "Target region entry already registered!");
 OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum, Addr, ID, Flags);
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] = Entry;
 ++OffloadingEntriesNum;
@@ -2962,8 +2969,8 @@ void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
 }
 
 bool CGOpenMPRuntime::OffloadEntriesInfoManagerTy::hasTargetRegionEntryInfo(
-unsigned DeviceID, unsigned FileID, StringRef ParentName,
-unsigned LineNum) const {
+unsigned DeviceID, unsigned FileID, StringRef ParentName, unsigned LineNum,
+bool IgnoreAddressId) const {
   auto PerDevice = OffloadEntriesTargetRegion.find(DeviceID);
   if (PerDevice == OffloadEntriesTargetRegion.end())
 return false;
@@ -2977,7 +2984,8 @@ bool 
CGOpenMPRuntime::OffloadEntriesInfoManagerTy::hasTargetRegionEntryInfo(
   if (PerLine == PerParentName->second.end())
 return false;
   // Fail if this entry is already registered.
-  if (PerLine->second.getAddress() || PerLine->second.getID())
+  if (!IgnoreAddressId &&
+  (PerLine->second.getAddress() || PerLine->second.getID()))
 return false;
   return true;
 }

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index d67034cb3de6..8da028d06de8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -613,7 +613,8 @@ class CGOpenMPRuntime {
 /// Return true if a target region entry with the provided information
 /// exists.
 bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum) 
const;
+  StringRef ParentName, unsigned LineNum,
+  bool IgnoreAddressId = false) const;
 /// brief Applies action \a Action on all registered entries.
 typedef llvm::function_ref

diff  --git a/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp 
b/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
new file mode 100644
index ..2a57497b5fd6
--- /dev/null
+++ b/clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopen

[PATCH] D90704: [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts

2020-11-04 Thread Chi Chun Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0d43b58b109: [OpenMP] target nested `use_device_ptr() if()` 
and is_device_ptr trigger asserts (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90704

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
@@ -0,0 +1,48 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK1
+
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i64] [i64 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+// CK1: [[MTYPE02:@.+]] = {{.*}}constant [1 x i64] [i64 288]
+
+void add_one(float *b, int dm)
+{
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: store float* [[B_ADDR:%.+]], float** [[CBP]]
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load float*, float** [[PVT]],
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE01]]
+  // CK1: call i32 @__tgt_target{{.+}}[[MTYPE02]]
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+#pragma omp target data map(tofrom:b[:1]) use_device_ptr(b) if(dm == 0)
+  {
+#pragma omp target is_device_ptr(b)
+  {
+b[0] += 1;
+  }
+  }
+}
+
+#endif
+#endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -613,7 +613,8 @@
 /// Return true if a target region entry with the provided information
 /// exists.
 bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum) const;
+  StringRef ParentName, unsigned LineNum,
+  bool IgnoreAddressId = false) const;
 /// brief Applies action \a Action on all registered entries.
 typedef llvm::function_ref
Index: clang/lib/CodeGen/CGOpenMPRuntim

[PATCH] D90714: [clang]Fix length threshold for MicrosoftMangle md5 hash

2020-11-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 302902.
mibintc added a comment.

Add lit test case, based on test case in bug report


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90714

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-md5.cpp


Index: clang/test/CodeGenCXX/mangle-ms-md5.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-md5.cpp
+++ clang/test/CodeGenCXX/mangle-ms-md5.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple i686-pc-win32 %s | FileCheck %s
+// RUN: %clang_cc1 -DNEED_MD5=1 -emit-llvm -o - -triple i686-pc-win32 %s | 
FileCheck --check-prefix=CHECK-MD5 %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-pc-win32 %s | FileCheck 
--check-prefix=CHECK-NOMD5 %s
 int 
xxx;
 // CHECK-DAG: @"??@bf7ea7b95f2

[PATCH] D90714: [clang]Fix length threshold for MicrosoftMangle md5 hash

2020-11-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D90714#2372458 , @dblaikie wrote:

> Test case?

Thanks, done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90714

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


[PATCH] D90486: [NewPM] Add OptimizationLevel param to TargetMachine::registerPassBuilderCallbacks()

2020-11-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Target/BPF/BPFTargetMachine.cpp:129
 bool DebugPassManager) {
   PB.registerPipelineStartEPCallback([=](ModulePassManager &MPM) {
 FunctionPassManager FPM(DebugPassManager);

ychen wrote:
> Maybe I missed something. Except for PipelineStartEPCallback, all the other 
> EP callbacks already take `OptimizationLevel` as input, do we only need to 
> extend PipelineStartEPCallback to also take `OptimizationLevel` as input?
You're right, I didn't realize that. https://reviews.llvm.org/D90777 for that 
approach


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90486

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


  1   2   >