[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 351082.
balazske added a comment.

Added AST dump without clang-format into test code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103792

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4368,6 +4368,245 @@
   EXPECT_EQ(ToD->getNumTemplateParameterLists(), 1u);
 }
 
+const internal::VariadicDynCastAllOfMatcher
+varTemplateDecl;
+
+const internal::VariadicDynCastAllOfMatcher<
+Decl, VarTemplatePartialSpecializationDecl>
+varTemplatePartialSpecializationDecl;
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   FunctionTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  void f() {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("f")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  struct S {};
+  template
+  struct S {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, classTemplateDecl(hasName("S")));
+  auto *FromDPart =
+  FirstDeclMatcher().match(
+  FromTU, classTemplatePartialSpecializationDecl(hasName("S")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+  ASSERT_EQ(FromDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromDPart);
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  auto *ToDPart = Import(FromDPart, Lang_CXX11);
+
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+
+  EXPECT_EQ(ToDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToDPart);
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToDPart, ToDPart->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   CXXDeductionGuideTemplateParameterDeclContext) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  struct A {
+A(T);
+  };
+  A a{(int)0};
+  )",
+  Lang_CXX17, "input.cc");
+// clang-format off
+/*
+|-ClassTemplateDecl 0x1fe5000  line:2:36 A
+| |-TemplateTypeParmDecl 0x1fe4eb0  col:26 referenced typename depth 0 index 0 T
+| |-CXXRecordDecl 0x1fe4f70  line:2:36 struct A definition
+
+|-FunctionTemplateDecl 0x1fe5860  col:9 implicit 
+| |-TemplateTypeParmDecl 0x1fe4eb0  col:26 referenced typename depth 0 index 0 T
+| |-CXXDeductionGuideDecl 0x1fe57a8  col:9 implicit  'auto (T) -> A'
+| | `-ParmVarDecl 0x1fe56b0  col:12 'T'
+| `-CXXDeductionGuideDecl 0x20515d8  col:9 implicit used  'auto (int) -> A'
+|   |-TemplateArgument type 'int'
+|   | `-BuiltinType 0x20587e0 'int'
+|   `-ParmVarDecl 0x2051388  col:12 'int':'int'
+`-FunctionTemplateDecl 0x1fe5a78  col:36 implicit 
+  |-TemplateTypeParmDecl 0x1fe4eb0  col:26 referenced typename depth 0 index 0 T
+  `-CXXDeductionGuideDecl 0x1fe59c0  col:36 implicit  'auto (A) -> A'
+`-ParmVarDecl 0x1fe5958  col:36 'A'
+*/
+// clang-format on
+  auto *FromD1 = FirstDeclMatcher().match(
+  FromTU, cxxDeductionGuideDecl());
+  auto *FromD2 = LastDeclMatcher().match(
+  FromTU, cxxDeductionGuideDecl());
+
+  NamedDecl *P1 =
+  FromD1->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  NamedDecl *P2 =
+  FromD2->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  DeclContext *DC = P1->getDeclContext();
+
+  ASSERT_EQ(P1, P2);
+  ASSERT_TRUE(DC == FromD1 || DC == FromD2);
+
+  auto *ToD1 = Import(FromD1, Lang_CXX17);
+  auto *ToD2 = Import(FromD2, Lang_CXX17);
+  ASSERT_TRUE(ToD1 && ToD2);
+
+  P1 = ToD1->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  P2 = ToD2->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  DC = P1->getDeclContext();
+
+  EXPECT_EQ(P1, P2);
+  EXPECT_TRUE(DC == ToD1 || DC == ToD2);
+
+  ASTImporterLookupTable *Tbl = SharedState

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-06-10 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 351083.
ksyx added a comment.

add: zmmul arch string test


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

https://reviews.llvm.org/D103313

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoM.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/zmmul.ll
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zmmul-invaild.s
  llvm/test/MC/RISCV/rv32zmmul-valid.s
  llvm/test/MC/RISCV/rv64zmmul-invalid.s
  llvm/test/MC/RISCV/rv64zmmul-valid.s

Index: llvm/test/MC/RISCV/rv64zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-valid.s
@@ -0,0 +1,5 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mulw ra, sp, gp
+mulw ra, sp, gp
Index: llvm/test/MC/RISCV/rv64zmmul-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-invalid.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divw tp, t0, t1
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divuw t2, s0, s2
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remw a0, a1, a2
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remuw a3, a4, a5
Index: llvm/test/MC/RISCV/rv32zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-valid.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mul a4, ra, s0
+mul a4, ra, s0
+
+# CHECK-INST: mulh ra, zero, zero
+mulh x1, x0, x0
+
+# CHECK-INST: mulhsu t0, t2, t1
+mulhsu t0, t2, t1
+
+# CHECK-INST: mulhu a5, a4, a3
+mulhu a5, a4, a3
Index: llvm/test/MC/RISCV/rv32zmmul-invaild.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-invaild.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div s0, s0, s0
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divu gp, a0, a1
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+rem s2, s2, s8
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remu x18, x18, x24
Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -169,7 +169,7 @@
 xor s2, s2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 
 # Instruction not in the base ISA
-mul a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point)
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/CodeGen/RISCV/zmmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/zmmul.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-REM %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileC

[clang] 31859f8 - Implementation of global.get/set for reftypes in LLVM IR

2021-06-10 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2021-06-10T10:07:45+02:00
New Revision: 31859f896cf90d64904134ce7b31230f374c3fcc

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

LOG: Implementation of global.get/set for reftypes in LLVM IR

This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and
lowering methods for load and stores of reference types from IR
globals. Once the lowering creates the new nodes, tablegen pattern
matches those and converts them to Wasm global.get/set.

Reviewed By: tlively

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

Added: 
llvm/test/CodeGen/WebAssembly/externref-globalget.ll
llvm/test/CodeGen/WebAssembly/externref-globalset.ll
llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
llvm/test/CodeGen/WebAssembly/externref-undef.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
llvm/test/CodeGen/WebAssembly/funcref-call.ll
llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Modified: 
clang/lib/Basic/Targets/WebAssembly.cpp
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/include/llvm/Support/MachineValueType.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 2a5055c3d534b..eade8e8d0346d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -214,6 +214,8 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   continue;
 }
 if (Feature == "+reference-types") {
+  // FIXME: Ensure address spaces 10 and 20 are marked as non-integral in
+  // the datalayout string.
   HasReferenceTypes = true;
   continue;
 }

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index c8c4219f2820c..03a5a1bb97528 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -350,7 +350,7 @@ class TargetLoweringBase {
   /// Return the in-memory pointer type for the given address space, defaults 
to
   /// the pointer type from the data layout.  FIXME: The default needs to be
   /// removed once all the code is updated.
-  MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
+  virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
 return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
   }
 

diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.h 
b/llvm/include/llvm/CodeGen/ValueTypes.h
index e7346f7a75abc..4001b39dae279 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -120,6 +120,9 @@ namespace llvm {
   return changeExtendedTypeToInteger();
 }
 
+/// Test if the given EVT has zero size
+bool isZeroSized() const { return getSizeInBits() == 0; }
+
 /// Test if the given EVT is simple (as opposed to being extended).
 bool isSimple() const {
   return V.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE;
@@ -207,7 +210,9 @@ namespace llvm {
 }
 
 /// Return true if the bit size is a multiple of 8.
-bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
+bool isByteSized() const {
+  return !isZeroSized() && getSizeInBits().isKnownMultipleOf(8);
+}
 
 /// Return true if the size is a power-of-two number of bytes.
 bool isRound() const {

diff  --git a/llvm/include/llvm/Support/MachineValueType.h 
b/llvm/include/llvm/Support/MachineValueType.h
index 88ae8f8e6fc4d..9b95943e484a7 100644
--- a/llvm/include/llvm/Support/MachineValueType.h
+++ b/llvm/include/llvm/Support/MachineValueType.h
@@ -1026,6 +1026,11 @@ namespace llvm {
   }
 }
 
+/// Test if the given MVT has zero size
+bool isZeroSized() const {
+  return !getSizeInBits().isSc

[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-06-10 Thread Paulo Matos via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
pmatos marked 2 inline comments as done.
Closed by commit rG31859f896cf9: Implementation of global.get/set for reftypes 
in LLVM IR (authored by pmatos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

Files:
  clang/lib/Basic/Targets/WebAssembly.cpp
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,23 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
+; CHECK: .tabletype __funcref_call_table, funcref
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s 2>&1 | File

[PATCH] D104012: [clang][deps] Move stripping of diagnostic serialization from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To prevent the creation of diagnostics file, `clang-scan-deps` strips the 
corresponding command-line argument. This behavior is useful even when using 
the C++ `DependencyScanner` library.

This patch transforms stripping of command-line in `clang-scan-deps` into 
stripping of `CompilerInvocation` in `DependencyScanning`.

AFAIK, the `clang-cl` driver doesn't even accept `--serialize-diagnostics`, so 
I've removed the test. (It would fail with an unknown command-line argument 
otherwise.)

Note: Since we're generating the command-line for modules from 
`CompilerInvocation`, the `--serialize-diagnostics` argument won't be 
generated. This of course happened in `clang-scan-deps` even before this patch, 
but not in the `DependencyScanning` library. This will be resolved in a future 
patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104012

Files:
  clang/include/clang/Tooling/ArgumentsAdjusters.h
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
  clang/test/ClangScanDeps/strip_diag_serialize.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -570,8 +570,6 @@
 AdjustedArgs.insert(AdjustedArgs.end(), FlagsEnd, Args.end());
 return AdjustedArgs;
   });
-  AdjustingCompilations->appendArgumentsAdjuster(
-  tooling::getClangStripSerializeDiagnosticAdjuster());
 
   SharedStream Errs(llvm::errs());
   // Print out the dependency results to STDOUT by default.
Index: clang/test/ClangScanDeps/strip_diag_serialize.cpp
===
--- clang/test/ClangScanDeps/strip_diag_serialize.cpp
+++ clang/test/ClangScanDeps/strip_diag_serialize.cpp
@@ -8,6 +8,5 @@
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 2>&1 | FileCheck %s
 // CHECK-NOT: unable to open file
 // CHECK: strip_diag_serialize_input.cpp
-// CHECK: strip_diag_serialize_input_clangcl.cpp
 
 #warning "diagnostic"
Index: clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
===
--- clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
+++ clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
@@ -3,10 +3,5 @@
   "directory": "DIR",
   "command": "clang -E -fsyntax-only DIR/strip_diag_serialize_input.cpp 
--serialize-diagnostics /does/not/exist",
   "file": "DIR/strip_diag_serialize_input.cpp"
-},
-{
-  "directory": "DIR",
-  "command": "clang-cl /E --serialize-diagnostics A:/does/not/exist -- 
DIR/strip_diag_serialize_input_clangcl.cpp",
-  "file": "DIR/strip_diag_serialize_input_clangcl.cpp"
 }
 ]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -85,6 +85,8 @@
 
 // Don't print 'X warnings and Y errors generated'.
 Compiler.getDiagnosticOpts().ShowCarets = false;
+// Don't write out diagnostic file.
+Compiler.getDiagnosticOpts().DiagnosticSerializationFile.clear();
 // Create the compiler's actual diagnostics engine.
 Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
 if (!Compiler.hasDiagnostics())
Index: clang/lib/Tooling/ArgumentsAdjusters.cpp
===
--- clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -86,22 +86,6 @@
   };
 }
 
-ArgumentsAdjuster getClangStripSerializeDiagnosticAdjuster() {
-  return [](const CommandLineArguments &Args, StringRef /*unused*/) {
-CommandLineArguments AdjustedArgs;
-for (size_t i = 0, e = Args.size(); i < e; ++i) {
-  StringRef Arg = Args[i];
-  if (Arg == "--serialize-diagnostics") {
-// Skip the diagnostic output argument.
-++i;
-continue;
-  }
-  AdjustedArgs.push_back(Args[i]);
-}
-return AdjustedArgs;
-  };
-}
-
 ArgumentsAdjuster getClangStripDependencyFileAdjuster() {
   return [](const CommandLineArguments &Args, StringRef /*unused*/) {
 auto UsingClDriver = (getDriverMode(Args) == "cl");
Index: clang/include/clang/Tooling/ArgumentsAdjusters.h
===
--- clang/include/clang/Tooling/ArgumentsAdjusters.h
+++ clang/include/clang/Tooling/ArgumentsAdjusters.h
@@ -43,10 +43,6 @@
 /// argume

[PATCH] D103630: [analyzer] Refactor trackRValueExpression into ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D103630#2809658 , @NoQ wrote:

> I guess you should mark all of these commits as NFC?

I thought about, but they do change one thing: return value of 
`trackExpressionValue`.  With each commit it's getting more consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103630

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


[PATCH] D103618: [analyzer] Change FindLastStoreBRVisitor to use Tracker

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2274
+   const StackFrameContext *Origin) {
+  Tracker::create(Report)->track(V, R, Opts, Origin);
+}

NoQ wrote:
> How does lifetime work here? Do I understand correctly that the tracker is 
> only kept alive by the `FindLastStoreBRVisitor` instance, even after its 
> completion?
Correct, every `TrackingVisitor` keeps its parent tracker alive.  We can 
optimize it a bit by setting it to `null` when the visitor is done early.  But 
it feels like such a negligible gain that I didn't bother.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103618

___
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

2021-06-10 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

@njames93, Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[clang] c5ffc6f - [OpenCL] Add builtin header test

2021-06-10 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-06-10T10:05:53+01:00
New Revision: c5ffc6f8bd6ae0e187de8b6a0e4300161952ba66

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

LOG: [OpenCL] Add builtin header test

Add a test to verify OpenCL builtin declarations using
OpenCLBuiltins.td.

This test consists of parsing a 60k line generated input file.  The
entire test takes about 60s with a debug build on a decent machine.
Admittedly this is not the fastest test, but doesn't seem excessive
compared to other tests in clang/test/Headers (with one of the tests
taking 85s for example).

RFC: https://lists.llvm.org/pipermail/cfe-dev/2021-April/067973.html

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

Added: 
clang/test/Headers/lit.local.cfg
clang/test/Headers/opencl-builtins.cl

Modified: 


Removed: 




diff  --git a/clang/test/Headers/lit.local.cfg 
b/clang/test/Headers/lit.local.cfg
new file mode 100644
index 0..7774a20d637b1
--- /dev/null
+++ b/clang/test/Headers/lit.local.cfg
@@ -0,0 +1,4 @@
+config.substitutions = list(config.substitutions)
+
+# Enable substituting Clang Sema source directory for TableGen input.
+config.substitutions.append(('%clang_src_sema_dir', 
os.path.join(config.clang_src_dir, 'lib', 'Sema')))

diff  --git a/clang/test/Headers/opencl-builtins.cl 
b/clang/test/Headers/opencl-builtins.cl
new file mode 100644
index 0..68ac2922c2ac4
--- /dev/null
+++ b/clang/test/Headers/opencl-builtins.cl
@@ -0,0 +1,19 @@
+// RUN: clang-tblgen -gen-clang-opencl-builtin-tests 
%clang_src_sema_dir/OpenCLBuiltins.td -o %t.cl
+// RUN: %clang_cc1 -include %s %t.cl -triple spir -verify -fsyntax-only 
-cl-std=CL2.0 -finclude-default-header
+// RUN: %clang_cc1 -include %s %t.cl -triple spir -verify -fsyntax-only 
-cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+
+// Generate an OpenCL source file containing a call to each builtin from
+// OpenCLBuiltins.td and then run that generated source file through the
+// frontend.
+//
+// Then test that:
+//  - The generated file can be parsed using opencl-c.h, giving some confidence
+//that OpenCLBuiltins.td does not provide more than what opencl-c.h 
provides
+//(but not vice versa).
+//
+//  - The generated file can be parsed using -fdeclare-opencl-builtins, 
ensuring
+//some internal consistency of declarations in OpenCLBuiltins.td.  For
+//example, addition of builtin declarations that lead to ambiguity during
+//overload resolution will cause this test to fail.
+
+// expected-no-diagnostics



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


[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-06-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Hi @pmatos, this has caused SVE related failures on our AArch64 bot (and 
probably others):
https://lab.llvm.org/buildbot/#/builders/43/builds/7187

Not an SVE expert myself but if you need help figuring it out I can find 
someone to help out I'm sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

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


[PATCH] D103605: [analyzer] Introduce a new interface for tracking

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:110
+  /// (inlined defensive checks, returned null).
+  bool EnableNullFPSuppression = true;
+};

xazax.hun wrote:
> I vaguely remember we wanting to put this defensive check suppression in the 
> related checkers. If that is the case, I wonder if this option belongs here. 
It is not really about suppressing it at all for all checkers.  Such option 
already exists in analyzer options.
This one is used specifically for situations when globally suppressions are on, 
but don't make sense for that particular type (like array index).



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:210
+  ///much.
+  virtual Result track(KnownSVal V, const MemRegion *R,
+   TrackingOptions Opts = {},

NoQ wrote:
> vsavchenko wrote:
> > NoQ wrote:
> > > xazax.hun wrote:
> > > > Not directly related to this patch, but I wonder if we want to have 
> > > > unknown values with identities at some point, so we can track them.
> > > `UnknownVal` is a stop-gap for situations when we've screwed up so badly 
> > > we don't even have types anymore. The only thing I'd ever want from them 
> > > is to disappear :)
> > > 
> > > I guess this could be useful for a debug checker that could explain where 
> > > does an `UnknownVal` come from. In this case unknown values don't need 
> > > identities; we can track other values without identities, such as null 
> > > pointers, just fine.
> > +1 for not caring about `UnknownVal`.
> That said, I'd rather not force the caller to perform a `getAs<>()`. It's 
> pretty cumbersome and we can do the right thing (ignore it) in the callee 
> anyway.
OK, I see, so we can call it with whatever value, but track only known values, 
correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103605

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


[PATCH] D90238: [clang-format] Added ReferenceAlignmentStyle option - (Update to D31635)

2021-06-10 Thread Seraphime Kirkovski (VMware) via Phabricator via cfe-commits
skirkovski added a comment.

Hi @catskul, @MyDeveloperDay,

Is there still interest in this feature ?

My organization has had an internal implementation of this for years and I 
would like to replace it with an upstream version (and this one seems almost 
approved).

Let me know if I can help getting this revision upstream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90238

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


[clang] ac677e6 - [OpenCL] Relax test implicit members in C++ for OpenCL

2021-06-10 Thread Ole Strohm via cfe-commits

Author: Ole Strohm
Date: 2021-06-10T10:18:52+01:00
New Revision: ac677e69bdfc84fc64bfbc83977282d5c5223206

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

LOG: [OpenCL] Relax test implicit members in C++ for OpenCL

Addresses the issue from a comment in D103252

Relaxes the test to account for some targets with added attributes
to inside the pattern.

Added: 


Modified: 
clang/test/AST/ast-dump-implicit-members.clcpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-implicit-members.clcpp 
b/clang/test/AST/ast-dump-implicit-members.clcpp
index 5e1eb7c48c2a9..f80211e1f33d4 100644
--- a/clang/test/AST/ast-dump-implicit-members.clcpp
+++ b/clang/test/AST/ast-dump-implicit-members.clcpp
@@ -7,8 +7,8 @@ void f() {
 i = i;
 }
 
-// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
__generic noexcept'
-// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &) __generic'
-// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (__generic S 
&&) __generic'
-// CHECK: CXXMethodDecl {{.*}} implicit used constexpr operator= '__generic S 
&(const __generic S &) __generic noexcept'
-// CHECK: CXXMethodDecl {{.*}} implicit constexpr operator= '__generic S 
&(__generic S &&) __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void (){{.*}} 
__generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &){{.*}} __generic'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (__generic S 
&&){{.*}} __generic'
+// CHECK: CXXMethodDecl {{.*}} implicit used constexpr operator= '__generic S 
&(const __generic S &){{.*}} __generic noexcept'
+// CHECK: CXXMethodDecl {{.*}} implicit constexpr operator= '__generic S 
&(__generic S &&){{.*}} __generic'



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


[PATCH] D103252: [C++4OpenCL] Fix missing address space on implicit move assignment operator

2021-06-10 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added inline comments.



Comment at: clang/test/AST/ast-dump-implicit-members.clcpp:10
+
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
__generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &) __generic'

abhinavgaba wrote:
> Could you please relax these checks? The test fails with `-triple 
> i386-pc-win32`  with errors like this:
> ```
> ast-dump-implicit-members.clcpp:10:11: error: CHECK: expected string not 
> found in input
> // CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
> __generic noexcept'
>   ^
> :1:1: note: scanning from here
> Dumping __NSConstantString:
> ^
> :16:18: note: possible intended match here
> |-CXXConstructorDecl 0x10b6c718  col:8 implicit used constexpr S 'void 
> () __attribute__((thiscall)) __generic noexcept' inline default trivial
>  ^
> ```
Hi, sorry for this.
I have relaxed the tests in rGac677e69bdfc, so hopefully that should fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103252

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


[clang] 7fb1f62 - [clang][Arm] Require arm and aarch64 target for bf16 intrinsics test

2021-06-10 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-06-10T09:45:10Z
New Revision: 7fb1f62d12c67d4d3193c84687f0d1267d11ba99

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

LOG: [clang][Arm] Require arm and aarch64 target for bf16 intrinsics test

Added: 


Modified: 
clang/test/CodeGen/arm-bf16-convert-intrinsics.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c 
b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
index 7c65f7270ab7d..75304a43f05c0 100644
--- a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
+++ b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
@@ -17,6 +17,9 @@
 // RUN:   | opt -S -mem2reg \
 // RUN:   | FileCheck --check-prefixes=CHECK,CHECK-A32-SOFTFP %s
 
+// REQUIRES: arm-registered-target
+// REQUIRES: aarch64-registered-target
+
 #include 
 
 // CHECK-A64-LABEL: @test_vcvt_f32_bf16(



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


[PATCH] D103605: [analyzer] Introduce a new interface for tracking

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351098.
vsavchenko marked 4 inline comments as done.
vsavchenko added a comment.

Fix review remarks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103605

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -65,6 +65,7 @@
 
 using namespace clang;
 using namespace ento;
+using namespace bugreporter;
 
 //===--===//
 // Utility functions.
@@ -2045,6 +2046,53 @@
   }
 }
 
+//===--===//
+//Tracker implementation
+//===--===//
+
+Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
+  // TODO: split trackExpressionValue and FindLastStoreBRVisitor into handlers
+  //   and add them here.
+}
+
+Tracker::Result Tracker::track(const Expr *E, const ExplodedNode *N,
+   TrackingOptions Opts) {
+  if (!E || !N)
+return {};
+
+  const Expr *Inner = peelOffOuterExpr(E, N);
+  const ExplodedNode *LVNode = findNodeForExpression(N, Inner);
+  if (!LVNode)
+return {};
+
+  Result CombinedResult;
+  // Iterate through the handlers in the order according to their priorities.
+  for (ExpressionHandlerPtr &Handler : ExpressionHandlers) {
+CombinedResult.combineWith(Handler->handle(Inner, N, LVNode, Opts));
+if (CombinedResult.WasInterrupted)
+  break;
+  }
+
+  return CombinedResult;
+}
+
+Tracker::Result Tracker::track(SVal V, const MemRegion *R, TrackingOptions Opts,
+   const StackFrameContext *Origin) {
+  // TODO: support this operation after dismantling FindLastStoreBRVisitor
+  return {};
+}
+
+PathDiagnosticPieceRef Tracker::handle(StoreInfo SI, TrackingOptions Opts) {
+  // Iterate through the handlers in the order according to their priorities.
+  for (StoreHandlerPtr &Handler : StoreHandlers) {
+if (PathDiagnosticPieceRef Result = Handler->handle(SI, Opts))
+  // If the handler produced a non-null piece, return it.
+  // There is no need in asking other handlers.
+  return Result;
+  }
+  return {};
+}
+
 bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
