[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-20 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

The only method that I think can be realistically modelled is `==` (and thus 
`!=`). If both the operands refer to the same `unique_ptr`, we know `==` 
returns true. If they are not the same, the only way `==` can return true if 
the two smart pointers were initialized from the //same// raw pointer. This is 
of course a fatal bug in itself. So perhaps we can ignore this case and only 
consider the first case.
The ordering operators I guess can't be handled because there is no way to 
statically tell in general the address of some value. We have the following 
deductions, nevertheless, mathematically:
Let `ptr1` and `ptr2` be two `std::unique_ptr` objects.
If `(ptr1 == ptr2)` is true:

- `ptr1 < ptr2` is false
- `ptr1 > ptr2` is false
- `ptr1 <= ptr2` is true
- `ptr1 >= ptr2` is true

If `(ptr1 == ptr2)` is false, we can't say anything really.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616

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


[PATCH] D104617: [clangd] Type hints for structured bindings

2021-06-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Hints are shown for the individual bindings, not the aggregate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104617

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  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
@@ -462,19 +462,57 @@
 }
 
 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.
+  // Hint individual bindings, not the aggregate.
   assertTypeHints(R"cpp(
+// 1. Struct with public fields.
 struct Point {
   int x;
   int y;
 };
 Point foo();
-auto [x, y] = foo();
-  )cpp");
+auto [$x1[[x1]], $y1[[y1]]] = foo();
+
+// 2. Array
+int arr[2];
+auto [$x2[[x2]], $y2[[y2]]] = arr;
+
+// 3. Tuple-like type.
+struct IntPair {
+  int a;
+  int b;
+};
+namespace std {
+  template 
+  struct tuple_size {};
+  template <>
+  struct tuple_size {
+constexpr static unsigned value = 2;
+  };
+  template 
+  struct tuple_element {};
+  template 
+  struct tuple_element {
+using type = int;
+  };
+}
+template 
+int get(const IntPair& p) {
+  if constexpr (I == 0) {
+return p.a;
+  } else if constexpr (I == 1) {
+return p.b;
+  }
+}
+IntPair bar();
+auto [$x3[[x3]], $y3[[y3]]] = bar();
+
+// 4. No initializer (ill-formed).
+// Do not show useless "NULL TYPE" hint.
+auto [x4, y4];  /*error-ok*/
+  )cpp",
+  ExpectedHint{": int", "x1"}, ExpectedHint{": int", "y1"},
+  ExpectedHint{": int", "x2"}, ExpectedHint{": int", "y2"},
+  ExpectedHint{": int", "x3"}, ExpectedHint{": int", "y3"});
 }
 
 TEST(TypeHints, ReturnTypeDeduction) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -32,6 +32,12 @@
 TypeHintPolicy.SuppressScope = true; // keep type names short
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
+// Print canonical types. Otherwise, SuppressScope would result in
+// things like "metafunction::type" being shorted to just "type",
+// which is useless. This is particularly important for structured
+// bindings that use the tuple_element protocol, where the non-canonical
+// types would be "tuple_element::type".
+TypeHintPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@@ -76,9 +82,8 @@
 if (auto *AT = D->getReturnType()->getContainedAutoType()) {
   QualType Deduced = AT->getDeducedType();
   if (!Deduced.isNull()) {
-addInlayHint(D->getFunctionTypeLoc().getRParenLoc(),
- InlayHintKind::TypeHint,
- "-> " + D->getReturnType().getAsString(TypeHintPolicy));
+addTypeHint(D->getFunctionTypeLoc().getRParenLoc(), D->getReturnType(),
+"-> ");
   }
 }
 
@@ -86,10 +91,14 @@
   }
 
   bool VisitVarDecl(VarDecl *D) {
-// Do not show hints for the aggregate in a structured binding.
-// In the future, we may show hints for the individual bindings.
-if (isa(D))
+// Do not show hints for the aggregate in a structured binding,
+// but show hints for the individual bindings.
+if (auto *DD = dyn_cast(D)) {
+  for (auto *Binding : DD->bindings()) {
+addTypeHint(Binding->getLocation(), Binding->getType(), ": ");
+  }
   return true;
+}
 
 if (auto *AT = D->getType()->getContainedAutoType()) {
   if (!D->getType()->isDependentType()) {
@@ -98,8 +107,7 @@
 // (e.g. for `const auto& x = 42`, print `const int&`).
 // Alternatively, we could place the hint on the `auto`
 // (and then just print the type deduced for the `auto`).
-addInlayHint(D->getLocation(), InlayHintKind::TypeHint,
- ": " + D->getType().getAsString(TypeHintPolicy));
+addTypeHint(D->getLocation(), D->getType(), ": ");
   }
 }
 return true;
@@ -311,6 +319,15 @@
 Kind, Label.str()});
   }
 
