[clang] c8ddf27 - Revert "[Sema] Address-space sensitive index check for unbounded arrays"

2020-09-15 Thread Chris Hamilton via cfe-commits

Author: Chris Hamilton
Date: 2020-09-15T01:57:29-05:00
New Revision: c8ddf27ddbbe140d8acbcf1b2d3fdfbba253d02c

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

LOG: Revert "[Sema] Address-space sensitive index check for unbounded arrays"

This reverts commit da55e9ba1273284f1af61bceeaeb25e487838034.

Build bots uncovered coverage gap in testing.  Change not ready.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/const-eval.c
clang/test/SemaCXX/constant-expression-cxx1y.cpp

Removed: 
clang/test/Sema/unbounded-array-bounds.c



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e0be2072bb6e..e0d700c66724 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8847,14 +8847,6 @@ def warn_array_index_precedes_bounds : Warning<
 def warn_array_index_exceeds_bounds : Warning<
   "array index %0 is past the end of the array (which contains %1 "
   "element%s2)">, InGroup;
-def warn_ptr_arith_exceeds_max_addressable_bounds : Warning<
-  "the pointer incremented by %0 refers past the last possible element for an 
array in %1-bit "
-  "address space containing %2-bit (%3-byte) elements (max possible %4 
element%s5)">,
-  InGroup;
-def warn_array_index_exceeds_max_addressable_bounds : Warning<
-  "array index %0 refers past the last possible element for an array in %1-bit 
"
-  "address space containing %2-bit (%3-byte) elements (max possible %4 
element%s5)">,
-  InGroup;
 def note_array_declared_here : Note<
   "array %0 declared here">;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index dbfa329993c8..f2b70be1d431 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14038,11 +14038,11 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, 
const Expr *IndexExpr,
   const ConstantArrayType *ArrayTy =
   Context.getAsConstantArrayType(BaseExpr->getType());
 
-  const Type *BaseType =
-  ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
-  bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
-  (!IsUnboundedArray && BaseType->isDependentType()))
+  if (!ArrayTy)
+return;
+
+  const Type *BaseType = ArrayTy->getElementType().getTypePtr();
+  if (EffectiveType->isDependentType() || BaseType->isDependentType())
 return;
 
   Expr::EvalResult Result;
@@ -14059,69 +14059,6 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, 
const Expr *IndexExpr,
   if (const MemberExpr *ME = dyn_cast(BaseExpr))
 ND = ME->getMemberDecl();
 
-  if (IsUnboundedArray) {
-if (index.isUnsigned() || !index.isNegative()) {
-  const auto &ASTC = getASTContext();
-  unsigned AddrBits =
-  ASTC.getTargetInfo().getPointerWidth(ASTC.getTargetAddressSpace(
-  EffectiveType->getCanonicalTypeInternal()));
-  if (index.getBitWidth() < AddrBits)
-index = index.zext(AddrBits);
-  CharUnits ElemCharUnits = ASTC.getTypeSizeInChars(EffectiveType);
-  llvm::APInt ElemBytes(index.getBitWidth(), ElemCharUnits.getQuantity());
-  // If index has more active bits than address space, we already know
-  // we have a bounds violation to warn about.  Otherwise, compute
-  // address of (index + 1)th element, and warn about bounds violation
-  // only if that address exceeds address space.
-  if (index.getActiveBits() <= AddrBits) {
-bool Overflow;
-llvm::APInt Product(index);
-Product += 1;
-Product = Product.umul_ov(ElemBytes, Overflow);
-if (!Overflow && Product.getActiveBits() <= AddrBits)
-  return;
-  }
-
-  // Need to compute max possible elements in address space, since that
-  // is included in diag message.
-  llvm::APInt MaxElems = llvm::APInt::getMaxValue(AddrBits);
-  MaxElems = MaxElems.zext(std::max(AddrBits + 1, 
ElemBytes.getBitWidth()));
-  MaxElems += 1;
-  ElemBytes = ElemBytes.zextOrTrunc(MaxElems.getBitWidth());
-  MaxElems = MaxElems.udiv(ElemBytes);
-
-  unsigned DiagID =
-  ASE ? diag::warn_array_index_exceeds_max_addressable_bounds
-  : diag::warn_ptr_arith_exceeds_max_addressable_bounds;
-
-  // Diag message shows element size in bits and in "bytes" (platform-
-  // dependent CharUnits)
-  DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
-  PDiag(DiagID)
-  << index.toString(10, true) << AddrBits
-  << (unsigned)ASTC.toBits(ElemCharUnits)
-  << ElemBytes.

[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-15 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 291813.
usaxena95 added a comment.

Fixed namespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/for-review-only/CompletionModel.cpp
  clang-tools-extra/clangd/for-review-only/CompletionModel.h
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.cpp
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.h
  clang-tools-extra/clangd/quality/CompletionModel.cmake
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/quality/README.md
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
  clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
  clang-tools-extra/clangd/unittests/model/features.json
  clang-tools-extra/clangd/unittests/model/forest.json

Index: clang-tools-extra/clangd/unittests/model/forest.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/forest.json
@@ -0,0 +1,52 @@
+[
+{
+"operation": "if_greater",
+"feature": "ANumber",
+"threshold": 200.0,
+"then": {
+"operation": "if_greater",
+"feature": "AFloat",
+"threshold": -1,
+"then": {
+"operation": "boost",
+"score": 10.0
+},
+"else": {
+"operation": "boost",
+"score": -20.0
+}
+},
+"else": {
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"C"
+],
+"then": {
+"operation": "boost",
+"score": 3.0
+},
+"else": {
+"operation": "boost",
+"score": -4.0
+}
+}
+},
+{
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"B"
+],
+"then": {
+"operation": "boost",
+"score": 5.0
+},
+"else": {
+"operation": "boost",
+"score": -6.0
+}
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/model/features.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/features.json
@@ -0,0 +1,16 @@
+[
+{
+"name": "ANumber",
+"type": "NUMBER"
+},
+{
+"name": "AFloat",
+"type": "NUMBER"
+},
+{
+"name": "ACategorical",
+"type": "ENUM",
+"enum": "ns1::ns2::TestEnum",
+"header": "model/CategoricalFeature.h"
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
@@ -0,0 +1,5 @@
+namespace ns1 {
+namespace ns2 {
+enum TestEnum { A, B, C, D };
+} // namespace ns2
+} // namespace ns1
Index: clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
@@ -0,0 +1,29 @@
+#include "DecisionForestRuntimeTest.h"
+#include "model/CategoricalFeature.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+TEST(DecisionForestRuntime, Evaluate) {
+  using Example = ::ns1::ns2::test::Example;
+  using Cat = ::ns1::ns2::TestEnum;
+  using ::ns1::ns2::test::Evaluate;
+
+  Example E;
+  E.setANumber(200); // True
+  E.setAFloat(0);// True: +10.0
+  E.setACategorical(Cat::A); // True: +5.0
+  EXPECT_EQ(Evaluate(E), 15.0);
+
+  E.setANumber(200); // True
+  E.setAFloat(-2.5); // False: -20.0
+  E.setACategorical(Cat::B); // True: +5.0
+  EXPECT_EQ(Evaluate(E), -15.0);
+
+  E.setANumber(100); // False
+  E.setACategorical(Cat::C); // True: +3.0, False: -6.0
+  EXPECT_EQ(Evaluate(E), -3.0);
+}
+} // namespace clangd
+} // namespace clangd
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -10,6 +10,7 @@
 #include "ClangdServer.h"
 #include "CodeComplete.h"
 #include "Compiler.h"
+#include "CompletionModel.h"
 #include "Matchers.h"
 #include "Protocol.h"
 #inc

[PATCH] D87352: Fix typo in doc ClangFormatStyleOptions.rst

2020-09-15 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui added a comment.

In D87352#2263416 , @MyDeveloperDay 
wrote:

> LGTM, thank you for doing this..

Thanks,
may me you can help me commit it  : )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87352

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


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-15 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.
Herald added a subscriber: modimo.

@lxfind , could you backport this to branch 11?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

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


[PATCH] D87604: [X86] Convert integer _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)

2020-09-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D87604#2272211 , @craig.topper 
wrote:

> Longer term should we have a variadic version of this like 
> __builtin_shufflevector or __builtin_convertvector that can handle any 
> reduction?

Yes, I was looking at what would be necessary for that as well - I think that 
is what is proposed in PR36691.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87604

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, mstorsjo, kadircet, arphaman, 
jkorous.
Herald added a project: clang.
ArcsinX requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Without this patch `clangd` crashes at try to load compressed string table when 
`zlib` it not available.
Example:

- Build `clangd` with MinGW (zlib found)
- Build index
- Build `clangd` with Visual Studio compiler (zlib not found)
- Try to load index


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87673

Files:
  clang-tools-extra/clangd/index/Serialization.cpp


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,11 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
+  } else {
+return makeError("Compressed string table, but zlib is unavailable");
   }
 
   StringTableIn Table;


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,11 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
+  } else {
+return makeError("Compressed string table, but zlib is unavailable");
   }
 
   StringTableIn Table;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87352: Fix typo in doc ClangFormatStyleOptions.rst

2020-09-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

I have realized this is the wrong change

The actual error is in Format.h

clang/docs/ClangFormatStyleOption.rst is generated using the 
clang/docs/tools/dump_format_style.py if we commit this change in the rst will 
get reintroduced when that is run

If you are still interested please change Format.h

  /// Break parameters list into lines when there is nested block
   /// parameters in a fuction call.
   /// \code
   ///   false:
   ///- (void)_aMethod
   ///{
   ///[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
   ///*u, NSNumber *v) {
   ///u = c;
   ///}]
   ///}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87352

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added reviewers: sammccall, kadircet, adamcz.
ArcsinX added a comment.

Unsure about test for this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-15 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

All comments should be adressed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D87352: Fix typo in Format.h

2020-09-15 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui updated this revision to Diff 291825.
YangZhihui retitled this revision from "Fix typo in doc 
ClangFormatStyleOptions.rst" to "Fix typo in Format.h".

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

https://reviews.llvm.org/D87352

Files:
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-15 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 291826.
fodinabor marked 9 inline comments as done.
fodinabor added a comment.

Unit test cleanups.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,21 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnknownOption) {
+  StringRef InputYAML = "InvalidKey: InvalidValue\n"
+"Binary: \n";
+  BinaryHolder BH;
+  yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case.
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+  EXPECT_EQ(BH2.Binary, yaml::BinaryRef(""));
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   bool   

[PATCH] D87352: Fix typo in Format.h

2020-09-15 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui added a comment.

In D87352#2273349 , @MyDeveloperDay 
wrote:

> I have realized this is the wrong change
>
> The actual error is in Format.h
>
> clang/docs/ClangFormatStyleOption.rst is generated using the 
> clang/docs/tools/dump_format_style.py if we commit this change in the rst 
> will get reintroduced when that is run
>
> If you are still interested please change Format.h
>
>   /// Break parameters list into lines when there is nested block
>/// parameters in a fuction call.
>/// \code
>///   false:
>///- (void)_aMethod
>///{
>///[self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
>///*u, NSNumber *v) {
>///u = c;
>///}]
>///}

Thanks for tell me this error
I'll change Format.h


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

https://reviews.llvm.org/D87352

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 291827.
ArcsinX added a comment.

Fix build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

Files:
  clang-tools-extra/clangd/index/Serialization.cpp


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,11 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
+  } else {
+return error("Compressed string table, but zlib is unavailable");
   }
 
   StringTableIn Table;


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,11 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
+  } else {
+return error("Compressed string table, but zlib is unavailable");
   }
 
   StringTableIn Table;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87615: [clang][Driver] Force stack realignment on 32-bit Solaris/x86

2020-09-15 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D87615#2271646 , @efriedma wrote:

> 



> X86Subtarget::initSubtargetFeatures claims that that stack is 16-byte aligned 
> on Solaris; if that's wrong, we should fix it, not force stack realignment.

I missed that (my usual issue of config info spread over llvm and clang).  I'll 
shortly post an alternative patch using that approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[PATCH] D87615: [clang][Driver] Force stack realignment on 32-bit Solaris/x86

2020-09-15 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

That claim of 16-byte alignment on Solaris is half-wrong: it's definitely wrong 
on Solaris, but seems to be true on Illumos.

However, there's currently no way to distinguish the two other than checking 
`uname -v` at runtime in a native compiler.  The configure triples continue to 
be identical.  Maybe it's possible to do the `uname` check in 
`llvm/lib/Support/Unix/Host.inc` (`updateTripleOSVersion`) changing the triple 
to (say) `x86_64-pc-illumos` at runtime.  Then `isOSSolaris` would return 
`true` for both Solaris and Illumos, while a new `isOSIllumos` would only 
return `true` on Illumos: I think such a subtarget approach is what they used 
in Go.  However, this might well break elsewhere and it's ultimately up to the 
Illumos community to decide how to deal with the Solaris/Illumos differences.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

2020-09-15 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 291831.
ro retitled this revision from "[clang][Driver] Force stack realignment on 
32-bit Solaris/x86" to "[X86] Fix stack alignment on 32-bit Solaris/x86".
ro added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Set `stackAlignment` instead.

Tested on `amd64-pc-solaris2.11`.  However, compared to the `-mstackrealign` 
version
there's one regression that I still need to investigate:

  UBSan-Standalone-i386 :: TestCases/TypeCheck/vptr.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

Files:
  llvm/lib/Target/X86/X86Subtarget.cpp