const Expr *E,
PathSensitiveBugReport &report,
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -21,7 +21,9 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include 
 #include 
+#include 
 
 namespace clang {
 
@@ -99,6 +101,223 @@
   Condition
 };
 
+/// Defines a set of options altering tracking behavior.
+struct TrackingOptions {
+  /// Specifies the kind of tracking.
+  TrackingKind Kind = TrackingKind::Thorough;
+  /// Specifies whether we should employ false positive suppression
+  /// (inlined defensive checks, returned null).
+  bool EnableNullFPSuppression = true;
+};
+
+/// Describes an event when the value got stored into a memory region.
+///
+/// As opposed to checker checkBind API, it reacts also to binds
+/// generated by the checker as well.  It can be useful when the binding
+/// happened as a result of evalCall, for example.
+struct StoreInfo {
+  enum Kind {
+/// The value got stored into the region during initialization:
+///   int x = 42;
+Initialization,
+/// The value got stored into the region during assignment:
+///   int x;
+///   x = 42;
+Assignment,
+/// The value got stored into the region as block capture.
+/// Block data is modeled as a separate region, thus whenever
+/// the analyzer sees a captured variable, its value is copied
+/// into a special block region.
+BlockCapture
+  };
+
+  /// The type of store operation.
+  Kind StoreKind;
+  /// The node where the store happened.
+  const ExplodedNode *StoreSite;
+  /// The expression where the value comes from.
+  /// NOTE: might be null.
+  Expr *SourceOfTheValue;
+  /// Symbolic value that is being stored.
+  SVal Value;
+  /// Memory regions involved in the store operation.
+  ///   Dest <- Origin
+  /// NOTE: Origin might be null, when the stored value doesn't come
+  ///   from another region.
+  const MemRegion *Dest, *Origin;
+

[PATCH] D103616: [analyzer] Reimplement trackExpressionValue as ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351099.
vsavchenko added a comment.

Rebase and change how we call track for values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103616

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2050,7 +2050,166 @@
 //Tracker implementation
 //===--===//
 
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
+
+// We only track expressions if we believe that they are important. Chances
+// are good that control dependencies to the tracking point are also
+// important because of this, let's explain why we believe control reached
+// this point.
+// TODO: Shouldn't we track control dependencies of every bug location,
+// rather than only tracked expressions?
+if (LVState->getAnalysisManager()
+.getAnalyzerOptions()
+.ShouldTrackConditions) {
+  Report.addVisitor(InputNode);
+  Result.FoundSomethingToTrack = true;
+}
+
+// The message send could be nil due to the receiver being nil.
+// At this point in the path, the receiver should be live since we are at
+// the message send expr. If it is nil, start tracking it.
+if (const Expr *Receiver =
+NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
+  Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+
+// Track the index if this is an array subscript.
+if (const auto *Arr = dyn_cast(Inner))
+  Result.combineWith(getParentTracker().track(
+  Arr->getIdx(), LVNode,
+  {Opts.Kind, /*EnableNullFPSuppression*/ false}));
+
+// See if the expression we're interested refers to a variable.
+// If so, we can track both its contents and constraints on its value.
+if (ExplodedGraph::isInterestingLValueExpr(Inner)) {
+  SVal LVal = LVNode->getSVal(Inner);
+
+  const MemRegion *RR = getLocationRegionIfReference(Inner, LVNode);
+  bool LVIsNull = LVState->isNull(LVal).isConstrainedTrue();
+
+  // If this is a C++ reference to a null pointer, we are tracking the
+  // pointer. In addition, we should find the store at which the reference
+  // got initialized.
+  if (RR && !LVIsNull)
+Result.combineWith(getParentTracker().track(LVal, RR, Opts, SFC));
+
+  // In case of C++ references, we want to differentiate between a null
+  // reference and reference to null pointer.
+  // If the LVal is null, check if we are dealing with null reference.
+  // For those, we want to track the location of the reference.
+  const MemRegion *R =
+  (RR && LVIsNull) ? RR : LVNode->getSVal(Inner).getAsRegion();
+
+  if (R) {
+
+// Mark both the variable region and its contents as interesting.
+SVal V = LVState->getRawSVal(loc::MemRegionVal(R));
+Report.addVisitor(cast(R), Opts.Kind);
+
+// When we got here, we do have something to track, and we will
+// interrupt.
+Result.FoundSomethingToTrack = true;
+Result.WasInterrupted = true;
+
+MacroNullReturnSuppressionVisitor::addMacroVisitorIfNecessary(
+LVNode, R, Opts.EnableNullFPSuppression, Report, V);
+
+Report.markInteresting(V, Opts.Kind);
+Report.addVisitor(R);
+
+// If the contents are symbolic and null, find out when they became
+// null.
+if (V.getAsLocSymbol(/*IncludeBaseRegions=*/true))
+  if (LVState->isNull(V).isConstrainedTrue())
+Report.addVisitor(V.castAs(),
+false);
+
+// Add visitor, which will suppress inline defensive checks.
+if (auto DV = V.getAs())
+  if (!DV->isZeroConstant() && Opts.EnableNullFPSuppression)
+// Note that LVNode may be too late (i.e., too far from the
+// InputNode) because the lvalue may have been computed before the
+// inlined call was evaluated. InputNode may as well be too early
+// here, because the symbol is already dead; this, however, is fine
+// because we can still find the n

[PATCH] D103616: [analyzer] Reimplement trackExpressionValue as ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351102.
vsavchenko added a comment.

Rebase and change `KnownSVal` to `SVal` in `trackStoredValue`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103616

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1488,8 +1488,8 @@
 if (!IsParam)
   InitE = InitE->IgnoreParenCasts();
 
-bugreporter::trackExpressionValue(StoreSite, InitE, BR, TKind,
-  EnableNullFPSuppression);
+getParentTracker().track(InitE, StoreSite,
+ {TKind, EnableNullFPSuppression});
   }
 
   // Let's try to find the region where the value came from.
@@ -1588,8 +1588,8 @@
   dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
 if (auto KV = State->getSVal(OriginalR).getAs())
-  BR.addVisitor(
-  *KV, OriginalR, EnableNullFPSuppression, TKind, OriginSFC);
+  getParentTracker().track(
+  *KV, OriginalR, {TKind, EnableNullFPSuppression}, OriginSFC);
   }
 }
   }
@@ -2050,7 +2050,166 @@
 //Tracker implementation
 //===--===//
 
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
+
+// We only track expressions if we believe that they are important. Chances
+// are good that control dependencies to the tracking point are also
+// important because of this, let's explain why we believe control reached
+// this point.
+// TODO: Shouldn't we track control dependencies of every bug location,
+// rather than only tracked expressions?
+if (LVState->getAnalysisManager()
+.getAnalyzerOptions()
+.ShouldTrackConditions) {
+  Report.addVisitor(InputNode);
+  Result.FoundSomethingToTrack = true;
+}
+
+// The message send could be nil due to the receiver being nil.
+// At this point in the path, the receiver should be live since we are at
+// the message send expr. If it is nil, start tracking it.
+if (const Expr *Receiver =
+NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
+  Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+
+// Track the index if this is an array subscript.
+if (const auto *Arr = dyn_cast(Inner))
+  Result.combineWith(getParentTracker().track(
+  Arr->getIdx(), LVNode,
+  {Opts.Kind, /*EnableNullFPSuppression*/ false}));
+
+// See if the expression we're interested refers to a variable.
+// If so, we can track both its contents and constraints on its value.
+if (ExplodedGraph::isInterestingLValueExpr(Inner)) {
+  SVal LVal = LVNode->getSVal(Inner);
+
+  const MemRegion *RR = getLocationRegionIfReference(Inner, LVNode);
+  bool LVIsNull = LVState->isNull(LVal).isConstrainedTrue();
+
+  // If this is a C++ reference to a null pointer, we are tracking the
+  // pointer. In addition, we should find the store at which the reference
+  // got initialized.
+  if (RR && !LVIsNull)
+Result.combineWith(getParentTracker().track(LVal, RR, Opts, SFC));
+
+  // In case of C++ references, we want to differentiate between a null
+  // reference and reference to null pointer.
+  // If the LVal is null, check if we are dealing with null reference.
+  // For those, we want to track the location of the reference.
+  const MemRegion *R =
+  (RR && LVIsNull) ? RR : LVNode->getSVal(Inner).getAsRegion();
+
+  if (R) {
+
+// Mark both the variable region and its contents as interesting.
+SVal V = LVState->getRawSVal(loc::MemRegionVal(R));
+Report.addVisitor(cast(R), Opts.Kind);
+
+// When we got here, we do have something to track, and we will
+// interrupt.
+Result.FoundSomethingToTrack = true

[clang-tools-extra] 0ce61d4 - Add explicit braces to silence warning about ambiguous 'else' inside the EXPECT_EQ macro. NFCI.

2021-06-10 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-10T10:55:24+01:00
New Revision: 0ce61d47c03df280ce41e226527f8c72fcfa4b13

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

LOG: Add explicit braces to silence warning about ambiguous 'else' inside the 
EXPECT_EQ macro. NFCI.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SelectionTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp 
b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
index a063c84a6a4ca..85b7d9fb541a1 100644
--- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -659,10 +659,11 @@ TEST(SelectionTest, CreateAll) {
   AST.getASTContext(), AST.getTokens(), Test.point("ambiguous"),
   Test.point("ambiguous"), [&](SelectionTree T) {
 // Expect to see the right-biased tree first.
-if (Seen == 0)
+if (Seen == 0) {
   EXPECT_EQ("BinaryOperator", nodeKind(T.commonAncestor()));
-else if (Seen == 1)
+} else if (Seen == 1) {
   EXPECT_EQ("IntegerLiteral", nodeKind(T.commonAncestor()));
+}
 ++Seen;
 return false;
   });



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


[clang] 64de876 - Revert "Implementation of global.get/set for reftypes in LLVM IR"

2021-06-10 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2021-06-10T10:11:17Z
New Revision: 64de8763aa7cabc5aee4312ae2f9a68d8fd10bfa

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

LOG: Revert "Implementation of global.get/set for reftypes in LLVM IR"

This reverts commit 31859f896cf90d64904134ce7b31230f374c3fcc.

Causing SVE and RISCV-V test failures on bots.

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.cpp
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/include/llvm/Support/MachineValueType.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 
llvm/test/CodeGen/WebAssembly/externref-globalget.ll
llvm/test/CodeGen/WebAssembly/externref-globalset.ll
llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
llvm/test/CodeGen/WebAssembly/externref-undef.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
llvm/test/CodeGen/WebAssembly/funcref-call.ll
llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
llvm/test/CodeGen/WebAssembly/funcref-globalset.ll



diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index eade8e8d0346d..2a5055c3d534b 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -214,8 +214,6 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   continue;
 }
 if (Feature == "+reference-types") {
-  // FIXME: Ensure address spaces 10 and 20 are marked as non-integral in
-  // the datalayout string.
   HasReferenceTypes = true;
   continue;
 }

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index d61dd77c878d1..c1b199f4ed58e 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -350,7 +350,7 @@ class TargetLoweringBase {
   /// Return the in-memory pointer type for the given address space, defaults 
to
   /// the pointer type from the data layout.  FIXME: The default needs to be
   /// removed once all the code is updated.
-  virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
+  MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const {
 return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
   }
 

diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.h 
b/llvm/include/llvm/CodeGen/ValueTypes.h
index 4001b39dae279..e7346f7a75abc 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -120,9 +120,6 @@ namespace llvm {
   return changeExtendedTypeToInteger();
 }
 
-/// Test if the given EVT has zero size
-bool isZeroSized() const { return getSizeInBits() == 0; }
-
 /// Test if the given EVT is simple (as opposed to being extended).
 bool isSimple() const {
   return V.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE;
@@ -210,9 +207,7 @@ namespace llvm {
 }
 
 /// Return true if the bit size is a multiple of 8.
-bool isByteSized() const {
-  return !isZeroSized() && getSizeInBits().isKnownMultipleOf(8);
-}
+bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
 
 /// Return true if the size is a power-of-two number of bytes.
 bool isRound() const {

diff  --git a/llvm/include/llvm/Support/MachineValueType.h 
b/llvm/include/llvm/Support/MachineValueType.h
index 9b95943e484a7..88ae8f8e6fc4d 100644
--- a/llvm/include/llvm/Support/MachineValueType.h
+++ b/llvm/include/llvm/Support/MachineValueType.h
@@ -1026,11 +1026,6 @@ namespace llvm {
   }
 }
 
-/// Test if the given MVT has zero size
-bool isZeroSized() const {
-  return !getSizeInBits().isScalable() && getFixedSizeInBits() == 0;
-}
-
 /// Return the size of the specified fixed width value type in bits. The
 /// function will assert if the type is scalable.
 uint64_t getFixedSizeInBit

[PATCH] D95425: Implementation of global.get/set for reftypes in LLVM IR

2021-06-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Also affecting riscv-v (riscvv?) so I've reverted the change.

https://lab.llvm.org/buildbot/#/builders/67/builds/3087


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95425

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


[PATCH] D103628: [analyzer] Turn ReturnVisitor into a tracking visitor

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351104.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103628

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -906,7 +906,7 @@
 ///
 /// This visitor is intended to be used when another visitor discovers that an
 /// interesting value comes from an inlined function call.
-class ReturnVisitor : public BugReporterVisitor {
+class ReturnVisitor : public TrackingBugReporterVisitor {
   const StackFrameContext *CalleeSFC;
   enum {
 Initial,
@@ -920,10 +920,11 @@
   bugreporter::TrackingKind TKind;
 
 public:
-  ReturnVisitor(const StackFrameContext *Frame, bool Suppressed,
-AnalyzerOptions &Options, bugreporter::TrackingKind TKind)
-  : CalleeSFC(Frame), EnableNullFPSuppression(Suppressed),
-Options(Options), TKind(TKind) {}
+  ReturnVisitor(TrackerRef ParentTracker, const StackFrameContext *Frame,
+bool Suppressed, AnalyzerOptions &Options,
+bugreporter::TrackingKind TKind)
+  : TrackingBugReporterVisitor(ParentTracker), CalleeSFC(Frame),
+EnableNullFPSuppression(Suppressed), Options(Options), TKind(TKind) {}
 
   static void *getTag() {
 static int Tag = 0;
@@ -943,7 +944,8 @@
   /// node, looking for when the given statement was processed. If it turns out
   /// the statement is a call that was inlined, we add the visitor to the
   /// bug report, so it can print a note later.
-  static void addVisitorIfNecessary(const ExplodedNode *Node, const Stmt *S,
+  static void addVisitorIfNecessary(TrackerRef ParentTracker,
+const ExplodedNode *Node, const Stmt *S,
 PathSensitiveBugReport &BR,
 bool InEnableNullFPSuppression,
 bugreporter::TrackingKind TKind) {
@@ -1016,8 +1018,8 @@
   if (Optional RetLoc = RetVal.getAs())
 EnableNullFPSuppression = State->isNull(*RetLoc).isConstrainedTrue();
 
-BR.addVisitor(CalleeContext, EnableNullFPSuppression,
- Options, TKind);
+BR.addVisitor(ParentTracker, CalleeContext,
+ EnableNullFPSuppression, Options, TKind);
   }
 
   PathDiagnosticPieceRef visitNodeInitial(const ExplodedNode *N,
@@ -1066,8 +1068,7 @@
 RetE = RetE->IgnoreParenCasts();
 
 // Let's track the return value.
-bugreporter::trackExpressionValue(
-N, RetE, BR, TKind, EnableNullFPSuppression);
+getParentTracker().track(RetE, N, {TKind, EnableNullFPSuppression});
 
 // Build an appropriate message based on the return value.
 SmallString<64> Msg;
@@ -1183,7 +1184,9 @@
   if (!State->isNull(*ArgV).isConstrainedTrue())
 continue;
 
-  if (trackExpressionValue(N, ArgE, BR, TKind, EnableNullFPSuppression))
+  if (getParentTracker()
+  .track(ArgE, N, {TKind, EnableNullFPSuppression})
+  .FoundSomethingToTrack)
 ShouldInvalidate = false;
 
   // If we /can't/ track the null pointer, we should err on the side of
@@ -2197,8 +2200,9 @@
 // track the constraints on its contents.
 SVal V = LVState->getSValAsScalarOrLoc(Inner, 
LVNode->getLocationContext());
 
-ReturnVisitor::addVisitorIfNecessary(
-LVNode, Inner, Report, Opts.EnableNullFPSuppression, Opts.Kind);
+ReturnVisitor::addVisitorIfNecessary(&getParentTracker(), LVNode, Inner,
+ Report, Opts.EnableNullFPSuppression,
+ Opts.Kind);
 
 // Is it a symbolic value?
 if (auto L = V.getAs()) {


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -906,7 +906,7 @@
 ///
 /// This visitor is intended to be used when another visitor discovers that an
 /// interesting value comes from an inlined function call.
-class ReturnVisitor : public BugReporterVisitor {
+class ReturnVisitor : public TrackingBugReporterVisitor {
   const StackFrameContext *CalleeSFC;
   enum {
 Initial,
@@ -920,10 +920,11 @@
   bugreporter::TrackingKind TKind;
 
 public:
-  ReturnVisitor(const StackFrameContext *Frame, bool Suppressed,
-AnalyzerOptions &Options, bugreporter::TrackingKind TKind)
-  : CalleeSFC(Frame), EnableNullFPSuppression(Suppressed),
-Options(Options), TKind(TKind) {}
+  ReturnVisitor(TrackerRef ParentTracker, const StackFrameContext *Frame,
+

[PATCH] D103630: [analyzer] Refactor trackRValueExpression into ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351106.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103630

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2053,44 +2053,6 @@
   return N;
 }
 
-/// Attempts to add visitors to track an RValue expression back to its point of
-/// origin. Works similarly to trackExpressionValue, but accepts only RValues.
-static void trackRValueExpression(const ExplodedNode *InputNode, const Expr *E,
-  PathSensitiveBugReport &report,
-  bugreporter::TrackingKind TKind,
-  bool EnableNullFPSuppression) {
-  assert(E->isRValue() && "The expression is not an rvalue!");
-  const ExplodedNode *RVNode = findNodeForExpression(InputNode, E);
-  if (!RVNode)
-return;
-  ProgramStateRef RVState = RVNode->getState();
-  SVal V = RVState->getSValAsScalarOrLoc(E, RVNode->getLocationContext());
-  const auto *BO = dyn_cast(E);
-  if (!BO)
-return;
-  if (!V.isZeroConstant())
-return;
-  if (!BO->isMultiplicativeOp())
-return;
-
-  SVal RHSV = RVState->getSVal(BO->getRHS(), RVNode->getLocationContext());
-  SVal LHSV = RVState->getSVal(BO->getLHS(), RVNode->getLocationContext());
-
-  // Track both LHS and RHS of a multiplication.
-  if (BO->getOpcode() == BO_Mul) {
-if (LHSV.isZeroConstant())
-  trackExpressionValue(InputNode, BO->getLHS(), report, TKind,
-   EnableNullFPSuppression);
-if (RHSV.isZeroConstant())
-  trackExpressionValue(InputNode, BO->getRHS(), report, TKind,
-   EnableNullFPSuppression);
-  } else { // Track only the LHS of a division or a modulo.
-if (LHSV.isZeroConstant())
-  trackExpressionValue(InputNode, BO->getLHS(), report, TKind,
-   EnableNullFPSuppression);
-  }
-}
-
 //===--===//
 //Tracker implementation
 //===--===//
@@ -2245,17 +2207,61 @@
   }
 }
 
-if (Inner->isRValue())
-  // TODO: Incorporate as Handler
-  trackRValueExpression(LVNode, Inner, Report, Opts.Kind,
-Opts.EnableNullFPSuppression);
-
 return Result;
   }
 };
 
+/// Attempts to add visitors to track an RValue expression back to its point of
+/// origin.
+class RValueHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *E, const ExplodedNode *InputNode,
+ const ExplodedNode *ExprNode,
+ TrackingOptions Opts) override {
+if (!E->isRValue())
+  return {};
+
+const ExplodedNode *RVNode = findNodeForExpression(ExprNode, E);
+if (!RVNode)
+  return {};
+
+ProgramStateRef RVState = RVNode->getState();
+SVal V = RVState->getSValAsScalarOrLoc(E, RVNode->getLocationContext());
+const auto *BO = dyn_cast(E);
+
+if (!BO || !BO->isMultiplicativeOp() || !V.isZeroConstant())
+  return {};
+
+SVal RHSV = RVState->getSVal(BO->getRHS(), RVNode->getLocationContext());
+SVal LHSV = RVState->getSVal(BO->getLHS(), RVNode->getLocationContext());
+
+// Track both LHS and RHS of a multiplication.
+Tracker::Result CombinedResult;
+Tracker &Parent = getParentTracker();
+
+const auto track = [&CombinedResult, &Parent, ExprNode, Opts](Expr *Inner) {
+  CombinedResult.combineWith(Parent.track(Inner, ExprNode, Opts));
+};
+
+if (BO->getOpcode() == BO_Mul) {
+  if (LHSV.isZeroConstant())
+track(BO->getLHS());
+  if (RHSV.isZeroConstant())
+track(BO->getRHS());
+} else { // Track only the LHS of a division or a modulo.
+  if (LHSV.isZeroConstant())
+track(BO->getLHS());
+}
+
+return CombinedResult;
+  }
+};
+
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   addHighPriorityHandler();
+  addLowPriorityHandler();
   // TODO: split trackExpressionValue and FindLastStoreBRVisitor into handlers
   //   and add them here.
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103631: [analyzer] Turn TrackControlDependencyCond into a tracking visitor

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351107.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103631

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1855,14 +1855,17 @@
 /// An error is emitted at line 3. This visitor realizes that the branch
 /// on line 2 is a control dependency of line 3, and tracks it's condition via
 /// trackExpressionValue().
-class TrackControlDependencyCondBRVisitor final : public BugReporterVisitor {
+class TrackControlDependencyCondBRVisitor final
+: public TrackingBugReporterVisitor {
   const ExplodedNode *Origin;
   ControlDependencyCalculator ControlDeps;
   llvm::SmallSet VisitedBlocks;
 
 public:
-  TrackControlDependencyCondBRVisitor(const ExplodedNode *O)
-  : Origin(O), ControlDeps(&O->getCFG()) {}
+  TrackControlDependencyCondBRVisitor(TrackerRef ParentTracker,
+  const ExplodedNode *O)
+  : TrackingBugReporterVisitor(ParentTracker), Origin(O),
+ControlDeps(&O->getCFG()) {}
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
 static int x = 0;
@@ -1960,9 +1963,9 @@
   // isn't sufficient, because a new visitor is created for each tracked
   // expression, hence the BugReport level set.
   if (BR.addTrackedCondition(N)) {
-bugreporter::trackExpressionValue(
-N, Condition, BR, bugreporter::TrackingKind::Condition,
-/*EnableNullFPSuppression=*/false);
+getParentTracker().track(Condition, N,
+ {bugreporter::TrackingKind::Condition,
+  /*EnableNullFPSuppression=*/false});
 return constructDebugPieceForTrackedCondition(Condition, N, BRC);
   }
 }
@@ -2078,7 +2081,8 @@
 if (LVState->getAnalysisManager()
 .getAnalyzerOptions()
 .ShouldTrackConditions) {
-  Report.addVisitor(InputNode);
+  Report.addVisitor(
+  &getParentTracker(), InputNode);
   Result.FoundSomethingToTrack = true;
 }
 


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1855,14 +1855,17 @@
 /// An error is emitted at line 3. This visitor realizes that the branch
 /// on line 2 is a control dependency of line 3, and tracks it's condition via
 /// trackExpressionValue().
-class TrackControlDependencyCondBRVisitor final : public BugReporterVisitor {
+class TrackControlDependencyCondBRVisitor final
+: public TrackingBugReporterVisitor {
   const ExplodedNode *Origin;
   ControlDependencyCalculator ControlDeps;
   llvm::SmallSet VisitedBlocks;
 
 public:
-  TrackControlDependencyCondBRVisitor(const ExplodedNode *O)
-  : Origin(O), ControlDeps(&O->getCFG()) {}
+  TrackControlDependencyCondBRVisitor(TrackerRef ParentTracker,
+  const ExplodedNode *O)
+  : TrackingBugReporterVisitor(ParentTracker), Origin(O),
+ControlDeps(&O->getCFG()) {}
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
 static int x = 0;
@@ -1960,9 +1963,9 @@
   // isn't sufficient, because a new visitor is created for each tracked
   // expression, hence the BugReport level set.
   if (BR.addTrackedCondition(N)) {
-bugreporter::trackExpressionValue(
-N, Condition, BR, bugreporter::TrackingKind::Condition,
-/*EnableNullFPSuppression=*/false);
+getParentTracker().track(Condition, N,
+ {bugreporter::TrackingKind::Condition,
+  /*EnableNullFPSuppression=*/false});
 return constructDebugPieceForTrackedCondition(Condition, N, BRC);
   }
 }
@@ -2078,7 +2081,8 @@
 if (LVState->getAnalysisManager()
 .getAnalyzerOptions()
 .ShouldTrackConditions) {
-  Report.addVisitor(InputNode);
+  Report.addVisitor(
+  &getParentTracker(), InputNode);
   Result.FoundSomethingToTrack = true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103633: [analyzer] Refactor trackExpressionValue to accept TrackingOptions

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351108.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103633

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2314,12 +2314,11 @@
 
 bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
const Expr *E,
-   PathSensitiveBugReport &report,
-   bugreporter::TrackingKind TKind,
-   bool EnableNullFPSuppression) {
+   PathSensitiveBugReport &Report,
+   TrackingOptions Opts) {
 
-  return Tracker::create(report)
-  ->track(E, InputNode, {TKind, EnableNullFPSuppression})
+  return Tracker::create(Report)
+  ->track(E, InputNode, Opts)
   .FoundSomethingToTrack;
 }
 
@@ -2376,9 +2375,9 @@
   // The receiver was nil, and hence the method was skipped.
   // Register a BugReporterVisitor to issue a message telling us how
   // the receiver was null.
-  bugreporter::trackExpressionValue(
-  N, Receiver, BR, bugreporter::TrackingKind::Thorough,
-  /*EnableNullFPSuppression*/ false);
+  bugreporter::trackExpressionValue(N, Receiver, BR,
+{bugreporter::TrackingKind::Thorough,
+ /*EnableNullFPSuppression*/ false});
   // Issue a message saying that the method was skipped.
   PathDiagnosticLocation L(Receiver, BRC.getSourceManager(),
  N->getLocationContext());
Index: clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
@@ -148,7 +148,7 @@
   *BT, "Index is out of bounds", N);
   R->addRange(IdxExpr->getSourceRange());
   bugreporter::trackExpressionValue(
-  N, IdxExpr, *R, bugreporter::TrackingKind::Thorough, false);
+  N, IdxExpr, *R, {bugreporter::TrackingKind::Thorough, false});
   C.emitReport(std::move(R));
   return;
 }
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -284,8 +284,9 @@
   N);
 
   R->addRange(RS->getSourceRange());
-  bugreporter::trackExpressionValue(N, RS->getRetValue(), *R,
-bugreporter::TrackingKind::Thorough, 
false);
+  bugreporter::trackExpressionValue(
+  N, RS->getRetValue(), *R,
+  {bugreporter::TrackingKind::Thorough, 
/*EnableNullFPSuppression=*/false});
   C.emitReport(std::move(R));
 }
 
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -353,9 +353,7 @@
 /// statement. Note that returning \c true does not actually imply
 /// that any visitors were added.
 bool trackExpressionValue(const ExplodedNode *N, const Expr *E,
-  PathSensitiveBugReport &R,
-  TrackingKind TKind = TrackingKind::Thorough,
-  bool EnableNullFPSuppression = true);
+  PathSensitiveBugReport &R, TrackingOptions Opts = 
{});
 
 /// Track how the value got stored into the given region and where it came
 /// from.


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2314,12 +2314,11 @@
 
 bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
const Expr *E,
-   PathSensitiveBugReport &report,
-   bugreporter::TrackingKind TKind,
-   bool EnableNullFPSuppression) {
+   PathSensitiveBugReport &Report,
+

[PATCH] D103633: [analyzer] Refactor trackExpressionValue to accept TrackingOptions

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351109.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103633

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1232,12 +1232,7 @@
   SVal V;
   bool Satisfied = false;
 
-  /// If the visitor is tracking the value directly responsible for the
-  /// bug, we are going to employ false positive suppression.
-  bool EnableNullFPSuppression;
-
-  using TrackingKind = bugreporter::TrackingKind;
-  TrackingKind TKind;
+  TrackingOptions Options;
   const StackFrameContext *OriginSFC;
 
 public:
@@ -1252,11 +1247,9 @@
   ///this visitor can prevent that without polluting the bugpath too
   ///much.
   StoreSiteFinder(bugreporter::TrackerRef ParentTracker, KnownSVal V,
-  const MemRegion *R, bool InEnableNullFPSuppression,
-  TrackingKind TKind,
+  const MemRegion *R, TrackingOptions Options,
   const StackFrameContext *OriginSFC = nullptr)
-  : TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
-EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
+  : TrackingBugReporterVisitor(ParentTracker), R(R), V(V), Options(Options),
 OriginSFC(OriginSFC) {
 assert(R);
   }
@@ -1273,8 +1266,8 @@
   ID.AddPointer(&tag);
   ID.AddPointer(R);
   ID.Add(V);
-  ID.AddInteger(static_cast(TKind));
-  ID.AddBoolean(EnableNullFPSuppression);
+  ID.AddInteger(static_cast(Options.Kind));
+  ID.AddBoolean(Options.EnableNullFPSuppression);
 }
 
 /// Returns true if \p N represents the DeclStmt declaring and initializing
@@ -1533,8 +1526,7 @@
 if (!IsParam)
   InitE = InitE->IgnoreParenCasts();
 
-getParentTracker().track(InitE, StoreSite,
- {TKind, EnableNullFPSuppression});
+getParentTracker().track(InitE, StoreSite, Options);
   }
 
   // Let's try to find the region where the value came from.
@@ -1605,7 +1597,7 @@
 }
   }
 