+  void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
+// Do not print useless "NULL TYPE" hint.

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-20 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD created this revision.
RedDocMD added reviewers: NoQ, vsavchenko, xazax.hun, teemperor.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware.
RedDocMD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch handles all the comparision methods (defined via overloaded
operators) on std::unique_ptr. These operators compare the underlying
pointers, which makes it difficult to model the result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104616

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -68,6 +68,7 @@
   bool updateMovedSmartPointers(CheckerContext &C, const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
   void handleBoolConversion(const CallEvent &Call, CheckerContext &C) const;
+  bool handleComparisionOp(const CallEvent &Call, CheckerContext &C) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent &Call, CheckerContext &) 
const;
@@ -264,6 +265,9 @@
   if (handleAssignOp(Call, C))
 return true;
 
+  if (handleComparisionOp(Call, C))
+return true;
+
   const SmartPtrMethodHandlerFn *Handler = SmartPtrMethodHandlers.lookup(Call);
   if (!Handler)
 return false;
@@ -272,6 +276,26 @@
   return C.isDifferent();
 }
 
+bool SmartPtrModeling::handleComparisionOp(const CallEvent &Call,
+   CheckerContext &C) const {
+  const auto *MC = llvm::dyn_cast(&Call);
+  if (!MC)
+return false;
+  const OverloadedOperatorKind OOK = MC->getOverloadedOperator();
+  if (!(OOK == OO_Equal || OOK == OO_ExclaimEqual || OOK == OO_Less ||
+OOK == OO_LessEqual || OOK == OO_Greater || OOK == OO_GreaterEqual ||
+OOK == OO_Spaceship))
+return false;
+
+  // TODO: We had better put some useful modelling here.
+  // But the problem is that all these operators act on the raw
+  // inner pointer (there are special cases for comparision with nullptr).
+  // So, we are not really comparing the value pointed to by the pointer
+  // but the *pointer* itself, which is just an address, which is not
+  // something that symbolic evaluation is concerned about.
+  return true;
+}
+
 void SmartPtrModeling::checkDeadSymbols(SymbolReaper &SymReaper,
 CheckerContext &C) const {
   ProgramStateRef State = C.getState();


Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -68,6 +68,7 @@
   bool updateMovedSmartPointers(CheckerContext &C, const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
   void handleBoolConversion(const CallEvent &Call, CheckerContext &C) const;
+  bool handleComparisionOp(const CallEvent &Call, CheckerContext &C) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent &Call, CheckerContext &) const;
@@ -264,6 +265,9 @@
   if (handleAssignOp(Call, C))
 return true;
 
+  if (handleComparisionOp(Call, C))
+return true;
+
   const SmartPtrMethodHandlerFn *Handler = SmartPtrMethodHandlers.lookup(Call);
   if (!Handler)
 return false;
@@ -272,6 +276,26 @@
   return C.isDifferent();
 }
 
+bool SmartPtrModeling::handleComparisionOp(const CallEvent &Call,
+   CheckerContext &C) const {
+  const auto *MC = llvm::dyn_cast(&Call);
+  if (!MC)
+return false;
+  const OverloadedOperatorKind OOK = MC->getOverloadedOperator();
+  if (!(OOK == OO_Equal || OOK == OO_ExclaimEqual || OOK == OO_Less ||
+OOK == OO_LessEqual || OOK == OO_Greater || OOK == OO_GreaterEqual ||
+OOK == OO_Spaceship))
+return false;
+
+  // TODO: We had better put some useful modelling here.
+  // But the problem is that all these operators act on the raw
+  // inner pointer (there are special cases for comparision with nullptr).
+  // So, we are not really comparing the value pointed to by the pointer
+  // but the *pointer* itself, which is just an address, which is not
+  // something that symbolic evaluation is concerned about.
+  return true;
+}
+
 void SmartPtrModeling::checkDeadSymbols(SymbolReaper &SymReaper,
 CheckerContext &C) const {
   ProgramStateRef State = C.getState();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llv

[PATCH] D103789: [clangd] Type hints for C++14 return type deduction

2021-06-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe37653da1399: [clangd] Type hints for C++14 return type 
deduction (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103789

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  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
@@ -478,14 +478,31 @@
 }
 
 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");
+  assertTypeHints(
+  R"cpp(
+auto f1(int x$ret1a[[)]];  // Hint forward declaration too
+auto f1(int x$ret1b[[)]] { return x + 1; }
+
+// Include pointer operators in hint
+int s;
+auto& f2($ret2[[)]] { return s; }
+
+// Do not hint `auto` for trailing return type.
+auto f3() -> int;
+
+// `auto` conversion operator
+struct A {
+  operator auto($retConv[[)]] { return 42; }
+};
+
+// FIXME: Dependent types do not work yet.
+template 
+struct S {
+  auto method() { return T(); }
+};
+  )cpp",
+  ExpectedHint{"-> int", "ret1a"}, ExpectedHint{"-> int", "ret1b"},
+  ExpectedHint{"-> int &", "ret2"}, ExpectedHint{"-> int", "retConv"});
 }
 
 TEST(TypeHints, DependentType) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -72,6 +72,19 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (auto *AT = D->getReturnType()->getContainedAutoType()) {
+  QualType Deduced = AT->getDeducedType();
+  if (!Deduced.isNull()) {
+addInlayHint(D->getFunctionTypeLoc().getRParenLoc(),
+ InlayHintKind::TypeHint,
+ "-> " + D->getReturnType().getAsString(TypeHintPolicy));
+  }
+}
+
+return true;
+  }
+
   bool VisitVarDecl(VarDecl *D) {
 // Do not show hints for the aggregate in a structured binding.
 // In the future, we may show hints for the individual bindings.


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -478,14 +478,31 @@
 }
 
 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");