Index: llvm/lib/Target/X86/X86Subtarget.cpp
===
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -258,13 +258,16 @@
 report_fatal_error("64-bit code requested on a subtarget that doesn't "
"support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
-  // 32 and 64 bit) and for all 64-bit targets.
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and for all
+  // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
+  // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
 stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
-   isTargetKFreeBSD() || In64BitMode)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+   In64BitMode)
 stackAlignment = Align(16);
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 
   // Consume the vector width attribute or apply any target specific limit.
   if (PreferVectorWidthOverride)


Index: llvm/lib/Target/X86/X86Subtarget.cpp
===
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -258,13 +258,16 @@
 report_fatal_error("64-bit code requested on a subtarget that doesn't "
"support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
-  // 32 and 64 bit) and for all 64-bit targets.
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and for all
+  // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
+  // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
 stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
-   isTargetKFreeBSD() || In64BitMode)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+   In64BitMode)
 stackAlignment = Align(16);
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 
   // Consume the vector width attribute or apply any target specific limit.
   if (PreferVectorWidthOverride)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87629: Thread safety analysis: Improve documentation for ASSERT_CAPABILITY

2020-09-15 Thread Vasil Dimov via Phabricator via cfe-commits
vasild added inline comments.



Comment at: clang/docs/ThreadSafetyAnalysis.rst:452-454
+and terminating or throwing if the capability is not held.  Presence of this
+annotation causes the analysis to assume the capability is held at the point of
+the call. See :ref:`mutexheader`, below, for example uses.

aaronpuchert wrote:
> That's an interesting point. We currently do assume that the capability is 
> held even when an exception is thrown, although that's primarily because 
> Clang's source-level CFG doesn't really model exception handling that well:
> 
> ```
> Mutex mu;
> bool a GUARDED_BY(mu);
> 
> void except() {
>   try {
> mu.AssertHeld();
>   } catch (...) {
> a = 0; // No warning.
>   }
> }
> ```
> 
> We can't warn there because `AssertHeld` might terminate in case the mutex 
> isn't held.
> 
> Not sure if we need to clarify this here: we just assume that the capability 
> is held on a regular return. The other case is basically UB for us.
Maybe don't mention "throwing", given the example above and `s/at the 
call/after the call/`.
It is similar to:

```
void f(char x, unsigned char y)
{
assert(x >= 0);
assert(y <= 127);
if (x > y) { // it is ok to omit a warning about comparing signed and 
unsigned because AFTER the asserts we know we are good.
...
}
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87629

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


[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

2020-09-15 Thread Rainer Orth via Phabricator via cfe-commits
ro added a subscriber: vitalybuka.
ro added a comment.

In D87615#2273427 , @ro wrote:

> 



> Tested on `amd64-pc-solaris2.11`.  However, compared to the `-mstackrealign` 
> version
> there's one regression that I still need to investigate:
>
>   UBSan-Standalone-i386 :: TestCases/TypeCheck/vptr.cpp

This turns out to be just a whitespace difference: before the stack alignment 
patch I'd get for the `mS` subtest:

  Test case: mS
  
/vol/llvm/src/llvm-project/dist/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp:169:15:
 runtime error: member access within address 0xfeffdcf0 which does not point to 
an object of type 'T'
  0xfeffdcf0: note: object is of type 'S'
   76 62 92 92  ec 1b 06 08 00 00 00 00  44 de ff fe 30 dd ff fe  00 00 00 00 
00 00 00 00  00 00 00 00
^~~
vptr for 'S'

After the patch I see instead:

  Test case: mS
  
/vol/llvm/src/llvm-project/dist/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp:169:15:
 runtime error: member access within address 0xfeffdd34 which does not point to 
an object of type 'T'
  0xfeffdd34: note: object is of type 'S'
76 62 92 92 ec 1b 06 08  00 00 00 00 78 dd ff fe  00 00 00 00 00 00 00 00  
00 00 00 00 00 00 00 00
^~~
vptr for 'S'

i.e. one additional blank at the beginning of the line and a different 
grouping.  I have no idea about the significance of those: @vitalybuka?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

2020-09-15 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 291837.
ro added a reviewer: vitalybuka.
ro added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Allow for whitespace differences in `vptr.cpp`.

Tested on `amd64-pc-solaris2.11` with the previous `-mstackrealign` patch and 
with the new `stackAlignment` one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

Files:
  compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
  llvm/lib/Target/X86/X86Subtarget.cpp


Index: llvm/lib/Target/X86/X86Subtarget.cpp
===
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -258,13 +258,16 @@
 report_fatal_error("64-bit code requested on a subtarget that doesn't "
"support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
-  // 32 and 64 bit) and for all 64-bit targets.
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and for all
+  // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
+  // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
 stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
-   isTargetKFreeBSD() || In64BitMode)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+   In64BitMode)
 stackAlignment = Align(16);
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 
   // Consume the vector width attribute or apply any target specific limit.
   if (PreferVectorWidthOverride)
Index: compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
@@ -162,7 +162,7 @@
   case 'm':
 // CHECK-MEMBER: vptr.cpp:[[@LINE+6]]:15: runtime error: member access 
within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
 // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']]
-// CHECK-MEMBER-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
+// CHECK-MEMBER-NEXT: {{^  ?.. .. .. ..  ?.. .. .. ..  ?.. .. .. ..  ?}}
 // CHECK-MEMBER-NEXT: {{^  \^~~()? *$}}
 // CHECK-MEMBER-NEXT: {{^  vptr for}} [[DYN_TYPE]]
 // CHECK-Linux-MEMBER: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE+1]]
@@ -178,7 +178,7 @@
   case 'f':
 // CHECK-MEMFUN: vptr.cpp:[[@LINE+6]]:15: runtime error: member call on 
address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
 // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']]
-// CHECK-MEMFUN-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
+// CHECK-MEMFUN-NEXT: {{^  ?.. .. .. ..  ?.. .. .. ..  ?.. .. .. ..  ?}}
 // CHECK-MEMFUN-NEXT: {{^  \^~~()? *$}}
 // CHECK-MEMFUN-NEXT: {{^  vptr for}} [[DYN_TYPE]]
 // TODO: Add check for stacktrace here.
@@ -196,7 +196,7 @@
   case 'c':
 // CHECK-DOWNCAST: vptr.cpp:[[@LINE+6]]:11: runtime error: downcast of 
address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
 // CHECK-DOWNCAST-NEXT: [[PTR]]: note: object is of type 
[[DYN_TYPE:'S'|'U']]
-// CHECK-DOWNCAST-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
+// CHECK-DOWNCAST-NEXT: {{^  ?.. .. .. ..  ?.. .. .. ..  ?.. .. .. ..  ?}}
 // CHECK-DOWNCAST-NEXT: {{^  \^~~()? *$}}
 // CHECK-DOWNCAST-NEXT: {{^  vptr for}} [[DYN_TYPE]]
 // CHECK-Linux-DOWNCAST: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE+1]]


Index: llvm/lib/Target/X86/X86Subtarget.cpp
===
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -258,13 +258,16 @@
 report_fatal_error("64-bit code requested on a subtarget that doesn't "
"support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
-  // 32 and 64 bit) and for all 64-bit targets.
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and for all
+  // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
+  // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
 stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
-   isTargetKFreeBSD() || In64BitMode)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+   In64BitMode)
 stackAlignment = Align(16);
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 
   // Consume the vect