-  if (TKind == TrackingKind::Condition &&
+  if (Options.Kind == TrackingKind::Condition && OriginSFC &&
   !OriginSFC->isParentOf(StoreSite->getStackFrame()))
 return nullptr;
 
@@ -1613,60 +1605,41 @@
   SmallString<256> sbuf;
   llvm::raw_svector_ostream os(sbuf);
 
+  StoreInfo SI = {StoreInfo::Assignment, // default kind
+  StoreSite,
+  InitE,
+  V,
+  R,
+  OldRegion};
+
   if (Optional PS = StoreSite->getLocationAs()) {
 const Stmt *S = PS->getStmt();
-const char *action = nullptr;
 const auto *DS = dyn_cast(S);
 const auto *VR = dyn_cast(R);
 
 if (DS) {
-  action = R->canPrintPretty() ? "initialized to " :
- "Initializing to ";
+  SI.StoreKind = StoreInfo::Initialization;
 } else if (isa(S)) {
-  action = R->canPrintPretty() ? "captured by block as " :
- "Captured by block as ";
+  SI.StoreKind = StoreInfo::BlockCapture;
   if (VR) {
 // See if we can get the BlockVarRegion.
 ProgramStateRef State = StoreSite->getState();
 SVal V = StoreSite->getSVal(S);
 if (const auto *BDR =
-  dyn_cast_or_null(V.getAsRegion())) {
+dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
 if (auto KV = State->getSVal(OriginalR).getAs())
-  getParentTracker().track(
-  *KV, OriginalR, {TKind, EnableNullFPSuppression}, OriginSFC);
+  getParentTracker().track(*KV, OriginalR, Options, OriginSFC);
   }
 }
   }
 }
-if (action)
-  showBRDiagnostics(action, os, R, V, OldRegion, DS);
-
-  } else if (StoreSite->getLocation().getAs()) {
-if (const auto *VR = dyn_cast(R))
-  showBRParamDiagnostics(os, VR, V, OldRegion);
+  } else if (SI.StoreSite->getLocation().getAs() &&
+ isa(SI.Dest)) {
+SI.StoreKind = StoreInfo::CallArgument;
   }
 
-  if (os.str().empty())
-showBRDefaultDiagnostics(os, R, V, OldRegion);
-
-  if (TKind == bugreporter::TrackingKind::Condition)
-os << WillBeUsedForACondition;
-
-  // Construct a new PathDiagnosticPiece.
-  ProgramPoint P = StoreSite->getLocation();
-  PathDiagnosticLocation L;
-  if (P.getAs() && InitE)
-L = PathDiagnosticLocation(InitE, BRC.getSourceManager(),
-   

[PATCH] D103677: [analyzer] Extract ControlDependencyHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351110.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103677

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2090,17 +2090,14 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class ControlDependencyHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
 
   Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
  const ExplodedNode *LVNode,
  TrackingOptions Opts) override {
-ProgramStateRef LVState = LVNode->getState();
-const StackFrameContext *SFC = LVNode->getStackFrame();
 PathSensitiveBugReport &Report = getParentTracker().getReport();
-Tracker::Result Result;
 
 // We only track expressions if we believe that they are important. Chances
 // are good that control dependencies to the tracking point are also
@@ -2108,14 +2105,31 @@
 // this point.
 // TODO: Shouldn't we track control dependencies of every bug location,
 // rather than only tracked expressions?
-if (LVState->getAnalysisManager()
+if (LVNode->getState()
+->getAnalysisManager()
 .getAnalyzerOptions()
 .ShouldTrackConditions) {
   Report.addVisitor(
   &getParentTracker(), InputNode);
-  Result.FoundSomethingToTrack = true;
+  return {true};
 }
 
+return {};
+  }
+};
+
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
+
 // The message send could be nil due to the receiver being nil.
 // At this point in the path, the receiver should be live since we are at
 // the message send expr. If it is nil, start tracking it.
@@ -2295,7 +2309,8 @@
 
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   // Default expression handlers.
-  addHighPriorityHandler();
+  addLowPriorityHandler();
+  addLowPriorityHandler();
   addLowPriorityHandler();
   // Default store handlers.
   addHighPriorityHandler();


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2090,17 +2090,14 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class ControlDependencyHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
 
   Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
  const ExplodedNode *LVNode,
  TrackingOptions Opts) override {
-ProgramStateRef LVState = LVNode->getState();
-const StackFrameContext *SFC = LVNode->getStackFrame();
 PathSensitiveBugReport &Report = getParentTracker().getReport();
-Tracker::Result Result;
 
 // We only track expressions if we believe that they are important. Chances
 // are good that control dependencies to the tracking point are also
@@ -2108,14 +2105,31 @@
 // this point.
 // TODO: Shouldn't we track control dependencies of every bug location,
 // rather than only tracked expressions?
-if (LVState->getAnalysisManager()
+if (LVNode->getState()
+->getAnalysisManager()
 .getAnalyzerOptions()
 .ShouldTrackConditions) {
   Report.addVisitor(
   &getParentTracker(), InputNode);
-  Result.FoundSomethingToTrack = true;
+  return {true};
 }
 
+return {};
+  }
+};
+
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
+
 // The message send could be nil due to the 

[PATCH] D103902: [analyzer] Extract NilReceiverHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 35.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103902

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2118,24 +2118,35 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class NilReceiverHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
 
   Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
  const ExplodedNode *LVNode,
  TrackingOptions Opts) override {
-ProgramStateRef LVState = LVNode->getState();
-const StackFrameContext *SFC = LVNode->getStackFrame();
-PathSensitiveBugReport &Report = getParentTracker().getReport();
-Tracker::Result Result;
-
 // The message send could be nil due to the receiver being nil.
 // At this point in the path, the receiver should be live since we are at
 // the message send expr. If it is nil, start tracking it.
 if (const Expr *Receiver =
 NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
-  Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+  return getParentTracker().track(Receiver, LVNode, Opts);
+
+return {};
+  }
+};
+
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
 
 // Track the index if this is an array subscript.
 if (const auto *Arr = dyn_cast(Inner))
@@ -2310,6 +2321,7 @@
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   // Default expression handlers.
   addLowPriorityHandler();
+  addLowPriorityHandler();
   addLowPriorityHandler();
   addLowPriorityHandler();
   // Default store handlers.


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2118,24 +2118,35 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class NilReceiverHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
 
   Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
  const ExplodedNode *LVNode,
  TrackingOptions Opts) override {
-ProgramStateRef LVState = LVNode->getState();
-const StackFrameContext *SFC = LVNode->getStackFrame();
-PathSensitiveBugReport &Report = getParentTracker().getReport();
-Tracker::Result Result;
-
 // The message send could be nil due to the receiver being nil.
 // At this point in the path, the receiver should be live since we are at
 // the message send expr. If it is nil, start tracking it.
 if (const Expr *Receiver =
 NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
-  Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+  return getParentTracker().track(Receiver, LVNode, Opts);
+
+return {};
+  }
+};
+
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
 
 // Track the index if this is an array subscript.
 if (const auto *Arr = dyn_cast(Inner))
@@ -2310,6 +2321,7 @@
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   // Default expression handlers.
   addLowPriorityHandler();
+  addLowPriorityHandler();
   addLowPriorityHandler();
   addLowPriorityHandler();
   // Default store handlers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103914: [analyzer] Extract ArrayIndexHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351113.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103914

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2136,6 +2136,23 @@
   }
 };
 
+class ArrayIndexHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+// Track the index if this is an array subscript.
+if (const auto *Arr = dyn_cast(Inner))
+  return getParentTracker().track(
+  Arr->getIdx(), LVNode,
+  {Opts.Kind, /*EnableNullFPSuppression*/ false});
+
+return {};
+  }
+};
+
 class DefaultExpressionHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
@@ -2148,12 +2165,6 @@
 PathSensitiveBugReport &Report = getParentTracker().getReport();
 Tracker::Result Result;
 
-// Track the index if this is an array subscript.
-if (const auto *Arr = dyn_cast(Inner))
-  Result.combineWith(getParentTracker().track(
-  Arr->getIdx(), LVNode,
-  {Opts.Kind, /*EnableNullFPSuppression*/ false}));
-
 // See if the expression we're interested refers to a variable.
 // If so, we can track both its contents and constraints on its value.
 if (ExplodedGraph::isInterestingLValueExpr(Inner)) {
@@ -2322,6 +2333,7 @@
   // Default expression handlers.
   addLowPriorityHandler();
   addLowPriorityHandler();
+  addLowPriorityHandler();
   addLowPriorityHandler();
   addLowPriorityHandler();
   // Default store handlers.
@@ -2342,8 +2354,12 @@
   // Iterate through the handlers in the order according to their priorities.
   for (ExpressionHandlerPtr &Handler : ExpressionHandlers) {
 CombinedResult.combineWith(Handler->handle(Inner, N, LVNode, Opts));
-if (CombinedResult.WasInterrupted)
+if (CombinedResult.WasInterrupted) {
+  // There is no need to confuse our users here.
+  // We got interrupted, but our users don't need to know about it.
+  CombinedResult.WasInterrupted = false;
   break;
+}
   }
 
   return CombinedResult;


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2136,6 +2136,23 @@
   }
 };
 
+class ArrayIndexHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+// Track the index if this is an array subscript.
+if (const auto *Arr = dyn_cast(Inner))
+  return getParentTracker().track(
+  Arr->getIdx(), LVNode,
+  {Opts.Kind, /*EnableNullFPSuppression*/ false});
+
+return {};
+  }
+};
+
 class DefaultExpressionHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
@@ -2148,12 +2165,6 @@
 PathSensitiveBugReport &Report = getParentTracker().getReport();
 Tracker::Result Result;
 