+  assertTypeHints(
+  R"cpp(
+auto f1(int x$ret1a[[)]];  // Hint forward declaration too
+auto f1(int x$ret1b[[)]] { return x + 1; }
+
+// Include pointer operators in hint
+int s;
+auto& f2($ret2[[)]] { return s; }
+
+// Do not hint `auto` for trailing return type.
+auto f3() -> int;
+
+// `auto` conversion operator
+struct A {
+  operator auto($retConv[[)]] { return 42; }
+};
+
+// FIXME: Dependent types do not work yet.
+template 
+struct S {
+  auto method() { return T(); }
+};
+  )cpp",
+  ExpectedHint{"-> int", "ret1a"}, ExpectedHint{"-> int", "ret1b"},
+  ExpectedHint{"-> int &", "ret2"}, ExpectedHint{"-> int", "retConv"});
 }
 
 TEST(TypeHints, DependentType) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -72,6 +72,19 @@
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (auto *AT = D->getReturnType()->getContainedAutoType()) {
+  QualType Deduced = AT->getDeducedType();
+  if (!Deduced.isNull()) {
+addInlayHint(D->getFunctionTypeLoc().getRParenLoc(),
+ InlayHintKind::TypeHint,
+ "-> " + D->getReturnType().getAsString(TypeHintPolicy));
+  }
+}
+
+return true;
+  }
+
   bool VisitVarDecl(VarDecl *D) {
 // Do not show hints for the aggregate in a structured binding.
 // In the future, we may show hints for the individual bindings.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e37653d - [clangd] Type hints for C++14 return type deduction

2021-06-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2021-06-21T01:13:00-04:00
New Revision: e37653da1399d846e02897680412139fdcde93ab

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

LOG: [clangd] Type hints for C++14 return type deduction

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

Added: 


Modified: 
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index d0e0e961abcf3..1002aee218477 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -72,6 +72,19 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (auto *AT = D->getReturnType()->getContainedAutoType()) {
+  QualType Deduced = AT->getDeducedType();
+  if (!Deduced.isNull()) {
+addInlayHint(D->getFunctionTypeLoc().getRParenLoc(),
+ InlayHintKind::TypeHint,
+ "-> " + D->getReturnType().getAsString(TypeHintPolicy));
+  }
+}
+
+return true;
+  }
+
   bool VisitVarDecl(VarDecl *D) {
 // Do not show hints for the aggregate in a structured binding.
 // In the future, we may show hints for the individual bindings.

diff  --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 
b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
index 3c5503448ab8f..2c5597e17e2f0 100644
--- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -478,14 +478,31 @@ TEST(TypeHints, StructuredBindings) {
 }
 
 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");
+  assertTypeHints(
+  R"cpp(
+auto f1(int x$ret1a[[)]];  // Hint forward declaration too
+auto f1(int x$ret1b[[)]] { return x + 1; }
+
+// Include pointer operators in hint
+int s;
+auto& f2($ret2[[)]] { return s; }
+
+// Do not hint `auto` for trailing return type.
+auto f3() -> int;
+
+// `auto` conversion operator
+struct A {
+  operator auto($retConv[[)]] { return 42; }
+};
+
+// FIXME: Dependent types do not work yet.
+template 
+struct S {
+  auto method() { return T(); }
+};
+  )cpp",
+  ExpectedHint{"-> int", "ret1a"}, ExpectedHint{"-> int", "ret1b"},
+  ExpectedHint{"-> int &", "ret2"}, ExpectedHint{"-> int", "retConv"});
 }
 
 TEST(TypeHints, DependentType) {



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


[PATCH] D103501: [clang][AIX] Enable inlined quadword atomic operations

2021-06-20 Thread Kai Luo via Phabricator via cfe-commits
lkail added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:336
 .Default(false);
+  Features["quadword-atomics"] = llvm::StringSwitch(CPU)
+ .Case("pwr10", true)

qiucf wrote:
> What about `ppc64`?
> 
> Also, seems there's no need to add `pwr10` here.
> What about ppc64?


Instructions needed for inline quadword atomics like `lqarx` and `stqcx` are 
only user-space viable in pwr8 and above. However, pwr6 and pwr7 also feature 
ppc64.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103501

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


[PATCH] D103501: [clang][AIX] Enable inlined quadword atomic operations

2021-06-20 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 353268.
lkail added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103501

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/ppc64-quadword-atomics.c


Index: clang/test/CodeGen/ppc64-quadword-atomics.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-quadword-atomics.c
@@ -0,0 +1,16 @@
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr9 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr10 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+
+struct Quadword { long long a[2]; } __attribute__((aligned (16)));
+
+// CHECK-NOT: call void @__atomic_exchange
+// CHECK: +quadword-atomics
+struct Quadword test_xchg(struct Quadword *ptr, struct Quadword new) {
+  struct Quadword old;
+  __atomic_exchange(ptr, &new, &old, __ATOMIC_SEQ_CST);
+  return old;
+}
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -74,6 +74,7 @@
   bool HasP10Vector = false;
   bool HasPCRelativeMemops = false;
   bool HasPrefixInstrs = false;
+  bool HasQuadwordAtomics = false;
 
 protected:
   std::string ABI;
@@ -437,6 +438,12 @@
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }
 
