[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-09 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, sbc100.
Herald added projects: clang, LLVM.
nullptr.cpp requested review of this revision.
Herald added a subscriber: aheejin.

Fix by explicitly expressing the conversions that caused by comparison.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87347

Files:
  clang/lib/Lex/Pragma.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,7 +2037,8 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * 
TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
+assert(LSBIndex <=
+   static_cast(std::numeric_limits::max()) &&
"Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,10 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > static_cast(
+std::numeric_limits().max())
+   ? wasm::WASM_OPCODE_I64_CONST
+   : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -417,7 +417,7 @@
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
   assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+ static_cast(std::numeric_limits::max()) &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1356,7 +1356,7 @@
 while (Tok.is(tok::numeric_constant)) {
   uint64_t Value;
   if (!PP.parseSimpleIntegerLiteral(Tok, Value) || Value == 0 ||
-  Value > std::numeric_limits::max()) {
+  Value > static_cast(std::numeric_limits::max())) {
 PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
 return;
   }


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,7 +2037,8 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
+assert(LSBIndex <=
+   static_cast(std::numeric_limits::max()) &&
"Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,10 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > static_cast(
+std::numeric_limits().max())
+   ? wasm::WASM_OPCODE_I64_CONST
+   : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -417,7 +417,7 @@
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
   assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=

[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-09-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: rsmith.
Herald added a project: clang.
hokein requested review of this revision.

Context: https://reviews.llvm.org/D86048#2254607


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87349

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/test/CodeGenCXX/mangle-exprs.cpp
  clang/test/CodeGenCXX/mangle.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp
  clang/test/SemaTemplate/dependent-expr.cpp

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -129,7 +129,7 @@
   template void f() {
 decltype(({})) x; // expected-error {{incomplete type}}
   }
-  template void f(); // expected-note {{instantiation of}}
+  template void f();
 
   template auto g() {
 auto c = [](auto, int) -> decltype(({})) {};
Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -12,11 +12,12 @@
 template 
 using Alias = decltype(Foo(T())); // expected-error {{no matching function for call to 'Foo'}}
 template 
-struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}}
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}} \
+  expected-error {{base specifier must name a class}}
   Crash2(){};
 };
 