-// Track the index if this is an array subscript.
-if (const auto *Arr = dyn_cast(Inner))
-  Result.combineWith(getParentTracker().track(
-  Arr->getIdx(), LVNode,
-  {Opts.Kind, /*EnableNullFPSuppression*/ false}));
-
 // See if the expression we're interested refers to a variable.
 // If so, we can track both its contents and constraints on its value.
 if (ExplodedGraph::isInterestingLValueExpr(Inner)) {
@@ -2322,6 +2333,7 @@
   // Default expression handlers.
   addLowPriorityHandler();
   addLowPriorityHandler();
+  addLowPriorityHandler();
   addLowPriorityHandler();
   addLowPriorityHandler();
   // Default store handlers.
@@ -2342,8 +2354,12 @@
   // Iterate through the handlers in the order according to their priorities.
   for (ExpressionHandlerPtr &Handler : ExpressionHandlers) {
 CombinedResult.combineWith(Handler->handle(Inner, N, LVNode, Opts));
-if (CombinedResult.WasInterrupted)
+if (CombinedResult.WasInterrupted) {
+  // There is no need to confuse our users here.
+  // We got interrupted, but our users don't need to know about it.
+  CombinedResult.WasInterrupted = false;
   break;
+}
   }
 
   return CombinedResult;
___
cfe-commits maili

[PATCH] D104018: [clang-tidy] Allow disabling integer narrowing conversions for cppcoreguidelines-narrowing-conversions

2021-06-10 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: shchenz, kbarton, xazax.hun, nemanjai.
gchatelet requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104018

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion, value: true}]}'
+
+// RUN: %check_clang_tidy -check-suffix=DISABLED %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion, value: false}]}'
+
+void foo(unsigned long long value) {
+  int a = value;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:11: warning: narrowing conversion from 'unsigned long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
+  long long b = value;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:17: warning: narrowing conversion from 'unsigned long long' to signed type 'long long' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
+}
+
+void casting_float_to_bool_is_still_operational_when_integer_narrowing_is_disabled(float f) {
+  if (f) {
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
+// CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
@@ -13,7 +13,8 @@
 https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es46-avoid-lossy-narrowing-truncating-arithmetic-conversions.
 
 We enforce only part of the guideline, more specifically, we flag narrowing conversions from:
- - an integer to a narrower integer (e.g. ``char`` to ``unsigned char``),
+ - an integer to a narrower integer (e.g. ``char`` to ``unsigned char``)
+   if WarnOnIntegerNarrowingConversion Option is set,
  - an integer to a narrower floating-point (e.g. ``uint64_t`` to ``float``),
  - a floating-point to an integer (e.g. ``double`` to ``int``),
  - a floating-point to a narrower floating-point (e.g. ``double`` to ``float``)
@@ -30,6 +31,11 @@
 Options
 ---
 
+.. option:: WarnOnIntegerNarrowingConversion
+
+When `true`, the check will warn on narrowing integer conversion
+(e.g. ``int`` to ``size_t``). `true` by default.
+
 .. option:: WarnOnFloatingPointNarrowingConversion
 
 When `true`, the check will warn on narrowing floating point conversion
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
@@ -93,6 +93,7 @@
   void handleBinaryOperator(const ASTContext &Context,
 const BinaryOperator &Op);
 
+  const bool WarnOnIntegerNarrowingConversion;
   const bool WarnOnFloatingPointNarrowingConversion;
   const bool WarnWithinTemplateInstantiation;
   const bool WarnOnEquivalentBitWidth;
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -35,6 +35,8 @@
 NarrowingConversionsCheck::NarrowingConversionsCheck(Str

[PATCH] D103961: [analyzer] Extract InlinedFunctionCallHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351115.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103961

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -937,91 +937,6 @@
 ID.AddBoolean(EnableNullFPSuppression);
   }
 
-  /// Adds a ReturnVisitor if the given statement represents a call that was
-  /// inlined.
-  ///
-  /// This will search back through the ExplodedGraph, starting from the given
-  /// node, looking for when the given statement was processed. If it turns out
-  /// the statement is a call that was inlined, we add the visitor to the
-  /// bug report, so it can print a note later.
-  static void addVisitorIfNecessary(TrackerRef ParentTracker,
-const ExplodedNode *Node, const Stmt *S,
-PathSensitiveBugReport &BR,
-bool InEnableNullFPSuppression,
-bugreporter::TrackingKind TKind) {
-if (!CallEvent::isCallStmt(S))
-  return;
-
-// First, find when we processed the statement.
-// If we work with a 'CXXNewExpr' that is going to be purged away before
-// its call take place. We would catch that purge in the last condition
-// as a 'StmtPoint' so we have to bypass it.
-const bool BypassCXXNewExprEval = isa(S);
-
-// This is moving forward when we enter into another context.
-const StackFrameContext *CurrentSFC = Node->getStackFrame();
-
-do {
-  // If that is satisfied we found our statement as an inlined call.
-  if (Optional CEE = Node->getLocationAs())
-if (CEE->getCalleeContext()->getCallSite() == S)
-  break;
-
-  // Try to move forward to the end of the call-chain.
-  Node = Node->getFirstPred();
-  if (!Node)
-break;
-
-  const StackFrameContext *PredSFC = Node->getStackFrame();
-
-  // If that is satisfied we found our statement.
-  // FIXME: This code currently bypasses the call site for the
-  //conservatively evaluated allocator.
-  if (!BypassCXXNewExprEval)
-if (Optional SP = Node->getLocationAs())
-  // See if we do not enter into another context.
-  if (SP->getStmt() == S && CurrentSFC == PredSFC)
-break;
-
-  CurrentSFC = PredSFC;
-} while (Node->getStackFrame() == CurrentSFC);
-
-// Next, step over any post-statement checks.
-while (Node && Node->getLocation().getAs())
-  Node = Node->getFirstPred();
-if (!Node)
-  return;
-
-// Finally, see if we inlined the call.
-Optional CEE = Node->getLocationAs();
-if (!CEE)
-  return;
-
-const StackFrameContext *CalleeContext = CEE->getCalleeContext();
-if (CalleeContext->getCallSite() != S)
-  return;
-
-// Check the return value.
-ProgramStateRef State = Node->getState();
-SVal RetVal = Node->getSVal(S);
-
-// Handle cases where a reference is returned and then immediately used.
-if (cast(S)->isGLValue())
-  if (Optional LValue = RetVal.getAs())
-RetVal = State->getSVal(*LValue);
-
-// See if the return value is NULL. If so, suppress the report.
-AnalyzerOptions &Options = State->getAnalysisManager().options;
-
-bool EnableNullFPSuppression = false;
-if (InEnableNullFPSuppression && Options.ShouldSuppressNullReturnPaths)
-  if (Optional RetLoc = RetVal.getAs())
-EnableNullFPSuppression = State->isNull(*RetLoc).isConstrainedTrue();
-
-BR.addVisitor(ParentTracker, CalleeContext,
- EnableNullFPSuppression, Options, TKind);
-  }
-
   PathDiagnosticPieceRef visitNodeInitial(const ExplodedNode *N,
   BugReporterContext &BRC,
   PathSensitiveBugReport &BR) {
@@ -2230,6 +2145,96 @@
   }
 };
 
+/// Adds a ReturnVisitor if the given statement represents a call that was
+/// inlined.
+///
+/// This will search back through the ExplodedGraph, starting from the given
+/// node, looking for when the given statement was processed. If it turns out
+/// the statement is a call that was inlined, we add the visitor to the
+/// bug report, so it can print a note later.
+class InlinedFunctionCallHandler final : public ExpressionHandler {
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *E, const ExplodedNode *InputNode,
+ const ExplodedNode *ExprNode,
+ TrackingOptions Opts) override {
+if (!CallEvent::isCallStmt(E))
+  return {};
+
+// First, find when we processed 

[PATCH] D103616: [analyzer] Reimplement trackExpressionValue as ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Oh boy! I screwed up with interactive rebases 🥲


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103616

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


[PATCH] D103633: [analyzer] Refactor trackExpressionValue to accept TrackingOptions

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Oof, I also screwed up rebasing this commit as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103633

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


[PATCH] D103616: [analyzer] Reimplement trackExpressionValue as ExpressionHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351121.
vsavchenko added a comment.

Remove parts from the next commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103616

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2050,7 +2050,166 @@
 //Tracker implementation
 //===--===//
 
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ProgramStateRef LVState = LVNode->getState();
+const StackFrameContext *SFC = LVNode->getStackFrame();
+PathSensitiveBugReport &Report = getParentTracker().getReport();
+Tracker::Result Result;
+
+// We only track expressions if we believe that they are important. Chances
+// are good that control dependencies to the tracking point are also
+// important because of this, let's explain why we believe control reached
+// this point.
+// TODO: Shouldn't we track control dependencies of every bug location,
+// rather than only tracked expressions?
+if (LVState->getAnalysisManager()
+.getAnalyzerOptions()
+.ShouldTrackConditions) {
+  Report.addVisitor(InputNode);
+  Result.FoundSomethingToTrack = true;
+}
+
+// The message send could be nil due to the receiver being nil.
+// At this point in the path, the receiver should be live since we are at
+// the message send expr. If it is nil, start tracking it.
+if (const Expr *Receiver =
+NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
+  Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+
+// Track the index if this is an array subscript.
+if (const auto *Arr = dyn_cast(Inner))
+  Result.combineWith(getParentTracker().track(
+  Arr->getIdx(), LVNode,
+  {Opts.Kind, /*EnableNullFPSuppression*/ false}));
+
+// See if the expression we're interested refers to a variable.
+// If so, we can track both its contents and constraints on its value.
+if (ExplodedGraph::isInterestingLValueExpr(Inner)) {
+  SVal LVal = LVNode->getSVal(Inner);
+
+  const MemRegion *RR = getLocationRegionIfReference(Inner, LVNode);
+  bool LVIsNull = LVState->isNull(LVal).isConstrainedTrue();
+
+  // If this is a C++ reference to a null pointer, we are tracking the
+  // pointer. In addition, we should find the store at which the reference
+  // got initialized.
+  if (RR && !LVIsNull)
+Result.combineWith(getParentTracker().track(LVal, RR, Opts, SFC));
+
+  // In case of C++ references, we want to differentiate between a null
+  // reference and reference to null pointer.
+  // If the LVal is null, check if we are dealing with null reference.
+  // For those, we want to track the location of the reference.
+  const MemRegion *R =
+  (RR && LVIsNull) ? RR : LVNode->getSVal(Inner).getAsRegion();
+
+  if (R) {
+
+// Mark both the variable region and its contents as interesting.
+SVal V = LVState->getRawSVal(loc::MemRegionVal(R));
+Report.addVisitor(cast(R), Opts.Kind);
+
+// When we got here, we do have something to track, and we will
+// interrupt.
+Result.FoundSomethingToTrack = true;
+Result.WasInterrupted = true;
+
+MacroNullReturnSuppressionVisitor::addMacroVisitorIfNecessary(
+LVNode, R, Opts.EnableNullFPSuppression, Report, V);
+
+Report.markInteresting(V, Opts.Kind);
+Report.addVisitor(R);
+
+// If the contents are symbolic and null, find out when they became
+// null.
+if (V.getAsLocSymbol(/*IncludeBaseRegions=*/true))
+  if (LVState->isNull(V).isConstrainedTrue())
+Report.addVisitor(V.castAs(),
+false);
+
+// Add visitor, which will suppress inline defensive checks.
+if (auto DV = V.getAs())
+  if (!DV->isZeroConstant() && Opts.EnableNullFPSuppression)
+// Note that LVNode may be too late (i.e., too far from the
+// InputNode) because the lvalue may have been computed before the
+// inlined call was evaluated. InputNode may as well be too early
+// here, because the symbol is already dead; this, however, is fine
+// because we can still find the node in which 

[PATCH] D100733: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

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

Rebase.

Now that we have isPRValue, this is hopefully less controversial now :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100733

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp

Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5832,7 +5832,7 @@
  Entity.getType()) &&
 canPerformArrayCopy(Entity)) {
   // If source is a prvalue, use it directly.
-  if (Initializer->getValueKind() == VK_PRValue) {
+  if (Initializer->isPRValue()) {
 AddArrayInitStep(DestType, /*IsGNUExtension*/false);
 return;
   }
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6870,7 +6870,7 @@
   assert(!isa(E) && "Double-bound temporary?");
 
   // If the result is a glvalue, we shouldn't bind it.
-  if (!E->isPRValue())
+  if (E->isGLValue())
 return E;
 
   // In ARC, calls that return a retainable type can return retained,
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5541,7 +5541,7 @@
 BaseExpr = LHSExp;// vectors: V[123]
 IndexExpr = RHSExp;
 // We apply C++ DR1213 to vector subscripting too.
-if (getLangOpts().CPlusPlus11 && LHSExp->getValueKind() == VK_PRValue) {
+if (getLangOpts().CPlusPlus11 && LHSExp->isPRValue()) {
   ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
   if (Materialized.isInvalid())
 return ExprError();
@@ -10129,7 +10129,7 @@
 RHSType, DiagID))
 return RHSType;
 } else {
-  if (LHS.get()->getValueKind() == VK_LValue ||
+  if (LHS.get()->isLValue() ||
   !tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
 return RHSType;
 }
@@ -14852,7 +14852,7 @@
 // complex l-values to ordinary l-values and all other values to r-values.
 if (Input.isInvalid()) return ExprError();
 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
-  if (Input.get()->getValueKind() != VK_PRValue &&
+  if (Input.get()->isGLValue() &&
   Input.get()->getObjectKind() == OK_Ordinary)
 VK = Input.get()->getValueKind();
 } else if (!getLangOpts().CPlusPlus) {
@@ -19049,7 +19049,7 @@
   Expr *SubExpr = SubResult.get();
   E->setSubExpr(SubExpr);
   E->setType(S.Context.getPointerType(SubExpr->getType()));
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   assert(E->getObjectKind() == OK_Ordinary);
   return E;
 }
@@ -19059,7 +19059,7 @@
 
   E->setType(VD->getType());
 
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   if (S.getLangOpts().CPlusPlus &&
   !(isa(VD) &&
 cast(VD)->isInstance()))
@@ -19150,7 +19150,7 @@
 return ExprError();
   }
 
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   assert(E->getObjectKind() == OK_Ordinary);
   E->setType(DestType);
 
@@ -19304,7 +19304,7 @@
 ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
   // The only case we should ever see here is a function-to-pointer decay.
   if (E->getCastKind() == CK_FunctionToPointerDecay) {
-assert(E->getValueKind() == VK_PRValue);
+assert(E->isPRValue());
 assert(E->getObjectKind() == OK_Ordinary);
 
 E->setType(DestType);
@@ -19318,7 +19318,7 @@
 E->setSubExpr(Result.get());
 return E;
   } else if (E->getCastKind() == CK_LValueToRValue) {
-assert(E->getValueKind() == VK_PRValue);
+assert(E->isPRValue());
 assert(E->getObjectKind() == OK_Ordinary);
 
 assert(isa(E->getType()));
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -897,7 +897,7 @@
 
   // If the expression is a temporary, materialize it as an lvalue so that we
   // can use it multiple times.
-  if (E->getValueKind() == VK_PRValue)
+  if (E->isPRValue())
 E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
 
   // The location of the `co_await` token cannot be used when constructing
@@ -957,7 +957,7 @@
 
   // If the expression is a temporary, materializ

[PATCH] D90238: [clang-format] Added ReferenceAlignmentStyle option - (Update to D31635)

2021-06-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: HazardyKnusperkeks.
MyDeveloperDay added a comment.

@curdeius , @HazardyKnusperkeks any thoughts, personally I don't have any 
problems with this even if its not my personal preference.  @skirkovski if this 
is something you need we might need for you to take over the revision and bring 
it upto date and address the comments? is that something yo would be 
interesting in helping out with?

My personal preference is that someone who wants it should own it, as with all 
things we need volunteers. @catskul's last comment on D33029: [clang-format] 
add option for dangling parenthesis  was that 
they are busy, maybe they'd think the same here if someone wants to pick it up.

In my mind justification is that astyle supported seperate `align-pointer` and 
`align-reference`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90238

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


[PATCH] D100733: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

2021-06-10 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Also by the way D100713  is not really a 
dependency here, this DR can land on it's own if that is not clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100733

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


[PATCH] D103618: [analyzer] Change FindLastStoreBRVisitor to use Tracker

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351125.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103618

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1488,8 +1488,8 @@
 if (!IsParam)
   InitE = InitE->IgnoreParenCasts();
 
-bugreporter::trackExpressionValue(StoreSite, InitE, BR, TKind,
-  EnableNullFPSuppression);
+getParentTracker().track(InitE, StoreSite,
+ {TKind, EnableNullFPSuppression});
   }
 
   // Let's try to find the region where the value came from.
@@ -1588,8 +1588,8 @@
   dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
 if (auto KV = State->getSVal(OriginalR).getAs())
-  BR.addVisitor(
-  *KV, OriginalR, EnableNullFPSuppression, TKind, OriginSFC);
+  getParentTracker().track(
+  *KV, OriginalR, {TKind, EnableNullFPSuppression}, OriginSFC);
   }
 }
   }
@@ -2239,7 +2239,7 @@
const StackFrameContext *Origin) {
   if (auto KV = V.getAs()) {
 Report.addVisitor(
-*KV, R, Opts.EnableNullFPSuppression, Opts.Kind, Origin);
+this, *KV, R, Opts.EnableNullFPSuppression, Opts.Kind, Origin);
 return {true};
   }
   return {};
@@ -2262,11 +2262,18 @@
bugreporter::TrackingKind TKind,
bool EnableNullFPSuppression) {
 
-  return Tracker(report)
-  .track(E, InputNode, {TKind, EnableNullFPSuppression})
+  return Tracker::create(report)
+  ->track(E, InputNode, {TKind, EnableNullFPSuppression})
   .FoundSomethingToTrack;
 }
 
+void bugreporter::trackStoredValue(KnownSVal V, const MemRegion *R,
+   PathSensitiveBugReport &Report,
+   TrackingOptions Opts,
+   const StackFrameContext *Origin) {
+  Tracker::create(Report)->track(V, R, Opts, Origin);
+}
+
 //===--===//
 // Implementation of NulReceiverBRVisitor.
 //===--===//
Index: clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
@@ -86,9 +86,9 @@
 auto R = std::make_unique(*BT, os.str(), N);
 if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD))
   R->addRange(Ex->getSourceRange());
-R->addVisitor(std::make_unique(
-*V, VR, /*EnableNullFPSuppression*/ false,
-bugreporter::TrackingKind::Thorough));
+bugreporter::trackStoredValue(*V, VR, *R,
+  {bugreporter::TrackingKind::Thorough,
+   /*EnableNullFPSuppression*/ false});
 R->disablePathPruning();
 // need location of block
 C.emitReport(std::move(R));
Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -980,13 +980,12 @@
 // got from one to another.
 //
 // NOTE: We use the actual SVal stored in AllocBindingToReport here because
-//   FindLastStoreBRVisitor compares SVal's and it can get trickier for
+//   trackStoredValue compares SVal's and it can get trickier for
 //   something like derived regions if we want to construct SVal from
 //   Sym. Instead, we take the value that is definitely stored in that
-//   region, thus guaranteeing that FindLastStoreBRVisitor will work.
-addVisitor(
-AllVarBindings[0].second.castAs(), AllocBindingToReport,
-false, bugreporter::TrackingKind::Thorough);
+//   region, thus guaranteeing that trackStoredValue will work.
+bugreporter::trackStoredValue(AllVarBindings[0].second.castAs(),
+  Allo

[PATCH] D104021: [clang-tidy] LIT test fix for Remark diagnostic

2021-06-10 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko created this revision.
ivanmurashko added reviewers: aaron.ballman, alexfh, DmitryPolukhin.
ivanmurashko added projects: clang, clang-tools-extra.
Herald added a subscriber: xazax.hun.
ivanmurashko requested review of this revision.
Herald added a subscriber: cfe-commits.

There is a followup fix for a unit test introduced at D102906 
. The test file was placed into a temp folder 
and test assumed that it would be visible without the full path specification.

This behaviour can be changed in future and it would be good to specify full 
path to the file at the test.

Test Plan:

  ninja check-clang-tools


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104021

Files:
  clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
@@ -2,14 +2,13 @@
 // RUN: cp -r %S/Inputs/remarks %t
 // RUN: cp %s %t/t.cpp
 
-// RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-module-import' t.cpp -- \
+// RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-module-import' %t/t.cpp -- \
 // RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
 // RUN: -fsyntax-only \
 // RUN: -I%S/Inputs/remarks \
 // RUN: -working-directory=%t \
-// RUN: -Rmodule-build -Rmodule-import t.cpp 2>&1 |\
+// RUN: -Rmodule-build -Rmodule-import 2>&1 |\
 // RUN: FileCheck %s -implicit-check-not "remark:"
 
 #include "A.h"
 // CHECK: remark: importing module 'A' from {{.*}} 
[clang-diagnostic-module-import]
-


Index: clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/remarks.cpp
@@ -2,14 +2,13 @@
 // RUN: cp -r %S/Inputs/remarks %t
 // RUN: cp %s %t/t.cpp
 
-// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-module-import' t.cpp -- \
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-module-import' %t/t.cpp -- \
 // RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
 // RUN: -fsyntax-only \
 // RUN: -I%S/Inputs/remarks \
 // RUN: -working-directory=%t \
-// RUN: -Rmodule-build -Rmodule-import t.cpp 2>&1 |\
+// RUN: -Rmodule-build -Rmodule-import 2>&1 |\
 // RUN: FileCheck %s -implicit-check-not "remark:"
 
 #include "A.h"
 // CHECK: remark: importing module 'A' from {{.*}} [clang-diagnostic-module-import]
-
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104021: [clang-tidy] LIT test fix for Remark diagnostic

2021-06-10 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin accepted this revision.
DmitryPolukhin 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/D104021/new/

https://reviews.llvm.org/D104021

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


[PATCH] D90238: [clang-format] Added ReferenceAlignmentStyle option - (Update to D31635)

2021-06-10 Thread Seraphime Kirkovski (VMware) via Phabricator via cfe-commits
skirkovski added a comment.

In D90238#2810132 , @MyDeveloperDay 
wrote:

> @curdeius , @HazardyKnusperkeks any thoughts, personally I don't have any 
> problems with this even if its not my personal preference.  @skirkovski if 
> this is something you need we might need for you to take over the revision 
> and bring it upto date and address the comments? is that something you would 
> be interesting in helping out with?

Yes, I can do that. I'll pick it up, address the comments and if no one objects 
in the mean time, will post a revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90238

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


[PATCH] D103995: [OpenMP] Add type to firstprivate symbol for const firstprivate values

2021-06-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103995

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


[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-10 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D103958#2809353 , @efriedma wrote:

> You could break `__builtin_load_with_control_dependency(x)` into something 
> like `__builtin_control_dependency(READ_ONCE(x))`.  I don't think any 
> transforms will touch that in practice, even if it isn't theoretically sound. 
>  The rest of my suggestion still applies to that form, I think.  They key 
> point is that the compiler just needs to ensure some branch consumes the 
> loaded value; it doesn't matter which branch it is.

Because the original inline asm version was pretty similar (they just called it 
`volatile_cond()`), I think `__builtin_control_dependency()` is equivalent. 
Actually a later suggestion just called it `__builtin_ctrl_depends()`: 
https://lkml.kernel.org/r/yl9teqealhxbb...@hirez.programming.kicks-ass.net

It was nacked by GCC devs, who expressed concern that it seems impossible to 
guarantee a branch is emitted but also way too difficult to specify. The 
emitting-branch part seems straightforward, as you suggested.

I think implementation-wise, we can probably use your idea either way. I just 
worry about defined semantics, see below.

> The theoretical problem with separating the load from the branch is that it 
> imposes an implicit contract: the branch has to use the value of the load as 
> input, not an equivalent value produced some other way.  This is the general 
> problem with C++11 consume ordering, which nobody has tried to tackle.

Indeed. Which is why I wanted to steer clear of a __builtin that talks about 
control-dependencies directly. There are 2 challenges:

1. Defining the value used to establish a control dependency, e.g. the load 
later writes depend on (kernel only defines writes to be ctrl-dependently 
ordered).
2. Defining later ops that are control-dependent. With an expression like the 
__builtin, this could be any operation after, or it becomes too hard to define:

  x = __builtin_control_dependency(expr); // __builtin_control_dependency 
establishes an ordering edge between loads in expr and later ops
  y = 1; // control dependently ordered, although there is no explicit control 
statement yet...
  if (x) { z = 1; } // ... this code is only interested in z=1 to be 
control-dependently ordered.

Both are hard to define, as you suggested it's similar to consume which was 
also my worry.

Therefore, to get something simple that works and isn't doomed to a definition 
that is unimplementable, I tried to just talk about the control statement and 
the fact a branch must be emitted. In theory, (1) might still be a problem, but 
in practice the compiler has no other way than to use the loaded value if that 
value was loaded through an __atomic or volatile or similar.

Limiting ourselves to an attribute on control statements solves (2), because we 
can say that "the conditional branch is placed *before* conditionally executed 
instructions". Either that, or we make the __builtin give an error if used 
outside the condition of a control statement.



Given we've already gotten this far, I will summarize the options:

A. `__builtin_load_with_control_dependency()` -- this appears to solve the 
problem (1) above, but not (2). This approach seems unappealing if we want to 
solve this for the Linux kernel, because the whole point of compiler support 
was to avoid more read-primitives (with new primitives they say they'd just 
upgrade these to acquire and be done with it).

B. `__builtin_control_dependency()` -- would be nice if this would work, but I 
think it suffers from problems (1), and (2) above and is very hard to define 
properly.
B1 . Do this but constrain it to only be usable as 
conditions in control statements, which would solve (2) at least.

C. `[[mustcontrol]]`:

  Marking a conditional control statement as ``mustcontrol`` indicates that the
  compiler must generate a conditional branch in machine code, and such
  conditional branch is placed *before* conditionally executed instructions. The
  attribute may be ignored if the condition of the control statement is a
  constant expression.

D. But we can also just rename it to `[[control_dependency]]` if that's 
clearer. It looks like it's the same as B1  minus 
the artificial constraint; implementation should be similar. It'd allow for the 
same arch-dependent omission if an arch does not care about control 
dependencies. But I feel that, at least for the Linux kernel, they prefer 
having as much control over codegen as possible, regardless of arch. Because if 
there's an arch-agnostic way of doing this, we get it for free for POWER and 
Armv7.

All we'd like is a robust primitive, without overcomplicating things.

What do you recommend?

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103958

___
cfe-c

[PATCH] D99459: [OpenMP] Implement '#pragma omp unroll'.

2021-06-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2600-2604
+  RValue FactorRVal = EmitAnyExpr(FactorExpr, AggValueSlot::ignored(),
+  /*ignoreResult=*/true);
+  Factor =
+  cast(FactorRVal.getScalarVal())->getZExtValue();
+  assert(Factor >= 1 && "Only positive factors are valid");

ABataev wrote:
> I suppose it is compiled-time expression, right? If so, use 
> `FactorExpr->EvaluateKnownConstInt()` or something similar.
Not done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99459

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


[clang-tools-extra] 89c41c3 - [clang-tidy] Allow disabling integer narrowing conversions for cppcoreguidelines-narrowing-conversions

2021-06-10 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2021-06-10T12:41:57Z
New Revision: 89c41c335dac288d991d1e99ad19493bc89439e4

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

LOG: [clang-tidy] Allow disabling integer narrowing conversions for 
cppcoreguidelines-narrowing-conversions

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
index 8ce9afc8f926e..41eabb4f5bf92 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -35,6 +35,8 @@ auto hasAnyListedName(const std::string &Names) {
 NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
+  WarnOnIntegerNarrowingConversion(
+  Options.get("WarnOnIntegerNarrowingConversion", true)),
   WarnOnFloatingPointNarrowingConversion(
   Options.get("WarnOnFloatingPointNarrowingConversion", true)),
   WarnWithinTemplateInstantiation(
@@ -45,6 +47,8 @@ 
NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
 
 void NarrowingConversionsCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WarnOnIntegerNarrowingConversion",
+WarnOnIntegerNarrowingConversion);
   Options.store(Opts, "WarnOnFloatingPointNarrowingConversion",
 WarnOnFloatingPointNarrowingConversion);
   Options.store(Opts, "WarnWithinTemplateInstantiation",
@@ -294,34 +298,37 @@ void NarrowingConversionsCheck::handleIntegralCast(const 
ASTContext &Context,
SourceLocation SourceLoc,
const Expr &Lhs,
const Expr &Rhs) {
-  const BuiltinType *ToType = getBuiltinType(Lhs);
-  // From [conv.integral]p7.3.8:
-  // Conversions to unsigned integer is well defined so no warning is issued.
-  // "The resulting value is the smallest unsigned value equal to the source
-  // value modulo 2^n where n is the number of bits used to represent the
-  // destination type."
-  if (ToType->isUnsignedInteger())
-return;
-  const BuiltinType *FromType = getBuiltinType(Rhs);
-
-  // With this option, we don't warn on conversions that have equivalent width
-  // in bits. eg. uint32 <-> int32.
-  if (!WarnOnEquivalentBitWidth) {
-uint64_t FromTypeSize = Context.getTypeSize(FromType);
-uint64_t ToTypeSize = Context.getTypeSize(ToType);
-if (FromTypeSize == ToTypeSize)
+  if (WarnOnIntegerNarrowingConversion) {
+const BuiltinType *ToType = getBuiltinType(Lhs);
+// From [conv.integral]p7.3.8:
+// Conversions to unsigned integer is well defined so no warning is issued.
+// "The resulting value is the smallest unsigned value equal to the source
+// value modulo 2^n where n is the number of bits used to represent the
+// destination type."
+if (ToType->isUnsignedInteger())
   return;
-  }
+const BuiltinType *FromType = getBuiltinType(Rhs);
 
-  llvm::APSInt IntegerConstant;
-  if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
-if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
-  diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs, 
IntegerConstant,
-   Context.getTypeSize(FromType));
-return;
+// With this option, we don't warn on conversions that have equivalent 
width
+// in bits. eg. uint32 <-> int32.
+if (!WarnOnEquivalentBitWidth) {
+  uint64_t FromTypeSize = Context.getTypeSize(FromType);
+  uint64_t ToTypeSize = Context.getTypeSize(ToType);
+  if (FromTypeSize == ToTypeSize)
+return;
+}
+
+llvm::APSInt IntegerConstant;
+if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
+  if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
+diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs,
+ IntegerConstant,
+ Context.getTypeSize(FromType));
+  return;
+ 

[PATCH] D104018: [clang-tidy] Allow disabling integer narrowing conversions for cppcoreguidelines-narrowing-conversions

2021-06-10 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89c41c335dac: [clang-tidy] Allow disabling integer narrowing 
conversions for… (authored by gchatelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104018

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-narrowinginteger-option.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion, value: true}]}'
+
+// RUN: %check_clang_tidy -check-suffix=DISABLED %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion, value: false}]}'
+
+void foo(unsigned long long value) {
+  int a = value;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:11: warning: narrowing conversion from 'unsigned long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
+  long long b = value;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:17: warning: narrowing conversion from 'unsigned long long' to signed type 'long long' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
+}
+
+void casting_float_to_bool_is_still_operational_when_integer_narrowing_is_disabled(float f) {
+  if (f) {
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
+// CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
@@ -13,7 +13,8 @@
 https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es46-avoid-lossy-narrowing-truncating-arithmetic-conversions.
 
 We enforce only part of the guideline, more specifically, we flag narrowing conversions from:
- - an integer to a narrower integer (e.g. ``char`` to ``unsigned char``),
+ - an integer to a narrower integer (e.g. ``char`` to ``unsigned char``)
+   if WarnOnIntegerNarrowingConversion Option is set,
  - an integer to a narrower floating-point (e.g. ``uint64_t`` to ``float``),
  - a floating-point to an integer (e.g. ``double`` to ``int``),
  - a floating-point to a narrower floating-point (e.g. ``double`` to ``float``)
@@ -30,6 +31,11 @@
 Options
 ---
 
+.. option:: WarnOnIntegerNarrowingConversion
+
+When `true`, the check will warn on narrowing integer conversion
+(e.g. ``int`` to ``size_t``). `true` by default.
+
 .. option:: WarnOnFloatingPointNarrowingConversion
 
 When `true`, the check will warn on narrowing floating point conversion
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
@@ -93,6 +93,7 @@
   void handleBinaryOperator(const ASTContext &Context,
 const BinaryOperator &Op);
 
+  const bool WarnOnIntegerNarrowingConversion;
   const bool WarnOnFloatingPointNarrowingConversion;
   const bool WarnWithinTemplateInstantiation;
   const bool WarnOnEquivalentBitWidth;
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -35,6 +35,8 @@
 NarrowingConversionsCheck::NarrowingConversionsCheck(St

[PATCH] D103633: [analyzer] Refactor trackExpressionValue to accept TrackingOptions

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351143.
vsavchenko added a comment.

Remove unintnentionally merged changes from the next commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103633

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2314,12 +2314,11 @@
 
 bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
const Expr *E,
-   PathSensitiveBugReport &report,
-   bugreporter::TrackingKind TKind,
-   bool EnableNullFPSuppression) {
+   PathSensitiveBugReport &Report,
+   TrackingOptions Opts) {
 
-  return Tracker::create(report)
-  ->track(E, InputNode, {TKind, EnableNullFPSuppression})
+  return Tracker::create(Report)
+  ->track(E, InputNode, Opts)
   .FoundSomethingToTrack;
 }
 
@@ -2376,9 +2375,9 @@
   // The receiver was nil, and hence the method was skipped.
   // Register a BugReporterVisitor to issue a message telling us how
   // the receiver was null.
-  bugreporter::trackExpressionValue(
-  N, Receiver, BR, bugreporter::TrackingKind::Thorough,
-  /*EnableNullFPSuppression*/ false);
+  bugreporter::trackExpressionValue(N, Receiver, BR,
+{bugreporter::TrackingKind::Thorough,
+ /*EnableNullFPSuppression*/ false});
   // Issue a message saying that the method was skipped.
   PathDiagnosticLocation L(Receiver, BRC.getSourceManager(),
  N->getLocationContext());
Index: clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
@@ -147,8 +147,9 @@
   auto R = std::make_unique(
   *BT, "Index is out of bounds", N);
   R->addRange(IdxExpr->getSourceRange());
-  bugreporter::trackExpressionValue(
-  N, IdxExpr, *R, bugreporter::TrackingKind::Thorough, false);
+  bugreporter::trackExpressionValue(N, IdxExpr, *R,
+{bugreporter::TrackingKind::Thorough,
+ /*EnableNullFPSuppression=*/false});
   C.emitReport(std::move(R));
   return;
 }
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -284,8 +284,9 @@
   N);
 
   R->addRange(RS->getSourceRange());
-  bugreporter::trackExpressionValue(N, RS->getRetValue(), *R,
-bugreporter::TrackingKind::Thorough, 
false);
+  bugreporter::trackExpressionValue(
+  N, RS->getRetValue(), *R,
+  {bugreporter::TrackingKind::Thorough, 
/*EnableNullFPSuppression=*/false});
   C.emitReport(std::move(R));
 }
 
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -353,9 +353,7 @@
 /// statement. Note that returning \c true does not actually imply
 /// that any visitors were added.
 bool trackExpressionValue(const ExplodedNode *N, const Expr *E,
-  PathSensitiveBugReport &R,
-  TrackingKind TKind = TrackingKind::Thorough,
-  bool EnableNullFPSuppression = true);
+  PathSensitiveBugReport &R, TrackingOptions Opts = 
{});
 
 /// Track how the value got stored into the given region and where it came
 /// from.


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2314,12 +2314,11 @@
 
 bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