[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks! Mostly looks good, just couple of nits.




Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:223
+// whenever they become available.
+void hotReload(clangd::SwapIndex *Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,

Again `Index` is a non-nullptr, so let's use a ref instead.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:231
+  // Current index is newer than the one before: no reload is needed.
+  if (NewModificationTime <= LastStatus.getLastModificationTime())
+return;

from previous comment:
```
i think we should rather store the file_status from the original file in here. 
as we want to reload whenever files size/modification_time has changed.
it doesn't have to be moving forward let alone share the same timezone 
restrictions and such provided by system_clock::now.
```



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:247
+
+void runServer(clangd::SymbolIndex *Index, llvm::StringRef ServerAddress,
+   llvm::StringRef IndexPath) {

nit: maybe rename to `runServerAndWait`



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:328
+auto Status = FS->status(IndexPath);
+assert(Status);
+if (!Status)

instead of both asserting and bailing out, maybe just elog before bail-out?

+ I think what you rather want is grab the inital status outside this lambda. 
i.e:

```
clang::clangd::RealThreadsafeFS TFS;
auto FS = TFS...;
auto Status = ;
if(!Status) {
  // elog and exit, file does not exist
}
auto Index = ...;

if(!Index) {
 // elog and exit, failed to load index 
}

std::thread ..([FS = TFS.view(), LastStatus = *Status, &Index]{ ... });
runServer();
joinThread();
```



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:332
+llvm::vfs::Status LastStatus = *Status;
+const auto REFRESH_FREQUENCY = std::chrono::seconds(90);
+while (!clang::clangd::shutdownRequested()) {

nit: `static constexpr auto RefreshFrequency`, i.e. use constexpr and we don't 
have a different naming convention for constants. same for `WatcherFrequency`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

2020-09-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8522
+  return VT->getElementType().getCanonicalType() ==
+ getBuiltinVectorTypeInfo(BT).ElementType;
   }

efriedma wrote:
> We allow casting SVE fixed-width vectors only if the element type is 
> identical, but we allow casting to GNU fixed-width vectors if the vector 
> width is the same?  That seems sort of loose; could allow weird casts, 
> particularly when bool vectors are involved.
> We allow casting SVE fixed-width vectors only if the element type is 
> identical, but we allow casting to GNU fixed-width vectors if the vector 
> width is the same? That seems sort of loose; could allow weird casts, 
> particularly when bool vectors are involved.

Fixed-length SVE vectors are created with the attribute and the vector width 
must match `-msve-vector-bits`, which should guarantee consistent vector widths 
for a given input. This is checking the vector width is the same and the 
element type matches when casting between GNU and SVE vectors, although since 
neither of those types are created by the attribute it's necessary to check the 
vector width to validate `__ARM_FEATURE_SVE_BITS==N`.

Predicates are treated differently in the ACLE and it doesn't mention 
supporting casts between GNU bool vectors and SVE VLS/VLA predicates. I'm also 
not sure the GNU vector_size extension is defined for bool elements yet, but I 
did notice Simon Moll is working on this (D81083).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87607

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


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 291861.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Address a round of comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, Object);
   if (!SerializedItem) {
@@ -210,22 +215,54 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  if (!Status || Status->equivalent(LastStatus))
+return;
+  // Current index is different from the one before: no reload is needed.
+  vlog("Found different index version: existing index was modified at {0}, new "
+   "index was modified at {1}. Attempting to reload.",
+   LastStatus.getLastModificationTime(), Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {
+vlog("Failed to load new index. Old index will be served.");
+return;
+  }
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}.",
+  Status->getLastModificationTime());
+  LastStatus = *Status;
+}
+
+void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
+  llvm::StringRef IndexPath) {
+  RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
   grpc::ServerBuilder

[PATCH] D87590: Backport D79219, D85820, D86134 to 10.0 branch

2020-09-15 Thread Harmen Stoppels via Phabricator via cfe-commits
haampie added a comment.

D86134  should not be added, it was reverted 
afterwards. What eventually landed was D85820 
, which adds a better fix for what D86134 
 was supposed to solve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87590

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


[PATCH] D87590: Backport D79219, D85820, D86134 to 10.0 branch

2020-09-15 Thread Pavel Labath via Phabricator via cfe-commits
labath added subscribers: tstellar, labath.
labath added a reviewer: tstellar.
labath added a comment.

@tstellar, who is (was) the release manager for 10.0, can make a definitive 
call, but our usual modus operandi is to have one point release for each major 
version. I don't know if this is a sufficiently major issue to break from that 
(and it definitely is risky).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87590

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: gribozavr2, aaron.ballman.
baloghadamsoftware added a project: clang-tools-extra.
Herald added subscribers: martong, steakhal, gamesh411, Szelethus, dkrupp, 
rnkovacs, xazax.hun, whisperity.
Herald added a project: clang.
baloghadamsoftware requested review of this revision.

Placement new operators on non-object types cause crash in 
`bugprone-misplaced-pointer-arithmetic-in-alloc`. This patch fixes this issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87683

Files:
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,10 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+void* operator new(unsigned long, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is 
applied to the result of operator new() instead of its size-like argument
+}
Index: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,10 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+void* operator new(unsigned long, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+}
Index: clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87590: Backport D79219, D85820, D86134 to 10.0 branch

2020-09-15 Thread Harmen Stoppels via Phabricator via cfe-commits
haampie added a comment.

Also note that the changes are not likely to be backported to 11 even: 
https://reviews.llvm.org/rG31e5f7120bdd2f76337686d9d169b1c00e6ee69c#942622


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87590

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


[PATCH] D87352: Fix typo in Format.h

2020-09-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Ok almost...

so you change the Format.h, then run the docs/tools/clang_format_stype.py and 
attach both the rst and the .h to the review


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

https://reviews.llvm.org/D87352

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


[PATCH] D87590: Backport D79219, D85820, D86134 to 10.0 branch

2020-09-15 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

In D87590#2273721 , @haampie wrote:

> Also note that the changes are not likely to be backported to 11 even: 
> https://reviews.llvm.org/rG31e5f7120bdd2f76337686d9d169b1c00e6ee69c#942622.

11.0.0, probably. There's should be enough time for 11.0.1, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87590

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


[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

2020-09-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, xazax.hun.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

The integration is already complete; this patch updates information as well as
suggests using Clang-Tidy via Clangd integration that is vastly available
in most editors through LSP client plugins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87686

Files:
  clang-tools-extra/docs/clang-tidy/Integrations.rst


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -3,23 +3,28 @@
 ==
 
 .. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using Clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
+
+The following table shows the most well-known :program:`clang-tidy`
+integrations in detail.
 
 
+--++-+--+-+--+
 |  |Feature

   |
 
+==++=+==+=+==+
 |  **Tool**| On-the-fly inspection  | Check list 
configuration (GUI)  | Options to checks (GUI)  | Configuration via 
``.clang-tidy`` files | Custom clang-tidy binary |
 
+--++-+--+-+--+
+|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
++--++-+--+-+--+
 |A.L.E. for Vim| \+\|  
 \-\   |   \-\| \-\ 
|   \+\|
 
+--++-+--+-+--+
 |Clang Power Tools for Visual Studio   | \-\|  
 \+\   |   \-\| \+\ 
|   \-\|
 
+--++-+--+-+--+
-|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
-+--++-+--+-+--+
 |CLion IDE | \+\|  
 \+\   |   \+\| \+\ 
|   \+\|
 
+--++-+--+-+--+
 |CodeChecker   | \-\|  
 \-\   |   \-\| \-\ 
|   \+\|


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-t

[PATCH] D87396: Sema: add support for `__attribute__((__swift_bridged_typedef__))`

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

LGTM with some test location nits.




Comment at: clang/test/SemaObjC/attr-swift_bridged_typedef.m:2
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+

Can you split this bit off into a separate test in the AST directory? Then you 
don't have to contend with the errors in the test file and it's a more 
realistic test (AST tests with errors present always leave me wondering how the 
AST will change as we add error recovery functionality to the AST).



Comment at: clang/test/SemaObjC/attr-swift_bridged_typedef.mm:1
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+

Can you move this test to the AST directory as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87396

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


[PATCH] D87627: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

2020-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp:81
+  assert(FnTy && "FunctionProtoType is null.");
+  if (clang::isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+  return;

No need for the `clang::` bit.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp:23
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }

njames93 wrote:
> This line is causing tests to fail
Another suggestion is to do: `using size_t = decltype(sizeof(0));` at the top 
of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87627

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@russell.gallop I see a lots of failing tests when running `ninja check-all` on 
a Scudo-enabled build (stage 2). Do you see the same thing on your end?

  ==89136==ERROR: Scudo failed to allocate 0x1 (65536) bytes of memory at 
address 0x4c0090e00 (error code: 1455)
  ==89136==Dumping process modules:
  ERROR: Failed to mmap

If 4.4 TB of virtual pages are mapped in each process (this happens on 
startup), then we quickly exaust the 48-bit (256 TB) addressable space with 72+ 
programs running (on a 36-core). Any idea where this 4.4 TB mapping comes from?

Also, the infamous `DynamicLibrary.Shutdown` unittest fails with Scudo, like 
with SnMalloc. That test covers a tricky situation at shutdown.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

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


[PATCH] D87540: [clang-tidy] Fix false positive issue in performance-unnecessary-value-param for arguments being moved in the function body.

2020-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:66
 
+bool isPassedToStdMove(const ParmVarDecl &Param, ASTContext &Context) {
+  // Check if the parameter has a name, in case of functions like -

Can `Context` be `const ASTContext &`?



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:74
+  // parmVarDecl picked up by this checker. It will be an empty string and will
+  // lead to an assertion failure when using hasName(std::string) being used
+  // in the matcher below. If empty then exit indicating no move calls present

This may be a bigger issue with `hasName()` as this strikes me as possibly 
being a bug. I would expect `hasName("")` to return `false` for any AST node 
which has a nonempty name, and `true` for any AST node without a name.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:77
+  // for the function argument being examined.
+  const auto ParamName = Param.getName();
+

We don't typically use top-level `const` in the project, so you can drop that, 
and you should only use `auto` when the type is spelled out in the 
initialization (or is impossible to spell, or strikingly obvious from context 
like iterators), so you should spell that type out in this case.


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

https://reviews.llvm.org/D87540

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


[clang-tools-extra] 98e07b5 - Restrict UnnecessaryCopyInitialization check to variables initialized from free functions without arguments

2020-09-15 Thread Aaron Ballman via cfe-commits

Author: Felix Berger
Date: 2020-09-15T08:46:04-04:00
New Revision: 98e07b5596c8692c43770bc4e21a2b19467e35f7

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

LOG: Restrict UnnecessaryCopyInitialization check to variables initialized from 
free functions without arguments

This restriction avoids cases where an alias is returned to an argument and
which could lead to to a false positive change.

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index f7b21a50203c..03b4450d8ca8 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -54,7 +54,8 @@ void 
UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
 on(declRefExpr(to(varDecl().bind("objectArg");
   auto ConstRefReturningFunctionCall =
   callExpr(callee(functionDecl(returns(ConstReference))),
-   unless(callee(cxxMethodDecl(;
+   unless(callee(cxxMethodDecl(
+  .bind("initFunctionCall");
 
   auto localVarCopiedFrom = [this](const internal::Matcher &CopyCtorArg) 
{
 return compoundStmt(
@@ -96,6 +97,8 @@ void UnnecessaryCopyInitialization::check(
   const auto *ObjectArg = Result.Nodes.getNodeAs("objectArg");
   const auto *BlockStmt = Result.Nodes.getNodeAs("blockStmt");
   const auto *CtorCall = Result.Nodes.getNodeAs("ctorCall");
+  const auto *InitFunctionCall =
+  Result.Nodes.getNodeAs("initFunctionCall");
 
   TraversalKindScope RAII(*Result.Context, ast_type_traits::TK_AsIs);
 
@@ -113,6 +116,11 @@ void UnnecessaryCopyInitialization::check(
   return;
 
   if (OldVar == nullptr) {
+// Only allow initialization of a const reference from a free function if 
it
+// has no arguments. Otherwise it could return an alias to one of its
+// arguments and the arguments need to be checked for const use as well.
+if (InitFunctionCall != nullptr && InitFunctionCall->getNumArgs() > 0)
+  return;
 handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, ObjectArg,
*Result.Context);
   } else {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
index 50dcfd8f8bf2..7a70bc18a28c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -23,6 +23,9 @@ struct WeirdCopyCtorType {
 ExpensiveToCopyType global_expensive_to_copy_type;
 
 const ExpensiveToCopyType &ExpensiveTypeReference();
+const ExpensiveToCopyType &freeFunctionWithArg(const ExpensiveToCopyType &);
+const ExpensiveToCopyType &freeFunctionWithDefaultArg(
+const ExpensiveToCopyType *arg = nullptr);
 const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
@@ -387,3 +390,18 @@ void implicitVarFalsePositive() {
   for (const Element &E : Container()) {
   }
 }
+
+// This should not trigger the check as the argument could introduce an alias.
+void negativeInitializedFromFreeFunctionWithArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = freeFunctionWithArg(Orig);
+}
+
+void negativeInitializedFromFreeFunctionWithDefaultArg() {
+  const ExpensiveToCopyType Copy = freeFunctionWithDefaultArg();
+}
+
+void negativeInitialzedFromFreeFunctionWithNonDefaultArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = freeFunctionWithDefaultArg(&Orig);
+}



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


[PATCH] D87455: [clang-tidy] performance-unnecessary-copy-initialization: Restrict UnnecessaryCopyInitialization check to variables initialized from free functions without arguments

2020-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D87455#2271582 , @flx wrote:

> Thank you for the review, Aaron!
>
> I don't have have commit access. Would you mind submitting it?

I've commit on your behalf in 98e07b5596c8692c43770bc4e21a2b19467e35f7 
, thank 
you for the patch!


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

https://reviews.llvm.org/D87455

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


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

2020-09-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D87163#2272749 , @asbirlea wrote:

> I'd suggest reverting if the failures are blocking, but we do need a 
> reproducer so it can be recommitted after a fix is in place.

+1, but I think ideally we would have reproducers for the remaining issues 
first. @dmajor @thakis please let me know if this is blocking you and it is not 
feasible to provide reproducers before reverting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


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

2020-09-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

It's not blocking us because we added an explicit flag to force this off to our 
build config for "normal" builds. (We still get the default-on behavior on our 
bots that build with trunk clang.) But if others are seeing problems with this 
too, I think it makes sense to revert so others don't spend time tracking down 
miscompiles to this commit.

Sadly our ToT bots were broken all day yesterday because someone broke 
-Warray-bounds in clang. That got reverted 5h ago, but our bots need 6-7h to 
cycle, so we don't know how our tests look at clang trunk.

(The last build before the -Warray-bounds issue also timed out during compile, 
so it's possible that that's a real issue and if so then the current build will 
also time out during compile and we'll have to analyze and fix that first 
before we get data about the state of our tests.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D85607: CfgTraits: add CfgInstructionRef

2020-09-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: tatianashp.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85607

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


[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

2020-09-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 291891.
c-rhodes edited the summary of this revision.
c-rhodes added a comment.

Added tests for implicit casts between GNU and fixed-length SVE vectors. I was 
planning to create a separate patch for this but since it's only tests and no 
functional changes I've included it in this patch.


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

https://reviews.llvm.org/D87607

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -1,14 +1,26 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
 // expected-no-diagnostics
 
+#include 
+
 #define N __ARM_FEATURE_SVE_BITS
 
 typedef __SVInt8_t svint8_t;
 typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
 
 template struct S { T var; };
 
 S s;
 
+// Test implicit casts between VLA and VLS vectors
 svint8_t to_svint8_t(fixed_int8_t x) { return x; }
 fixed_int8_t from_svint8_t(svint8_t x) { return x; }
+
+// Test implicit casts between GNU and VLA vectors
+svint8_t to_svint8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
+gnu_int8_t from_svint8_t__to_gnu_int8_t(svint8_t x) { return x; }
+
+// Test implicit casts between GNU and VLS vectors
+fixed_int8_t to_fixed_int8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
+gnu_int8_t from_fixed_int8_t__to_gnu_int8_t(fixed_int8_t x) { return x; }
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+
+#include 
 
 #define N __ARM_FEATURE_SVE_BITS
 
+typedef __fp16 float16_t;
+typedef float float32_t;
+typedef double float64_t;
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 typedef __SVInt32_t svint32_t;
@@ -19,6 +24,7 @@
 typedef __SVFloat64_t svfloat64_t;
 
 #if defined(__ARM_FEATURE_SVE_BF16)
+typedef __bf16 bfloat16_t;
 typedef __SVBFloat16_t svbfloat16_t;
 #endif
 
@@ -43,6 +49,23 @@
 
 typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
 
+// GNU vector types
+typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
+typedef int16_t gnu_int16_t __attribute__((vector_size(N / 8)));
+typedef int32_t gnu_int32_t __attribute__((vector_size(N / 8)));
+typedef int64_t gnu_int64_t __attribute__((vector_size(N / 8)));
+
+typedef uint8_t gnu_uint8_t __attribute__((vector_size(N / 8)));

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

2020-09-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D87163#2273917 , @thakis wrote:

> It's not blocking us because we added an explicit flag to force this off to 
> our build config for "normal" builds. (We still get the default-on behavior 
> on our bots that build with trunk clang.) But if others are seeing problems 
> with this too, I think it makes sense to revert so others don't spend time 
> tracking down miscompiles to this commit.
>
> Sadly our ToT bots were broken all day yesterday because someone broke 
> -Warray-bounds in clang. That got reverted 5h ago, but our bots need 6-7h to 
> cycle, so we don't know how our tests look at clang trunk.

Ok, if you could let me know once you have some results, that would be great. 
If there still are problems, I'll go ahead an revert the patch later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D86532: (Urgent!) [docs][analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock

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

lgtm please commit so this makes it into the release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86532

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


[PATCH] D86533: (Urgent!) [release][docs][analyzer] Add 11.0.0. release notes

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

This has probably had enough time for review. Please commit.


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

https://reviews.llvm.org/D86533

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


[PATCH] D78902: [Driver] Add output file to properties of Command

2020-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 291899.
sepavloff added a comment.

Rebase and ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78902

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/Minix.cpp
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,34 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, CommandOutput) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  "clang LLVM compiler", InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  const JobList &Jobs = CC->getJobs();
+
+  const auto &CmdCompile = Jobs.getJobs().front();
+  const auto &InFile = CmdCompile->getInputFilenames().front();
+  EXPECT_STREQ(InFile, "foo.cpp");
+  auto ObjFile = CmdCompile->getOutputFilenames().front();
+  EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
+
+  const auto &CmdLink = Jobs.getJobs().back();
+  const auto LinkInFile = CmdLink->getInputFilenames().front();
+  EXPECT_EQ(ObjFile, LinkInFile);
+  auto ExeFile = CmdLink->getOutputFilenames().front();
+  EXPECT_EQ("a.out", ExeFile);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -53,7 +53,7 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
- Exec, CmdArgs, Inputs));
+ Exec, CmdArgs, Inputs, Output));
 }
 
 void tools::XCore::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -82,7 +82,7 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
- Exec, CmdArgs, Inputs));
+ Exec, CmdArgs, Inputs, Output));
 }
 
 /// XCore tool chain
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -114,8 +114,9 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  C.addCommand(std::make_unique(
-  JA, *this, ResponseFileSupport::AtFileCurCP(), Linker, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this,
+ ResponseFileSupport::AtFileCurCP(),
+ Linker, CmdArgs, Inputs, Output));
 
   // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
@@ -139,7 +140,7 @@
 CmdArgs.push_back(Output.getFilename());
 C.addCommand(std::

[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

2020-09-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:233-234
 
+svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // 
expected-error-re {{returning 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' 
values) from a function with incompatible result type 'svint64_t' (aka 
'__SVInt64_t')}}
+gnu_int32_t from_svint64_t__to_gnu_int32_t(svint64_t x) { return x; } // 
expected-error-re {{returning 'svint64_t' (aka '__SVInt64_t') from a function 
with incompatible result type 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' 
values)}}
+

I expected similar diagnostics when casting between GNU and fixed-length SVE 
vectors where the element type doesn't match but the vector size is equal but 
that wasn't the case. Since no functional changes were necessary to support 
casting between these types I tried the following:
```#include 

#define N 128

typedef float float32_t;
typedef double float64_t;

typedef float32_t gnu_float32_t __attribute__((vector_size(N/8)));
typedef float64_t gnu_float64_t __attribute__((vector_size(N/8)));

gnu_float32_t foo(gnu_float64_t x) { return (gnu_float32_t)x; }
gnu_float64_t bar(gnu_float32_t x) { return (gnu_float64_t)x; }```

It seems Clang considers this implicit cast valid whereas GCC doesn't, even 
with lax vector conversions enabled.


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

https://reviews.llvm.org/D87607

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


[PATCH] D86562: [OPENMP][NFC]Release notes for OpenMP in clang (11.x).

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Please go ahead and commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86562

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


[PATCH] D86562: [OPENMP][NFC]Release notes for OpenMP in clang (11.x).

2020-09-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D86562#2274036 , @hans wrote:

> Please go ahead and commit.

Hi Hans, can you commit it yourself? I have some technical issues and not able 
to commit it. And I don't know when it is going to be resolved. :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86562

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


[PATCH] D87540: [clang-tidy] Fix false positive issue in performance-unnecessary-value-param for arguments being moved in the function body.

2020-09-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp:74
+  // parmVarDecl picked up by this checker. It will be an empty string and will
+  // lead to an assertion failure when using hasName(std::string) being used
+  // in the matcher below. If empty then exit indicating no move calls present

aaron.ballman wrote:
> This may be a bigger issue with `hasName()` as this strikes me as possibly 
> being a bug. I would expect `hasName("")` to return `false` for any AST node 
> which has a nonempty name, and `true` for any AST node without a name.
When I was looking at the `hasName` matcher I was surprised that this is not 
the case (see `getNodeName` in `ASTMatchers/ASTMatchersInternal.cpp`). For 
example an unnamed enumeration can be matched with `(anonymous enum)` (which 
should be `unnamed` instead). For an other example a constructor can be matched 
with the name of the class despite the fact that the constructor is formally 
unnamed (because `DeclarationName::getDeclName` and `NamedDecl::printName` are 
used).

I think that the `hasName` matcher is mixing two different concepts: the formal 
name of the AST node and the name for diagnostic purposes. One possible fix 
would be to add a matcher `hasFormalName` which would match the name as per the 
specification, and then modify the `hasName` matcher to use the name for 
diagnostic purposes (without the extra location information).

Not hard-coding the logic in `getNodeName` would have the additional benefit of 
being more consistent with the use of `anonymous`/`unnamed` terminology.


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

https://reviews.llvm.org/D87540

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


[PATCH] D86958: [Docs] Add/update release notes for D71913 (LTO WPD changes)

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Please go ahead and commit to the branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86958

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


[PATCH] D87527: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

2020-09-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 291901.
baloghadamsoftware added a comment.

Created another matcher `hasAnyBody`, and updated the documentation of the 
matchers.


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

https://reviews.llvm.org/D87527

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1454,10 +1454,49 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+}
+
+TEST(HasBody, FindsBodyOfFunctions) {
   EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
   EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
-  EXPECT_TRUE(matches("void f(); void f() {}",
-  functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 1)));
+}
+
+TEST(HasAnyBody, FindsAnyBodyOfFunctions) {
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();",
+ functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasAnyBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasAnyBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasAnyBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasAnyBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 2)));
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1835,18 +1835,18 @@
   DynTypedNode Node;
 };
 
+template  struct GetBodyMatcher {
+  static const Stmt *get(const Ty &Node) { return Node.getBody(); }
+};
+
 template 
-struct GetBodyMatcher {
+struct GetBodyMatcher::value>::type> {
   static const Stmt *get(const Ty &Node) {
-return Node.getBody();
+return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
   }
 };
 
-template <>
-inline const Stmt *GetBodyMatcher::get(const FunctionDecl &Node) {
-  return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
-}
-
 template 
 struct HasSizeMatcher {
   static bool hasSize(const Ty &Node, unsigned int N) {
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4769,7 +4769,9 @@
 }
 
 /// Matches a 'for', 'while', 'do while' statement or a function
-/// definition that has a given body.
+/// definition that has a given body. Note that in case of functions
+/// this matcher only matches the definition itself and not the other
+/// declarations of the same function.
 ///
 /// Given
 /// \code
@@ -4779,6 +4781,18 @@
 ///   matches 'for (;;) {}'
 /// with compoundStmt()
 ///   matching '{}'
+///
+/// Given
+/// \code
+///   void f();
+///   void f() {}
+/// \endcode
+/// hasBody(functionDecl())
+///   matches 'void f() {}'
+/// with compoundStmt()
+///   matching '{}'
+///   but does not match 'void f();'
+
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
@@ -4790,6 +4804,30 @@
   InnerM

[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-09-15 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86097

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


[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

2020-09-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/Integrations.rst:5
 
 .. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins

nit: update to the official website http://clangd.llvm.org/



Comment at: clang-tools-extra/docs/clang-tidy/Integrations.rst:22
 
+--++-+--+-+--+
+|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
++--++-+--+-+--+

hmm, I know the purpose, but the table is sorted by the name, I think we should 
not change it.

btw `.clang-tidy` is supported now, we can change `-` to `+`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87686

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


[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-15 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 291909.
usaxena95 added a comment.

Fixed namespace ending.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/for-review-only/CompletionModel.cpp
  clang-tools-extra/clangd/for-review-only/CompletionModel.h
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.cpp
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.h
  clang-tools-extra/clangd/quality/CompletionModel.cmake
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/quality/README.md
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
  clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
  clang-tools-extra/clangd/unittests/model/features.json
  clang-tools-extra/clangd/unittests/model/forest.json

Index: clang-tools-extra/clangd/unittests/model/forest.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/forest.json
@@ -0,0 +1,52 @@
+[
+{
+"operation": "if_greater",
+"feature": "ANumber",
+"threshold": 200.0,
+"then": {
+"operation": "if_greater",
+"feature": "AFloat",
+"threshold": -1,
+"then": {
+"operation": "boost",
+"score": 10.0
+},
+"else": {
+"operation": "boost",
+"score": -20.0
+}
+},
+"else": {
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"C"
+],
+"then": {
+"operation": "boost",
+"score": 3.0
+},
+"else": {
+"operation": "boost",
+"score": -4.0
+}
+}
+},
+{
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"B"
+],
+"then": {
+"operation": "boost",
+"score": 5.0
+},
+"else": {
+"operation": "boost",
+"score": -6.0
+}
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/model/features.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/features.json
@@ -0,0 +1,16 @@
+[
+{
+"name": "ANumber",
+"type": "NUMBER"
+},
+{
+"name": "AFloat",
+"type": "NUMBER"
+},
+{
+"name": "ACategorical",
+"type": "ENUM",
+"enum": "ns1::ns2::TestEnum",
+"header": "model/CategoricalFeature.h"
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/model/CategoricalFeature.h
@@ -0,0 +1,5 @@
+namespace ns1 {
+namespace ns2 {
+enum TestEnum { A, B, C, D };
+} // namespace ns2
+} // namespace ns1
Index: clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
@@ -0,0 +1,29 @@
+#include "DecisionForestRuntimeTest.h"
+#include "model/CategoricalFeature.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+TEST(DecisionForestRuntime, Evaluate) {
+  using Example = ::ns1::ns2::test::Example;
+  using Cat = ::ns1::ns2::TestEnum;
+  using ::ns1::ns2::test::Evaluate;
+
+  Example E;
+  E.setANumber(200); // True
+  E.setAFloat(0);// True: +10.0
+  E.setACategorical(Cat::A); // True: +5.0
+  EXPECT_EQ(Evaluate(E), 15.0);
+
+  E.setANumber(200); // True
+  E.setAFloat(-2.5); // False: -20.0
+  E.setACategorical(Cat::B); // True: +5.0
+  EXPECT_EQ(Evaluate(E), -15.0);
+
+  E.setANumber(100); // False
+  E.setACategorical(Cat::C); // True: +3.0, False: -6.0
+  EXPECT_EQ(Evaluate(E), -3.0);
+}
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -10,6 +10,7 @@
 #include "ClangdServer.h"
 #include "CodeComplete.h"
 #include "Compiler.h"
+#include "CompletionModel.h"
 #include "Matchers.h"
 #include "Protocol.h"

[PATCH] D87240: [analyzer][StdLibraryFunctionsChecker] Have proper weak dependencies

2020-09-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:352
   HelpText<"Improve modeling of the C standard library functions">,
-  Dependencies<[CallAndMessageModeling]>,
   CheckerOptions<[

Umm, we should not have removed this. The checker always asserts that the 
arguments are initialized and that is checked by the dependency.

This is causing an assertion in D87081. Unfortunately, we hadn't have any tests 
to catch this, but now we have one, exactly in D87081. So I am putting back 
this dependency there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87240

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


[PATCH] D87081: [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

2020-09-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

There is a blatant regression we introduced in D87240 
. Actually, the test added here could have 
catched that regression.
See https://reviews.llvm.org/D87240#inline-812062
I am putting back the modeling dependency with this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87081

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


[clang] a012bc4 - [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

2020-09-15 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-09-15T16:35:39+02:00
New Revision: a012bc4c42e4408a18e4c4d67306b79c576df961

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

LOG: [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and 
fwrite

Add the BufferSize argument constraint to fread and fwrite. This change
itself makes it possible to discover a security critical case, described
in SEI-CERT ARR38-C.

We also add the not-null constraint on the 3rd arguments.

In this patch, I also remove those lambdas that don't take any
parameters (Fwrite, Fread, Getc), thus making the code better
structured.

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

Added: 
clang/test/Analysis/std-c-library-functions-vs-stream-checker.c

Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator.h
clang/test/Analysis/analyzer-enabled-checkers.c
clang/test/Analysis/std-c-library-functions-arg-constraints.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index a61af45231348..cbc048ba74c42 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -349,6 +349,9 @@ let ParentPackage = APIModeling in {
 
 def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
   HelpText<"Improve modeling of the C standard library functions">,
+  // Uninitialized value check is a mandatory dependency. This Checker asserts
+  // that arguments are always initialized.
+  Dependencies<[CallAndMessageModeling]>,
   CheckerOptions<[
 CmdLineOption FilePtrRestrictTy = getRestrictTy(FilePtrTy);
 
   // Templates for summaries that are reused by many functions.
-  auto Getc = [&]() {
-return Summary(ArgTypes{FilePtrTy}, RetType{IntTy}, NoEvalCall)
-.Case({ReturnValueCondition(WithinRange,
-{{EOFv, EOFv}, {0, UCharRangeMax}})});
-  };
   auto Read = [&](RetType R, RangeInt Max) {
 return Summary(ArgTypes{Irrelevant, Irrelevant, SizeTy}, RetType{R},
NoEvalCall)
 .Case({ReturnValueCondition(LessThanOrEq, ArgNo(2)),
ReturnValueCondition(WithinRange, Range(-1, Max))});
   };
-  auto Fread = [&]() {
-return Summary(
-   ArgTypes{VoidPtrRestrictTy, SizeTy, SizeTy, FilePtrRestrictTy},
-   RetType{SizeTy}, NoEvalCall)
-.Case({
-ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-})
-.ArgConstraint(NotNull(ArgNo(0)));
-  };
-  auto Fwrite = [&]() {
-return Summary(ArgTypes{ConstVoidPtrRestrictTy, SizeTy, SizeTy,
-FilePtrRestrictTy},
-   RetType{SizeTy}, NoEvalCall)
-.Case({
-ReturnValueCondition(LessThanOrEq, ArgNo(2)),
-})
-.ArgConstraint(NotNull(ArgNo(0)));
-  };
   auto Getline = [&](RetType R, RangeInt Max) {
 return Summary(ArgTypes{Irrelevant, Irrelevant, Irrelevant}, RetType{R},
NoEvalCall)
@@ -1283,19 +1260,45 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
  0U, WithinRange, {{EOFv, EOFv}, {0, 
UCharRangeMax}})));
 
   // The getc() family of functions that returns either a char or an EOF.
-addToFunctionSummaryMap("getc", Getc());
-addToFunctionSummaryMap("fgetc", Getc());
+  addToFunctionSummaryMap(
+  {"getc", "fgetc"}, Signature(ArgTypes{FilePtrTy}, RetType{IntTy}),
+  Summary(NoEvalCall)
+  .Case({ReturnValueCondition(WithinRange,
+  {{EOFv, EOFv}, {0, UCharRangeMax}})}));
   addToFunctionSummaryMap(
   "getchar", Summary(ArgTypes{}, RetType{IntTy}, NoEvalCall)
  .Case({ReturnValueCondition(
  WithinRange, {{EOFv, EOFv}, {0, UCharRangeMax}})}));
 
   // read()-like functions that never return more than buffer size.
-addToFunctionSummaryMap("fread", Fread());
-addToFunctionSummaryMap("fwrite", Fwrite());
+  auto FreadSummary =
+  Summary(NoEvalCall)
+  .Case({
+  ReturnValueCondition(LessThanOrEq, ArgNo(2)),
+  })
+  .ArgConstraint(NotNull(ArgNo(0)))
+  .ArgConstraint(NotNull(ArgNo(3)))
+  .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(0), /*BufSize=*/ArgNo(1),
+/*BufSizeMultiplier=*/ArgNo(2)));
+
+  // size_t fread(void *restrict ptr, size_t size, size_t nitems,
+  //  FILE *restrict stream);
+  addToFunctionSummaryMap(
+  "fread",
+  Signature(ArgTypes{VoidPtrRestrictTy, SizeTy, 

[PATCH] D87081: [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

2020-09-15 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa012bc4c42e4: [analyzer][StdLibraryFunctionsChecker] 
Elaborate the summary of fread and fwrite (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D87081?vs=291606&id=291919#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87081

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-vs-stream-checker.c

Index: clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
@@ -0,0 +1,58 @@
+// Check the case when only the StreamChecker is enabled.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core,alpha.unix.Stream \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify=stream
+
+// Check the case when only the StdLibraryFunctionsChecker is enabled.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify=stdLib 2>&1 | FileCheck %s
+
+// Check the case when both the StreamChecker and the
+// StdLibraryFunctionsChecker are enabled.
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core,alpha.unix.Stream \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple x86_64-unknown-linux \
+// RUN:   -verify=both 2>&1 | FileCheck %s
+
+// Verify that the summaries are loaded when the StdLibraryFunctionsChecker is
+// enabled.
+//  CHECK: Loaded summary for: int getchar()
+// CHECK-NEXT: Loaded summary for: unsigned long fread(void *restrict, size_t, size_t, FILE *restrict)
+// CHECK-NEXT: Loaded summary for: unsigned long fwrite(const void *restrict, size_t, size_t, FILE *restrict)
+
+#include "Inputs/system-header-simulator.h"
+
+void clang_analyzer_eval(int);
+
+void test_fread_fwrite(FILE *fp, int *buf) {
+  fp = fopen("foo", "r");
+  if (!fp)
+return;
+  size_t x = fwrite(buf, sizeof(int), 10, fp);
+
+  clang_analyzer_eval(x <= 10); // \
+ // stream-warning{{TRUE}} \
+ // stdLib-warning{{TRUE}} \
+ // both-warning{{TRUE}} \
+
+  clang_analyzer_eval(x == 10); // \
+  // stream-warning{{TRUE}} \
+  // stream-warning{{FALSE}} \
+  // stdLib-warning{{UNKNOWN}} \
+  // both-warning{{TRUE}} \
+  // both-warning{{FALSE}}
+
+  fclose(fp);
+}
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -194,6 +194,22 @@
 // bugpath-warning{{Function argument constraint is not satisfied}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 }
+typedef __WCHAR_TYPE__ wchar_t;
+// This is one test case for the ARR38-C SEI-CERT rule.
+void ARR38_C_F(FILE *file) {
+  enum { BUFFER_SIZE = 1024 };
+  wchar_t wbuf[BUFFER_SIZE]; // bugpath-note{{'wbuf' initialized here}}
+
+  const size_t size = sizeof(*wbuf);
+  const size_t nitems = sizeof(wbuf);
+
+  // The 3rd parameter should be the number of elements to read, not
+  // the size in bytes.
+  fread(wbuf, size, nitems, file); // \
+  // report-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
 
 int __two_constrained_args(int, int);
 void test_constraints_on_multiple_args(int x, int y) {
Index: clang/test/Analysis/analyzer-enabled-checkers.c
===
--- clang/test/Analysis/analyzer-enabled-checkers.c
+++ clang/test/Analysis/analyzer-enabled-checkers.c
@@ -6,11 +6,11 @@
 
 // CHECK:  OVERVIEW: Clang Static Analyzer Enabled Checkers List
 // CHECK-EMPTY:
+// CHECK-NEXT: core.CallAndMessageModeling
 // CHECK-NEXT: apiModeling.StdCLibraryFunctions
 // CHECK-NEXT: apiModeling.TrustNonnull
 // CHECK-NEXT: apiModeling.llvm.CastValue
 // CHECK-NEXT: apiMo

[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-09-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:684
 const OffloadDeviceGlobalVarEntryInfoActTy &Action);
-
   private:

Restore original formatting



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:2482-2487
+FieldDecl *addFieldToRecordDecl(ASTContext &C, DeclContext *DC,
+QualType FieldTy);
+
+template 
+llvm::GlobalVariable *createGlobalStruct(CodeGenModule &CGM, QualType Ty,
+ bool IsConstant,

Better to encapsulate these functions into a new utility class and make them 
public static.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:498
   /// far.
+
   class OffloadEntriesInfoManagerTy {

ABataev wrote:
> Remove unnecessary formatting changes. 
Still not removed



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h:30-63
+  /// Curret nesting level of parallel region
+  int ParallelLevel = 0;
+
+  /// Maximum nesting level of parallel region
+  int MaxParallelLevel = 0;
+
+  /// Struct to store kernel descriptors

Do you really need to expose all these new members as public?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h:31
+  /// Curret nesting level of parallel region
+  int ParallelLevel = 0;
+

Runtime does not support nested parallelism on GPU. Do you really need it?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h:98
+
+  /// AMDGCN specific PrePostActionTy implementation
+  class AMDGCNPrePostActionTy final : public PrePostActionTy {

It does not help to understand the functionality



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1957
+  auto &RT = static_cast(CGM.getOpenMPRuntime());
+  PrePostActionTy *Action = RT.getPrePostActionTy();
+  CodeGen.setAction(*Action);

It leads to a mem leak.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:37
+  /// Linkage type of StaticRD Global variable
+  llvm::GlobalValue::LinkageTypes StaticRDLinkage;
+

1. Make it private or protected
2.Add default initializer



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:217-249
+  /// Allocate global variable for TransferMedium
+  virtual llvm::GlobalVariable *
+  allocateTransferMediumGlobal(CodeGenModule &CGM, llvm::ArrayType *Ty,
+   StringRef TransferMediumName) = 0;
+
+  /// Allocate global variable for SharedStaticRD
+  virtual llvm::GlobalVariable *

Are all these required to be public?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:415-417
+  /// true if we're definitely in the parallel region.
+  bool IsInParallelRegion = false;
+

Make it private or protected


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86097

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


[PATCH] D87652: Sema: add support for `__attribute__((__swift_newtype__))`

2020-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2179
+def SwiftNewType : InheritableAttr {
+  let Spellings = [GNU<"swift_newtype">, GNU<"swift_wrapper">];
+  let Args = [EnumArgument<"NewtypeKind", "NewtypeKind",

We don't ever document `swift_wrapper`, is that intentional?

(Do you have code elsewhere that's looking at the spelling of the AST attribute 
object? Should you add an `AdditionalMembers` to this declaration to make that 
easier to distinguish?)



Comment at: clang/include/clang/Basic/Attr.td:2183
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+  let Documentation = [SwiftNewTypeDocs];
+}

You should also set: `let HasCustomParsing = 1;` since this uses a custom 
parser.

Is the custom parser actually needed though? Or is it only needed because the 
enum names selected are keywords? If it's only because of the keyword nature, 
should the parser be improved in `Parser::ParseAttributeArgsCommon()` instead?



Comment at: clang/include/clang/Basic/AttrDocs.td:3585
+ypedef.
+  }];
+}

Code examples of how to use this properly would be appreciated.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4038
+def warn_swift_newtype_attribute_non_typedef
+  : Warning<"%0 attribute may be put on a typedef only; attribute is ignored">,
+InGroup>;

Hrm, we already have existing diagnostics to cover this 
(`warn_attribute_wrong_decl_type_str`) but it's in the `IgnoredAttributes` 
group. Do you need a new warning group specific to this? Is there a reason that 
group is not a subset of `IgnoredAttributes`?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5894
+  // Make sure that there is an identifier as the annotation's single argument.
+  if (!checkAttributeNumArgs(S, AL, 1)) {
+AL.setInvalid();

Btw, if you fix up the parser, then you can skip setting `HasCustomParsing` and 
then can remove some of this manual error checking as well.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5895
+  if (!checkAttributeNumArgs(S, AL, 1)) {
+AL.setInvalid();
+return;

No need to do this (I'm surprised it even compiles given that `AL` is a `const` 
reference), here or elsewhere.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5905
+
+  IdentifierInfo *II = AL.getArgAsIdent(0)->Ident;
+  SwiftNewTypeAttr::NewtypeKind Kind;

There should be a helper method to do this dance for you. 
`SwiftNewTypeAttr::ConvertStrToNewtypeKind()` should be roughly what it's 
called (it's generated for you by the attr emitter).



Comment at: clang/test/SemaObjC/attr-swift-newtype.m:2
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: not %clang_cc1 -ast-dump %s | FileCheck %s
+

Can you split the AST bits out into their own test in the AST directory?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87652

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


[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

2020-09-15 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:233-234
 
+svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // 
expected-error-re {{returning 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' 
values) from a function with incompatible result type 'svint64_t' (aka 
'__SVInt64_t')}}
+gnu_int32_t from_svint64_t__to_gnu_int32_t(svint64_t x) { return x; } // 
expected-error-re {{returning 'svint64_t' (aka '__SVInt64_t') from a function 
with incompatible result type 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' 
values)}}
+

c-rhodes wrote:
> I expected similar diagnostics when casting between GNU and fixed-length SVE 
> vectors where the element type doesn't match but the vector size is equal but 
> that wasn't the case. Since no functional changes were necessary to support 
> casting between these types I tried the following:
> ```#include 
> 
> #define N 128
> 
> typedef float float32_t;
> typedef double float64_t;
> 
> typedef float32_t gnu_float32_t __attribute__((vector_size(N/8)));
> typedef float64_t gnu_float64_t __attribute__((vector_size(N/8)));
> 
> gnu_float32_t foo(gnu_float64_t x) { return (gnu_float32_t)x; }
> gnu_float64_t bar(gnu_float32_t x) { return (gnu_float64_t)x; }```
> 
> It seems Clang considers this implicit cast valid whereas GCC doesn't, even 
> with lax vector conversions enabled.
I pasted the wrong example, the explicit cast shouldn't be there:
```#include 

#define N 128

typedef float float32_t;
typedef double float64_t;

typedef float32_t gnu_float32_t __attribute__((vector_size(N/8)));
typedef float64_t gnu_float64_t __attribute__((vector_size(N/8)));

gnu_float32_t foo(gnu_float64_t x) { return x; }
gnu_float64_t bar(gnu_float32_t x) { return x; }```


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

https://reviews.llvm.org/D87607

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


[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

Looks good to me overall, some minor style comments included ;-)

Do we expect this to be a generic model code generator that gets reused for 
other things? If not, maybe we can hardcode more (like the namespace, class 
name, etc), but if you think there's other use cases for this then this LGTM.




Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:39
+'''Returns the header guard for the generated header.'''
+return "GENERATED_DECISION_FOREST_MODEL_{}_H".format(filename.upper())
+

Why GENERATED_DECISON_FOREST_MODEL instead of output_dir, to be consistent with 
header guards for other files? Doesn't matter much for generated code, but if 
someone opens this in vim they'll see warnings.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:57
+Control falls through if condition is evaluated to false."""
+return "{label}: if(E.{feature} >= {encoded} /*{threshold}*/) goto 
{true_label};".format(
+label=label,

nit: add space after if for readability (also below)



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:93
+def tree(t, tree_num: int, node_num: int):
+"""Returns code for inferencing a Decision Tree.
+

Please extend the comment to mention the second return value (size of the tree)



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:105
+"""
+label = "t{tree}_n{node}".format(tree=tree_num, node=node_num)
+code = []

This is a good place to use an Python's f-string.

Also in few places below.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:126
+
+return code + false_code + true_code, 1 + false_size+true_size
+

style nit: be consistent with spaces around +



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:177
+
+code += "  friend float Evaluate(const {}&);\n".format(cpp_class.name)
+code += "};\n"

Is there a reason to make this a friend free-function instead of static method 
on the Example class? The problem is that you now end up with 
clang::clangd::Evaluate, so if we every re-use this code gen for another model 
we'll have a name collision.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:271
+parser = argparse.ArgumentParser('DecisionForestCodegen')
+parser.add_argument('--filename', help='output file name.')
+parser.add_argument('--output_dir', help='output directory')

nit: be consistent about putting a "." at the end of the help text or not.



Comment at: clang-tools-extra/clangd/unittests/model/CategoricalFeature.h:1
+namespace ns1 {
+namespace ns2 {

Can we rename this directory? quality/model makes some sense (although it would 
be better to include something about code completion there), but 
unittests/model is not very descriptive - what model?

How about unittests/decision_forest_model/ or something like that? Or go with 
the Input/TEST_NAME pattern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814

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


[PATCH] D81930: [AArch64] Add -mmark-bti-property flag.

2020-09-15 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 291922.

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

https://reviews.llvm.org/D81930

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm64-markbti.S
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h

Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
===
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
@@ -33,6 +33,9 @@
   /// Emit contents of constant pool for the current section.
   void emitCurrentConstantPool();
 
+  /// Callback used to implement the .note.gnu.property section.
+  void emitNoteSection(unsigned Flags);
+
   /// Callback used to implement the .inst directive.
   virtual void emitInst(uint32_t Inst);
 
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
===
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
@@ -11,12 +11,23 @@
 //===--===//
 
 #include "AArch64TargetStreamer.h"
+#include "AArch64MCAsmInfo.h"
+#include "AArch64Subtarget.h"
+#include "llvm/BinaryFormat/ELF.h"
 #include "llvm/MC/ConstantPools.h"
+#include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/CommandLine.h"
 
 using namespace llvm;
 
+static cl::opt MarkBTIProperty(
+"aarch64-mark-bti-property", cl::Hidden,
+cl::desc("Add .note.gnu.property with BTI to assembly files"),
+cl::init(false));
+
 //
 // AArch64TargetStreamer Implemenation
 //
@@ -37,8 +48,50 @@
   ConstantPools->emitForCurrentSection(Streamer);
 }
 
-// finish() - write out any non-empty assembler constant pools.
-void AArch64TargetStreamer::finish() { ConstantPools->emitAll(Streamer); }
+// finish() - write out any non-empty assembler constant pools and
+//   write out note.gnu.properties if need.
+void AArch64TargetStreamer::finish() {
+  ConstantPools->emitAll(Streamer);
+
+  if (MarkBTIProperty)
+emitNoteSection(ELF::GNU_PROPERTY_AARCH64_FEATURE_1_BTI);
+}
+
+void AArch64TargetStreamer::emitNoteSection(unsigned Flags) {
+  if (Flags == 0)
+return;
+
+  MCStreamer &OutStreamer = getStreamer();
+  MCContext &Context = OutStreamer.getContext();
+  // Emit a .note.gnu.property section with the flags.
+  MCSectionELF *Nt = Context.getELFSection(".note.gnu.property", ELF::SHT_NOTE,
+   ELF::SHF_ALLOC);
+  if (Nt->isRegistered()) {
+SMLoc Loc;
+Context.reportWarning(
+Loc,
+"The .note.gnu.property is not emitted because it is already present.");
+return;
+  }
+  MCSection *Cur = OutStreamer.getCurrentSectionOnly();
+  OutStreamer.SwitchSection(Nt);
+
+  // Emit the note header.
+  OutStreamer.emitValueToAlignment(Align(8).value());
+  OutStreamer.emitIntValue(4, 4); // data size for "GNU\0"
+  OutStreamer.emitIntValue(4 * 4, 4); // Elf_Prop size
+  OutStreamer.emitIntValue(ELF::NT_GNU_PROPERTY_TYPE_0, 4);
+  OutStreamer.emitBytes(StringRef("GNU", 4)); // note name
+
+  // Emit the PAC/BTI properties.
+  OutStreamer.emitIntValue(ELF::GNU_PROPERTY_AARCH64_FEATURE_1_AND, 4);
+  OutStreamer.emitIntValue(4, 4); // data size
+  OutStreamer.emitIntValue(Flags, 4); // data
+  OutStreamer.emitIntValue(0, 4); // pad
+
+  OutStreamer.endSection(Nt);
+  OutStreamer.SwitchSection(Cur);
+}
 
 void AArch64TargetStreamer::emitInst(uint32_t Inst) {
   char Buffer[4];
Index: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
===
--- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -223,26 +223,9 @@
 return;
 
   // Emit a .note.gnu.property section with the flags.
-  MCSection *Cur = OutStreamer->getCurrentSectionOnly();
-  MCSection *Nt = MMI->getContext().getELFSection(
-  ".note.gnu.property", ELF::SHT_NOTE, ELF::SHF_ALLOC);
-  OutStreamer->SwitchSection(Nt);
-
-  // Emit the note header.
-  emitAlignment(Align(8));
-  OutStreamer->emitInt32(4); // data size for "GNU\0"
-  OutStreamer->emitInt32(4 * 4); // Elf_Prop size
-  OutStreamer->emitInt32(ELF::NT_GNU_PROPERTY_TYPE_0);
-  OutStreamer->emitBytes(StringRef("GNU", 4)); // note name
-
-  // Emit the PAC/BTI properties.
-  OutStreamer->emitInt32(ELF::GNU_PROPERTY_AARCH64_FEATURE_1_AND);
-  OutStreamer->emitInt32(4); // data size
-  OutStreamer->emitInt32(Flags); // data
-  OutStreamer->emitInt32(0); // pad
-
-  OutStreamer->endSection(Nt);
-  OutStreamer->Switch

[PATCH] D81930: [AArch64] Add -mmark-bti-property flag.

2020-09-15 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss marked 4 inline comments as done.
danielkiss added a comment.

@nickdesaulniers Thanks for the review, comments are addressed.


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

https://reviews.llvm.org/D81930

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


[PATCH] D86533: (Urgent!) [release][docs][analyzer] Add 11.0.0. release notes

2020-09-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Sorry for the slack (which is kind of ironic with my attention grabbing title 
:) ). Landed in rG791b7e9f73e0064153a7c3db8045a7333a8c390c 
. Thanks 
everyone!


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

https://reviews.llvm.org/D86533

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


[PATCH] D86533: (Urgent!) [release][docs][analyzer] Add 11.0.0. release notes

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

No worries :) Thanks for the notes!


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

https://reviews.llvm.org/D86533

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


[clang] 7c6f5b7 - [analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock

2020-09-15 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2020-09-15T16:55:44+02:00
New Revision: 7c6f5b7fbf5a9eee7f3ef9192c354d1536a8f1c6

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

LOG: [analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/docs/analyzer/user-docs/CrossTranslationUnit.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 7a294f916bcf..9fb6782cf5a5 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1491,6 +1491,23 @@ Warn about assigning non-{0,1} values to boolean 
variables.
 alpha.core
 ^^
 
+.. _alpha-core-C11Lock:
+
+alpha.core.C11Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of ``mtx_t`` mutexes.
+
+.. code-block:: cpp
+
+ mtx_t mtx1;
+
+ void bad1(void)
+ {
+   mtx_lock(&mtx1);
+   mtx_lock(&mtx1); // warn: This lock has already been acquired
+ }
+
 .. _alpha-core-CallAndMessageUnInitRefArg:
 
 alpha.core.CallAndMessageUnInitRefArg (C,C++, ObjC)
@@ -1868,6 +1885,26 @@ Check for dereference of null smart pointers.
*P; // warn: dereference of a default constructed smart unique_ptr
  }
 
+alpha.fuchsia
+^
+
+.. _alpha-fuchsia-lock:
+
+alpha.fuchsia.Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of fuchsia mutexes.
+
+.. code-block:: cpp
+
+ spin_lock_t mtx1;
+
+ void bad1(void)
+ {
+   spin_lock(&mtx1);
+   spin_lock(&mtx1);   // warn: This lock has already been acquired
+ }
+
 alpha.llvm
 ^^
 

diff  --git a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst 
b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
index 36be82f209ef..0606185f39e6 100644
--- a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -201,6 +201,8 @@ Example usage of scan-build-py:
   ^C
   $
 
+.. _ctu-on-demand:
+
 On-demand analysis
 __
 The analysis produces the necessary AST structure of external TUs during 
analysis. This requires the



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


[PATCH] D86532: (Urgent!) [docs][analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock

2020-09-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c6f5b7fbf5a: [analyzer] Add documentation for 
alpha.fuchsia.Lock and alpha.core.C11Lock (authored by Szelethus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86532

Files:
  clang/docs/analyzer/checkers.rst
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst


Index: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
===
--- clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -201,6 +201,8 @@
   ^C
   $
 
+.. _ctu-on-demand:
+
 On-demand analysis
 __
 The analysis produces the necessary AST structure of external TUs during 
analysis. This requires the
Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1491,6 +1491,23 @@
 alpha.core
 ^^
 
+.. _alpha-core-C11Lock:
+
+alpha.core.C11Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of ``mtx_t`` mutexes.
+
+.. code-block:: cpp
+
+ mtx_t mtx1;
+
+ void bad1(void)
+ {
+   mtx_lock(&mtx1);
+   mtx_lock(&mtx1); // warn: This lock has already been acquired
+ }
+
 .. _alpha-core-CallAndMessageUnInitRefArg:
 
 alpha.core.CallAndMessageUnInitRefArg (C,C++, ObjC)
@@ -1868,6 +1885,26 @@
*P; // warn: dereference of a default constructed smart unique_ptr
  }
 
+alpha.fuchsia
+^
+
+.. _alpha-fuchsia-lock:
+
+alpha.fuchsia.Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of fuchsia mutexes.
+
+.. code-block:: cpp
+
+ spin_lock_t mtx1;
+
+ void bad1(void)
+ {
+   spin_lock(&mtx1);
+   spin_lock(&mtx1);   // warn: This lock has already been acquired
+ }
+
 alpha.llvm
 ^^
 


Index: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
===
--- clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -201,6 +201,8 @@
   ^C
   $
 
+.. _ctu-on-demand:
+
 On-demand analysis
 __
 The analysis produces the necessary AST structure of external TUs during analysis. This requires the
Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1491,6 +1491,23 @@
 alpha.core
 ^^
 
+.. _alpha-core-C11Lock:
+
+alpha.core.C11Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of ``mtx_t`` mutexes.
+
+.. code-block:: cpp
+
+ mtx_t mtx1;
+
+ void bad1(void)
+ {
+   mtx_lock(&mtx1);
+   mtx_lock(&mtx1); // warn: This lock has already been acquired
+ }
+
 .. _alpha-core-CallAndMessageUnInitRefArg:
 
 alpha.core.CallAndMessageUnInitRefArg (C,C++, ObjC)
@@ -1868,6 +1885,26 @@
*P; // warn: dereference of a default constructed smart unique_ptr
  }
 
+alpha.fuchsia
+^
+
+.. _alpha-fuchsia-lock:
+
+alpha.fuchsia.Lock
+""
+Similarly to :ref:`alpha.unix.PthreadLock `, checks for
+the locking/unlocking of fuchsia mutexes.
+
+.. code-block:: cpp
+
+ spin_lock_t mtx1;
+
+ void bad1(void)
+ {
+   spin_lock(&mtx1);
+   spin_lock(&mtx1);	// warn: This lock has already been acquired
+ }
+
 alpha.llvm
 ^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77882: [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This seems to have caused https://bugs.llvm.org/show_bug.cgi?id=47512

Can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77882

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


[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

2020-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a subscriber: rsmith.
aaron.ballman added a comment.

In D84362#2271585 , @tra wrote:

> So, the idea here is to do some sort of duck-typing and allow DiagBuilder to 
> work with both `DiagnosticBuilder` and `PartialDiagnostic`.
>
> What bothers me is that unlike `Diagnostic` `PartialDiagnostic` seems to be 
> commingling functionality of the builder with that of the diagnostic itself. 
> I'm not sure if that's by design or just happened to be that way.
>
> I think a better approach would be to refactor `PartialDiagnostic` and 
> separate the builder functionality. That should make it possible to create a 
> common diagnostic builder base class with Partial/Full diagnostic deriving 
> their own builder, if needed.
>
> That said, I'm not that familiar with the diags. Perhaps  @rtrieu 
> @aaron.ballman would have better ideas.

I'm similarly a bit uncomfortable with adding the SFINAE magic to make this 
work instead of making a base class that will work for either kind of 
diagnostic builder. I'm adding @rsmith to see if he has opinions as well.


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

https://reviews.llvm.org/D84362

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


[PATCH] D76599: Represent FP options in AST by special Statement node

2020-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff abandoned this revision.
sepavloff added a comment.

FPOptions is now stored in AST objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76599

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


[PATCH] D77545: Represent FP options in AST by special Expression node

2020-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff abandoned this revision.
sepavloff added a comment.

FPOptions is now stored in AST objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77545

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


[PATCH] D87587: [clang-format][PR47290] Make one-line namespaces resistant to FixNamespaceComments, update documentation

2020-09-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Firstly let me say thank you for the patch, and taking the time to listen to 
the reviewers. Please don't be discouraged by my reply/opinon.

> a) adding a new option means increasing our maintenance cost by possibly 
> adding a rarely-used switch (which I also dislike)

I always here people complaining about this...but what is the cost to ALL the 
users that see breaking changes every release across all the projects that use 
clang-format. Its potentially massive. I'm not sure the cost is that high for 
us.

> b) it's been a part of clang-format documentation since release 5 so we could 
> make clang-format work as expected

Either the documentation isn't being read/understood/misinterpreted, or perhaps 
the person who wrote this wanted it like this, to not namespace comment small 
namespaces. Again who can tell, but in my view the precedent has been set for 6 
releases and I'd be uncomfortable about changing it now without a get out 
clause if we were wrong,

if your view was correct then having an option and setting the default to the 
new value so people could set it back is a far better solution because it 
doesn't create an impasse for those that don't like your opinion of what is 
correct? but I think hundreds of projects will complain they have to change the 
default. (as many as complain they have to set it in the first place 
potentially)

> c) this patch doesn't have to be applied to already released versions and 
> could be merged with a new major release. I think people can expect certain 
> things to work differently while changing major versions.

If its not good enough for trunk its not good enough for the next release in my 
view, there is never a good time to land something that causes a lot of flux. 
remember people massively lag the release number and often jump many version 
numbers, by which time going back and changing a default will be far too late.

> I think people can expect certain things to work differently while changing 
> major versions.

I think certain people expect things to work differently, others, easily an 
equal number expect it to just work as is, and don't want subjective changes.

> d) in general, people care about preserving their git history and they 
> normally don't format all their code blindly. I think the most frequent use 
> case it to format only adjacent parts of code.

We should not make assumptions about what others care about.. IMHO this is not 
true, I work in an organization where any file that is committed MUST conform 
fully to clang-format resulting in failed phabricator builds (by design), every 
time we update clang-format we have to makes some alterations for bug fixes. 
But this change would likely cause a change in almost every file and the impact 
and cost would be massive to us alone let alone every project that might use it.

This is also what happens inside LLVM (in some sub-projects) where checking for 
clang-format status is actually part of what will be done via the build_bots. 
As soon as you check this in, you'll break LLVM, you need to be prepared for 
that!

I don't want to discourage you, and my opinion is as subjective as yours. But 
I'm afraid I won't be able to hit the accept button with the review in this 
form.

Feel free to reach out to other reviewers, mine is not the only opinion.

Ultimately thank you for the patch  I think the idea behind it is a good 
change, I'd personally just want to give people the option, I see this as no 
different to the people who wanted Small Functions/If/Else blocks formatted 
differently if they were considered "Small"

Many thanks @MyDeveloperDay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87587

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


[PATCH] D87701: Do not apply calling conventions to MSVC entry points

2020-09-15 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: rnk, erichkeane.
eandrews requested review of this revision.

Fix link error for MSVC entry points when calling conventions are specified. 
MSVC entry points should have default calling convention.


https://reviews.llvm.org/D87701

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/default_calling_conv.cpp


Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | 
FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
-
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s -DMAIN | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s 
-DMAIN | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWMAIN | FileCheck %s  
--check-prefix=WMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWINMAIN | FileCheck %s  
--check-prefix=WINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWWINMAIN | FileCheck %s  
--check-prefix=WWINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DDLLMAIN | FileCheck %s  
--check-prefix=DLLMAIN
+//
 // CDECL: define void @_Z5test1v
 // FASTCALL: define x86_fastcallcc void @_Z5test1v
 // STDCALL: define x86_stdcallcc void @_Z5test1v
@@ -46,7 +50,37 @@
   a.test_member();
 }
 
+#ifdef MAIN
 // ALL: define i32 @main
 int main() {
   return 1;
 }
+#endif // main
+
+#ifdef WMAIN
+// WMAIN: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+#endif // wmain
+
+#ifdef WINMAIN
+// WINMAIN: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+#endif // WinMain
+
+#ifdef WWINMAIN
+// WWINMAIN: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+#endif // wWinMain
+
+#ifdef DLLMAIN
+// DLLMAIN: define dso_local i32 @DllMain
+int DllMain() {
+  return 1;
+}
+#endif // DllMain
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11095,6 +11095,11 @@
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  if (FT->getCallConv() != CC_C) {
+FT = Context.adjustFunctionType(FT, 
FT->getExtInfo().withCallingConv(CC_C));
+FD->setType(QualType(FT, 0));
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();


Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
-// RUN: %clang_cc1 -tr

[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-15 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D86694#2273815 , @aganea wrote:

> If 4.4 TB of virtual pages are mapped in each process (this happens on 
> startup), then we quickly exaust the 48-bit (256 TB) addressable space with 
> 72+ programs running (on a 36-core). Any idea where this 4.4 TB mapping comes 
> from?

The size of the Primary is defined in 
https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/scudo/scudo_platform.h#L75
Scudo reserves that size but doesn't commit it, then it incrementally commits 
when memory is needed within the reserved region.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D77882: [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`

2020-09-15 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In D77882#2274292 , @hans wrote:

> This seems to have caused https://bugs.llvm.org/show_bug.cgi?id=47512
>
> Can you take a look?

Are you sure? This has been fixed from august in trunk 
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py#L87


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77882

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


[PATCH] D87702: [Frontend] Add pragma align natural and sort out pragma pack stack effect

2020-09-15 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, hubert.reinterpretcast, efriedma, 
jyknight, rnk, rsmith, aaron.ballman.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
Xiangling_L requested review of this revision.

1. Implementing the natural align for AIX
2. Sort out pragma pack stack effect
3. Add -faix-pragma-stack option to enable AIX pragma stack effect


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87702

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Driver/aix-pragma-pack.c
  clang/test/Layout/aix-power-natural-interaction.cpp
  clang/test/Sema/aix-pragma-pack-and-align.c

Index: clang/test/Sema/aix-pragma-pack-and-align.c
===
--- /dev/null
+++ clang/test/Sema/aix-pragma-pack-and-align.c
@@ -0,0 +1,212 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -faix-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -faix-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+#pragma align(natural)
+#pragma pack(4)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma pack()
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}}
+#pragma pack(pop)
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}}
+struct B {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+#pragma align(natural)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma align(reset)
+
+struct B {
+  int i;
+  double d;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+
+} // namespace test2
+
+namespace test3 {
+#pragma pack(2)
+#pragma align(natural)
+struct A {
+  double d;
+};
+#pragma align(reset)
+#pragma pack(pop)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test3::A
+// CHECK-NEXT:  0 |   double d
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=8, nvalign=4, preferrednvalign=8]
+
+} // namespace test3
+
+namespace test4 {
+#pragma pack(2)
+#pragma align(natural)
+#pragma pack(pop)
+
+struct A {
+  int i;
+  double d;
+} a;
+#pragma align(reset)
+#pragma pack(pop)
+
+int i = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test4::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test4
+
+namespace test5 {
+#pragma align(power)
+#pragma align(natural)
+#pragma pack(2)
+#pragma align(reset)
+struct A {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test5::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4

[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-15 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7216
   "aligned %select{allocation|deallocation}0 function of type '%1' is only "
   "available on %2 %3 or newer">;
+def err_aligned_allocation_unavailable_on_os : Error<

ahatanak wrote:
> Is it possible to merge these two diagnostics?
> 
> 
> ```
> "aligned %select{allocation|deallocation}0 function of type '%1' is 
> %select{only|not}4 "
> "available on %2 %select{%3 or newer|}4"
> ```
> 
Thanks for reviewing Akira! This merged format does look better, I'll make the 
change.


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

https://reviews.llvm.org/D87611

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-15 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 291949.
fanbo-meng added a comment.

merge diagnostics


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

https://reviews.llvm.org/D87611

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,12 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DZOS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DZOS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -62,40 +65,40 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-28 {{aligned de

[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-09-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd1d5488e47d: [analyzer][Liveness][NFC] Get rid of statement 
liveness, because such a thing… (authored by Szelethus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598

Files:
  clang/docs/analyzer/developer-docs/DebugChecks.rst
  clang/include/clang/Analysis/Analyses/LiveVariables.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/Analysis/LiveVariables.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/lib/StaticAnalyzer/Core/Environment.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/live-stmts.cpp
  clang/test/Analysis/live-stmts.mm

Index: clang/test/Analysis/live-stmts.mm
===
--- clang/test/Analysis/live-stmts.mm
+++ clang/test/Analysis/live-stmts.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -w -fblocks %s \
-// RUN:   -analyzer-checker=debug.DumpLiveStmts \
+// RUN:   -analyzer-checker=debug.DumpLiveExprs \
 // RUN:   2>&1 | FileCheck %s
 
 @interface Item
@@ -18,25 +18,25 @@
 public:
   RAII(Blk blk): blk(blk) {}
 
-// CHECK: [ B0 (live statements at block exit) ]
+// CHECK: [ B0 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-NEXT: [ B1 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B2 (live statements at block exit) ]
+// CHECK-NEXT: [ B2 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
 
   ~RAII() { blk(); }
 
-// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-NEXT: [ B0 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-NEXT: [ B1 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B2 (live statements at block exit) ]
+// CHECK-NEXT: [ B2 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
 };
@@ -45,57 +45,37 @@
   RAII raii(^{});
   for (Item *item in coll) {}
 }
-// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-NEXT: [ B0 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-NEXT: [ B1 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B2 (live statements at block exit) ]
-// CHECK-EMPTY:
-// CHECK-NEXT: DeclStmt {{.*}}
-// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-NEXT: [ B2 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
 // CHECK-EMPTY:
-// CHECK-NEXT: CompoundStmt {{.*}}
-// CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B3 (live statements at block exit) ]
-// CHECK-EMPTY:
-// CHECK-NEXT: DeclStmt {{.*}}
-// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-NEXT: [ B3 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
 // CHECK-EMPTY:
-// CHECK-NEXT: CompoundStmt {{.*}}
-// CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B4 (live statements at block exit) ]
-// CHECK-EMPTY:
-// CHECK-NEXT: DeclStmt {{.*}}
-// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
+// CHECK-NEXT: [ B4 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' 
 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
 // CHECK-EMPTY:
-// CHECK-NEXT: CompoundStmt {{.*}}
-// CHECK-EMPTY:
-// CHECK-EMPTY:
-// CHECK-NEXT: [ B5 (live statements at block exit) ]
-// CHECK-EMPTY:
-// CHECK-NEXT: DeclStmt {{.*}}
-// CHECK-NEXT: `-VarDecl {{.*}}  item 'Item *'
 // CHECK-EMPTY:
-// CHECK-NEXT: CompoundStmt {{.*}}
+// CHECK-NEXT: [ B5 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B0 (live statements at block exit) ]
+// CHECK-NEXT: [ B0 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
-// CHECK-NEXT: [ B1 (live statements at block exit) ]
+// CHECK-NEXT: [ B1 (live expressions at block exit) ]
 // CHECK-EMPTY:
 // CHECK-EMPTY:
 
Index: clang/test/Analysis/live-stmts.cpp
===
--- clang/test/Analysis/live-stmts.cpp
+++ clang/test/Analysis/live-stmts.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveStmts %s 2>&1\
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
 // RUN:   | FileCheck %s
 
 int coin();
@@ -7,13 +7,24 @@
 int testThatDumperWorks(in

[PATCH] D87702: [Frontend] Add pragma align natural and sort out pragma pack stack effect

2020-09-15 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 291950.
Xiangling_L added a comment.

Removed redundant header file include;


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

https://reviews.llvm.org/D87702

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Driver/aix-pragma-pack.c
  clang/test/Layout/aix-power-natural-interaction.cpp
  clang/test/Sema/aix-pragma-pack-and-align.c

Index: clang/test/Sema/aix-pragma-pack-and-align.c
===
--- /dev/null
+++ clang/test/Sema/aix-pragma-pack-and-align.c
@@ -0,0 +1,212 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -faix-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -faix-pragma-pack -verify -fsyntax-only -x c++ %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+#pragma align(natural)
+#pragma pack(4)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma pack()
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}}
+#pragma pack(pop)
+#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}}
+struct B {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test1::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+#pragma align(natural)
+#pragma pack(2)
+struct A {
+  int i;
+  double d;
+};
+
+int a = sizeof(A);
+#pragma align(reset)
+
+struct B {
+  int i;
+  double d;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=2, preferredalign=2,
+// CHECK-NEXT:|  nvsize=12, nvalign=2, preferrednvalign=2]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test2::B
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+
+} // namespace test2
+
+namespace test3 {
+#pragma pack(2)
+#pragma align(natural)
+struct A {
+  double d;
+};
+#pragma align(reset)
+#pragma pack(pop)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test3::A
+// CHECK-NEXT:  0 |   double d
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=8, nvalign=4, preferrednvalign=8]
+
+} // namespace test3
+
+namespace test4 {
+#pragma pack(2)
+#pragma align(natural)
+#pragma pack(pop)
+
+struct A {
+  int i;
+  double d;
+} a;
+#pragma align(reset)
+#pragma pack(pop)
+
+int i = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test4::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  8 |   double d
+// CHECK-NEXT:| [sizeof=16, dsize=16, align=4, preferredalign=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=4, preferrednvalign=8]
+
+} // namespace test4
+
+namespace test5 {
+#pragma align(power)
+#pragma align(natural)
+#pragma pack(2)
+#pragma align(reset)
+struct A {
+  int i;
+  double d;
+};
+#pragma align(reset)
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct test5::A
+// CHECK-NEXT:  0 |   int i
+// CHECK-NEXT:  4 |   double d
+// CHECK-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+
+} // namespace test5
+
+namespace test6 {
+#pragma align(natural)
+#pragma pack(0)// expected-error {{expected #pragma pack parameter to be '1', '2'

[clang] dd1d548 - [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-09-15 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2020-09-15T17:43:02+02:00
New Revision: dd1d5488e47d0a89217dfd22a726c3d3ad2b4984

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

LOG: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a 
thing doesn't exist

The summary and very short discussion in D82122 summarizes whats happening here.

In short, liveness talks about variables, or expressions, anything that
has a value. Well, statements just simply don't have a one.

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

Added: 


Modified: 
clang/docs/analyzer/developer-docs/DebugChecks.rst
clang/include/clang/Analysis/Analyses/LiveVariables.h
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
clang/lib/Analysis/LiveVariables.cpp
clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
clang/test/Analysis/live-stmts.cpp
clang/test/Analysis/live-stmts.mm

Removed: 




diff  --git a/clang/docs/analyzer/developer-docs/DebugChecks.rst 
b/clang/docs/analyzer/developer-docs/DebugChecks.rst
index 48b584a46307..45985a1dfd79 100644
--- a/clang/docs/analyzer/developer-docs/DebugChecks.rst
+++ b/clang/docs/analyzer/developer-docs/DebugChecks.rst
@@ -30,7 +30,7 @@ using a 'dot' format viewer (such as Graphviz on macOS) 
instead.
 - debug.DumpLiveVars: Show the results of live variable analysis for each
   top-level function being analyzed.
 
-- debug.DumpLiveStmts: Show the results of live statement analysis for each
+- debug.DumpLiveExprs: Show the results of live expression analysis for each
   top-level function being analyzed.
 
 - debug.ViewExplodedGraph: Show the Exploded Graphs generated for the

diff  --git a/clang/include/clang/Analysis/Analyses/LiveVariables.h 
b/clang/include/clang/Analysis/Analyses/LiveVariables.h
index 2e7dd5d81678..8a3dd0c35e64 100644
--- a/clang/include/clang/Analysis/Analyses/LiveVariables.h
+++ b/clang/include/clang/Analysis/Analyses/LiveVariables.h
@@ -30,22 +30,22 @@ class LiveVariables : public ManagedAnalysis {
   class LivenessValues {
   public:
 
-llvm::ImmutableSet liveStmts;
+llvm::ImmutableSet liveExprs;
 llvm::ImmutableSet liveDecls;
 llvm::ImmutableSet liveBindings;
 
 bool equals(const LivenessValues &V) const;
 
 LivenessValues()
-  : liveStmts(nullptr), liveDecls(nullptr), liveBindings(nullptr) {}
+  : liveExprs(nullptr), liveDecls(nullptr), liveBindings(nullptr) {}
 
-LivenessValues(llvm::ImmutableSet LiveStmts,
+LivenessValues(llvm::ImmutableSet liveExprs,
llvm::ImmutableSet LiveDecls,
llvm::ImmutableSet LiveBindings)
-: liveStmts(LiveStmts), liveDecls(LiveDecls),
+: liveExprs(liveExprs), liveDecls(LiveDecls),
   liveBindings(LiveBindings) {}
 
-bool isLive(const Stmt *S) const;
+bool isLive(const Expr *E) const;
 bool isLive(const VarDecl *D) const;
 
 friend class LiveVariables;
@@ -83,17 +83,17 @@ class LiveVariables : public ManagedAnalysis {
   ///  only returns liveness information for block-level expressions.
   bool isLive(const Stmt *S, const VarDecl *D);
 
-  /// Returns true the block-level expression "value" is live
+  /// Returns true the block-level expression value is live
   ///  before the given block-level expression (see runOnAllBlocks).
-  bool isLive(const Stmt *Loc, const Stmt *StmtVal);
+  bool isLive(const Stmt *Loc, const Expr *Val);
 
   /// Print to stderr the variable liveness information associated with
   /// each basic block.
   void dumpBlockLiveness(const SourceManager &M);
 
-  /// Print to stderr the statement liveness information associated with
+  /// Print to stderr the expression liveness information associated with
   /// each basic block.
-  void dumpStmtLiveness(const SourceManager &M);
+  void dumpExprLiveness(const SourceManager &M);
 
   void runOnAllBlocks(Observer &obs);
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index cbc048ba74c4..3540fe5fe55c 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1478,8 +1478,8 @@ def LiveVariablesDumper : Checker<"DumpLiveVars">,
   HelpText<"Print results of live variable analysis">,
   Documentation;
 
-def LiveStatementsDumper : Checker<"DumpLiveStmts">,
-  HelpText<"Print results of live statement analysis">,
+def LiveExpressionsDumper : Checker<"DumpLiveExprs">,
+  HelpText<"Print results of live expression analysis">,
   Documentation;
 
 def CFGViewer : Checker<"Vie

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

2020-09-15 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

Here is a reduced-ish repro, I can keep poking at it but maybe this is 
sufficient for you to notice something: https://godbolt.org/z/endf6d.

Center pane is old DSE, right pane is new DSE. I highlighted the problem area 
with a nop at line 56 of the source, and line 59 of each disassembly. The array 
writes following the nop have been eliminated, even though they will be needed 
on a future iteration of the for loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D86958: [Docs] Add/update release notes for D71913 (LTO WPD changes)

2020-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D86958#2274040 , @hans wrote:

> Please go ahead and commit to the branch.

Sorry, I thought I already did! Just pushed the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86958

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-15 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D86694#2273815 , @aganea wrote:

> @russell.gallop I see a lots of failing tests when running `ninja check-all` 
> on a Scudo-enabled build (stage 2). Do you see the same thing on your end?

Not a lot but a few, including DynamicLibrary.Shutdown:

  Failed Tests (4):
LLVM-Unit :: 
Support/DynamicLibrary/./DynamicLibraryTests.exe/DynamicLibrary.Shutdown
LLVM :: ExecutionEngine/MCJIT/multi-module-sm-pic-a.ll
LLVM :: ExecutionEngine/OrcMCJIT/multi-module-sm-pic-a.ll
LLVM :: ExecutionEngine/OrcMCJIT/stubs-sm-pic.ll

And the MCJIT ones seem intermittent (different ones fail each time).

> If 4.4 TB of virtual pages are mapped in each process (this happens on 
> startup), then we quickly exhaust the 48-bit (256 TB) addressable space with 
> 72+ programs running (on a 36-core). Any idea where this 4.4 TB mapping comes 
> from?

I guess that's just a problem with a larger number of cores then.

I'm going to concentrate on the standalone port as I think that's the way 
forward. If I get that working then can work through the other issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-15 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D86694#2274383 , @cryptoad wrote:

> In D86694#2273815 , @aganea wrote:
>
>> If 4.4 TB of virtual pages are mapped in each process (this happens on 
>> startup), then we quickly exaust the 48-bit (256 TB) addressable space with 
>> 72+ programs running (on a 36-core). Any idea where this 4.4 TB mapping 
>> comes from?
>
> The size of the Primary is defined in 
> https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/scudo/scudo_platform.h#L75
> Scudo reserves that size but doesn't commit it, then it incrementally commits 
> when memory is needed within the reserved region.

I guess using scudo as a general purpose allocator that could set a limit on 
the number of cores that can be used at once as @aganea found. Would there be 
any problem with making this very small (e.g. a couple of GB)?

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


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

2020-09-15 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

Reduced a bit more: https://godbolt.org/z/j59evK (C++) and 
https://godbolt.org/z/8xG688 (IR) -- the store at line 43 of `while.end` has 
been removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked

2020-09-15 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D83004#2250897 , @jdoerfert wrote:

> reverse ping?

Heh.  Getting back to this now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83004

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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-09-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I am not sure if this checker is worth to further development. A part of the 
found bugs can be detected with other checkers too, specially if the 
preconditions of many standard functions are checked (more than what is done 
now) and by modeling the function calls with assumed error return value. Some 
return codes does not cause invalid preconditions but then it is often enough 
to have any check for the returned value, or the problem can be found by the 
taint checker (this can be improved).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

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


[PATCH] D79432: [analyzer] StdLibraryFunctionsChecker: Add summaries for libc

2020-09-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1123-1124
+  "abs", Summary(ArgTypes{IntTy}, RetType{IntTy}, EvalCallAsPure)
+ .Case({ArgumentCondition(0, WithinRange, SingleValue(0)),
+ReturnValueCondition(WithinRange, SingleValue(0))})
+ .Case({ArgumentCondition(0, WithinRange, Range(1, IntMax)),

martong wrote:
> NoQ wrote:
> > NoQ wrote:
> > > The three-way state split is unjustified here. Usage of `abs` is not a 
> > > sufficient indication that the value may be 0, otherwise:
> > > ```lang=c++
> > > int foo(int x, int y) {
> > >   int z = abs(y);   // Assuming 'abs' has taken branch on which y == 0...
> > >   return x / z; // ... we'll be forced to emit a division by zero 
> > > warning here.
> > > }
> > > ```
> > > 
> > > Generally, there are very few cases when state splits upon function calls 
> > > are justified. The common cases are:
> > > - The function returns bool and finding that bool is the only reason to 
> > > ever call this function. Eg., `isalpha()` and such.
> > > - The function can at any time completely unpredictably take any of the 
> > > branches, in other words, taint is involved. Eg., `scanf()` can always 
> > > fail simply because the user of the program wrote something special into 
> > > stdin.
> > > returns bool
> > 
> > Or something that kinda resembles bool (eg., `isalpha()` returns a variety 
> > of different ints in practice due to its static lookup table implementation 
> > strategy but the user only cares about whether it's zero or non-zero).
> Alright, I agree, I'll remove these cases. 
> 
> Generally speaking I realized that it is hard to create these cases, and it 
> is very rare when we can come up with a meaningful case set for any function. 
> So while we are at it, could you please take a look at another patch, where I 
> add no cases just argument constraints: D82288 ?
But it could make sense that if the input of the function is known before the 
call, we can compute the output? For `abs(x)` if we know that `x == 0` is true 
the checker could assume `abs(x) == 0` too. These "cases" provide data for this 
functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79432

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-15 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Please fix the test case first, can't call `operator new(unsigned long, void*)` 
with an argument of type `void*`
The other failures the pre merge bot detected can safely be disregarded


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

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


[PATCH] D77882: [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`

2020-09-15 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

Has been pushed to the 11.x branch 
https://github.com/llvm/llvm-project/commit/1596c2dfd548b21cf33ad3353882ac465d78c1bb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77882

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


[PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked

2020-09-15 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D83004#2168427 , @jdoerfert wrote:

> Due to D82995  I realized we should have a 
> test of this in `llvm/test/tools/UpdateTestChecks` as well.

Do you mean a test for recognizing the option in `common.py`?  I'm not sure 
what you're asking for here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83004

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


[PATCH] D86562: [OPENMP][NFC]Release notes for OpenMP in clang (11.x).

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D86562#2274039 , @ABataev wrote:

> In D86562#2274036 , @hans wrote:
>
>> Please go ahead and commit.
>
> Hi Hans, can you commit it yourself? I have some technical issues and not 
> able to commit it. And I don't know when it is going to be resolved. :(

Sure! 4b23932e230dd48a7bfc6fadb461d0ef81aeba94 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86562

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


[PATCH] D86562: [OPENMP][NFC]Release notes for OpenMP in clang (11.x).

2020-09-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D86562#2274595 , @hans wrote:

> In D86562#2274039 , @ABataev wrote:
>
>> In D86562#2274036 , @hans wrote:
>>
>>> Please go ahead and commit.
>>
>> Hi Hans, can you commit it yourself? I have some technical issues and not 
>> able to commit it. And I don't know when it is going to be resolved. :(
>
> Sure! 4b23932e230dd48a7bfc6fadb461d0ef81aeba94 
> 

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86562

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


[PATCH] D87527: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

2020-09-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.

Thanks, this looks great!  But, can you also please update 
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp#L39,
 since it depends on the current semantics?


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

https://reviews.llvm.org/D87527

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


[PATCH] D87532: Sema: add support for `__attribute__((__swift_bridge__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2133
 
+def SwiftBridge : Attr {
+  let Spellings = [GNU<"swift_bridge">];

aaron.ballman wrote:
> Is this a type or a declaration attribute? It looks like a declaration 
> attribute based on the declaration and the list of subjects, but it looks 
> like a type based on the `ExpectedType` diagnostic and the documentation. Or 
> is this one of those unholy GNU attributes that's confused about what it 
> appertains to?
> 
> Should this be inherited by redeclarations? Might be worth adding a test:
> ```
> struct __attribute__((swift_bridge)) S;
> 
> struct S { // Should still have the attribute
>   int i;
> };
> ```
It is a declaration attribute, and yes, it should be inheritable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87532

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D87683#2274569 , @njames93 wrote:

> Please fix the test case first, can't call `operator new(unsigned long, 
> void*)` with an argument of type `void*`
> The other failures the pre merge bot detected can safely be disregarded

Placement new is defined per standard:

  void* operator new  ( std::size_t count, void* ptr );

Here, the problem is that `size_t` is `unsigned long` on //Linux// and it seems 
that it is `unsigned long long` on //Windows//. How should I overcome this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

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


[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.



>> I think it would be safer to do the change purely as an optimization in 
>> codegen (maybe we could add a new helper method that could also be used by 
>> the warning).
>
> For "optimization in codegen", do you mean optimization after the IR is 
> generated or like I did in `CodeGenFunction::EmitCXXTypeidExpr`?

I mean like you did in `CodeGenFunction::EmitCXXTypeidExpr`.




Comment at: clang/include/clang/AST/ExprCXX.h:843
 
+  bool isMostDerived(ASTContext &Context) const;
+

A comment would be good here.



Comment at: clang/lib/AST/ExprCXX.cpp:151
+  if (isTypeOperand())
+return false;
+

I suppose it depends on what you want the semantics of this function to be, but 
returning false here seems odd.. wouldn't true make as much sense?
If this function is not intended to be called for type operands, maybe assert 
about that instead?



Comment at: clang/lib/AST/ExprCXX.cpp:154
+  const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();

I think checking for DeclRefExpr isn't guaranteed to handle all cases, like 

```
typeid(*&obj)
``` 

for example. That's okay, but it should be clear from the function comment (and 
maybe the name) that this is a best-effort check, not a strong guarantee about 
whether the expression refers to a most derived object.



Comment at: clang/test/SemaCXX/constant-expression-cxx2a.cpp:312
   // expected-note@+1 {{typeid applied to object 'extern_b2' whose dynamic 
type is not constant}}
-  static_assert(&typeid(extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
+  static_assert(&typeid(*&extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
 

This appears to be changing semantics. It could be that this test is 
unnecessary strict (that's my understanding), but usually these checks are 
based on examples in the standard, or the current understanding of the 
standard. I think it would be best to check with Richard before changing this.

Actually, I'm surprised this affected since you're only updating CodeGen, not 
Sema. Is the static_assert really invoking Codegen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

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


[PATCH] D86958: [Docs] Add/update release notes for D71913 (LTO WPD changes)

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I see it now. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86958

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


[PATCH] D77882: [clang-tidy] Add option to use alpha checkers from clang-analyzer when using `run-clang-tidy.py`

2020-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D77882#2274570 , @Abpostelnicu 
wrote:

> Has been pushed to the 11.x branch 
> https://github.com/llvm/llvm-project/commit/1596c2dfd548b21cf33ad3353882ac465d78c1bb

Great, that was the missing piece :) Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77882

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


  1   2   3   >