[PATCH] D102148: [clangd] Type hints for variables with 'auto' type

2021-05-30 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:33
+TypeHintPolicy.SuppressScope = true; // keep type names short
+TypeHintPolicy.AnonymousTagLocations =
+false; // do not print lambda locations

sammccall wrote:
> For lambda values, the overwhelmingly common case is `auto X = `.
> 
> A few reasons we may want to not show these at all (and so omit type hints 
> for lambdas as a first approximation):
>  - the fact that it's a lambda is pretty obvious
>  - lambdas very often have complex introducers (captures/params) that a hint 
> will displace/add noise to
>  - we may want to add type hints to captures-with-initializers, which are 
> very much like auto-typed variables, and the fewer hints we have to cram on a 
> line the better
> 
> (fine to consider this stuff later, just wanted to mention it)
There is some value in showing `(lambda)` as a hint: it tells you the 
initializer is not an IIFE (immediately-invoked function expression, i.e. `auto 
var = [](...){ ... }();` -- note the parentheses at the end). For multi-line 
lambdas, this information is not otherwise present on the first line of the 
declaration.

Granted, how useful this is depends on the code style, i.e. whether IIFEs are 
common or even allowed.

I'm going to keep this as-is for now, but I'm definitely open to revise this 
based on usage experience.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:76
+  bool VisitVarDecl(VarDecl *D) {
+// Structured binding - not handled yet.
+if (isa(D))

sammccall wrote:
> FWIW I think hinting the individual bindings will be more useful and also 
> more consistent with the other hints you have here.
Makes sense, I've updated the comment here and in the testcase to reflect this 
direction.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:81
+if (auto *AT = D->getType()->getContainedAutoType()) {
+  if (!D->getType()->isDependentType()) {
+addInlayHint(D->getLocation(), InlayHintKind::TypeHint,

sammccall wrote:
> why this check vs checking whether AT is deduced?
> (thus fixing the dependent `T` testcase)
> At first I assumed this was the usual "AutoType in AST doesn't store the 
> deduced type" problem, but shouldn't it work properly if we're starting at 
> the variable type?
Not sure if I'm understanding the suggestion correctly, but if I make the 
condition `AT->isDeduced()`, I get an unwanted `auto` hint for `var1` in 
`TypeHints.DependentType` as well (and moreover, the hint for `var2` is also 
`auto` instead of the desired `T`).



Comment at: clang-tools-extra/clangd/InlayHints.cpp:82
+  if (!D->getType()->isDependentType()) {
+addInlayHint(D->getLocation(), InlayHintKind::TypeHint,
+ ": " + D->getType().getAsString(TypeHintPolicy));

sammccall wrote:
> This places the hint on the variable rather than the `auto`. And fittingly 
> (but subtly), it prints type rather than just the placeholder type (e.g. 
> `const auto& x = 42` => `const int&`, not `int`)
> 
> This decision is worth a comment, and probably a little discussion :-)
> 
> The alternative of annotating `auto` has advantages:
>  - the deduced `auto` type is the most obvious question when reading the code
>  - that `auto` deduces to a particular type is the "correct" model, and may 
> lead to better language understanding. Extreme unrealistic example: in `auto 
> x = foo(), *y = bar();` I'd strongly prefer one hint.
>  - the hint will often be shorter, which is an important consideration since 
> we're reflowing column-limited text
>  - the annotated code more closely resembles code that does not use `auto`
> 
> And annotating the variable has advantages too:
>  - the type of the variable is the most directly important fact
>  - generalizes better to cases where `auto` is not present (lambda captures, 
> individual structured bindings)
>  - i suspect simpler implementation
> 
> My intuition is to expect annotating `auto` to be a little nicer, mostly 
> because it will come closer to making code read the same way whether it uses 
> `auto` or not. I'm not certain though. Interested if you have strong feelings 
> about this!
> 
> To save a round-trip: a likely conclusion is "maybe annotating auto is 
> better, but it's not clear and/or it's a bunch of work". That's 100% fine, 
> but we should just leave a comment whether this is something decided against 
> vs desirable but deferred vs unsure.
Very good points here.

The argument I find most convincing for annotating the `auto` is the space 
savings, which are significant especially in the presence of `const`.

On the other hand, the arguments I find most convincing for the current 
approach are:

 * the generalization to lambda captures and structured bindings, as you mention
 * the familiarity to people coming from other languages like Typescript or 

[PATCH] D102148: [clangd] Type hints for variables with 'auto' type

2021-05-30 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 348727.
nridge marked 8 inline comments as done.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102148

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -15,14 +15,19 @@
 
 namespace clang {
 namespace clangd {
+
+std::ostream <<(std::ostream , const InlayHint ) {
+  return Stream << Hint.label;
+}
+
 namespace {
 
 using ::testing::UnorderedElementsAre;
 
-std::vector parameterHints(ParsedAST ) {
+std::vector hintsOfKind(ParsedAST , InlayHintKind Kind) {
   std::vector Result;
   for (auto  : inlayHints(AST)) {
-if (Hint.kind == InlayHintKind::ParameterHint)
+if (Hint.kind == Kind)
   Result.push_back(Hint);
   }
   return Result;
@@ -31,6 +36,11 @@
 struct ExpectedHint {
   std::string Label;
   std::string RangeName;
+
+  friend std::ostream <<(std::ostream ,
+  const ExpectedHint ) {
+return Stream << Hint.RangeName << ": " << Hint.Label;
+  }
 };
 
 MATCHER_P2(HintMatcher, Expected, Code, "") {
@@ -39,17 +49,29 @@
 }
 
 template 
-void assertParameterHints(llvm::StringRef AnnotatedSource,
-  ExpectedHints... Expected) {
+void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
   Annotations Source(AnnotatedSource);
   TestTU TU = TestTU::withCode(Source.code());
-  TU.ExtraArgs.push_back("-std=c++11");
+  TU.ExtraArgs.push_back("-std=c++14");
   auto AST = TU.build();
 
-  EXPECT_THAT(parameterHints(AST),
+  EXPECT_THAT(hintsOfKind(AST, Kind),
   UnorderedElementsAre(HintMatcher(Expected, Source)...));
 }
 
+template 
+void assertParameterHints(llvm::StringRef AnnotatedSource,
+  ExpectedHints... Expected) {
+  assertHints(InlayHintKind::ParameterHint, AnnotatedSource, Expected...);
+}
+
+template 
+void assertTypeHints(llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
+  assertHints(InlayHintKind::TypeHint, AnnotatedSource, Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -376,6 +398,119 @@
ExpectedHint{"timeout_millis: ", "timeout_millis"});
 }
 
+TEST(TypeHints, Smoke) {
+  assertTypeHints(R"cpp(
+auto $waldo[[waldo]] = 42;
+  )cpp",
+  ExpectedHint{": int", "waldo"});
+}
+
+TEST(TypeHints, Decorations) {
+  assertTypeHints(R"cpp(
+int x = 42;
+auto* $var1[[var1]] = 
+auto&& $var2[[var2]] = x;
+const auto& $var3[[var3]] = x;
+  )cpp",
+  ExpectedHint{": int *", "var1"},
+  ExpectedHint{": int &", "var2"},
+  ExpectedHint{": const int &", "var3"});
+}
+
+TEST(TypeHints, DecltypeAuto) {
+  assertTypeHints(R"cpp(
+int x = 42;
+int& y = x;
+decltype(auto) $z[[z]] = y;
+  )cpp",
+  ExpectedHint{": int &", "z"});
+}
+
+TEST(TypeHints, NoQualifiers) {
+  assertTypeHints(R"cpp(
+namespace A {
+  namespace B {
+struct S1 {};
+S1 foo();
+auto $x[[x]] = foo();
+
+struct S2 {
+  template 
+  struct Inner {};
+};
+S2::Inner bar();
+auto $y[[y]] = bar();
+  }
+}
+  )cpp",
+  ExpectedHint{": S1", "x"}, ExpectedHint{": Inner", "y"});
+}
+
+TEST(TypeHints, Lambda) {
+  // Do not print something overly verbose like the lambda's location.
+  // Show hints for init-captures (but not regular captures).
+  assertTypeHints(R"cpp(
+void f() {
+  int cap = 42;
+  auto $L[[L]] = [cap, $init[[init]] = 1 + 1](int a) { 
+return a + cap + init; 
+  };
+}
+  )cpp",
+  ExpectedHint{": (lambda)", "L"},
+  ExpectedHint{": int", "init"});
+}
+
+TEST(TypeHints, StructuredBindings) {
+  // FIXME: Not handled yet.
+  // To handle it, we could print:
+  //  - the aggregate type next to the 'auto', or
+  //  - the individual types inside the brackets
+  // The latter is probably more useful.
+  assertTypeHints(R"cpp(
+struct Point {
+  int x;
+  int y;
+};
+Point foo();
+auto [x, y] = foo();
+  )cpp");
+}
+
+TEST(TypeHints, ReturnTypeDeduction) {
+  // FIXME: Not handled yet.
+  // This test is currently here mostly because a naive implementation
+  // might have us print something not super helpful like the function type.
+  assertTypeHints(R"cpp(
+auto func(int x) {
+  return x + 1;
+}
+  )cpp");
+}
+

[PATCH] D103386: [PowerPC] Fix x86 vector intrinsics wrapper compilation under C++

2021-05-30 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: PowerPC, jsji, nemanjai.
Herald added subscribers: shchenz, kbarton.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103386

Files:
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/ppc-xmmintrin.c


Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -3,8 +3,12 @@
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu 
-mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 #include 
 
@@ -1426,7 +1430,7 @@
 
 void __attribute__((noinline))
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, (enum _mm_hint)i);
 }
 
 // CHECK-LABEL: @test_prefetch
Index: clang/lib/Headers/ppc_wrappers/xmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -62,14 +62,13 @@
 
 /* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components.  */
-typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef vector float __m128 __attribute__((__may_alias__));
 
 /* Unaligned version of the same type.  */
-typedef float __m128_u __attribute__ ((__vector_size__ (16), __may_alias__,
-  __aligned__ (1)));
+typedef vector float __m128_u __attribute__((__may_alias__, __aligned__(1)));
 
 /* Internal data types for implementing the intrinsics.  */
-typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+typedef vector float __v4sf;
 
 /* Create an undefined vector.  */
 extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))


Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -3,8 +3,12 @@
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
 #include 
 
@@ -1426,7 +1430,7 @@
 
 void __attribute__((noinline))
 test_prefetch() {
-  _mm_prefetch(ms, i);
+  _mm_prefetch(ms, (enum _mm_hint)i);
 }
 
 // CHECK-LABEL: @test_prefetch
Index: clang/lib/Headers/ppc_wrappers/xmmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/xmmintrin.h
+++ clang/lib/Headers/ppc_wrappers/xmmintrin.h
@@ -62,14 +62,13 @@
 
 /* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components.  */
-typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef vector float __m128 __attribute__((__may_alias__));
 
 /* Unaligned version of the same type.  */
-typedef float __m128_u __attribute__ ((__vector_size__ (16), __may_alias__,
-   __aligned__ (1)));
+typedef vector float __m128_u __attribute__((__may_alias__, __aligned__(1)));
 
 /* Internal data types for implementing the intrinsics.  */
-typedef float __v4sf __attribute__ ((__vector_size__ (16)));
+typedef vector float __v4sf;
 
 /* Create an undefined vector.  */
 extern __inline __m128 

[PATCH] D103385: [clang-tidy] bugprone-forwarding-reference-overload: support non-type template parameters

2021-05-30 Thread Jesse Towner via Phabricator via cfe-commits
jwtowner added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp:83
+  hasType(isEnableIf()),
+  anyOf(hasDescendant(cxxBoolLiteral()),
+hasDescendant(cxxNullPtrLiteralExpr()),

Note that I'm using `hasDescendant` here, because sometimes the literal ends up 
inside of an `ImplicitCastExpr` node and sometimes its a direct child of the 
`NonTypeTemplateParmDecl` node. I'm not sure exactly what causes the difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103385

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


[PATCH] D103385: [clang-tidy] bugprone-forwarding-reference-overload: support non-type template parameters

2021-05-30 Thread Jesse Towner via Phabricator via cfe-commits
jwtowner created this revision.
jwtowner added reviewers: alexfh, aaron.ballman, hokein.
Herald added a subscriber: xazax.hun.
jwtowner requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Many concepts emulation libraries, such as the one found in Range v3, tend to
use non-type template parameters for the enable_if type expression, due to
their versatility in template functions and constructors containing variadic
template parameter packs.

Unfortunately the bugprone-forwarding-reference-overload check does not
handle non-type template parameters, as was first noted in this bug report:
https://bugs.llvm.org/show_bug.cgi?id=38081

This patch fixes this long standing issue and allows for the check to be 
suppressed
with the use of a non-type template parameter containing enable_if or 
enable_if_t in
the type expression, so long as it has a default literal value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103385

Files:
  clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forwarding-reference-overload.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-forwarding-reference-overload.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-forwarding-reference-overload.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-forwarding-reference-overload.cpp
@@ -150,3 +150,93 @@
   constexpr variant(_Arg&& __arg) {}
   // CHECK-NOTES: :[[@LINE-1]]:13: warning: constructor accepting a forwarding reference can hide the copy and move constructors
 };
+
+namespace std {
+template  struct is_same { static constexpr bool value = false; };
+template  struct is_same { static constexpr bool value = true; };
+template  constexpr bool is_same_v = is_same::value;
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template  using remove_reference_t = typename remove_reference::type;
+template  struct remove_cv { using type = T; };
+template  struct remove_cv { using type = T; };
+template  struct remove_cv { using type = T; };
+template  struct remove_cv { using type = T; };
+template  using remove_cv_t = typename remove_cv::type;
+template  struct remove_cvref { using type = remove_cv_t>; };
+template  using remove_cvref_t = typename remove_cvref::type;
+} // namespace std
+
+// Handle enable_if when used as a non-type template parameter.
+class Test7 {
+public:
+  // Guarded with enable_if.
+  template , int>, int>::type = 0>
+  Test7(T &);
+
+  // Guarded with enable_if.
+  template , Test7>
+  && !std::is_same_v, bool>, int> = true>
+  Test7(T &);
+
+  Test7(const Test7 ) = default;
+  Test7(Test7 &) = default;
+};
+
+// Handle enable_if when used as a non-type template parameter following
+// a variadic template parameter pack.
+class Test8 {
+public:
+  // Guarded with enable_if.
+  template , Test8>
+  || (sizeof...(A) > 0)>* = nullptr>
+  Test8(T &, A &&... a);
+
+  Test8(const Test8 ) = default;
+  Test8(Test8 &) = default;
+};
+
+// Non-type template parameter failure cases.
+class Test9 {
+public:
+  // Requires a default argument (such as a literal, implicit cast expression, etc.)
+  template , bool>, int>>
+  Test9(T &);
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: 240:3: note: copy constructor declared here
+  // CHECK-NOTES: 241:3: note: move constructor declared here
+
+  // Requires a default argument (such as a literal, implicit cast expression, etc.)
+  template , long>>*>
+  Test9(T &);
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: 240:3: note: copy constructor declared here
+  // CHECK-NOTES: 241:3: note: move constructor declared here
+
+  // Only std::enable_if or std::enable_if_t are supported
+  template ::type* = nullptr>
+  Test9(T &);
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: 240:3: note: copy constructor declared here
+  // CHECK-NOTES: 241:3: note: move constructor declared here
+
+  // Only std::enable_if or std::enable_if_t are supported
+  template ::type = 0>
+  Test9(T &);
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors
+  // CHECK-NOTES: 240:3: note: copy constructor declared here
+  // CHECK-NOTES: 241:3: note: move constructor declared here
+
+  Test9(const Test9 ) = default;
+  Test9(Test9 &) = default;
+};
Index: 

[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-30 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb requested changes to this revision.
cjdb added a comment.
This revision now requires changes to proceed.

Thanks for working on this, it'll be a huge win for testing in libc++, methinks!

Could we get a few more tests please? I'd like to know what happens when we put 
a lambda directly inside:

- a SFINAE expression
- a noexcept specifier
- a sizeof operator

Similarly for lambdas inside `decltype` for each of the above. It'd also be 
good to have lambdas that aren't called as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

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


[PATCH] D103136: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-seriesø

2021-05-30 Thread Justin Latimer via Phabricator via cfe-commits
justinlatimer updated this revision to Diff 348707.
justinlatimer added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add devices into the clang AVR target constant list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103136

Files:
  clang/lib/Basic/Targets/AVR.cpp
  llvm/lib/Target/AVR/AVRDevices.td


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -495,4 +495,28 @@
 def : Device<"attiny40",   FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102",  FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104",  FamilyTiny, ELFArchTiny>;
-
+def : Device<"attiny202",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny412",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny214",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny414",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny814",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1614", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny416",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny816",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1616", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3216", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny417",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny817",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1617", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3217", FamilyXMEGA, ELFArchXMEGA3>;
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -267,6 +267,31 @@
 {"attiny40", "__AVR_ATtiny40__"},
 {"attiny102", "__AVR_ATtiny102__"},
 {"attiny104", "__AVR_ATtiny104__"},
+{"attiny202", "__AVR_ATtiny202__"},
+{"attiny402", "__AVR_ATtiny402__"},
+{"attiny204", "__AVR_ATtiny204__"},
+{"attiny404", "__AVR_ATtiny404__"},
+{"attiny804", "__AVR_ATtiny804__"},
+{"attiny1604", "__AVR_ATtiny1604__"},
+{"attiny406", "__AVR_ATtiny406__"},
+{"attiny806", "__AVR_ATtiny806__"},
+{"attiny1606", "__AVR_ATtiny1606__"},
+{"attiny807", "__AVR_ATtiny807__"},
+{"attiny1607", "__AVR_ATtiny1607__"},
+{"attiny212", "__AVR_ATtiny212__"},
+{"attiny412", "__AVR_ATtiny412__"},
+{"attiny214", "__AVR_ATtiny214__"},
+{"attiny414", "__AVR_ATtiny414__"},
+{"attiny814", "__AVR_ATtiny814__"},
+{"attiny1614", "__AVR_ATtiny1614__"},
+{"attiny416", "__AVR_ATtiny416__"},
+{"attiny816", "__AVR_ATtiny816__"},
+{"attiny1616", "__AVR_ATtiny1616__"},
+{"attiny3216", "__AVR_ATtiny3216__"},
+{"attiny417", "__AVR_ATtiny417__"},
+{"attiny817", "__AVR_ATtiny817__"},
+{"attiny1617", "__AVR_ATtiny1617__"},
+{"attiny3217", "__AVR_ATtiny3217__"},
 };
 
 } // namespace targets


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -495,4 +495,28 @@
 def : Device<"attiny40",   FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102",  FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104",  FamilyTiny, ELFArchTiny>;