const Expr *E,
-   PathSensitiveBugReport &report,
- 

[clang] cc86b87 - [CodeGen] limit tests to current pass manager to avoid variability; NFC

2021-06-10 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2021-06-10T08:50:06-04:00
New Revision: cc86b87a57000ba673edaf95f65913412928f003

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

LOG: [CodeGen] limit tests to current pass manager to avoid variability; NFC

Post-commit feedback for d69c4372bfbe says the output
may vary between pass managers. This is hopefully a
quick fix, but we might want to investigate how to
better solve this type of problem.

Added: 


Modified: 
clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
clang/test/CodeGen/arm-bf16-convert-intrinsics.c
clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c
clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
index 4fe6c6b43aa1..966c50f62c8b 100644
--- a/clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +neon 
-target-feature +bf16 \
-// RUN: -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s
+// RUN: -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager %s -o - | opt 
-S -mem2reg | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
index 3cb9f0dd8db2..7f3bf7f1ec30 100644
--- a/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +neon 
-target-feature +bf16 \
-// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
%s
+// RUN:  -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager %s -o - | opt 
-S -mem2reg | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
index 694dc65cc7d6..b5a2c20f2e32 100644
--- a/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-lane-intrinsics.c
@@ -1,8 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +neon 
-target-feature +bf16 \
-// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-LE %s
+// RUN:  -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager %s -o - | opt 
-S -mem2reg | FileCheck --check-prefix=CHECK-LE %s
 // RUN: %clang_cc1 -triple aarch64_be-arm-none-eabi -target-feature +neon 
-target-feature +bf16 \
-// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-BE %s
+// RUN:  -disable-O0-optnone -emit-llvm %s -fno-legacy-pass-manager -o - | opt 
-S -mem2reg | FileCheck --check-prefix=CHECK-BE %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c 
b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
index 75304a43f05c..e77e92115f6c 100644
--- a/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
+++ b/clang/test/CodeGen/arm-bf16-convert-intrinsics.c
@@ -1,19 +1,19 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 \
 // RUN:   -triple aarch64-arm-none-eabi -target-feature +neon -target-feature 
+bf16 \
-// RUN:   -disable-O0-optnone -emit-llvm -o - %s \
+// RUN:   -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager -o - %s \
 // RUN:   | opt -S -mem2reg \
 // RUN:   | FileCheck --check-prefixes=CHECK,CHECK-A64 %s
 // RUN: %clang_cc1 \
 // RUN:   -triple armv8.6a-arm-none-eabi -target-feature +neon \
 // RUN:   -target-feature +bf16 -mfloat-abi hard \
-// RUN:   -disable-O0-optnone -emit-llvm -o - %s \
+// RUN:   -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager -o - %s \
 // RUN:   | opt -S -mem2reg \
 // RUN:   | FileCheck --check-prefixes=CHECK,CHECK-A32-HARDFP %s
 // RUN: %clang_cc1 \
 // RUN:   -triple armv8.6a-arm-none-eabi -target-feature +neon \
 // RUN:   -target-feature +bf16 -mfloat-abi softfp \
-// RUN:   -disable-O0-optnone -emit-llvm -o - %s \
+// RUN:   -disable-O0-optnone -emit-llvm -fno-legacy-pass-manager -o - %s \
 // RUN:   | opt -S -mem2reg \
 // RUN:   | FileCheck --check-prefixes=CHECK,CHECK-A32-SOFTFP %s
 

diff  --git a/clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c 
b/clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c
index 1211f2ffa732..2fdb9f1c2

[PATCH] D103644: [analyzer] Refactor StoreSiteFinder and extract DefaultStoreHandler

2021-06-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 351145.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103644

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1232,12 +1232,7 @@
   SVal V;
   bool Satisfied = false;
 
-  /// If the visitor is tracking the value directly responsible for the
-  /// bug, we are going to employ false positive suppression.
-  bool EnableNullFPSuppression;
-
-  using TrackingKind = bugreporter::TrackingKind;
-  TrackingKind TKind;
+  TrackingOptions Options;
   const StackFrameContext *OriginSFC;
 
 public:
@@ -1252,11 +1247,9 @@
   ///this visitor can prevent that without polluting the bugpath too
   ///much.
   StoreSiteFinder(bugreporter::TrackerRef ParentTracker, KnownSVal V,
-  const MemRegion *R, bool InEnableNullFPSuppression,
-  TrackingKind TKind,
+  const MemRegion *R, TrackingOptions Options,
   const StackFrameContext *OriginSFC = nullptr)
-  : TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
-EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
+  : TrackingBugReporterVisitor(ParentTracker), R(R), V(V), Options(Options),
 OriginSFC(OriginSFC) {
 assert(R);
   }
@@ -1273,8 +1266,8 @@
   ID.AddPointer(&tag);
   ID.AddPointer(R);
   ID.Add(V);
-  ID.AddInteger(static_cast(TKind));
-  ID.AddBoolean(EnableNullFPSuppression);
+  ID.AddInteger(static_cast(Options.Kind));
+  ID.AddBoolean(Options.EnableNullFPSuppression);
 }
 
 /// Returns true if \p N represents the DeclStmt declaring and initializing
@@ -1533,8 +1526,7 @@
 if (!IsParam)
   InitE = InitE->IgnoreParenCasts();
 
-getParentTracker().track(InitE, StoreSite,
- {TKind, EnableNullFPSuppression});
+getParentTracker().track(InitE, StoreSite, Options);
   }
 
   // Let's try to find the region where the value came from.
@@ -1605,7 +1597,7 @@
 }
   }
 
-  if (TKind == TrackingKind::Condition &&
+  if (Options.Kind == TrackingKind::Condition && OriginSFC &&
   !OriginSFC->isParentOf(StoreSite->getStackFrame()))
 return nullptr;
 
@@ -1613,60 +1605,41 @@
   SmallString<256> sbuf;
   llvm::raw_svector_ostream os(sbuf);
 
+  StoreInfo SI = {StoreInfo::Assignment, // default kind
+  StoreSite,
+  InitE,
+  V,
+  R,
+  OldRegion};
+
   if (Optional PS = StoreSite->getLocationAs()) {
 const Stmt *S = PS->getStmt();
-const char *action = nullptr;
 const auto *DS = dyn_cast(S);
 const auto *VR = dyn_cast(R);
 
 if (DS) {
-  action = R->canPrintPretty() ? "initialized to " :
- "Initializing to ";
+  SI.StoreKind = StoreInfo::Initialization;
 } else if (isa(S)) {
-  action = R->canPrintPretty() ? "captured by block as " :
- "Captured by block as ";
+  SI.StoreKind = StoreInfo::BlockCapture;
   if (VR) {
 // See if we can get the BlockVarRegion.
 ProgramStateRef State = StoreSite->getState();
 SVal V = StoreSite->getSVal(S);
 if (const auto *BDR =
-  dyn_cast_or_null(V.getAsRegion())) {
+dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
-if (auto KV = State->getSVal(OriginalR).getAs())
-  getParentTracker().track(
-  *KV, OriginalR, {TKind, EnableNullFPSuppression}, OriginSFC);
+getParentTracker().track(State->getSVal(OriginalR), OriginalR,
+ Options, OriginSFC);
   }
 }
   }
 }
-if (action)
-  showBRDiagnostics(action, os, R, V, OldRegion, DS);
-
-  } else if (StoreSite->getLocation().getAs()) {
-if (const auto *VR = dyn_cast(R))
-  showBRParamDiagnostics(os, VR, V, OldRegion);
+  } else if (SI.StoreSite->getLocation().getAs() &&
+ isa(SI.Dest)) {
+SI.StoreKind = StoreInfo::CallArgument;
   }
 
-  if (os.str().empty())
-showBRDefaultDiagnostics(os, R, V, OldRegion);
-
-  if (TKind == bugreporter::TrackingKind::Condition)
-os << WillBeUsedForACondition;
-
-  // Construct a new PathDiagnosticPiece.
-  ProgramPoint P = StoreSite->getLocation();
-  PathDiagnosticLocation L;
-  if (P.getAs() && InitE)
-L = PathDiagnosticLocation(InitE, BRC.getSourceManager(),
-   P.getLocationContext());
-
-  if (!L.isValid() || !

[clang] a959374 - [clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr

2021-06-10 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-06-10T14:51:08+02:00
New Revision: a95937452f237fad10e6b7e43154c17c6b8476c4

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

LOG: [clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr

Before this change, CXXDefaultArgExpr would always have
ExprDependence::None. This can lead to issues when, for example, the
inner expression is RecoveryExpr and yet containsErrors() on the default
expression is false.

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

Added: 
clang/test/AST/ast-dump-default-arg-dep.cpp

Modified: 
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ComputeDependence.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index 7dde42ee71ba0..8db09e6b57d0f 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -71,6 +71,7 @@ class OverloadExpr;
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
 class CXXDefaultInitExpr;
+class CXXDefaultArgExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -156,6 +157,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool 
KnownDependent,
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
 ExprDependence computeDependence(CXXDefaultInitExpr *E);
+ExprDependence computeDependence(CXXDefaultArgExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c46f9bd7f4db0..2626f9b925962 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1257,7 +1257,7 @@ class CXXDefaultArgExpr final : public Expr {
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-setDependence(ExprDependence::None);
+setDependence(computeDependence(this));
   }
 
 public:

diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 1a5d2f7075fb5..5648cf2103d64 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -748,6 +748,10 @@ ExprDependence clang::computeDependence(CXXDefaultInitExpr 
*E) {
   return E->getExpr()->getDependence();
 }
 
+ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());

diff  --git a/clang/test/AST/ast-dump-default-arg-dep.cpp 
b/clang/test/AST/ast-dump-default-arg-dep.cpp
new file mode 100644
index 0..a804ac120fca4
--- /dev/null
+++ b/clang/test/AST/ast-dump-default-arg-dep.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump 
-frecovery-ast %s | FileCheck %s
+
+// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this 
case
+// RecoveryExpr.
+void fun(int arg = foo());
+
+void test() {
+  fun();
+}
+// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <> '' 
contains-errors lvalue



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


[PATCH] D103982: [clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr

2021-06-10 Thread Adam Czachorowski 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 rGa95937452f23: [clang] Make CXXDefaultArgExpr inherit 
dependence from the inner Expr (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103982

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ComputeDependence.cpp
  clang/test/AST/ast-dump-default-arg-dep.cpp


Index: clang/test/AST/ast-dump-default-arg-dep.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-default-arg-dep.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump 
-frecovery-ast %s | FileCheck %s
+
+// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this 
case
+// RecoveryExpr.
+void fun(int arg = foo());
+
+void test() {
+  fun();
+}
+// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <> '' 
contains-errors lvalue
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -748,6 +748,10 @@
   return E->getExpr()->getDependence();
 }
 
+ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -1257,7 +1257,7 @@
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-setDependence(ExprDependence::None);
+setDependence(computeDependence(this));
   }
 
 public:
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -71,6 +71,7 @@
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
 class CXXDefaultInitExpr;
+class CXXDefaultArgExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -156,6 +157,7 @@
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
 ExprDependence computeDependence(CXXDefaultInitExpr *E);
+ExprDependence computeDependence(CXXDefaultArgExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);


Index: clang/test/AST/ast-dump-default-arg-dep.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-default-arg-dep.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump -frecovery-ast %s | FileCheck %s
+
+// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this case
+// RecoveryExpr.
+void fun(int arg = foo());
+
+void test() {
+  fun();
+}
+// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <> '' contains-errors lvalue
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -748,6 +748,10 @@
   return E->getExpr()->getDependence();
 }
 
+ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -1257,7 +1257,7 @@
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-setDependence(ExprDependence::None);
+setDependence(computeDependence(this));
   }
 
 public:
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -71,6 +71,7 @@
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
 class CXXDefaultInitExpr;
+class CXXDefaultArgExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentS

[clang] 0c32ffc - [OpenMP] Add type to firstprivate symbol for const firstprivate values

2021-06-10 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-06-10T09:02:20-04:00
New Revision: 0c32ffceedca2a0d7026fc142bab8ac259131386

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

LOG: [OpenMP] Add type to firstprivate symbol for const firstprivate values

Clang will create a global value put in constant memory if an aggregate value
is declared firstprivate in the target device. The symbol name only uses the
name of the firstprivate variable, so symbol name conflicts will occur if the
variable is allowed to have different types through templates. An example of
this behvaiour is shown in https://godbolt.org/z/EsMjYh47n. This patch adds the
mangled type name to the symbol to avoid such naming conflicts. This fixes
https://bugs.llvm.org/show_bug.cgi?id=50642.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e4bb6dcaa4f65..8f65f38747d87 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10593,7 +10593,12 @@ 
CGOpenMPRuntime::registerTargetFirstprivateCopy(CodeGenFunction &CGF,
  FileID, Line);
 llvm::raw_svector_ostream OS(Buffer);
 OS << "__omp_offloading_firstprivate_" << llvm::format("_%x", DeviceID)
-   << llvm::format("_%x_", FileID) << VD->getName() << "_l" << Line;
+   << llvm::format("_%x_", FileID);
+if (CGM.getLangOpts().CPlusPlus) {
+  CGM.getCXXABI().getMangleContext().mangleTypeName(VD->getType(), OS);
+  OS << "_";
+}
+OS << VD->getName() << "_l" << Line;
 VarName = OS.str();
   }
   Linkage = llvm::GlobalValue::InternalLinkage;

diff  --git a/clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp 
b/clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
index 70f5a1f849be4..2c470ffcf3950 100644
--- a/clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -13,11 +13,14 @@ struct TT {
   ty Y;
 };
 
-// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
+// TCHECK-DAG:  [[TTIC:%.+]] = type { i8, i8 }
+// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l27 = internal 
addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal 
addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = 
internal addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = 
internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -136,6 +139,12 @@ static int fstatic(int n) {
   return a;
 }
 
+template 
+void fconst(const tx t) {
+#pragma omp target firstprivate(t)
+  { }
+}
+
 // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}(i{{[0-9]+}}{{.*}} 
[[A_IN:%.+]], i{{[0-9]+}}{{.*}} [[A3_IN:%.+]], [10 x i{{[0-9]+}}]*{{.+}} 
[[B_IN:%.+]])
 // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
 // TCHECK:  [[A3_ADDR:%.+]] = alloca i{{[0-9]+}},
@@ -199,6 +208,9 @@ int bar(int n, double *ptr) {
   a += fstatic(n);
   a += ftemplate(n);
 
+  fconst(TT{0, 0});
+  fconst(TT{0, 0});
+
   return a;
 }
 



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


[PATCH] D103995: [OpenMP] Add type to firstprivate symbol for const firstprivate values

2021-06-10 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c32ffceedca: [OpenMP] Add type to firstprivate symbol for 
const firstprivate values (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103995

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp


Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -13,11 +13,14 @@
   ty Y;
 };
 
-// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
+// TCHECK-DAG:  [[TTIC:%.+]] = type { i8, i8 }
+// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l27 = internal 
addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal 
addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = 
internal addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = 
internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -136,6 +139,12 @@
   return a;
 }
 
+template 
+void fconst(const tx t) {
+#pragma omp target firstprivate(t)
+  { }
+}
+
 // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}(i{{[0-9]+}}{{.*}} 
[[A_IN:%.+]], i{{[0-9]+}}{{.*}} [[A3_IN:%.+]], [10 x i{{[0-9]+}}]*{{.+}} 
[[B_IN:%.+]])
 // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
 // TCHECK:  [[A3_ADDR:%.+]] = alloca i{{[0-9]+}},
@@ -199,6 +208,9 @@
   a += fstatic(n);
   a += ftemplate(n);
 
+  fconst(TT{0, 0});
+  fconst(TT{0, 0});
+
   return a;
 }
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10593,7 +10593,12 @@
  FileID, Line);
 llvm::raw_svector_ostream OS(Buffer);
 OS << "__omp_offloading_firstprivate_" << llvm::format("_%x", DeviceID)
-   << llvm::format("_%x_", FileID) << VD->getName() << "_l" << Line;
+   << llvm::format("_%x_", FileID);
+if (CGM.getLangOpts().CPlusPlus) {
+  CGM.getCXXABI().getMangleContext().mangleTypeName(VD->getType(), OS);
+  OS << "_";
+}
+OS << VD->getName() << "_l" << Line;
 VarName = OS.str();
   }
   Linkage = llvm::GlobalValue::InternalLinkage;


Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -13,11 +13,14 @@
   ty Y;
 };
 
-// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
+// TCHECK-DAG:  [[TTIC:%.+]] = type { i8, i8 }
+// TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l27 = internal addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = internal addrspace(4) global [[TTII]] zeroinitializer
+// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -136,6 +139,12 @@
   return a;
 }
 
+template 
+void fconst(const tx t) {
+#pragma omp target firstprivate(t)
+  { }
+}
+
 // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}(i{{[0-9]+}}{{.*}} [[A_IN:%.+]], i{{[0-9]+}}{{.*}} [[A3_IN:%.+]], [10 x i{{[0-9]+}}]*{{.+}} [[B_IN:%.+]])
 // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
 // TCHECK:  [[A3_ADDR:%.+]] = alloca i{{[0-9]+}},
@@ -199,6 +208,9 @@
   a += fstatic(n);
   a += ftemplate(n);
 
+  fconst(TT{0, 0});
+  fconst(TT{0, 0});
+
   return a;
 }
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10593,7 +10593,12 @@
  FileID, Line);
 llvm::raw_svector_ostream OS(Buffer);
 OS << "__omp_offloading_firstprivate_" << llvm::format("_%x", DeviceID)
