[PATCH] D95714: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 320286.
poelmanc added a comment.

Fix test failure in `modernize-use-nullptr-cxx20.cpp` by replacing `#include 
` with some minimal equivalent `std` code.


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

https://reviews.llvm.org/D95714

Files:
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+// Not all systems have #include  to define std::std_ordering
+// required by operator<=>, so recreate minimal version for tests below.
+namespace std {
+
+struct strong_ordering {
+  static const strong_ordering less;
+  static const strong_ordering equal;
+  static const strong_ordering greater;
+  using zero_type = decltype(nullptr);
+
+  friend constexpr bool operator<(const strong_ordering value, zero_type) 
noexcept {
+return value.comparison_value < 0;
+  }
+
+  friend constexpr bool operator>(const strong_ordering value, zero_type) 
noexcept {
+return value.comparison_value > 0;
+  }
+
+  friend constexpr bool operator>=(const strong_ordering value, zero_type) 
noexcept {
+return value.comparison_value >= 0;
+  }
+
+  signed char comparison_value;
+};
+
+inline constexpr strong_ordering strong_ordering::less{-1};
+inline constexpr strong_ordering strong_ordering::equal{0};
+inline constexpr strong_ordering strong_ordering::greater{1};
+
+} // namespace std
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+}
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -45,6 +45,8 @@
   TK_AsIs,
   castExpr(anyOf(ImplicitCastToNull,
  explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+   // Skip implicit casts to 0 generated by operator<=> rewrites.
+   unless(hasAncestor(cxxRewrittenBinaryOperator())),
unless(hasAncestor(explicitCastExpr(
   .bind(CastSequence));
 }


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+// Not all systems have #include  to define std::std_ordering
+// required by operator<=>, so recreate minimal version for tests below.
+namespace std {
+
+struct strong_ordering {
+  static const strong_ordering less;
+  static const strong_ordering equal;
+  static const strong_ordering greater;
+  using zero_type = decltype(nullptr);
+
+  friend constexpr bool operator<(const strong_ordering value, zero_type) noexcept {
+return value.comparison_value < 0;
+  }
+
+  friend constexpr bool operator>(const strong_ordering value, zero_type) noexcept {
+return value.comparison_value > 0;
+  }
+
+  friend constexpr bool operator>=(const strong_ordering value, zero_type) noexcept {
+return value.comparison_value >= 0;
+  }
+
+  signed char comparison_value;
+};
+
+inline constexpr strong_ordering strong_ordering::less{-1};
+inline constexpr strong_ordering strong_ordering::equal{0};
+inline constexpr strong_ordering strong_ordering::greater{1};
+
+} // namespace std
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+}
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -45,6 +45,8 @@
   TK_AsIs,
   castExpr(anyOf(ImplicitCastToNull,
  explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+   // Skip implicit casts to 0 generated by operator<=> rewrites.
+   

[PATCH] D95726: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons - hasGrandparent version

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Fix test failure in `modernize-use-nullptr-cxx20.cpp` by replacing `#include 
` with some minimal equivalent `std` code.


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

https://reviews.llvm.org/D95726

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


[PATCH] D95726: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons - hasGrandparent version

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Fixed test failure in `modernize-use-nullptr-cxx20.cpp` by replacing `#include 
` with some minimal equivalent `std` code.


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

https://reviews.llvm.org/D95726

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


[PATCH] D95726: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons - hasGrandparent version

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 320284.
poelmanc added a comment.

Fix test failure in `modernize-use-nullptr-cxx20.cpp` by replacing `#include 
` with some minimal equivalent `std` code.


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

https://reviews.llvm.org/D95726

Files:
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -659,6 +659,8 @@
   ResultCache.clear();
 if (MatchMode == AncestorMatchMode::AMM_ParentOnly)
   return matchesParentOf(Node, Matcher, Builder);
+else if (MatchMode == AncestorMatchMode::AMM_GrandparentOnly)
+  return matchesGrandparentOf(Node, Matcher, Builder);
 return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
   }
 
@@ -893,6 +895,18 @@
 return false;
   }
 
+  // Returns whether a direct grandparent of \p Node matches \p Matcher.
+  bool matchesGrandparentOf(const DynTypedNode &Node,
+  const DynTypedMatcher &Matcher,
+  BoundNodesTreeBuilder *Builder) {
+for (const auto &Parent : ActiveASTContext->getParents(Node)) {
+  if (matchesParentOf(Parent, Matcher, Builder)) {
+return true;
+  }
+}
+return false;
+  }
+
   // Returns whether an ancestor of \p Node matches \p Matcher.
   //
   // The order of matching (which can lead to different nodes being bound in
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -654,7 +654,10 @@
 AMM_All,
 
 /// Direct parent only.
-AMM_ParentOnly
+AMM_ParentOnly,
+
+/// Direct grandparent only.
+AMM_GrandparentOnly
   };
 
   virtual ~ASTMatchFinder() = default;
@@ -1654,6 +1657,29 @@
   }
 };
 
+/// Matches nodes of type \c T that have a grandparent node of type
+/// \c GrandparentT for which the given inner matcher matches.
+///
+/// \c GrandparentT must be an AST base type.
+template 
+class HasGrandparentMatcher : public MatcherInterface {
+  static_assert(IsBaseType::value,
+"has parent only accepts base type matcher");
+
+  const DynTypedMatcher GrandparentMatcher;
+
+public:
+  explicit HasGrandparentMatcher(
+  const Matcher &GrandparentMatcher)
+  : GrandparentMatcher(GrandparentMatcher) {}
+
+  bool matches(const T &Node, ASTMatchFinder *Finder,
+   BoundNodesTreeBuilder *Builder) const override {
+return Finder->matchesAncestorOf(Node, this->GrandparentMatcher, Builder,
+ ASTMatchFinder::AMM_GrandparentOnly);
+  }
+};
+
 /// Matches nodes of type \c T that have at least one ancestor node of
 /// type \c AncestorT for which the given inner matcher matches.
 ///
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3434,6 +3434,22 @@
 internal::TypeList>
 hasParent;
 
+/// Matches AST nodes that have a grandparent that matches the provided
+/// matcher.
+///
+/// Given
+/// \code
+/// void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
+/// \endcode
+/// \c compoundStmt(hasGrandparent(forStmt())) matches "{ int x = 43; }".
+///
+/// Usable as: Any Matcher
+extern const internal::ArgumentAdaptingMatcherFunc<
+internal::HasGrandparentMatcher,
+internal::TypeList,
+internal::TypeList>
+hasGrandparent;
+
 /// Matches AST nodes that have an ancestor that matches the provided
 /// matcher.
 ///
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+// Not all systems have #include  to define std::std_ordering
+// required by operator<=>, so recreate minimal version for tests below.
+namespace std {
+
+struct strong_ordering {
+  static const strong_ordering less;
+  static const strong_ordering equal;
+  static const strong_ordering greater;
+  using zero_type = decltype(nullptr);
+
+  friend constexpr bool operator<(const strong_ordering value, zero_type) noexcept {
+return value.comparison_value < 0;
+  }
+
+  friend constexpr bool operator>(const strong_ordering value, zero_type) noexcept 

[PATCH] D95726: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons - hasGrandparent version

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc created this revision.
poelmanc added reviewers: aaron.ballman, angelgarcia, hokein.
poelmanc added a project: clang-tools-extra.
Herald added a subscriber: yaxunl.
poelmanc requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As in https://reviews.llvm.org/D95714, `clang-tidy -std=c++20` with 
`modernize-use-nullptr` mistakenly inserts `nullptr` in place of the comparison 
operator if the comparison internally expands in the AST to a rewritten 
spaceship operator. This can be reproduced by running the new 
`modernize-use-nullptr-cxx20.cpp` test without applying the supplied patch to 
UseNullptrCheck.cpp; the current clang-tidy will mistakenly replace:

  result = (a1 < a2);

with

  result = (a1 nullptr a2);

Oops!

The supplied patch fixes this by adding just one comment and one line of code 
to UseNullptrCheck.cpp:

  // Skip implicit casts to 0 generated by operator<=> rewrites.
  unless(hasGrandparent(cxxRewrittenBinaryOperator())),

It also adds the new `hasGrandparent` matcher, which is necessary as opposed to 
`hasAncestor` to properly convert:

  result = (a1 > (ptr == 0 ? a1 : a2));

to

  result = (a1 > (ptr == nullptr ? a1 : a2));

In this case the AST has an "ancestor" that is a rewritten binary operator, but 
not a direct grandparent.

This is an alternative to https://reviews.llvm.org/D95714.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95726

Files:
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -659,6 +659,8 @@
   ResultCache.clear();
 if (MatchMode == AncestorMatchMode::AMM_ParentOnly)
   return matchesParentOf(Node, Matcher, Builder);
+else if (MatchMode == AncestorMatchMode::AMM_GrandparentOnly)
+  return matchesGrandparentOf(Node, Matcher, Builder);
 return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
   }
 
@@ -893,6 +895,18 @@
 return false;
   }
 
+  // Returns whether a direct grandparent of \p Node matches \p Matcher.
+  bool matchesGrandparentOf(const DynTypedNode &Node,
+  const DynTypedMatcher &Matcher,
+  BoundNodesTreeBuilder *Builder) {
+for (const auto &Parent : ActiveASTContext->getParents(Node)) {
+  if (matchesParentOf(Parent, Matcher, Builder)) {
+return true;
+  }
+}
+return false;
+  }
+
   // Returns whether an ancestor of \p Node matches \p Matcher.
   //
   // The order of matching (which can lead to different nodes being bound in
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -654,7 +654,10 @@
 AMM_All,
 
 /// Direct parent only.
-AMM_ParentOnly
+AMM_ParentOnly,
+
+/// Direct grandparent only.
+AMM_GrandparentOnly
   };
 
   virtual ~ASTMatchFinder() = default;
@@ -1654,6 +1657,29 @@
   }
 };
 
+/// Matches nodes of type \c T that have a grandparent node of type
+/// \c GrandparentT for which the given inner matcher matches.
+///
+/// \c GrandparentT must be an AST base type.
+template 
+class HasGrandparentMatcher : public MatcherInterface {
+  static_assert(IsBaseType::value,
+"has parent only accepts base type matcher");
+
+  const DynTypedMatcher GrandparentMatcher;
+
+public:
+  explicit HasGrandparentMatcher(
+  const Matcher &GrandparentMatcher)
+  : GrandparentMatcher(GrandparentMatcher) {}
+
+  bool matches(const T &Node, ASTMatchFinder *Finder,
+   BoundNodesTreeBuilder *Builder) const override {
+return Finder->matchesAncestorOf(Node, this->GrandparentMatcher, Builder,
+ ASTMatchFinder::AMM_GrandparentOnly);
+  }
+};
+
 /// Matches nodes of type \c T that have at least one ancestor node of
 /// type \c AncestorT for which the given inner matcher matches.
 ///
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3434,6 +3434,22 @@
 internal::TypeList>
 hasParent;
 
+/// Matches AST nodes that have a grandparent that matches the provided
+/// matcher.
+///
+/// Given
+/// \code
+/// void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
+/// \endcode
+/// \c compoundStmt(hasGrandparent(forStmt())) matches "{ int x = 43; }".
+///

[PATCH] D95608: [OpenCL][PR48896] Fix address space in binding of initializer lists to references

2021-01-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4297
+  ? S.Context.getQualifiedType(T1, T1Quals.withoutAddressSpace())
+  : cv1T1;
   // Not reference-related. Create a temporary and bind to that.

Should we be rejecting this path immediately if the address space in T1 can't 
be converted to from the address space of temporaries?



Comment at: clang/lib/Sema/SemaInit.cpp:4308
+  if (T1Quals.hasAddressSpace())
+Sequence.AddQualificationConversionStep(cv1T1, VK_XValue);
+} else

This should only be `VK_XValue` if we're binding a r-value reference, I think.


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

https://reviews.llvm.org/D95608

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


[PATCH] D95725: clang-extra: fix incorrect use of std::lock_guard by adding variable name (identified by MSVC [[nodiscard]] error)

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc created this revision.
poelmanc added reviewers: sammccall, ilya-biryukov.
poelmanc added a project: clang-tools-extra.
Herald added subscribers: usaxena95, kadircet, arphaman.
poelmanc requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`std::lock_guard` is an RAII class that needs a variable name whose scope 
determines the guard's lifetime. This particular usage lacked a variable name, 
meaning the guard could be destroyed before the line that it was indented to 
protect.

This line was identified by building clang with the latest MSVC preview 
release, which declares the std::lock_guard constructor to be `[[nodiscard]]` 
to draw attention to such issues.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95725

Files:
  clang-tools-extra/clangd/support/Function.h