-
+def : Device<"attiny202",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212",  

[PATCH] D103383: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-series

2021-05-30 Thread Justin Latimer via Phabricator via cfe-commits
justinlatimer created this revision.
Herald added subscribers: Jim, hiraditya, dylanmckay.
justinlatimer requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

[AVR] Add support for the tinyAVR 0-series and tinyAVR 1-series


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103383

Files:
  clang/lib/Basic/Targets/AVR.cpp
  llvm/lib/Target/AVR/AVRDevices.td


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -495,4 +495,28 @@
 def : Device<"attiny40",   FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102",  FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104",  FamilyTiny, ELFArchTiny>;
-
+def : Device<"attiny202",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny412",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny214",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny414",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny814",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1614", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny416",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny816",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1616", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3216", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny417",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny817",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1617", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3217", FamilyXMEGA, ELFArchXMEGA3>;
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -267,6 +267,31 @@
 {"attiny40", "__AVR_ATtiny40__"},
 {"attiny102", "__AVR_ATtiny102__"},
 {"attiny104", "__AVR_ATtiny104__"},
+{"attiny202", "__AVR_ATtiny202__"},
+{"attiny402", "__AVR_ATtiny402__"},
+{"attiny204", "__AVR_ATtiny204__"},
+{"attiny404", "__AVR_ATtiny404__"},
+{"attiny804", "__AVR_ATtiny804__"},
+{"attiny1604", "__AVR_ATtiny1604__"},
+{"attiny406", "__AVR_ATtiny406__"},
+{"attiny806", "__AVR_ATtiny806__"},
+{"attiny1606", "__AVR_ATtiny1606__"},
+{"attiny807", "__AVR_ATtiny807__"},
+{"attiny1607", "__AVR_ATtiny1607__"},
+{"attiny212", "__AVR_ATtiny212__"},
+{"attiny412", "__AVR_ATtiny412__"},
+{"attiny214", "__AVR_ATtiny214__"},
+{"attiny414", "__AVR_ATtiny414__"},
+{"attiny814", "__AVR_ATtiny814__"},
+{"attiny1614", "__AVR_ATtiny1614__"},
+{"attiny416", "__AVR_ATtiny416__"},
+{"attiny816", "__AVR_ATtiny816__"},
+{"attiny1616", "__AVR_ATtiny1616__"},
+{"attiny3216", "__AVR_ATtiny3216__"},
+{"attiny417", "__AVR_ATtiny417__"},
+{"attiny817", "__AVR_ATtiny817__"},
+{"attiny1617", "__AVR_ATtiny1617__"},
+{"attiny3217", "__AVR_ATtiny3217__"},
 };
 
 } // namespace targets


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -495,4 +495,28 @@
 def : Device<"attiny40",   FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102",  FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104",  FamilyTiny, ELFArchTiny>;