-   << llvm::format("_%x_", FileID) << VD->getName() << "_l" << Line;
+   << llvm::format("_%x_", FileID);
+if (CGM.getLangOpts().CPlusPlus) {
+  CGM.getCXXABI().getMangleContext().mangleTypeName(VD->getType(), OS);
+

[clang] 734213d - Fix test hip-device-compile.hip

2021-06-10 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-06-10T09:13:27-04:00
New Revision: 734213d7b51f9ea22a9d122c0646ca5b69f88ac8

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

LOG: Fix test hip-device-compile.hip

Add stricter check for 'ld'.

Added: 


Modified: 
clang/test/Driver/hip-device-compile.hip

Removed: 




diff  --git a/clang/test/Driver/hip-device-compile.hip 
b/clang/test/Driver/hip-device-compile.hip
index 8711a1fadfc1..bc7baeb6ce4a 100644
--- a/clang/test/Driver/hip-device-compile.hip
+++ b/clang/test/Driver/hip-device-compile.hip
@@ -79,7 +79,7 @@
 // BCBUN: {{".*clang-offload-bundler"}}{{.*}}"-outputs=a.bc"
 // LLBUN: {{".*clang-offload-bundler"}}{{.*}}"-outputs=a.ll"
 // ASMBUN: {{".*clang-offload-bundler"}}{{.*}}"-outputs=a.s"
-// CHECK-NOT: {{".*ld.*"}}
+// CHECK-NOT: {{".*ld.*"}}{{.*}}"-o"
 
 // If neither -emit-llvm nor -S is used in device only compilation,
 // the output should be bundled except --no-gpu-bundle-output is



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


[PATCH] D101630: [HIP] Add --gpu-bundle-output

2021-06-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

got test failures on some bots. fixed by 
734213d7b51f9ea22a9d122c0646ca5b69f88ac8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101630

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


[PATCH] D103825: [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-10 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 351155.
adamcz added a comment.

updated after the CXXDefaultArgExpr containsErrors() change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103825

Files:
  clang/lib/Sema/SemaChecking.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
@@ -136,3 +136,9 @@
   bar(S(123)); // expected-error {{no matching conversion}}
 }
 } // namespace test11
+
+namespace test12 {
+// Verify we do not crash.
+void fun(int *foo = no_such_function()); // expected-error {{undeclared 
identifier}}
+void baz() { fun(); }
+} // namespace test12
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
@@ -4654,6 +4655,9 @@
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
+if (Arg->containsErrors())
+  continue;
+
 QualType ParamTy = Proto->getParamType(ArgIdx);
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -136,3 +136,9 @@
   bar(S(123)); // expected-error {{no matching conversion}}
 }
 } // namespace test11
+
+namespace test12 {
+// Verify we do not crash.
+void fun(int *foo = no_such_function()); // expected-error {{undeclared identifier}}
+void baz() { fun(); }
+} // namespace test12
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
@@ -4654,6 +4655,9 @@
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
+if (Arg->containsErrors())
+  continue;
+
 QualType ParamTy = Proto->getParamType(ArgIdx);
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8daac37 - [clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on

2021-06-10 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-10T09:30:41-04:00
New Revision: 8daac3714083aa5507622dba858344051f6b5574

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

LOG: [clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on

This patch changes the ffp-model=precise to enables -ffp-contract=on
(previously -ffp-model=precise enabled -ffp-contract=fast). This is a
follow-up to Andy Kaylor's comments in the llvm-dev discussion
"Floating Point semantic modes". From the same email thread, I put
Andy's distillation of floating point options and floating point modes
into UsersManual.rst

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 244212a1336db..96512f7514b3e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a0e1208fd709c..6eaa8938a8d24 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef F

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8daac3714083: [clang][FPEnv] Clang floatng point model 
ffp-model=precise enables ffp… (authored by mibintc).

Changed prior to commit:
  https://reviews.llvm.org/D74436?vs=345526&id=351156#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/ffp-contract-option.c
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c
  clang/test/Driver/fp-model.c

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNc %s
 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fre

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/UsersManual.rst:1501
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.

Maybe you should add short info to Release Notes as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/docs/UsersManual.rst:1501
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.

xbolva00 wrote:
> Maybe you should add short info to Release Notes as well?
> Maybe you should add short info to Release Notes as well?

Good idea thanks. Can I do that in a separate patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/UsersManual.rst:1501
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.

mibintc wrote:
> xbolva00 wrote:
> > Maybe you should add short info to Release Notes as well?
> > Maybe you should add short info to Release Notes as well?
> 
> Good idea thanks. Can I do that in a separate patch?
Yes, maybe wait a few days in case of the revert of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-10 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

If I can get someone to submit this on my behalf I think we can call it a day.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D103825: [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

Thanks! Really hope this is the last time to fix this crash.




Comment at: clang/lib/Sema/SemaChecking.cpp:4574
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||

looks like the `isNull` is not needed to fix the crash, but let's be more 
defensive this time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103825

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


[PATCH] D97085: [OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

2021-06-10 Thread Andrey Churbanov via Phabricator via cfe-commits
AndreyChurbanov added inline comments.



Comment at: openmp/runtime/src/kmp_taskdeps.cpp:418
 if (dep_list[i].base_addr != 0) {
+  KMP_DEBUG_ASSERT(
+  dep_list[i].flag == KMP_DEP_IN || dep_list[i].flag == KMP_DEP_OUT ||

protze.joachim wrote:
> I hit this assertion, when compiling the tests with clang-11. Is this 
> expected behavior? Does this patch break backwards compatibility, or should 
> this assertion just not look at the higher bits, as they might be 
> uninitialized?
> 
> Whey I change `dep_list[i].flag` to `(dep_list[i].flag&0xf)`, the assertion 
> doesn't trigger.
Thanks for pointing this out. I've reverted the patch in order to fix backwards 
compatibility problem. Will eliminate the dependence flag type size change in 
clang, and change the size in the library code instead.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97085

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


[PATCH] D104030: [clang][deps] Move invocation adjustments from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `clang-scan-deps` tool has some logic that parses and modifies the original 
Clang command-line. The goal is to setup `DependencyOutputOptions` by injecting 
`-M -MT ` and prevent the creation of output files.

This patch moves the logic into the `DependencyScanning` library, and uses the 
parsed `CompilerInvocation` instead of the raw command-line. The code simpler 
and can be used from the C++ API as well.

The `-o /dev/null` arguments are not necessary, since the `DependencyScanning` 
library only runs a preprocessing action, so there's no way it'll produce an 
actual object file.

Some related tests were updated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104030

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/modules.cpp
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -201,13 +201,6 @@
 
 } // end anonymous namespace
 
-/// \returns object-file path derived from source-file path.
-static std::string getObjFilePath(StringRef SrcFile) {
-  SmallString<128> ObjFileName(SrcFile);
-  llvm::sys::path::replace_extension(ObjFileName, "o");
-  return std::string(ObjFileName.str());
-}
-
 class SingleCommandCompilationDatabase : public tooling::CompilationDatabase {
 public:
   SingleCommandCompilationDatabase(tooling::CompileCommand Cmd)
@@ -469,9 +462,6 @@
   [&ResourceDirCache](const tooling::CommandLineArguments &Args,
   StringRef FileName) {
 std::string LastO = "";
-bool HasMT = false;
-bool HasMQ = false;
-bool HasMD = false;
 bool HasResourceDir = false;
 bool ClangCLMode = false;
 auto FlagsEnd = llvm::find(Args, "--");
@@ -502,58 +492,17 @@
 if (!LastO.empty() && !llvm::sys::path::has_extension(LastO))
   LastO.append(".obj");
   }
-  if (Arg == "/clang:-MT")
-HasMT = true;
-  if (Arg == "/clang:-MQ")
-HasMQ = true;
-  if (Arg == "/clang:-MD")
-HasMD = true;
-} else {
-  if (LastO.empty()) {
-if (Arg == "-o" && I != R)
-  LastO = I[-1]; // Next argument (reverse iterator)
-else if (Arg.startswith("-o"))
-  LastO = Arg.drop_front(2).str();
-  }
-  if (Arg == "-MT")
-HasMT = true;
-  if (Arg == "-MQ")
-HasMQ = true;
-  if (Arg == "-MD")
-HasMD = true;
 }
 if (Arg == "-resource-dir")
   HasResourceDir = true;
   }
 }
-// If there's no -MT/-MQ Driver would add -MT with the value of the last
-// -o option.
 tooling::CommandLineArguments AdjustedArgs(Args.begin(), FlagsEnd);
-AdjustedArgs.push_back("-o");
-#ifdef _WIN32
-AdjustedArgs.push_back("nul");
-#else
-AdjustedArgs.push_back("/dev/null");
-#endif
-if (!HasMT && !HasMQ && Format == ScanningOutputFormat::Make) {
-  // We're interested in source dependencies of an object file.
-  std::string FileNameArg;
-  if (!HasMD) {
-// FIXME: We are missing the directory unless the -o value is an
-// absolute path.
-FileNameArg = !LastO.empty() ? LastO : getObjFilePath(FileName);
-  } else {
-FileNameArg = std::string(FileName);
-  }
-  if (ClangCLMode) {
-AdjustedArgs.push_back("/clang:-M");
-AdjustedArgs.push_back("/clang:-MT");
-AdjustedArgs.push_back(Twine("/clang:", FileNameArg).str());
-  } else {
-AdjustedArgs.push_back("-M");
-AdjustedArgs.push_back("-MT");
-AdjustedArgs.push_back(std::move(FileNameArg));
-  }
+// The clang-cl driver passes "-o -" to the frontend. Inject the real
+// file here to ensure "-MT" can be deduced if need be.
+if (ClangCLMode && !LastO.empty()) {
+  AdjustedArgs.push_back("/clang:-o");
+  AdjustedArgs.push_back("/clang:" + LastO);
 }
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
Index: clang/test/ClangScanDeps/regular_cdb.cpp
===
--- clang/test/ClangScanDeps/regular_cdb.cpp
+++ clang/test/ClangSc

[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-06-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

The bot is showing a fail due to this patch, see 
https://lab.llvm.org/buildbot#builders/110/builds/4007

It looks like my updates to LNT earlier this week haven't been migrated to the 
bot, is that right?

See https://reviews.llvm.org/rTccc86f938839d02de3a6564b2d80fb47a60aa069

In the json log I can see ffp-contract=off but it should be overridden to 
ffp-contract=off on the command line due to the LNT change.

Is there something else I need to do to update those sources?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


[PATCH] D102850: [C++4OpenCL] Fix overloading resolution of addrspace constructors

2021-06-10 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 351165.
olestrohm added a comment.

Added a comment explaining what the check is meant for.

Also added a `CHECK-NOT: used` to properly test that the __generic constructor 
is not used.


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

https://reviews.llvm.org/D102850

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp


Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -1,14 +1,24 @@
-// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s
 
 __constant int g1; // expected-error {{variable in constant address space must 
be initialized}}
 __constant int g2 = 0;
 
 struct X {
   int x;
+//CHECK:  CXXConstructorDecl
+//CHECK-NOT:  used
+//CHECK-SAME: X 'void (){{.*}} __generic'
+  X() /*__generic*/ : x(0) {}
+//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __private'
+  X() __private : x(0) {}
+//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __global'
+  X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}
 };
 
+__global X gx;
+
 //expected-note@+2{{candidate constructor (the implicit copy constructor) not 
viable: no known conversion from 'int' to 'const __generic Y' for 1st argument}}
 //expected-note@+1{{candidate constructor (the implicit move constructor) not 
viable: no known conversion from 'int' to '__generic Y' for 1st argument}}
 struct Y {
@@ -20,6 +30,7 @@
   __constant X cx1;
   __constant X cx2(1);
   __local X lx;
+  __private X x;
 
   __private Y py;
   __constant Y cy1; // expected-error{{variable in constant address space must 
be initialized}}
Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -11,8 +11,7 @@
   int x;
 
   // Local variables are handled in local_addrspace_init.clcpp
-  // FIXME: __private and __generic constructors clash for __private variable
-  // X() /*__generic*/ = default;
+  X() /*__generic*/ : x(0) {}
   X() __private : x(0) {}
   X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
@@ -30,7 +29,7 @@
 // CHECK: @_ZZ1kE3cx2 = internal addrspace(2) constant %struct.X { i32 1 }
 
 kernel void k() {
-  // Check that the constructor for px is executed
+  // Check that the constructor for px calls the __private constructor.
   // CHECK: %px = alloca %struct.X
   // CHECK-NEXT: call spir_func void @_ZN1XC1Ev(%struct.X* {{.*}}%px)
   __private X px;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9867,6 +9867,23 @@
S.IdentifyCUDAPreference(Caller, Cand2.Function);
   }
 
+  // Method overloading is handled above, so this only handles
+  // constructors with address spaces.
+  // This only handles address spaces since C++ has no other
+  // qualifier that can be used with constructors.
+  const auto *CD1 = dyn_cast_or_null(Cand1.Function);
+  const auto *CD2 = dyn_cast_or_null(Cand2.Function);
+  if (CD1 && CD2) {
+LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
+LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
+if (AS1 != AS2) {
+  if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
+return true;
+  if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
+return false;
+}
+  }
+
   return false;
 }
 


Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -1,14 +1,24 @@
-// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s
 
 __constant int g1; // expected-error {{variable in constant address space must be initialized}}
 __constant int g2 = 0;
 
 struct X {
   int x;
+//CHECK:  CXXConstructorDecl
+//CHECK-NOT:  used
+//CHECK-SAME: X 'void (){{.*}} __generic'
+  X() /*__generic*/ : x(0) {}
+//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __private'
+  X() __private : x(0) {}
+//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __global'
+  X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}
 };
 
+__global X gx;
+
 //expected-note@+2{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const __generic Y' for

[PATCH] D104031: [clang][deps] Move injection of `-Wno-error` from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This moves another piece of logic specific to `clang-scan-deps` into the 
`DependencyScanning` library. This makes it easier to check how the original 
command-line looked like in the library and will enable the library to stop 
inventing `-Wno-error` for modular dependencies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104031

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -506,7 +506,6 @@
 }
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
-AdjustedArgs.push_back("-Wno-error");
 
 if (!HasResourceDir) {
   StringRef ResourceDir =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -107,6 +107,8 @@
 Compiler.getDiagnosticOpts().ShowCarets = false;
 // Don't write out diagnostic file.
 Compiler.getDiagnosticOpts().DiagnosticSerializationFile.clear();
+// Don't treat warnings as errors.
+Compiler.getDiagnosticOpts().Warnings.push_back("no-error");
 // Create the compiler's actual diagnostics engine.
 Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
 if (!Compiler.hasDiagnostics())


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -506,7 +506,6 @@
 }
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
-AdjustedArgs.push_back("-Wno-error");
 
 if (!HasResourceDir) {
   StringRef ResourceDir =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -107,6 +107,8 @@
 Compiler.getDiagnosticOpts().ShowCarets = false;
 // Don't write out diagnostic file.
 Compiler.getDiagnosticOpts().DiagnosticSerializationFile.clear();
+// Don't treat warnings as errors.
+Compiler.getDiagnosticOpts().Warnings.push_back("no-error");
 // Create the compiler's actual diagnostics engine.
 Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
 if (!Compiler.hasDiagnostics())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104033: [clang][deps] Move enabling system header deps from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch moves enabling system header deps from `clang-scan-deps` into the 
`DependencyScanning` library. This will make it easier to preserve semantics of 
the original TU command-line for modular dependencies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104033

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -504,8 +504,6 @@
   AdjustedArgs.push_back("/clang:-o");
   AdjustedArgs.push_back("/clang:" + LastO);
 }
-AdjustedArgs.push_back("-Xclang");
-AdjustedArgs.push_back("-sys-header-deps");
 
 if (!HasResourceDir) {
   StringRef ResourceDir =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -175,6 +175,7 @@
 if (Opts->Targets.empty())
   Opts->Targets = {deduceDepTarget(Compiler.getFrontendOpts().OutputFile,
Compiler.getFrontendOpts().Inputs)};
+Opts->IncludeSystemHeaders = true;
 
 switch (Format) {
 case ScanningOutputFormat::Make:


Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -504,8 +504,6 @@
   AdjustedArgs.push_back("/clang:-o");
   AdjustedArgs.push_back("/clang:" + LastO);
 }
-AdjustedArgs.push_back("-Xclang");
-AdjustedArgs.push_back("-sys-header-deps");
 
 if (!HasResourceDir) {
   StringRef ResourceDir =
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -175,6 +175,7 @@
 if (Opts->Targets.empty())
   Opts->Targets = {deduceDepTarget(Compiler.getFrontendOpts().OutputFile,
Compiler.getFrontendOpts().Inputs)};
+Opts->IncludeSystemHeaders = true;
 
 switch (Format) {
 case ScanningOutputFormat::Make:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104036: [clang][deps] Prevent unintended modifications of the original TU command-line

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

One of the goals of the dependency scanner is to provide command-lines that can 
be used to build modular dependencies of a translation unit. The only 
modifications to these command-lines should be for the purposes of explicit 
modular build.

The current version of dependency scanner leaks its implementation details into 
the command-lines for modular dependencies.

The first problem is that the `clang-scan-deps` tool adjusts the original 
textual command-line (adding `-Eonly -M -MT  -sys-header-deps 
-Wno-error -o /dev/null `, removing `--serialize-diagnostics`) in order to set 
up the `DependencyScanning` library. This has been addressed in D103461 
, D104012 , 
D104030 , D104031 
, D104033  
and moved into the library which directly adjusts a `CompilerInvocation` 
instead.

The `DependencyScanning` library now received the unmodifies 
`CompilerInvocation`, sets it up internally and uses it for the implicit build.

To prevent leaking the implementation details to the resulting command-lines 
(which get generated from this `CompilerInvocation`), this patch immediately 
makes a deep copy of the original invocation, stores the copy and uses it to 
generate the command-lines instead of the modified one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104036

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/preserved-args/cdb.json.template
  clang/test/ClangScanDeps/Inputs/preserved-args/mod.h
  clang/test/ClangScanDeps/Inputs/preserved-args/module.modulemap
  clang/test/ClangScanDeps/Inputs/preserved-args/tu.c
  clang/test/ClangScanDeps/preserved-args.c

Index: clang/test/ClangScanDeps/preserved-args.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/preserved-args.c
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp -r %S/Inputs/preserved-args/* %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full >> %t/result.json
+// RUN: cat %t/result.json | FileCheck %s
+
+// CHECK:  -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK:  "-serialize-diagnostic-file"
+// CHECK-NEXT: "[[PREFIX]]/tu.dia"
+// CHECK:  "-fmodule-file=Foo=[[PREFIX]]/foo.pcm"
+// CHECK:  "-MT"
+// CHECK-NEXT: "my_target"
+// CHECK:  "-dependency-file"
+// CHECK-NEXT: "[[PREFIX]]/tu.d"
+// CHECK:],
+// CHECK:"name": "Mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK:  }
Index: clang/test/ClangScanDeps/Inputs/preserved-args/tu.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/preserved-args/tu.c
@@ -0,0 +1 @@
+#include "mod.h"
Index: clang/test/ClangScanDeps/Inputs/preserved-args/module.modulemap
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/preserved-args/module.modulemap
@@ -0,0 +1,3 @@
+module Mod {
+  header "mod.h"
+}
Index: clang/test/ClangScanDeps/Inputs/preserved-args/mod.h
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/preserved-args/mod.h
@@ -0,0 +1 @@
+// mod.h
Index: clang/test/ClangScanDeps/Inputs/preserved-args/cdb.json.template
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/preserved-args/cdb.json.template
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -MD -MT my_target -serialize-diagnostics DIR/tu.dia -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -fmodule-file=Foo=DIR/foo.pcm -o DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -20,8 +20,8 @@
 
 CompilerInvocation ModuleDepCollector::makeInvocationForModuleBuildWithoutPaths(
 const ModuleDeps &Deps) const {
-  // Make a deep copy of the invocation.
-  CompilerInvocation CI(

[clang] 49eba8b - [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-10 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-06-10T16:54:15+02:00
New Revision: 49eba8bf1780684f1173a455b909ce37008eaa09

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

LOG: [clang] Do not crash when ArgTy is null in CheckArgAlignment

This can happen around RecoveryExpr.

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 99110c6b5d8dd..86c888548077e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
@@ -4654,6 +4655,9 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
+if (Arg->containsErrors())
+  continue;
+
 QualType ParamTy = Proto->getParamType(ArgIdx);
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
index 8bdf83e9512fd..d3ac772db0089 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -136,3 +136,9 @@ void baz() {
   bar(S(123)); // expected-error {{no matching conversion}}
 }
 } // namespace test11
+
+namespace test12 {
+// Verify we do not crash.
+void fun(int *foo = no_such_function()); // expected-error {{undeclared 
identifier}}
+void baz() { fun(); }
+} // namespace test12



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


[PATCH] D103825: [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-10 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49eba8bf1780: [clang] Do not crash when ArgTy is null in 
CheckArgAlignment (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103825

Files:
  clang/lib/Sema/SemaChecking.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
@@ -136,3 +136,9 @@
   bar(S(123)); // expected-error {{no matching conversion}}
 }
 } // namespace test11
+
+namespace test12 {
+// Verify we do not crash.
+void fun(int *foo = no_such_function()); // expected-error {{undeclared 
identifier}}
+void baz() { fun(); }
+} // namespace test12
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
@@ -4654,6 +4655,9 @@
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
+if (Arg->containsErrors())
+  continue;
+
 QualType ParamTy = Proto->getParamType(ArgIdx);
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -136,3 +136,9 @@
   bar(S(123)); // expected-error {{no matching conversion}}
 }
 } // namespace test11
+
+namespace test12 {
+// Verify we do not crash.
+void fun(int *foo = no_such_function()); // expected-error {{undeclared identifier}}
+void baz() { fun(); }
+} // namespace test12
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4571,8 +4571,9 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ArgTy.isNull() || ParamTy->isIncompleteType() ||
+  ArgTy->isIncompleteType() || ParamTy->isUndeducedType() ||
+  ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
@@ -4654,6 +4655,9 @@
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
+if (Arg->containsErrors())
+  continue;
+
 QualType ParamTy = Proto->getParamType(ArgIdx);
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9833b57 - [clang][driver] Add -foperator-names

2021-06-10 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-06-10T17:01:35+02:00
New Revision: 9833b57981c4e9402a326b5acd805e074cd2c802

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

LOG: [clang][driver] Add -foperator-names

This patch adds the command line option -foperator-names which acts as the 
opposite of -fno-operator-names. With this command line option it is possible 
to reenable C++ operator keywords on the command line if -fno-operator-names 
had previously been passed.

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

Added: 
clang/test/Driver/cxx-operator-names.cpp

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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7dcee76b4ed8..862cb32730a2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2221,9 +2221,10 @@ def fno_ms_compatibility : Flag<["-"], 
"fno-ms-compatibility">, Group,
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;
 def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group;
-def fno_operator_names : Flag<["-"], "fno-operator-names">, Group,
-  HelpText<"Do not treat C++ operator name keywords as synonyms for 
operators">,
-  Flags<[CC1Option]>, 
MarshallingInfoNegativeFlag, cplusplus.KeyPath>;
+defm operator_names : BoolFOption<"operator-names",
+  LangOpts<"CXXOperatorNames">, Default,
+  NegFlag,
+  PosFlag>;
 def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, 
Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in 
diagnostics">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6eaa8938a8d2..3163c26e4472 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5654,11 +5654,14 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fno_operator_names,
+   options::OPT_foperator_names, false))
+CmdArgs.push_back("-fno-operator-names");
+
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
-  Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
   options::OPT_fno_emulated_tls);
 

diff  --git a/clang/test/Driver/cxx-operator-names.cpp 
b/clang/test/Driver/cxx-operator-names.cpp
new file mode 100644
index ..d8a7a01449bb
--- /dev/null
+++ b/clang/test/Driver/cxx-operator-names.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -### -S -foperator-names -fno-operator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: "-fno-operator-names"
+
+// RUN: %clang -### -S -fno-operator-names -foperator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: "-fno-operator-names"



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


[PATCH] D103749: [clang][driver] Add -foperator-names

2021-06-10 Thread Markus Böck 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 rG9833b57981c4: [clang][driver] Add -foperator-names (authored 
by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103749

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cxx-operator-names.cpp


Index: clang/test/Driver/cxx-operator-names.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-operator-names.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -### -S -foperator-names -fno-operator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: "-fno-operator-names"
+
+// RUN: %clang -### -S -fno-operator-names -foperator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: "-fno-operator-names"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5654,11 +5654,14 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fno_operator_names,
+   options::OPT_foperator_names, false))
+CmdArgs.push_back("-fno-operator-names");
+
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
-  Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
   options::OPT_fno_emulated_tls);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2221,9 +2221,10 @@
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;
 def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group;
-def fno_operator_names : Flag<["-"], "fno-operator-names">, Group,
-  HelpText<"Do not treat C++ operator name keywords as synonyms for 
operators">,
-  Flags<[CC1Option]>, 
MarshallingInfoNegativeFlag, cplusplus.KeyPath>;
+defm operator_names : BoolFOption<"operator-names",
+  LangOpts<"CXXOperatorNames">, Default,
+  NegFlag,
+  PosFlag>;
 def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, 
Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in 
diagnostics">,
   MarshallingInfoFlag>;


Index: clang/test/Driver/cxx-operator-names.cpp
===
--- /dev/null
+++ clang/test/Driver/cxx-operator-names.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -### -S -foperator-names -fno-operator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: "-fno-operator-names"
+
+// RUN: %clang -### -S -fno-operator-names -foperator-names %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2-NOT: "-fno-operator-names"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5654,11 +5654,14 @@
 
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fno_operator_names,
+   options::OPT_foperator_names, false))
+CmdArgs.push_back("-fno-operator-names");
+
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
-  Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
   options::OPT_fno_emulated_tls);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2221,9 +2221,10 @@
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, Flags<[CC1Option]>;
 def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group;
-def fno_operator_names : Flag<["-"], "fno-operator-names">, Group,
-  HelpText<"Do not treat C++ operator name keywords as synonyms for operators">,
-  Flags<[CC1Option]>, MarshallingInfoNegativeFlag, cplusplus.KeyPath>;
+defm operator_names : BoolFOption<"operator-names",
+  Lan

[clang] 936d675 - [clang][msvc] Define _HAS_STATIC_RTTI to 0, when compiling with -fno-rtti

2021-06-10 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-06-10T17:02:44+02:00
New Revision: 936d6756ccfbe207a181b692b828f9fd8f1489f2

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

LOG: [clang][msvc] Define _HAS_STATIC_RTTI to 0, when compiling with -fno-rtti

When using the -fno-rtti option of the GCC style clang++, using typeid results 
in an error. The MSVC STL however kindly provides a define flag called 
_HAS_STATIC_RTTI, which either enables or disables uses of typeid throughout 
the STL. By default, if undefined, it is set to 1, enabling the use of typeid.

With this patch, _HAS_STATIC_RTTI is set to 0 when -fno-rtti is specified. This 
way various headers of the MSVC STL like functional can be consumed without 
compilation failures.

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

Added: 
clang/test/Driver/msvc-static-rtti.cpp

Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index dd7fa5ebf6ff..9b1c320755ed 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1573,3 +1573,13 @@ MSVCToolChain::TranslateArgs(const 
llvm::opt::DerivedArgList &Args,
 
   return DAL;
 }
+
+void MSVCToolChain::addClangTargetOptions(
+const ArgList &DriverArgs, ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const {
+  // MSVC STL kindly allows removing all usages of typeid by defining
+  // _HAS_STATIC_RTTI to 0. Do so, when compiling with -fno-rtti
+  if (DriverArgs.hasArg(options::OPT_fno_rtti, options::OPT_frtti,
+/*Default=*/false))
+CC1Args.push_back("-D_HAS_STATIC_RTTI=0");
+}