Index: clang-tools-extra/clangd/support/Function.h
===
--- clang-tools-extra/clangd/support/Function.h
+++ clang-tools-extra/clangd/support/Function.h
@@ -51,7 +51,7 @@
 Subscription &operator=(Subscription &&Other) {
   // If *this is active, unsubscribe.
   if (Parent) {
-std::lock_guard(Parent->ListenersMu);
+std::lock_guard Guard(Parent->ListenersMu);
 llvm::erase_if(Parent->Listeners,
[&](const std::pair &P) {
  return P.second == ListenerID;


Index: clang-tools-extra/clangd/support/Function.h
===
--- clang-tools-extra/clangd/support/Function.h
+++ clang-tools-extra/clangd/support/Function.h
@@ -51,7 +51,7 @@
 Subscription &operator=(Subscription &&Other) {
   // If *this is active, unsubscribe.
   if (Parent) {
-std::lock_guard(Parent->ListenersMu);
+std::lock_guard Guard(Parent->ListenersMu);
 llvm::erase_if(Parent->Listeners,
[&](const std::pair &P) {
  return P.second == ListenerID;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95714: clang-tidy: modernize-use-nullptr mistakenly fixes rewritten spaceship operator comparisons

2021-01-29 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc created this revision.
poelmanc added reviewers: aaron.ballman, angelgarcia, hokein.
poelmanc added a project: clang-tools-extra.
Herald added a subscriber: yaxunl.
poelmanc requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`clang-tidy -std=c++20` with `modernize-use-nullptr` mistakenly inserts 
`nullptr` in place of the comparison operator if the comparison internally 
expands in the AST to a rewritten spaceship operator. This can be reproduced by 
running the new `modernize-use-nullptr-cxx20.cpp` test without applying the 
supplied patch to `UseNullptrCheck.cpp`; the current clang-tidy will mistakenly 
replace:

  result = (a1 < a2);

with

  result = (a1 nullptr a2);

Oops!

The supplied patch fixes this by adding just one comment and one line of code 
to `UseNullptrCheck.cpp`:

  // Skip implicit casts to 0 generated by operator<=> rewrites.
  unless(hasAncestor(cxxRewrittenBinaryOperator())),

I looked for a `hasGrandparent` matcher which would be more precise, but none 
exists. This fix slightly overly-aggressively eliminates matches, so even with 
this patch `modernize-use-nullptr` will not convert

  result = (a1 > (ptr == 0 ? a1 : a2));

to

  result = (a1 > (ptr == nullptr ? a1 : a2));

because `ptr == 0` has an ancestor that is a rewritten spaceship operator. 
Changing the proposed one-line fix to:

  unless(hasGrandparent(cxxRewrittenBinaryOperator())),

resolves this, but requires another 57 lines of code across AstMatchers.h, 
AstMatchersInternal.h, and AstMatchFinder.cpp to create `hasGrandparent`. I'd 
be happy to supply that patch instead if folks think it worthwhile? Maybe 
others in the future can benefit from `hasGrandparent`?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95714

Files:
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+#include 
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+}
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -45,6 +45,8 @@
   TK_AsIs,
   castExpr(anyOf(ImplicitCastToNull,
  explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+   // Skip implicit casts to 0 generated by operator<=> rewrites.
+   unless(hasAncestor(cxxRewrittenBinaryOperator())),
unless(hasAncestor(explicitCastExpr(
   .bind(CastSequence));
 }


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-cxx20.cpp
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-nullptr %t
+
+#include 
+
+class A {
+public:
+  auto operator<=>(const A &other) const = default;
+};
+
+void test_cxx_rewritten_binary_ops() {
+  A a1, a2;
+  bool result;
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 < a2);
+  // CHECK-FIXES: result = (a1 < a2);
+  // should not change next line to (a1 nullptr a2)
+  result = (a1 >= a2);
+  // CHECK-FIXES: result = (a1 >= a2);
+}
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -45,6 +45,8 @@
   TK_AsIs,
   castExpr(anyOf(ImplicitCastToNull,
  explicitCastExpr(hasDescendant(ImplicitCastToNull))),
+   // Skip implicit casts to 0 generated by operator<=> rewrites.
+   unless(hasAncestor(cxxRewrittenBinaryOperator())),
unless(hasAncestor(explicitCastExpr(
   .bind(CastSequence));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94844: [VFS] Add support to RedirectingFileSystem for mapping a virtual directory to one in the external FS.

2021-01-29 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes updated this revision to Diff 320257.
nathawes marked an inline comment as done.
nathawes edited the summary of this revision.
nathawes set the repository for this revision to rG LLVM Github Monorepo.
nathawes added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

- Updated shouldFallBackToExternalFS() to accept an Entry * rather than an 
Optional to avoid an unnecessary copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94844

Files:
  clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
  clang/test/VFS/Inputs/vfsoverlay-directory.yaml
  clang/test/VFS/directory.c
  lldb/source/Host/common/FileSystem.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1328,6 +1328,7 @@
 
 TEST_F(VFSFromYAMLTest, MappedFiles) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
   Lower->addRegularFile("//root/foo/bar/a");
   IntrusiveRefCntPtr FS = getFromYAMLString(
   "{ 'roots': [\n"
@@ -1343,6 +1344,17 @@
   "  'type': 'file',\n"
   "  'name': 'file2',\n"
   "  'external-contents': '//root/foo/b'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir',\n"
+  "  'external-contents': '//root/foo/bar'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir2',\n"
+  "  'use-external-name': false,\n"
+  "  'external-contents': '//root/foo/bar'\n"
   "}\n"
   "  ]\n"
   "}\n"
@@ -1380,12 +1392,221 @@
   EXPECT_TRUE(S->isDirectory());
   EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID
 
+  // remapped directory
+  S = O->status("//root/mappeddir");
+  ASSERT_FALSE(S.getError());
+  EXPECT_TRUE(S->isDirectory());
+  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar")));
+
+  SLower = O->status("//root/foo/bar");
+  EXPECT_EQ("//root/foo/bar", SLower->getName());
+  EXPECT_TRUE(S->equivalent(*SLower));
+  EXPECT_FALSE(SLower->IsVFSMapped);
+
+  // file in remapped directory
+  S = O->status("//root/mappeddir/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/foo/bar/a", S->getName());
+
+  // file in remapped directory, with use-external-name=false
+  S = O->status("//root/mappeddir2/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+
+  // file contents in remapped directory
+  OpenedF = O->openFileForRead("//root/mappeddir/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  // file contents in remapped directory, with use-external-name=false
+  OpenedF = O->openFileForRead("//root/mappeddir2/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
 llvm::errc::no_such_file_or_directory);
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, MappedRoot) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
+  Lower->addRegularFile("//root/foo/bar/a");
+  IntrusiveRefCntPtr FS =
+  getFromYAMLString("{ 'roots': [\n"
+"{\n"
+"  'type': 'directory-remap',\n"
+"  'name': '//mappedroot/',\n"
+"  'external-contents': '//root/foo/bar'\n"
+"}\n"
+"]\n"
+"}",
+Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(FS);
+
+  // file
+  ErrorOr S = O->status("//mappedroot/a");
+  ASSERT_FALSE(S.getError());
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
+  EXPECT_TRUE(S->IsVFSMapped);
+
+  ErrorOr SLower = O->status("//root/foo/bar/a");
+  EXPECT_EQ("//root/foo/bar/a", SLower->getName());
+  EXPECT_TRUE(S->equivalent(*SLower

[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 320256.
mtrofin added a comment.

indent


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

Files:
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/cuda-detect.cu
  clang/test/Driver/fsanitize.c
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/ps4-visibility-dllstorageclass.c
  clang/test/Driver/rocm-device-libs.cl

Index: clang/test/Driver/rocm-device-libs.cl
===
--- clang/test/Driver/rocm-device-libs.cl
+++ clang/test/Driver/rocm-device-libs.cl
@@ -78,46 +78,46 @@
 // RUN:   -x cl -mcpu=gfx803 \
 // RUN:   -cl-unsafe-math-optimizations \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1011\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1011,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1012\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1012,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64 -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // Ignore -mno-wavefrontsize64 without wave32 support
 // RUN: %clang -### -target amdgcn-amd-amdhsa   \
 // RUN:   -x cl -mcpu=gfx803  -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm\
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefixes=GFX803,WAVE64 %s
 
 
 
Index: clang/test/Driver/ps4-visibility-dllstorageclass.c
===
--- clang/test/Driver/ps4-visibility-dllstorageclass.c
+++ clang/test/Driver/ps4-visibility-dllstorageclass.c
@@ -1,7 +1,7 @@
 // Check behaviour of -fvisibility-from-dllstorageclass options for PS4
 
 // RUN: %clang -### -target x86_64-scei-ps4 %s -Werror -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS1 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
@@ -13,7 +13,7 @@
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -Werror \
 // RUN: %s -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS2 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,3 +1,11 @@
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.hip']
 config.substitutions = list(config.substitutions)
Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -15,11 +15,11 @@
 // RUN: %clang -target x86_64-apple-darwin

[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/rocm-device-libs.cl:82
 // RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 
%s
+// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 

mtrofin wrote:
> MaskRay wrote:
> > Since you changing the lines, consider indenting `2>&1`
> > 
> > The most common style is to place `2>&1 | \` on the previous line.
> done
All the continuation lines should be indented, i.e. `FileCheck` needs to be 
indented...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added inline comments.



Comment at: clang/test/Driver/rocm-device-libs.cl:82
 // RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 
%s
+// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 

MaskRay wrote:
> Since you changing the lines, consider indenting `2>&1`
> 
> The most common style is to place `2>&1 | \` on the previous line.
done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 320246.
mtrofin marked an inline comment as done.
mtrofin added a comment.

cleaned up the RUN line for rocm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

Files:
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/cuda-detect.cu
  clang/test/Driver/fsanitize.c
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/ps4-visibility-dllstorageclass.c
  clang/test/Driver/rocm-device-libs.cl

Index: clang/test/Driver/rocm-device-libs.cl
===
--- clang/test/Driver/rocm-device-libs.cl
+++ clang/test/Driver/rocm-device-libs.cl
@@ -78,46 +78,46 @@
 // RUN:   -x cl -mcpu=gfx803 \
 // RUN:   -cl-unsafe-math-optimizations \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1011\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1011,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1012\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1012,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefix=WAVE32 %s
 
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefix=WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64 -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefix=WAVE32 %s
 
 // Ignore -mno-wavefrontsize64 without wave32 support
 // RUN: %clang -### -target amdgcn-amd-amdhsa   \
 // RUN:   -x cl -mcpu=gfx803  -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm\
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN: FileCheck  --check-prefixes=GFX803,WAVE64 %s
 
 
 
Index: clang/test/Driver/ps4-visibility-dllstorageclass.c
===
--- clang/test/Driver/ps4-visibility-dllstorageclass.c
+++ clang/test/Driver/ps4-visibility-dllstorageclass.c
@@ -1,7 +1,7 @@
 // Check behaviour of -fvisibility-from-dllstorageclass options for PS4
 
 // RUN: %clang -### -target x86_64-scei-ps4 %s -Werror -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS1 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
@@ -13,7 +13,7 @@
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -Werror \
 // RUN: %s -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS2 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,3 +1,11 @@
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.hip']
 config.substitutions = list(config.substitutions)
Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -15,11

[PATCH] D95706: [clangd] Expose more dependent-name detail via semanticTokens

2021-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: nridge.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This change makes dependentName a modifier, rather than a token type.
It can be combined with:

- type (new, standard) - this combination replaces dependentType like 
T::typename Foo
- unknown (new, nonstandard) - for general dependent names
- Field, etc - when the name is dependent but we heuristically resolve it

While here, fix cases where template-template-parameter cases were
incorrectly flagged as type-dependent.
And the merging of modifiers when resolving conflicts accidentally
happens to work around a bug that showed up in a test.

The behavior observed through the pre-standard protocol should be mostly
unchanged (it'll see the bugfixes only). This is done in a somehat
fragile way but it's not expected to live long.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95706

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -58,8 +58,8 @@
   {HighlightingKind::Method, "Method"},
   {HighlightingKind::StaticMethod, "StaticMethod"},
   {HighlightingKind::Typedef, "Typedef"},
-  {HighlightingKind::DependentType, "DependentType"},
-  {HighlightingKind::DependentName, "DependentName"},
+  {HighlightingKind::Type, "Type"},
+  {HighlightingKind::Unknown, "Unknown"},
   {HighlightingKind::TemplateParameter, "TemplateParameter"},
   {HighlightingKind::Concept, "Concept"},
   {HighlightingKind::Primitive, "Primitive"},
@@ -198,7 +198,7 @@
   }
   template
   struct $Class_decl[[C]] : $Namespace[[abc]]::$Class[[A]]<$TemplateParameter[[T]]> {
-typename $TemplateParameter[[T]]::$DependentType[[A]]* $Field_decl[[D]];
+typename $TemplateParameter[[T]]::$Type_dependentName[[A]]* $Field_decl[[D]];
   };
   $Namespace[[abc]]::$Class[[A]] $Variable_decl[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]] $Class_decl[[AAA]];
@@ -332,11 +332,8 @@
   R"cpp(
   template 
   struct $Class_decl[[Tmpl]] {$TemplateParameter[[T]] $Field_decl[[x]] = 0;};
-  // FIXME: highlights dropped due to conflicts.
-  // explicitReferenceTargets reports ClassTemplateSpecializationDecl twice
-  // at its location, calling it a declaration/non-declaration once each.
-  extern template struct Tmpl;
-  template struct Tmpl;
+  extern template struct $Class_decl[[Tmpl]];
+  template struct $Class_decl[[Tmpl]];
 )cpp",
   // This test is to guard against highlightings disappearing when using
   // conversion operators as their behaviour in the clang AST differ from
@@ -559,7 +556,7 @@
   template 
   void $Function_decl[[foo]]($TemplateParameter[[T]] $Parameter_decl[[P]]) {
 $Function[[phase1]]($Parameter[[P]]);
-$DependentName[[phase2]]($Parameter[[P]]);
+$Unknown_dependentName[[phase2]]($Parameter[[P]]);
   }
 )cpp",
   R"cpp(
@@ -588,20 +585,20 @@
 )cpp",
   R"cpp(
   template 
-  void $Function_decl[[foo]](typename $TemplateParameter[[T]]::$DependentType[[Type]]
-= $TemplateParameter[[T]]::$DependentName[[val]]);
+  void $Function_decl[[foo]](typename $TemplateParameter[[T]]::$Type_dependentName[[Type]]
+= $TemplateParameter[[T]]::$Unknown_dependentName[[val]]);
 )cpp",
   R"cpp(
   template 
   void $Function_decl[[foo]]($TemplateParameter[[T]] $Parameter_decl[[P]]) {
-$Parameter[[P]].$DependentName[[Field]];
+$Parameter[[P]].$Unknown_dependentName[[Field]];
   }
 )cpp",
   R"cpp(
   template 
   class $Class_decl[[A]] {
 int $Method_decl[[foo]]() {
-  return $TemplateParameter[[T]]::$DependentName[[Field]];
+  return $TemplateParameter[[T]]::$Unknown_dependentName[[Field]];
 }
   };
 )cpp",
@@ -664,15 +661,15 @@
   template 
   struct $Class_decl[[Waldo]] {
 using $Typedef_decl[[Location1]] = typename $TemplateParameter[[T]]
-::$DependentType[[Resolver]]::$DependentType[[Location]];
+::$Type_dependentName[[Resolver]]::$Type_dependentName[[Location]];
 using $Typedef_decl[[Location2]] = typename $TemplateParameter[[T]]
-::template $DependentType[[Resolver]]<$TemplateParameter[[T]]>
-   

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

My apologies for misrepresenting the meaning of the docs and stirring up this 
confusion.  I did not read the docs carefully enough.

Replying on the mailing list ...




Comment at: clang/CMakeLists.txt:1
 cmake_minimum_required(VERSION 3.13.4)
 

Note that we already have a precedent for requiring the stated version with 
CMake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D94355: [SimplifyCFG] Add relative switch lookup tables

2021-01-29 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem marked an inline comment as done.
gulfem added a comment.

In D94355#2530225 , @lebedev.ri wrote:

> Can you please add an explanation to the patch's description as to why
> we don't want to instead convert non-relative/relative LUT's elsewhere,
> please.

@mcgrathr gave some explanation to that:

>> Many backends generate PIC-friendly jump tables. This is about generating IR 
>> initializers that translate to the same kind of backend assembly expressions 
>> as those backends use for their jump tables.

I also want to add to that:
This task specifically tries make switch-to-lookup tables PIC-friendly, but it 
does not necessarily try to make all the jump tables PIC-friendly.
There is also another work going on to generate PIC-friendly vtables.
Therefore, converting non-relative lookup tables to relative tables elsewhere 
can be explored as a separate task.




Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5512-5525
+  // If not in x86 or aarch64 mode, do not generate a relative lookup table.
+  Triple TargetTriple(M.getTargetTriple());
+  if (!(TargetTriple.getArch() == Triple::x86_64 ||
+TargetTriple.getArch() == Triple::aarch64))
+return false;
+
+  // If not tiny or small code model, do not generate a relative lookup table.

lebedev.ri wrote:
> This should be some TLI/TTI hook.
> This should be some TLI/TTI hook.
Could you please elaborate on that?
Are you talking about getting the PIC level?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D87928: Provide -fsource-dir flag in Clang

2021-01-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I'm picking up this change again after D83154  
landed. I did some tracing and it looks like `FileManager` already returns a 
relative path when relative path was passed to the compiler as you'd expect so 
I don't think we need to change anything there. It's 
CoverageMappingModuleGen::normalizeFilename 

 that makes the path absolute so perhaps if we restrict this change only to 
coverage mapping, perhaps we should just introduce a flag to disable that 
behavior, for example `-f[no]-normalize-coverage-mapping`, or to normalize 
paths as relative against a given directory, for example 
`-fcoverage-mapping-dir=[DIR]`. What do you think?


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

https://reviews.llvm.org/D87928

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


[PATCH] D95704: [CodeGen] Introduce DWARF tag for SwiftTail and emit it in CodeGen.

2021-01-29 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95704

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


[PATCH] D95704: [CodeGen] Introduce DWARF tag for SwiftTail and emit it in CodeGen.

2021-01-29 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple created this revision.
varungandhi-apple added a reviewer: aprantl.
varungandhi-apple requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

swifttailcc is a new calling convention in LLVM introduced
in https://reviews.llvm.org/D95443. We add a new DWARF tag to capture
this in debuginfo.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95704

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-cc.c
  llvm/include/llvm/BinaryFormat/Dwarf.def


Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -788,6 +788,7 @@
 HANDLE_DW_CC(0xc9, LLVM_PreserveMost)
 HANDLE_DW_CC(0xca, LLVM_PreserveAll)
 HANDLE_DW_CC(0xcb, LLVM_X86RegCall)
+HANDLE_DW_CC(0xcc, LLVM_SwiftTail)
 // From GCC source code (include/dwarf2.h): This DW_CC_ value is not currently
 // generated by any toolchain.  It is used internally to GDB to indicate 
OpenCL C
 // functions that have been compiled with the IBM XL C for OpenCL compiler and 
use
Index: clang/test/CodeGen/debug-info-cc.c
===
--- clang/test/CodeGen/debug-info-cc.c
+++ clang/test/CodeGen/debug-info-cc.c
@@ -57,9 +57,8 @@
   return a+b;
 }
 
-// [FIXME: swiftasynccc] Update debuginfo tag to SwiftAsync once LLVM support 
lands.
 // LINUX: !DISubprogram({{.*}}"add_swiftasynccall", {{.*}}type: ![[FTY:[0-9]+]]
-// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Swift,
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_SwiftTail,
 __attribute__((swiftasynccall)) int add_swiftasynccall(int a, int b) {
   return a+b;
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1249,8 +1249,7 @@
   case CC_Swift:
 return llvm::dwarf::DW_CC_LLVM_Swift;
   case CC_SwiftAsync:
-// [FIXME: swiftasynccc] Update to SwiftAsync once LLVM support lands.
-return llvm::dwarf::DW_CC_LLVM_Swift;
+return llvm::dwarf::DW_CC_LLVM_SwiftTail;
   case CC_PreserveMost:
 return llvm::dwarf::DW_CC_LLVM_PreserveMost;
   case CC_PreserveAll:


Index: llvm/include/llvm/BinaryFormat/Dwarf.def
===
--- llvm/include/llvm/BinaryFormat/Dwarf.def
+++ llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -788,6 +788,7 @@
 HANDLE_DW_CC(0xc9, LLVM_PreserveMost)
 HANDLE_DW_CC(0xca, LLVM_PreserveAll)
 HANDLE_DW_CC(0xcb, LLVM_X86RegCall)
+HANDLE_DW_CC(0xcc, LLVM_SwiftTail)
 // From GCC source code (include/dwarf2.h): This DW_CC_ value is not currently
 // generated by any toolchain.  It is used internally to GDB to indicate OpenCL C
 // functions that have been compiled with the IBM XL C for OpenCL compiler and use
Index: clang/test/CodeGen/debug-info-cc.c
===
--- clang/test/CodeGen/debug-info-cc.c
+++ clang/test/CodeGen/debug-info-cc.c
@@ -57,9 +57,8 @@
   return a+b;
 }
 
-// [FIXME: swiftasynccc] Update debuginfo tag to SwiftAsync once LLVM support lands.
 // LINUX: !DISubprogram({{.*}}"add_swiftasynccall", {{.*}}type: ![[FTY:[0-9]+]]
-// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Swift,
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_SwiftTail,
 __attribute__((swiftasynccall)) int add_swiftasynccall(int a, int b) {
   return a+b;
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1249,8 +1249,7 @@
   case CC_Swift:
 return llvm::dwarf::DW_CC_LLVM_Swift;
   case CC_SwiftAsync:
-// [FIXME: swiftasynccc] Update to SwiftAsync once LLVM support lands.
-return llvm::dwarf::DW_CC_LLVM_Swift;
+return llvm::dwarf::DW_CC_LLVM_SwiftTail;
   case CC_PreserveMost:
 return llvm::dwarf::DW_CC_LLVM_PreserveMost;
   case CC_PreserveAll:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Hsiangkai Wang 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 rG282aca10aeb0: [RISCV] Update the version number to v0.10 for 
vector. (authored by HsiangKai).

Changed prior to commit:
  https://reviews.llvm.org/D95680?vs=320125&id=320226#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95680

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,7 +40,7 @@
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v1p0"
+# CHECK: attribute  5, "rv32i2p0_v0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
@@ -79,7 +79,7 @@
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1"
 
 .attribute arch, "rv32ivzvamo_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 
-.attribute arch, "rv32iv_zvamo1p0_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+.attribute arch, "rv32iv_zvamo0p10_zvlsseg"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,7 +47,7 @@
 ; RV32D: .attribute 5, "rv32i2p0_f2p0_d2p0"
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32B: .attribute 5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
-; RV32V: .attribute 5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+; RV32V: .attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
 ; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
 ; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
@@ -60,7 +60,7 @@
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
 ; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -80,8 +80,8 @@
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
 ; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
-; RV64V: .attribute 5, "rv64i2p0_v1p0_zvamo1p0_zvlsseg1p0"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
+; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/RISCVInstrInfoV.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoV.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoV.td
@@ -7,7 +7,7 @@
 //===--===//
 ///
 /// This file describes the RISC-V instructions from the standard 'V' Vector
-/// extension, version 0.9.
+/// extension, version 0.10.
 /// This version is still experimental as the 'V' extension hasn't been
 /// ratified yet.
 ///
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -63,7 +63,7 @@
   if (STI.hasFeature(RISCV::FeatureStdExtB))
 Arch += "_b0p93";
   if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v1p0";
+Arch += "_v0p10";
   if (STI.hasFeature(RISCV::FeatureExtZfh))
 Arch += "_zfh0p1";
   if (STI.hasFeature(RISCV::FeatureExtZba))
@@ -89,9 +89,9 @@
   if (STI.hasFeature(RISCV::FeatureExtZbt))
 Arch += "_zbt0p93";
   if (STI.hasFeature(RISCV::FeatureExtZvamo))
-Arch += "_zvamo1p0";
+Arch += "_zvamo0p10";
   if (STI.hasFeature(RISCV::FeatureStdExtZvlsseg))
-Arch += "_zvlsseg1p0";
+Arch += "_zvlsseg0p10";
 
   emitTextAttribute(RISCVAttrs::ARCH, Arch);
 }
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
==

[clang] 282aca1 - [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-01-30T07:20:05+08:00
New Revision: 282aca10aeb03bdaef0a8d4f3faa4c2ff236e527

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

LOG: [RISCV] Update the version number to v0.10 for vector.

v0.10 is tagged in V specification. Update the version to v0.10.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoV.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 0bf02e605740..786201ea340d 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -150,7 +150,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   }
 
   if (HasV) {
-Builder.defineMacro("__riscv_v", "100");
+Builder.defineMacro("__riscv_v", "1");
 Builder.defineMacro("__riscv_vector");
   }
 
@@ -191,10 +191,10 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__riscv_zfh", "1000");
 
   if (HasZvamo)
-Builder.defineMacro("__riscv_zvamo", "100");
+Builder.defineMacro("__riscv_zvamo", "1");
 
   if (HasZvlsseg)
-Builder.defineMacro("__riscv_zvlsseg", "100");
+Builder.defineMacro("__riscv_zvlsseg", "1");
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index ffae47e5672e..c7f2a3ea5e02 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -63,7 +63,7 @@ isExperimentalExtension(StringRef Ext) {
   Ext == "zbr" || Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "93"};
   if (Ext == "v" || Ext == "zvamo" || Ext == "zvlsseg")
-return RISCVExtensionVersion{"1", "0"};
+return RISCVExtensionVersion{"0", "10"};
   if (Ext == "zfh")
 return RISCVExtensionVersion{"0", "1"};
   return None;

diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 3762a4aef1b3..cf148ca885d0 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -384,7 +384,7 @@
 // RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
 // RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for 
experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iv1p0 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p10 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
 // RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
 
@@ -412,7 +412,7 @@
 // RV32-EXPERIMENTAL-ZVAMO-BADVERS: error: invalid arch name 'rv32izvamo0p1'
 // RV32-EXPERIMENTAL-ZVAMO-BADVERS: unsupported version number 0.1 for 
experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo1p0 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvamo0p10 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVAMO-GOODVERS %s
 // RV32-EXPERIMENTAL-ZVAMO-GOODVERS: "-target-feature" "+experimental-zvamo"
 
@@ -431,6 +431,6 @@
 // RV32-EXPERIMENTAL-ZVLSSEG-BADVERS: error: invalid arch name 
'rv32izvlsseg0p1'
 // RV32-EXPERIMENTAL-ZVLSSEG-BADVERS: unsupported version number 0.1 for 
experimental extension
 
-// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg1p0 
-menable-experimental-extensions -### %s -c 2>&1 | \
+// RUN: %clang -target riscv32-unknown-elf -march=rv32izvlsseg0p10 
-menable-experimental-extensions -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-EXPERIMENTAL-ZVLSSEG-GOODVERS %s
 // RV32-EXPERIMENTAL-ZVLSSEG-GOODVERS: "-target-feature" 
"+experimental-zvlsseg"

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 006395505246..88826bbd60b8 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -110,23 +110,23 @@
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
 
 // RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN:   -march=rv32iv1p0 -x

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Thanks for brining this up on the mailing list, I think that's a good place to 
discuss!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D95680#2530775 , @asb wrote:

> LGTM modulo one additional request: please update the comment at the top of 
> RISCVInstrInfoV.td to say "0.10" rather than "0.9".

Thanks for pointing it out. I will do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95680

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


[PATCH] D95702: [AIX] Improve option processing for mabi=vec-extabi and mabi=vec=defaul

2021-01-29 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: hubert.reinterpretcast, cebowleratibm.
ZarkoCA added a project: PowerPC.
ZarkoCA requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Opening this revision to better address comments by @hubert.reinterpretcast in 
https://reviews.llvm.org/rGcaaaebcde462


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95702

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/altivec.c


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -6,9 +6,6 @@
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 
-triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu 
pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
-
-// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target 
powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target 
powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 
-triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s 
--check-prefix=AIX-ERROR
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4669,23 +4669,15 @@
 }
   }
 
-  if (Triple.isOSAIX() && Args.hasArg(options::OPT_maltivec)) {
-if (Args.getLastArg(options::OPT_mabi_EQ_vec_extabi)) {
-  CmdArgs.push_back("-mabi=vec-extabi");
-} else {
-  D.Diag(diag::err_aix_default_altivec_abi);
-}
-  }
-
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ_vec_extabi,
options::OPT_mabi_EQ_vec_default)) {
 if (!Triple.isOSAIX())
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getSpelling() << RawTriple.str();
-if (A->getOption().getID() == options::OPT_mabi_EQ_vec_default)
-  D.Diag(diag::err_aix_default_altivec_abi);
 if (A->getOption().getID() == options::OPT_mabi_EQ_vec_extabi)
   CmdArgs.push_back("-mabi=vec-extabi");
+else
+  D.Diag(diag::err_aix_default_altivec_abi);
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {


Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -6,9 +6,6 @@
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
 // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-
-// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -mcpu=pwr8 -target powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR 
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4669,23 +4669,15 @@
 }
   }
 
-  if (Triple.isOSAIX() && Args.hasArg(options::OPT_maltivec)) {
-if (Args.getLastArg(options::OPT_mabi_EQ_vec_extabi)) {
-  CmdArgs.push_back("-mabi=vec-extabi");
-} else {
-  D.Diag(diag::err_aix_default_altivec_abi);

[PATCH] D95701: [clangd] Add semanticTokens modifiers for function/class/file/global scope

2021-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: nridge.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

These allow (function-) local variables to be distinguished, but also a
bunch more cases.
It's not quite independent with existing information (e.g. the
field/variable distinction is redundant if you have class-scope + static
attributes) but I don't think this is terribly important.

Depends on D77811 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95701

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,17 +18,18 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* Function [decl] */f() {}", apply("void ^f() {}"));
+  EXPECT_EQ("void /* Function [decl] [globalScope] */f() {}",
+apply("void ^f() {}"));
 
-  EXPECT_EQ(
-  apply("[[int f1(); const int x = f1();]]"),
-  "int /* Function [decl] */f1(); "
-  "const int /* Variable [decl] [readonly] */x = /* Function */f1();");
+  EXPECT_EQ(apply("[[int f1(); const int x = f1();]]"),
+"int /* Function [decl] [globalScope] */f1(); "
+"const int /* Variable [decl] [readonly] [fileScope] */x = "
+"/* Function [globalScope] */f1();");
 
   // Only the targeted range is annotated.
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"void /* Function [decl] */f2() {}");
+"void /* Function [decl] [globalScope] */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -113,7 +113,8 @@
 void checkHighlightings(llvm::StringRef Code,
 std::vector>
-AdditionalFiles = {}) {
+AdditionalFiles = {},
+uint32_t ModifierMask = -1) {
   Annotations Test(Code);
   TestTU TU;
   TU.Code = std::string(Test.code());
@@ -126,8 +127,11 @@
   for (auto File : AdditionalFiles)
 TU.AdditionalFiles.insert({File.first, std::string(File.second)});
   auto AST = TU.build();
+  auto Actual = getSemanticHighlightings(AST);
+  for (auto &Token : Actual)
+Token.Modifiers &= ModifierMask;
 
-  EXPECT_EQ(Code, annotate(Test.code(), getSemanticHighlightings(AST)));
+  EXPECT_EQ(Code, annotate(Test.code(), Actual));
 }
 
 // Any annotations in OldCode and NewCode are converted into their corresponding
@@ -163,6 +167,12 @@
   << OldCode;
 }
 
+constexpr static uint32_t ScopeModifierMask =
+1 << unsigned(HighlightingModifier::FunctionScope) |
+1 << unsigned(HighlightingModifier::ClassScope) |
+1 << unsigned(HighlightingModifier::FileScope) |
+1 << unsigned(HighlightingModifier::GlobalScope);
+
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
@@ -717,9 +727,10 @@
   };
   )cpp",
   };
-  for (const auto &TestCase : TestCases) {
-checkHighlightings(TestCase);
-  }
+  for (const auto &TestCase : TestCases)
+// Mask off scope modifiers to keep the tests manageable.
+// They're tested separately.
+checkHighlightings(TestCase, {}, ~ScopeModifierMask);
 
   checkHighlightings(R"cpp(
 class $Class_decl[[A]] {
@@ -729,7 +740,8 @@
  {{"imp.h", R"cpp(
 int someMethod();
 void otherMethod();
-  )cpp"}});
+  )cpp"}},
+ ~ScopeModifierMask);
 
   // A separate test for macros in headers.
   checkHighlightings(R"cpp(
@@ -742,7 +754,59 @@
 #define DXYZ_Y(Y) DXYZ(x##Y)
 #define DEFINE(X) int X;
 #define DEFINE_Y DEFINE(Y)
-  )cpp"}});
+  )cpp"}},
+ ~ScopeModifierMask);
+}
+
+TEST(SemanticHighlighting, ScopeModifiers) {
+  const char *TestCases[] = {
+  R"cpp(
+static int $Variable_fileScope[[x]];
+namespace $Namespace_globalScope[[ns]] {
+  class $Class_globalScope[[x]];
+}
+namespace {
+  v

[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-01-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 320218.
sammccall added a comment.

Add tests for 'abstract' and fix bugs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77811

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
  llvm/lib/Testing/Support/Annotations.cpp

Index: llvm/lib/Testing/Support/Annotations.cpp
===
--- llvm/lib/Testing/Support/Annotations.cpp
+++ llvm/lib/Testing/Support/Annotations.cpp
@@ -53,7 +53,8 @@
   continue;
 }
 if (Text.consume_front("$")) {
-  Name = Text.take_while(llvm::isAlnum);
+  Name =
+  Text.take_while([](char C) { return llvm::isAlnum(C) || C == '_'; });
   Text = Text.drop_front(Name->size());
   continue;
 }
Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,15 +18,17 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
+  EXPECT_EQ("void /* Function [decl] */f() {}", apply("void ^f() {}"));
 
-  EXPECT_EQ(apply("[[void f1(); void f2();]]"),
-"void /* entity.name.function.cpp */f1(); "
-"void /* entity.name.function.cpp */f2();");
+  EXPECT_EQ(
+  apply("[[int f1(); const int x = f1();]]"),
+  "int /* Function [decl] */f1(); "
+  "const int /* Variable [decl] [readonly] */x = /* Function */f1();");
 
+  // Only the targeted range is annotated.
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"void /* entity.name.function.cpp */f2() {}");
+"void /* Function [decl] */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include 
 
@@ -86,7 +87,8 @@
 return L.R.start < R.R.start;
   }));
 
-  std::string Result;
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
   unsigned NextChar = 0;
   for (auto &T : Tokens) {
 unsigned StartOffset = llvm::cantFail(positionToOffset(Input, T.R.start));
@@ -94,14 +96,18 @@
 assert(StartOffset <= EndOffset);
 assert(NextChar <= StartOffset);
 
-Result += Input.substr(NextChar, StartOffset - NextChar);
-Result += std::string(
-llvm::formatv("${0}[[{1}]]", T.Kind,
-  Input.substr(StartOffset, EndOffset - StartOffset)));
+OS << Input.substr(NextChar, StartOffset - NextChar);
+OS << '$' << T.Kind;
+for (unsigned I = 0;
+ I <= static_cast(HighlightingModifier::LastModifier); ++I) {
+  if (T.Modifiers & (1 << I))
+OS << '_' << static_cast(I);
+}
+OS << "[[" << Input.substr(StartOffset, EndOffset - StartOffset) << "]]";
 NextChar = EndOffset;
   }
-  Result += Input.substr(NextChar);
-  return Result;
+  OS << Input.substr(NextChar);
+  return std::move(OS.str());
 }
 
 void checkHighlightings(llvm::StringRef Code,
@@ -160,337 +166,340 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
-  struct $Class[[AS]] {
-double $Field[[SomeMember]];
+  struct $Class_decl[[AS]] {
+double $Field_decl[[SomeMember]];
   };
   struct {
-  } $Variable[[S]];
-  void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
-$Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
-$Class[[AS]] $LocalVariable[[AA]];
-$Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
-auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]](int $Parameter[[A]]) -> void {};
+  } $Variable_decl[[S]];
+  void $Function_decl[[foo]](int $Parameter_decl[[A]], $Class[[AS]] $Parameter_decl[[As]]) {
+$Primitive_dedu

[PATCH] D93095: Introduce -Wreserved-identifier

2021-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.

@rsmith I did my bet to address your comments. What do you think of current 
state?




Comment at: clang/lib/Sema/SemaDecl.cpp:13640
 
+  warnOnReservedIdentifier(New);
+

serge-sans-paille wrote:
> rsmith wrote:
> > Is there somewhere more central you can do this, rather than repeating it 
> > once for each kind of declaration? (Eg, `PushOnScopeChains`)
> That would be sane. I'll check that.
I tried PushOnScopeChains, and this does not capture all the required 
declarations. I failed to find another place :-/



Comment at: clang/lib/Sema/SemaDecl.cpp:16296
   } else {
+if (TUK == TUK_Definition)
+  warnOnReservedIdentifier(New);

serge-sans-paille wrote:
> rsmith wrote:
> > Why do we not diagnose the other possible `TagUseKind`s? `struct _foo;` and 
> > `struct _foo *p;` both use reserved identifiers too.
> We have a test case for `struct _foo` and its correctly diagnosed. I'll 
> double check for pointer / reference too.
Test case added for pointers, works like a charm.


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

https://reviews.llvm.org/D93095

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


[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-29 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1018
+  an USE statement.  The default is the current 
directory.}]>,Group;
+def module_dir : Separate<["-"], "module-dir">, 
Flags<[FlangOption,FC1Option]>, MetaVarName<"">, Alias;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,

It would be better to make `-module-dir` the main option and `-J` the alias. 
`-J` is only there for gfortran compatibility, not because it is a good name 
for the option.



Comment at: flang/include/flang/Frontend/CompilerInstance.h:105
   /// {
+  Fortran::semantics::SemanticsContext &semaChecking() const { return 
*semantics_; }
 

`semanticsContext` would be a better name for this function.



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:67
+  // of options.
+  std::string moduleDirJ_ = "."; 
+

`moduleDir_` would be a better name.



Comment at: flang/lib/Frontend/CompilerInstance.cpp:29
+  semantics_(new Fortran::semantics::SemanticsContext(*(new  
Fortran::common::IntrinsicTypeDefaultKinds()),*(new 
common::LanguageFeatureControl()),
+ *allCookedSources_)) {
 

Why is `semantics_` a `shared_ptr` rather than a simple data member of  type 
`SemanticsContext`? It's owned by only `CompilerInstance`, not shared.
The same question probably applies to the other fields too.


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

https://reviews.llvm.org/D95448

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


[PATCH] D93095: Introduce -Wreserved-identifier

2021-01-29 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 320212.
serge-sans-paille added a comment.

Extra test cases


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{'foo__bar' is a reserved identifier}}
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _barbouille() { return 0; } // expected-warning {{'_barbouille' is a reserved identifier}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{'__toucan' is a reserved identifier}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{'_Barbotine' is a reserved identifier}}
+
+template  // expected-warning {{'__' is a reserved identifier}}
+struct BarbeNoire {};
+
+template  // expected-warning {{'__' is a reserved identifier}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{'_Barbidur' is a reserved identifier}}
+
+struct __barbidou {}; // expected-warning {{'__barbidou' is a reserved identifier}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{'__barbouille' is a reserved identifier}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{'__babar' is a reserved identifier}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{'__barbapapa' is a reserved identifier}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{'_Barbalala' is a reserved identifier}}
+};
+
+enum class __menu { // expected-warning {{'__menu' is a reserved identifier}}
+  __some,   // expected-warning {{'__some' is a reserved identifier}}
+  _Other,   // expected-warning {{'_Other' is a reserved identifier}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{'_Menu' is a reserved identifier}}
+  _OtheR_,   // expected-warning {{'_OtheR_' is a reserved identifier}}
+  _other_// expected-warning {{'_other_' is a reserved identifier}}
+};
+
+enum {
+  __some, // expected-warning {{'__some' is a reserved identifier}}
+  _Other, // expected-warning {{'_Other' is a reserved identifier}}
+  _other  // expected-warning {{'_other' is a reserved identifier}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{'_Barbamama' is a reserved identifier}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+int _barbatruc; // no-warning
+}
+
+long double operator"" _BarbeBleue(long double) // no-warning
+{
+  return 0.;
+}
+
+struct _BarbeRouge {} p; // expected-warning {{'_BarbeRouge' is a reserved identifier}}
+struct _BarbeNoire {}* q; // expected-warning {{'_BarbeNoire' is a reserved identifier}}
Index: clang/test/Sema/reserved-identifier.c
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+
+#define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
+
+int foo__bar() { return 0; }// no-warning
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _foo() { return 0; }// expected-warning {{'_foo' is a reserved identifier}}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+  goto __reserved;
+__reserved: // expected-warning {{'__reserved' is 

[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

2021-01-29 Thread Félix Cloutier via Phabricator via cfe-commits
fcloutier updated this revision to Diff 320204.
fcloutier added a comment.

Updating the diff using arcanist, which I'm told produces better results. Sorry 
for the churn!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95695

Files:
  clang/test/AST/ast-print-attr.c
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -773,10 +773,8 @@
 
 void writeValue(raw_ostream &OS) const override {
   OS << "\";\n";
-  OS << "  bool isFirst = true;\n"
- << "  for (const auto &Val : " << RangeName << "()) {\n"
- << "if (isFirst) isFirst = false;\n"
- << "else OS << \", \";\n";
+  OS << "  for (const auto &Val : " << RangeName << "()) {\n"
+ << "Comma(OS, IsFirstArgument);\n";
   writeValueImpl(OS);
   OS << "  }\n";
   OS << "  OS << \"";
@@ -1428,10 +1426,12 @@
 return;
   }
 
-  OS << "  switch (getAttributeSpellingListIndex()) {\n"
-"  default:\n"
-"llvm_unreachable(\"Unknown attribute spelling!\");\n"
-"break;\n";
+  OS << "  bool IsFirstArgument = true; (void)IsFirstArgument;\n"
+ << "  unsigned TrailingOmittedArgs = 0; (void)TrailingOmittedArgs;\n"
+ << "  switch (getAttributeSpellingListIndex()) {\n"
+ << "  default:\n"
+ << "llvm_unreachable(\"Unknown attribute spelling!\");\n"
+ << "break;\n";
 
   for (unsigned I = 0; I < Spellings.size(); ++ I) {
 llvm::SmallString<16> Prefix;
@@ -1476,12 +1476,10 @@
 
 Spelling += Name;
 
-OS <<
-  "  case " << I << " : {\n"
-  "OS << \"" << Prefix << Spelling;
+OS << "  case " << I << " : {\n"
+   << "OS << \"" << Prefix << Spelling << "\";\n";
 
 if (Variety == "Pragma") {
-  OS << "\";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
   OS << "OS << \"\\n\";";
   OS << "break;\n";
@@ -1490,19 +1488,18 @@
 }
 
 if (Spelling == "availability") {
-  OS << "(";
+  OS << "OS << \"(";
   writeAvailabilityValue(OS);
-  OS << ")";
+  OS << ")\";\n";
 } else if (Spelling == "deprecated" || Spelling == "gnu::deprecated") {
-  OS << "(";
+  OS << "OS << \"(";
   writeDeprecatedAttrValue(OS, Variety);
-  OS << ")";
+  OS << ")\";\n";
 } else {
   // To avoid printing parentheses around an empty argument list or
   // printing spurious commas at the end of an argument list, we need to
   // determine where the last provided non-fake argument is.
   unsigned NonFakeArgs = 0;
-  unsigned TrailingOptArgs = 0;
   bool FoundNonOptArg = false;
   for (const auto &arg : llvm::reverse(Args)) {
 if (arg->isFake())
@@ -1516,61 +1513,33 @@
   FoundNonOptArg = true;
   continue;
 }
-if (!TrailingOptArgs++)
-  OS << "\";\n"
- << "unsigned TrailingOmittedArgs = 0;\n";
 OS << "if (" << arg->getIsOmitted() << ")\n"
<< "  ++TrailingOmittedArgs;\n";
   }
-  if (TrailingOptArgs)
-OS << "OS << \"";
-  if (TrailingOptArgs < NonFakeArgs)
-OS << "(";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << "   OS << \"(\";\n"
-   << "OS << \"";
   unsigned ArgIndex = 0;
   for (const auto &arg : Args) {
 if (arg->isFake())
   continue;
-if (ArgIndex) {
-  if (ArgIndex >= NonFakeArgs - TrailingOptArgs)
-OS << "\";\n"
-   << "if (" << ArgIndex << " < " << NonFakeArgs
-   << " - TrailingOmittedArgs)\n"
-   << "  OS << \", \";\n"
-   << "OS << \"";
-  else
-OS << ", ";
-}
 std::string IsOmitted = arg->getIsOmitted();
 if (arg->isOptional() && IsOmitted != "false")
-  OS << "\";\n"
- << "if (!(" << IsOmitted << ")) {\n"
- << "  OS << \"";
+  OS << "if (!(" << IsOmitted << ")) {\n";
+// Variadic arguments print their own leading comma.
+if (!arg->isVariadic())
+  OS << "Comma(OS, IsFirstArgument);\n";
+OS << "OS << \"";
 arg->writeValue(OS);
+OS << "\";\n";
 if (arg->isOptional() && IsOmitted != "false")
-  OS << "\";\n"
- << "}\n"
- << "OS << \"";
+  OS << "}\n";
 ++ArgIndex;
   }
-  if (TrailingOptArgs < NonFakeArgs)
-OS << ")";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << " 

[PATCH] D95655: [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

2021-01-29 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 320199.
rsanthir.quic marked an inline comment as done.
rsanthir.quic added a comment.

Corrected register ordering for sm4e and removed redundant argument in sm3ss1 
test


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

https://reviews.llvm.org/D95655

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-sm4-sm3-invalid.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll

Index: llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+sm4 -o - | FileCheck %s
+
+define <4 x i32> @test_vsm3partw1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3partw1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3partw1 v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3partw1.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3partw1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3partw1.i
+}
+
+define <4 x i32> @test_vsm3partw2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3partw2:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3partw2 v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3partw2.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3partw2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3partw2.i
+}
+
+define <4 x i32> @test_vsm3ss1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3ss1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3ss1 v0.4s, v0.4s, v1.4s, v2.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm3ss1.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3ss1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+  ret <4 x i32> %vsm3ss1.i
+}
+
+define <4 x i32> @test_vsm3tt1a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt1a:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt1a v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt1a.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt1a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt1a.i
+}
+
+define <4 x i32> @test_vsm3tt1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt1b:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt1b v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt1b.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt1b.i
+}
+
+define <4 x i32> @test_vsm3tt2a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt2a:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt2a v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt2a.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt2a(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt2a.i
+}
+
+define <4 x i32> @test_vsm3tt2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
+; CHECK-LABEL: test_vsm3tt2b:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm3tt2b v0.4s, v1.4s, v2.s[2]
+; CHECK-NEXT:ret
+entry:
+  %vsm3tt2b.i = tail call <4 x i32> @llvm.aarch64.crypto.sm3tt2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i64 2)
+  ret <4 x i32> %vsm3tt2b.i
+}
+
+define <4 x i32> @test_vsm4e(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vsm4e:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4e v0.4s, v1.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm4e.i = tail call <4 x i32> @llvm.aarch64.crypto.sm4e(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %vsm4e.i
+}
+
+define <4 x i32> @test_vsm4ekey(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vsm4ekey:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4ekey v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:ret
+entry:
+  %vsm4ekey.i = tail call <4 x i32> @llvm.aarch64.crypto.sm4ekey(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %vsm4ekey.i
+}
+
+declare <4 x i32> @llvm.aarch64.crypto.sm3partw1(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3partw2(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3ss1(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt1a(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt2b(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt2a(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm3tt1b(<4 x i32>, <4 x i32>, <4 x i32>, i64 immarg)
+declare <4 x i32> @llvm.aarch64.crypto.sm4e(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.crypto.sm4ekey(<4 

[PATCH] D95655: [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

2021-01-29 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic marked 2 inline comments as done.
rsanthir.quic added a comment.

Thank you for taking a look at this @labrinea !




Comment at: llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll:77
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4e v1.4s, v0.4s
+; CHECK-NEXT:mov v0.16b, v1.16b

labrinea wrote:
> Shouldn't the registers be the other way around: sm4e v0.4s, v1.4s ? I 
> believe the reason this happens is because of how CryptoRRTied is defined in 
> `llvm/lib/Target/AArch64/AArch64InstrFormats.td`: 
> 
> 
> ```
> class CryptoRRTiedop0, bits<2>op1, string asm, string asmops>
>   : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm), asm, asmops,
>   "$Vm = $Vd", []> {
> ```
> 
> Vd be should be the first source register (as well as destination register) 
> and Vn should be the second source register.
I see what you mean, this has the added effect of correcting SHA512SU0 as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95655

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2021-01-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 320196.
HazardyKnusperkeks added a comment.

The previous one broke a (format) test in polly. This lead me to change the one 
breaking behavior, no it is not breaking anymore.
A comment starting with `}` will only be indented if it is in a comment section 
which will get an indention. Test case is adapted.

I will wait a few days if there is no negative feedback I will push it again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3144,7 +3144,7 @@
 "  # commen6\n"
 "  # commen7",
 format("k:val#commen1 commen2\n"
-   " # commen3\n"
+   " #commen3\n"
"# commen4\n"
"a:1#commen5 commen6\n"
" #commen7",
@@ -3275,6 +3275,526 @@
JSStyle20));
 }
 
+TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
+  FormatStyle Style = getLLVMStyle();
+  StringRef NoTextInComment = " //   \n"
+  "\n"
+  "void foo() {// \n"
+  "// \n"
+  "}";
+
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style.SpacesInLineCommentPrefix.Minimum = 0;
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style.SpacesInLineCommentPrefix.Minimum = 5;
+  EXPECT_EQ("//\n"
+"\n"
+"void foo() { //\n"
+"  //\n"
+"}",
+format(NoTextInComment, Style));
+
+  Style = getLLVMStyle();
+  StringRef Code =
+  "//Free comment without space\n"
+  "\n"
+  "//   Free comment with 3 spaces\n"
+  "\n"
+  "///Free Doxygen without space\n"
+  "\n"
+  "///   Free Doxygen with 3 spaces\n"
+  "\n"
+  "/// A Doxygen Comment with a nested list:\n"
+  "/// - Foo\n"
+  "/// - Bar\n"
+  "///   - Baz\n"
+  "///   - End\n"
+  "/// of the inner list\n"
+  "///   .\n"
+  "/// .\n"
+  "\n"
+  "namespace Foo {\n"
+  "bool bar(bool b) {\n"
+  "  bool ret1 = true; ///TokenText;
   if (NamespaceTok->is(TT_NamespaceMacro))
 text += "(";
@@ -278,7 +280,8 @@
   EndCommentNextTok->NewlinesBefore == 0 &&
   EndCommentNextTok->isNot(tok::eof);
 const std::string EndCommentText =
-computeEndCommentText(NamespaceName, AddNewline, NamespaceTok);
+computeEndCommentText(NamespaceName, AddNewline, NamespaceTok,
+  Style.SpacesInLineCommentPrefix.Minimum);
 if (!hasEndComment(EndCommentPrevTok)) {
   bool isShort = I - StartLineIndex <= kShortNamespaceMaxLines + 1;
   if (!isShort)
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -661,6 +661,8 @@
Style.SpacesInContainerLiterals);
 IO.mapOptional("SpacesInCStyleCastParentheses",
Style.SpacesInCStyleCastParentheses);
+IO.mapOptional("SpacesInLineCommentPrefix",
+   Style.SpacesInLineCommentPrefix);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
 IO.mapOptional("SpaceBeforeSquareBrackets",
@@ -710,6 +712,20 @@
   }
 };
 
+template <> struct MappingTraits {
+  static void mapping(IO &IO, FormatStyle::SpacesInLineComment &Space) {
+// Transform the maximum to signed, to parse "-1" correctly
+int signedMaximum = static_cast(Space.Maximum);
+IO.mapOptional("Minimum", Space.Minimum);
+IO.mapOptional("Maximum", signedMaximum);
+Space.Maximum = static_cast(signedMaximum);
+
+if (Space.Maximum != -1u) {
+  Space.Minimum = std::min(Space.Minimum, Space.Maximum);
+}
+  }
+};
+
 // Allows to read vector while keeping default values.
 // IO.getContext() should contain a pointer to the FormatStyle structure, that
 // will be used to get default values for missing keys.
@@ -986,6 +1002,7 @@
   LLVMStyle.Sp

[PATCH] D95653: [clang-tidy] Fix linking tests to LLVMTestingSupport

2021-01-29 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG632545e8ce84: [clang-tidy] Fix linking tests to 
LLVMTestingSupport (authored by mgorny).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95653

Files:
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt


Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
-  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR
@@ -46,4 +45,5 @@
   clangTidyObjCModule
   clangTidyReadabilityModule
   clangTidyUtils
+  LLVMTestingSupport
   )


Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
-  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR
@@ -46,4 +45,5 @@
   clangTidyObjCModule
   clangTidyReadabilityModule
   clangTidyUtils
+  LLVMTestingSupport
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 632545e - [clang-tidy] Fix linking tests to LLVMTestingSupport

2021-01-29 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2021-01-29T21:54:09+01:00
New Revision: 632545e8ce846ccaeca8df15a3dc5e36d01a1275

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

LOG: [clang-tidy] Fix linking tests to LLVMTestingSupport

LLVMTestingSupport is not part of libLLVM, and therefore can not
be linked to via LLVM_LINK_COMPONENTS.  Instead, it needs to be
specified explicitly to ensure that it is linked explicitly
even if LLVM_LINK_LLVM_DYLIB is used.  This is consistent with handling
in clangd.

Fixes PR#48931

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

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
index be35b71d15cf..05d330dd8033 100644
--- a/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
-  TestingSupport
   )
 
 get_filename_component(CLANG_LINT_SOURCE_DIR
@@ -46,4 +45,5 @@ target_link_libraries(ClangTidyTests
   clangTidyObjCModule
   clangTidyReadabilityModule
   clangTidyUtils
+  LLVMTestingSupport
   )



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


[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

2021-01-29 Thread Félix Cloutier via Phabricator via cfe-commits
fcloutier created this revision.
fcloutier added reviewers: jkorous, dcoughlin.
fcloutier added a project: clang.
Herald added a subscriber: Charusso.
Herald added a reviewer: aaron.ballman.
fcloutier requested review of this revision.
Herald added a subscriber: cfe-commits.

Since it gained a new `VariadicExprArgument`, `AnnotateAttr`'s `printPretty` no 
longer prints back compilable code when the attribute is only passed a string. 
This is because the comma-printing logic unconditionally prints a comma between 
the first, fixed argument and the `VariadicExprArgument`, which is most likely 
an empty collection.

This diff adds a `Comma` helper to AttrImpl.inc that prints a comma before an 
argument if it isn't the first argument. In the process, it simplifies 
substantially the generation code, and arguably the generated code, too.

rdar://73742471


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95695

Files:
  clang/test/AST/ast-print-attr.c
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -776,4 +776,2 @@
-  OS << "  bool isFirst = true;\n"
- << "  for (const auto &Val : " << RangeName << "()) {\n"
- << "if (isFirst) isFirst = false;\n"
- << "else OS << \", \";\n";
+  OS << "  for (const auto &Val : " << RangeName << "()) {\n"
+ << "Comma(OS, IsFirstArgument);\n";
@@ -1431,4 +1429,6 @@
-  OS << "  switch (getAttributeSpellingListIndex()) {\n"
-"  default:\n"
-"llvm_unreachable(\"Unknown attribute spelling!\");\n"
-"break;\n";
+  OS << "  bool IsFirstArgument = true; (void)IsFirstArgument;\n"
+ << "  unsigned TrailingOmittedArgs = 0; (void)TrailingOmittedArgs;\n"
+ << "  switch (getAttributeSpellingListIndex()) {\n"
+ << "  default:\n"
+ << "llvm_unreachable(\"Unknown attribute spelling!\");\n"
+ << "break;\n";
@@ -1479,3 +1479,2 @@
-OS <<
-  "  case " << I << " : {\n"
-  "OS << \"" << Prefix << Spelling;
+OS << "  case " << I << " : {\n"
+   << "OS << \"" << Prefix << Spelling << "\";\n";
@@ -1484 +1482,0 @@
-  OS << "\";\n";
@@ -1493 +1491 @@
-  OS << "(";
+  OS << "OS << \"(";
@@ -1495 +1493 @@
-  OS << ")";
+  OS << ")\";\n";
@@ -1497 +1495 @@
-  OS << "(";
+  OS << "OS << \"(";
@@ -1499 +1497 @@
-  OS << ")";
+  OS << ")\";\n";
@@ -1505 +1502,0 @@
-  unsigned TrailingOptArgs = 0;
@@ -1519,3 +1515,0 @@
-if (!TrailingOptArgs++)
-  OS << "\";\n"
- << "unsigned TrailingOmittedArgs = 0;\n";
@@ -1525,9 +1518,0 @@
-  if (TrailingOptArgs)
-OS << "OS << \"";
-  if (TrailingOptArgs < NonFakeArgs)
-OS << "(";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << "   OS << \"(\";\n"
-   << "OS << \"";
@@ -1538,10 +1522,0 @@
-if (ArgIndex) {
-  if (ArgIndex >= NonFakeArgs - TrailingOptArgs)
-OS << "\";\n"
-   << "if (" << ArgIndex << " < " << NonFakeArgs
-   << " - TrailingOmittedArgs)\n"
-   << "  OS << \", \";\n"
-   << "OS << \"";
-  else
-OS << ", ";
-}
@@ -1550,3 +1525,5 @@
-  OS << "\";\n"
- << "if (!(" << IsOmitted << ")) {\n"
- << "  OS << \"";
+  OS << "if (!(" << IsOmitted << ")) {\n";
+// Variadic arguments print their own leading comma.
+if (!arg->isVariadic())
+  OS << "Comma(OS, IsFirstArgument);\n";
+OS << "OS << \"";
@@ -1553,0 +1531 @@
+OS << "\";\n";
@@ -1555,3 +1533 @@
-  OS << "\";\n"
- << "}\n"
- << "OS << \"";
+  OS << "}\n";
@@ -1560,7 +1536,3 @@
-  if (TrailingOptArgs < NonFakeArgs)
-OS << ")";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << "   OS << \")\";\n"
-   << "OS << \"";
+  if (ArgIndex != 0)
+OS << "if (!IsFirstArgument)\n"
+   << "  OS << \")\";\n";
@@ -1568,6 +1540,3 @@
-
-OS << Suffix + "\";\n";
-
-OS <<
-  "break;\n"
-  "  }\n";
+OS << "OS << \"" << Suffix << "\";\n"
+   << "break;\n"
+   << "  }\n";
@@ -2281,0 +2251,11 @@
+  // Helper to print the starting character of an attribute argument. If there
+  // hasn't been an argument yet, it prints an opening parenthese; otherwise it
+  // prints a comma.
+  OS << "static inline void Comma(raw_ostream& OS, bool& IsFirst) {\n"
+ << "  if (IsFirst) {\n"
+ << "IsFirst = false;\n"
+ << "OS << 

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

https://lists.llvm.org/pipermail/llvm-dev/2021-January/148229.html "Python 
version requirement" for the version discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-29 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2530791 , @thakis wrote:

> Landed revert in 1608ba09462d877111230e9461b895f696f8fcb1 
> . 
> Someone should file a PR to make sure that gets merged to the 12.0 branch.
>
> We can then reland on trunk once there are clear instructions for folks 
> building with trunk clang but old NDK but without the toolchain file (either 
> "use toolchain file" or "set LLVM_USE_LLD" or something like that, I'm 
> guessing?)

The instructions would be "use the whole toolchain, don't mix and match". Where 
should that be documented?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added a comment.

@JDevlieghere I personally have no skin in this game. This is actually quite an 
obnoxious development for me since my linux machine is stuck on an old version 
and Python 3.5 is the newest version in the repos. I sent a message to llvm-dev 
so hopefully this will get hashed out there. You are right though, that the 
linked page does not actually say "minimum requirement". I just assumed that 
since code was going in unchallenged that requires it, that it must be true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95694: [clang][RelativeVTablesABI] Place non-local vtables in comdat groups

2021-01-29 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: mcgrathr, phosek.
leonardchan added a project: clang.
Herald added a subscriber: pengfei.
leonardchan requested review of this revision.

Currently, it's possible for vtables that fit precisely in a mergable constants 
group to not be collected by `--gc-sections` even when `-fdata-sections` is 
enabled. This results in some vtables that would normally be garbage collected 
to persist after linking, causing extra bloat in rodata.

This happens because constants that do not need relocations according to 
`Constant::needsRelocation` have the option of being placed into these `cstN` 
sections. That is, a vtable would get placed into `.section .rodata.cst16` 
rather than something like `.section .rodata.{vtable}` under `-fdata-sections`, 
and `--gc-sections` would not collect the vtable in `.section .rodata.cst16`.

Note that this doesn't affect vtables under the default Itanium ABI that 
*could* fit into one of these mergeable sections but *would* get placed only 
into `.rodata`. Example:

  class A {
   public:
virtual void func();
virtual void func2();
  };
  
  void A::func() {}
  void A::func2() {}

compiled with `./bin/clang++ -c /tmp/test.cc -target x86_64-linux-gnu -fno-pic 
-fno-rtti -fdata-sections -S -o -` generates

.type   _ZTV1A,@object  # @_ZTV1A
.section.rodata._ZTV1A,"a",@progbits
.globl  _ZTV1A
.p2align3
  _ZTV1A:
.quad   0
.quad   0
.quad   _ZN1A4funcEv
.quad   _ZN1A5func2Ev
.size   _ZTV1A, 32

The only reason this isn't placed into `.rodata.cst32` is because they need 
dynamic relocations according to `Constant::needsRelocation` (so they take a 
different branch 

 that relative vtables would), but because this is made with a static 
relocation model (non-PIC mode), the vtable can be safely placed in `.rodata`. 
This is a unique scenario that is only surfacing now from the relative vtables 
work.

To keep this contained under the realm of RV changes, a simple fix would be to 
place these kinds of vtables in comdat groups when appropriate, then 
`--gc-sections` can collect them appropriately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95694

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CGVTables.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/vtable-in-comdat.cpp


Index: clang/test/CodeGenCXX/RelativeVTablesABI/vtable-in-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/RelativeVTablesABI/vtable-in-comdat.cpp
@@ -0,0 +1,24 @@
+// Check that all vtables under the relative ABI are placed in a comdat group.
+// This is necessary because if the vtable happens to fit in a mergable
+// constants section, then the LLVM backend will not place the symbol in its 
own
+// unique section even if -fdata-sections is enabled. (That is, in the object
+// file the vtable is defined, it will be in section .rodata.cst{N} instead of
+// something like .rodata.{vtable}). This can cause vtables to be retained that
+// normally would be collected by --gc-sections. Placing them in a comdat group
+// can guarantee that they will be placed in a unique section group and garbage
+// collected.
+
+// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -S -o - -emit-llvm 
-fexperimental-relative-c++-abi-vtables -fno-rtti | FileCheck %s
+
+// This will result in a vtable of size 16, which would normally be placed in
+// .rodata.cst16.
+class A {
+public:
+  virtual void func();
+  virtual void func2();
+};
+
+void A::func() {}
+void A::func2() {}
+
+// CHECK: @_ZTV1A = {{.*}}, comdat, align 4
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1772,6 +1772,9 @@
 
   if (VTContext.isRelativeLayout() && !VTable->isDSOLocal())
 CGVT.GenerateRelativeVTableAlias(VTable, VTable->getName());
+
+  if (CGVT.CanPlaceRelativeVTableInComdat(VTable))
+VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
 }
 
 bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(
Index: clang/lib/CodeGen/CGVTables.h
===
--- clang/lib/CodeGen/CGVTables.h
+++ clang/lib/CodeGen/CGVTables.h
@@ -154,6 +154,10 @@
   /// when a vtable may not be dso_local.
   void GenerateRelativeVTableAlias(llvm::GlobalVariable *VTable,
llvm::StringRef AliasNameRef);
+
+  /// Check if we can place the vtable in a comdat group under the relative
+  /// layout.
+  bool CanPlaceRelativeVTableInComdat(const llvm::GlobalVariable *VTable);
 };
 
 } // end namespace Co

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere reopened this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

In D95635#2529027 , @ctetreau wrote:

> In D95635#2528851 , @JDevlieghere 
> wrote:
>
>>> However, the project claims to require 3.6 or greater, and 3.6 features are 
>>> being used.
>>
>> Can you link to where it says that? I'm not opposed to making 3.6 the 
>> minimally required version, but at least for LLDB we don't have that 
>> requirement and we have documentation mentioning Python 3.5.
>
>
>
> In D95635#2528883 , @yln wrote:
>
>> In D95635#2528851 , @JDevlieghere 
>> wrote:
>>
 However, the project claims to require 3.6 or greater, and 3.6 features 
 are being used.
>>>
>>> Can you link to where it says that? I'm not opposed to making 3.6 the 
>>> minimally required version, but at least for LLDB we don't have that 
>>> requirement and we have documentation mentioning Python 3.5.
>>
>> For LLVM: https://llvm.org/docs/GettingStarted.html#software
>
> This is where I saw it. I got bit by @yln's cleanup patch. I can reduce the 
> minimum version for LLDB if that's the officially required version, but llvm 
> at the very least advertises 3.6

That page says "known to work" which is not exactly the same a minimally 
supported. In a unified build there's also no way to say LLVM requires Python 
3.6 but LLDB only requires Python 3.5 because we use the same variables and we 
need to keep that in sync as to not run the test suite under one Python version 
while linking against another.

I see the patch got reverted because not all the bots have Python 3.6. What's 
the lowest Python version that they're running? Is there a reason 3.6 should be 
the minimally supported version?

Again, I'm not opposed to this, but it warrants a bit more discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-29 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 320188.
arnamoy10 added a comment.

Added test for the driver-help, also contains all the changes that was done in 
the previous diff (Aliasing `-J` and `-module-dir`, changing data structures 
etc).


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

https://reviews.llvm.org/D95448

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- flang/test/Flang-Driver/include-module.f90
+++ flang/test/Flang-Driver/include-module.f90
@@ -8,12 +8,28 @@
 !--
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -J %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -module-dir %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs/module-dir -J%S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
 
 !-
 ! FRONTEND FLANG DRIVER (flang-new -fc1)
 !-
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs/module-dir -J %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs/module-dir -module-dir %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs/module-dir -J%S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
 
 !-
 ! EXPECTED OUTPUT FOR MISSING MODULE FILE
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -26,6 +26,7 @@
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-NEXT: -JPut MODULE files in 'directory'
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
@@ -41,6 +42,7 @@
 ! HELP-FC1-NEXT: -E Only run the preprocessor
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
+! HELP-FC1-NEXT: -JPut MODULE files in 'directory'
 ! HELP-FC1-NEXT: -o   Write output to 
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Flang-Driver/driver-help-hi

[Diffusion] rGcaaaebcde462: [AIX] Actually push back "-mabi=vec-extabi" when option is on.

2021-01-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.

BRANCHES
  main

/clang/lib/Driver/ToolChains/Clang.cpp:4672-4678 This seems to be saying that 
`-maltivec` rather actively implies `-mabi=vec-default` (on AIX) even in cases 
where `-maltivec` really makes no difference. I suggest just removing this. If 
kept, this needs more code comments and should be moved below to become a check 
only in the case where neither `-mabi=vec-extabi` nor `-mabi=vec-default` was 
present.
/clang/lib/Driver/ToolChains/Clang.cpp:4687 This `if` can be replaced with 
`else`. In this case, although the body of the preceding `if` "exits", I think 
using `else` is reasonable since the mechanism used is not a standard library 
function or jump statement. Any qualms about this can also be alleviated by 
reversing the order of the check.

Users:
  ZarkoCA (Author)

https://reviews.llvm.org/rGcaaaebcde462

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


[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-29 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 320184.
arnamoy10 added a comment.

Addressing reviewers' comments with the following changes:

1. Aliasing of -module-dir and -J to avoid code duplication
2. Moving the code to set the module and search directories from 
`FrontendActions.cpp` to `CompilerInvocation.cpp`
3. Data structures updated/ variables added to separate Preprocessor options 
from Compiler Options
4. Added more test cases.


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

https://reviews.llvm.org/D95448

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/include-module.f90

Index: flang/test/Flang-Driver/include-module.f90
===
--- flang/test/Flang-Driver/include-module.f90
+++ flang/test/Flang-Driver/include-module.f90
@@ -8,12 +8,28 @@
 !--
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -J %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -module-dir %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs/module-dir -J%S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
 
 !-
 ! FRONTEND FLANG DRIVER (flang-new -fc1)
 !-
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
 ! RUN: not %flang-new -fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs/module-dir -J %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -J %S/Inputs/module-dir -module-dir %S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs/module-dir -J%S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fc1 -fsyntax-only -module-dir %S/Inputs -I %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED
 
 !-
 ! EXPECTED OUTPUT FOR MISSING MODULE FILE
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -96,11 +96,9 @@
 
   auto &parseTree{*ci.parsing().parseTree()};
 
-  // Prepare semantics
-  Fortran::semantics::SemanticsContext semanticsContext{
-  defaultKinds, features, ci.allCookedSources()};
+  // Prepare semantics 
   Fortran::semantics::Semantics semantics{
-  semanticsContext, parseTree, ci.parsing().cooked().AsCharBlock()};
+  ci.semaChecking(), parseTree, ci.parsing().cooked().AsCharBlock()};
 
   // Run semantic checks
   semantics.Perform();
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -183,6 +183,14 @@
 opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
 }
 
+/// Parses all semantic related arguments and populates the variables
+/// options accordingly.
+stat

[clang] 0703b07 - [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Christopher Tetreault via cfe-commits

Author: Christopher Tetreault
Date: 2021-01-29T11:47:21-08:00
New Revision: 0703b0753c40dad30f1683403f6600bd2cb42055

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

LOG: [CMake] Actually require python 3.6 or greater

Previously, CMake would find any version of Python3. However, the project
claims to require 3.6 or greater, and 3.6 features are being used.

Reviewed By: yln

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

Added: 


Modified: 
clang/CMakeLists.txt
lld/CMakeLists.txt
llvm/CMakeLists.txt
mlir/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 9e74014134a0..466b92ba6143 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -131,7 +131,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index d4e561b50d8f..4923361a9969 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -57,7 +57,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 40be7a855932..f0cb42b77c64 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -697,7 +697,7 @@ set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 ##
 

diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index cbae5fd54823..b2eec04520c9 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -79,7 +79,7 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")



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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-29 Thread Christopher Tetreault 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 rG0703b0753c40: [CMake] Actually require python 3.6 or greater 
(authored by ctetreau).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,7 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,7 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,7 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,7 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[Diffusion] rGcaaaebcde462: [AIX] Actually push back "-mabi=vec-extabi" when option is on.

2021-01-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added subscribers: ZarkoCA, hubert.reinterpretcast, 
cfe-commits.

BRANCHES
  main

Users:
  ZarkoCA (Author)

https://reviews.llvm.org/rGcaaaebcde462

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


[PATCH] D95691: Implement P2173 for attributes on lambdas

2021-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall, jyknight.
aaron.ballman requested review of this revision.

https://wg21.link/P2173 is making its way through WG21 currently and has not 
been formally adopted yet. This feature provides very useful functionality in 
that you can specify attributes on the various function *declarations* 
generated by a lambda expression, where the current C++ grammar only allows 
attributes which apply to the various function *types* so generated.

This patch implements P2173  on the assumption 
that it will be adopted by WG21 with this syntax because there are no other 
syntactic locations to put an attribute on a lambda that will unambiguously 
appertain to the declaration rather than the type. Given the large number of 
function declaration attributes compared to function type attributes, such a 
construct is needed. The proposal has been approved in principle by EWG and is 
scheduled to go through Core wording review, so there is a strong likelihood it 
will be adopted, at least with this syntax. When WG21 adopts the proposal, the 
diagnostic can be changed as appropriate. In the unlikely event that WG21 
decides not to adopt the proposal, this syntax is still a conforming extension.

I need this functionality in a downstream fork of Clang that is currently 
sliding some attributes written in the type position to instead apply to the 
declaration.


https://reviews.llvm.org/D95691

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/AST/ast-dump-lambda.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp

Index: clang/test/Parser/cxx0x-lambda-expressions.cpp
===
--- clang/test/Parser/cxx0x-lambda-expressions.cpp
+++ clang/test/Parser/cxx0x-lambda-expressions.cpp
@@ -101,7 +101,6 @@
   }
 
   void attributes() {
-[] [[]] {}; // expected-error {{lambda requires '()' before attribute specifier}}
 [] __attribute__((noreturn)) {}; // expected-error {{lambda requires '()' before attribute specifier}}
 []() [[]]
   mutable {}; // expected-error {{expected body of lambda expression}}
@@ -116,6 +115,14 @@
 []() __attribute__((noreturn)) mutable { while(1); };
 []() mutable
   __attribute__((noreturn)) { while(1); }; // expected-error {{expected body of lambda expression}}
+
+// Testing support for P2173 on adding attributes to the declaration
+// rather than the type.
+[] [[]] () {}; // expected-warning {{an attribute specifier sequence in this position is a Clang extension}}
+#if __cplusplus > 201703L
+[]  [[]] () {};  // expected-warning {{an attribute specifier sequence in this position is a Clang extension}}
+#endif
+[] [[]] {}; // expected-warning {{an attribute specifier sequence in this position is a Clang extension}}
   }
 };
 
Index: clang/test/AST/ast-dump-lambda.cpp
===
--- clang/test/AST/ast-dump-lambda.cpp
+++ clang/test/AST/ast-dump-lambda.cpp
@@ -33,13 +33,14 @@
   []() mutable {};
   []() noexcept {};
   []() -> int { return 0; };
+  [] [[noreturn]] () {};
 }
 // CHECK:Dumping test:
-// CHECK-NEXT:FunctionTemplateDecl {{.*}} <{{.*}}ast-dump-lambda.cpp:15:1, line:36:1> line:15:32{{( imported)?}} test
+// CHECK-NEXT:FunctionTemplateDecl {{.*}} <{{.*}}ast-dump-lambda.cpp:15:1, line:37:1> line:15:32{{( imported)?}} test
 // CHECK-NEXT:|-TemplateTypeParmDecl {{.*}}  col:23{{( imported)?}} referenced typename depth 0 index 0 ... Ts
-// CHECK-NEXT:`-FunctionDecl {{.*}}  line:15:32{{( imported)?}} test 'void (Ts...)'
+// CHECK-NEXT:`-FunctionDecl {{.*}}  line:15:32{{( imported)?}} test 'void (Ts...)'
 // CHECK-NEXT:  |-ParmVarDecl {{.*}}  col:43{{( imported)?}} referenced a 'Ts...' pack
-// CHECK-NEXT:  `-CompoundStmt {{.*}} 
+// CHECK-NEXT:  `-CompoundStmt {{.*}} 
 // CHECK-NEXT:|-DeclStmt {{.*}} 
 // CHECK-NEXT:| `-CXXRecordDecl {{.*}}  line:16:10{{( imported)?}}{{( )?}} struct V definition
 // CHECK-NEXT:|   |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
@@ -275,7 +276,25 @@
 // CHECK-NEXT:| | |-CXXConversionDecl {{.*}}  col:3{{( imported)?}} implicit constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' inline
 // CHECK-NEXT:| | `-CXXMethodDecl {{.*}}  col:3{{( imported)?}} implicit __invoke 'auto () noexcept' static inline
 // CHECK-NEXT:| `-CompoundStmt {{.*}} 
-// CHECK-NEXT:`-LambdaExpr {{.*}}  '(lambda at {{.*}}ast-dump-lambda.cpp:35:3)'
+// CHECK-NEXT:|-LambdaExpr {{.*}}  '(lambda at {{.*}}ast-dump-lambda.cpp:35:3)'
+// CHECK-NEXT:| |-CXXRecordDecl {{.*}}  col:3{{( imported)?}} implicit{{( )?}} class definition
+// CHECK-NEXT:| | |-DefinitionData lambda empty standard_layout trivially_copyable literal can_cons

[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-29 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj added a comment.

https://bugs.llvm.org/show_bug.cgi?id=48668 already exists as a bug report 
linked to this review. I'm not sure "the Zeek project would like to start using 
this" is a good enough reason to block an LLVM release though. I'm fairly 
certain there aren't a whole lot of people in the world using Whitesmiths. That 
said, there's already at least one clang-format bug in the release-blocker list.

I'll get the release notes updated shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

PS4 changes lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[clang] caaaebc - [AIX] Actually push back "-mabi=vec-extabi" when option is on.

2021-01-29 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2021-01-29T14:12:46-05:00
New Revision: caaaebcde462bf681498ce85c2659d683a07fc87

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

LOG: [AIX] Actually push back "-mabi=vec-extabi" when option is on.

Accidentaly ommitted the portion of pushing back the option in
https://reviews.llvm.org/D94986

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index b0379aece75b..431f534c38fe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4684,6 +4684,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   << A->getSpelling() << RawTriple.str();
 if (A->getOption().getID() == options::OPT_mabi_EQ_vec_default)
   D.Diag(diag::err_aix_default_altivec_abi);
+if (A->getOption().getID() == options::OPT_mabi_EQ_vec_extabi)
+  CmdArgs.push_back("-mabi=vec-extabi");
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {



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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/rocm-device-libs.cl:82
 // RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 
%s
+// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 

Since you changing the lines, consider indenting `2>&1`

The most common style is to place `2>&1 | \` on the previous line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[PATCH] D95658: Make the profile-filter.c test compatible with 32-bit systems

2021-01-29 Thread Petr Hosek 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 rG0217f1c7a31b: Make the profile-filter.c test compatible with 
32-bit systems (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95658

Files:
  clang/test/CodeGen/profile-filter.c


Index: clang/test/CodeGen/profile-filter.c
===
--- clang/test/CodeGen/profile-filter.c
+++ clang/test/CodeGen/profile-filter.c
@@ -28,11 +28,11 @@
 // EXCLUDE: noprofile
 // EXCLUDE: @test1
 unsigned test1() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
+  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
   return i + 1;
 }
 
@@ -47,10 +47,10 @@
 // EXCLUDE-NOT: noprofile
 // EXCLUDE: @test2
 unsigned test2() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0), align 8
-  // FUNC-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], 
[1 x i64]* @__profc_test2, i64 0, i64 0), align 8
-  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0), align 8
-  // SECTION: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0), align 8
-  // EXCLUDE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0), align 8
+  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0)
+  // FUNC-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], 
[1 x i64]* @__profc_test2, i64 0, i64 0)
+  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0)
+  // SECTION: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0)
+  // EXCLUDE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0)
   return i - 1;
 }


Index: clang/test/CodeGen/profile-filter.c
===
--- clang/test/CodeGen/profile-filter.c
+++ clang/test/CodeGen/profile-filter.c
@@ -28,11 +28,11 @@
 // EXCLUDE: noprofile
 // EXCLUDE: @test1
 unsigned test1() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
+  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
   return i + 1;
 }
 
@@ -47,10 +47,10 @@
 // EXCLUDE-NOT: noprofile
 // EXCLUDE: @test2
 unsigned test2() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__p

[clang] 0217f1c - Make the profile-filter.c test compatible with 32-bit systems

2021-01-29 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-01-29T09:58:32-08:00
New Revision: 0217f1c7a31ba44715bc083a60cddc2192ffed96

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

LOG: Make the profile-filter.c test compatible with 32-bit systems

This addresses PR48930.

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

Added: 


Modified: 
clang/test/CodeGen/profile-filter.c

Removed: 




diff  --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index 5415ff96cb14..dc5a31e872a1 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -28,11 +28,11 @@ unsigned i;
 // EXCLUDE: noprofile
 // EXCLUDE: @test1
 unsigned test1() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0), align 8
-  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
-  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0), align 8
+  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // FUNC: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test1, i64 0, i64 0)
+  // SECTION-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
+  // EXCLUDE-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* @__profc_test1, i64 0, i64 0)
   return i + 1;
 }
 
@@ -47,10 +47,10 @@ unsigned test1() {
 // EXCLUDE-NOT: noprofile
 // EXCLUDE: @test2
 unsigned test2() {
-  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0), align 8
-  // FUNC-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], 
[1 x i64]* @__profc_test2, i64 0, i64 0), align 8
-  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0), align 8
-  // SECTION: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0), align 8
-  // EXCLUDE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0), align 8
+  // CHECK: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0)
+  // FUNC-NOT: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], 
[1 x i64]* @__profc_test2, i64 0, i64 0)
+  // FILE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x 
i64]* @__profc_test2, i64 0, i64 0)
+  // SECTION: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0)
+  // EXCLUDE: %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* @__profc_test2, i64 0, i64 0)
   return i - 1;
 }



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


[clang] c5e7e64 - [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-29 Thread Pavel Iliin via cfe-commits

Author: Pavel Iliin
Date: 2021-01-29T17:44:45Z
New Revision: c5e7e649d537067dec7111f3de1430d0fc8a4d11

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

LOG: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

Generate outline atomics if compiling for armv8-a non-LSE AArch64 Linux
(including Android) targets to use LSE instructions, if they are available,
at runtime. Library support is checked by clang driver which doesn't enable
outline atomics if no proper libraries (libgcc >= 9.3.1 or compiler-rt) found.

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

Added: 

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/crtbegin.o

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/libgcc.a

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/crtbegin.o

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/libgcc.a

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/crtbegin.o

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/libgcc.a

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/crtbegin.o

clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/libgcc.a

Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/aarch64-features.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 28c37a44e1eb..59fdd2997fec 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -456,6 +456,12 @@ class ToolChain {
   /// by default.
   virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
 
+  /// Test whether this toolchain supports outline atomics by default.
+  virtual bool
+  IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const {
+return false;
+  }
+
   /// Test whether this toolchain defaults to PIC.
   virtual bool isPICDefault() const = 0;
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7bac2b1df17d..b0379aece75b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6500,6 +6500,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   CmdArgs.push_back("-target-feature");
   CmdArgs.push_back("-outline-atomics");
 }
+  } else if (Triple.isAArch64() &&
+ getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
+CmdArgs.push_back("-target-feature");
+CmdArgs.push_back("+outline-atomics");
   }
 
   if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 9663a7390ada..5f0ce69fc5e6 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -836,6 +836,19 @@ bool Linux::isPIEDefault() const {
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
+  // Outline atomics for AArch64 are supported by compiler-rt
+  // and libgcc since 9.3.1
+  assert(getTriple().isAArch64() && "expected AArch64 target!");
+  ToolChain::RuntimeLibType RtLib = GetRuntimeLibType(Args);
+  if (RtLib == ToolChain::RLT_CompilerRT)
+return true;
+  assert(RtLib == ToolChain::RLT_Libgcc && "unexpected runtime library type!");
+  if (GCCInstallation.getVersion().isOlderThan(9, 3, 1))
+return false;
+  return true;
+}
+
 bool Linux::isNoExecStackDefault() const {
 return getTriple().isAndroid();
 }

diff  --git a/clang/lib/Driver/ToolChains/Linux.h 
b/clang/lib/Driver/ToolChains/Linux.h
index 6b16b0e64990..a45236bc10d3 100644
--- a/clang/lib/Driver/ToolChains/Linux.h
+++ b/clang/lib/Driver/ToolChains/Linux.h
@@ -36,6 +36,8 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetDefaultCXXStdlibType() const override;
+  bool
+  IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const 
override;
   bool isPIEDefault() const override;
   bool isNoExecStackDefault() const override;
   bool IsMathErrnoDefault() const override;

diff  --git 
a/clang/test/Driver/Inputs/aarch64-lin

[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-29 Thread Pavel Iliin 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 rGc5e7e649d537: [AArch64][Clang][Linux] Enable out-of-line 
atomics by default. (authored by ilinpv).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/libgcc.a
  clang/test/Driver/aarch64-features.c

Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -6,3 +6,60 @@
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 
+// Check for AArch64 out-of-line atomics default settings.
+// RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target arm64-unknown-linux -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64--none-eabi -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-windows-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-unknown-openbsd -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target arm64-linux -rtlib=compiler-rt -mno-outline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck \
+// RUN: -check-prefixes=CHECK-OUTLINE-ATOMICS-OFF,CHECK-NO-OUTLINE-ATOMICS %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc -mno-outline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck \
+// RUN: -check-prefixes=CHECK-OUTLINE-ATOMICS-OFF,CHECK-NO-OUTLINE-ATOMICS %s
+
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt -moutline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-windows-gnu -rtlib=libgcc -moutline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// CHECK-OUTLINE-ATOMICS-ON: "-target-feature" "+outline-atomics"
+// CHECK-OUTLINE-ATOMICS-OFF-NOT: "-target-feature" "+outline-atomics"
+// CHECK-NO-OUTLINE-ATOMICS: "-target-feature" "-outline-atomics"
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -36,6 +36,8 @@
   void AddIAMCUIncludeArgs(const

[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-29 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4133
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group;
-def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group;
+def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Flags<[FlangOption, FC1Option]>,
+  Group, HelpText<"Use  as character line width in 
fixed mode">,

Why isn't this `-ffixed-line-length=` (i.e. with an equals sign, not a 
hyphen)? Isn't that how clang does options with values? It's fine to support 
the gfortran form as an alternative but I think the primary goal should be good 
consistent style for options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

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


[PATCH] D95369: [clang][cli] Generate and round-trip analyzer options

2021-01-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:822
+
 static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags) {

jansvoboda11 wrote:
> dexonsmith wrote:
> > Can you rename this `ParseAnalyzerArgsImpl` for better readability?
> I left this unchanged to keep the diff (and merge conflicts) minimal. We 
> would rename it back to `ParseAnalyzerArgs` in a few weeks anyway (when we 
> drop granular round-tripping in favor of one big round-trip).
I still have a preference for somehow varying the two names despite the minor 
churn — maybe the other one could be parseAnalyzerArgsWithRoundTrip — but it’s 
up to you (still LGTM as-is).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95369

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-29 Thread Faris via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 320145.
FarisRehman added a comment.

Remove -fno-fixed-form and -fno-free-form

Remove options `-fno-fixed-form` and `-fno-free-form` allowing for help 
messages to be added to `-ffixed-form` and `-ffree-form`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/fixed-form-test.f
  flang/test/Flang-Driver/Inputs/fixed-line-length-test.f
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/fixed-free-flag.f90
  flang/test/Flang-Driver/fixed-line-length.f90

Index: flang/test/Flang-Driver/fixed-line-length.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-line-length.f90
@@ -0,0 +1,50 @@
+! Ensure argument -ffixed-line-length-n works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -E -ffixed-line-length--2 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang-new -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: %flang-new -fc1 -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length--2 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!-
+! EXPECTED OUTPUT WITH DEFAULT LENGTH
+!-
+! The line should be trimmed to 72 characters when reading based on the default value of fixed line length.
+! DEFAULTLENGTH: program{{(a{58})}}
+
+!-
+! EXPECTED OUTPUT WITH A NEGATIVE LENGTH
+!-
+! NEGATIVELENGTH: invalid value '-2' in 'ffixed-line-length-','value must be 'none' or a non-negative integer'
+
+!-
+! EXPECTED OUTPUT WITH LENGTH LESS THAN 7
+!-
+! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length-','value must be at least seven'
+
+!---
+! EXPECTED OUTPUT WITH UNLIMITED LENGTH
+!---
+! The line should not be trimmed and so 73 characters (including spaces) should be read.
+! UNLIMITEDLENGTH: program{{(a{59})}}
+
+!
+! EXPECTED OUTPUT WITH LENGTH 13
+!
+! LENGTH13: program
Index: flang/test/Flang-Driver/fixed-free-flag.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-free-flag.f90
@@ -0,0 +1,25 @@
+! Ensure arguments -ffree-form and -ffixed-form work as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -ffree-form %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FREEFORM
+! RUN: %flang-new -fsyntax-only -ffixed-form %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FIXEDFORM
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: not %flang-new -fc1 -fsyntax-only -ffree-form %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s

[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Alternatively, there's `LinkerIsLLD` in the driver code, maybe the driver wants 
to check that in some way (if only to emit a better diag if it's false, I guess)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95665: [Builtins][FIX] Allow targets to opt-out of `long double` builtins

2021-01-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

For target-specific builtins I ended up implementing this: 
https://github.com/llvm/llvm-project/commit/81a73fde5cea304d31294fd26c2f051f1685e97c
 at one point to make sure that 'host' builtins get looked up in the aux-target 
if necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95665

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Landed revert in 1608ba09462d877111230e9461b895f696f8fcb1 
. Someone 
should file a PR to make sure that gets merged to the 12.0 branch.

We can then reland on trunk once there are clear instructions for folks 
building with trunk clang but old NDK but without the toolchain file (either 
"use toolchain file" or "set LLVM_USE_LLD" or something like that, I'm 
guessing?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95665: [Builtins][FIX] Allow targets to opt-out of `long double` builtins

2021-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I tried this patch with our CI and it breaks HIP and OpenMP. I suspect it may 
also break CUDA. It seems in device compilation, when a host function calls a 
builtin with long double argument, the builtin is not found. My guess is that 
the target for checking builtin needs to be caller dependent. E.g. in device 
compilation, when checking builtin called by a host function, aux-target and 
aux-cpu should be used. Then this raises another question: what to use for host 
device function? It seems for this to work, the dianostic about missing builtin 
needs to be also deferred diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95665

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


[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-29 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv updated this revision to Diff 320142.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/libgcc.a
  clang/test/Driver/aarch64-features.c

Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -6,3 +6,60 @@
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 
+// Check for AArch64 out-of-line atomics default settings.
+// RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target arm64-unknown-linux -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64--none-eabi -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-windows-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-unknown-openbsd -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang -target arm64-linux -rtlib=compiler-rt -mno-outline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck \
+// RUN: -check-prefixes=CHECK-OUTLINE-ATOMICS-OFF,CHECK-NO-OUTLINE-ATOMICS %s
+
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc -mno-outline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck \
+// RUN: -check-prefixes=CHECK-OUTLINE-ATOMICS-OFF,CHECK-NO-OUTLINE-ATOMICS %s
+
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt -moutline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// RUN: %clang -target aarch64-windows-gnu -rtlib=libgcc -moutline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+
+// CHECK-OUTLINE-ATOMICS-ON: "-target-feature" "+outline-atomics"
+// CHECK-OUTLINE-ATOMICS-OFF-NOT: "-target-feature" "+outline-atomics"
+// CHECK-NO-OUTLINE-ATOMICS: "-target-feature" "-outline-atomics"
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -36,6 +36,8 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetDefaultCXXStdlibType() const override;
+  bool
+  IsAArch64OutlineAtomic

[clang] 1608ba0 - Revert "Disable rosegment for old Android versions."

2021-01-29 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-01-29T11:20:48-05:00
New Revision: 1608ba09462d877111230e9461b895f696f8fcb1

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

LOG: Revert "Disable rosegment for old Android versions."

This reverts commit fae16fc0eed7cf60207901818cfe040116f2ef00.
Breaks building compiler-rt android runtimes with trunk clang
but older NDK, see discussion on https://reviews.llvm.org/D95166

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index e17a6bd4bdd2..9663a7390ada 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,15 +236,6 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
 ExtraOpts.push_back("relro");
   }
 
-  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
-// https://github.com/android/ndk/issues/1196
-// The unwinder used by the crash handler on versions of Android prior to
-// API 29 did not correctly handle binaries built with rosegment, which is
-// enabled by default for LLD. Android only supports LLD, so it's not an
-// issue that this flag is not accepted by other linkers.
-ExtraOpts.push_back("--no-rosegment");
-  }
-
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 0b788ffcb852..24d3c78643f8 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1089,20 +1089,6 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
-// Check that we pass --no-rosegment for pre-29 Android versions and do not for
-// 29+.
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=armv7-linux-android28 \
-// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
-// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
-//
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=armv7-linux-android29 \
-// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
-// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
-
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s



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


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck accepted this revision.
frasercrmck added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95680

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


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.

LGTM modulo one additional request: please update the comment at the top of 
RISCVInstrInfoV.td to say "0.10" rather than "0.9".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95680

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks us too: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1172291

Given that this breaks at least 3 distinct build configs, let's revert this for 
now until we've figured out a path forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95583: Frontend: Add -f{, no-}implicit-modules-uses-lock and -Rmodule-lock

2021-01-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Modules/implicit-modules-use-lock.m:21
+
+// CHECK-NO-LOCKS-NOT: remark:
+// CHECK-LOCKS: remark: locking '{{.*}}.pcm' to build module 'X' 
[-Rmodule-lock]

jansvoboda11 wrote:
> Where is the empty remark coming from? Is it useful to us in any way?
This is a `CHECK-NOT: ` line (with a custom `-check-prefix`). It 
confirms that `` does not occur at least until the next positive check 
matches. The `FileCheck` invocation that uses `CHECK-NO-LOCKS` has no other 
check lines, so this really means: "`remark:` does not match on any line". Note 
I also needed to add `-allow-empty` since with no diagnostics at all, 
`FileCheck`'s stdin will be empty.

FYI, if you want to read more:
- `-check-prefix` is documented at 
https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-filecheck-check-prefix-option
- `CHECK-NOT` is documented at 
https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-check-not-directive

Often in clang tests it's easier to use `-cc1 -verify` for diagnostics instead 
of manual `FileCheck`s (`expected-no-diagnostics` comment being the equivalent 
of `-allow-empty`). In the modules testcases, there's often a complicated setup 
that we want to run a lot of `RUN:` lines against where each one expects 
different diagnostics. Maybe we should add prefix support to `-verify` (or 
maybe it's there and no one told me...).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95583

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


[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-01-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:684-685
+  if (!GeneratedStringsEqual)
+llvm::report_fatal_error("Mismatch between arguments generated during "
+ "round-trip");
+

jansvoboda11 wrote:
> dexonsmith wrote:
> > Another option vs. report_fatal_error would be to create (fatal) clang 
> > error diagnostics. That applies here, and to my previous comments. WDYT? 
> > (@Bigcheese, any thoughts?)
> > 
> > Also, I think `-round-trip-args-debug` might not be super discoverable. 
> > Maybe we can add a comment in the code where the errors are reported 
> > suggesting adding that.
> If we decide to go with custom diagnostics instead of just using `llvm::errs` 
> and `llvm::report_fatal_error`, we'd need to instantiate a custom 
> `DiagnosticsEngine` here in `RoundTrip`, because we cannot rely on clients 
> passing us reasonable `Diags`.
> 
> One such example is `CompilerInvocationTest`, where we don't care what 
> diagnostics get emitted (by using `TextDiagnosticBuffer` consumer). The 
> errors we're emitting here would be still useful to see when testing though.
I'm not entirely following why this would need a custom Diags. If the client 
wants to ignore diagnostics that should be up to the client, especially in 
clang-as-a-library situations. In fact, using `errs` or `dbgs` at all is pretty 
iffy when clang is used as a library.

For CompilerInvocationTest, I imagine we could change the consumer / test 
fixture / etc. somehow to capture this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM for amdgpu changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[PATCH] D95575: clang-cl: Accept /std:c11, /std:c17 flags

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd087d805acb6: clang-cl: Accept /std:c11, /std:c17 flags 
(authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95575

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -337,6 +337,9 @@
 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix 
CHECK-CHAR8_T_ %s
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
+// RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix 
CHECK-C11 %s
+// CHECK-C11: -std=c11
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5204,6 +5204,7 @@
   //
   // If a std is supplied, only add -trigraphs if it follows the
   // option.
+  bool ImplyVCPPCVer = false;
   bool ImplyVCPPCXXVer = false;
   const Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi);
   if (Std) {
@@ -5228,9 +5229,13 @@
 // doesn't match. For the time being just ignore this for C++ inputs;
 // eventually we want to do all the standard defaulting here instead of
 // splitting it between the driver and clang -cc1.
-if (!types::isCXX(InputType))
-  Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, "-std=",
-/*Joined=*/true);
+if (!types::isCXX(InputType)) {
+  if (!Args.hasArg(options::OPT__SLASH_std)) {
+Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, 
"-std=",
+  /*Joined=*/true);
+  } else
+ImplyVCPPCVer = true;
+}
 else if (IsWindowsMSVC)
   ImplyVCPPCXXVer = true;
 
@@ -5848,6 +5853,20 @@
 Args.MakeArgString("-fms-compatibility-version=" + 
MSVT.getAsString()));
 
   bool IsMSVC2015Compatible = MSVT.getMajor() >= 19;
+  if (ImplyVCPPCVer) {
+StringRef LanguageStandard;
+if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
+  Std = StdArg;
+  LanguageStandard = llvm::StringSwitch(StdArg->getValue())
+ .Case("c11", "-std=c11")
+ .Case("c17", "-std=c17")
+ .Default("");
+  if (LanguageStandard.empty())
+D.Diag(clang::diag::warn_drv_unused_argument)
+<< StdArg->getAsString(Args);
+}
+CmdArgs.push_back(LanguageStandard.data());
+  }
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5604,7 +5604,7 @@
   HelpText<"Set runtime encoding, supports only UTF-8">,
   Alias;
 def _SLASH_std : CLCompileJoined<"std:">,
-  HelpText<"Set C++ version (c++14,c++17,c++latest)">;
+  HelpText<"Set language version (c++14,c++17,c++latest,c11,c17)">;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
   MetaVarName<"">, Alias;
 def _SLASH_validate_charset : CLFlag<"validate-charset">,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -337,6 +337,9 @@
 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T_ %s
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
+// RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix CHECK-C11 %s
+// CHECK-C11: -std=c11
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5204,6 +5204,7 @@
   //
   // If a std is supplied, only add -trigraphs if it follows the
   // option.
+  bool ImplyVCPPCVer = false;
   bool ImplyVCPPCXXVer = false;
   const Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi);
   if (Std) {
@@ -5228,9 +5229,13 @@
 // doesn't match. For the time being just ignore this for C++ inputs;
 // eventually we want to do all the standar

[clang] d087d80 - clang-cl: Accept /std:c11, /std:c17 flags

2021-01-29 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-01-29T09:59:00-05:00
New Revision: d087d805acb664e885e9c31a916f6cfa5dbc2186

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

LOG: clang-cl: Accept /std:c11, /std:c17 flags

clang-cl already defaults to C17 for .c files, but no harm
in accepting these flags. Fixes PR48185.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 845f5be55ae7..a13a83eba6d5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5604,7 +5604,7 @@ def _SLASH_execution_charset : 
CLCompileJoined<"execution-charset:">,
   HelpText<"Set runtime encoding, supports only UTF-8">,
   Alias;
 def _SLASH_std : CLCompileJoined<"std:">,
-  HelpText<"Set C++ version (c++14,c++17,c++latest)">;
+  HelpText<"Set language version (c++14,c++17,c++latest,c11,c17)">;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
   MetaVarName<"">, Alias;
 def _SLASH_validate_charset : CLFlag<"validate-charset">,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index fdb8a58cd1b3..7bac2b1df17d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5204,6 +5204,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   //
   // If a std is supplied, only add -trigraphs if it follows the
   // option.
+  bool ImplyVCPPCVer = false;
   bool ImplyVCPPCXXVer = false;
   const Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi);
   if (Std) {
@@ -5228,9 +5229,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 // doesn't match. For the time being just ignore this for C++ inputs;
 // eventually we want to do all the standard defaulting here instead of
 // splitting it between the driver and clang -cc1.
-if (!types::isCXX(InputType))
-  Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, "-std=",
-/*Joined=*/true);
+if (!types::isCXX(InputType)) {
+  if (!Args.hasArg(options::OPT__SLASH_std)) {
+Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, 
"-std=",
+  /*Joined=*/true);
+  } else
+ImplyVCPPCVer = true;
+}
 else if (IsWindowsMSVC)
   ImplyVCPPCXXVer = true;
 
@@ -5848,6 +5853,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 Args.MakeArgString("-fms-compatibility-version=" + 
MSVT.getAsString()));
 
   bool IsMSVC2015Compatible = MSVT.getMajor() >= 19;
+  if (ImplyVCPPCVer) {
+StringRef LanguageStandard;
+if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
+  Std = StdArg;
+  LanguageStandard = llvm::StringSwitch(StdArg->getValue())
+ .Case("c11", "-std=c11")
+ .Case("c17", "-std=c17")
+ .Default("");
+  if (LanguageStandard.empty())
+D.Diag(clang::diag::warn_drv_unused_argument)
+<< StdArg->getAsString(Args);
+}
+CmdArgs.push_back(LanguageStandard.data());
+  }
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 73f7026c65e6..226dc446028f 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -337,6 +337,9 @@
 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix 
CHECK-CHAR8_T_ %s
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
+// RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix 
CHECK-C11 %s
+// CHECK-C11: -std=c11
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"



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


[PATCH] D95665: [Builtins][FIX] Allow targets to opt-out of `long double` builtins

2021-01-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Can you show any tests where this builtin would be a part of the aux-triple, 
and not in active code?  So an nvptx triple, x86_64 aux-triple, and in 
non-device code?  (such as in a CUDA app)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95665

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


[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82847436e925: clang-cl: Invent a /winsysroot concept 
(authored by thakis).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D95534?vs=319949&id=320126#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95534

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-sysroot.cpp

Index: clang/test/Driver/cl-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/cl-sysroot.cpp
@@ -0,0 +1,34 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cl /winsysroot %t -### -- %t/foo.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cl /vctoolsdir %t/VC/Tools/MSVC/27.1828.18284 \
+// RUN:   /winsdkdir "%t/Windows Kits/10" \
+// RUN:   -### -- %t/foo.cpp 2>&1 | FileCheck %s
+
+// CHECK: "-internal-isystem" "[[ROOT:[^"]*]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}atlmfc{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}ucrt"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}shared"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}um"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}winrt"
+
+#--- VC/Tools/MSVC/27.1828.18284/include/string
+namespace std {
+class mystring {
+public:
+  bool empty();
+};
+}
+
+#--- Windows Kits/10/Include/10.0.19041.0/ucrt/assert.h
+#define myassert(X)
+
+#--- foo.cpp
+#include 
+#include 
+
+void f() {
+  std::mystring s;
+  myassert(s.empty());
+}
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -66,14 +66,49 @@
 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
 std::string &value, std::string *phValue);
 
+static std::string getHighestNumericTupleInDirectory(StringRef Directory) {
+  std::string Highest;
+  llvm::VersionTuple HighestTuple;
+
+  std::error_code EC;
+  for (llvm::sys::fs::directory_iterator DirIt(Directory, EC), DirEnd;
+   !EC && DirIt != DirEnd; DirIt.increment(EC)) {
+if (!llvm::sys::fs::is_directory(DirIt->path()))
+  continue;
+StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
+llvm::VersionTuple Tuple;
+if (Tuple.tryParse(CandidateName)) // tryParse() returns true on error.
+  continue;
+if (Tuple > HighestTuple) {
+  HighestTuple = Tuple;
+  Highest = CandidateName.str();
+}
+  }
+
+  return Highest;
+}
+
 // Check command line arguments to try and find a toolchain.
 static bool
 findVCToolChainViaCommandLine(const ArgList &Args, std::string &Path,
   MSVCToolChain::ToolsetLayout &VSLayout) {
   // Don't validate the input; trust the value supplied by the user.
   // The primary motivation is to prevent unnecessary file and registry access.
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
-Path = A->getValue();
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir,
+   options::OPT__SLASH_winsysroot)) {
+if (A->getOption().getID() == options::OPT__SLASH_winsysroot) {
+  llvm::SmallString<128> ToolsPath(A->getValue());
+  llvm::sys::path::append(ToolsPath, "VC", "Tools", "MSVC");
+  std::string VCToolsVersion;
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsversion))
+VCToolsVersion = A->getValue();
+  else
+VCToolsVersion = getHighestNumericTupleInDirectory(ToolsPath);
+  llvm::sys::path::append(ToolsPath, VCToolsVersion);
+  Path = std::string(ToolsPath.str());
+} else {
+  Path = A->getValue();
+}
 VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
 return true;
   }
@@ -345,7 +380,8 @@
   // they're doing. If the user passes /vctoolsdir or /winsdkdir, trust that
   // over env vars.
   if (!llvm::sys::Process::GetEnv("LIB") ||
-  Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+  Args.getLastArg(options::OPT__SLASH_vctoolsdir,
+  options::OPT__SLASH_winsysroot)) {
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-libpath:") +
 TC.getSubDirectoryPath(
@@ -356,7 +392,8 @@
"atlmfc")));
   }
   if (!llvm::sys::Process::GetEnv("LIB") ||
-  Args.g

[clang] 8284743 - clang-cl: Invent a /winsysroot concept

2021-01-29 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-01-29T09:47:00-05:00
New Revision: 82847436e9258a12503dcfadb5dc373cb42fea43

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

LOG: clang-cl: Invent a /winsysroot concept

On non-Windows platforms, --sysroot can be used to make the compiler use
a single, hermetic directory for all header and library files.

This is useful, but difficult to do on Windows. After D95472 it's
possible to achieve this with two flags:

out/gn/bin/clang-cl win.c -fuse-ld=lld \
/vctoolsdir path/to/VC/Tools/MSVC/14.26.28801 \
/winsdkdir path/to/win_sdk

But that's still cumbersome: It requires two flags instead of one, and
it requires writing down the (changing) VC/Tools/MSVC version.

This adds a new `/winsysroot ` flag that's effectively an alias to
these two flags. With this, building against a hermetic Windows
toolchain only needs:

out/gn/bin/clang-cl win.c -fuse-ld=lld /winsysroot path

`/winsysroot ` is the same as adding

/vctoolsdir /VC/Tools/MSVC/
/winsdkdir /Windows Kits/

`` is taken from `/vctoolsversion` if passed, or else it's
the name of the directory in `/VC/Tools/MSVC` that's the highest
numeric tuple.

`` is the major version in /winsdkversion if passed,
else it's the name of the directory in `/Windows Kits` that's the
highest number.

So `/winsysroot ` requires this subfolder structure:

  path/
VC/
  Tools/
MSVC/
  14.26.28801  (or another number)
include/
...
Windows Kits/
  10/
Include/
  10.0.19041.0/ (or another number)
um/
...
Lib/
  10.0.19041.0/ (or another number)
um/
  x64/
  ...
...

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

Added: 
clang/test/Driver/cl-sysroot.cpp

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/MSVC.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 77f13e21bb18..845f5be55ae7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5762,10 +5762,15 @@ def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">,
 def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">;
 def _SLASH_vctoolsdir : CLJoinedOrSeparate<"vctoolsdir">,
   HelpText<"Path to the VCToolChain">, MetaVarName<"">;
+def _SLASH_vctoolsversion : CLJoinedOrSeparate<"vctoolsversion">,
+  HelpText<"For use with /winsysroot, defaults to newest found">;
 def _SLASH_winsdkdir : CLJoinedOrSeparate<"winsdkdir">,
   HelpText<"Path to the Windows SDK">, MetaVarName<"">;
 def _SLASH_winsdkversion : CLJoinedOrSeparate<"winsdkversion">,
-  HelpText<"Full version of the Windows SDK">;
+  HelpText<"Full version of the Windows SDK, defaults to newest found">;
+def _SLASH_winsysroot : CLJoinedOrSeparate<"winsysroot">,
+  HelpText<"Same as /vctoolsdir /VC/Tools/MSVC/ 
/winsdkdir /Windows Kits/10">,
+  MetaVarName<"">;
 def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>,
   Group<_SLASH_volatile_Group>, Flags<[CLOption, NoXarchOption]>,
   HelpText<"Volatile loads and stores have standard semantics">;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 9253ca6c2cb4..1fc517cebd1c 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -66,14 +66,49 @@ using namespace llvm::opt;
 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
 std::string &value, std::string *phValue);
 
+static std::string getHighestNumericTupleInDirectory(StringRef Directory) {
+  std::string Highest;
+  llvm::VersionTuple HighestTuple;
+
+  std::error_code EC;
+  for (llvm::sys::fs::directory_iterator DirIt(Directory, EC), DirEnd;
+   !EC && DirIt != DirEnd; DirIt.increment(EC)) {
+if (!llvm::sys::fs::is_directory(DirIt->path()))
+  continue;
+StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
+llvm::VersionTuple Tuple;
+if (Tuple.tryParse(CandidateName)) // tryParse() returns true on error.
+  continue;
+if (Tuple > HighestTuple) {
+  HighestTuple = Tuple;
+  Highest = CandidateName.str();
+}
+  }
+
+  return Highest;
+}
+
 // Check command line arguments to try and find a toolchain.
 static bool
 findVCToolChainViaCommandLine(const ArgList &Args, std::string &Path,
   MSVCToolChain::ToolsetLayout &VSLayout) {
   // Don't validate the input; trust the value supplied by the user.
   // The primary motivation is to prevent unnecessary file and registry access.
-  if (Arg *A = Args.getLastArg(options::

[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-01-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/test/Driver/cl-sysroot.cpp:10
+
+// CHECK: "-internal-isystem" "[[ROOT]]/VC/Tools/MSVC/14.26.28801/include"
+// CHECK: "-internal-isystem" 
"[[ROOT]]/VC/Tools/MSVC/14.26.28801/atlmfc/include"

hans wrote:
> could the slashes be backslashes when this test runs on a windows machine?
Yes, thanks. Even worse, the whole -DFOO=%t approach doesn't work because clang 
escapes %t for the driver, which double all the slashes etc. Instead gave the 
toolsdir a number that no real msvc install should use and then captured the 
root dir via filecheck from there.


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

https://reviews.llvm.org/D95534

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


[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-29 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM too.

One nit inlined that can be addressed before committing.




Comment at: clang/test/Driver/aarch64-features.c:47
+// CHECK-OUTLINE-ATOMICS-ON: "-target-feature" "+outline-atomics"
+// CHECK-OUTLINE-ATOMICS-OFF-NOT: "-target-feature" "+outline-atomics"

Probably better to just check for the OFF case:

  "-target-feature" "-outline-atomics"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

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


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added a comment.
This revision is now accepted and ready to land.

\o/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95680

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


[PATCH] D95680: [RISCV] Update the version number to v0.10 for vector.

2021-01-29 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, jrtc27, rogfer01, frasercrmck, evandro.
Herald added subscribers: vkmr, NickHung, jdoerfert, luismarques, apazos, 
sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

v0.10 is tagged in V specification. Update the version to v0.10.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95680

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,7 +40,7 @@
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v1p0"
+# CHECK: attribute  5, "rv32i2p0_v0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
@@ -79,7 +79,7 @@
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1"
 
 .attribute arch, "rv32ivzvamo_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 
-.attribute arch, "rv32iv_zvamo1p0_zvlsseg"
-# CHECK: attribute  5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+.attribute arch, "rv32iv_zvamo0p10_zvlsseg"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,7 +47,7 @@
 ; RV32D: .attribute 5, "rv32i2p0_f2p0_d2p0"
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32B: .attribute 5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
-; RV32V: .attribute 5, "rv32i2p0_v1p0_zvamo1p0_zvlsseg1p0"
+; RV32V: .attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
 ; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
 ; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
@@ -60,7 +60,7 @@
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
 ; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -80,8 +80,8 @@
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
 ; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
-; RV64V: .attribute 5, "rv64i2p0_v1p0_zvamo1p0_zvlsseg1p0"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v1p0_zfh0p1_zbb0p93_zvamo1p0_zvlsseg1p0"
+; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -63,7 +63,7 @@
   if (STI.hasFeature(RISCV::FeatureStdExtB))
 Arch += "_b0p93";
   if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v1p0";
+Arch += "_v0p10";
   if (STI.hasFeature(RISCV::FeatureExtZfh))
 Arch += "_zfh0p1";
   if (STI.hasFeature(RISCV::FeatureExtZba))
@@ -89,9 +89,9 @@
   if (STI.hasFeature(RISCV::FeatureExtZbt))
 Arch += "_zbt0p93";
   if (STI.hasFeature(RISCV::FeatureExtZvamo))
-Arch += "_zvamo1p0";
+Arch += "_zvamo0p10";
   if (STI.hasFeature(RISCV::FeatureStdExtZvlsseg))
-Arch += "_zvlsseg1p0";
+Arch += "_zvlsseg0p10";
 
   emitTextAttribute(RISCVAttrs::ARCH, Arch);
 }
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2126,7 +2126,7 @@
   if (getFeatureBits(RISCV::FeatureStdExtB))
 formalArchStr = (Twine(formalArchStr) + "_b0p93").str();
   if (getFeatureBits(RISCV::FeatureStdExtV))
-formalArchStr = (Twine(formalArchStr) + "_v1p0").str();
+

[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-29 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv updated this revision to Diff 320123.
ilinpv added a comment.

Tests for "-m[no]outline-atomics" options added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-10/lib/gcc/aarch64-unknown-linux-gnu/10/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0/lib/gcc/aarch64-unknown-linux-gnu/7.5.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/libgcc.a
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/crtbegin.o
  
clang/test/Driver/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1/lib/gcc/aarch64-unknown-linux-gnu/9.3.1/libgcc.a
  clang/test/Driver/aarch64-features.c

Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -6,3 +6,42 @@
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 
+// Check for AArch64 out-of-line atomics default settings.
+// RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target arm64-unknown-linux -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64--none-eabi -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-windows-gnu -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-unknown-openbsd -rtlib=compiler-rt \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.1 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-9.3.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target arm64-linux -rtlib=compiler-rt -mno-outline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc -mno-outline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-10 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+// RUN: %clang -target aarch64-apple-darwin -rtlib=compiler-rt -moutline-atomics \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// RUN: %clang -target aarch64-windows-gnu -rtlib=libgcc -moutline-atomics \
+// RUN: --gcc-toolchain=%S/Inputs/aarch64-linux-gnu-tree/gcc-7.5.0 \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
+// CHECK-OUTLINE-ATOMICS-ON: "-target-feature" "+outline-atomics"
+// CHECK-OUTLINE-ATOMICS-OFF-NOT: "-target-feature" "+outline-atomics"
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -36,6 +36,8 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetDefaultCXXStdlibType() const override;
+  bool
+  IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
  

[clang-tools-extra] 7d1b499 - Revert "[clangd] Extract symbol-scope logic out of Quality, add tests. NFC"

2021-01-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-01-29T14:59:16+01:00
New Revision: 7d1b499caef6ebde09a2697a97b43b89f7fa35c8

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

LOG: Revert "[clangd] Extract symbol-scope logic out of Quality, add tests. NFC"

On second thought, this can't properly be reused for highlighting.

Consider this example, which Quality wants to consider function-scope,
but highlighting must consider class-scope:

void foo() {
  class X {
int ^y;
  };
}

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Quality.h
clang-tools-extra/clangd/quality/CompletionModelCodegen.py
clang-tools-extra/clangd/quality/model/features.json
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/QualityTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index f71d935c204c..aecaf7e6b8f7 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -478,29 +478,5 @@ bool hasUnstableLinkage(const Decl *D) {
   return VD && !VD->getType().isNull() && VD->getType()->isUndeducedType();
 }
 
-SymbolScope symbolScope(const NamedDecl &D) {
-  // Injected "Foo" within the class "Foo" has file scope, not class scope.
-  const DeclContext *DC = D.getDeclContext();
-  if (auto *R = dyn_cast(&D))
-if (R->isInjectedClassName())
-  DC = DC->getParent();
-  // Class constructor should have the same scope as the class.
-  if (isa(D))
-DC = DC->getParent();
-  bool InClass = false;
-  for (; !DC->isFileContext(); DC = DC->getParent()) {
-if (DC->isFunctionOrMethod())
-  return SymbolScope::FunctionScope;
-InClass = InClass || DC->isRecord();
-  }
-  if (InClass)
-return SymbolScope::ClassScope;
-  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
-  // Avoid caching linkage if it may change after enclosing code completion.
-  if (hasUnstableLinkage(&D) || D.getLinkageInternal() < ExternalLinkage)
-return SymbolScope::FileScope;
-  return SymbolScope::GlobalScope;
-}
-
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index 1baf8c585fd2..b603964189e8 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -162,15 +162,6 @@ std::string getQualification(ASTContext &Context,
 /// the cached value is incorrect. (clang catches this with an assertion).
 bool hasUnstableLinkage(const Decl *D);
 
-/// An approximate measure of where we expect a symbol to be used.
-enum class SymbolScope {
-  FunctionScope,
-  ClassScope,
-  FileScope,
-  GlobalScope,
-};
-SymbolScope symbolScope(const NamedDecl &D);
-
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index eb0df5fd4dd9..1d1027319dfb 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1726,7 +1726,7 @@ class CodeCompleteFlow {
   }
   if (Candidate.IdentifierResult) {
 Quality.References = Candidate.IdentifierResult->References;
-Relevance.ScopeKind = SymbolScope::FileScope;
+Relevance.Scope = SymbolRelevanceSignals::FileScope;
 Origin |= SymbolOrigin::Identifier;
   }
 }

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 28b44bd0d4a1..b49392bc7d04 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -262,12 +262,37 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   return OS;
 }
 
+static SymbolRelevanceSignals::AccessibleScope
+computeScope(const NamedDecl *D) {
+  // Injected "Foo" within the class "Foo" has file scope, not class scope.
+  const DeclContext *DC = D->getDeclContext();
+  if (auto *R = dyn_cast_or_null(D))
+if (R->isInjectedClassName())
+  DC = DC->getParent();
+  // Class constructor should have the same scope as the class.
+  if (isa(D))
+DC = DC->getParent();
+  bool InClass = false;
+  for (; !DC->isFileContext(); DC = DC->getParent()) {
+if (DC->isFunctionOrMethod())
+  return SymbolRelevanceSignals::FunctionScope;
+InClass = InClass || DC->isRecord();
+  }
+  if (InClass)
+return SymbolRelevanceSignals::ClassScope;
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (hasUnstableLinkage(D) || D->getLinkageInternal() < ExternalLinkage)
+return SymbolRelevanceSignals::FileSco

[PATCH] D95653: [clang-tidy] Fix linking tests to LLVMTestingSupport

2021-01-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D95653#2530163 , @mgorny wrote:

> In D95653#2529776 , @njames93 wrote:
>
>> I think I introduced this failure due to my abysmal



In D95653#2530163 , @mgorny wrote:

> In D95653#2529776 , @njames93 wrote:
>
>> I think I introduced this failure due to my abysmal knowledge of CMake and 
>> LLVM's library structure, So I'm definitely not qualified to say if this is 
>> a good fix, but seeing as it fixes the linker error I'll give it a tentative 
>> LG.
>
> I'm a bit confused now. Are you telling that I should push it or wait for 
> another review?

I was just saying wait for another reviewer to approve it. But it's all good now


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

https://reviews.llvm.org/D95653

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


[PATCH] D95366: [clang][cli] Generate and round-trip preprocessor options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 320119.
jansvoboda11 edited the summary of this revision.
jansvoboda11 added a comment.

Rename variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95366

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3053,9 +3053,83 @@
   llvm_unreachable("invalid frontend action");
 }
 
-static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
+static void GeneratePreprocessorArgs(PreprocessorOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA,
+ const LangOptions &LangOpts,
+ const FrontendOptions &FrontendOpts,
+ const CodeGenOptions &CodeGenOpts) {
+  PreprocessorOptions *PreprocessorOpts = &Opts;
+
+#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...)  \
+  GENERATE_OPTION_WITH_MARSHALLING(Args, SA, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
+
+  if (Opts.PCHWithHdrStop && !Opts.PCHWithHdrStopCreate)
+GenerateArg(Args, OPT_pch_through_hdrstop_use, SA);
+
+  for (const auto &D : Opts.DeserializedPCHDeclsToErrorOn)
+GenerateArg(Args, OPT_error_on_deserialized_pch_decl, D, SA);
+
+  for (const auto &MP : Opts.MacroPrefixMap)
+GenerateArg(Args, OPT_fmacro_prefix_map_EQ, MP.first + "=" + MP.second, SA);
+
+  if (Opts.PrecompiledPreambleBytes != std::make_pair(0u, false))
+GenerateArg(Args, OPT_preamble_bytes_EQ,
+Twine(Opts.PrecompiledPreambleBytes.first) + "," +
+(Opts.PrecompiledPreambleBytes.second ? "1" : "0"),
+SA);
+
+  for (const auto &M : Opts.Macros) {
+// Don't generate __CET__ macro definitions. They are implied by the
+// -fcf-protection option that is generated elsewhere.
+if (M.first == "__CET__=1" && !M.second &&
+!CodeGenOpts.CFProtectionReturn && CodeGenOpts.CFProtectionBranch)
+  continue;
+if (M.first == "__CET__=2" && !M.second && CodeGenOpts.CFProtectionReturn &&
+!CodeGenOpts.CFProtectionBranch)
+  continue;
+if (M.first == "__CET__=3" && !M.second && CodeGenOpts.CFProtectionReturn &&
+CodeGenOpts.CFProtectionBranch)
+  continue;
+
+GenerateArg(Args, M.second ? OPT_U : OPT_D, M.first, SA);
+  }
+
+  for (const auto &I : Opts.Includes) {
+// Don't generate OpenCL includes. They are implied by other flags that are
+// generated elsewhere.
+if (LangOpts.OpenCL && LangOpts.IncludeDefaultHeader &&
+((LangOpts.DeclareOpenCLBuiltins && I == "opencl-c-base.h") ||
+ I == "opencl-c.h"))
+  continue;
+
+GenerateArg(Args, OPT_include, I, SA);
+  }
+
+  for (const auto &CI : Opts.ChainedIncludes)
+GenerateArg(Args, OPT_chain_include, CI, SA);
+
+  for (const auto &RF : Opts.RemappedFiles)
+GenerateArg(Args, OPT_remap_file, RF.first + ";" + RF.second, SA);
+
+  // Don't handle LexEditorPlaceholders. It is implied by the action that is
+  // generated elsewhere.
+}
+
+static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags,
-  frontend::ActionKind Action) {
+  frontend::ActionKind Action,
+  const FrontendOptions &FrontendOpts) {
+  PreprocessorOptions *PreprocessorOpts = &Opts;
+  bool Success = true;
+
+#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...)  \
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
+
   Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
 Args.hasArg(OPT_pch_through_hdrstop_use);
 
@@ -3126,6 +3200,48 @@
   // "editor placeholder in source file" error in PP only mode.
   if (isStrictlyPreprocessorAction(Action))
 Opts.LexEditorPlaceholders = false;
+
+  return Success;
+}
+
+static bool ParsePreprocessorArgs(CompilerInvocation &Res,
+  PreprocessorOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags,
+  frontend::ActionKind Action,
+  FrontendOptions &FrontendOpts) {
+  auto DummyOpts = std::make_shared();
+
+  auto Parse = [Action](CompilerInvocation &Res, ArgList &Args,
+DiagnosticsEngine &Diags) {
+return ::ParseP

[PATCH] D95366: [clang][cli] Generate and round-trip preprocessor options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3093
+
+static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags,

dexonsmith wrote:
> Can we name this differently, so it's obvious which is being called without 
> looking at the argument list? I suggest `ParsePreprocessorArgsImpl` for this 
> one, since it's doing the actual parsing.
I thought about it and decided to keep it the same. We'd be renaming it back to 
`ParsePreprocessorArgs` in a few weeks, when we round-trip the whole 
CompilerInvocation at once and the need for the fine-grained interposed 
functions disappears.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3215-3216
+
+  return RoundTrip(Parse, Generate, Swap, Res, Args, Diags,
+   "PreprocessorOptions");
 }

dexonsmith wrote:
> Have you considered just defining the lambdas inline in the call to 
> `RoundTrip`? I'm fine either way, but the way clang-format tends to clean 
> this up seems pretty readable to me, and the names don't really add much 
> value since they match the functions being called. Up to you.
In this case, where one of the lambdas contains a long comment, I suggest 
keeping it separate. It's easier to read that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95366

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


[clang-tools-extra] d0817b5 - [clangd] Extract symbol-scope logic out of Quality, add tests. NFC

2021-01-29 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-01-29T14:44:28+01:00
New Revision: d0817b5f18c7bb435012d214f293d4a7839e492e

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

LOG: [clangd] Extract symbol-scope logic out of Quality, add tests. NFC

This prepares for reuse from the semantic highlighting code.

There's a bit of yak-shaving here:
 - when the enum is moved into the clangd namespace, promote it to a
   scoped enum. This means teaching the decision forest infrastructure
   to deal with scoped enums.
 - AccessibleScope isn't quite the right name: e.g. public class members
   are treated as accessible, but still have class scope. So rename to
   SymbolScope.
 - Rename some QualitySignals members to avoid name conflicts.
   (the string) SymbolScope -> Scope
   (the enum) Scope -> ScopeKind

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Quality.h
clang-tools-extra/clangd/quality/CompletionModelCodegen.py
clang-tools-extra/clangd/quality/model/features.json
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/QualityTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index aecaf7e6b8f7..f71d935c204c 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -478,5 +478,29 @@ bool hasUnstableLinkage(const Decl *D) {
   return VD && !VD->getType().isNull() && VD->getType()->isUndeducedType();
 }
 
+SymbolScope symbolScope(const NamedDecl &D) {
+  // Injected "Foo" within the class "Foo" has file scope, not class scope.
+  const DeclContext *DC = D.getDeclContext();
+  if (auto *R = dyn_cast(&D))
+if (R->isInjectedClassName())
+  DC = DC->getParent();
+  // Class constructor should have the same scope as the class.
+  if (isa(D))
+DC = DC->getParent();
+  bool InClass = false;
+  for (; !DC->isFileContext(); DC = DC->getParent()) {
+if (DC->isFunctionOrMethod())
+  return SymbolScope::FunctionScope;
+InClass = InClass || DC->isRecord();
+  }
+  if (InClass)
+return SymbolScope::ClassScope;
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (hasUnstableLinkage(&D) || D.getLinkageInternal() < ExternalLinkage)
+return SymbolScope::FileScope;
+  return SymbolScope::GlobalScope;
+}
+
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index b603964189e8..1baf8c585fd2 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -162,6 +162,15 @@ std::string getQualification(ASTContext &Context,
 /// the cached value is incorrect. (clang catches this with an assertion).
 bool hasUnstableLinkage(const Decl *D);
 
+/// An approximate measure of where we expect a symbol to be used.
+enum class SymbolScope {
+  FunctionScope,
+  ClassScope,
+  FileScope,
+  GlobalScope,
+};
+SymbolScope symbolScope(const NamedDecl &D);
+
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 1d1027319dfb..eb0df5fd4dd9 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1726,7 +1726,7 @@ class CodeCompleteFlow {
   }
   if (Candidate.IdentifierResult) {
 Quality.References = Candidate.IdentifierResult->References;
-Relevance.Scope = SymbolRelevanceSignals::FileScope;
+Relevance.ScopeKind = SymbolScope::FileScope;
 Origin |= SymbolOrigin::Identifier;
   }
 }

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index b49392bc7d04..28b44bd0d4a1 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -262,37 +262,12 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   return OS;
 }
 
-static SymbolRelevanceSignals::AccessibleScope
-computeScope(const NamedDecl *D) {
-  // Injected "Foo" within the class "Foo" has file scope, not class scope.
-  const DeclContext *DC = D->getDeclContext();
-  if (auto *R = dyn_cast_or_null(D))
-if (R->isInjectedClassName())
-  DC = DC->getParent();
-  // Class constructor should have the same scope as the class.
-  if (isa(D))
-DC = DC->getParent();
-  bool InClass = false;
-  for (; !DC->isFileContext(); DC = DC->getParent()) {
-if (DC->isFunctionOrMethod())
-  return SymbolRelevanceSignals::FunctionScope;
-InClass = InClass || DC->isRecord();
-  }
-  if (InClass)
- 

[PATCH] D95369: [clang][cli] Generate and round-trip analyzer options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:822
+
 static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags) {

dexonsmith wrote:
> Can you rename this `ParseAnalyzerArgsImpl` for better readability?
I left this unchanged to keep the diff (and merge conflicts) minimal. We would 
rename it back to `ParseAnalyzerArgs` in a few weeks anyway (when we drop 
granular round-tripping in favor of one big round-trip).



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1002
+
+  return RoundTrip(Parse, Generate, Swap, Res, Args, Diags, "AnalyzerOptions");
+}

dexonsmith wrote:
> I wonder if these lambdas could/should just be defined inline in the call to 
> `RoundTrip`, but up to you to decide.
Why not, clang-format handles the inline lambdas pretty well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95369

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


[PATCH] D95369: [clang][cli] Generate and round-trip analyzer options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 320118.
jansvoboda11 added a comment.

Rebase, inline lambdas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95369

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -763,9 +763,108 @@
   Funcs.insert(Funcs.end(), Values.begin(), Values.end());
 }
 
+static void GenerateAnalyzerArgs(AnalyzerOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  const AnalyzerOptions *AnalyzerOpts = &Opts;
+
+#define ANALYZER_OPTION_WITH_MARSHALLING(...)  \
+  GENERATE_OPTION_WITH_MARSHALLING(Args, SA, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef ANALYZER_OPTION_WITH_MARSHALLING
+
+  if (Opts.AnalysisStoreOpt != RegionStoreModel) {
+switch (Opts.AnalysisStoreOpt) {
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)   \
+  case NAME##Model:\
+GenerateArg(Args, OPT_analyzer_store, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis store.");
+}
+  }
+
+  if (Opts.AnalysisConstraintsOpt != RangeConstraintsModel) {
+switch (Opts.AnalysisConstraintsOpt) {
+#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) \
+  case NAME##Model:\
+GenerateArg(Args, OPT_analyzer_constraints, CMDFLAG, SA);  \
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis constraint.");
+}
+  }
+
+  if (Opts.AnalysisDiagOpt != PD_HTML) {
+switch (Opts.AnalysisDiagOpt) {
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) \
+  case PD_##NAME:  \
+GenerateArg(Args, OPT_analyzer_output, CMDFLAG, SA);   \
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis diagnostic client.");
+}
+  }
+
+  if (Opts.AnalysisPurgeOpt != PurgeStmt) {
+switch (Opts.AnalysisPurgeOpt) {
+#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC)\
+  case NAME:   \
+GenerateArg(Args, OPT_analyzer_purge, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis purge mode.");
+}
+  }
+
+  if (Opts.InliningMode != NoRedundancy) {
+switch (Opts.InliningMode) {
+#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC)\
+  case NAME:   \
+GenerateArg(Args, OPT_analyzer_inlining_mode, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis inlining mode.");
+}
+  }
+
+  for (const auto &CP : Opts.CheckersAndPackages) {
+OptSpecifier Opt =
+CP.second ? OPT_analyzer_checker : OPT_analyzer_disable_checker;
+GenerateArg(Args, Opt, CP.first, SA);
+  }
+
+  AnalyzerOptions ConfigOpts;
+  parseAnalyzerConfigs(ConfigOpts, nullptr);
+
+  for (const auto &C : Opts.Config) {
+// Don't generate anything that came from parseAnalyzerConfigs. It would be
+// redundant and may not be valid on the command line.
+auto Entry = ConfigOpts.Config.find(C.getKey());
+if (Entry != ConfigOpts.Config.end() && Entry->getValue() == C.getValue())
+  continue;
+
+GenerateArg(Args, OPT_analyzer_config, C.getKey() + "=" + C.getValue(), SA);
+  }
+
+  // Nothing to generate for FullCompilerInvocation.
+}
+
 static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags) {
+  AnalyzerOptions *AnalyzerOpts = &Opts;
   bool Success = true;
+
+#define ANALYZER_OPTION_WITH_MARSHALLING(...)  \
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef ANALYZER_OPTION_WITH_MARSHALLING
+
   if (Arg *A = Args.getLastArg(OPT_analyzer_store)) {
 StringRef Name = A->getValue();
 AnalysisStores Value = llvm::StringSwitch(Name)
@@ -889,8 +988,10 @@
   // TODO: Check checke

[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:584-589
+static bool Equal(const ArgStringList &A, const ArgStringList &B) {
+  auto StrEq = [](const char *AElem, const char *BElem) {
+return StringRef(AElem) == StringRef(BElem);
+  };
+  return std::equal(A.begin(), A.end(), B.begin(), B.end(), StrEq);
+}

dexonsmith wrote:
> I suggest inlining `Equal` and defining the lambda directly in the call to 
> `std::equal`; I think that'll be easier to read than having this up here. 
> (Nice to have it split out fo rcompile-time if `RoundTrip` is templated, but 
> I have a suggestion about that below.)
That's fair.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:591-596
+static void Print(ArgStringList &Args, const llvm::Twine &Description) {
+  llvm::dbgs() << Description;
+  for (const char *Arg : Args)
+llvm::dbgs() << " " << Arg;
+  llvm::dbgs() << "\n";
+}

dexonsmith wrote:
> - I think this would be more clear as a local lambda too.
> - I don't think this is the best destination, since `llvm::dbgs()` goes 
> nowhere when `NDEBUG`. Should this go in `errs()`? Or should 
> `-round-trip-args-debug=` take a filename for where to write extra stuff?
> - The arguments won't be correctly formatted for copy-paste if there are any 
> characters that should be escaped. Is the logic from `-###` reusable?
Good point, resolved.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:604-608
+template 
+static bool RoundTrip(ParseFn &&Parse, GenerateFn &&Generate,
+  SwapOptsFn &&SwapOpts, CompilerInvocation &Res,
+  ArgList &OriginalArgs, DiagnosticsEngine &Diags,
+  StringRef OptsName) {

dexonsmith wrote:
> Instead of templating this, can we take `llvm::function_ref`s to type-erase 
> the functions?
Yes, that would be better. I had this templated while I was figuring out what 
their signature should even be. I've extracted typedefs to keep the signature 
of `RoundTrip` readable.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:633
+SwapOpts(Res);
+return Parse(Res, OriginalArgs, Diags);
+  }

dexonsmith wrote:
> I suggest double-checking that the second parse also fails, and reporting 
> that as an error somehow.
I think this should never happen, but being defensive here is a good idea.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:654-656
+  InputArgList GeneratedArgs1 =
+  getDriverOptTable().ParseArgs(GeneratedStrings1, MissingArgIndex1,
+MissingArgCount1, options::CC1Option);

dexonsmith wrote:
> Does this need to be checked for success / error conditions in any way?
Other callers usually check for missing argument values or unknown arguments. 
If we did that, we'd need to distinguish between bad arguments we've copied 
from `OriginalArgs` and errors we created in `Generate`. We don't have access 
to `MissingArgIndex` and `MissingArgsCount` of `OriginalArgs`, so it's not that 
easy. We could serialize and parse `OriginalArgs` again, but I think that's not 
a good idea from performance perspective.

I suggest we omit the checks for now, but put them in place as soon as we 
round-trip all arguments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:663
+  SwapOpts(Res);
+  bool Success2 = Parse(Res, GeneratedArgs1, Diags);
+

dexonsmith wrote:
> Might be better to error here if the second parse fails. We'd want to debug 
> the generated args too.
That's right.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:684-685
+  if (!GeneratedStringsEqual)
+llvm::report_fatal_error("Mismatch between arguments generated during "
+ "round-trip");
+

dexonsmith wrote:
> Another option vs. report_fatal_error would be to create (fatal) clang error 
> diagnostics. That applies here, and to my previous comments. WDYT? 
> (@Bigcheese, any thoughts?)
> 
> Also, I think `-round-trip-args-debug` might not be super discoverable. Maybe 
> we can add a comment in the code where the errors are reported suggesting 
> adding that.
If we decide to go with custom diagnostics instead of just using `llvm::errs` 
and `llvm::report_fatal_error`, we'd need to instantiate a custom 
`DiagnosticsEngine` here in `RoundTrip`, because we cannot rely on clients 
passing us reasonable `Diags`.

One such example is `CompilerInvocationTest`, where we don't care what 
diagnostics get emitted (by using `TextDiagnosticBuffer` consumer). The errors 
we're emitting here would be still useful to see when testing though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

___
cfe-commi

[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-29 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I don't think it can go into 12.x. But if you have a good reason and a related 
bug report you might add this bug ticket as a release blocker of 
https://llvm.org/PR48902.

BTW, would you mind updating clang/docs/ReleaseNotes.rst?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-01-29 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 320115.
jansvoboda11 added a comment.

Improve error handling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -90,11 +90,22 @@
 }
 
 std::vector ArgList::getAllArgValues(OptSpecifier Id) const {
+  recordQueriedOpts(Id);
   SmallVector Values;
   AddAllArgValues(Values, Id);
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+   const DenseSet &ExcludeIds) const {
+  for (const Arg *Arg : *this) {
+if (!ExcludeIds.contains(Arg->getOption().getID())) {
+  Arg->claim();
+  Arg->render(*this, Output);
+}
+  }
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -137,6 +137,16 @@
   /// The first and last index of each different OptSpecifier ID.
   DenseMap OptRanges;
 
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+
+  /// Record the queried OptSpecifiers.
+  template 
+  void recordQueriedOpts(OptSpecifiers... Ids) const {
+SmallVector OptsSpecifiers({toOptSpecifier(Ids).getID()...});
+QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
+  }
+
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
   OptRange getRange(std::initializer_list Ids) const;
@@ -203,6 +213,7 @@
   template
   iterator_range>
   filtered(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.begin() + Range.first;
 auto E = Args.begin() + Range.second;
@@ -214,6 +225,7 @@
   template
   iterator_range>
   filtered_reverse(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.rend() - Range.second;
 auto E = Args.rend() - Range.first;
@@ -308,6 +320,10 @@
   A->render(*this, Output);
   }
 
+  /// AddAllArgsExcept - Render all arguments not matching any of the excluded
+  /// ids.
+  void AddAllArgsExcept(ArgStringList &Output,
+const DenseSet &ExcludeIds) const;
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
   void AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids,
@@ -342,6 +358,12 @@
   ///
   void ClaimAllArgs() const;
 
+  /// Return the OptSpecifiers queried from this argument list.
+  const DenseSet &getQueriedOpts() const { return QueriedOpts; }
+
+  /// Clear the set of queried OptSpecifiers.
+  void clearQueriedOpts() const { QueriedOpts.clear(); }
+
   /// @}
   /// @name Arg Synthesis
   /// @{
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -38,6 +38,7 @@
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -48,6 +49,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
@@ -204,7 +206,7 @@
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
   Option::OptionClass OptClass, unsigned,
-  Twine Value) {
+  const Twine &Value) {
   switch (OptClass) {
   case Option::SeparateClass:
   case Option::JoinedOrSeparateClass:
@@ -562,9 +564,163 @@
   return 0;
 }
 
-static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
-  static const OptTable &OptTable = getDriverOptTable();
-  return OptTable.getOption(OptSpecifier).getPrefixedName();
+static void

[PATCH] D95655: Adding Neon Sm3 & Sm4 Intrinsics

2021-01-29 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea added inline comments.



Comment at: llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll:24
+
+define <4 x i32> @test_vsm3ss1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x 
i32> %d) {
+; CHECK-LABEL: test_vsm3ss1:

The forth argument (<4 x i32> %d) is redundant.



Comment at: llvm/test/CodeGen/AArch64/neon-sm4-sm3.ll:77
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sm4e v1.4s, v0.4s
+; CHECK-NEXT:mov v0.16b, v1.16b

Shouldn't the registers be the other way around: sm4e v0.4s, v1.4s ? I believe 
the reason this happens is because of how CryptoRRTied is defined in 
`llvm/lib/Target/AArch64/AArch64InstrFormats.td`: 


```
class CryptoRRTiedop0, bits<2>op1, string asm, string asmops>
  : BaseCryptoV82<(outs V128:$Vd), (ins V128:$Vn, V128:$Vm), asm, asmops,
  "$Vm = $Vd", []> {
```

Vd be should be the first source register (as well as destination register) and 
Vn should be the second source register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95655

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


[PATCH] D95526: [Syntax] Add syntax-tree-dump in clang-check.

2021-01-29 Thread Haojian Wu 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 rGe90e455d2a0c: [Syntax] Add syntax-tree-dump in clang-check. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95526

Files:
  clang/test/Tooling/clang-check-syntax-tree-dump.cpp
  clang/tools/clang-check/CMakeLists.txt
  clang/tools/clang-check/ClangCheck.cpp


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -24,6 +24,9 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
@@ -82,6 +85,10 @@
 cl::desc(Options.getOptionHelpText(options::OPT_fix_what_you_can)),
 cl::cat(ClangCheckCategory));
 
+static cl::opt SyntaxTreeDump("syntax-tree-dump",
+cl::desc("dump the syntax tree"),
+cl::cat(ClangCheckCategory));
+
 namespace {
 
 // FIXME: Move FixItRewriteInPlace from 
lib/Rewrite/Frontend/FrontendActions.cpp
@@ -131,6 +138,28 @@
   }
 };
 
+class DumpSyntaxTree : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef InFile) override {
+class Consumer : public clang::ASTConsumer {
+public:
+  Consumer(clang::CompilerInstance &CI) : Collector(CI.getPreprocessor()) 
{}
+
+  void HandleTranslationUnit(clang::ASTContext &AST) override {
+clang::syntax::TokenBuffer TB = std::move(Collector).consume();
+clang::syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(), TB);
+llvm::outs() << clang::syntax::buildSyntaxTree(A, AST)->dump(
+AST.getSourceManager());
+  }
+
+private:
+  clang::syntax::TokenCollector Collector;
+};
+return std::make_unique(CI);
+  }
+};
+
 class ClangCheckActionFactory {
 public:
   std::unique_ptr newASTConsumer() {
@@ -188,6 +217,8 @@
 FrontendFactory = newFrontendActionFactory();
   else if (Fixit)
 FrontendFactory = newFrontendActionFactory();
+  else if (SyntaxTreeDump)
+FrontendFactory = newFrontendActionFactory();
   else
 FrontendFactory = newFrontendActionFactory(&CheckFactory);
 
Index: clang/tools/clang-check/CMakeLists.txt
===
--- clang/tools/clang-check/CMakeLists.txt
+++ clang/tools/clang-check/CMakeLists.txt
@@ -18,4 +18,5 @@
   clangSerialization
   clangStaticAnalyzerFrontend
   clangTooling
+  clangToolingSyntax
   )
Index: clang/test/Tooling/clang-check-syntax-tree-dump.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-syntax-tree-dump.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-check -syntax-tree-dump "%s" -- 2>&1 | FileCheck %s
+int abc;
+// CHECK:  TranslationUnit Detached
+// CHECK-NEXT: `-SimpleDeclaration
+// CHECK-NEXT:   |-'int'
+// CHECK-NEXT:   |-DeclaratorList Declarators
+// CHECK-NEXT:   | `-SimpleDeclarator ListElement
+// CHECK-NEXT:   |   `-'abc'
+// CHECK-NEXT:   `-';'


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -24,6 +24,9 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
@@ -82,6 +85,10 @@
 cl::desc(Options.getOptionHelpText(options::OPT_fix_what_you_can)),
 cl::cat(ClangCheckCategory));
 
+static cl::opt SyntaxTreeDump("syntax-tree-dump",
+cl::desc("dump the syntax tree"),
+cl::cat(ClangCheckCategory));
+
 namespace {
 
 // FIXME: Move FixItRewriteInPlace from lib/Rewrite/Frontend/FrontendActions.cpp
@@ -131,6 +138,28 @@
   }
 };
 
+class DumpSyntaxTree : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef InFile) override {
+class Consumer : public clang::ASTConsumer {
+public:
+  Consumer(clang::CompilerInstance &CI) : Collector(CI.getPreprocessor()) {}
+
+  void HandleTranslationUnit(clang::ASTCon

[clang] e90e455 - [Syntax] Add syntax-tree-dump in clang-check.

2021-01-29 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-01-29T14:10:27+01:00
New Revision: e90e455d2a0cc6e04b930a43355c3551e2c6f0e0

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

LOG: [Syntax] Add syntax-tree-dump in clang-check.

This is useful to experiment/develop syntax trees.

Reviewed By: sammccall

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

Added: 
clang/test/Tooling/clang-check-syntax-tree-dump.cpp

Modified: 
clang/tools/clang-check/CMakeLists.txt
clang/tools/clang-check/ClangCheck.cpp

Removed: 




diff  --git a/clang/test/Tooling/clang-check-syntax-tree-dump.cpp 
b/clang/test/Tooling/clang-check-syntax-tree-dump.cpp
new file mode 100644
index ..026a866eab06
--- /dev/null
+++ b/clang/test/Tooling/clang-check-syntax-tree-dump.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-check -syntax-tree-dump "%s" -- 2>&1 | FileCheck %s
+int abc;
+// CHECK:  TranslationUnit Detached
+// CHECK-NEXT: `-SimpleDeclaration
+// CHECK-NEXT:   |-'int'
+// CHECK-NEXT:   |-DeclaratorList Declarators
+// CHECK-NEXT:   | `-SimpleDeclarator ListElement
+// CHECK-NEXT:   |   `-'abc'
+// CHECK-NEXT:   `-';'

diff  --git a/clang/tools/clang-check/CMakeLists.txt 
b/clang/tools/clang-check/CMakeLists.txt
index 6d2fc196631d..5493aa4237ae 100644
--- a/clang/tools/clang-check/CMakeLists.txt
+++ b/clang/tools/clang-check/CMakeLists.txt
@@ -18,4 +18,5 @@ clang_target_link_libraries(clang-check
   clangSerialization
   clangStaticAnalyzerFrontend
   clangTooling
+  clangToolingSyntax
   )

diff  --git a/clang/tools/clang-check/ClangCheck.cpp 
b/clang/tools/clang-check/ClangCheck.cpp
index a04936478eb3..4be3ce980c81 100644
--- a/clang/tools/clang-check/ClangCheck.cpp
+++ b/clang/tools/clang-check/ClangCheck.cpp
@@ -24,6 +24,9 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
@@ -82,6 +85,10 @@ static cl::opt FixWhatYouCan(
 cl::desc(Options.getOptionHelpText(options::OPT_fix_what_you_can)),
 cl::cat(ClangCheckCategory));
 
+static cl::opt SyntaxTreeDump("syntax-tree-dump",
+cl::desc("dump the syntax tree"),
+cl::cat(ClangCheckCategory));
+
 namespace {
 
 // FIXME: Move FixItRewriteInPlace from 
lib/Rewrite/Frontend/FrontendActions.cpp
@@ -131,6 +138,28 @@ class ClangCheckFixItAction : public clang::FixItAction {
   }
 };
 
+class DumpSyntaxTree : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef InFile) override {
+class Consumer : public clang::ASTConsumer {
+public:
+  Consumer(clang::CompilerInstance &CI) : Collector(CI.getPreprocessor()) 
{}
+
+  void HandleTranslationUnit(clang::ASTContext &AST) override {
+clang::syntax::TokenBuffer TB = std::move(Collector).consume();
+clang::syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(), TB);
+llvm::outs() << clang::syntax::buildSyntaxTree(A, AST)->dump(
+AST.getSourceManager());
+  }
+
+private:
+  clang::syntax::TokenCollector Collector;
+};
+return std::make_unique(CI);
+  }
+};
+
 class ClangCheckActionFactory {
 public:
   std::unique_ptr newASTConsumer() {
@@ -188,6 +217,8 @@ int main(int argc, const char **argv) {
 FrontendFactory = newFrontendActionFactory();
   else if (Fixit)
 FrontendFactory = newFrontendActionFactory();
+  else if (SyntaxTreeDump)
+FrontendFactory = newFrontendActionFactory();
   else
 FrontendFactory = newFrontendActionFactory(&CheckFactory);
 



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


[PATCH] D95526: [Syntax] Add syntax-tree-dump in clang-check.

2021-01-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 320112.
hokein marked an inline comment as done.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95526

Files:
  clang/test/Tooling/clang-check-syntax-tree-dump.cpp
  clang/tools/clang-check/CMakeLists.txt
  clang/tools/clang-check/ClangCheck.cpp


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -24,6 +24,9 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
@@ -82,6 +85,10 @@
 cl::desc(Options.getOptionHelpText(options::OPT_fix_what_you_can)),
 cl::cat(ClangCheckCategory));
 
+static cl::opt SyntaxTreeDump("syntax-tree-dump",
+cl::desc("dump the syntax tree"),
+cl::cat(ClangCheckCategory));
+
 namespace {
 
 // FIXME: Move FixItRewriteInPlace from 
lib/Rewrite/Frontend/FrontendActions.cpp
@@ -131,6 +138,28 @@
   }
 };
 
+class DumpSyntaxTree : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef InFile) override {
+class Consumer : public clang::ASTConsumer {
+public:
+  Consumer(clang::CompilerInstance &CI) : Collector(CI.getPreprocessor()) 
{}
+
+  void HandleTranslationUnit(clang::ASTContext &AST) override {
+clang::syntax::TokenBuffer TB = std::move(Collector).consume();
+clang::syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(), TB);
+llvm::outs() << clang::syntax::buildSyntaxTree(A, AST)->dump(
+AST.getSourceManager());
+  }
+
+private:
+  clang::syntax::TokenCollector Collector;
+};
+return std::make_unique(CI);
+  }
+};
+
 class ClangCheckActionFactory {
 public:
   std::unique_ptr newASTConsumer() {
@@ -188,6 +217,8 @@
 FrontendFactory = newFrontendActionFactory();
   else if (Fixit)
 FrontendFactory = newFrontendActionFactory();
+  else if (SyntaxTreeDump)
+FrontendFactory = newFrontendActionFactory();
   else
 FrontendFactory = newFrontendActionFactory(&CheckFactory);
 
Index: clang/tools/clang-check/CMakeLists.txt
===
--- clang/tools/clang-check/CMakeLists.txt
+++ clang/tools/clang-check/CMakeLists.txt
@@ -18,4 +18,5 @@
   clangSerialization
   clangStaticAnalyzerFrontend
   clangTooling
+  clangToolingSyntax
   )
Index: clang/test/Tooling/clang-check-syntax-tree-dump.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-syntax-tree-dump.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-check -syntax-tree-dump "%s" -- 2>&1 | FileCheck %s
+int abc;
+// CHECK:  TranslationUnit Detached
+// CHECK-NEXT: `-SimpleDeclaration
+// CHECK-NEXT:   |-'int'
+// CHECK-NEXT:   |-DeclaratorList Declarators
+// CHECK-NEXT:   | `-SimpleDeclarator ListElement
+// CHECK-NEXT:   |   `-'abc'
+// CHECK-NEXT:   `-';'


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -24,6 +24,9 @@
 #include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
@@ -82,6 +85,10 @@
 cl::desc(Options.getOptionHelpText(options::OPT_fix_what_you_can)),
 cl::cat(ClangCheckCategory));
 
+static cl::opt SyntaxTreeDump("syntax-tree-dump",
+cl::desc("dump the syntax tree"),
+cl::cat(ClangCheckCategory));
+
 namespace {
 
 // FIXME: Move FixItRewriteInPlace from lib/Rewrite/Frontend/FrontendActions.cpp
@@ -131,6 +138,28 @@
   }
 };
 
+class DumpSyntaxTree : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef InFile) override {
+class Consumer : public clang::ASTConsumer {
+public:
+  Consumer(clang::CompilerInstance &CI) : Collector(CI.getPreprocessor()) {}
+
+  void HandleTranslationUnit(clang::ASTContext &AST) override {
+clang::syntax::TokenBuffer TB = std::move(Collector).consume();
+   

[PATCH] D95653: [clang-tidy] Fix linking tests to LLVMTestingSupport

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

LGTM


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

https://reviews.llvm.org/D95653

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-29 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@FarisRehman, thank you for addressing my comments! I've just realised that 
`gfortran` doesn't actually support `-fno-fixed-form` or `-fno-free-form`:

  $ gfortran -ffixed-form -fno-fixed-form test.f
  gfortran: error: unrecognized command line option ‘-fno-fixed-form’

I've checked the other spellings too. If that's the case then perhaps the 
definitions in `Options.td` should be updated to reflect that? And if we don't 
use `BooleanFFlag` for these options then it should be much easier to add a 
help text too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

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


[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-01-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:874-876
+if (!getLangOpts().CPlusPlus)
+  Diag(Tok, diag::warn_cxx_static_assert_in_c)
+  << FixItHint::CreateReplacement(Tok.getLocation(), "_Static_assert");

rsmith wrote:
> I don't think this diagnostic is useful as-is: on Windows, including 
> `` doesn't help because it doesn't `#define static_assert`. And 
> people hitting this also can't switch to using `_Static_assert`, because MSVC 
> doesn't provide it, only `static_assert`.
> 
> If we want to warn here, we could perhaps check whether `` has been 
> included, but getting that check correct across PCH / modules is not 
> straightforward. (If we knew what include guard the CRT's `assert.h` used (if 
> any), I guess we could check whether that's defined, but that'd be a bit of a 
> hack.) But I'm somewhat inclined to think we don't have a good way to 
> distinguish between the good cases and the bad ones, so we shouldn't warn. 
> Hopefully MS will fix their CRT at some point and we can stop providing this 
> compatibility hack entirely (or start warning on it by default).
Are you sure they don't support `_Static_assert` yet? I seem to be able to use 
it fine: https://godbolt.org/z/vG47he

That said, this does appear to be only available in newer versions of MSVC, so 
perhaps you're correct about the diagnostic being a bit unhelpful. My primary 
concern is that use of `static_assert` in C is a nonconforming extension and we 
default to `-fms-compatibility` on Windows when Clang is built by MSVC. So it's 
not difficult to accidentally run into this, but the only warning we give on it 
with `-Weverything -pedantic` is how it's not compatible with C++98.

WDYT?


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

https://reviews.llvm.org/D95396

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-01-29 Thread Abhina Sree 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 rG42a21778f61c: [test] Use host platform specific error 
message substitution in lit tests (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/COFF/pdb-type-server-missing.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/reproduce-error.s
  lld/test/ELF/symbol-ordering-file.s
  lld/test/MachO/invalid/no-filelist.s
  llvm/docs/TestingGuide.rst
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/MC/Hexagon/not_found.s
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/dsymutil/archive-timestamp.test
  llvm/test/tools/dsymutil/debug-map-parsing.test
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-libtool-darwin/filelist.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/yaml2obj/output-file.yaml
===
--- llvm/test/tools/yaml2obj/output-file.yaml
+++ llvm/test/tools/yaml2obj/output-file.yaml
@@ -7,9 +7,9 @@
 # RUN: yaml2obj %s -o%t
 # RUN: ls %t
 
-# RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck %s
+# RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
 
-# CHECK: yaml2obj: error: fai

[clang] 42a2177 - [test] Use host platform specific error message substitution in lit tests

2021-01-29 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-01-29T07:16:30-05:00
New Revision: 42a21778f61cdc8462ce2cfb6ad7bc1992b2063c

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

LOG: [test] Use host platform specific error message substitution in lit tests

On z/OS, the following error message is not matched correctly in lit tests.

```
EDC5129I No such file or directory.
```

This patch uses a lit config substitution to check for platform specific error 
messages.

Reviewed By: muiez, jhenderson

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

Added: 


Modified: 
clang/test/CodeGen/basic-block-sections.c
clang/test/CodeGen/ubsan-blacklist-vfs.c
clang/test/Driver/clang-offload-bundler.c
clang/test/Frontend/output-paths.c
clang/test/Frontend/stats-file.c
lld/test/COFF/driver.test
lld/test/COFF/manifestinput-error.test
lld/test/COFF/nodefaultlib.test
lld/test/COFF/pdb-type-server-invalid-signature.yaml
lld/test/COFF/pdb-type-server-missing.yaml
lld/test/ELF/archive-thin-missing-member.s
lld/test/ELF/basic.s
lld/test/ELF/reproduce-error.s
lld/test/ELF/symbol-ordering-file.s
lld/test/MachO/invalid/no-filelist.s
llvm/docs/TestingGuide.rst
llvm/test/DebugInfo/symbolize-missing-file.test
llvm/test/MC/Hexagon/not_found.s
llvm/test/Object/archive-extract-dir.test
llvm/test/Object/archive-extract.test
llvm/test/Object/directory.ll
llvm/test/tools/dsymutil/X86/papertrail-warnings.test
llvm/test/tools/dsymutil/archive-timestamp.test
llvm/test/tools/dsymutil/debug-map-parsing.test
llvm/test/tools/llvm-ar/error-opening-directory.test
llvm/test/tools/llvm-ar/missing-thin-archive-member.test
llvm/test/tools/llvm-ar/move.test
llvm/test/tools/llvm-ar/print.test
llvm/test/tools/llvm-ar/quick-append.test
llvm/test/tools/llvm-ar/replace.test
llvm/test/tools/llvm-ar/response.test
llvm/test/tools/llvm-cxxdump/trivial.test
llvm/test/tools/llvm-libtool-darwin/filelist.test
llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
llvm/test/tools/llvm-lipo/create-arch.test
llvm/test/tools/llvm-lipo/replace-invalid-input.test
llvm/test/tools/llvm-lto/error.ll
llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
llvm/test/tools/llvm-mc/basic.test
llvm/test/tools/llvm-mca/invalid_input_file_name.test
llvm/test/tools/llvm-ml/basic.test
llvm/test/tools/llvm-objcopy/COFF/add-section.test
llvm/test/tools/llvm-objcopy/ELF/add-section.test
llvm/test/tools/llvm-objcopy/ELF/error-format.test
llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
llvm/test/tools/llvm-objcopy/redefine-symbols.test
llvm/test/tools/llvm-objcopy/wasm/dump-section.test
llvm/test/tools/llvm-profdata/weight-instr.test
llvm/test/tools/llvm-profdata/weight-sample.test
llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
llvm/test/tools/llvm-readobj/basic.test
llvm/test/tools/llvm-readobj/thin-archive.test
llvm/test/tools/llvm-size/no-input.test
llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
llvm/test/tools/llvm-xray/X86/no-such-file.txt
llvm/test/tools/obj2yaml/invalid_input_file.test
llvm/test/tools/yaml2obj/output-file.yaml
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/clang/test/CodeGen/basic-block-sections.c 
b/clang/test/CodeGen/basic-block-sections.c
index 70cdeeebb0d3..ee0dc90e2d02 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -triple x86_64 -S 
-fbasic-block-sections=list=%S/Inputs/basic-block-sections.funcnames -o - < %s 
| FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST
 // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all 
-funique-basic-block-section-names -o - < %s | FileCheck %s 
--check-prefix=UNIQUE
 // RUN: rm -f %t
-// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-obj -o %t %s 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-obj -o %t %s 2>&1 | 
FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERROR
 // RUN: not ls %t
 
 int world(int a) {
@@ -41,4 +41,4 @@ int another(int a) {
 //
 // UNIQUE: .section .text.world.world.__part.1,
 // UNIQUE: .section .text.another.another.__part.1,
-// ERROR: error:  unable to load basic block sections function list: 
'{{[Nn]}}o such file or directory'
+// ERROR: error:  unable to load basic block sections function list: '[[MSG]]'

diff  --git a/clang/test/CodeGen/ubsan-blacklist-vfs.c 
b/clang/test/CodeGen/ubsan-blacklist-vfs.c
index 0647cbf7a57b..558c5f5ea817 100644
--- a/clang/test/CodeGen/ubsan-blacklist-vfs.c
+++ b/clang/test/CodeGen/ubsan-blacklist-vfs

  1   2   >