-
+def : Device<"attiny202",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212",   

[PATCH] D96223: [clang-tidy] Simplify static assert check

2021-05-30 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D96223#2788712 , @aaron.ballman 
wrote:

> In D96223#2788681 , @lebedev.ri 
> wrote:
>
>> Reverted in be6b9e8ae71768d2e09ec14619ca4ecfdef553fa 
>>  - 
>> https://godbolt.org/z/3zdqvbfxj
>> While there, please ensure that other such simplifications don't have 
>> similar lingering effects.
>
> Thanks for catching the issue!
>
> FWIW, I think that reverting something several months after it lands is a bit 
> disruptive and the test case causing the revert feels arbitrary without 
> further context that should have been explicitly mentioned in the reverting 
> commit message. The context is that this change broke a test that should have 
> caught the failure: 
> https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp#L86-L87
>  which led to this bug report: https://bugs.llvm.org/show_bug.cgi?id=50532. 
> I'm still not convinced the correct action was to revert a change with no 
> discussion that already was shipped in a release, however. Next time, I think 
> it'd be a bit friendlier to mention the regression on the patch to see if the 
> author can do a quick fix -- if no one noticed it for almost four months, 
> it's hard to argue it's a critical issue that needs an immediate revert. (The 
> reversion mildly worries me because this change already shipped as part of 
> Clang 12 and larger reversions make for harder git blame logic to follow 
> along with, both of which can lead to potential confusion for folks.)