diff  --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 432d399e241e..19d94c5c606e 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -122,6 +122,11 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
 
   bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
 
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+
 protected:
   void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args,

diff  --git a/clang/test/Driver/msvc-static-rtti.cpp 
b/clang/test/Driver/msvc-static-rtti.cpp
new file mode 100644
index ..b352f07bc6c1
--- /dev/null
+++ b/clang/test/Driver/msvc-static-rtti.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc -fno-rtti -### %s 2>&1 | 
FileCheck %s -check-prefix STATIC-RTTI-DEF
+// RUN: %clang -target x86_64-pc-windows-msvc -frtti -### %s 2>&1 | FileCheck 
%s -check-prefix STATIC-RTTI-DEF-NOT
+
+// STATIC-RTTI-DEF: -D_HAS_STATIC_RTTI=0
+// STATIC-RTTI-DEF-NOT: -D_HAS_STATIC_RTTI=0



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


[PATCH] D103771: [clang][msvc] Define _HAS_STATIC_RTTI to 0, when compiling with -fno-rtti

2021-06-10 Thread Markus Böck via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG936d6756ccfb: [clang][msvc] Define _HAS_STATIC_RTTI to 0, 
when compiling with -fno-rtti (authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103771

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/test/Driver/msvc-static-rtti.cpp


Index: clang/test/Driver/msvc-static-rtti.cpp
===
--- /dev/null
+++ clang/test/Driver/msvc-static-rtti.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc -fno-rtti -### %s 2>&1 | 
FileCheck %s -check-prefix STATIC-RTTI-DEF
+// RUN: %clang -target x86_64-pc-windows-msvc -frtti -### %s 2>&1 | FileCheck 
%s -check-prefix STATIC-RTTI-DEF-NOT
+
+// STATIC-RTTI-DEF: -D_HAS_STATIC_RTTI=0
+// STATIC-RTTI-DEF-NOT: -D_HAS_STATIC_RTTI=0
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -122,6 +122,11 @@
 
   bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
 
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+
 protected:
   void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args,
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1573,3 +1573,13 @@
 
   return DAL;
 }
+
+void MSVCToolChain::addClangTargetOptions(
+const ArgList &DriverArgs, ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const {
+  // MSVC STL kindly allows removing all usages of typeid by defining
+  // _HAS_STATIC_RTTI to 0. Do so, when compiling with -fno-rtti
+  if (DriverArgs.hasArg(options::OPT_fno_rtti, options::OPT_frtti,
+/*Default=*/false))
+CC1Args.push_back("-D_HAS_STATIC_RTTI=0");
+}


Index: clang/test/Driver/msvc-static-rtti.cpp
===
--- /dev/null
+++ clang/test/Driver/msvc-static-rtti.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc -fno-rtti -### %s 2>&1 | FileCheck %s -check-prefix STATIC-RTTI-DEF
+// RUN: %clang -target x86_64-pc-windows-msvc -frtti -### %s 2>&1 | FileCheck %s -check-prefix STATIC-RTTI-DEF-NOT
+
+// STATIC-RTTI-DEF: -D_HAS_STATIC_RTTI=0
+// STATIC-RTTI-DEF-NOT: -D_HAS_STATIC_RTTI=0
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -122,6 +122,11 @@
 
   bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }
 
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+
 protected:
   void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args,
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1573,3 +1573,13 @@
 
   return DAL;
 }
+
+void MSVCToolChain::addClangTargetOptions(
+const ArgList &DriverArgs, ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const {
+  // MSVC STL kindly allows removing all usages of typeid by defining
+  // _HAS_STATIC_RTTI to 0. Do so, when compiling with -fno-rtti
+  if (DriverArgs.hasArg(options::OPT_fno_rtti, options::OPT_frtti,
+/*Default=*/false))
+CC1Args.push_back("-D_HAS_STATIC_RTTI=0");
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c70b0e8 - [clang-cl] Add /permissive and /permissive-

2021-06-10 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2021-06-10T17:06:19+02:00
New Revision: c70b0e808da8e1650f3ee426698a8b87c94b8910

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

LOG: [clang-cl] Add /permissive and /permissive-

This patch adds the command line options /permissive and /permissive- to 
clang-cl. These flags are used in MSVC to enable various /Zc language 
conformance options at once. In particular, /permissive is used to enable the 
various non standard behaviour of MSVC, while /permissive- is the opposite.

When either of two command lines are specified they are simply expanded to the 
various underlying /Zc options. In particular when /permissive is passed it 
currently expands to:

/Zc:twoPhase- (disable two phase lookup)
-fno-operator-names (disable C++ operator keywords)
/permissive- expands to the opposites of these flags + /Zc:strictStrings 
(/Zc:strictStrings- does not currently exist). In the future, if any more MSVC 
workarounds are ever added they can easily be added to the expansion. One is 
also able to override settings done by permissive. Specifying /permissive- 
/Zc:twoPhase- will apply the settings from permissive minus, but disables two 
phase lookup.

Motivation for this patch was mainly parity with MSVC as well as compatibility 
with Windows SDK headers. The /permissive page from MSVC documents various 
workarounds that have to be done for the Windows SDK headers [1], when MSVC is 
used with /permissive-. In these, Microsoft often recommends simply compiling 
with /permissive for the specified source files. Since some of these also apply 
to clang-cl (which acts like /permissive- by default mostly), and some are 
currently implemented as "hacks" within clang that I'd like to remove, adding 
/permissive and /permissive- to be in full parity with MSVC and Microsofts 
documentation made sense to me.

[1] 
https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160#windows-header-issues

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

Added: 
clang/test/Driver/cl-permissive.c

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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 862cb32730a2..1271a75ba67e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6099,6 +6099,10 @@ def _SLASH_o : CLJoinedOrSeparate<"o">,
   HelpText<"Deprecated (set output file name); use /Fe or /Fe">,
   MetaVarName<"">;
 def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">;
+def _SLASH_permissive : CLFlag<"permissive">,
+  HelpText<"Enable some non conforming code to compile">;
+def _SLASH_permissive_ : CLFlag<"permissive-">,
+  HelpText<"Disable non conforming code from compiling (default)">;
 def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">,
   HelpText<"Treat  as C source file">, MetaVarName<"">;
 def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">;
@@ -6180,7 +6184,6 @@ def _SLASH_FS : CLIgnoredFlag<"FS">;
 def _SLASH_JMC : CLIgnoredFlag<"JMC">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
-def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
 def _SLASH_sdl : CLIgnoredFlag<"sdl">;
 def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">;

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 9b1c320755ed..ea79c0ec9eb5 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1523,6 +1523,20 @@ static void TranslateDArg(Arg *A, 
llvm::opt::DerivedArgList &DAL,
   DAL.AddJoinedArg(A, Opts.getOption(options::OPT_D), NewVal);
 }
 
+static void TranslatePermissive(Arg *A, llvm::opt::DerivedArgList &DAL,
+const OptTable &Opts) {
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase_));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_operator_names));
+  // There is currently no /Zc:strictStrings- in clang-cl
+}
+
+static void TranslatePermissiveMinus(Arg *A, llvm::opt::DerivedArgList &DAL,
+ const OptTable &Opts) {
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_foperator_names));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_strictStrings));
+}
+
 llvm::opt::DerivedArgList *
 MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
  StringRef BoundArch,
@@ -1565,6 +1579,12 @@ MSVCToolChain::TranslateArgs(const 
llvm::opt::DerivedArgList &Args,
 } else if (A->getOption().matches(options::OPT_D)) {
   

[PATCH] D103773: [clang-cl] Add /permissive and /permissive-

2021-06-10 Thread Markus Böck 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 rGc70b0e808da8: [clang-cl] Add /permissive and /permissive- 
(authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103773

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


Index: clang/test/Driver/cl-permissive.c
===
--- /dev/null
+++ clang/test/Driver/cl-permissive.c
@@ -0,0 +1,17 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// RUN: %clang_cl /permissive -### -- %s 2>&1 | FileCheck 
-check-prefix=PERMISSIVE %s
+// PERMISSIVE: "-fno-operator-names"
+// PERMISSIVE: "-fdelayed-template-parsing"
+// RUN: %clang_cl /permissive- -### -- %s 2>&1 | FileCheck 
-check-prefix=PERMISSIVE-MINUS %s
+// PERMISSIVE-MINUS-NOT: "-fno-operator-names"
+// PERMISSIVE-MINUS-NOT: "-fdelayed-template-parsing"
+
+// The switches set by permissive may then still be manually enabled or 
disabled
+// RUN: %clang_cl /permissive /Zc:twoPhase -### -- %s 2>&1 | FileCheck 
-check-prefix=PERMISSIVE-OVERWRITE %s
+// PERMISSIVE-OVERWRITE: "-fno-operator-names"
+// PERMISSIVE-OVERWRITE-NOT: "-fdelayed-template-parsing"
+// RUN: %clang_cl /permissive- /Zc:twoPhase- -### -- %s 2>&1 | FileCheck 
-check-prefix=PERMISSIVE-MINUS-OVERWRITE %s
+// PERMISSIVE-MINUS-OVERWRITE-NOT: "-fno-operator-names"
+// PERMISSIVE-MINUS-OVERWRITE: "-fdelayed-template-parsing"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1523,6 +1523,20 @@
   DAL.AddJoinedArg(A, Opts.getOption(options::OPT_D), NewVal);
 }
 
+static void TranslatePermissive(Arg *A, llvm::opt::DerivedArgList &DAL,
+const OptTable &Opts) {
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase_));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_operator_names));
+  // There is currently no /Zc:strictStrings- in clang-cl
+}
+
+static void TranslatePermissiveMinus(Arg *A, llvm::opt::DerivedArgList &DAL,
+ const OptTable &Opts) {
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_twoPhase));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT_foperator_names));
+  DAL.AddFlagArg(A, Opts.getOption(options::OPT__SLASH_Zc_strictStrings));
+}
+
 llvm::opt::DerivedArgList *
 MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
  StringRef BoundArch,
@@ -1565,6 +1579,12 @@
 } else if (A->getOption().matches(options::OPT_D)) {
   // Translate -Dfoo#bar into -Dfoo=bar.
   TranslateDArg(A, *DAL, Opts);
+} else if (A->getOption().matches(options::OPT__SLASH_permissive)) {
+  // Expand /permissive
+  TranslatePermissive(A, *DAL, Opts);
+} else if (A->getOption().matches(options::OPT__SLASH_permissive_)) {
+  // Expand /permissive-
+  TranslatePermissiveMinus(A, *DAL, Opts);
 } else if (OFK != Action::OFK_HIP) {
   // HIP Toolchain translates input args by itself.
   DAL->append(A);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6099,6 +6099,10 @@
   HelpText<"Deprecated (set output file name); use /Fe or /Fe">,
   MetaVarName<"">;
 def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">;
+def _SLASH_permissive : CLFlag<"permissive">,
+  HelpText<"Enable some non conforming code to compile">;
+def _SLASH_permissive_ : CLFlag<"permissive-">,
+  HelpText<"Disable non conforming code from compiling (default)">;
 def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">,
   HelpText<"Treat  as C source file">, MetaVarName<"">;
 def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">;
@@ -6180,7 +6184,6 @@
 def _SLASH_JMC : CLIgnoredFlag<"JMC">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
-def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
 def _SLASH_sdl : CLIgnoredFlag<"sdl">;
 def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">;


Index: clang/test/Driver/cl-permissive.c
===
--- /dev/null
+++ clang/test/Driver/cl-permissive.c
@@ -0,0 +1,17 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// RUN: %clang_cl /permissive -### -- %s 2>&1 | FileCheck -check-prefix=PERMISSIVE %s
+// PERMISSIVE: "-fno

[PATCH] D102576: [clang-tidy] cppcoreguidelines-avoid-do-while: a new check

2021-06-10 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 added a comment.

Friendly Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102576

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


[PATCH] D104030: [clang][deps] Move invocation adjustments from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a subscriber: saudi.
jansvoboda11 added a comment.

FYI @saudi.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104030

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


[PATCH] D104031: [clang][deps] Move injection of `-Wno-error` from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104031

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


[PATCH] D104033: [clang][deps] Move enabling system header deps from `clang-scan-deps` to `DependencyScanning` library

2021-06-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104033

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


[PATCH] D103849: Fix undeduced type when instanciating template member

2021-06-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 351191.
serge-sans-paille added a comment.

Added test + fix suggested by @aaron.ballman


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

https://reviews.llvm.org/D103849

Files:
  clang/lib/AST/Expr.cpp
  clang/test/CodeGenCXX/auto-variable-template.cpp


Index: clang/test/CodeGenCXX/auto-variable-template.cpp
===
--- clang/test/CodeGenCXX/auto-variable-template.cpp
+++ clang/test/CodeGenCXX/auto-variable-template.cpp
@@ -12,3 +12,21 @@
 
 // CHECK: define{{.*}} i32 @main()
 // CHECK: call void @_ZNK1fclEv(%struct.f* {{[^,]*}} @_Z9vtemplateIiE)
+
+template 
+struct pack {
+  template 
+  constexpr static auto some_boolean_cx_value = true;
+};
+
+auto usage() {
+  return pack::some_boolean_cx_value;
+}
+
+// CHECK: define{{.*}} i1 @_Z5usagev()
+
+auto otherusage() {
+  return pack{}.some_boolean_cx_value;
+}
+
+// CHECK: define{{.*}} i1 @_Z10otherusagev()
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -490,6 +490,8 @@
 
 void DeclRefExpr::setDecl(ValueDecl *NewD) {
   D = NewD;
+  if (getType()->isUndeducedType())
+setType(NewD->getType());
   setDependence(computeDependence(this, NewD->getASTContext()));
 }
 
@@ -1722,8 +1724,10 @@
   return new (Mem) MemberExpr(EmptyShell());
 }
 
-void MemberExpr::setMemberDecl(ValueDecl *D) {
-  MemberDecl = D;
+void MemberExpr::setMemberDecl(ValueDecl *NewD) {
+  MemberDecl = NewD;
+  if (getType()->isUndeducedType())
+setType(NewD->getType());
   setDependence(computeDependence(this));
 }
 


Index: clang/test/CodeGenCXX/auto-variable-template.cpp
===
--- clang/test/CodeGenCXX/auto-variable-template.cpp
+++ clang/test/CodeGenCXX/auto-variable-template.cpp
@@ -12,3 +12,21 @@
 
 // CHECK: define{{.*}} i32 @main()
 // CHECK: call void @_ZNK1fclEv(%struct.f* {{[^,]*}} @_Z9vtemplateIiE)
+
+template 
+struct pack {
+  template 
+  constexpr static auto some_boolean_cx_value = true;
+};
+
+auto usage() {
+  return pack::some_boolean_cx_value;
+}
+
+// CHECK: define{{.*}} i1 @_Z5usagev()
+
+auto otherusage() {
+  return pack{}.some_boolean_cx_value;
+}
+
+// CHECK: define{{.*}} i1 @_Z10otherusagev()
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -490,6 +490,8 @@
 
 void DeclRefExpr::setDecl(ValueDecl *NewD) {
   D = NewD;
+  if (getType()->isUndeducedType())
+setType(NewD->getType());
   setDependence(computeDependence(this, NewD->getASTContext()));
 }
 
@@ -1722,8 +1724,10 @@
   return new (Mem) MemberExpr(EmptyShell());
 }
 