+  void setMaxAtomicWidth() override {
+// FIXME: Current only support quadword inline atomics on AIX.
+if (getTriple().isOSAIX() && hasFeature("quadword-atomics"))
+  MaxAtomicInlineWidth = 128;
+  }
+
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -73,6 +73,8 @@
   HasROPProtect = true;
 } else if (Feature == "+privileged") {
   HasPrivileged = true;
+} else if (Feature == "+quadword-atomics") {
+  HasQuadwordAtomics = true;
 }
 // TODO: Finish this list and add an assert that we've handled them
 // all.
@@ -352,6 +354,11 @@
 .Case("pwr9", true)
 .Case("pwr8", true)
 .Default(false);
+  Features["quadword-atomics"] =
+  getTriple().isArch64Bit() && llvm::StringSwitch(CPU)
+   .Case("pwr9", true)
+   .Case("pwr8", true)
+   .Default(false);
 
   // ROP Protect is off by default.
   Features["rop-protect"] = false;
@@ -449,6 +456,7 @@
   .Case("mma", HasMMA)
   .Case("rop-protect", HasROPProtect)
   .Case("privileged", HasPrivileged)
+  .Case("quadword-atomics", HasQuadwordAtomics)
   .Default(false);
 }
 


Index: clang/test/CodeGen/ppc64-quadword-atomics.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-quadword-atomics.c
@@ -0,0 +1,16 @@
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr9 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr10 -S -emit-llvm -o - \
+// RUN:   %s | FileCheck %s
+
+struct Quadword { long long a[2]; } __attribute__((aligned (16)));
+
+// CHECK-NOT: call void @__atomic_exchange
+// CHECK: +quadword-atomics
+struct Quadword test_xchg(struct Quadword *ptr, struct Quadword new) {
+  struct Quadword old;
+  __atomic_exchange(ptr, &new, &old, __ATOMIC_SEQ_CST);
+  return old;
+}
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -74,6 +74,7 @@
   bool HasP10Vector = false;
   bool HasPCRelativeMemops = false;
   bool HasPrefixInstrs = false;
+  bool HasQuadwordAtomics = false;
 
 protected:
   std::string ABI;
@@ -437,6 +438,12 @@
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }
 
+  void setMaxAtomicWidth() override {
+// FIXME: Current only support quadword inline atomics on AIX.
+if (getTriple().isOSAIX() && hasFeature("quadword-atomics"))
+  MaxAtomicInlineWidth = 128;
+  }
+
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
   }
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -73,6 +73,8 @@
   HasROPProtect = true;