And LLVM policy agrees with you.

Reverts should be reasonably timely. A change submitted two hours ago can be 
reverted without prior discussion. A change submitted two years ago should not 
be. Where exactly the transition point is is hard to say, but it’s probably in 
the handful of days in tree territory. If you are unsure, we encourage you to 
reply to the commit thread, give the author a bit to respond, and then proceed 
with the revert if the author doesn’t seem to be actively responding.

https://llvm.org/docs/DeveloperPolicy.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96223

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


[PATCH] D96223: [clang-tidy] Simplify static assert check

2021-05-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D96223#2788681 , @lebedev.ri wrote:

> Reverted in be6b9e8ae71768d2e09ec14619ca4ecfdef553fa 
>  - 
> https://godbolt.org/z/3zdqvbfxj
> While there, please ensure that other such simplifications don't have similar 
> lingering effects.

Thanks for catching the issue!

FWIW, I think that reverting something several months after it lands is a bit 
disruptive and the test case causing the revert feels arbitrary without further 
context that should have been explicitly mentioned in the reverting commit 
message. The context is that this change broke a test that should have caught 
the failure: 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/misc-static-assert.cpp#L86-L87
 which led to this bug report: https://bugs.llvm.org/show_bug.cgi?id=50532. I'm 
still not convinced the correct action was to revert a change with no 
discussion that already was shipped in a release, however. Next time, I think 
it'd be a bit friendlier to mention the regression on the patch to see if the 
author can do a quick fix -- if no one noticed it for almost four months, it's 
hard to argue it's a critical issue that needs an immediate revert. (The 
reversion mildly worries me because this change already shipped as part of 
Clang 12 and larger reversions make for harder git blame logic to follow along 
with, both of which can lead to potential confusion for folks.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96223

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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-05-30 Thread Ben Shi 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 rGc1ee4fb5af49: [clang][AVR] Add avr-libc/include to clang 
system include paths (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97669

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/.keep
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -2,3 +2,12 @@
 
 // RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | 
FileCheck -check-prefix CC1A %s
+// CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" 
{{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck -check-prefix CC1B %s
+// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck -check-prefix CC1C %s
+// CC1C-NOT: "-internal-isystem" {{".*avr/include"}}
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -22,6 +22,9 @@
 public:
   AVRToolChain(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
 
 protected:
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -353,6 +353,23 @@
   }
 }
 
+void AVRToolChain::AddClangSystemIncludeArgs(const ArgList ,
+ ArgStringList ) const {
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Omit if there is no avr-libc installed.
+  Optional AVRLibcRoot = findAVRLibcInstallation();
+  if (!AVRLibcRoot.hasValue())
+return;
+
+  // Add 'avr-libc/include' to clang system include paths if applicable.
+  std::string AVRInc = AVRLibcRoot.getValue() + "/include";
+  if (llvm::sys::fs::is_directory(AVRInc))
+addSystemInclude(DriverArgs, CC1Args, AVRInc);
+}
+
 Tool *AVRToolChain::buildLinker() const {
   return new tools::AVR::Linker(getTriple(), *this, LinkStdlib);
 }


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -2,3 +2,12 @@
 
 // RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck -check-prefix CC1A %s
+// CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck -check-prefix CC1B %s
+// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck -check-prefix CC1C %s
+// CC1C-NOT: "-internal-isystem" {{".*avr/include"}}
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -22,6 +22,9 @@
 public:
   AVRToolChain(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
 
 protected:
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -353,6 +353,23 @@
   }
 }
 
+void AVRToolChain::AddClangSystemIncludeArgs(const ArgList ,
+ ArgStringList ) const {
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Omit if there is no avr-libc installed.
+  Optional AVRLibcRoot = findAVRLibcInstallation();
+  if (!AVRLibcRoot.hasValue())
+return;
+
+  // Add 

[clang] c1ee4fb - [clang][AVR] Add avr-libc/include to clang system include paths

2021-05-30 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2021-05-30T22:39:07+08:00
New Revision: c1ee4fb5af49af5911ad7dc7932d975073030ec3

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

LOG: [clang][AVR] Add avr-libc/include to clang system include paths

Reviewed By: dylanmckay

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

Added: 
clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/.keep

Modified: 
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/AVR.h
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index f4f8014ff3872..ea35abb86f45d 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -353,6 +353,23 @@ AVRToolChain::AVRToolChain(const Driver , const 
llvm::Triple ,
   }
 }
 
+void AVRToolChain::AddClangSystemIncludeArgs(const ArgList ,
+ ArgStringList ) const {
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Omit if there is no avr-libc installed.
+  Optional AVRLibcRoot = findAVRLibcInstallation();
+  if (!AVRLibcRoot.hasValue())
+return;
+
+  // Add 'avr-libc/include' to clang system include paths if applicable.
+  std::string AVRInc = AVRLibcRoot.getValue() + "/include";
+  if (llvm::sys::fs::is_directory(AVRInc))
+addSystemInclude(DriverArgs, CC1Args, AVRInc);
+}
+
 Tool *AVRToolChain::buildLinker() const {
   return new tools::AVR::Linker(getTriple(), *this, LinkStdlib);
 }

diff  --git a/clang/lib/Driver/ToolChains/AVR.h 
b/clang/lib/Driver/ToolChains/AVR.h
index a3198b2495803..1b3b2035add2d 100644
--- a/clang/lib/Driver/ToolChains/AVR.h
+++ b/clang/lib/Driver/ToolChains/AVR.h
@@ -22,6 +22,9 @@ class LLVM_LIBRARY_VISIBILITY AVRToolChain : public 
Generic_ELF {
 public:
   AVRToolChain(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
 
 protected:
   Tool *buildLinker() const override;

diff  --git a/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/.keep 
b/clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/include/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/avr-toolchain.c 
b/clang/test/Driver/avr-toolchain.c
index 46a3c10fa3a15..b9ca1777a7d69 100644
--- a/clang/test/Driver/avr-toolchain.c
+++ b/clang/test/Driver/avr-toolchain.c
@@ -2,3 +2,12 @@
 
 // RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | 
FileCheck -check-prefix CC1A %s
+// CC1A: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-internal-isystem" 
{{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdinc | FileCheck -check-prefix CC1B %s
+// CC1B-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck -check-prefix CC1C %s
+// CC1C-NOT: "-internal-isystem" {{".*avr/include"}}



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


[PATCH] D96223: [clang-tidy] Simplify static assert check

2021-05-30 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri reopened this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Herald added a project: clang-tools-extra.

Reverted in be6b9e8ae71768d2e09ec14619ca4ecfdef553fa 
 - 
https://godbolt.org/z/3zdqvbfxj
While there, please ensure that other such simplifications don't have similar 
lingering effects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96223

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


[clang-tools-extra] be6b9e8 - Revert "[clang-tidy] Simplify static assert check"

2021-05-30 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2021-05-30T16:44:31+03:00
New Revision: be6b9e8ae71768d2e09ec14619ca4ecfdef553fa

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

LOG: Revert "[clang-tidy] Simplify static assert check"

This patch starts to produce a very obvious false-positives,
despite the fact the preexisting tests already cover the pattern.
they clearly don't actually cover it.

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

This reverts commit 1709bb8c7395418236ec94fe3b9d91fed746452b.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
index e9ea69aaeb323..224936887e033 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
@@ -27,37 +27,48 @@ StaticAssertCheck::StaticAssertCheck(StringRef Name, 
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context) {}
 
 void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
-  auto NegatedString =
-  unaryOperator(hasOperatorName("!"), hasUnaryOperand(stringLiteral()));
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), 
hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
  cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
-  auto IsAlwaysFalseWithCast =
-  anyOf(IsAlwaysFalse, 
cStyleCastExpr(has(IsAlwaysFalse)).bind("castExpr"));
-  auto AssertExprRoot =
-  anyOf(binaryOperator(
-hasAnyOperatorName("&&", "=="),
-hasEitherOperand(stringLiteral().bind("assertMSG")),
-anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
-  anything()))
-.bind("assertExprRoot"),
-IsAlwaysFalse);
+  auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
+  IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
+ .bind("castExpr")));
+  auto AssertExprRoot = anyOf(
+  binaryOperator(
+  hasAnyOperatorName("&&", "=="),
+  
hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))),
+  anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
+anything()))
+  .bind("assertExprRoot"),
+  IsAlwaysFalse);
   auto NonConstexprFunctionCall =
   callExpr(hasDeclaration(functionDecl(unless(isConstexpr();
   auto AssertCondition =
-  expr(optionally(expr(anyOf(AssertExprRoot,
-unaryOperator(hasUnaryOperand(AssertExprRoot),
-   unless(findAll(NonConstexprFunctionCall)))
+  expr(
+  anyOf(expr(ignoringParenCasts(anyOf(
+AssertExprRoot, unaryOperator(hasUnaryOperand(
+
ignoringParenCasts(AssertExprRoot)),
+anything()),
+  unless(findAll(NonConstexprFunctionCall)))
   .bind("condition");
   auto Condition =
-  anyOf(callExpr(traverse(TK_AsIs, callExpr(hasDeclaration(functionDecl(
-   hasName("__builtin_expect"),
- hasArgument(0, AssertCondition)),
+  anyOf(ignoringParenImpCasts(callExpr(
+hasDeclaration(functionDecl(hasName("__builtin_expect"))),
+hasArgument(0, AssertCondition))),
 AssertCondition);
 
+  Finder->addMatcher(conditionalOperator(hasCondition(Condition),
+ unless(isInTemplateInstantiation()))
+ .bind("condStmt"),
+ this);
+
   Finder->addMatcher(
-  mapAnyOf(ifStmt, 
conditionalOperator).with(hasCondition(Condition)).bind("condStmt"), this);
+  ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
+  .bind("condStmt"),
+  this);
 }
 
 void StaticAssertCheck::check(const MatchFinder::MatchResult ) {

diff  --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h 
b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h
index 796fc4827db42..0168d1fcd107f 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h
@@ -30,9 +30,6 @@ class StaticAssertCheck : public ClangTidyCheck {
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
-  llvm::Optional getCheckTraversalKind() const override {
-return 

[PATCH] D66481: [C++20] Support for lambdas in unevaluated context

2021-05-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Given the lack of activity, I made another PR for the same feature 
https://reviews.llvm.org/D103380


Repository:
  rC Clang

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

https://reviews.llvm.org/D66481

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


[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 348693.
cor3ntin added a comment.

Code formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103380

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
  clang/test/SemaCXX/anonymous-struct.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4;>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this 
typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given 
name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not 
C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage 
purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+// expected-no-diagnostics
+
+template  struct Nothing {};
+
+template 
+concept True = [] { return true; }();
+
+static_assert(True);
+
+using x = decltype([] { return 0; }());
+
+Nothing<[]() { return 0; }()> nothing;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16657,8 +16657,10 @@
 
   if (!Rec.Lambdas.empty()) {
 using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
-if (Rec.ExprContext == ExpressionKind::EK_TemplateArgument || 
Rec.isUnevaluated() ||
-(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17)) {
+if (!getLangOpts().CPlusPlus20 &&
+(Rec.ExprContext == ExpressionKind::EK_TemplateArgument ||
+ Rec.isUnevaluated() ||
+ (Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17))) {
   unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -41,9 +41,11 @@
   LHS = BO->getLHS();
   RHS = BO->getRHS();
 } else if (auto *OO = dyn_cast(E)) {
-  Op = OO->getOperator();
-  LHS = OO->getArg(0);
-  RHS = OO->getArg(1);
+  if (OO->getNumArgs() == 2) {
+Op = OO->getOperator();
+LHS = OO->getArg(0);
+RHS = OO->getArg(1);
+  }
 }
   }
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4;>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+// expected-no-diagnostics
+
+template  struct Nothing {};
+
+template 
+concept True = [] { return true; }();
+

[PATCH] D103380: [C++20] Support for lambdas in unevaluated context

2021-05-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Partially implement P0315R4.

This patch allow lambda in unevaluated context.
It does not implement temp.deduct/9.

This is a rewrite of https://reviews.llvm.org/D66481 that did
not see progress over the past 2 years.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103380

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
  clang/test/SemaCXX/anonymous-struct.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4;>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this 
typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given 
name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not 
C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage 
purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+// expected-no-diagnostics
+
+template struct Nothing {};
+
+template
+concept True = [] { return true; }();
+
+static_assert(True);
+
+using x = decltype([] { return 0;}());
+
+Nothing<[]() { return 0; }()> nothing;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16657,8 +16657,8 @@
 
   if (!Rec.Lambdas.empty()) {
 using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
-if (Rec.ExprContext == ExpressionKind::EK_TemplateArgument || 
Rec.isUnevaluated() ||
-(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17)) {
+if (!getLangOpts().CPlusPlus20 && (Rec.ExprContext == 
ExpressionKind::EK_TemplateArgument || Rec.isUnevaluated() ||
+(Rec.isConstantEvaluated() && !getLangOpts().CPlusPlus17))) {
   unsigned D;
   if (Rec.isUnevaluated()) {
 // C++11 [expr.prim.lambda]p2:
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -41,9 +41,11 @@
   LHS = BO->getLHS();
   RHS = BO->getRHS();
 } else if (auto *OO = dyn_cast(E)) {
-  Op = OO->getOperator();
-  LHS = OO->getArg(0);
-  RHS = OO->getArg(1);
+if(OO->getNumArgs() == 2) {
+  Op = OO->getOperator();
+  LHS = OO->getArg(0);
+  RHS = OO->getArg(1);
+  }
 }
   }
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1011,7 +1011,7 @@
 
   Lambdas in unevaluated contexts
   https://wg21.link/p0315r4;>P0315R4
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -49,7 +49,7 @@
 : B { // expected-note {{type is not C-compatible due to this base class}}
 } C; // expected-note {{type is given name 'C' for linkage purposes by this typedef declaration}}
 
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cplusplus < 202002L
 typedef struct { // expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
   static_assert([]{ return true; }()); // expected-note {{type is not C-compatible due to this lambda expression}}
 } Lambda1; // expected-note {{type is given name 'Lambda1' for linkage purposes by this typedef declaration}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-unevaluated.cpp
===
--- /dev/null
+++ 

[PATCH] D103377: [clangd] Add ability to change storage directory of index files

2021-05-30 Thread Christopher Rhodes via Phabricator via cfe-commits
crr0004 created this revision.
crr0004 added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
crr0004 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This adds a new option to change the root directory of where the index files 
get stored.
I mainly added this because I am doing profiling of indexing and needed a way 
for multiple instances of index files not to conflict with each other.

The extact naming of variables and the help text can be changed, I just guessed.

I tried to add a test for the change however I couldn't find a way to neatly 
check storage root directory. I am not sure if the test I've written is all 
that helpful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103377

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -161,6 +161,30 @@
QName("bar"), QName("bar::one")));
 }
 
+TEST_F(BackgroundIndexTest, StoreIndexedFilesInCustomPath){
+
+  OverlayCDB CDB(/*Base=*/nullptr);
+  auto DiskStorage = BackgroundIndexStorage::createDiskBackedStorageFactory(
+		  [](llvm::StringRef File) {
+			  return CDB.getProjectInfo(File);
+		  },
+		  testing::TempDir()
+  );
+
+  auto *Result = DiskStorage("root/A.cc");
+  IndexFileIn ShardIn{
+		  SymbolSlab{},
+		  RefSlab{},
+		  RelationSlab{},
+		  IncludeGraph{},
+		  tooling::CompileCommand{}
+  };
+  IndexFileOut Shard{ShardIn};
+  auto Result2 = Result->storeShard("root/A.cc", Shard);
+
+  ASSERT_TRUE(Result);
+  ASSERT_FALSE(llvm::errorToBool(std::move(Result2)));
+}
 TEST_F(BackgroundIndexTest, IndexTwoFiles) {
   MockFS FS;
   // a.h yields different symbols when included by A.cc vs B.cc.
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -339,6 +339,14 @@
 Hidden,
 };
 
+opt BackgroundIndexCachePath{
+	"background-index-storage",
+	cat(Misc),
+	desc("The path to store the index files generated by background indexing"),
+	init(""),
+	Hidden
+};
+
 opt Test{
 "lit-test",
 cat(Misc),
@@ -830,6 +838,7 @@
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
   Opts.ReferencesLimit = ReferencesLimit;
+  Opts.BackgroundIndexCachePath = BackgroundIndexCachePath;
   auto PAI = createProjectAwareIndex(loadExternalIndex, Sync);
   if (StaticIdx) {
 IdxStack.emplace_back(std::move(StaticIdx));
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -100,9 +100,11 @@
 class DiskBackedIndexStorageManager {
 public:
   DiskBackedIndexStorageManager(
-  std::function(PathRef)> GetProjectInfo)
+  std::function(PathRef)> GetProjectInfo,
+  llvm::Optional BackgroundDiskCachePath)
   : IndexStorageMapMu(std::make_unique()),
-GetProjectInfo(std::move(GetProjectInfo)) {
+GetProjectInfo(std::move(GetProjectInfo)),
+BackgroundDiskCachePath(BackgroundDiskCachePath) {
 llvm::SmallString<128> FallbackDir;
 if (llvm::sys::path::cache_directory(FallbackDir))
   llvm::sys::path::append(FallbackDir, "clangd", "index");
@@ -113,7 +115,12 @@
   BackgroundIndexStorage *operator()(PathRef File) {
 std::lock_guard Lock(*IndexStorageMapMu);
 llvm::SmallString<128> StorageDir(FallbackDir);
-if (auto PI = GetProjectInfo(File)) {
+if (BackgroundDiskCachePath &&
+!BackgroundDiskCachePath.getValue().empty()) {
+  StorageDir = BackgroundDiskCachePath.getValue();
+  llvm::sys::path::append(StorageDir, ".cache", "clangd", "index");
+
+} else if (auto PI = GetProjectInfo(File)) {
   StorageDir = PI->SourceRoot;
   llvm::sys::path::append(StorageDir, ".cache", "clangd", "index");
 }
@@ -138,14 +145,17 @@
   std::unique_ptr IndexStorageMapMu;
 
   std::function(PathRef)> GetProjectInfo;
+  llvm::Optional BackgroundDiskCachePath;
 };
 
 } // namespace
 
 BackgroundIndexStorage::Factory
 BackgroundIndexStorage::createDiskBackedStorageFactory(
-std::function(PathRef)> GetProjectInfo) {
-  return DiskBackedIndexStorageManager(std::move(GetProjectInfo));
+std::function(PathRef)> GetProjectInfo,
+

[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-05-30 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D101191#2783570 , @rupprecht wrote:

> In D101191#2782963 , @rupprecht 
> wrote:
>
>> The issue I'm seeing seems more directly caused by SLP vectorization, as it 
>> goes away with `-fno-slp-vectorize`. This patch merely unblocks that bad 
>> optimization AFAICT.
>
> Filed as http://llvm.org/PR50500

We needed SLP to get to the problem state in that example, but the bug was in 
instcombine/instsimplify. 
Should be fixed with:
7bb8bfa0622b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2021-05-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

We can't rename options without giving some form of backwards compatibility, 
personally, I think we need to start again with this review if its still of 
interest, this one is 6 years old.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-30 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:3447
+   style);
+}
+

can you add a test

```
#ifdef X
   void foo() {
   ...
   }
#endif
```

its unclear if PPIndentWidth affects code in #ifdef or just # preprocessor 
instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

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


[PATCH] D97669: [clang][AVR] Add avr-libc/include to clang system include paths

2021-05-30 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay accepted this revision.
dylanmckay added a comment.
This revision is now accepted and ready to land.

Looks good, nice and simple. Thanks @benshi001


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

https://reviews.llvm.org/D97669

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


[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2021-05-30 Thread Timo Suoranta via Phabricator via cfe-commits
tksuoran added a comment.

I would like to use exactly the same formatting (really exactly one initializer 
(and nother else) per line). 
Some comments:

- Keep `ConstructorInitializerAllOnOneLineOrOnePerLine` so that the change does 
not break any existing behavior
- Default value for `ConstructorInitializerKind` would make 
`ConstructorInitializerAllOnOneLineOrOnePerLine` to be used
- Non-default values for `ConstructorInitializerKind` would enable for example 
really exactly one initializer per line - yay!
- End result:
  - Old style settings keep working and it just works, giving old results
  - New style settings can omit  
`ConstructorInitializerAllOnOneLineOrOnePerLine` and use 
`ConstructorInitializerKind` and it just works


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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