-void MemberExpr::setMemberDecl(ValueDecl *D) {
-  MemberDecl = D;
+void MemberExpr::setMemberDecl(ValueDecl *NewD) {
+  MemberDecl = NewD;
+  if (getType()->isUndeducedType())
+setType(NewD->getType());
   setDependence(computeDependence(this));
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3a7a774 - Add a page to track the status of C proposals in Clang.

2021-06-10 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-06-10T12:00:52-04:00
New Revision: 3a7a7749417854827cf621eaef6012d31e7a82ab

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

LOG: Add a page to track the status of C proposals in Clang.

Added: 
clang/www/c_status.html

Modified: 
clang/www/menu.html.incl

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
new file mode 100644
index 0..72df57a667b89
--- /dev/null
+++ b/clang/www/c_status.html
@@ -0,0 +1,300 @@
+
+
+
+  
+  Clang - C Programming Language Status
+  
+  
+  
+.none { background-color: #FF }
+.partial { background-color: #FFE0B0 }
+.unreleased { background-color: #99 }
+.unknown { background-color: #FF55FF }
+.full { background-color: #CCFF99 }
+.na { background-color: #DD }
+:target { background-color: #BB; outline: #55 solid thin; }
+th { background-color: #FFDDAA }
+td { vertical-align: middle }
+tt { white-space: nowrap }
+  
+
+
+
+
+
+
+
+
+C Support in Clang
+
+
+Clang implements the following published and upcoming ISO C standards:
+
+
+
+ Language Standard
+ Flag
+ Available in Clang?
+
+
+ C89
+ -std=c89
+ Yes
+
+
+ C99
+ -std=c99
+ Almost certainly
+
+
+ C11
+ -std=c11
+ Probably
+
+
+ C17
+ -std=c17
+ Maybe?
+
+
+ C2x
+ -std=c2x
+ Partial
+
+
+
+The implementation status for C99, C11, and C17 are currently under
+investigation. Any proposal whose status in Clang is currently unknown
+will be marked in magenta.
+
+The Clang community is continually striving to improve C standards
+compliance between releases. We implement the resolution for defect
+reports, but we do not currently track our DR status (help with
+tracking DR status is appreciated).
+
+The https://bugs.llvm.org/";>LLVM bug tracker contains a
+Clang C component that tracks known bugs with Clang's language
+conformance.
+
+C89 implementation status
+
+Clang implements all of the ISO 9899:1990 (C89) standard.
+
+C99 implementation status
+
+Clang implements a significant portion of the ISO 9899:1999 (C99) standard, 
but the status of individual proposals is still under investigation.
+
+C11 implementation status
+
+Clang implements a significant portion of the ISO 9899:2011 (C11) standard, 
but the status of individual proposals is still under investigation.
+
+C17 implementation status
+
+Clang implements a significant portion of the ISO 9899:2018 (C17) standard, 
but the status of individual proposals is still under investigation.
+
+C2x implementation status
+
+Clang has support for some of the features of the C standard following C17, 
informally referred to as C2x.
+
+You can use Clang in C2x mode with the -std=c2x option.
+
+
+List of features and minimum Clang version with support
+
+
+ 
+Language Feature
+C2x Proposal
+Available in Clang?
+ 
+
+
+  Evaluation formats
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2186.pdf";>N2186
+  Unknown
+
+
+  Clarifying the restrict Keyword v2
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2260.pdf";>N2660
+  Unknown
+
+
+  Harmonizing static_assert with C++
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2265.pdf";>N2665
+  Clang 9
+
+
+  nodiscard attribute
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2667.pdf";>N2667
+  Clang 9
+
+
+  maybe_unused attribute
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2670.pdf";>N2670
+  Clang 9
+
+
+  TS 18661 Integration
+
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2314.pdf";>N2314
+Unknown
+  
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2341.pdf";>N2341
+Unknown
+  
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2401.pdf";>N2401
+Unknown
+  
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2359.pdf";>N2359
+Unknown
+  
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2546.pdf";>N2546
+Unknown
+  
+
+  Preprocessor line numbers unspecified
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2322.htm";>N2322
+  Yes
+
+
+  deprecated attribute
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2334.pdf";>N2334
+  Clang 9
+
+
+  Attributes
+
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2335.pdf";>N2335
+Clang 9
+  
+   
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2554.pdf";>N2554
+Clang 9
+  
+
+  Defining new types in offsetof
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm";>N2350
+  Yes
+
+
+  fallthrough attr

[PATCH] D104040: [OpenCL] Add TableGen emitter for OpenCL builtin header

2021-06-10 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: azabaznov, Anastasia.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Add an emitter to produce something similar to `opencl-c.h` from the
OpenCL builtin descriptions in `OpenCLBuiltins.td`

Factor out functionality that can be shared between the test emitter
and the header emitter into a new base class.

This only adds the emitter, without any use of it currently.

Example output excerpt (the full output is about 16k lines):

  ...
  __ovld __cnfn size_t get_global_id(uint);
  __ovld __cnfn size_t get_local_size(uint);
  __ovld __cnfn size_t get_local_id(uint);
  __ovld __cnfn size_t get_num_groups(uint);
  __ovld __cnfn size_t get_group_id(uint);
  __ovld __cnfn size_t get_global_offset(uint);
  #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
  __ovld size_t get_enqueued_local_size(uint);
  #endif // MinVersion
  ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104040

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -122,6 +122,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangOpenCLBuiltinHeader(llvm::RecordKeeper &Records,
+  llvm::raw_ostream &OS);
 void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
 
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinHeader,
   GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
@@ -195,6 +196,9 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinHeader,
+   "gen-clang-opencl-builtin-header",
+   "Generate OpenCL builtin header"),
 clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
"Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
@@ -374,6 +378,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinHeader:
+EmitClangOpenCLBuiltinHeader(Records, OS);
+break;
   case GenClangOpenCLBuiltinTests:
 EmitClangOpenCLBuiltinTests(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -229,19 +229,17 @@
   MapVector SignatureListMap;
 };
 
-// OpenCL builtin test generator.  This class processes the same TableGen input
-// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
-// builtin function described in the .td input.
-class OpenCLBuiltinTestEmitter {
+/// Base class for emitting a file (e.g. header or test) from OpenCLBuiltins.td
+class OpenCLBuiltinFileEmitterBase {
 public:
-  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  OpenCLBuiltinFileEmitterBase(RecordKeeper &Records, raw_ostream &OS)
   : Records(Records), OS(OS) {}
 
   // Entrypoint to generate the functions for testing all OpenCL builtin
   // functions.
-  void emit();
+  virtual void emit() = 0;
 
-private:
+protected:
   struct TypeFlags {
 TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
 bool IsConst : 1;
@@ -278,6 +276,18 @@
   expandTypesInSignature(const std::vector &Signature,
  SmallVectorImpl> &Types);
 
+  // Emit extension enabling pragmas.
+  void emitExtensionSetup();
+
+  // Emit an #if guard for a Builtin's extension.  Return the corresponding
+  // closing #endif, or an empty string if no extension #if guard was emitted.
+  std::string emitExtensionGuard(const Record *Builtin);
+
+  // Emit an #if guard for a Builtin's language version.  Return the
+  // corresponding closing #endif, or an empty string if no version #if guard
+  // was emitted.
+  std::string emitVersionGuard(const Record *Builtin);
+
   // Contains OpenCL builtin functions and related information, stored as
   // Record instances. They are coming from the associated TableGen file.
   RecordKe

[PATCH] D103987: Start tracking Clang's C implementation status

2021-06-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D103987#2809125 , @jyknight wrote:

> Sounds like a great plan to me.
>
> I might suggest adding some text about the page being incomplete, so that 
> people don't wonder if the blank sections for pre-C2x are a bug.

Thanks, that's a great suggestion!

I've landed this patch with some additional text about the incompleteness in 
3a7a7749417854827cf621eaef6012d31e7a82ab 
, and I'll 
update the page as I have the opportunity. If anyone spots anything they think 
I've misclassified, please let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103987

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2021-06-10 Thread Andrew Gallagher via Phabricator via cfe-commits
andrewjcg updated this revision to Diff 351195.
andrewjcg added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/Inputs/implicit-module-header-maps/a.h
  clang/test/Modules/Inputs/implicit-module-header-maps/a.hmap.json
  clang/test/Modules/Inputs/implicit-module-header-maps/a.module.modulemap
  clang/test/Modules/Inputs/implicit-module-header-maps/b.hmap.json
  clang/test/Modules/implicit-module-header-maps.cpp


Index: clang/test/Modules/implicit-module-header-maps.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-header-maps.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %T
+// RUN: mkdir %T
+// RUN: cd %T
+//
+// RUN: %hmaptool write %S/Inputs/implicit-module-header-maps/a.hmap.json 
%T/hmap
+//
+// RUN: mkdir -p %T/After
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.h %T/After/Mapping.h
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.module.modulemap 
%T/module.modulemap
+//
+// RUN: %clang -Rmodule-build -fmodules -fimplicit-modules 
-fimplicit-module-maps -fmodule-map-file=%T/module.modulemap -fsyntax-only %s 
-I %T/hmap
+//
+// RUN: rm -rf %T
+// RUN: mkdir %T
+// RUN: cd %T
+//
+// RUN: sed -e "s:OUTPUTS_DIR:%T:g" 
%S/Inputs/implicit-module-header-maps/b.hmap.json > %T/hmap.json
+// RUN: %hmaptool write %T/hmap.json %T/hmap
+//
+// RUN: mkdir -p %T/After
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.h %T/After/Mapping.h
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.module.modulemap 
%T/module.modulemap
+//
+// RUN: %clang -Rmodule-build -fmodules -fimplicit-modules 
-fimplicit-module-maps -fmodule-map-file=%T/module.modulemap -fsyntax-only %s 
-I %T/hmap
+
+#define FOO
+#include "Before/Mapping.h"
Index: clang/test/Modules/Inputs/implicit-module-header-maps/b.hmap.json
===
--- /dev/null
+++ clang/test/Modules/Inputs/implicit-module-header-maps/b.hmap.json
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Before/Mapping.h" : "OUTPUTS_DIR/After/Mapping.h"
+}
+}
Index: clang/test/Modules/Inputs/implicit-module-header-maps/a.module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/implicit-module-header-maps/a.module.modulemap
@@ -0,0 +1,3 @@
+module a {
+  header "After/Mapping.h"
+}
Index: clang/test/Modules/Inputs/implicit-module-header-maps/a.hmap.json
===
--- /dev/null
+++ clang/test/Modules/Inputs/implicit-module-header-maps/a.hmap.json
@@ -0,0 +1,7 @@
+{
+  "mappings" :
+{
+ "Before/Mapping.h" : "After/Mapping.h",
+ "After/Mapping.h" : "After/Mapping.h"
+}
+}
Index: clang/test/Modules/Inputs/implicit-module-header-maps/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/implicit-module-header-maps/a.h
@@ -0,0 +1,3 @@
+#ifdef FOO
+#error foo
+#endif
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -438,10 +438,20 @@
 Optional Result = HM->LookupFile(Filename, HS.getFileMgr());
 if (Result) {
   FixupSearchPath();
+  if (!HS.findUsableModuleForHeader(
+  &Result->getFileEntry(), Result->getFileEntry().getDir(),
+  RequestingModule, SuggestedModule, isSystemHeaderDirectory())) {
+return None;
+  }
   return *Result;
 }
   } else if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest)) {
 FixupSearchPath();
+if (!HS.findUsableModuleForHeader(
+&Res->getFileEntry(), Res->getFileEntry().getDir(),
+RequestingModule, SuggestedModule, isSystemHeaderDirectory())) {
+  return None;
+}
 return *Res;
   }
 


Index: clang/test/Modules/implicit-module-header-maps.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-header-maps.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %T
+// RUN: mkdir %T
+// RUN: cd %T
+//
+// RUN: %hmaptool write %S/Inputs/implicit-module-header-maps/a.hmap.json %T/hmap
+//
+// RUN: mkdir -p %T/After
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.h %T/After/Mapping.h
+// RUN: cp %S/Inputs/implicit-module-header-maps/a.module.modulemap %T/module.modulemap
+//
+// RUN: %clang -Rmodule-build -fmodules -fimplicit-modules -fimplicit-module-maps -fmodule-map-file=%T/module.modulemap -fsyntax-only %s -I %T/hmap
+//
+// RUN: rm -rf %T
+// RUN: mkdir %T
+// RUN: cd %T
+//
+// RUN: sed -e "s:OUTPUTS_DIR:%T:g" %S/Inputs/implicit-module-header-maps/b.hmap.json > %T/hmap.json
+// RUN: %hmaptool write %T/hmap.json %T/hmap
+//
+// RUN: mkdir -p %T/After
+// RUN: cp %S/Inp

[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

I have the first measurements results in the attached zip file. The file 
contains the html file generated by csa-testbench. It's name contains `CTU` but 
actually it was a regular non-CTU analysis. The most interesting is probably 
the run-times, where we can notice a small increase:
F17327338: image.png 
Other than that, the number of the warnings seems to be unchanged. The most 
notable change in the statistics is in the number of paths explored by the 
analyzer: in some cases (e.g. twin) it increased with 2-3 %. F17327375: 
CTU_20results_20on_20open_20projects_201.zip 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[clang] c3cc14f - Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables ffp-contract=on"

2021-06-10 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-06-10T12:19:02-04:00
New Revision: c3cc14f87f78f8172b74175bbd2557cfb9384900

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

LOG: Revert "[clang][FPEnv] Clang floatng point model ffp-model=precise enables 
ffp-contract=on"

This reverts commit 8daac3714083aa5507622dba858344051f6b5574.
The build bots are showing some fails on broadwell and arm.
Fix to LNT test suite needs work.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 96512f7514b3e..244212a1336db 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,50 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
-  "fenv_access", "{off, on}", "(none)"
-  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
-  "contract", "{on, off, fast}", "ffp-contract"
-  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
-  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
-  "support_math_errno", "{on, off}", "fmath-errno"
-  "no_honor_nans", "{on, off}", "fhonor-nans"
-  "no_honor_infinities", "{on, off}", "fhonor-infinities"
-  "no_signed_zeros", "{on, off}", "fsigned-zeros"
-  "allow_reciprocal", "{on, off}", "freciprocal-math"
-  "allow_approximate_fns", "{on, off}", "(none)"
-  "allow_reassociation", "{on, off}", "fassociative-math"
-
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1498,7 +1456,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3163c26e44723..bcbb35f07d407 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2631,7 +2631,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 
   llvm::DenormalMode DenormalFPMath = DefaultDenormalFPMath;
   llvm::DenormalMode DenormalFP32Math = DefaultDenormalFP32Math;
-  StringRef FPContract = "on";
+  StringRef FPContract = "";
   bool StrictFPModel = false;
 
 
@@ -2656,7 +2656,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   ReciprocalMath = false;
   SignedZeros = true;
   // -

[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-10 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield accepted this revision.
mbenfield added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D103949

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


[PATCH] D104044: [clang-format] Fix the issue of no empty line after namespace

2021-06-10 Thread Darwin Xu via Phabricator via cfe-commits
darwin created this revision.
darwin added a project: clang-format.
darwin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This a bug fix of https://bugs.llvm.org/show_bug.cgi?id=50116

First revision only contains the change of the test code. I would like to have 
someone review the expected result. If it is OK. Then I can fix it.

Here is the output of the test case without fixing yet:

  darwin@Darwins-iMac build % 
/Volumes/silo/Projects/open-source/llvm-project/build/tools/clang/unittests/Format/./FormatTests
 --gtest_filter=FormatTest.RemovesEmptyLines
  Note: Google Test filter = FormatTest.RemovesEmptyLines
  [==] Running 1 test from 1 test suite.
  [--] Global test environment set-up.
  [--] 1 test from FormatTest
  [ RUN  ] FormatTest.RemovesEmptyLines
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:279:
 Failure
  Expected equality of these values:
"namespace N\n" "{\n" "\n" "int i;\n" "}"
  Which is: "namespace N\n{\n\nint i;\n}"
format("namespace N\n" "{\n" "\n" "\n" "inti;\n" "}", 
GoogleWrapBraceAfterNamespace)
  Which is: "namespace N\n{\nint i;\n}"
  With diff:
  @@ -1,5 @@
   namespace N
   {
  -
   int i;
   }
  
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:290:
 Failure
  Expected equality of these values:
"/* something */ namespace N\n" "{\n" "\n" "int i;\n" "}"
  Which is: "/* something */ namespace N\n{\n\nint i;\n}"
format("/* something */ namespace N {\n" "\n" "\n" "inti;\n" "}", 
GoogleWrapBraceAfterNamespace)
  Which is: "/* something */ namespace N\n{\nint i;\n}"
  With diff:
  @@ -1,5 @@
   /* something */ namespace N
   {
  -
   int i;
   }
  
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:302:
 Failure
  Expected equality of these values:
"inline namespace N\n" "{\n" "\n" "int i;\n" "}"
  Which is: "inline namespace N\n{\n\nint i;\n}"
format("inline namespace N\n" "{\n" "\n" "\n" "inti;\n" "}", 
GoogleWrapBraceAfterNamespace)
  Which is: "inline namespace N\n{\nint i;\n}"
  With diff:
  @@ -1,5 @@
   inline namespace N
   {
  -
   int i;
   }
  
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:313:
 Failure
  Expected equality of these values:
"/* something */ inline namespace N\n" "{\n" "\n" "int i;\n" "}"
  Which is: "/* something */ inline namespace N\n{\n\nint i;\n}"
format("/* something */ inline namespace N\n" "{\n" "\n" "inti;\n" "}", 
GoogleWrapBraceAfterNamespace)
  Which is: "/* something */ inline namespace N\n{\nint i;\n}"
  With diff:
  @@ -1,5 @@
   /* something */ inline namespace N
   {
  -
   int i;
   }
  
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:324:
 Failure
  Expected equality of these values:
"export namespace N\n" "{\n" "\n" "int i;\n" "}"
  Which is: "export namespace N\n{\n\nint i;\n}"
format("export namespace N\n" "{\n" "\n" "inti;\n" "}", 
GoogleWrapBraceAfterNamespace)
  Which is: "export namespace N\n{\nint i;\n}"
  With diff:
  @@ -1,5 @@
   export namespace N
   {
  -
   int i;
   }
  
  
/Volumes/silo/Projects/open-source/llvm-project/clang/unittests/Format/FormatTest.cpp:345:
 Failure
  Expected equality of these values:
"namespace a\n" "{\n" "namespace b\n" "{\n" "\n" "class AA {};\n" "\n" "}  
// namespace b\n" "}  // namespace a\n"
  Which is: "namespace a\n{\nnamespace b\n{\n\nclass AA {};\n\n}  // 
namespace b\n}  // namespace a\n"
format("namespace a\n" "{\n" "namespace b\n" "{\n" "\n" "\n" "class AA 
{};\n" "\n" "\n" "}\n" "}\n", GoogleWrapBraceAfterNamespace)
  Which is: "namespace a\n{\nnamespace b\n{\nclass AA {};\n\n}  // 
namespace b\n}  // namespace a\n"
  With diff:
  @@ -3,5 @@
   namespace b
   {
  -
   class AA {};
   
  
  [  FAILED  ] FormatTest.RemovesEmptyLines (41 ms)
  [--] 1 test from FormatTest (41 ms total)
  
  [--] Global test environment tear-down
  [==] 1 test from 1 test suite ran. (41 ms total)
  [  PASSED  ] 0 tests.
  [  FAILED  ] 1 test, listed below:
  [  FAILED  ] FormatTest.RemovesEmptyLines
  
   1 FAILED TEST
  darwin@Darwins-iMac build % 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104044

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -262,6 +262,88 @@
"}",
getGoogleStyle()));
 
+  auto GoogleWrapBraceAfterNamespace = getGoogleStyle();
+  GoogleWrapBraceAfterNamespace.BreakBeforeBraces = FormatStyle::BS_Custom;
+  GoogleWrapBraceAfterNamespace.BraceWrapping.AfterNamespace = true;
+  EXPECT_EQ("namespace N\n"

[PATCH] D104044: [clang-format] Fix the issue of no empty line after namespace

2021-06-10 Thread Darwin Xu via Phabricator via cfe-commits
darwin added a comment.

Sorry, I may need some help here. It shows "Context not available.", how do I 
correct it?


Repository:
  rZORG LLVM Github Zorg

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

https://reviews.llvm.org/D104044

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


[PATCH] D102850: [C++4OpenCL] Fix overloading resolution of addrspace constructors

2021-06-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks! Please, amend the comment as suggested in the final commit




Comment at: clang/lib/Sema/SemaOverload.cpp:9870
 
+  // Method overloading is handled above, so this only handles
+  // constructors with address spaces.

`Method` -> `General member function`


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

https://reviews.llvm.org/D102850

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


[PATCH] D104046: [analyzer] Simplify the process of producing notes for stores

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104046

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1214,136 +1214,144 @@
   return FrameSpace->getStackFrame() == LCtx->getStackFrame();
 }
 
+static bool isObjCPointer(const MemRegion *R) {
+  if (R->isBoundable())
+if (const auto *TR = dyn_cast(R))
+  return TR->getValueType()->isObjCObjectPointerType();
+
+  return false;
+}
+
+static bool isObjCPointer(const ValueDecl *D) {
+  return D->getType()->isObjCObjectPointerType();
+}
+
 /// Show diagnostics for initializing or declaring a region \p R with a bad value.
-static void showBRDiagnostics(const char *action, llvm::raw_svector_ostream &os,
-  const MemRegion *NewR, SVal V,
-  const MemRegion *OldR, const DeclStmt *DS) {
-  if (NewR->canPrintPretty()) {
-NewR->printPretty(os);
-os << " ";
-  }
-
-  if (V.getAs()) {
-bool b = false;
-if (NewR->isBoundable()) {
-  if (const auto *TR = dyn_cast(NewR)) {
-if (TR->getValueType()->isObjCObjectPointerType()) {
-  os << action << "nil";
-  b = true;
-}
-  }
-}
-if (!b)
-  os << action << "a null pointer value";
-
-  } else if (auto CVal = V.getAs()) {
-os << action << CVal->getValue();
-  } else if (OldR && OldR->canPrintPretty()) {
-os << action << "the value of ";
-OldR->printPretty(os);
-  } else if (DS) {
-if (V.isUndef()) {
-  if (isa(NewR)) {
+static void showBRDiagnostics(llvm::raw_svector_ostream &OS, StoreInfo SI) {
+  const bool HasPrefix = SI.Dest->canPrintPretty();
+
+  if (HasPrefix) {
+SI.Dest->printPretty(OS);
+OS << " ";
+  }
+
+  const char *Action = nullptr;
+
+  switch (SI.StoreKind) {
+  case StoreInfo::Initialization:
+Action = HasPrefix ? "initialized to " : "Initializing to ";
+break;
+  case StoreInfo::BlockCapture:
+Action = HasPrefix ? "captured by block as " : "Captured by block as ";
+break;
+  default:
+llvm_unreachable("Unexpected store kind");
+  }
+
+  if (SI.Value.getAs()) {
+OS << Action << (isObjCPointer(SI.Dest) ? "nil" : "a null pointer value");
+
+  } else if (auto CVal = SI.Value.getAs()) {
+OS << Action << CVal->getValue();
+
+  } else if (SI.Origin && SI.Origin->canPrintPretty()) {
+OS << Action << "the value of ";
+SI.Origin->printPretty(OS);
+
+  } else if (SI.StoreKind == StoreInfo::Initialization) {
+// We don't need to check here, all these conditions were
+// checked by StoreSiteFinder, when it figured out that it is
+// initialization.
+const auto *DS =
+cast(SI.StoreSite->getLocationAs()->getStmt());
+
+if (SI.Value.isUndef()) {
+  if (isa(SI.Dest)) {
 const auto *VD = cast(DS->getSingleDecl());
+
 if (VD->getInit()) {
-  os << (NewR->canPrintPretty() ? "initialized" : "Initializing")
+  OS << (HasPrefix ? "initialized" : "Initializing")
  << " to a garbage value";
 } else {
-  os << (NewR->canPrintPretty() ? "declared" : "Declaring")
+  OS << (HasPrefix ? "declared" : "Declaring")
  << " without an initial value";
 }
   }
 } else {
-  os << (NewR->canPrintPretty() ? "initialized" : "Initialized") << " here";
+  OS << (HasPrefix ? "initialized" : "Initialized") << " here";
 }
   }
 }
 
 /// Display diagnostics for passing bad region as a parameter.
-static void showBRParamDiagnostics(llvm::raw_svector_ostream &os,
-   const VarRegion *VR, SVal V,
-   const MemRegion *ValueR) {
+static void showBRParamDiagnostics(llvm::raw_svector_ostream &OS,
+   StoreInfo SI) {
+  const auto *VR = cast(SI.Dest);
   const auto *Param = cast(VR->getDecl());
 
-  os << "Passing ";
+  OS << "Passing ";
+
+  if (SI.Value.getAs()) {
+OS << (isObjCPointer(Param) ? "nil object reference"
+: "null pointer value");
+
+  } else if (SI.Value.isUndef()) {
+OS << "uninitialized value";
+
+  } else if (auto CI = SI.Value.getAs()) {
+OS << "the value " << CI->getValue();
+
+  } else if (SI.Origin && SI.Origin->canPrintPretty()) {
+SI.Origin->printPretty(

[PATCH] D103252: [C++4OpenCL] Fix missing address space on implicit move assignment operator

2021-06-10 Thread Abhinav Gaba via Phabricator via cfe-commits
abhinavgaba added inline comments.



Comment at: clang/test/AST/ast-dump-implicit-members.clcpp:10
+
+// CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
__generic noexcept'
+// CHECK: CXXConstructorDecl {{.*}} implicit constexpr S 'void (const 
__generic S &) __generic'

olestrohm wrote:
> abhinavgaba wrote:
> > Could you please relax these checks? The test fails with `-triple 
> > i386-pc-win32`  with errors like this:
> > ```
> > ast-dump-implicit-members.clcpp:10:11: error: CHECK: expected string not 
> > found in input
> > // CHECK: CXXConstructorDecl {{.*}} implicit used constexpr S 'void () 
> > __generic noexcept'
> >   ^
> > :1:1: note: scanning from here
> > Dumping __NSConstantString:
> > ^
> > :16:18: note: possible intended match here
> > |-CXXConstructorDecl 0x10b6c718  col:8 implicit used constexpr S 
> > 'void () __attribute__((thiscall)) __generic noexcept' inline default 
> > trivial
> >  ^
> > ```
> Hi, sorry for this.
> I have relaxed the tests in rGac677e69bdfc, so hopefully that should fix it.
Thanks for the fix, @olestrohm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103252

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


[PATCH] D99459: [OpenMP] Implement '#pragma omp unroll'.

2021-06-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur marked an inline comment as done.
Meinersbur added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2600-2604
+  RValue FactorRVal = EmitAnyExpr(FactorExpr, AggValueSlot::ignored(),
+  /*ignoreResult=*/true);
+  Factor =
+  cast(FactorRVal.getScalarVal())->getZExtValue();
+  assert(Factor >= 1 && "Only positive factors are valid");

ABataev wrote:
> ABataev wrote:
> > I suppose it is compiled-time expression, right? If so, use 
> > `FactorExpr->EvaluateKnownConstInt()` or something similar.
> Not done.
It was done in another branch that I forgot to merge. Sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99459

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


[PATCH] D95496: [clang][OpenMP] Augment ForStmt/CXXForRangeStmt for OpenMP canonical loops.

2021-06-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur abandoned this revision.
Meinersbur added a comment.

Obsolete since D94973  was committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95496

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


[PATCH] D103495: [static initializers] Emit global_ctors and global_dtors in reverse order when init_array is not used.

2021-06-10 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

If nobody has any more objections, I'll commit this change, then. Please let me 
know if you think otherwise.


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

https://reviews.llvm.org/D103495

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


[PATCH] D99459: [OpenMP] Implement '#pragma omp unroll'.

2021-06-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99459

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


  1   2   >