-void test2() { Crash2(); } // expected-note {{in instantiation of template class 'Crash2' requested here}}
+void test2() { Crash2(); } // expected-note2 {{in instantiation of template class 'Crash2' requested here}}
 
 template 
 class Base {};
Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -802,7 +802,7 @@
   template
   void f(decltype(sizeof(decltype(T() + T() {}
 
-  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvm
   template void f(decltype(sizeof(1)));
 
   // Mangling for non-instantiation-dependent sizeof expressions.
@@ -839,7 +839,7 @@
   template
   void f1(decltype(sizeof(&T::template operator+))) {}
 
-  // CHECK-LABEL: define weak_odr void @_ZN6test352f1INS_1AEEEvDTszadsrT_onplIiEE
+  // CHECK-LABEL: define weak_odr void @_ZN6test352f1INS_1AEEEvm
   template void f1(__SIZE_TYPE__);
 }
 
@@ -1116,14 +1116,14 @@
 namespace test56 {
   struct A { A *operator->(); int n; } a;
   template void f(decltype(a->n + N)) {}
-  // CHECK-LABEL: @_ZN6test561fILi0EEEvDTplptL_ZNS_1aEE1nT_E
+  // CHECK-LABEL: @_ZN6test561fILi0EEEvi
   template void f<0>(int);
 }
 
 namespace test57 {
   struct X { template  int f(); } x;
   template void f(decltype(x.f<0>() + N)) {}
-  // CHECK-LABEL: @_ZN6test571fILi0EEEvDTplcldtL_ZNS_1xEE1fIXLi0T_E
+  // CHECK-LABEL: @_ZN6test571fILi0EEEvi
   template void f<0>(int);
 }
 
Index: clang/test/CodeGenCXX/mangle-exprs.cpp
===
--- clang/test/CodeGenCXX/mangle-exprs.cpp
+++ clang/test/CodeGenCXX/mangle-exprs.cpp
@@ -215,7 +215,7 @@
 namespace test5 {
   template  void a(decltype(noexcept(T( {}
   template void a(decltype(noexcept(int(;
-  // CHECK: void @_ZN5test51aIiEEvDTnxcvT__EE(
+  // CHECK: void @_ZN5test51aIiEEvb
 }
 
 namespace test6 {
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3422,18 +3422,17 @@
 }
 
 DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
-// C++11 [temp.type]p2: "If an expression e involves a template parameter,
-// decltype(e) denotes a unique dependent type." Hence a decltype type is
-// type-dependent even if its expression is only instantiation-dependent.
+// C++17 [temp.type]p2: "If an expression e is type-dependent, decltype(e)
+// denotes a unique dependent type."
 : Type(Decltype, can,
toTypeDependence(E->getDependence()) |
-   (E->isInstantiationDependent() ? TypeDependence::Dependent
-  : TypeDependence::None) |
+   (E->isTypeDependent() ? TypeDependence::Dependent
+ : TypeDependence::None) |
(E->getType()->getDependence() &
 TypeDependence::VariablyModified)),
   E(E), UnderlyingType(underlyingType) {}
 
-bool DecltypeType::isSugared() const { return !E->isInstantiationDependent(); }
+bool DecltypeType::isSugared() const { return !E->isTypeDepe

[PATCH] D87350: [AST][RecoveryExpr] Fix a crash on undeduced type.

2020-09-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein requested review of this revision.

We should not capture the type if the function return type is undeduced.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87350

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -105,3 +105,9 @@
 int v = arr(); // expected-error {{array types cannot be value-initialized}} \
   expected-error {{cannot initialize a variable of type 'int' 
with an rvalue of type 'test8::arr'}}
 }
+
+namespace test9 {
+auto f(); // expected-note {{candidate function not viable}}
+// verify no crash on evaluating the size of undeduced auto type.
+static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for 
call to 'f'}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12853,7 +12853,7 @@
 if (Candidate.Function->isInvalidDecl())
   return;
 QualType T = Candidate.Function->getReturnType();
-if (T.isNull())
+if (T.isNull() || T->isUndeducedType())
   return;
 if (!Result)
   Result = T;


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -105,3 +105,9 @@
 int v = arr(); // expected-error {{array types cannot be value-initialized}} \
   expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
 }
+
+namespace test9 {
+auto f(); // expected-note {{candidate function not viable}}
+// verify no crash on evaluating the size of undeduced auto type.
+static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for call to 'f'}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12853,7 +12853,7 @@
 if (Candidate.Function->isInvalidDecl())
   return;
 QualType T = Candidate.Function->getReturnType();
-if (T.isNull())
+if (T.isNull() || T->isUndeducedType())
   return;
 if (!Result)
   Result = T;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c0e5e3f - [Ignore Expressions] Fix performance regression by inlining `Ignore*SingleStep`

2020-09-09 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-09-09T07:32:40Z
New Revision: c0e5e3fbfa504c3792023d0db9008b08caa6b6d7

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

LOG: [Ignore Expressions] Fix performance regression by inlining 
`Ignore*SingleStep`

We also add a `const` versions of `IgnoreExprNodes`

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

Added: 


Modified: 
clang/include/clang/AST/IgnoreExpr.h
clang/lib/AST/CMakeLists.txt

Removed: 
clang/lib/AST/IgnoreExpr.cpp



diff  --git a/clang/include/clang/AST/IgnoreExpr.h 
b/clang/include/clang/AST/IgnoreExpr.h
index 0aeb547606a2..1c2b538e5b63 100644
--- a/clang/include/clang/AST/IgnoreExpr.h
+++ b/clang/include/clang/AST/IgnoreExpr.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_AST_IGNOREEXPR_H
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 
 namespace clang {
 namespace detail {
@@ -38,23 +39,122 @@ template  Expr *IgnoreExprNodes(Expr 
*E, FnTys &&... Fns) {
   return E;
 }
 
-Expr *IgnoreImplicitCastsSingleStep(Expr *E);
+template 
+const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) {
+  return const_cast(IgnoreExprNodes(E, std::forward(Fns)...));
+}
+
+inline Expr *IgnoreImplicitCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+inline Expr *IgnoreImplicitCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+inline Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+inline Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
 
-Expr *IgnoreImplicitCastsExtraSingleStep(Expr *E);
+  return IgnoreCastsSingleStep(E);
+}
+
+inline Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+inline Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+inline Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
 
-Expr *IgnoreCastsSingleStep(Expr *E);
+  return IgnoreImplicitSingleStep(E);
+}
 
-Expr *IgnoreLValueCastsSingleStep(Expr *E);
+inline Expr *IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
 
-Expr *IgnoreBaseCastsSingleStep(Expr *E);
+inline Expr *IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
 
-Expr *IgnoreImplicitSingleStep(Expr *E);
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
 
-Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E);
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
 
-Expr *IgnoreParensOnlySingleStep(Expr *E);
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
 
-Expr *IgnoreParensSingleStep(Expr *E);
+  return E;
+}
 
 } // namespace clang
 

diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index dfd26fd97bc6..35099fd0dacf 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -55,7 +55,6 @@ add_clang_library(clangAST
   ExternalASTMerger.cpp
   ExternalASTSource.cpp
   FormatString.cpp
-  IgnoreExpr.cpp
   InheritViz.cpp
   Interp/ByteCodeEmitter.cpp
   Interp/ByteCodeExprGen.cpp

diff  --git a/clang/lib/AST/IgnoreExpr.cpp b/clang/lib/AST/IgnoreExpr.cpp
deleted file mode 100644
index 65aaaeb6a1ed..
--- a/clang/lib/AST/IgnoreEx

[PATCH] D87278: [Ignore Expressions] Fix performance regression by inlining `Ignore*SingleStep`

2020-09-09 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc0e5e3fbfa50: [Ignore Expressions] Fix performance 
regression by inlining `Ignore*SingleStep` (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87278

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/IgnoreExpr.cpp

Index: clang/lib/AST/IgnoreExpr.cpp
===
--- clang/lib/AST/IgnoreExpr.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-//===--- IgnoreExpr.cpp - Ignore intermediate Expressions -===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file implements common functions to ignore intermediate expression nodes
-//
-//===--===//
-
-#include "clang/AST/IgnoreExpr.h"
-#include "clang/AST/Expr.h"
-#include "clang/AST/ExprCXX.h"
-
-using namespace clang;
-
-Expr *clang::IgnoreImplicitCastsSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  return E;
-}
-
-Expr *clang::IgnoreImplicitCastsExtraSingleStep(Expr *E) {
-  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
-  // addition to what IgnoreImpCasts() skips to account for the current
-  // behaviour of IgnoreParenImpCasts().
-  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->getSubExpr();
-
-  if (auto *NTTP = dyn_cast(E))
-return NTTP->getReplacement();
-
-  return E;
-}
-
-Expr *clang::IgnoreCastsSingleStep(Expr *E) {
-  if (auto *CE = dyn_cast(E))
-return CE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->getSubExpr();
-
-  if (auto *NTTP = dyn_cast(E))
-return NTTP->getReplacement();
-
-  return E;
-}
-
-Expr *clang::IgnoreLValueCastsSingleStep(Expr *E) {
-  // Skip what IgnoreCastsSingleStep skips, except that only
-  // lvalue-to-rvalue casts are skipped.
-  if (auto *CE = dyn_cast(E))
-if (CE->getCastKind() != CK_LValueToRValue)
-  return E;
-
-  return IgnoreCastsSingleStep(E);
-}
-
-Expr *clang::IgnoreBaseCastsSingleStep(Expr *E) {
-  if (auto *CE = dyn_cast(E))
-if (CE->getCastKind() == CK_DerivedToBase ||
-CE->getCastKind() == CK_UncheckedDerivedToBase ||
-CE->getCastKind() == CK_NoOp)
-  return CE->getSubExpr();
-
-  return E;
-}
-
-Expr *clang::IgnoreImplicitSingleStep(Expr *E) {
-  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->getSubExpr();
-
-  if (auto *BTE = dyn_cast(E))
-return BTE->getSubExpr();
-
-  return E;
-}
-
-Expr *clang::IgnoreImplicitAsWrittenSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExprAsWritten();
-
-  return IgnoreImplicitSingleStep(E);
-}
-
-Expr *clang::IgnoreParensOnlySingleStep(Expr *E) {
-  if (auto *PE = dyn_cast(E))
-return PE->getSubExpr();
-  return E;
-}
-
-Expr *clang::IgnoreParensSingleStep(Expr *E) {
-  if (auto *PE = dyn_cast(E))
-return PE->getSubExpr();
-
-  if (auto *UO = dyn_cast(E)) {
-if (UO->getOpcode() == UO_Extension)
-  return UO->getSubExpr();
-  }
-
-  else if (auto *GSE = dyn_cast(E)) {
-if (!GSE->isResultDependent())
-  return GSE->getResultExpr();
-  }
-
-  else if (auto *CE = dyn_cast(E)) {
-if (!CE->isConditionDependent())
-  return CE->getChosenSubExpr();
-  }
-
-  return E;
-}
Index: clang/lib/AST/CMakeLists.txt
===
--- clang/lib/AST/CMakeLists.txt
+++ clang/lib/AST/CMakeLists.txt
@@ -55,7 +55,6 @@
   ExternalASTMerger.cpp
   ExternalASTSource.cpp
   FormatString.cpp
-  IgnoreExpr.cpp
   InheritViz.cpp
   Interp/ByteCodeEmitter.cpp
   Interp/ByteCodeExprGen.cpp
Index: clang/include/clang/AST/IgnoreExpr.h
===
--- clang/include/clang/AST/IgnoreExpr.h
+++ clang/include/clang/AST/IgnoreExpr.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_AST_IGNOREEXPR_H
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 
 namespace clang {
 namespace detail {
@@ -38,23 +39,122 @@
   return E;
 }
 
-Expr *IgnoreImplicitCastsSingleStep(Expr *E);
+template 
+const Expr *IgnoreExprNodes(const Expr *E, FnTys &&...Fns) {
+  return const_cast(IgnoreExprNodes(E, std::forward(Fns)...));
+}
+
+inline Expr *IgnoreImplic

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

2020-09-09 Thread George Rimar via Phabricator via cfe-commits
grimar added inline comments.



Comment at: llvm/lib/Support/YAMLTraits.cpp:204
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  auto ReportNode = NN.second.get();
+  auto ReportMessage = Twine("unknown key '") + NN.first() + "'";

Please don't use `auto` when the variable type is not obvious.
Use the real type name instead.



Comment at: llvm/lib/Support/YAMLTraits.cpp:205
+  auto ReportNode = NN.second.get();
+  auto ReportMessage = Twine("unknown key '") + NN.first() + "'";
+  if (!AllowUnknownKeys) {

The same here, but also the result type here is `Twine`, and you shouldn't use 
it like this. Documentation says:
"A Twine is not intended for use directly and should not be stored, its 
implementation relies on the ability to store pointers to temporary stack 
objects which may be deallocated at the end of a statement. Twines should only 
be used accepted as const references in arguments, when an API wishes to accept 
possibly-concatenated strings."
(https://llvm.org/doxygen/classllvm_1_1Twine.html#details)

You can probably inline it or use `std::string`, since this is a error path 
only code.



Comment at: llvm/lib/Support/YAMLTraits.cpp:387
+
+void Input::reportWarning(Node *node, const Twine &message) {
+  Strm->printError(node, message, SourceMgr::DK_Warning);

Why do you need both `reportWarning` methods? I think you can have only one for 
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] D78938: Make LLVM build in C++20 mode

2020-09-09 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D78938#2261411 , @jfb wrote:

> On C++20 mode rotting: it won't if someone sets up a bot. If it rots, then 
> it's easier to un-rot with Barry's patch.

I assume this would be a private bot? It can't be a public bot, since LLVM 
isn't even on C++17, let alone C++20, and so it shouldn't be part of minimum 
requirements that somebody has a compiler that can build C++20. Whilst I 
personally am quite happy with moving LLVM forward, I develop on Windows 
primarily, so don't have the same need to support a long tail of old *nix 
versions etc.

@BRevzin, you should a) mention the u8/const char* issue in the description 
too, and also what compiler you used to build this with. I fully expect at this 
stage that there are some C++20 compilers that might have slightly different 
interpretations of things which this won't resolve, so knowing which one this 
is intended to work with could help with historical research.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

___
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-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 290658.
fhahn added a comment.

rebase on top of latest changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenObjC/exceptions.m
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/test/Analysis/BasicAA/modref.ll
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-03-25-DSEMiscompile.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-EndOfFunction.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-MemCpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2016-07-17-UseAfterFree.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreBegin.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreEnd.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore2.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/X86/gather-null-pointer.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-overlapping.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/calloc-store.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/const-pointers.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/crash.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/cs-cs-aliasing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/debug-counter.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/debuginfo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/dominate.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/fence-todo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/fence.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/free.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/inst-limits.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/int_sideeffect.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/invariant.start.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/launder.invariant.group.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/lifetime.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/mda-with-dbg-values.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memcpy-complete-overwrite.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memoryssa-scan-limit.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-and-memcpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-unknown-sizes.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores-big-endian.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-captures.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-exceptions.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-malloc-free.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memintrinsics.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
  
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath-throwing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-overlap.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-partial.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-throwing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-unreachable.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/no-targetdata.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/noop-stores.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/operand-bundles.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/pr11390.ll
  
llvm/test/Transforms/DeadStoreElimination/MSSA/pr47285-not-overwritten-on-all-exit-paths.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/simple-preservation.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/simple-todo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/s

[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-09 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

I don't have commit access, can anyone help commit this and D86997 
?
Yang Fan 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

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


[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-09-09 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I would like to discuss why don't we have a distinct checker managing the 
bookkeeping stuff of the CString lengths.
I just want a clean understanding and wide consensus about this.

Personally, I would still prefer the original version of this patch (//+nits of 
course//).




Comment at: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringChecker.cpp:32-34
+auto CStringChecker::createOutOfBoundErrorMsg(StringRef FunctionDescription,
+  AccessKind Access)
+-> ErrorMessage {

NoQ wrote:
> Why suddenly use arrow syntax here?
This way I could spare the full name of the class :D
I will use the qualified name instead.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringChecker.h:227
+#endif
\ No newline at end of file


NoQ wrote:
> No NeWlInE aT eNd Of FiLe
I'm wondering why did clang-format not add this - I'm really surprised. Thanks.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLengthModeling.cpp:309
+
+// TODO: Is it useful?
+void CStringChecker::printState(raw_ostream &Out, ProgramStateRef State,

NoQ wrote:
> Yes it is. It gets invoked during exploded graph dumps and it's an invaluable 
> debugging facility.
A strange observation to note here.
In the implementation of the dump method, I use the provided  `NL` and `Sep` 
parameters.
However, in the `checker_messages` of a State dump, `Sep` seem to be 
substituted with the empty string.
For example [[ 
https://github.com/llvm/llvm-project/blob/86e1b73507f3738f10eefb580d7c5e9adf17c6c0/clang/lib/StaticAnalyzer/Checkers/Taint.cpp#L37
 | taint::printTaint ]] just ignore the `Sep` parameter to //possibly// 
workaround this issue.


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

https://reviews.llvm.org/D84316

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


[PATCH] D84604: Thread safety analysis: Consider global variables in scope

2020-09-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I'm not sure this is the problematic patch, but i'm now seeing some weird 
warnings:

  :304:15: warning: acquiring mutex 'guard' requires negative 
capability '!guard' [-Wthread-safety-negative]
MutexLocker guard(&mutex);
^
  :309:15: warning: acquiring mutex 'guard' requires negative 
capability '!guard' [-Wthread-safety-negative]
MutexLocker guard(&mutex);
^
  :322:15: warning: acquiring mutex 'guard' requires negative 
capability '!guard' [-Wthread-safety-negative]
MutexLocker guard(&mutex);
^
  3 warnings generated.

https://godbolt.org/z/5zYT55

If this is the patch that causes it, then i think it's an obvious 
false-positive (wasn't this patch supposed to only handle globals?),
if not, the warning's wording is not great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84604

___
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-09 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui created this revision.
YangZhihui added a reviewer: MyDeveloperDay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
YangZhihui requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87352

Files:
  clang/docs/ClangFormatStyleOptions.rst


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2246,7 +2246,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2246,7 +2246,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 
___
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-09 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui added a comment.

I don't have commit access.
Please help me commit it.
Thanks : )


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] D80197: [DebugInfo] Upgrade DISubrange to support Fortran dynamic arrays

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

Alok, Adrian: please work on addressing the concerns raised in 
https://bugs.llvm.org/show_bug.cgi?id=47287, or please revert this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80197

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


[clang] 8427885 - Temporairly revert "Thread safety analysis: Consider global variables in scope" & followup

2020-09-09 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-09-09T12:15:56+03:00
New Revision: 8427885e27813c457dccb011f65e8ded7e31

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

LOG: Temporairly revert "Thread safety analysis: Consider global variables in 
scope" & followup

This appears to cause false-positives because it started to warn on local 
non-global variables.

Repro posted to https://reviews.llvm.org/D84604#2262745

This reverts commit 9dcc82f34ea9b623d82d2577b93aaf67d36dabd2.
This reverts commit b2ce79ef66157dd752e3864ece57915e23a73f5d.

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp
clang/test/SemaCXX/warn-thread-safety-negative.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 5b97265a6d8a..64e0da9e64b1 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1266,21 +1266,13 @@ ClassifyDiagnostic(const AttrTy *A) {
 }
 
 bool ThreadSafetyAnalyzer::inCurrentScope(const CapabilityExpr &CapE) {
-  const threadSafety::til::SExpr *SExp = CapE.sexpr();
-  assert(SExp && "Null expressions should be ignored");
-
-  // Global variables are always in scope.
-  if (isa(SExp))
-return true;
-
-  // Members are in scope from methods of the same class.
-  if (const auto *P = dyn_cast(SExp)) {
-if (!CurrentMethod)
+  if (!CurrentMethod)
   return false;
-const ValueDecl *VD = P->clangDecl();
-return VD->getDeclContext() == CurrentMethod->getDeclContext();
+  if (const auto *P = dyn_cast_or_null(CapE.sexpr())) {
+const auto *VD = P->clangDecl();
+if (VD)
+  return VD->getDeclContext() == CurrentMethod->getDeclContext();
   }
-
   return false;
 }
 

diff  --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp 
b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index aee918576007..1b8c55e56d47 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -274,7 +274,7 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const 
DeclRefExpr *DRE,
   const auto *VD = cast(DRE->getDecl()->getCanonicalDecl());
 
   // Function parameters require substitution and/or renaming.
-  if (const auto *PV = dyn_cast(VD)) {
+  if (const auto *PV = dyn_cast_or_null(VD)) {
 unsigned I = PV->getFunctionScopeIndex();
 const DeclContext *D = PV->getDeclContext();
 if (Ctx && Ctx->FunArgs) {

diff  --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp 
b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
index d1520b1decbd..91bd15def577 100644
--- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -5036,8 +5036,7 @@ void spawn_fake_flight_control_thread(void) {
 }
 
 extern const char *deque_log_msg(void) 
__attribute__((requires_capability(Logger)));
-void logger_entry(void) __attribute__((requires_capability(Logger)))
-__attribute__((requires_capability(!FlightControl))) {
+void logger_entry(void) __attribute__((requires_capability(Logger))) {
   const char *msg;
 
   while ((msg = deque_log_msg())) {
@@ -5045,13 +5044,13 @@ void logger_entry(void) 
__attribute__((requires_capability(Logger)))
   }
 }
 
-void spawn_fake_logger_thread(void) 
__attribute__((requires_capability(!FlightControl))) {
+void spawn_fake_logger_thread(void) {
   acquire(Logger);
   logger_entry();
   release(Logger);
 }
 
-int main(void) __attribute__((requires_capability(!FlightControl))) {
+int main(void) {
   spawn_fake_flight_control_thread();
   spawn_fake_logger_thread();
 

diff  --git a/clang/test/SemaCXX/warn-thread-safety-negative.cpp 
b/clang/test/SemaCXX/warn-thread-safety-negative.cpp
index 68e30f4a3225..456fe16e6574 100644
--- a/clang/test/SemaCXX/warn-thread-safety-negative.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-negative.cpp
@@ -81,35 +81,6 @@ class Foo {
 
 }  // end namespace SimpleTest
 
-Mutex globalMutex;
-
-namespace ScopeTest {
-
-void f() EXCLUSIVE_LOCKS_REQUIRED(!globalMutex);
-void fq() EXCLUSIVE_LOCKS_REQUIRED(!::globalMutex);
-
-namespace ns {
-  Mutex globalMutex;
-  void f() EXCLUSIVE_LOCKS_REQUIRED(!globalMutex);
-  void fq() EXCLUSIVE_LOCKS_REQUIRED(!ns::globalMutex);
-}
-
-void testGlobals() EXCLUSIVE_LOCKS_REQUIRED(!ns::globalMutex) {
-  f(); // expected-warning {{calling function 'f' requires negative 
capability '!globalMutex'}}
-  fq();// expected-warning {{calling function 'fq' requires negative 
capability '!globalMutex'}}
-  ns::f();
-  ns::fq();
-}
-
-void testNamespaceGlobals() EXCLUSIVE_LOCKS_REQUIRED(!globalMutex) {
-  f();
-  fq();
-  ns::f();  // expected-warning {{calling function 'f' requires negative 
capa

[PATCH] D84604: Thread safety analysis: Consider global variables in scope

2020-09-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D84604#2262745 , @lebedev.ri wrote:

> I'm not sure this is the problematic patch, but i'm now seeing some weird 
> warnings:
>
>   :304:15: warning: acquiring mutex 'guard' requires negative 
> capability '!guard' [-Wthread-safety-negative]
> MutexLocker guard(&mutex);
> ^
>   :309:15: warning: acquiring mutex 'guard' requires negative 
> capability '!guard' [-Wthread-safety-negative]
> MutexLocker guard(&mutex);
> ^
>   :322:15: warning: acquiring mutex 'guard' requires negative 
> capability '!guard' [-Wthread-safety-negative]
> MutexLocker guard(&mutex);
> ^
>   3 warnings generated.
>
> https://godbolt.org/z/5zYT55
>
> If this is the patch that causes it, then i think it's an obvious 
> false-positive (wasn't this patch supposed to only handle globals?),
> if not, the warning's wording is not great.

I've verified that this is indeed the change that causes it,
and therefore gone ahead and temporairly reverted it in 
rG8427885e27813c457dccb011f65e8ded7e31 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84604

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


[PATCH] D87244: [clang] Add fix-it for -Wreorder-ctor.

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

thanks, comments around some implementations. the only high level question i 
have is about the choice of location for fix-it (see the detailed comment 
inline)




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5198
+static bool RangeContainsComments(Sema &SemaRef, SourceLocation Begin,
+  SourceLocation End) {
+  auto &SrcMgr = SemaRef.getSourceManager();

nit: assert for fileids of begin and end at the beginning.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5208
+  while (!Lex.LexFromRawLexer(Tok) &&
+ SrcMgr.isBeforeInTranslationUnit(Tok.getLocation(), End)) {
+if (Tok.is(tok::comment))

since Tok and End are in the same file you can just use `<` operator.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5298
+  if (IdealIndex == NumIdealInits) {
+// This initializer is not in the ideal list at all. This can happen in
+// a class with dependent base, when we cannot tell if initializer is

i don't really follow when this happens. comments mentions a dependent base, 
but test case only has a templated constructor. why do we think it is safe to 
continue in this case, while we bail out in case of a dependent class? i would 
suggest just bailing out at the beginning of the function if constructor is 
dependent too (in addition to it's class being dependent)



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5311
+// previous (valid) initializer, emit a warning.
+if (IsOutOfOrder && !InitsWithIdealIndex.empty()) {
+  // Emit previous diagnostic, if any.

why not move this into previous if block i.e.

```
if (isoutoforder) {
 if(!Initswithidealindex.empty()) { ... }
 if(IdealIndex== NumIdealInits) { ..}
 if(!InitsWithIdealIndex.empty() {
// emit diag
  }
}
```



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5337
+
+  // If possible, add fix to the last diagnostic. The fix will reorder all
+  // initializers. This is preferable to attaching overlapping fixes for each

I totally agree with having a single fix-it to re-order all of the 
initializers, but I am not sure if last initializer is the best location for 
that fixit, especially for interactive tools (it is definitely the right 
behaviour for command line tools like clang and clang-tidy tho, as they'll 
either print the fix multiple times or try to apply conflicting fixes)

e.g. if user sees 3 out-of-order initializer warnings, they'll likely hover 
over one of them and say, "aaah" and fix the code themselves, if fixit wasn't 
available with that one.
Moreover when there's only 1 out-of-order initialzier warning, they'll see the 
fixit attached no matter what.
Next time, when there are multiple warnings they won't see it and will likely 
file bugs saying that "clang(d) doesn't generate fixes all the time".

But I also don't have any better suggestions, as having it multiple times will 
definitely be helpful for interactive tools but will regress the others.. Maybe 
attaching it to the first initializer might be better overall?



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5348
+  for (const auto &Init : Inits) {
+if (Init->getSourceLocation().isMacroID() ||
+!SrcMgr.isWrittenInSameFile(Init->getSourceLocation(),

can we have some tests for this case?



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5355
+  }
+  if (ShouldEmitFix)
+ShouldEmitFix =

nit: `ShouldEmitFix = ShouldEmitFix && !Range...`



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5358
+!RangeContainsComments(SemaRef, Inits.front()->getSourceLocation(),
+   Inits.back()->getSourceLocation());
 

what if there are comments after last initializer ? I think we should rather 
use LBraceLoc for the constructor in here.



Comment at: clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp:139
+struct Y {
+  template  Y(T x) : a(), X(x) {}
+  Foo a;

i think it is enough to have `int a;` as a member do we really need a separate 
type? + why don't we just merge this with the previous case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87244

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


[PATCH] D87358: [clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

2020-09-09 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: efriedma, sdesmalen, rsandifo-arm.
Herald added subscribers: kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
c-rhodes requested review of this revision.

The element types of scalable vectors are defined in terms of stdint
types in the ACLE. This patch fixes the mapping to builtin types for the
ILP32 ABI when creating VLS types with the arm_sve_vector_bits, where
the mapping is as follows:

  int32_t -> LongTy
  int64_t -> LongLongTy
  uint32_t -> UnsignedLongTy
  uint64_t -> UnsignedLongLongTy

The test uses the 'aarch64_32-unknown-darwin' triple since that seems to be the
only AArch64 target with ILP32 ABI support. Interested in suggestions if
there's another way to test this.

For more information, see:

https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#types-varying-by-data-model
https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-support-for-scalable-vectors


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87358

Files:
  clang/lib/AST/Type.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-types.c


Index: clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=512 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-512
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=1024 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-1024
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=2048 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-2048
+// RUN: %clang_cc1 -triple aarch64_32-unknown-darwin -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=512 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ILP32
 
 #include 
 
@@ -579,3 +580,11 @@
 // CHECK-2048-NEXT:  %local_arr_f64 = alloca [3 x <32 x double>], align 16
 // CHECK-2048-NEXT:  %local_arr_bf16 = alloca [3 x <128 x bfloat>], align 16
 // CHECK-2048-NEXT:  %local_arr_bool = alloca [3 x <32 x i8>], align 2
+
+//===--===//
+// ILP32 ABI
+//===--===//
+// CHECK-ILP32: @global_i32 = global <16 x i32> zeroinitializer, align 16
+// CHECK-ILP32: @global_i64 = global <8 x i64> zeroinitializer, align 16
+// CHECK-ILP32: @global_u32 = global <16 x i32> zeroinitializer, align 16
+// CHECK-ILP32: @global_u64 = global <8 x i64> zeroinitializer, align 16
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2316,6 +2316,9 @@
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
+  llvm::Triple Triple = Ctx.getTargetInfo().getTriple();
+  bool IsILP32 = Triple.getArch() == llvm::Triple::aarch64_32;
+
   const BuiltinType *BTy = getAs();
   switch (BTy->getKind()) {
   default:
@@ -2333,13 +2336,13 @@
   case BuiltinType::SveUint16:
 return Ctx.UnsignedShortTy;
   case BuiltinType::SveInt32:
-return Ctx.IntTy;
+return IsILP32 ? Ctx.LongTy : Ctx.IntTy;
   case BuiltinType::SveUint32:
-return Ctx.UnsignedIntTy;
+return IsILP32 ? Ctx.UnsignedLongTy : Ctx.UnsignedIntTy;
   case BuiltinType::SveInt64:
-return Ctx.LongTy;
+return IsILP32 ? Ctx.LongLongTy : Ctx.LongTy;
   case BuiltinType::SveUint64:
-return Ctx.UnsignedLongTy;
+return IsILP32 ? Ctx.UnsignedLongLongTy : Ctx.UnsignedLongTy;
   case BuiltinType::SveFloat16:
 return Ctx.Float16Ty;
   case BuiltinType::SveBFloat16:


Index: clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -msve-vector-bits=512 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-512
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -msve-vector-bits=1024 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-1024
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -msve-vector-bits=2048 -fallo

[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

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

Couldn't we avoid a lot of this of this casting + template ugliness by just 
using the  /  INT_MAX / INT32_MAX defines?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

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


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu created this revision.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
ki.stfu requested review of this revision.

See 
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4101


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87360

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4101 : CLFlag<"wd4101">, Alias,
+  AliasArgs<["no-unused-variable"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4101 : CLFlag<"wd4101">, Alias,
+  AliasArgs<["no-unused-variable"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu updated this revision to Diff 290697.
ki.stfu added a comment.

Add tests


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

https://reviews.llvm.org/D87360

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,10 +330,11 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4101 -wd4910 -wd4996 -### -- %s 2>&1 | 
FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
+// Wno: "-Wno-unused-variable"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4101 : CLFlag<"wd4101">, Alias,
+  AliasArgs<["no-unused-variable"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,10 +330,11 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4101 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
+// Wno: "-Wno-unused-variable"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4101 : CLFlag<"wd4101">, Alias,
+  AliasArgs<["no-unused-variable"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu created this revision.
ki.stfu added a reviewer: rsmith.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
ki.stfu requested review of this revision.

See 
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4238


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87364

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,10 +330,11 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4238 -wd4910 -wd4996 -### -- %s 2>&1 | 
FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
+// Wno: "-Wno-address-of-temporary"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4238 : CLFlag<"wd4238">, Alias,
+  AliasArgs<["no-address-of-temporary"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,10 +330,11 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4238 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
+// Wno: "-Wno-address-of-temporary"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4630,6 +4630,8 @@
   AliasArgs<["no-sign-compare"]>;
 def _SLASH_wd4100 : CLFlag<"wd4100">, Alias,
   AliasArgs<["no-unused-parameter"]>;
+def _SLASH_wd4238 : CLFlag<"wd4238">, Alias,
+  AliasArgs<["no-address-of-temporary"]>;
 def _SLASH_wd4910 : CLFlag<"wd4910">, Alias,
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu created this revision.
ki.stfu added a reviewer: rsmith.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
ki.stfu requested review of this revision.

>From here 
>https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4800-through-c4999:

> operator 'operator-name': deprecated between enumerations of different types




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87368

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,12 +330,13 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd5054 -### -- %s 2>&1 | 
FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
+// Wno: "-Wno-deprecated-anon-enum-enum-conversion"
 
 // Ignored options. Check that we don't get "unused during compilation" errors.
 // RUN: %clang_cl /c \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4634,6 +4634,8 @@
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
   AliasArgs<["no-deprecated-declarations"]>;
+def _SLASH_wd5054 : CLFlag<"wd5054">, Alias,
+  AliasArgs<["no-deprecated-anon-enum-enum-conversion"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
 def _SLASH_X : CLFlag<"X">,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -330,12 +330,13 @@
 // CHECK-CHAR8_T_: "-fno-char8_t"
 
 // For some warning ids, we can map from MSVC warning to Clang warning.
-// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
+// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd5054 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
 // Wno: "-cc1"
 // Wno: "-Wno-macro-redefined"
 // Wno: "-Wno-unused-parameter"
 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
 // Wno: "-Wno-deprecated-declarations"
+// Wno: "-Wno-deprecated-anon-enum-enum-conversion"
 
 // Ignored options. Check that we don't get "unused during compilation" errors.
 // RUN: %clang_cl /c \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4634,6 +4634,8 @@
   AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
 def _SLASH_wd4996 : CLFlag<"wd4996">, Alias,
   AliasArgs<["no-deprecated-declarations"]>;
+def _SLASH_wd5054 : CLFlag<"wd5054">, Alias,
+  AliasArgs<["no-deprecated-anon-enum-enum-conversion"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
 def _SLASH_X : CLFlag<"X">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu created this revision.
ki.stfu added a reviewer: rsmith.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
ki.stfu requested review of this revision.

The first option tells the compiler to use external linkage for `constexpr` 
variables, and the second one prevents null checks after `operator new` which 
can throw.

See https://docs.microsoft.com/en-us/cpp/build/reference/zc-externconstexpr and 
https://docs.microsoft.com/en-us/cpp/build/reference/zc-throwingnew-assume-operator-new-throws


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87372

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -369,10 +369,12 @@
 // RUN:/wd1234 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
+// RUN:/Zc:externConstexpr \
 // RUN:/Zc:forScope \
 // RUN:/Zc:inline \
 // RUN:/Zc:rvalueCast \
 // RUN:/Zc:ternary \
+// RUN:/Zc:throwingNew \
 // RUN:/Zc:wchar_t \
 // RUN:/ZH:MD5 \
 // RUN:/ZH:SHA1 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4837,10 +4837,12 @@
 def _SLASH_w : CLIgnoredJoined<"w">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
+def _SLASH_Zc_externConstexpr : CLIgnoredFlag<"Zc:externConstexpr">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
 def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">;
 def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">;
 def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">;
+def _SLASH_Zc_throwingNew : CLIgnoredFlag<"Zc:throwingNew">;
 def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">;
 def _SLASH_ZH_MD5 : CLIgnoredFlag<"ZH:MD5">;
 def _SLASH_ZH_SHA1 : CLIgnoredFlag<"ZH:SHA1">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -369,10 +369,12 @@
 // RUN:/wd1234 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
+// RUN:/Zc:externConstexpr \
 // RUN:/Zc:forScope \
 // RUN:/Zc:inline \
 // RUN:/Zc:rvalueCast \
 // RUN:/Zc:ternary \
+// RUN:/Zc:throwingNew \
 // RUN:/Zc:wchar_t \
 // RUN:/ZH:MD5 \
 // RUN:/ZH:SHA1 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4837,10 +4837,12 @@
 def _SLASH_w : CLIgnoredJoined<"w">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
+def _SLASH_Zc_externConstexpr : CLIgnoredFlag<"Zc:externConstexpr">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
 def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">;
 def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">;
 def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">;
+def _SLASH_Zc_throwingNew : CLIgnoredFlag<"Zc:throwingNew">;
 def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">;
 def _SLASH_ZH_MD5 : CLIgnoredFlag<"ZH:MD5">;
 def _SLASH_ZH_SHA1 : CLIgnoredFlag<"ZH:SHA1">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-09-09 Thread Ilia K via Phabricator via cfe-commits
ki.stfu added a comment.

Not sure, but I'd be surprised if Clang behaves like MSVC in one of these cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87372

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


[PATCH] D78938: Make LLVM build in C++20 mode

2020-09-09 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin added a comment.

> @BRevzin, you should a) mention the u8/const char* issue in the description 
> too, and also what compiler you used to build this with. I fully expect at 
> this stage that there are some C++20 compilers that might have slightly 
> different interpretations of things which this won't resolve, so knowing 
> which one this is intended to work with could help with historical research.

It's mentioned in the description. I built with clang-10.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D87374: [SyntaxTree] Specialize `TreeTestBase` for `BuildTreeTest` and `MutationsTest`

2020-09-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
eduucaldas added a reviewer: gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87374

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -32,11 +32,6 @@
   TranslationUnit *buildTree(StringRef Code,
  const TestClangConfig &ClangConfig);
 
-  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree);
-
-  ::testing::AssertionResult
-  treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
- ArrayRef TreeDumps);
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root);
@@ -56,6 +51,8 @@
   std::unique_ptr TB;
   std::unique_ptr Arena;
 };
+
+std::vector allTestClangConfigs();
 } // namespace syntax
 } // namespace clang
 #endif // LLVM_CLANG_UNITTESTS_TOOLING_SYNTAX_TREETESTBASE_H
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -43,8 +43,9 @@
   return llvm::makeArrayRef(T->firstLeaf()->token(),
 T->lastLeaf()->token() + 1);
 }
+} // namespace
 
-std::vector allTestClangConfigs() {
+std::vector clang::syntax::allTestClangConfigs() {
   std::vector all_configs;
   for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
 Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
@@ -61,10 +62,6 @@
   return all_configs;
 }
 
-INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
-testing::ValuesIn(allTestClangConfigs()), );
-} // namespace
-
 syntax::TranslationUnit *
 SyntaxTreeTest::buildTree(StringRef Code, const TestClangConfig &ClangConfig) {
   // FIXME: this code is almost the identical to the one in TokensTest. Share
@@ -161,62 +158,6 @@
   return Root;
 }
 
-::testing::AssertionResult SyntaxTreeTest::treeDumpEqual(StringRef Code,
- StringRef Tree) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto *Root = buildTree(Code, GetParam());
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-  auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
-  // EXPECT_EQ shows the diff between the two strings if they are different.
-  EXPECT_EQ(Tree.trim().str(), Actual);
-  if (Actual != Tree.trim().str()) {
-return ::testing::AssertionFailure();
-  }
-  return ::testing::AssertionSuccess();
-}
-
-::testing::AssertionResult
-SyntaxTreeTest::treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
-   ArrayRef TreeDumps) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto AnnotatedCode = llvm::Annotations(CodeWithAnnotations);
-  auto *Root = buildTree(AnnotatedCode.code(), GetParam());
-
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-
-  auto AnnotatedRanges = AnnotatedCode.ranges();
-  if (AnnotatedRanges.size() != TreeDumps.size()) {
-return ::testing::AssertionFailure()
-   << "The number of annotated ranges in the source code is different "
-  "to the number of their corresponding tree dumps.";
-  }
-  bool Failed = false;
-  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
-auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
-assert(AnnotatedNode);
-auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
-// EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
-<< "Dumps diverged for the code:\n"
-<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
-  AnnotatedRanges[i].End);
-if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  Failed = true;
-  }
-  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
-}
-
 syntax::Node *SyntaxTreeTest

[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

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



Comment at: clang/include/clang/Basic/Attr.td:2122
+def SwiftError : InheritableAttr {
+  let Spellings = [GCC<"swift_error">];
+  let Args = [

Is this attribute also supported by GCC? It looked like it wasn't from my quick 
check, so I'd recommend switching the spelling to be `Clang` instead. Note, 
this will give you `[[clang::swift_error(...)]]` in both C and C++ as well. If 
you only want the GNU spelling, use `GNU`.



Comment at: clang/include/clang/Basic/Attr.td:2128
+  ];
+  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
+  let Documentation = [SwiftErrorDocs];

Should this apply to function-like things such as blocks or function pointers? 
If so, you should use `HasFunctionProto`.



Comment at: clang/include/clang/Basic/AttrDocs.td:3390
+Objective-C method) is imported into Swift as a throwing function, and if so,
+the dynamic convention it uses.
+

the dynamic -> which dynamic



Comment at: clang/include/clang/Basic/AttrDocs.td:3394
+parameter. Currently, the error parameter is always the last parameter of type
+``NSError**`` or ``CFErrorRef*``.  Swift will remove the error parameter from
+the imported API. When calling the API, Swift will always pass a valid address

Canonical type or are typedefs to these types also fine? May want to mention 
that the type has to be cv-unqualified, but I do wonder whether something like 
`NSError * const *` is fine.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5536
+  if (const auto *OPT = Pointee->getAs())
+if (auto *ID = OPT->getInterfaceDecl())
+  if (ID->getIdentifier() == S.getNSErrorIdent())

`const auto *`?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5551-5552
+  auto hasErrorParameter = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool {
+if (D->isInvalidDecl())
+  return true;
+

No need to repeat this condition three times (and in some cases repeat the 
check). You can hoist this out of all of the lambdas and call it once.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5560
+S.Diag(AL.getLoc(), diag::err_attr_swift_error_no_error_parameter)
+<< AL.getNormalizedFullName() << isa(D);
+return false;

You should just be able to pass in `AL` directly (the diagnostics engine 
handles formatting the name properly), or is there a reason you want to call 
`getNormalizedFullName()` explicitly?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5576
+S.Diag(AL.getLoc(), diag::err_attr_swift_error_return_type)
+<< AL.getNormalizedFullName() << AL.getArgAsIdent(0)->Ident->getName()
+<< isa(D) << /*pointer*/ 1;

Same here as above, but also, you can just pass in `Ident`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5590
+S.Diag(AL.getLoc(), diag::err_attr_swift_error_return_type)
+<< AL.getNormalizedFullName() << AL.getArgAsIdent(0)->Ident->getName()
+<< isa(D) << /*integeral*/ 0;

Same here as above.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5596
+  IdentifierLoc *Loc = AL.getArgAsIdent(0);
+  SwiftErrorAttr::ConventionKind convention;
+  if (!SwiftErrorAttr::ConvertStrToConventionKind(Loc->Ident->getName(),

`convention` -> `Convention` per usual naming rules.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5600
+S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+<< AL.getNormalizedFullName() << Loc->Ident;
+return;

Same here as above.



Comment at: clang/test/SemaObjC/attr-swift-error.m:10
+#endif
+
+typedef struct __attribute__((__objc_bridge__(NSError))) __CFError *CFErrorRef;

You should also have some tests where the attribute accepts no args, too many 
args, and unknown enum value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D87374: [SyntaxTree] Specialize `TreeTestBase` for `BuildTreeTest` and `MutationsTest`

2020-09-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/MutationsTest.cpp:75-85
+INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
+::testing::ValuesIn(allTestClangConfigs()), );
+
 TEST_P(SyntaxTreeTest, SynthesizedNodes) {
   buildTree("", GetParam());
 
   auto *C = syntax::createPunctuation(*Arena, tok::comma);

I think it makes sense to split this into a separate file as well. 

If agreed this will be done in a separate patch, because it will also incur the 
creation of a `Synthesis.h`.

Currently `BuildTree.h` is backed by `Synthesis.cpp` and `BuildTree.cpp` which 
I don't think makes a lot of sense


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87374

___
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-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

As another data point, I have collected compile-time numbers for ARM64 with -Os 
-g LTO & -Oz -g LTO. Geoman changes below. Compile time here is actual 
execution time on a stabilized system.

   Compile time code size
  -Oz RLTO   0.67% -0.12%
  -Os -g RLTO0.06% -0.14%

I think flipping the switch now should be reasonable compile-time wise and we 
also have some ideas on how to reduce compile-time even further once it is 
enabled by default.


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] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-09-09 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob updated this revision to Diff 290726.
dougpuob added a comment.

- Fixed lint warnings and regression test failures on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
@@ -0,0 +1,261 @@
+typedef signed char int8_t;  // NOLINT
+typedef short int16_t;   // NOLINT
+typedef long int32_t;// NOLINT
+typedef long long int64_t;   // NOLINT
+typedef unsigned char uint8_t;   // NOLINT
+typedef unsigned short uint16_t; // NOLINT
+typedef unsigned long uint32_t;  // NOLINT
+typedef unsigned long long uint64_t; // NOLINT
+typedef unsigned long long size_t;   // NOLINT
+typedef long intptr_t;   // NOLINT
+typedef unsigned long uintptr_t; // NOLINT
+typedef long int ptrdiff_t;  // NOLINT
+typedef unsigned char BYTE;  // NOLINT
+typedef unsigned short WORD; // NOLINT
+typedef unsigned long DWORD; // NOLINT
+typedef int BOOL;// NOLINT
+typedef BYTE BOOLEAN;// NOLINT
+#define NULL (0) // NOLINT
+
+// RUN: clang-tidy %s -checks=readability-identifier-naming \
+// RUN:   -config="{CheckOptions: [\
+// RUN: {key: readability-identifier-naming.FunctionCase   , value: CamelCase },   \
+// RUN: {key: readability-identifier-naming.ClassCase  , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.TypedefCase, value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.MemberCase , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.ClassMemberCase, value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.ConstantMemberCase , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.VariableCase   , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.ParameterCase  , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.GlobalPointerCase  , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.GlobalVariableCase , value: szHungarianNotation }, \
+// RUN: {key: readability-identifier-naming.GlobalFunctionCase , value: CamelCase } \
+// RUN:   ]}"
+
+class UnlistedClass { public: mutable int ValInt; };
+// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: invalid case style for member 'ValInt' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}class UnlistedClass { public: mutable int iValInt; };
+
+UnlistedClass cUnlisted2;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'cUnlisted2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}UnlistedClass Unlisted2;
+
+UnlistedClass objUnlistedClass3;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for global variable 'objUnlistedClass3' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}UnlistedClass UnlistedClass3;
+
+typedef int INDEX;
+INDEX iIndex = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global variable 'iIndex' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}INDEX Index = 0;
+
+struct DataBuffer {
+mutable size_t Size;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: invalid case style for member 'Size' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}mutable size_t nSize;
+
+int &RefValueIndex = iIndex;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global variable 'RefValueIndex' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int &iRefValueIndex = Index;
+
+typedef void (*FUNC_PTR_HELLO)();
+FUNC_PTR_HELLO Hello = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'Hello' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}FUNC_PTR_HELLO fnHello = NULL;
+
+void *ValueVoidPtr = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'ValueVoidPtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void *pValueVoidPtr = NULL;
+
+ptrdiff_t PtrDiff = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global variable 'PtrDiff' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}ptrdiff_t pPtrDi

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

2020-09-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 accepted this revision.
xbolva00 added a subscriber: spatel.
xbolva00 added a comment.
This revision is now accepted and ready to land.

Thanks, amazing work!

I agree that this should be enabled now and do not wait anymore.

@nikic @spatel ?


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] D87201: [clang-format] Add a option for the position of Java static import

2020-09-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM, I'm happy if @JakeMerdichAMD  is




Comment at: clang/include/clang/Format/Format.h:1708
+  /// \endcode
+  bool JavaStaticImportAfterImport;
+

bc-lee wrote:
> JakeMerdichAMD wrote:
> > MyDeveloperDay wrote:
> > > Can we consider changing the name or the option to make it clearer what 
> > > its for?
> > > 
> > > `SortJavaStaticImport`
> > > 
> > > and make it an enumeration rather than true/false
> > > 
> > > `Before,After,Never`
> > > 
> > > There need to be a "don't touch it option (.e.g. Never)" that does what 
> > > it does today (and that should be the default, otherwise we end up 
> > > causing clang-format to change ALL java code" which could be 100's of 
> > > millions of lines+
> > > 
> > > 
> > I'm confused, there is not currently a never option... Right now the 
> > behavior is always 'before', there is no 'after' or 'never'.
> > 
> > Making it an enum would probably be more ergonomic though, even there is no 
> > never option.
> If `SortIncludes` is `true`, it doesn't make sense to not touch Java static 
> include.
> Making it an enum is also good for me.
> 
true.. it will sort it I assume one way or the other


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87201

___
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-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for doing this..


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] D83678: [analyzer][ReturnPtrRangeChecker] Fix a false positive on end() iterator

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

LGTM on my end!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83678

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


[PATCH] D87220: [PowerPC] Fix STRICT_FRINT/STRICT_FNEARBYINT lowering

2020-09-09 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88ff4d2ca1a0: [PowerPC] Fix STRICT_FRINT/STRICT_FNEARBYINT 
lowering (authored by qiucf).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87220

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/builtins-ppc-vsx.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/fp-strict-round.ll
  llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll
===
--- llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll
+++ llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll
@@ -4899,19 +4899,50 @@
 define <2 x double> @constrained_vector_nearbyint_v2f64() #0 {
 ; PC64LE-LABEL: constrained_vector_nearbyint_v2f64:
 ; PC64LE:   # %bb.0: # %entry
+; PC64LE-NEXT:mflr 0
+; PC64LE-NEXT:std 0, 16(1)
+; PC64LE-NEXT:stdu 1, -64(1)
 ; PC64LE-NEXT:addis 3, 2, .LCPI81_0@toc@ha
-; PC64LE-NEXT:addi 3, 3, .LCPI81_0@toc@l
-; PC64LE-NEXT:lxvd2x 0, 0, 3
-; PC64LE-NEXT:xxswapd 0, 0
-; PC64LE-NEXT:xvrdpic 34, 0
+; PC64LE-NEXT:lfd 1, .LCPI81_0@toc@l(3)
+; PC64LE-NEXT:bl nearbyint
+; PC64LE-NEXT:nop
+; PC64LE-NEXT:li 3, 48
+; PC64LE-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE-NEXT:stxvd2x 1, 1, 3 # 16-byte Folded Spill
+; PC64LE-NEXT:addis 3, 2, .LCPI81_1@toc@ha
+; PC64LE-NEXT:lfs 1, .LCPI81_1@toc@l(3)
+; PC64LE-NEXT:bl nearbyint
+; PC64LE-NEXT:nop
+; PC64LE-NEXT:li 3, 48
+; PC64LE-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE-NEXT:lxvd2x 0, 1, 3 # 16-byte Folded Reload
+; PC64LE-NEXT:xxmrghd 34, 1, 0
+; PC64LE-NEXT:addi 1, 1, 64
+; PC64LE-NEXT:ld 0, 16(1)
+; PC64LE-NEXT:mtlr 0
 ; PC64LE-NEXT:blr
 ;
 ; PC64LE9-LABEL: constrained_vector_nearbyint_v2f64:
 ; PC64LE9:   # %bb.0: # %entry
+; PC64LE9-NEXT:mflr 0
+; PC64LE9-NEXT:std 0, 16(1)
+; PC64LE9-NEXT:stdu 1, -48(1)
 ; PC64LE9-NEXT:addis 3, 2, .LCPI81_0@toc@ha
-; PC64LE9-NEXT:addi 3, 3, .LCPI81_0@toc@l
-; PC64LE9-NEXT:lxvx 0, 0, 3
-; PC64LE9-NEXT:xvrdpic 34, 0
+; PC64LE9-NEXT:lfd 1, .LCPI81_0@toc@l(3)
+; PC64LE9-NEXT:bl nearbyint
+; PC64LE9-NEXT:nop
+; PC64LE9-NEXT:addis 3, 2, .LCPI81_1@toc@ha
+; PC64LE9-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE9-NEXT:stxv 1, 32(1) # 16-byte Folded Spill
+; PC64LE9-NEXT:lfs 1, .LCPI81_1@toc@l(3)
+; PC64LE9-NEXT:bl nearbyint
+; PC64LE9-NEXT:nop
+; PC64LE9-NEXT:lxv 0, 32(1) # 16-byte Folded Reload
+; PC64LE9-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE9-NEXT:xxmrghd 34, 1, 0
+; PC64LE9-NEXT:addi 1, 1, 48
+; PC64LE9-NEXT:ld 0, 16(1)
+; PC64LE9-NEXT:mtlr 0
 ; PC64LE9-NEXT:blr
 entry:
   %nearby = call <2 x double> @llvm.experimental.constrained.nearbyint.v2f64(
@@ -5010,31 +5041,72 @@
 define <3 x double> @constrained_vector_nearby_v3f64() #0 {
 ; PC64LE-LABEL: constrained_vector_nearby_v3f64:
 ; PC64LE:   # %bb.0: # %entry
-; PC64LE-NEXT:addis 3, 2, .LCPI83_1@toc@ha
-; PC64LE-NEXT:addi 3, 3, .LCPI83_1@toc@l
-; PC64LE-NEXT:lxvd2x 0, 0, 3
+; PC64LE-NEXT:mflr 0
+; PC64LE-NEXT:std 0, 16(1)
+; PC64LE-NEXT:stdu 1, -80(1)
+; PC64LE-NEXT:li 3, 64
+; PC64LE-NEXT:stxvd2x 63, 1, 3 # 16-byte Folded Spill
 ; PC64LE-NEXT:addis 3, 2, .LCPI83_0@toc@ha
 ; PC64LE-NEXT:lfd 1, .LCPI83_0@toc@l(3)
-; PC64LE-NEXT:xxswapd 0, 0
-; PC64LE-NEXT:xsrdpic 3, 1
-; PC64LE-NEXT:xvrdpic 2, 0
-; PC64LE-NEXT:xxswapd 1, 2
-; PC64LE-NEXT:# kill: def $f2 killed $f2 killed $vsl2
-; PC64LE-NEXT:# kill: def $f1 killed $f1 killed $vsl1
+; PC64LE-NEXT:bl nearbyint
+; PC64LE-NEXT:nop
+; PC64LE-NEXT:li 3, 48
+; PC64LE-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE-NEXT:stxvd2x 1, 1, 3 # 16-byte Folded Spill
+; PC64LE-NEXT:addis 3, 2, .LCPI83_1@toc@ha
+; PC64LE-NEXT:lfs 1, .LCPI83_1@toc@l(3)
+; PC64LE-NEXT:bl nearbyint
+; PC64LE-NEXT:nop
+; PC64LE-NEXT:li 3, 48
+; PC64LE-NEXT:# kill: def $f1 killed $f1 def $vsl1
+; PC64LE-NEXT:lxvd2x 0, 1, 3 # 16-byte Folded Reload
+; PC64LE-NEXT:addis 3, 2, .LCPI83_2@toc@ha
+; PC64LE-NEXT:xxmrghd 63, 0, 1
+; PC64LE-NEXT:lfd 1, .LCPI83_2@toc@l(3)
+; PC64LE-NEXT:bl nearbyint
+; PC64LE-NEXT:nop
+; PC64LE-NEXT:xxswapd 0, 63
+; PC64LE-NEXT:li 3, 64
+; PC64LE-NEXT:xxlor 2, 63, 63
+; PC64LE-NEXT:lxvd2x 63, 1, 3 # 16-byte Folded Reload
+; PC64LE-NEXT:fmr 3, 1
+; PC64LE-NEXT:fmr 1, 0
+; PC64LE-NEXT:addi 1, 1, 80
+; PC64LE-NEXT:ld 0, 16(1)
+; PC64LE-NEXT:mtlr 0
 ;

[clang] 88ff4d2 - [PowerPC] Fix STRICT_FRINT/STRICT_FNEARBYINT lowering

2020-09-09 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2020-09-09T22:40:58+08:00
New Revision: 88ff4d2ca1a0aaed6888152042256a0ef3fe863d

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

LOG: [PowerPC] Fix STRICT_FRINT/STRICT_FNEARBYINT lowering

In standard C library, both rint and nearbyint returns rounding result
in current rounding mode. But nearbyint never raises inexact exception.
On PowerPC, x(v|s)r(d|s)pic may modify FPSCR XX, raising inexact
exception. So we can't select constrained fnearbyint into xvrdpic.

One exception here is xsrqpi, which will not raise inexact exception, so
fnearbyint f128 is okay here.

Reviewed By: uweigand

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-ppc-fpconstrained.c
clang/test/CodeGen/builtins-ppc-vsx.c
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrVSX.td
llvm/test/CodeGen/PowerPC/fp-strict-round.ll
llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 0cb8f8f636f4..b2abc10544e1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14273,8 +14273,8 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpic ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspic)
   ID = Builder.getIsFPConstrained()
-   ? Intrinsic::experimental_constrained_nearbyint
-   : Intrinsic::nearbyint;
+   ? Intrinsic::experimental_constrained_rint
+   : Intrinsic::rint;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpip ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspip)
   ID = Builder.getIsFPConstrained()

diff  --git a/clang/test/CodeGen/builtins-ppc-fpconstrained.c 
b/clang/test/CodeGen/builtins-ppc-fpconstrained.c
index c8b08c3fb5d4..7c770845090f 100644
--- a/clang/test/CodeGen/builtins-ppc-fpconstrained.c
+++ b/clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -59,14 +59,14 @@ void test_float(void) {
 
   vf = __builtin_vsx_xvrspic(vf);
   // CHECK-LABEL: try-xvrspic
-  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
-  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v4f32(<4 x 
float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-UNCONSTRAINED: @llvm.rint.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.rint.v4f32(<4 x float> 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK-ASM: xvrspic
 
   vd = __builtin_vsx_xvrdpic(vd);
   // CHECK-LABEL: try-xvrdpic
-  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v2f64(<2 x double> %{{.*}})
-  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v2f64(<2 x 
double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-UNCONSTRAINED: @llvm.rint.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.rint.v2f64(<2 x double> 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK-ASM: xvrdpic
 
   vf = __builtin_vsx_xvrspip(vf);

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index 0d0724726275..2542b30590bf 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -863,12 +863,12 @@ void test1() {
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.xvredp(<2 x double>
 
   res_vf = vec_rint(vf);
-// CHECK: call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %{{[0-9]+}})
-// CHECK-LE: call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %{{[0-9]+}})
+// CHECK: call <4 x float> @llvm.rint.v4f32(<4 x float> %{{[0-9]+}})
+// CHECK-LE: call <4 x float> @llvm.rint.v4f32(<4 x float> %{{[0-9]+}})
 
   res_vd = vec_rint(vd);
-// CHECK: call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %{{[0-9]+}})
-// CHECK-LE: call <2 x double> @llvm.nearbyint.v2f64(<2 x double> %{{[0-9]+}})
+// CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double> %{{[0-9]+}})
+// CHECK-LE: call <2 x double> @llvm.rint.v2f64(<2 x double> %{{[0-9]+}})
 
   res_vf = vec_rsqrte(vf);
 // CHECK: call <4 x float> @llvm.ppc.vsx.xvrsqrtesp(<4 x float> %{{[0-9]+}})

diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index f542a8018b4f..fc9a80919fc1 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -316,8 +316,10 @@ PPCTargetLowering::PPCTargetLowering(const 
PPCTargetMachine &TM,
   setOperationAction(ISD::STRICT_FMUL, MVT::f64, Legal);
   setOperationAction(ISD::STRICT_FDIV, MVT::

[PATCH] D87382: [AST] Fix dependence-bits for CXXDefaultInitExpr.

2020-09-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: rsmith.
Herald added a project: clang.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87382

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -9,8 +9,7 @@
 constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
 
 struct X2 {
-  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant 
expression}}
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
   constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
 };
 
@@ -27,3 +26,9 @@
   // no bogus "delegation cycle" diagnostic
   CycleDelegate(float) : CycleDelegate(1) {}
 };
+
+struct X4 {
+  int* p = new int(invalid()); // expected-error {{use of undeclared 
identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -940,7 +940,7 @@
   CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 
-  setDependence(ExprDependence::None);
+  setDependence(computeDependence(this));
 }
 
 CXXTemporary *CXXTemporary::Create(const ASTContext &C,
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -694,6 +694,10 @@
   return D;
 }
 
+ExprDependence clang::computeDependence(CXXDefaultInitExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -70,6 +70,7 @@
 class OverloadExpr;
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
+class CXXDefaultInitExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -153,6 +154,7 @@
  bool KnownContainsUnexpandedParameterPack);
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
+ExprDependence computeDependence(CXXDefaultInitExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -9,8 +9,7 @@
 constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}}
 
 struct X2 {
-  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
- // expected-note {{subexpression not valid in a constant expression}}
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
   constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
 };
 
@@ -27,3 +26,9 @@
   // no bogus "delegation cycle" diagnostic
   CycleDelegate(float) : CycleDelegate(1) {}
 };
+
+struct X4 {
+  int* p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+};
+// no crash on evaluating the CXXDefaultInitExpr.
+constexpr int* s = X4().p; // expected-error {{must be initialized by}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -940,7 +940,7 @@
   CXXDefaultInitExprBits.Loc = Loc;
   assert(Field->hasInClassInitializer());
 
-  setDependence(ExprDependence::None);
+  setDependence(computeDependence(this));
 }
 
 CXXTemporary *CXXTemporary::Create(const ASTContext &C,
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -694,6 +694,10 @@
   return D;
 }

[PATCH] D86558: [OPENMP]Add support for allocate vars in untied tasks.

2020-09-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert 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/D86558/new/

https://reviews.llvm.org/D86558

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


[PATCH] D86796: [Sema] Address-space sensitive index check for unbounded arrays

2020-09-09 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86796

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


[PATCH] D86546: [compiler-rt][builtins] Use explicitly-sized integer types for LibCalls

2020-09-09 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86546

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


[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z

2020-09-09 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547

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


[PATCH] D87388: [Analyzer] Model default constructors of containers

2020-09-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, vsavchenko, gamesh411.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, 
whisperity.
Herald added a reviewer: Szelethus.
baloghadamsoftware requested review of this revision.

Model default constructors of containers by setting their abstract `begin()` 
and `end()` symbols to equal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87388

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -32,6 +32,23 @@
// expected-note@-1{{$V.end()}}
 }
 
+
+///
+/// C O N T A I N E R   C O N S T R U C T O R S
+///
+
+
+// Default Constructor
+
+void default_constructor() {
+  std::vector V;
+
+  clang_analyzer_eval(clang_analyzer_container_begin(V) ==
+  clang_analyzer_container_end(V));
+  // expected-warning@-2{{TRUE}}
+  // expected-note@-3   {{TRUE}}
+}
+
 
 ///
 /// C O N T A I N E R   A S S I G N M E N T S
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -157,8 +157,6 @@
 bool isSimpleComparisonOperator(OverloadedOperatorKind OK);
 bool isSimpleComparisonOperator(BinaryOperatorKind OK);
 ProgramStateRef removeIteratorPosition(ProgramStateRef State, SVal Val);
-ProgramStateRef relateSymbols(ProgramStateRef State, SymbolRef Sym1,
-  SymbolRef Sym2, bool Equal);
 const ExplodedNode *findCallEnter(const ExplodedNode *Node, const Expr *Call);
 
 } // namespace
@@ -777,38 +775,6 @@
   return State;
 }
 
-ProgramStateRef relateSymbols(ProgramStateRef State, SymbolRef Sym1,
-  SymbolRef Sym2, bool Equal) {
-  auto &SVB = State->getStateManager().getSValBuilder();
-
-  // FIXME: This code should be reworked as follows:
-  // 1. Subtract the operands using evalBinOp().
-  // 2. Assume that the result doesn't overflow.
-  // 3. Compare the result to 0.
-  // 4. Assume the result of the comparison.
-  const auto comparison =
-SVB.evalBinOp(State, BO_EQ, nonloc::SymbolVal(Sym1),
-  nonloc::SymbolVal(Sym2), SVB.getConditionType());
-
-  assert(comparison.getAs() &&
-"Symbol comparison must be a `DefinedSVal`");
-
-  auto NewState = State->assume(comparison.castAs(), Equal);
-  if (!NewState)
-return nullptr;
-
-  if (const auto CompSym = comparison.getAsSymbol()) {
-assert(isa(CompSym) &&
-   "Symbol comparison must be a `SymIntExpr`");
-assert(BinaryOperator::isComparisonOp(
-   cast(CompSym)->getOpcode()) &&
-   "Symbol comparison must be a comparison");
-return assumeNoOverflow(NewState, cast(CompSym)->getLHS(), 2);
-  }
-
-  return NewState;
-}
-
 const ExplodedNode *findCallEnter(const ExplodedNode *Node, const Expr *Call) {
   while (Node) {
 ProgramPoint PP = Node->getLocation();
Index: clang/lib/StaticAnalyzer/Checkers/Iterator.h
===
--- clang/lib/StaticAnalyzer/Checkers/Iterator.h
+++ clang/lib/StaticAnalyzer/Checkers/Iterator.h
@@ -144,7 +144,8 @@
 
 namespace iterator {
 
-bool isIteratorType(const QualType &Type);
+bool isIteratorType(const QualType &QTyp);
+bool isIteratorType(const Type* Typ);
 bool isIterator(const CXXRecordDecl *CRD);
 bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isInsertCall(const FunctionDecl *Func);
@@ -179,6 +180,8 @@
 const SVal &Distance);
 ProgramStateRef assumeNoOverflow(ProgramStateRef State, SymbolRef Sym,
  long Scale);
+ProgramStateRef relateSymbols(ProgramStateRef State, SymbolRef Sym1,
+  SymbolRef Sym2, bool Equal);
 bool compare(ProgramStateRef State, SymbolRef Sym1, SymbolRef Sym2,
  BinaryOperator::Opcode Opc);
 bool compare(ProgramStateRef State, NonLoc NL1, NonLoc NL2,
Index: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
===
--

[PATCH] D87239: [analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

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

@steakhal Ping.

> I completely agree with you.

So, how should we proceed? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87239

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


[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.

2020-09-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 290754.
hokein marked an inline comment as done.
hokein added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/enable_if.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -53,14 +53,12 @@
 return 2;
   }
   static constexpr int foo2() {
-return AA::getB(); // expected-error{{no matching function for call to 'getB'}} \
-  // expected-note {{subexpression not valid in a constant expression}}
+return AA::getB(); // expected-error{{no matching function for call to 'getB'}}
   }
 };
 // FIXME: should we suppress the "be initialized by a constant expression" diagnostic?
 constexpr auto x2 = AA::foo2(); // expected-error {{be initialized by a constant expression}} \
- // expected-note {{in instantiation of member function}} \
- // expected-note {{in call to}}
+ // expected-note {{in instantiation of member function}}
 }
 
 // verify no assertion failure on violating value category.
Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -2,7 +2,7 @@
 
 struct X {
   int Y;
-  constexpr X() // expected-error {{constexpr constructor never produces}}
+  constexpr X()
   : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 // no crash on evaluating the constexpr ctor.
@@ -15,8 +15,8 @@
 
 struct X3 {
   int Y;
-  constexpr X3() // expected-error {{constexpr constructor never produces}}
-  : Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}}
+  constexpr X3()
+  : Y(({ foo(); })) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 
 struct CycleDelegate {
Index: clang/test/SemaCXX/enable_if.cpp
===
--- clang/test/SemaCXX/enable_if.cpp
+++ clang/test/SemaCXX/enable_if.cpp
@@ -414,8 +414,8 @@
 
 template  constexpr int callTemplated() { return templated(); }
 
-constexpr int B = 10 + // expected-error {{initialized by a constant expression}}
-callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}} expected-note {{in call to 'callTemplated()'}} expected-note@-3 {{subexpression not valid in a constant expression}}
+constexpr int B = 10 +// expected-error {{initialized by a constant expression}}
+  callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}}
 static_assert(callTemplated<1>() == 1, "");
 }
 
Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify
+
+// verify no value-dependent-assertion crash in constexpr function body.
+class Foo {
+  constexpr Foo() {
+while (invalid()) {
+} // expected-error {{use of undeclared identifier}}
+if (invalid()) {
+} // expected-error {{use of undeclared identifier}}
+  }
+};
+
+constexpr void test1() {
+  while (invalid()) {
+  } // expected-error {{use of undeclared identifier}}
+  if (invalid()) {
+  } // expected-error {{use of undeclared identifier}}
+}
+
+struct A {
+  int *p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+  constexpr ~A() { delete p; }
+};
+constexpr int test2() {
+  A a;
+  return 1;
+}
+
+constexpr int test3() {
+  return invalid(); // expected-error {{use of undeclared identifier}}
+}
+
+constexpr int test4() {
+  if (invalid()) // expected-error {{use of undeclared identifier}}
+return 1;
+  else
+return 0;
+}
+
+constexpr int test5() {
+  for (;; a++)
+; // expected-error {{use of undeclared identifier}}
+  return 1;
+}
+
+constexpr int test6() {
+  int n = 0;
+  switch (n) {
+for (;; a++) { // expected-error {{use of undeclared identifier}}
+case 0:;
+}
+  }
+  return 0;
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprC

[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-09 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram accepted this revision.
tmsriram added a comment.
This revision is now accepted and ready to land.

This LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.

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



Comment at: clang/lib/AST/ExprConstant.cpp:4583
   if (!InitE)
 return getDefaultInitValue(VD->getType(), Val);
 

rsmith wrote:
> The initializer might also be null because the variable is type-dependent 
> (eg, `X x;`), in which case assuming default-init is wrong. 
> We should check for that and treat it like a value-dependent initializer.
I think you're right, added the check here, but unfortunately I didn't see 
noticeable behavior changes, and didn't manage to construct one (I confirmed 
that `decltype(invalid()) x;` will trigger this path).



Comment at: clang/lib/AST/ExprConstant.cpp:4961
 }
+if (IS->getCond()->isValueDependent())
+  return EvaluateDependentExpr(IS->getCond(), Info);

rsmith wrote:
> rsmith wrote:
> > hokein wrote:
> > > The `if` stmt (the same to `while`, `for`) is tricky -- if the condition 
> > > is value-dependent, then we don't know which branch we should run into.
> > > 
> > > - returning a ESR_Succeeded may lead to a bogus diagnostic ("reach the 
> > > end of the function");
> > > - returning a ESR_Failed may lead to a bogus diagnostic ("never produce a 
> > > constexpr"); 
> > > 
> > > I guess what we want is to stop the evaluation, and indicate that we hit 
> > > a value-dependent expression and we don't know how to evaluate it, but 
> > > still treat the constexpr function as potential constexpr (but no extra 
> > > diagnostics being emitted), but the current `EvalStmtResult` is not 
> > > sufficient, maybe we need a new enum.
> > We should only produce the "never produce a constant expression" diagnostic 
> > if we also produce a CCEDiag/FFDiag, so I think returning ESR_Failed here 
> > should work.
> Should this check live in EvaluateCond instead?
> Should this check live in EvaluateCond instead?

there is a subtle difference -- doing it outside (not matter succeed or fail) 
will stop any execution of the following code, while doing it in `EvaluateCond` 
may continue the remaining code path if it succeeds, which may introduce bogus 
diagnostics, e.g. emitting a diagnostic `constexpr evaluation hit maximum step 
limit; possible infinite loop?` for the following example.

```
constexpr int foo() {
  while (invalid()) {} 
  return 1;
}
```

Another point is that -- looks like if we just return `false` if it is a 
value-dependent expr in `EvaluateCond`, it improves diagnostics (` function 
never produces ` and `reached end of` diagnostics are suppressed) for the 
following example


```
 constexpr int test4() { // expected-error {{constexpr function never produces 
a constant expression}}
  if (invalid()) // expected-error {{use of undeclared identifier}}
return 1;
  else
return 0;
}  // expected-note {{control reached end of constexpr function}}
```



Comment at: clang/lib/AST/ExprConstant.cpp:5053
 FullExpressionRAII IncScope(Info);
 if (!EvaluateIgnoredValue(Info, FS->getInc()) || !IncScope.destroy())
   return ESR_Failed;

rsmith wrote:
> Missing value dependence check here.
ah, right. Added one test.



Comment at: clang/lib/AST/ExprConstant.cpp:8440
 } else {
+  if (SubExpr->isValueDependent())
+return EvaluateDependentExpr(SubExpr, Info);

rsmith wrote:
> How does this happen?
I think this is a similar escaped case to CXXNewExpr as well. 



Comment at: clang/lib/AST/ExprConstant.cpp:9145
   } else if (Init) {
+if (Init->isValueDependent())
+  return EvaluateDependentExpr(Init, Info);

rsmith wrote:
> How does this happen? Do we not propagate value-dependence from initializers 
> to new-expressions?
this happens in the following case (during the constructor call), the 
dependence-bits of `CXXNewExpr` are correct -- it is value-dependent, 
instantiation-dependent, contains-errors.

However, we run into this codepath because the `CXXDefaultInitExpr` doesn't 
have any dependence-bits being set, in fact, it is always none, I think this is 
a bug, fixing in https://reviews.llvm.org/D87382.

With that fix, we don't need this check anymore (the same to other two places).

```
struct A {
  int* p = new int(invalid());
}
constexpr int test2() {
  A a;
  return 1;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

___
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-09 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.

LGTM as well, per llvm-dev discussion. I think you've done all the due 
diligence we can expect.

Do you plan to also work on MSSA-based MemCpyOpt? I expect that one will have a 
large positive impact on Rust code, where lack of cross-BB memcpy elision is a 
big issue right now.


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] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

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

In D79431#2215610 , @Szelethus wrote:

> Ah, okay, silly me. Didn't catch that. Then the message is OK for now.
>
> edit: Describing //how// the violation happened might be a valuable for 
> development purposes as well.

What if we'd add a `toString` method to the constraints and we'd add this to 
`Msg`? This way we'd know the contents of the constraint, thus we we'd know 
//how// the constraint is violated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

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

In D79431#2263690 , @martong wrote:

> In D79431#2215610 , @Szelethus wrote:
>
>> Ah, okay, silly me. Didn't catch that. Then the message is OK for now.
>>
>> edit: Describing //how// the violation happened might be a valuable for 
>> development purposes as well.
>
> What if we'd add a `toString` method to the constraints and we'd add this to 
> `Msg`? This way we'd know the contents of the constraint, thus we we'd know 
> //how// the constraint is violated.

I mean we'd know what is not satisfied. But, to know why exactly that is not 
satisfied we should dump the whole `State` but that's obviously not an option. 
Perhaps we could track which symbols and expressions are participating in the 
assumption related to the constraint and we could dump only those, but this 
seems to be a very complex approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D87394: [PowerPC][Power10] Implementation of 128-bit Binary Vector Mod and Sign Extend builtins

2020-09-09 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: PowerPC, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.
Herald added subscribers: steven.zhang, kbarton.
Conanap requested review of this revision.

This patch implements 128-bit Binary Vector Mod and Sign Extend builtins for 
PowerPC10.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87394

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  clang/test/CodeGen/builtins-ppc-p9vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrAltivec.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
  llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-sign-extend.ll
@@ -0,0 +1,67 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; This test case aims to test vector sign extend builtins.
+
+declare <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsb2d(<16 x i8>) nounwind readnone
+declare <4 x i32> @llvm.ppc.altivec.vextsh2w(<8 x i16>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsh2d(<8 x i16>) nounwind readnone
+declare <2 x i64> @llvm.ppc.altivec.vextsw2d(<4 x i32>) nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vextsd2q(<2 x i64>) nounwind readnone
+
+define <4 x i32> @test_vextsb2w(<16 x i8> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsb2w:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsb2w v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <4 x i32> @llvm.ppc.altivec.vextsb2w(<16 x i8> %x)
+  ret <4 x i32> %tmp
+}
+
+define <2 x i64> @test_vextsb2d(<16 x i8> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsb2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsb2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsb2d(<16 x i8> %x)
+  ret <2 x i64> %tmp
+}
+
+define <4 x i32> @test_vextsh2w(<8 x i16> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsh2w:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsh2w v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <4 x i32> @llvm.ppc.altivec.vextsh2w(<8 x i16> %x)
+  ret <4 x i32> %tmp
+}
+
+define <2 x i64> @test_vextsh2d(<8 x i16> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsh2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsh2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsh2d(<8 x i16> %x)
+  ret <2 x i64> %tmp
+}
+
+define <2 x i64> @test_vextsw2d(<4 x i32> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsw2d:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsw2d v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vextsw2d(<4 x i32> %x)
+  ret <2 x i64> %tmp
+}
+
+define <1 x i128> @test_vextsd2q(<2 x i64> %x) nounwind readnone {
+; CHECK-LABEL: test_vextsd2q:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vextsd2q v2, v2
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vextsd2q(<2 x i64> %x)
+  ret <1 x i128> %tmp
+}
Index: llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-modulo.ll
@@ -10,6 +10,30 @@
 ; The vector modulo instructions operate on signed and unsigned words
 ; and doublewords.
 
+; The vector modulo instructions operate on signed and unsigned words,
+; doublewords and 128-bit values.
+
+declare <1 x i128> @llvm.ppc.altivec.vmodsq(<1 x i128>, <1 x i128>) nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vmoduq(<1 x i128>, <1 x i128>) nounwind readnone
+
+define <1 x i128> @test_vmodsq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vmodsq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vmodsq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vmodsq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vmoduq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vmoduq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vmoduq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vmoduq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
+
 define <2 x i64> @test_vmodud(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vmodud:
 ; CHECK:   # %bb.0: # %entry
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerP

[PATCH] D87358: [clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

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



Comment at: clang/lib/AST/Type.cpp:2339
   case BuiltinType::SveInt32:
-return Ctx.IntTy;
+return IsILP32 ? Ctx.LongTy : Ctx.IntTy;
   case BuiltinType::SveUint32:

Rather than comparing with a specific triple, how about getting the information 
from `TargetInfo`, i.e.

  case BuiltinType::SveInt32:
Ctx.getTargetInfo().getLongWidth() == 32 ? Ctx.LongTy : Ctx.IntTy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87358

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-09-09 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 aside from a commenting nit. Thank you for the work on this!




Comment at: clang/include/clang/AST/Stmt.h:1180
+
+  /// \returns the likelihood of the branches of an if statement.
+  static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);

This only returns one value, so it can't return the likelihood of "the 
branches". How about something along the lines of:

`returns the likelihood of the 'then' branch of an 'if' statement. The 'else' 
branch is required to determine whether both branches specify the same 
likelihood, which impacts the result.`


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

https://reviews.llvm.org/D85091

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


[PATCH] D87395: Sema: add support for `__attribute__((__swift_objc_members__))`

2020-09-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added a reviewer: aaron.ballman.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
compnerd requested review of this revision.

This adds the `__swift_objc_members__` attribute to the semantic
analysis.  It allows for annotating ObjC interfaces to provide Swift
semantics indicating that the types derived from this interface will be
back-bridged to Objective-C to allow interoperability with Objective-C
and Swift.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87395

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-swift_objc_members.m


Index: clang/test/SemaObjC/attr-swift_objc_members.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_objc_members.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+#if !__has_attribute(swift_objc_members)
+#error cannot verify precense of swift_objc_members attribute
+#endif
+
+__attribute__((__swift_objc_members__))
+__attribute__((__objc_root_class__))
+@interface I
+@end
+
+__attribute__((swift_objc_members))
+@protocol P
+@end
+// expected-error@-3 {{'swift_objc_members' attribute only applies to 
Objective-C interfaces}}
+
+__attribute__((swift_objc_members))
+extern void f(void);
+// expected-error@-2 {{'swift_objc_members' attribute only applies to 
Objective-C interfaces}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -150,6 +150,7 @@
 // CHECK-NEXT: SwiftError (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
 // CHECK-NEXT: SwiftErrorResult (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: SwiftIndirectResult (SubjectMatchRule_variable_is_parameter)
+// CHECK-NEXT: SwiftObjCMembers (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: TLSModel (SubjectMatchRule_variable_is_thread_local)
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7542,6 +7542,9 @@
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;
+  case ParsedAttr::AT_SwiftObjCMembers:
+handleSimpleAttribute(S, D, AL);
+break;
 
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3381,6 +3381,14 @@
   }];
 }
 
+def SwiftObjCMembersDocs : Documentation {
+  let Content = [{
+The ``swift_objc_members`` attribute maps to the ``@objcMembers`` Swift
+attribute, which indicates that Swift members of this class, its subclasses, 
and
+all extensions thereof, will implicitly be exposed back to Objective-C.
+  }];
+}
+
 def SwiftErrorDocs : Documentation {
   let Category = SwiftDocs;
   let Heading = "swift_error";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2118,6 +2118,12 @@
   let ASTNode = 0;
 }
 
+def SwiftObjCMembers : Attr {
+  let Spellings = [GNU<"swift_objc_members">];
+  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Documentation = [SwiftObjCMembersDocs];
+}
+
 def SwiftError : InheritableAttr {
   let Spellings = [GCC<"swift_error">];
   let Args = [


Index: clang/test/SemaObjC/attr-swift_objc_members.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_objc_members.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+#if !__has_attribute(swift_objc_members)
+#error cannot verify precense of swift_objc_members attribute
+#endif
+
+__attribute__((__swift_objc_members__))
+__attribute__((__objc_root_class__))
+@interface I
+@end
+
+__attribute__((swift_objc_members))
+@protocol P
+@end
+// expected-error@-3 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
+
+__attribute__((swift_objc_members))
+extern void f(void);
+// expected-error@-2 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -150,6 +150,7 @@

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

2020-09-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added a reviewer: aaron.ballman.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
compnerd requested review of this revision.

Extend the semantic attributes that clang processes for Swift to include
`swift_typedef_bridged`.  This attribute enables typedefs to be bridged
into Swift with a bridged name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87396

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-swift_bridged_typedef.m


Index: clang/test/SemaObjC/attr-swift_bridged_typedef.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_bridged_typedef.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+@interface NSString
+@end
+
+typedef NSString *NSStringAlias __attribute__((__swift_bridged_typedef__));
+
+struct __attribute__((swift_bridged_typedef)) S {};
+// expected-error@-1 {{'swift_bridged_typedef' attribute only applies to 
typedefs}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -146,6 +146,7 @@
 // CHECK-NEXT: Section (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, 
SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: SpeculativeLoadHardening (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
+// CHECK-NEXT: SwiftBridgedTypedef (SubjectMatchRule_type_alias)
 // CHECK-NEXT: SwiftContext (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: SwiftError (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
 // CHECK-NEXT: SwiftErrorResult (SubjectMatchRule_variable_is_parameter)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7539,6 +7539,9 @@
 break;
 
   // Swift attributes.
+  case ParsedAttr::AT_SwiftBridgedTypedef:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3381,6 +3381,15 @@
   }];
 }
 
+def SwiftBridgedTypedefDocs : Documentation {
+  let Content = [{
+The ``swift_bridged_typedef`` attribute indicates that when the typedef to 
which
+the attribute appertains is imported into Swift, it should refer to the bridged
+Swift type (e.g. Swift's ``String``) rather than the Objective-C type as 
written
+(e.g. ``NSString``).
+  }];
+}
+
 def SwiftObjCMembersDocs : Documentation {
   let Content = [{
 The ``swift_objc_members`` attribute maps to the ``@objcMembers`` Swift
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2118,6 +2118,12 @@
   let ASTNode = 0;
 }
 
+def SwiftBridgedTypedef : Attr {
+  let Spellings = [GNU<"swift_bridged_typedef">];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag, "typedefs">;
+  let Documentation = [SwiftBridgedTypedefDocs];
+}
+
 def SwiftObjCMembers : Attr {
   let Spellings = [GNU<"swift_objc_members">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;


Index: clang/test/SemaObjC/attr-swift_bridged_typedef.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_bridged_typedef.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+@interface NSString
+@end
+
+typedef NSString *NSStringAlias __attribute__((__swift_bridged_typedef__));
+
+struct __attribute__((swift_bridged_typedef)) S {};
+// expected-error@-1 {{'swift_bridged_typedef' attribute only applies to typedefs}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -146,6 +146,7 @@
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: SpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: SwiftBridgedTypedef (SubjectMatchRule_type_alias)
 // CHECK-NEXT: SwiftCon

[PATCH] D86796: [Sema] Address-space sensitive index check for unbounded arrays

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

In D86796#2263557 , 
@chrish_ericsson_atx wrote:

> Ping?

Sorry for the delayed review, but this managed to fall off my radar. Thank you 
for the ping!




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8841-8844
+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;

I'd combine this with the above diagnostic given how similar they are:
```
def warn_exceeds_max_addressable_bounds : Warning<
  "%select{array index %1|the pointer incremented by %1}0 refers past the last 
possible element for an array in %2-bit "
  "address space containing %3-bit (%4-byte) elements (max possible %5 
element%s6)">,
  InGroup;
```



Comment at: clang/lib/Sema/SemaChecking.cpp:14043
+  ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
+  bool isUnboundedArray = (BaseType == nullptr);
+  if (EffectiveType->isDependentType() ||

`IsUnboundedArray` per our usual coding style rules.



Comment at: clang/lib/Sema/SemaChecking.cpp:14063
+  if (isUnboundedArray) {
+if (index.isUnsigned() || !index.isNegative()) {
+  const auto &ASTC = getASTContext();

ebevhan wrote:
> This could be early return to avoid the indentation.
+1 to using early return here. I might even get rid of `isUnboundedArray` and 
just use `!BaseType`



Comment at: clang/lib/Sema/SemaChecking.cpp:14071
+  CharUnits ElemBytes = ASTC.getTypeSizeInChars(EffectiveType);
+  llvm::APInt apElemBytes(index.getBitWidth(), ElemBytes.getQuantity());
+  // If index has more active bits than address space, we already know

`ElemBytes` per usual coding style rules.



Comment at: clang/lib/Sema/SemaChecking.cpp:14077
+  if (index.getActiveBits() <= AddrBits) {
+bool overflow;
+llvm::APInt product(index);

`Overflow`, `Product` (I'll stop commenting on them -- just take a quick pass 
to make sure the new variables you introduce meet style rules.)



Comment at: clang/lib/Sema/SemaChecking.cpp:14085
+
+  // Need to compute max possible elements in address space, since  that
+  // is included in diag message.

since  that -> since that

(removes a whitespace)



Comment at: clang/lib/Sema/SemaChecking.cpp:14094-14096
+  unsigned DiagID = diag::warn_ptr_arith_exceeds_max_addressable_bounds;
+  if (ASE)
+DiagID = diag::warn_array_index_exceeds_max_addressable_bounds;

```
unsigned DiagID = ASE ?
  diag::warn_array_index_exceeds_max_addressable_bounds :
  diag::warn_ptr_arith_exceeds_max_addressable_bounds;
```



Comment at: clang/lib/Sema/SemaChecking.cpp:14100
+  // dependent CharUnits)
+  DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
+  PDiag(DiagID)

It's not clear to me whether we need to pay the extra expense of doing 
reachability checks for the diagnostic -- do you have evidence that there would 
be a high false positive rate if we always emit the diagnostic?



Comment at: clang/lib/Sema/SemaChecking.cpp:14111
+// Try harder to find a NamedDecl to point at in the note.
+while (const ArraySubscriptExpr *ASE =
+   dyn_cast(BaseExpr))

You can use `const auto *` here since the type is spelled out in the 
initialization. Same below.



Comment at: clang/lib/Sema/SemaChecking.cpp:14121
+  if (ND)
+DiagRuntimeBehavior(ND->getBeginLoc(), BaseExpr,
+PDiag(diag::note_array_declared_here) << ND);

Similar comment here about reachability.



Comment at: clang/test/Sema/const-eval.c:143
 // expressions, like we do for integers.
-void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a;
-void *PR28739b = &PR28739b + (__int128)(unsigned long)-1;
-__int128 PR28739c = (&PR28739c + (__int128)(unsigned long)-1) - &PR28739c;
-void *PR28739d = &(&PR28739d)[(__int128)(unsigned long)-1];
+void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a;  // 
expected-warning {{refers past the last possible element}}
+void *PR28739b = &PR28739b + (__int128)(unsigned long)-1;  // 
expected-warning {{refers past the last possible element}}

You should spell out the full form of the diagnostic the first time it appears 
in a test. You can use the shortened form for subsequent diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86796


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 10 inline comments as done.
compnerd added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2122
+def SwiftError : InheritableAttr {
+  let Spellings = [GCC<"swift_error">];
+  let Args = [

aaron.ballman wrote:
> Is this attribute also supported by GCC? It looked like it wasn't from my 
> quick check, so I'd recommend switching the spelling to be `Clang` instead. 
> Note, this will give you `[[clang::swift_error(...)]]` in both C and C++ as 
> well. If you only want the GNU spelling, use `GNU`.
Ah, oops, this should be `GNU`.



Comment at: clang/include/clang/Basic/Attr.td:2128
+  ];
+  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
+  let Documentation = [SwiftErrorDocs];

aaron.ballman wrote:
> Should this apply to function-like things such as blocks or function 
> pointers? If so, you should use `HasFunctionProto`.
I believe not.



Comment at: clang/include/clang/Basic/AttrDocs.td:3394
+parameter. Currently, the error parameter is always the last parameter of type
+``NSError**`` or ``CFErrorRef*``.  Swift will remove the error parameter from
+the imported API. When calling the API, Swift will always pass a valid address

aaron.ballman wrote:
> Canonical type or are typedefs to these types also fine? May want to mention 
> that the type has to be cv-unqualified, but I do wonder whether something 
> like `NSError * const *` is fine.
I am definitely not the authority on this, but I believe that the common thing 
is to take `NSError **` or `CFErrorRef **` by canonical name.  The cv-qualified 
versions, except on the outermost pointer, is something that can be treated as 
valid, though it is certainly extremely unusual.  I've added test cases for 
them as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 290767.
compnerd marked an inline comment as done.
compnerd added a comment.

Address feedback from @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-swift-error.m

Index: clang/test/SemaObjC/attr-swift-error.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift-error.m
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
+
+@class NSError;
+
+#if __SIZEOF_POINTER__ == 4
+typedef unsigned char BOOL;
+#else
+typedef _Bool BOOL;
+#endif
+
+typedef struct __attribute__((__objc_bridge__(NSError))) __CFError *CFErrorRef;
+
+extern int f0(void) __attribute__((__swift_error__));
+// expected-error@-1 {{'__swift_error__' attribute takes one argument}}
+extern int f1(void) __attribute__((__swift_error__(invalid)));
+// expected-warning@-1 {{'__swift_error__' attribute argument not supported: 'invalid'}}
+extern int f2(void) __attribute__((__swift_error__(none,zero_result)));
+// expected-error@-1 {{use of undeclared identifier 'zero_result'}}
+
+@interface Erroneous
+- (BOOL)m0:(NSError **)error __attribute__((__swift_error__(none)));
+- (BOOL)m1:(NSError **)error __attribute__((__swift_error__(nonnull_error)));
+- (BOOL)m2:(NSError **)error __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a method returning a pointer}}
+- (BOOL)m3:(NSError **)error __attribute__((__swift_error__(nonzero_result)));
+- (BOOL)m4:(NSError **)error __attribute__((__swift_error__(zero_result)));
+
+- (Undeclared)n0:(NSError **)error __attribute__((__swift_error__(none)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n1:(NSError **)error __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n2:(NSError **)error __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n3:(NSError **)error __attribute__((__swift_error__(nonzero_result)));
+// expected-error@-1 {{expected a type}}
+// FIXME: the follow-on warning should really be suppressed, but apparently
+// having an ill-formed return type doesn't mark anything as invalid.
+// expected-error@-4 {{can only be applied}}
+- (Undeclared)n4:(NSError **)error __attribute__((__swift_error__(zero_result)));
+// expected-error@-1 {{expected a type}}
+// FIXME: the follow-on warning should really be suppressed, but apparently
+// having an ill-formed return type doesn't mark anything as invalid.
+// expected-error@-4 {{can only be applied}}
+
+- (instancetype)o0 __attribute__((__swift_error__(none)));
+- (instancetype)o1 __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o2 __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o3 __attribute__((__swift_error__(nonzero_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o4 __attribute__((__swift_error__(zero_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+
+// This is unconventional and very odd but we do process it.
+- (int)q0:(const NSError **)error __attribute__((__swift_error__(nonzero_result)));
+- (int)q1:(const NSError * const *)error __attribute__((__swift_error__(nonzero_result)));
+- (int)q2:(NSError * const *)error __attribute__((__swift_error__(nonzero_result)));
+@end
+
+extern BOOL m0(CFErrorRef *) __attribute__((__swift_error__(none)));
+extern BOOL m1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));
+extern BOOL m2(CFErrorRef *) __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a function returning a pointer}}
+extern BOOL m3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result)));
+extern BOOL m4(CFErrorRef *) __attribute__((__swift_error__(zero_result)));
+
+extern Undeclared n0(CFErrorRef *) __attribute__((__swift_error__(none)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n2(CFErrorRef *) __attribute__((__swift_error__(null_result)));
+// 

[PATCH] D87338: [Driver][PGO] Driver support for de-Optimizing cold functions (PATCH 2/2)

2020-09-09 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 290769.
myhsu added a comment.

Fix a bug in driver that accidentally made this feature turn on by default


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

https://reviews.llvm.org/D87338

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/deopt-cold-funcs.c
  clang/test/Driver/gold-lto-deopt-cold-funcs.c

Index: clang/test/Driver/gold-lto-deopt-cold-funcs.c
===
--- /dev/null
+++ clang/test/Driver/gold-lto-deopt-cold-funcs.c
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -### -fprofile-instr-use -fprofile-deopt-cold %t.o -flto 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-BASE %s
+
+// RUN: %clang -### -fprofile-instr-use -fprofile-deopt-cold -fprofile-deopt-cold-percent=87 \
+// RUN: %t.o -flto 2>&1 \
+// RUN: | FileCheck --check-prefixes=CHECK-BASE,CHECK-PERCENT %s
+
+// CHECK-BASE: "-plugin-opt=-profile-deopt-cold=true"
+// CHECK-PERCENT: "-plugin-opt=-profile-deopt-cold-percent=87"
Index: clang/test/Driver/deopt-cold-funcs.c
===
--- /dev/null
+++ clang/test/Driver/deopt-cold-funcs.c
@@ -0,0 +1,15 @@
+// RUN: %clang -### -fprofile-instr-use -fprofile-deopt-cold -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-BASE %s
+
+// RUN: %clang -### -fprofile-instr-use \
+// RUN: -fprofile-deopt-cold -fprofile-deopt-cold-percent=87 \
+// RUN: -c %s 2>&1 \
+// RUN: | FileCheck --check-prefixes=CHECK-BASE,CHECK-PERCENT %s
+
+// Shouldn't do anything if it's not using PGO profile
+// RUN: %clang -### -fprofile-deopt-cold -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-PGO %s
+
+// CHECK-BASE: "-mllvm" "-profile-deopt-cold=true"
+// CHECK-PERCENT: "-mllvm" "-profile-deopt-cold-percent=87"
+// CHECK-NO-PGO-NOT: "-profile-deopt-cold=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -516,6 +516,16 @@
   llvm::sys::path::append(Path, "default.profdata");
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=cs-profile-path=") +
  Path));
+// Propagate -profile-deopt-cold options
+if (Args.hasFlag(options::OPT_fprofile_deopt_cold,
+ options::OPT_fno_profile_deopt_cold, false)) {
+  CmdArgs.push_back("-plugin-opt=-profile-deopt-cold=true");
+  Arg *A = Args.getLastArg(options::OPT_fprofile_deopt_cold_percent_EQ);
+  if (A) {
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-plugin-opt=-profile-deopt-cold-percent=") + A->getValue()));
+  }
+}
   }
 
   // Need this flag to turn on new pass manager via Gold plugin.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -824,6 +824,19 @@
   CmdArgs.push_back(
   Args.MakeArgString(Twine("-fprofile-instrument-use-path=") + Path));
 }
+// Tell profile passes to deopt cold functions.
+if (Args.hasFlag(options::OPT_fprofile_deopt_cold,
+ options::OPT_fno_profile_deopt_cold, false)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-profile-deopt-cold=true");
+
+  if (Arg *A =
+  Args.getLastArg(options::OPT_fprofile_deopt_cold_percent_EQ)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-profile-deopt-cold-percent=") + A->getValue()));
+  }
+}
   }
 
   bool EmitCovNotes = Args.hasFlag(options::OPT_ftest_coverage,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -793,6 +793,17 @@
 Alias;
 defm debug_info_for_profiling : OptInFFlag<"debug-info-for-profiling",
   "Emit extra debug info to make sample profile more accurate">;
+
+// New option to deopt cold code.
+def fprofile_deopt_cold : Flag<["-"], "fprofile-deopt-cold">,
+Group, Flags<[CoreOption]>,
+HelpText<"Do not optimize functions that profiling indicates are cold">;
+def fno_profile_deopt_cold : Flag<["-"], "fno-profile-deopt-cold">,
+Group, Flags<[CoreOption]>;
+def fprofile_deopt_cold_percent_EQ : Joined<["-"], "fprofile-deopt-cold-percent=">,
+Group, Flags<[CoreOption]>,
+HelpText<"Do not optimize functions whose profiling count is lower than this percentage">;
+
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
 Group, Flags<[CoreOption]>,
 HelpText<"Generate instrumented 

[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2128
+  ];
+  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
+  let Documentation = [SwiftErrorDocs];

compnerd wrote:
> aaron.ballman wrote:
> > Should this apply to function-like things such as blocks or function 
> > pointers? If so, you should use `HasFunctionProto`.
> I believe not.
Correct, it's just declared functions for now.



Comment at: clang/include/clang/Basic/AttrDocs.td:3394
+parameter. Currently, the error parameter is always the last parameter of type
+``NSError**`` or ``CFErrorRef*``.  Swift will remove the error parameter from
+the imported API. When calling the API, Swift will always pass a valid address

compnerd wrote:
> aaron.ballman wrote:
> > Canonical type or are typedefs to these types also fine? May want to 
> > mention that the type has to be cv-unqualified, but I do wonder whether 
> > something like `NSError * const *` is fine.
> I am definitely not the authority on this, but I believe that the common 
> thing is to take `NSError **` or `CFErrorRef **` by canonical name.  The 
> cv-qualified versions, except on the outermost pointer, is something that can 
> be treated as valid, though it is certainly extremely unusual.  I've added 
> test cases for them as well.
`NSError * const *` actually does not really work; the whole point is that this 
is an out-parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-09-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added a comment.

Thanks for your feedback during the review.




Comment at: clang/include/clang/AST/Stmt.h:1180
+
+  /// \returns the likelihood of the branches of an if statement.
+  static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);

aaron.ballman wrote:
> This only returns one value, so it can't return the likelihood of "the 
> branches". How about something along the lines of:
> 
> `returns the likelihood of the 'then' branch of an 'if' statement. The 'else' 
> branch is required to determine whether both branches specify the same 
> likelihood, which impacts the result.`
Good catch, I'll use your suggestion.


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

https://reviews.llvm.org/D85091

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


[PATCH] D87239: [analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

2020-09-09 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

In D87239#2259428 , @martong wrote:

> So, the problem is rather that the constraint check should be done in 
> checkPreCall, but that should be in an NFC refactoring.

You are right, but we can not fix everything at once. There are quite a few 
changes under review related to the `CStringChecker` already.

In D87239#2263634 , @martong wrote:

>> I completely agree with you.
>
> So, how should we proceed? :)

I'm fine with taking this reponsibilty out from the 
`StdLibraryFunctionsChecker`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87239

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-09 Thread Reid "Away June-Sep" Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1980
 HelpText<"remap file source paths in debug info">;
+def fprofile_prefix_map_QA
+  : Joined<["-"], "fprofile-prefix-map=">, Group,

Any reason for the _QA suffix instead of _EQ?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

Please only make the path absolute if nothing in the prefix map matches. 
Otherwise, the user must embed the CWD into the prefix map, which is needlessly 
difficult for the build system. I believe it is also consistent with the way 
that the debug info prefix map works. It appears to operate on the possibly 
relative source paths received on the command line (-I...).



Comment at: clang/test/Profile/profile-prefix-map.c:12
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c 
nested/profile-prefix-map.c -fprofile-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=PROFILE-PREFIX-MAP %s --implicit-check-not=root
+//

See here, for example, where you must pass `-fprofile-prefix-map=%/t/...`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-09-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1180
+
+  /// \returns the likelihood of the branches of an if statement.
+  static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);

Mordante wrote:
> aaron.ballman wrote:
> > This only returns one value, so it can't return the likelihood of "the 
> > branches". How about something along the lines of:
> > 
> > `returns the likelihood of the 'then' branch of an 'if' statement. The 
> > 'else' branch is required to determine whether both branches specify the 
> > same likelihood, which impacts the result.`
> Good catch, I'll use your suggestion.
s/impacts/affects/ ;)


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

https://reviews.llvm.org/D85091

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


[PATCH] D87118: Add an explicit toggle for the static analyzer in clang-tidy

2020-09-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang-tools-extra/CMakeLists.txt:4
+option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  "Include static analyzer checks in clang-tidy" ON)
+

hans wrote:
> Should this default to CLANG_ENABLE_STATIC_ANALYZER instead of ON?
I had thought about it but decided against it:

- They both default to on so it doesn't matter for the default
- If you turn off CLANG_ENABLE_STATIC_ANALYZER it's not clear you also want to 
disable it for clang-tidy
- It mixes cmake options from two different directories which can be a bit hairy
- Having the two toggles act independently is easier to understand



Comment at: clang/lib/CMakeLists.txt:24
 add_subdirectory(IndexSerialization)
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(StaticAnalyzer)

hans wrote:
> Why does removing the condition here work?
As far as I understand, it just impacts which targets CMake generates. 
clang/lib/FrontendTool/CMakeLists.txt only adds the dep on 
clangStaticAnalyzerFrontend if CLANG_ENABLE_STATIC_ANALYZER is set, so this 
doesn't change what gets built for "clang". If you build all targets, this will 
now always build the analyzer sources and I suppose it makes it a bit easier to 
accidentally depend on clangStaticAnalyzerFrontend , but I don't know of 
another way to be able to link this into clang-tidy when it's not built at all 
over here.



Comment at: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/BUILD.gn:18
+  } else {
+values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=" ]
+  }

hans wrote:
> Why not =0?
Because it's a #cmakedefine01, and the string "0" counts as truthy. See 
http://llvm-cs.pcc.me.uk/utils/gn/build/write_cmake_config.py#15

(That should probably print an error if a #cmakedefine gets a "0" argument 
since that's basically never what you want.)


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

https://reviews.llvm.org/D87118

___
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-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.

Green light from me as well. I think there's still room for improvement for the 
NPM, but this is the right step to move forward infrastructure-wise.

Regarding the MemCpyOpt question from nikic@, please let me know if you want to 
take that over.


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] D87118: Add an explicit toggle for the static analyzer in clang-tidy

2020-09-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/BUILD.gn:18
+  } else {
+values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=" ]
+  }

thakis wrote:
> hans wrote:
> > Why not =0?
> Because it's a #cmakedefine01, and the string "0" counts as truthy. See 
> http://llvm-cs.pcc.me.uk/utils/gn/build/write_cmake_config.py#15
> 
> (That should probably print an error if a #cmakedefine gets a "0" argument 
> since that's basically never what you want.)
Reading that script more, a better answer is "because the behavior of that 
script isn't quite right". It should treat '0' as false-y and all the gn files 
should use `=0` where they currently use `=`. I'll make a separate CL for that, 
but for now this is consistent with everything that's there.


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

https://reviews.llvm.org/D87118

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


[PATCH] D87118: Add an explicit toggle for the static analyzer in clang-tidy

2020-09-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/BUILD.gn:18
+  } else {
+values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=" ]
+  }

thakis wrote:
> thakis wrote:
> > hans wrote:
> > > Why not =0?
> > Because it's a #cmakedefine01, and the string "0" counts as truthy. See 
> > http://llvm-cs.pcc.me.uk/utils/gn/build/write_cmake_config.py#15
> > 
> > (That should probably print an error if a #cmakedefine gets a "0" argument 
> > since that's basically never what you want.)
> Reading that script more, a better answer is "because the behavior of that 
> script isn't quite right". It should treat '0' as false-y and all the gn 
> files should use `=0` where they currently use `=`. I'll make a separate CL 
> for that, but for now this is consistent with everything that's there.
...oh looks like I added a check at least in rG252c4dce6189, but llvm-cs seems 
to be very stale?


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

https://reviews.llvm.org/D87118

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-09-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 2 inline comments as done.
Mordante added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1180
+
+  /// \returns the likelihood of the branches of an if statement.
+  static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);

Quuxplusone wrote:
> Mordante wrote:
> > aaron.ballman wrote:
> > > This only returns one value, so it can't return the likelihood of "the 
> > > branches". How about something along the lines of:
> > > 
> > > `returns the likelihood of the 'then' branch of an 'if' statement. The 
> > > 'else' branch is required to determine whether both branches specify the 
> > > same likelihood, which impacts the result.`
> > Good catch, I'll use your suggestion.
> s/impacts/affects/ ;)
Just in time before I commit this patch :-)


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

https://reviews.llvm.org/D85091

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-09-09 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.
Closed by commit rG08196e0b2e1f: Implements [[likely]] and [[unlikely]] in 
IfStmt. (authored by Mordante).

Changed prior to commit:
  https://reviews.llvm.org/D85091?vs=289979&id=290787#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85091

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Stmt.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/Sema/attr-likelihood.c
  clang/test/SemaCXX/attr-likelihood.cpp
  clang/www/cxx_status.html
  llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp

Index: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
===
--- llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -24,7 +24,6 @@
 #include "llvm/IR/Metadata.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/MisExpect.h"
@@ -48,10 +47,10 @@
 // 'select' instructions. It may be worthwhile to hoist these values to some
 // shared space, so they can be used directly by other passes.
 
-static cl::opt LikelyBranchWeight(
+cl::opt llvm::LikelyBranchWeight(
 "likely-branch-weight", cl::Hidden, cl::init(2000),
 cl::desc("Weight of the branch likely to be taken (default = 2000)"));
-static cl::opt UnlikelyBranchWeight(
+cl::opt llvm::UnlikelyBranchWeight(
 "unlikely-branch-weight", cl::Hidden, cl::init(1),
 cl::desc("Weight of the branch unlikely to be taken (default = 1)"));
 
Index: llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
===
--- llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
+++ llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
@@ -17,6 +17,7 @@
 
 #include "llvm/IR/Function.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 
 namespace llvm {
 
@@ -31,6 +32,8 @@
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
 
+extern cl::opt LikelyBranchWeight;
+extern cl::opt UnlikelyBranchWeight;
 }
 
 #endif
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -987,7 +987,7 @@
 
   [[likely]] and [[unlikely]] attributes
   https://wg21.link/p0479r5";>P0479R5
-  No
+  Clang 12 (partial)
 
 
   typename optional in more contexts
Index: clang/test/SemaCXX/attr-likelihood.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-likelihood.cpp
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -DPEDANTIC -pedantic -fsyntax-only -verify
+
+#if PEDANTIC
+void g() {
+  if (true)
+[[likely]] {} // expected-warning {{use of the 'likely' attribute is a C++20 extension}}
+  else
+[[unlikely]] {} // expected-warning {{use of the 'unlikely' attribute is a C++20 extension}}
+}
+#else
+void a() {
+  if (true)
+[[likely]]; // expected-warning {{conflicting attributes 'likely' are ignored}}
+  else
+[[likely]]; // expected-note {{conflicting attribute is here}}
+}
+
+void b() {
+  if (true)
+[[unlikely]]; // expected-warning {{conflicting attributes 'unlikely' are ignored}}
+  else
+[[unlikely]]; // expected-note {{conflicting attribute is here}}
+}
+
+void c() {
+  if (true)
+[[likely]];
+}
+
+void d() {
+  if (true)
+[[unlikely]];
+}
+
+void g() {
+  if (true)
+[[likely]] {}
+  else
+[[unlikely]] {}
+}
+
+void h() {
+  if (true)
+[[likely]] {}
+  else {
+  }
+}
+
+void i() {
+  if (true)
+[[unlikely]] {}
+  else {
+  }
+}
+
+void j() {
+  if (true) {
+  } else
+[[likely]] {}
+}
+
+void k() {
+  if (true) {
+  } else
+[[likely]] {}
+}
+
+void l() {
+  if (true)
+[[likely]] {}
+  else
+[[unlikely]] if (false) [[likely]] {}
+}
+
+void m() {
+  [[likely]] int x = 42; // expected-error {{'likely' attribute cannot be applied to a declaration}}
+
+  if (x)
+[[unlikely]] {}
+  if (x) {
+[[unlikely]];
+  }
+  switch (x) {
+  case 1:
+[[likely]] {}
+break;
+[[likely]] case 2 : case 3 : {}
+break;
+  }
+
+  do {
+[[unlikely]];
+  } wh

[clang] 08196e0 - Implements [[likely]] and [[unlikely]] in IfStmt.

2020-09-09 Thread Mark de Wever via cfe-commits

Author: Mark de Wever
Date: 2020-09-09T20:48:37+02:00
New Revision: 08196e0b2e1f8aaa8a854585335c17ba479114df

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

LOG: Implements [[likely]] and [[unlikely]] in IfStmt.

This is the initial part of the implementation of the C++20 likelihood
attributes. It handles the attributes in an if statement.

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

Added: 
clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp
clang/test/Sema/attr-likelihood.c
clang/test/SemaCXX/attr-likelihood.cpp

Modified: 
clang/include/clang/AST/Stmt.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Stmt.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/Preprocessor/has_attribute.cpp
clang/www/cxx_status.html
llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 726c61cb0126..1e04e64727a0 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -1098,6 +1098,14 @@ class alignas(void *) Stmt {
   /// de-serialization).
   struct EmptyShell {};
 
+  /// The likelihood of a branch being taken.
+  enum Likelihood {
+LH_Unlikely = -1, ///< Branch has the [[unlikely]] attribute.
+LH_None,  ///< No attribute set or branches of the IfStmt have
+  ///< the same attribute.
+LH_Likely ///< Branch has the [[likely]] attribute.
+  };
+
 protected:
   /// Iterator for iterating over Stmt * arrays that contain only T *.
   ///
@@ -1166,6 +1174,20 @@ class alignas(void *) Stmt {
   static void EnableStatistics();
   static void PrintStats();
 
+  /// \returns the likelihood of a statement.
+  static Likelihood getLikelihood(const Stmt *S);
+
+  /// \returns the likelihood of the 'then' branch of an 'if' statement. The
+  /// 'else' branch is required to determine whether both branches specify the
+  /// same likelihood, which affects the result.
+  static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);
+
+  /// \returns whether the likelihood of the branches of an if statement are
+  /// conflicting. When the first element is \c true there's a conflict and
+  /// the Attr's are the conflicting attributes of the Then and Else Stmt.
+  static std::tuple
+  determineLikelihoodConflict(const Stmt *Then, const Stmt *Else);
+
   /// Dumps the specified AST fragment and all subtrees to
   /// \c llvm::errs().
   void dump() const;

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 2801a4aa1936..5676e9aa1678 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1288,6 +1288,18 @@ def FallThrough : StmtAttr {
   let Documentation = [FallthroughDocs];
 }
 
+def Likely : StmtAttr {
+  // FIXME: Change the date to 201803 once the implementation is finished.
+  let Spellings = [CXX11<"", "likely", 2>, C2x<"clang", "likely">];
+  let Documentation = [LikelihoodDocs];
+}
+
+def Unlikely : StmtAttr {
+  // FIXME: Change the date to 201803 once the implementation is finished.
+  let Spellings = [CXX11<"", "unlikely", 2>, C2x<"clang", "unlikely">];
+  let Documentation = [LikelihoodDocs];
+}
+
 def NoMerge : StmtAttr {
   let Spellings = [Clang<"nomerge">];
   let Documentation = [NoMergeDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d6d5567c7924..6daf9ca67896 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1684,6 +1684,101 @@ Here is an example:
   }];
 }
 
+def LikelihoodDocs : Documentation {
+  let Category = DocCatStmt;
+  let Heading = "likely and unlikely";
+  let Content = [{
+The ``likely`` and ``unlikely`` attributes are used as compiler hints.
+The attributes are used to aid the compiler to determine which branch is
+likely or unlikely to be taken. This is done by marking the branch substatement
+with one of the two attributes.
+
+It isn't allowed to annotate a single statement with both ``likely`` and
+``unlikely``. Annotating the ``true`` and ``false`` branch of an ``if``
+statement with the same likelihood attribute will result in a diagnostic and
+the attributes are ignored on both branches.
+
+These attributes have no effect on the generated code when using
+PGO (Profile-Guided Optimization) or at optimization level 0.
+
+In Clang, the at

[PATCH] D87409: [libTooling] Fix use of `char` in comparison.

2020-09-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: lbenes.
Herald added a project: clang.
ymandel requested review of this revision.

Fixes Transformer's `Range` parser to handle `char` in a platform-independent 
way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87409

Files:
  clang/lib/Tooling/Transformer/Parsing.cpp


Index: clang/lib/Tooling/Transformer/Parsing.cpp
===
--- clang/lib/Tooling/Transformer/Parsing.cpp
+++ clang/lib/Tooling/Transformer/Parsing.cpp
@@ -148,7 +148,7 @@
 }
 
 static StringRef consumeWhitespace(StringRef S) {
-  return S.drop_while([](char c) { return c >= 0 && isWhitespace(c); });
+  return S.drop_while([](char c) { return isASCII(c) && isWhitespace(c); });
 }
 
 // Parses a single expected character \c c from \c State, skipping preceding
@@ -165,7 +165,7 @@
 static ExpectedProgress parseId(ParseState State) {
   State.Input = consumeWhitespace(State.Input);
   auto Id = State.Input.take_while(
-  [](char c) { return c >= 0 && isIdentifierBody(c); });
+  [](char c) { return isASCII(c) && isIdentifierBody(c); });
   if (Id.empty())
 return makeParseError(State, "failed to parse name");
   return makeParseProgress(advance(State, Id.size()), Id.str());


Index: clang/lib/Tooling/Transformer/Parsing.cpp
===
--- clang/lib/Tooling/Transformer/Parsing.cpp
+++ clang/lib/Tooling/Transformer/Parsing.cpp
@@ -148,7 +148,7 @@
 }
 
 static StringRef consumeWhitespace(StringRef S) {
-  return S.drop_while([](char c) { return c >= 0 && isWhitespace(c); });
+  return S.drop_while([](char c) { return isASCII(c) && isWhitespace(c); });
 }
 
 // Parses a single expected character \c c from \c State, skipping preceding
@@ -165,7 +165,7 @@
 static ExpectedProgress parseId(ParseState State) {
   State.Input = consumeWhitespace(State.Input);
   auto Id = State.Input.take_while(
-  [](char c) { return c >= 0 && isIdentifierBody(c); });
+  [](char c) { return isASCII(c) && isIdentifierBody(c); });
   if (Id.empty())
 return makeParseError(State, "failed to parse name");
   return makeParseProgress(advance(State, Id.size()), Id.str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

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



Comment at: clang/include/clang/Basic/AttrDocs.td:3394
+parameter. Currently, the error parameter is always the last parameter of type
+``NSError**`` or ``CFErrorRef*``.  Swift will remove the error parameter from
+the imported API. When calling the API, Swift will always pass a valid address

rjmccall wrote:
> compnerd wrote:
> > aaron.ballman wrote:
> > > Canonical type or are typedefs to these types also fine? May want to 
> > > mention that the type has to be cv-unqualified, but I do wonder whether 
> > > something like `NSError * const *` is fine.
> > I am definitely not the authority on this, but I believe that the common 
> > thing is to take `NSError **` or `CFErrorRef **` by canonical name.  The 
> > cv-qualified versions, except on the outermost pointer, is something that 
> > can be treated as valid, though it is certainly extremely unusual.  I've 
> > added test cases for them as well.
> `NSError * const *` actually does not really work; the whole point is that 
> this is an out-parameter.
Oh right, its the `const NSError ** const` that can work, because the outer 
pointer can be non-mutable as it is a pointer by-reference scenario.  Should we 
diagnose the `NSError * const *` case then?  Any `const` qualified value is 
really unidiomatic to say the least.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-09-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

I took a closer look at the lexer changes, and think that these look fine. 
Thanks again for working on this. LGTM with a minor change, described inline.




Comment at: clang/lib/Lex/Lexer.cpp:2228
+if (!NewLinePtr && *CurPtr == '\n')
+  NewLinePtr = CurPtr;
 SawNewline = true;

It'd be more consistent to write this the way `lastNewLine` is initialized 
earlier in `SkipWhitespace`, e.g. as:

```
if (*CurPtr == '\n') {
  lastNewLine = CurPtr;
  if (!NewLinePtr)
NewLinePtr = CurPtr;
}
```

Maybe this could even be factored into a helper lambda, like 
`setLastNewLine(char *Ptr)` -- I'm not sure whether that'd be cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-09-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Thanks for reviewing. One last thing I need to resolve is to handle the 
coverage test case as skipped regions are emitted for empty lines, and haven't 
thought a good way other than adding checks for those new skipped regions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

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


[PATCH] D84467: Add support for Branch Coverage in LLVM Source-Based Code Coverage

2020-09-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

@alanphipps thanks for bearing with me. I think this is about ready to land. I 
do ask that you back out any punctuation/whitespace changes in code/tests that 
aren't directly modified in your diff (the clang-format-diff script can help 
with this). It looks like some libCoverage and test changes are no longer in 
the current version of this patch, as compared to the previous version 
(https://reviews.llvm.org/D84467?id=287269). Was that intentional?


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

https://reviews.llvm.org/D84467

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


[PATCH] D84968: [PowerPC] Legalize v256i1 and v512i1 and implement load and store of these types

2020-09-09 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 290804.
bsaleil added a comment.

Rebase so the patch can be applied on top of master. Also change the datalayout 
string on all ppc64 platforms to improve compatibility between object files.


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

https://reviews.llvm.org/D84968

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCRegisterInfo.td
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/mma-acc-memops.ll

Index: llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
@@ -0,0 +1,143 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=BE
+
+@f = common local_unnamed_addr global <512 x i1> zeroinitializer, align 16
+
+define void @testLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-LABEL: testLdSt:
+; LE:   # %bb.0: # %entry
+; LE-NEXT:plxv vs1, f@PCREL+96(0), 1
+; LE-NEXT:plxv vs0, f@PCREL+112(0), 1
+; LE-NEXT:plxv vs3, f@PCREL+64(0), 1
+; LE-NEXT:plxv vs2, f@PCREL+80(0), 1
+; LE-NEXT:xxmtacc acc0
+; LE-NEXT:xxmfacc acc0
+; LE-NEXT:pstxv vs0, f@PCREL+176(0), 1
+; LE-NEXT:pstxv vs1, f@PCREL+160(0), 1
+; LE-NEXT:pstxv vs2, f@PCREL+144(0), 1
+; LE-NEXT:pstxv vs3, f@PCREL+128(0), 1
+; LE-NEXT:blr
+;
+; BE-LABEL: testLdSt:
+; BE:   # %bb.0: # %entry
+; BE-NEXT:addis r3, r2, .LC0@toc@ha
+; BE-NEXT:ld r3, .LC0@toc@l(r3)
+; BE-NEXT:lxv vs1, 80(r3)
+; BE-NEXT:lxv vs0, 64(r3)
+; BE-NEXT:lxv vs3, 112(r3)
+; BE-NEXT:lxv vs2, 96(r3)
+; BE-NEXT:xxmtacc acc0
+; BE-NEXT:xxmfacc acc0
+; BE-NEXT:stxv vs1, 144(r3)
+; BE-NEXT:stxv vs0, 128(r3)
+; BE-NEXT:stxv vs3, 176(r3)
+; BE-NEXT:stxv vs2, 160(r3)
+; BE-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 1
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 16
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 2
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 16
+  ret void
+}
+
+define void @testXLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-LABEL: testXLdSt:
+; LE:   # %bb.0: # %entry
+; LE-NEXT:sldi r3, r3, 6
+; LE-NEXT:paddi r5, 0, f@PCREL, 1
+; LE-NEXT:add r6, r5, r3
+; LE-NEXT:lxv vs1, 32(r6)
+; LE-NEXT:lxv vs0, 48(r6)
+; LE-NEXT:lxvx vs3, r5, r3
+; LE-NEXT:lxv vs2, 16(r6)
+; LE-NEXT:sldi r3, r4, 6
+; LE-NEXT:xxmtacc acc0
+; LE-NEXT:add r4, r5, r3
+; LE-NEXT:xxmfacc acc0
+; LE-NEXT:stxvx vs3, r5, r3
+; LE-NEXT:stxv vs0, 48(r4)
+; LE-NEXT:stxv vs1, 32(r4)
+; LE-NEXT:stxv vs2, 16(r4)
+; LE-NEXT:blr
+;
+; BE-LABEL: testXLdSt:
+; BE:   # %bb.0: # %entry
+; BE-NEXT:addis r5, r2, .LC0@toc@ha
+; BE-NEXT:ld r5, .LC0@toc@l(r5)
+; BE-NEXT:sldi r3, r3, 6
+; BE-NEXT:add r6, r5, r3
+; BE-NEXT:lxvx vs0, r5, r3
+; BE-NEXT:lxv vs1, 16(r6)
+; BE-NEXT:lxv vs3, 48(r6)
+; BE-NEXT:lxv vs2, 32(r6)
+; BE-NEXT:sldi r3, r4, 6
+; BE-NEXT:xxmtacc acc0
+; BE-NEXT:add r4, r5, r3
+; BE-NEXT:xxmfacc acc0
+; BE-NEXT:stxvx vs0, r5, r3
+; BE-NEXT:stxv vs1, 16(r4)
+; BE-NEXT:stxv vs3, 48(r4)
+; BE-NEXT:stxv vs2, 32(r4)
+; BE-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %SrcIdx
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 16
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %DstIdx
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 16
+  ret void
+}
+
+define void @testUnalignedLdSt() {
+; LE-LABEL: testUnalignedLdSt:
+; LE:   # %bb.0: # %entry
+; LE-NEXT:plxv vs1, f@PCREL+43(0), 1
+; LE-NEXT:plxv vs0, f@PCREL+59(0), 1
+; LE-NEXT:plxv vs3, f@PCREL+11(0), 1
+; LE-NEXT:plxv vs2, f@PCREL+27(0), 1
+; LE-NEXT:xxmtacc acc0
+; LE-NEXT:xxmfacc acc0
+; LE-NEXT:pstxv vs0, f@PCREL+67(0), 1
+; LE-NEXT:pstxv vs1, f@PCREL+51(0), 1
+; LE-NEXT:pstxv vs2, f@PCREL+35(0), 1
+; LE-NEXT:pstxv vs3, f@PCREL+19(0), 1
+; LE-NEXT:blr
+;
+; BE-LABEL: testUnalignedLdSt:
+; BE:   # %bb.0: # %entry
+; BE-NEXT:addis r3, r2, .LC0@toc@ha
+; BE-NEXT:ld r3, .LC0@toc@l(r3)
+; BE-NEXT:li r4, 11
+; BE-NEXT:lxvx vs0, r3, r4
+; BE-NEXT:li r4, 27
+; BE-NEXT:lxvx vs1, r3, r4
+; BE-NEXT:l

[PATCH] D87164: Extending Baremetal toolchain's support for the rtlib option.

2020-09-09 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

> The Baremetal toolchain currently has a fixed behavior regardless of the 
> -rtlib option's value. It is always linking against compiler-rt unless 
> -nodefaultlibs is enabled.
>
> This proposal slightly changes the code in such a way that enabling 
> -rtlib=libgcc implies linking against -libgcc.
>
> Something that I'm unsure about this patch is that we are not enforcing the 
> existence of such libgcc. By reading other toolchains, I understood that is 
> not always enforced. Do you think this policy is acceptable? If it is not, 
> how would you think it should be addressed?

I think it's fine. You'll get linker errors if the library can't be found.

> Context:
>
> So far I manually set an -L path to a valid libgcc on my system when clang is 
> invoked. In this particular case, I use arm-none-eabi-gcc -mthumb 
> -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -print-libgcc-file-name 
> which retrieves the path I want.
>
> Assume the user forwards a gcc-toolchain installation through 
> --gcc-toolchain. Would be a good idea to programmatically query 
> arm-none-eabi-gcc for the libgcc as described above?

I don't think it's appropriate to bake this into clang's driver. Instead, this 
should be done by the build script, and the resulting path should be fed in via 
the -resource-dir flag.

> If that is the case, how would be the most "llvm way" to do it? I'm not very 
> related to all abstractions and concepts from the framework.
>
> This is my very first contribution to LLVM so I'd really appreciate any 
> feedback in order to improve this proposal :)

Sorry it took me a few days to get around to reviewing this. Been a bit busy 
with a move thanks for the patch!




Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:164
+Args.MakeArgString("-lclang_rt.builtins-" + 
getTriple().getArchName()));
+break;
+  case ToolChain::RLT_Libgcc:

If you make these `break`s into `return`s, and put an 
`llvm_unreachable("unhandled RuntimeLibType");` after the switch, then whoever 
adds a new entry to that enum will get a nice warning showing them that they 
need to update this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87164

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


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

2020-09-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 290809.
Mordante added a comment.

Update the patch to match the behaviour where the attribute only affects the 
substatement of an if statement. This means the likelihood attributes on labels 
are accepted but are a no-op. Since they're a no-op the documentation doesn't 
mention them.


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

https://reviews.llvm.org/D86559

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-likelihood.c
  clang/test/SemaCXX/attr-likelihood.cpp


Index: clang/test/SemaCXX/attr-likelihood.cpp
===
--- clang/test/SemaCXX/attr-likelihood.cpp
+++ clang/test/SemaCXX/attr-likelihood.cpp
@@ -115,8 +115,7 @@
   if (x)
 goto lbl;
 
-  // FIXME: allow the attribute on the label
-  [[unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be 
applied to a declaration}}
+  [[likely]] lbl :
  [[likely]] x = x + 1;
 
   [[likely]]++ x;
Index: clang/test/Sema/attr-likelihood.c
===
--- clang/test/Sema/attr-likelihood.c
+++ clang/test/Sema/attr-likelihood.c
@@ -43,8 +43,7 @@
   if (x)
 goto lbl;
 
-  // FIXME: allow the attribute on the label
-  [[clang::unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be 
applied to a declaration}}
+  [[clang::unlikely]] lbl :
   [[clang::likely]] x = x + 1;
 
   [[clang::likely]]++ x;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6451,6 +6451,29 @@
   D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, 
Replacement));
 }
 
+static bool validateLikelihoodAttr(Sema &S, Decl *D, const ParsedAttr &A) {
+  if (!isa(D)) {
+S.Diag(A.getRange().getBegin(), diag::err_stmt_attribute_invalid_on_decl)
+<< A << D->getBeginLoc();
+return false;
+  }
+
+  if (!S.getLangOpts().CPlusPlus20 && A.isCXX11Attribute() && 
!A.getScopeName())
+S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << A.getRange();
+
+  return true;
+}
+
+static void handleLikelyAttr(Sema &S, Decl *D, const ParsedAttr &A) {
+  if (validateLikelihoodAttr(S, D, A))
+D->addAttr(::new (S.Context) LikelyAttr(S.Context, A));
+}
+
+static void handleUnlikelyAttr(Sema &S, Decl *D, const ParsedAttr &A) {
+  if (validateLikelihoodAttr(S, D, A))
+D->addAttr(::new (S.Context) UnlikelyAttr(S.Context, A));
+}
+
 static bool isGlobalVar(const Decl *D) {
   if (const auto *S = dyn_cast(D))
 return S->hasGlobalStorage();
@@ -6984,6 +7007,12 @@
   case ParsedAttr::AT_Deprecated:
 handleDeprecatedAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_Likely:
+handleLikelyAttr(S, D, AL);
+break;
+  case ParsedAttr::AT_Unlikely:
+handleUnlikelyAttr(S, D, AL);
+break;
   case ParsedAttr::AT_Destructor:
 if (S.Context.getTargetInfo().getTriple().isOSAIX())
   llvm::report_fatal_error("'destructor' attribute is not yet supported on 
AIX");


Index: clang/test/SemaCXX/attr-likelihood.cpp
===
--- clang/test/SemaCXX/attr-likelihood.cpp
+++ clang/test/SemaCXX/attr-likelihood.cpp
@@ -115,8 +115,7 @@
   if (x)
 goto lbl;
 
-  // FIXME: allow the attribute on the label
-  [[unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be applied to a declaration}}
+  [[likely]] lbl :
  [[likely]] x = x + 1;
 
   [[likely]]++ x;
Index: clang/test/Sema/attr-likelihood.c
===
--- clang/test/Sema/attr-likelihood.c
+++ clang/test/Sema/attr-likelihood.c
@@ -43,8 +43,7 @@
   if (x)
 goto lbl;
 
-  // FIXME: allow the attribute on the label
-  [[clang::unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be applied to a declaration}}
+  [[clang::unlikely]] lbl :
   [[clang::likely]] x = x + 1;
 
   [[clang::likely]]++ x;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6451,6 +6451,29 @@
   D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, Replacement));
 }
 
+static bool validateLikelihoodAttr(Sema &S, Decl *D, const ParsedAttr &A) {
+  if (!isa(D)) {
+S.Diag(A.getRange().getBegin(), diag::err_stmt_attribute_invalid_on_decl)
+<< A << D->getBeginLoc();
+return false;
+  }
+
+  if (!S.getLangOpts().CPlusPlus20 && A.isCXX11Attribute() && !A.getScopeName())
+S.Diag(A.getLoc(), diag::ext_cxx20_attr) << A << A.getRange();
+
+  return true;
+}
+
+static void handleLikelyAttr(Sema &S, Decl *D, const ParsedAttr &A) {
+  if (validateLikelihoodAttr(S, D, A))
+D->addAttr(::new (S.Context) LikelyAttr(S.Context, A));
+}
+
+static void handleUnlikelyAttr(Sema &S, Decl *D, const Pars

[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

`const` qualification isn't the most meaningful thing for Objective-C objects 
anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-09-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In D84988#2264199 , @zequanwu wrote:

> Thanks for reviewing. One last thing I need to resolve is to handle the 
> coverage test case as skipped regions are emitted for empty lines, and 
> haven't thought a good way other than adding checks for those new skipped 
> regions.

How does it sound to add a testing-only cl::opt that disables whitespace 
skipped regions? Tests that aren't focused on validating skipped regions can 
set this cl::opt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

___
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-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

It looks like a recently introduced GVN crash is exposed by this change 
(probably D87061 ). I will commit once this is 
fixed.

In D87163#2263685 , @nikic wrote:

> LGTM as well, per llvm-dev discussion. I think you've done all the due 
> diligence we can expect.
>
> Do you plan to also work on MSSA-based MemCpyOpt? I expect that one will have 
> a large positive impact on Rust code, where lack of cross-BB memcpy elision 
> is a big issue right now.

I probably won't have time to work on MSSA-based MemCpyOpt for the next couple 
of weeks unfortunately. But I think there is a lot that can be re-used/shared 
from the DSE implementation. Happy to discuss approaches.


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] D82112: [RFC][BPF] Implement getUserCost() for BPFTargetTransformInfo

2020-09-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song abandoned this revision.
yonghong-song added a comment.

Abandon this one. The current approach is to add "user barriers" in an IR phase 
before simplifyCFG/instrcombine to disable unfavorable speculative code motion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82112

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


[libunwind] 09d4929 - [libunwind] Bare-metal DWARF: set dso_base to 0

2020-09-09 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2020-09-09T15:43:35-07:00
New Revision: 09d492902f178f60b3ab986360eadde9b5c8d359

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

LOG: [libunwind] Bare-metal DWARF: set dso_base to 0

Previously, DwarfFDECache::findFDE used 0 as a special value meaning
"search the entire cache, including dynamically-registered FDEs".
Switch this special value to -1, which doesn't make sense as a DSO
base.

Fixes PR47335.

Reviewed By: compnerd, #libunwind

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

Added: 


Modified: 
libunwind/src/AddressSpace.hpp
libunwind/src/UnwindCursor.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index cc298c9bbb83..eccc2153c697 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -518,6 +518,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t 
targetAddr,
 return true;
   }
 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && 
defined(_LIBUNWIND_IS_BAREMETAL)
+  info.dso_base = 0;
   // Bare metal is statically linked, so no need to ask the dynamic loader
   info.dwarf_section_length = (uintptr_t)(&__eh_frame_end - &__eh_frame_start);
   info.dwarf_section =(uintptr_t)(&__eh_frame_start);

diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index e6a36764fc79..206b5e398321 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -81,6 +81,7 @@ template 
 class _LIBUNWIND_HIDDEN DwarfFDECache {
   typedef typename A::pint_t pint_t;
 public:
+  static constexpr pint_t kSearchAll = static_cast(-1);
   static pint_t findFDE(pint_t mh, pint_t pc);
   static void add(pint_t mh, pint_t ip_start, pint_t ip_end, pint_t fde);
   static void removeAllIn(pint_t mh);
@@ -138,7 +139,7 @@ typename A::pint_t DwarfFDECache::findFDE(pint_t mh, 
pint_t pc) {
   pint_t result = 0;
   _LIBUNWIND_LOG_IF_FALSE(_lock.lock_shared());
   for (entry *p = _buffer; p < _bufferUsed; ++p) {
-if ((mh == p->mh) || (mh == 0)) {
+if ((mh == p->mh) || (mh == kSearchAll)) {
   if ((p->ip_start <= pc) && (pc < p->ip_end)) {
 result = p->fde;
 break;
@@ -1945,7 +1946,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   // There is no static unwind info for this pc. Look to see if an FDE was
   // dynamically registered for it.
-  pint_t cachedFDE = DwarfFDECache::findFDE(0, pc);
+  pint_t cachedFDE = DwarfFDECache::findFDE(DwarfFDECache::kSearchAll,
+   pc);
   if (cachedFDE != 0) {
 typename CFI_Parser::FDE_Info fdeInfo;
 typename CFI_Parser::CIE_Info cieInfo;



___
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-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: rsmith, hans.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zequanwu requested review of this revision.

Bug: https://bugs.llvm.org/show_bug.cgi?id=47467


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87425

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang/include/clang/AST/EvaluatedExprVisitor.h
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -309,7 +309,7 @@
   static_assert(&B2().ti2 == &typeid(B2));
   extern B2 extern_b2;
   // 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}}
 
   constexpr B2 b2;
   constexpr const B &b1 = b2;
Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* @"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* @"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info* test6_typeid() { return &typeid((V&)v); }
+// CHECK: define dso_local %struct.type_info* @"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,7 @@
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  if (E->isPotentiallyEvaluated(getContext()))
 return EmitTypeidFromVTable(*this, E->getExprOperand(),
 StdTypeInfoPtrTy);
 
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -40,7 +40,7 @@
 cxxTypeidExpr;
 
 AST_MATCHER(CXXTypeidExpr, isPotentiallyEvaluated) {
-  return Node.isPotentiallyEvaluated();
+  return Node.isPotentiallyEvaluated(Finder->getASTContext());
 }
 
 const ast_matchers::internal::VariadicDynCastAllOfMatcherisPotentiallyEvaluated()) {
+  if (!E->isPotentiallyEvaluated(Info.Ctx)) {
 if (E->isTypeOperand())
   TypeInfo = TypeInfoLValue(E->getTypeOperand(Info.Ctx).getTypePtr());
 else
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -131,14 +131,20 @@
   return Result;
 }
 
-bool CXXTypeidExpr::isPotentiallyEvaluated() const {
+bool CXXTypeidExpr::isPotentiallyEvaluated(const ASTContext &Context) const {
   if (isTypeOperand())
 return false;
 
+  Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();
+if (!Ty->isPointerType() && !Ty->isReferenceType())
+  return false;
+  }
+
   // C++11 [expr.typeid]p3:
   //   When typeid is applied to an expression other than a glvalue of
   //   polymorphic class type, [...] the expression is an unevaluated operand.
-  const Expr *E = getExprOperand();
   if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
 if (RD->isPolymorphic() && E->isGLValue())
   return true;
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3477,7 +3477,7 @@
   case CXXTypeidExprClass:
 // typeid might throw if its subexpression is potentially-evaluated, so has
 // side-effects in that case whether or not its subexpress

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

2020-09-09 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 290846.
zequanwu added a comment.

Remove unused field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang/include/clang/AST/EvaluatedExprVisitor.h
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -309,7 +309,7 @@
   static_assert(&B2().ti2 == &typeid(B2));
   extern B2 extern_b2;
   // 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}}
 
   constexpr B2 b2;
   constexpr const B &b1 = b2;
Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* @"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* @"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* @"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,7 @@
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  if (E->isPotentiallyEvaluated(getContext()))
 return EmitTypeidFromVTable(*this, E->getExprOperand(),
 StdTypeInfoPtrTy);
 
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -40,7 +40,7 @@
 cxxTypeidExpr;
 
 AST_MATCHER(CXXTypeidExpr, isPotentiallyEvaluated) {
-  return Node.isPotentiallyEvaluated();
+  return Node.isPotentiallyEvaluated(Finder->getASTContext());
 }
 
 const ast_matchers::internal::VariadicDynCastAllOfMatcherisPotentiallyEvaluated()) {
+  if (!E->isPotentiallyEvaluated(Info.Ctx)) {
 if (E->isTypeOperand())
   TypeInfo = TypeInfoLValue(E->getTypeOperand(Info.Ctx).getTypePtr());
 else
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -131,14 +131,20 @@
   return Result;
 }
 
-bool CXXTypeidExpr::isPotentiallyEvaluated() const {
+bool CXXTypeidExpr::isPotentiallyEvaluated(const ASTContext &Context) const {
   if (isTypeOperand())
 return false;
 
+  Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();
+if (!Ty->isPointerType() && !Ty->isReferenceType())
+  return false;
+  }
+
   // C++11 [expr.typeid]p3:
   //   When typeid is applied to an expression other than a glvalue of
   //   polymorphic class type, [...] the expression is an unevaluated operand.
-  const Expr *E = getExprOperand();
   if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
 if (RD->isPolymorphic() && E->isGLValue())
   return true;
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3477,7 +3477,7 @@
   case CXXTypeidExprClass:
 // typeid might throw if its subexpression is potentially-evaluated, so has
 // side-effects in that case whether or not its subexpression does.
-return cast(this)->isPotentiallyEvaluated();
+return cas

[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-09-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: sammccall, dblaikie.
dblaikie added a comment.

In D80531#2069637 , @kwk wrote:

> In D80531#2069383 , @njames93 wrote:
>
>> LGTM with 2 small nits, but I'd still give a few days see if anyone else 
>> wants to weight in.
>
> I'm okay with this but I'd like to understand when it's time to wait for 
> others? Only when a patch is approved or from the beginning of patch's life? 
> I mean who looks at patches that are approved unless you filter for the 
> amount of approvers? How many approvers must there be?

FWIW, I tend to - I have a queue of things to review, which doesn't have /much/ 
to do with whether they've already been reviewed. Sometimes, sometimes not - 
usually if I've decided it's worth looking at I'll still at least glance over 
it (enough to see if someone's asking for further consensus, etc).

While this is rather belated feedback, I've been seeing failures of this test 
consistently since it was committed, I think. Maybe there's something corrupted 
in my local client, but figured I'd mention/ask about it, in case it's useful. 
(+ @sammccall too):

  FAIL: Clang Tools :: 
clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp (18811 
of 74169)
   TEST 'Clang Tools :: 
clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp' 
FAILED 
  Script:
  --
  : 'RUN: at line 1';   /usr/bin/python3.8 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py
 -format-style=LLVM -check-suffix=DEFAULT 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
modernize-replace-disallow-copy-and-assign-macro 
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp
  : 'RUN: at line 4';   /usr/bin/python3.8 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py
 -format-style=LLVM -check-suffix=DIFFERENT-NAME 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
   modernize-replace-disallow-copy-and-assign-macro 
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp
   -config="{CheckOptions: [{key: 
modernize-replace-disallow-copy-and-assign-macro.MacroName, value: 
MY_MACRO_NAME}]}"
  : 'RUN: at line 10';   /usr/bin/python3.8 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py
 -format-style=LLVM -check-suffix=FINALIZE 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
   modernize-replace-disallow-copy-and-assign-macro 
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp
   -config="{CheckOptions: [{key: 
modernize-replace-disallow-copy-and-assign-macro.MacroName, value: 
DISALLOW_COPY_AND_ASSIGN_FINALIZE}]}"
  : 'RUN: at line 16';   clang-tidy 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
 -checks="-*,modernize-replace-disallow-copy-and-assign-macro"
-config="{CheckOptions: [ {key: 
modernize-replace-disallow-copy-and-assign-macro.MacroName,  value: 
DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS}]}" | count 0
  : 'RUN: at line 21';   clang-tidy 
/usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
 -checks="-*,modernize-replace-disallow-copy-and-assign-macro"
-config="{CheckOptions: [ {key: 
modernize-replace-disallow-copy-and-assign-macro.MacroName,  value: 
DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION}]}" | count 0
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  Running ['clang-tidy', 
'/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp',
 '-fix', '--checks=-*,modernize-replace-disallow-copy-and-assign-macro', 
'-format-style=LLVM', '--', '-std=c++11', '-nostdinc++']...
   clang-tidy output ---
  1 warning generated.
  
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp:33:3:
 warning: prefer deleting copy constructor and assignment operator over using 
macro 'DISALLOW_COPY_AND_

[PATCH] D87338: [Driver][PGO] Driver support for de-Optimizing cold functions (PATCH 2/2)

2020-09-09 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 290849.
myhsu edited the summary of this revision.
myhsu added a comment.

Unified driver options from "-fprofile-deopt-cold-*" into 
"-fprofile-omit-cold-opt" and "-fprofile-omit-cold-opt=". Where the 
former one is just a shorthand of "-fprofile-omit-cold-opt=0"


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

https://reviews.llvm.org/D87338

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/gold-lto-omit-cold-opt.c
  clang/test/Driver/omit-cold-opt.c

Index: clang/test/Driver/omit-cold-opt.c
===
--- /dev/null
+++ clang/test/Driver/omit-cold-opt.c
@@ -0,0 +1,20 @@
+// RUN: %clang -### -fprofile-instr-use -fprofile-omit-cold-opt -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-BASE %s
+
+// RUN: %clang -### -fprofile-instr-use \
+// RUN: -fprofile-omit-cold-opt=87 \
+// RUN: -c %s 2>&1 \
+// RUN: | FileCheck --check-prefixes=CHECK-BASE,CHECK-PERCENT %s
+
+// RUN: %clang -### -fprofile-instr-use \
+// RUN: -fprofile-omit-cold-opt -fno-profile-omit-cold-opt \
+// RUN: -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEG %s
+
+// Shouldn't do anything if it's not using PGO profile
+// RUN: %clang -### -fprofile-omit-cold-opt -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEG %s
+
+// CHECK-BASE: "-mllvm" "-profile-omit-cold-func-opt=true"
+// CHECK-PERCENT: "-mllvm" "-profile-omit-cold-func-opt-percent=87"
+// CHECK-NEG-NOT: "-profile-omit-cold-func-opt=true"
Index: clang/test/Driver/gold-lto-omit-cold-opt.c
===
--- /dev/null
+++ clang/test/Driver/gold-lto-omit-cold-opt.c
@@ -0,0 +1,11 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -### -fprofile-instr-use -fprofile-omit-cold-opt %t.o -flto 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-BASE %s
+
+// RUN: %clang -### -fprofile-instr-use -fprofile-omit-cold-opt=87 \
+// RUN: %t.o -flto 2>&1 \
+// RUN: | FileCheck --check-prefixes=CHECK-BASE,CHECK-PERCENT %s
+
+// CHECK-BASE: "-plugin-opt=-profile-omit-cold-func-opt=true"
+// CHECK-PERCENT: "-plugin-opt=-profile-omit-cold-func-opt-percent=87"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -516,6 +516,18 @@
   llvm::sys::path::append(Path, "default.profdata");
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=cs-profile-path=") +
  Path));
+// Propagate -profile-omit-cold-func-opt options
+if (Args.hasFlag(options::OPT_fprofile_omit_cold_opt,
+ options::OPT_fprofile_omit_cold_opt_EQ,
+ options::OPT_fno_profile_omit_cold_opt, false)) {
+  CmdArgs.push_back("-plugin-opt=-profile-omit-cold-func-opt=true");
+  Arg *A = Args.getLastArg(options::OPT_fprofile_omit_cold_opt_EQ);
+  if (A) {
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-plugin-opt=-profile-omit-cold-func-opt-percent=") +
+A->getValue()));
+  }
+}
   }
 
   // Need this flag to turn on new pass manager via Gold plugin.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -824,6 +824,19 @@
   CmdArgs.push_back(
   Args.MakeArgString(Twine("-fprofile-instrument-use-path=") + Path));
 }
+// Tell profile passes to avoid optimizing cold functions.
+if (Args.hasFlag(options::OPT_fprofile_omit_cold_opt,
+ options::OPT_fprofile_omit_cold_opt_EQ,
+ options::OPT_fno_profile_omit_cold_opt, false)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-profile-omit-cold-func-opt=true");
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_omit_cold_opt_EQ)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-profile-omit-cold-func-opt-percent=") + A->getValue()));
+  }
+}
   }
 
   bool EmitCovNotes = Args.hasFlag(options::OPT_ftest_coverage,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -793,6 +793,17 @@
 Alias;
 defm debug_info_for_profiling : OptInFFlag<"debug-info-for-profiling",
   "Emit extra debug info to make sample profile more accurate">;
+
+// Options to omit optimizations on cold code.
+def fprofile_omit_cold_opt : Flag<["-"], "fprofile-omit-cold-opt">,
+Group, Flags<[CoreOption]>,
+HelpT

[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-09 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

rnk wrote:
> Please only make the path absolute if nothing in the prefix map matches. 
> Otherwise, the user must embed the CWD into the prefix map, which is 
> needlessly difficult for the build system. I believe it is also consistent 
> with the way that the debug info prefix map works. It appears to operate on 
> the possibly relative source paths received on the command line (-I...).
Are you suggesting that I try to remap them relatively, and if that fails, 
absolutize it and attempt the remapping again? Or don't absolutize them at all 
anymore?



Comment at: clang/test/Profile/profile-prefix-map.c:12
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c 
nested/profile-prefix-map.c -fprofile-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=PROFILE-PREFIX-MAP %s --implicit-check-not=root
+//

rnk wrote:
> See here, for example, where you must pass `-fprofile-prefix-map=%/t/...`.
+1. I do think I still want this test case, but likely another pending the 
discussion above that validates the relative path behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-09 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 290851.
keith marked 2 inline comments as done.
keith added a comment.

Small fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debug-prefix-map.c
  clang/test/Profile/profile-prefix-map.c

Index: clang/test/Profile/profile-prefix-map.c
===
--- /dev/null
+++ clang/test/Profile/profile-prefix-map.c
@@ -0,0 +1,14 @@
+// %s expands to an absolute path, so to test relative paths we need to create a
+// clean directory, put the source there, and cd into it.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/root/nested
+// RUN: echo "void f1() {}" > %t/root/nested/profile-prefix-map.c
+// RUN: cd %t/root
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c nested/profile-prefix-map.c -o - | FileCheck --check-prefix=ABSOLUTE %s
+//
+// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\01.*root.*nested.*profile-prefix-map\.c}}
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name profile-prefix-map.c nested/profile-prefix-map.c -fprofile-prefix-map=%/t/root=. -o - | FileCheck --check-prefix=PROFILE-PREFIX-MAP %s --implicit-check-not=root
+//
+// PROFILE-PREFIX-MAP: @__llvm_coverage_mapping = {{.*"\\01[^/]*}}.{{/|\\+}}nested{{.*profile-prefix-map\.c}}
Index: clang/test/Driver/debug-prefix-map.c
===
--- clang/test/Driver/debug-prefix-map.c
+++ clang/test/Driver/debug-prefix-map.c
@@ -1,28 +1,39 @@
 // RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID
 // RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID
+// RUN: %clang -### -fprofile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-INVALID
 // RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID
 
 // RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
 // RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -fprofile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-SIMPLE
 // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
 // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-SIMPLE
 
 // RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
 // RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -fprofile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-COMPLEX
 // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
 // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-COMPLEX
 
 // RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
 // RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -fprofile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-EMPTY
 // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
 // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-PROFILE-EMPTY
 
 // CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
 // CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map
+// CHECK-PROFILE-INVALID: error: invalid argument 'old' to -fprofile-prefix-map
 // CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map
 // CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new
 // CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new
+// CHECK-PROFILE-SIMPLE: fprofile-prefix-map=old=new
 // CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew
 // CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew
+// CHECK-PROFILE-COMPLEX: fprofile-prefix-map=old=n=ew
 // CHECK-DEBUG-EMPTY: fdebug-prefix-map=old=
 // CHECK-MACRO-EMPTY: fmacro-pre

[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-09 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 290852.
snehasish added a comment.

Add a check for x86-elf.

- Add a check for the triple in the driver to only enable the flag on x86+elf 
targets.
- Add a test to ensure we don't enable this on other targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/split-machine-functions.c
  clang/test/Driver/fsplit-machine-functions.c

Index: clang/test/Driver/fsplit-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target arm-unknown-linux -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-fsplit-machine-functions"
+// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
Index: clang/test/CodeGen/split-machine-functions.c
===
--- /dev/null
+++ clang/test/CodeGen/split-machine-functions.c
@@ -0,0 +1,34 @@
+// REQUIRES: x86-registered-target
+
+// RUN: echo "foo"> %t.proftext
+// RUN: echo "# Func Hash:"   >> %t.proftext
+// RUN: echo "11262309905">> %t.proftext
+// RUN: echo "# Num Counters:">> %t.proftext
+// RUN: echo "2"  >> %t.proftext
+// RUN: echo "# Counter Values:"  >> %t.proftext
+// RUN: echo "100">> %t.proftext
+// RUN: echo "0"  >> %t.proftext
+// RUN: llvm-profdata merge -o %t.profdata %t.proftext
+// RUN: %clang_cc1 -triple x86_64 -O3 -S -fprofile-instrument-use-path=%t.profdata -fsplit-machine-functions -o - < %s | FileCheck %s
+
+__attribute__((noinline)) int foo(int argc) {
+  if (argc % 2 == 0) {
+exit(argc);
+  } else {
+return argc + 1;
+  }
+}
+
+int main(int argc, char *argv[]) {
+  int total = 0;
+  for (int i = 0; i < 100; ++i) {
+total += foo(argc);
+  }
+  printf("%d\n", total);
+}
+
+// CHECK: .section .text.hot.,"ax",@progbits
+// CHECK: foo:
+// CHECK: section .text.unlikely.foo,"ax",@progbits
+// CHECK: foo.cold:
+// CHECK: callq exit@PLT
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -998,6 +998,8 @@
   Opts.UniqueInternalLinkageNames =
   Args.hasArg(OPT_funique_internal_linkage_names);
 
+  Opts.SplitMachineFunctions = Args.hasArg(OPT_fsplit_machine_functions);
+
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4256,6 +4256,8 @@
 options::OPT_fno_unique_section_names,
 options::OPT_funique_basic_block_section_names,
 options::OPT_fno_unique_basic_block_section_names,
+options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions,
 options::OPT_mrestrict_it,
 options::OPT_mno_restrict_it,
 options::OPT_mstackrealign,
@@ -4906,6 +4908,12 @@
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Args.hasFlag(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions, false)) {
+if (Triple.isX86() && Triple.isOSBinFormatELF())
+  CmdArgs.push_back("-fsplit-machine-functions");
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -514,6 +514,13 @@
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  if (CodeGenOpts.SplitMachineFunctions) {
+if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+  Options.EnableMachineFunctionSplitter = true;
+else
+  Diags.Report(diag::warn_fe_machine_function_splitter_missing_profile);
+  }
+
   Options.Funct

[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish created this revision.
snehasish added reviewers: tmsriram, rahmanl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
snehasish requested review of this revision.

Basic block sections is untested on other platforms and binary formats apart 
from x86,elf. This patch silently drops the flag if the platform and binary 
format is not compatible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87426

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -2,8 +2,10 @@
 // RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
 // RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all %s -S 
2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-NOOPT-NOT:  "-fbasic-block-sections"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4879,14 +4879,16 @@
 CmdArgs.push_back("-ffunction-sections");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+  if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
+D.Diag(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  else
+A->render(Args, CmdArgs);
+}
   }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -2,8 +2,10 @@
 // RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
 // RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
 // RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-NOOPT-NOT:  "-fbasic-block-sections"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4879,14 +4879,16 @@
 CmdArgs.push_back("-ffunction-sections");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+  if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5))

[PATCH] D87358: [clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

2020-09-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/AST/Type.cpp:2339
   case BuiltinType::SveInt32:
-return Ctx.IntTy;
+return IsILP32 ? Ctx.LongTy : Ctx.IntTy;
   case BuiltinType::SveUint32:

sdesmalen wrote:
> Rather than comparing with a specific triple, how about getting the 
> information from `TargetInfo`, i.e.
> 
>   case BuiltinType::SveInt32:
> Ctx.getTargetInfo().getLongWidth() == 32 ? Ctx.LongTy : Ctx.IntTy
The type that actually corresponds to int64_t is TargetInfo::getInt64Type().  
Not sure if you need that here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87358

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


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Rahman Lavaee via Phabricator via cfe-commits
rahmanl accepted this revision.
rahmanl added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/fbasic-block-sections.c:11
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-NOOPT-NOT:  "-fbasic-block-sections"

nit, ignore if you want:
CHECK-NOOPT-NOT sounds like double negative? How about using CHECK-OPT-NONX86 
or CHECK-OPT-ARM for the check prefix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

___
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-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea requested changes to this revision.
asbirlea added a comment.
This revision now requires changes to proceed.

I'm running into a crash with this, could you please hold off until tomorrow? 
I'm working on getting a reproducer.


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] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 290863.
snehasish added a comment.

Specify triple for driver tests, address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=none %s -S 
2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=all %s -S 
2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=list=%s %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=labels %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all %s -S 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-TRIPLE-NOT: "-fbasic-block-sections=all"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4880,13 +4880,18 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
+D.Diag(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  else
+A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::warn_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
   }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sectio

[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-09 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 290864.
nullptr.cpp added a comment.

Fix by directly using `INT_MAX` and `INT32_MAX`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

Files:
  clang/lib/Lex/Pragma.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * 
TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
+  : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -416,8 +416,7 @@
   ScaledMask.clear();
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
-  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1356,7 +1356,7 @@
 while (Tok.is(tok::numeric_constant)) {
   uint64_t Value;
   if (!PP.parseSimpleIntegerLiteral(Tok, Value) || Value == 0 ||
-  Value > std::numeric_limits::max()) {
+  Value > INT_MAX) {
 PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
 return;
   }


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
+  : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -416,8 +416,7 @@
   ScaledMask.clear();
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
-  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
==

[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/fbasic-block-sections.c:1
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=none %s -S 
2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=all %s -S 
2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s

Consider dropping `-linux-gnu` because they are insignificant.

The code applies to generic ELF.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

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


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/test/Driver/fbasic-block-sections.c:12
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-TRIPLE-NOT: "-fbasic-block-sections=all"

`CHECK-TRIPLE` should check the diagnostic instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

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


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4892
+} else {
+  D.Diag(diag::warn_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;

This should be an error



Comment at: clang/test/Driver/fbasic-block-sections.c:5
+// RUN: %clang -### -target x86_64-linux-gnu -fbasic-block-sections=labels %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target arm-unknown-linux -fbasic-block-sections=all %s -S 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s

`%clang -###` -> `not %clang -fsyntax-only`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

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


  1   2   >