[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-06-20 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

A remained question.

- what's the semantics if user specified their allocation/deallocation 
functions?

Previously, we discussed for the ::operator new and ::operator delete. But what 
would we do for user specified allocation/deallocation functions?
It looks like we would treat them just like `::operator new`. And it makes 
sense at the first glance. But the problem comes from that we judge whether
or not to over allocate a frame by this condition:

  coro.align > align of new

But if the user uses their new, it makes no sense to use the `align of new` as 
the condition. On the other hand, if user specified their new function and the 
alignment requirement for their promise type, would it be better really that 
the compiler do the extra transformation?

May be we need to discuss with other guys who are more familiar with the C++ 
standard to answer this.




Comment at: clang/lib/CodeGen/CGCoroutine.cpp:437-475
+void emitDynamicAlignedDealloc(CodeGenFunction &CGF,
+   llvm::BasicBlock *AlignedFreeBB,
+   llvm::CallInst *CoroFree) {
+  llvm::CallInst *Dealloc = nullptr;
+  for (llvm::User *U : CoroFree->users()) {
+if (auto *CI = dyn_cast(U))
+  if (CI->getParent() == CGF.Builder.GetInsertBlock())

ychen wrote:
> ChuanqiXu wrote:
> > We don't need this in this patch.
> Do you mean `// Match size_t argument with the one used during allocation.` 
> or the function `emitDynamicAlignedDealloc`? I think either is needed here. 
> Could you please elaborate? 
Sorry for that I misunderstand this function earlier.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:420
+
+void OverAllocateFrame(CodeGenFunction &CGF, llvm::CallInst *CI, bool IsAlloc) 
{
+  unsigned CoroSizeIdx = IsAlloc ? 0 : 1;

It looks like we'd better to add comment for this function.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:421
+void OverAllocateFrame(CodeGenFunction &CGF, llvm::CallInst *CI, bool IsAlloc) 
{
+  unsigned CoroSizeIdx = IsAlloc ? 0 : 1;
+  CGBuilderTy &Builder = CGF.Builder;

CoroSizeIdx should be zero all the time in this patch.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:431-433
+  auto *Diff = Builder.CreateNSWSub(AlignCall, AlignOfNewInt);
+  auto *NewCoroSize = Builder.CreateAdd(CI->getArgOperand(CoroSizeIdx), Diff);
+  CI->setArgOperand(CoroSizeIdx, NewCoroSize);

In other comments, I find 'size += align - NEW_ALIGN + sizeof(void*);'. But I 
don't find sizeof(void*) in this function.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:452-461
+  llvm::Function *RawFramePtrOffsetIntrin = CGF.CGM.getIntrinsic(
+  llvm::Intrinsic::coro_raw_frame_ptr_offset, CGF.Int32Ty);
+  auto *RawFramePtrOffset = CGF.Builder.CreateCall(RawFramePtrOffsetIntrin);
+  auto *FramePtrAddrStart =
+  CGF.Builder.CreateInBoundsGEP(CoroFree, {RawFramePtrOffset});
+  auto *FramePtrAddr = CGF.Builder.CreatePointerCast(
+  FramePtrAddrStart, CGF.Int8PtrTy->getPointerTo());

We allocate overaligned-frame like:
```
| --- for align --- | --- true frame --- |
```
And here we set the argument to the address of true frame. Then I wonder how 
about the memory for the `for align` part. Would we still free them correctly? 
Maybe I missed something.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:466-472
+  if (Dealloc->getNumArgOperands() > 1) {
+// Size may only be the second argument of allocator call.
+if (auto *CoroSize =
+dyn_cast(Dealloc->getArgOperand(1)))
+  if (CoroSize->getIntrinsicID() == llvm::Intrinsic::coro_size)
+OverAllocateFrame(CGF, Dealloc, /*IsAlloc*/ false);
+  }

We don't need to handle this condition in this patch.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:644
+  llvm::BasicBlock *RetOnFailureBB = nullptr;
+  llvm::BasicBlock *AlignAllocBB2 = nullptr;
 

It may be better to rename AlignAllocBB2 as AlignAllocBBCont or something 
similar.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:717
+AlignAllocBB2 = createBasicBlock("coro.alloc.align2");
+Builder.CreateCondBr(Cond, AlignAllocBB2, RetOnFailureBB);
+EmitBlock(AlignAllocBB2);

It looks better to add an assert for RetOnFailureBB. I think it may be nullptr 
at the first glance.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:731-732
+  {RawFramePtrAddr, getPointerAlign()});
+  AlignedAllocateCall = AlignedUpAddr;
+
   EmitBlock(InitBB);

We remove this assignment and use AlignedUpAddr directly in the following.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:743-744
+CGM.getIntrinsic(llvm::Intrinsic::coro_align, SizeTy));
+auto *AlignedUpAddr = EmitBuiltinAlignTo(AlignedAllocateCall, CoroAlign,

[PATCH] D104604: [clang] NFC: add line break at the end of if expressions

2021-06-20 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104604

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


[PATCH] D104145: [clang] NFC: adjust indentation of statements with more than one lines

2021-06-20 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG735ad67a4ce8: [clang] NFC: adjust indentation of statements 
with more than one lines (authored by zhouyizhou, committed by pengfei).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104145

Files:
  clang/lib/Sema/TreeTransform.h

Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12497,15 +12497,13 @@
 nullptr);
 }
 
-template
-ExprResult
-TreeTransform::TransformDependentScopeDeclRefExpr(
-   DependentScopeDeclRefExpr *E,
-   bool IsAddressOfOperand,
-   TypeSourceInfo **RecoveryTSI) {
+template 
+ExprResult TreeTransform::TransformDependentScopeDeclRefExpr(
+DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
+TypeSourceInfo **RecoveryTSI) {
   assert(E->getQualifierLoc());
-  NestedNameSpecifierLoc QualifierLoc
-  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
+  NestedNameSpecifierLoc QualifierLoc =
+  getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
   if (!QualifierLoc)
 return ExprError();
   SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
@@ -12514,14 +12512,13 @@
   // destination type name (if present) resolves the same way after
   // instantiation as it did in the local scope.
 
-  DeclarationNameInfo NameInfo
-= getDerived().TransformDeclarationNameInfo(E->getNameInfo());
+  DeclarationNameInfo NameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getNameInfo());
   if (!NameInfo.getName())
 return ExprError();
 
   if (!E->hasExplicitTemplateArgs()) {
-if (!getDerived().AlwaysRebuild() &&
-QualifierLoc == E->getQualifierLoc() &&
+if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
 // Note: it is sufficient to compare the Name component of NameInfo:
 // if name has not changed, DNLoc has not changed either.
 NameInfo.getName() == E->getDeclName())
@@ -12533,9 +12530,8 @@
   }
 
   TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
-  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
-  E->getNumTemplateArgs(),
-  TransArgs))
+  if (getDerived().TransformTemplateArguments(
+  E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
 return ExprError();
 
   return getDerived().RebuildDependentScopeDeclRefExpr(
@@ -13183,18 +13179,18 @@
  &TransArgs);
 }
 
-template
-ExprResult
-TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) {
+template 
+ExprResult TreeTransform::TransformUnresolvedMemberExpr(
+UnresolvedMemberExpr *Old) {
   // Transform the base of the expression.
-  ExprResult Base((Expr*) nullptr);
+  ExprResult Base((Expr *)nullptr);
   QualType BaseType;
   if (!Old->isImplicitAccess()) {
 Base = getDerived().TransformExpr(Old->getBase());
 if (Base.isInvalid())
   return ExprError();
-Base = getSema().PerformMemberExprBaseConversion(Base.get(),
- Old->isArrow());
+Base =
+getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
 if (Base.isInvalid())
   return ExprError();
 BaseType = Base.get()->getType();
@@ -13204,27 +13200,24 @@
 
   NestedNameSpecifierLoc QualifierLoc;
   if (Old->getQualifierLoc()) {
-QualifierLoc
-= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
+QualifierLoc =
+getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
 if (!QualifierLoc)
   return ExprError();
   }
 
   SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
 
-  LookupResult R(SemaRef, Old->getMemberNameInfo(),
- Sema::LookupOrdinaryName);
+  LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
 
   // Transform the declaration set.
-  if (TransformOverloadExprDecls(Old, /*RequiresADL*/false, R))
+  if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
 return ExprError();
 
   // Determine the naming class.
   if (Old->getNamingClass()) {
-CXXRecordDecl *NamingClass
-  = cast_or_null(getDerived().TransformDecl(
-  Old->getMemberLoc(),
-Old->getNamingClass()));
+CXXRecordDecl *NamingClass = cast_or_null(
+getDerived().TransformDe

[clang] 735ad67 - [clang] NFC: adjust indentation of statements with more than one lines

2021-06-20 Thread via cfe-commits

Author: Zhouyi Zhou
Date: 2021-06-21T10:17:10+08:00
New Revision: 735ad67a4ce8d4a6c10f10d12f4282c796ea7ab7

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

LOG: [clang] NFC: adjust indentation of statements with more than one lines

Hi,

I think it will be more beautiful to adjust indentation of statements with more 
than one lines.

In function TreeTransform::TransformDependentScopeDeclRefExpr
the second line of statement
NestedNameSpecifierLoc QualifierLoc \newline = 
getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
is no more indent than the first line

There is a similar case in function 
TreeTransform::TransformUnresolvedMemberExpr

Also I use clang-format to fix above functions

Thanks alot

Reviewed By: pengfei

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

Added: 


Modified: 
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 21dc8c5d893bd..b4648efa229f8 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12497,15 +12497,13 @@ ExprResult 
TreeTransform::TransformDependentScopeDeclRefExpr(
 nullptr);
 }
 
-template
-ExprResult
-TreeTransform::TransformDependentScopeDeclRefExpr(
-   DependentScopeDeclRefExpr *E,
-   bool IsAddressOfOperand,
-   TypeSourceInfo **RecoveryTSI) {
+template 
+ExprResult TreeTransform::TransformDependentScopeDeclRefExpr(
+DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
+TypeSourceInfo **RecoveryTSI) {
   assert(E->getQualifierLoc());
-  NestedNameSpecifierLoc QualifierLoc
-  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
+  NestedNameSpecifierLoc QualifierLoc =
+  getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
   if (!QualifierLoc)
 return ExprError();
   SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
@@ -12514,14 +12512,13 @@ 
TreeTransform::TransformDependentScopeDeclRefExpr(
   // destination type name (if present) resolves the same way after
   // instantiation as it did in the local scope.
 
-  DeclarationNameInfo NameInfo
-= getDerived().TransformDeclarationNameInfo(E->getNameInfo());
+  DeclarationNameInfo NameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getNameInfo());
   if (!NameInfo.getName())
 return ExprError();
 
   if (!E->hasExplicitTemplateArgs()) {
-if (!getDerived().AlwaysRebuild() &&
-QualifierLoc == E->getQualifierLoc() &&
+if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() 
&&
 // Note: it is sufficient to compare the Name component of NameInfo:
 // if name has not changed, DNLoc has not changed either.
 NameInfo.getName() == E->getDeclName())
@@ -12533,9 +12530,8 @@ 
TreeTransform::TransformDependentScopeDeclRefExpr(
   }
 
   TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
-  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
-  E->getNumTemplateArgs(),
-  TransArgs))
+  if (getDerived().TransformTemplateArguments(
+  E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
 return ExprError();
 
   return getDerived().RebuildDependentScopeDeclRefExpr(
@@ -13183,18 +13179,18 @@ 
TreeTransform::TransformCXXDependentScopeMemberExpr(
  &TransArgs);
 }
 
-template
-ExprResult
-TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr 
*Old) {
+template 
+ExprResult TreeTransform::TransformUnresolvedMemberExpr(
+UnresolvedMemberExpr *Old) {
   // Transform the base of the expression.
-  ExprResult Base((Expr*) nullptr);
+  ExprResult Base((Expr *)nullptr);
   QualType BaseType;
   if (!Old->isImplicitAccess()) {
 Base = getDerived().TransformExpr(Old->getBase());
 if (Base.isInvalid())
   return ExprError();
-Base = getSema().PerformMemberExprBaseConversion(Base.get(),
- Old->isArrow());
+Base =
+getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
 if (Base.isInvalid())
   return ExprError();
 BaseType = Base.get()->getType();
@@ -13204,27 +13200,24 @@ 
TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old)
 
   NestedNameSpecifierLoc QualifierLoc;
   if (Old->getQualifierLoc()) {
-QualifierLoc
-= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
+QualifierLoc =
+getDerived().Transfo

[PATCH] D103750: [analyzer] Handle std::make_unique for SmartPtrModeling

2021-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yes, @xazax.hun is correct.

It's incorrect to say that the static analyzer "doesn't seem to be able to make 
up its mind". The analyzer gives perfectly clear and consistent answers for 
each execution path it explores and it's not surprising that the results are 
different on different execution paths. The presence of the FALSE path 
indicates indicates that the test indeed doesn't pass: an impossible execution 
path is being explored.

Eagerly-assume is a thing because it produces easier constraints for the solver 
to solve. Also the state split is pretty justified on any boolean expression 
with no side effects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D94333: [Inliner] Change inline remark format and update ReplayInlineAdvisor to use it

2021-06-20 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D94333#2829233 , @sylvestre.ledru 
wrote:

>> I think this change broke apt.llvm.org
>
> Confirmed: reverting this change fixed the link issue

What exact commit/download package and build command repros this? 
M68kSubtarget.cpp is completely untouched by this change I'm surprised that 
reverting this fixes it. Did you bisect it down to this commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94333

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


[PATCH] D104500: [clang] Apply P1825 as Defect Report from C++11 up to C++20.

2021-06-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 353240.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104500

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/SemaCXX/P1155.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp
  clang/test/SemaObjCXX/block-capture.mm

Index: clang/test/SemaObjCXX/block-capture.mm
===
--- clang/test/SemaObjCXX/block-capture.mm
+++ clang/test/SemaObjCXX/block-capture.mm
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b,cxx2b %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx20_2b   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx98_11   %s
-// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98_11   %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b,cxx2b %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fblocks   -verify=cxx98_2b,cxx11_2b   %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -fobjc-arc -fblocks -Wno-c++11-extensions -verify=cxx98_2b,cxx98  %s
 
 #define TEST(T) void test_##T() { \
   __block T x;\
@@ -14,54 +14,68 @@
 };
 TEST(CopyOnly); // cxx2b-error {{no matching constructor}}
 
+struct ConstCopyOnly {
+  ConstCopyOnly();
+  ConstCopyOnly(ConstCopyOnly &) = delete; // cxx98-note {{marked deleted here}}
+  ConstCopyOnly(const ConstCopyOnly &);
+};
+TEST(ConstCopyOnly); // cxx98-error {{call to deleted constructor}}
+
+struct NonConstCopyOnly {
+  NonConstCopyOnly();
+  NonConstCopyOnly(NonConstCopyOnly &);
+  NonConstCopyOnly(const NonConstCopyOnly &) = delete; // cxx11_2b-note {{marked deleted here}}
+};
+TEST(NonConstCopyOnly); // cxx11_2b-error {{call to deleted constructor}}
+
 struct CopyNoMove {
   CopyNoMove();
   CopyNoMove(CopyNoMove &);
-  CopyNoMove(CopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  CopyNoMove(CopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(CopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
+TEST(CopyNoMove); // cxx11_2b-error {{call to deleted constructor}}
 
 struct MoveOnly {
   MoveOnly();
-  MoveOnly(MoveOnly &) = delete;
+  MoveOnly(MoveOnly &) = delete; // cxx98-note {{marked deleted here}}
   MoveOnly(MoveOnly &&);
 };
-TEST(MoveOnly);
+TEST(MoveOnly); // cxx98-error {{call to deleted constructor}}
 
 struct NoCopyNoMove {
   NoCopyNoMove();
-  NoCopyNoMove(NoCopyNoMove &) = delete;
-  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx98_2b-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &) = delete;  // cxx98-note {{marked deleted here}}
+  NoCopyNoMove(NoCopyNoMove &&) = delete; // cxx11_2b-note {{marked deleted here}}
 };
 TEST(NoCopyNoMove); // cxx98_2b-error {{call to deleted constructor}}
 
 struct ConvertingRVRef {
   ConvertingRVRef();
-  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98_11-note {{marked deleted here}}
+  ConvertingRVRef(ConvertingRVRef &) = delete; // cxx98-note {{marked deleted here}}
 
   struct X {};
   ConvertingRVRef(X &&);
   operator X() const & = delete;
   operator X() &&;
 };
-TEST(ConvertingRVRef); // cxx98_11-error {{call to deleted constructor}}
+TEST(ConvertingRVRef); // cxx98-error {{call to deleted constructor}}
 
 struct ConvertingCLVRef {
   ConvertingCLVRef();
   ConvertingCLVRef(ConvertingCLVRef &);
 
   struct X {};
-  ConvertingCLVRef(X &&); // cxx20_2b-note {{passing argument to parameter here}}
+  ConvertingCLVRef(X &&); // cxx11_2b-note {{passing argument to parameter here}}
   operator X() const &;
-  operator X() && = delete; // cxx20_2b-note {{marked deleted here}}
+  operator X() && = delete; // cxx11_2b-note {{marked deleted here}}
 };
-TEST(ConvertingCLVRef); // cxx20_2b-error {{invokes a deleted function}}
+TEST(ConvertingCLVRef); // cxx11_2b-error {{invokes a deleted function}}
 
 struct SubSubMove {};
 struct SubMove : SubSubMove {
   SubMove();
-  SubMove(SubMove &) = delete; // cxx98_11-note {{marked deleted here}}
+  SubMove(SubMove &) = delete; // cxx98-note {{marked deleted here}}
 
   SubMove(SubSubMove &&);
 };
-TEST(SubMove); // cxx98_11-error {{call to deleted constructor}}
+TEST(SubMove); // cxx98-error {{call to deleted constructor}}
Index: clang/test/SemaCXX/warn-return-std-move.cpp
==

[PATCH] D104285: [analyzer] Retrieve value by direct index from list initialization of constant array declaration.

2021-06-20 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

I've looked this over and tested it locally, and I'm pretty sure it's a good 
patch.  If it were solely up to me, I'd accept this patch as-is.  I don't think 
I should assume I have enough experience in this area though...  @NoQ , could 
you take a look over this, and accept it if you think it's safe and reasonable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285

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


[PATCH] D104604: [clang] NFC: add line break at the end of if expressions

2021-06-20 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou created this revision.
zhouyizhou added reviewers: pengfei, rsmith, rjmccall, doug.gregor, sepavloff, 
craig.topper, klimek.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Hi,

In function TransformTemplateArgument,
would it be better to add line break at the end of "if" expressions?

I use clang-format to do the job for me.

Thanks a lot


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104604

Files:
  clang/lib/Sema/TreeTransform.h


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4322,10 +4322,10 @@
   Arg, QualType(), getDerived().getBaseLocation());
 }
 
-template
+template 
 bool TreeTransform::TransformTemplateArgument(
- const TemplateArgumentLoc &Input,
- TemplateArgumentLoc &Output, bool 
Uneval) {
+const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
+bool Uneval) {
   const TemplateArgument &Arg = Input.getArgument();
   switch (Arg.getKind()) {
   case TemplateArgument::Null:
@@ -4374,7 +4374,8 @@
   DI = InventTypeSourceInfo(Input.getArgument().getAsType());
 
 DI = getDerived().TransformType(DI);
-if (!DI) return true;
+if (!DI)
+  return true;
 
 Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
 return false;
@@ -4390,9 +4391,8 @@
 
 CXXScopeSpec SS;
 SS.Adopt(QualifierLoc);
-TemplateName Template
-  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
-   Input.getTemplateNameLoc());
+TemplateName Template = getDerived().TransformTemplateName(
+SS, Arg.getAsTemplate(), Input.getTemplateNameLoc());
 if (Template.isNull())
   return true;
 
@@ -4414,11 +4414,13 @@
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();
-if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
+if (!InputExpr)
+  InputExpr = Input.getArgument().getAsExpr();
 
 ExprResult E = getDerived().TransformExpr(InputExpr);
 E = SemaRef.ActOnConstantExpression(E);
-if (E.isInvalid()) return true;
+if (E.isInvalid())
+  return true;
 Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
 return false;
   }


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4322,10 +4322,10 @@
   Arg, QualType(), getDerived().getBaseLocation());
 }
 
-template
+template 
 bool TreeTransform::TransformTemplateArgument(
- const TemplateArgumentLoc &Input,
- TemplateArgumentLoc &Output, bool Uneval) {
+const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
+bool Uneval) {
   const TemplateArgument &Arg = Input.getArgument();
   switch (Arg.getKind()) {
   case TemplateArgument::Null:
@@ -4374,7 +4374,8 @@
   DI = InventTypeSourceInfo(Input.getArgument().getAsType());
 
 DI = getDerived().TransformType(DI);
-if (!DI) return true;
+if (!DI)
+  return true;
 
 Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
 return false;
@@ -4390,9 +4391,8 @@
 
 CXXScopeSpec SS;
 SS.Adopt(QualifierLoc);
-TemplateName Template
-  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
-   Input.getTemplateNameLoc());
+TemplateName Template = getDerived().TransformTemplateName(
+SS, Arg.getAsTemplate(), Input.getTemplateNameLoc());
 if (Template.isNull())
   return true;
 
@@ -4414,11 +4414,13 @@
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();
-if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
+if (!InputExpr)
+  InputExpr = Input.getArgument().getAsExpr();
 
 ExprResult E = getDerived().TransformExpr(InputExpr);
 E = SemaRef.ActOnConstantExpression(E);
-if (E.isInvalid()) return true;
+if (E.isInvalid())
+  return true;
 Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104044: [clang-format] Fix the issue that empty lines being removed at the beginning of namespace

2021-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:281
+   CustomStyle));
+  EXPECT_EQ("/* something */ namespace N\n"
+"{\n"

What does

```
namespace N  { /* comment */
```

or 

```
namespace N   /* comment */ {
```

do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104044

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


[PATCH] D94333: [Inliner] Change inline remark format and update ReplayInlineAdvisor to use it

2021-06-20 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

> I think this change broke apt.llvm.org

Confirmed: reverting this change fixed the link issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94333

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