[PATCH] D124595: [HLSL] Add llvm intrinsic for HLSL.

2022-04-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 425697.
python3kgae added a comment.

Remove clang part change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124595

Files:
  clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
  llvm/include/llvm/IR/CMakeLists.txt
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsDirectX.td
  llvm/lib/IR/Function.cpp


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -36,6 +36,7 @@
 #include "llvm/IR/IntrinsicsAMDGPU.h"
 #include "llvm/IR/IntrinsicsARM.h"
 #include "llvm/IR/IntrinsicsBPF.h"
+#include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/IntrinsicsHexagon.h"
 #include "llvm/IR/IntrinsicsMips.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
Index: llvm/include/llvm/IR/IntrinsicsDirectX.td
===
--- /dev/null
+++ llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -0,0 +1,17 @@
+//===- IntrinsicsDirectX.td - Defines DirectX intrinsics ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines all of the DirectX-specific intrinsics.
+//
+//===--===//
+
+// Specialized loads from packet
+let TargetPrefix = "dx" in {  // All intrinsics start with "llvm.dx."
+  def int_dx_sin_f32 : GCCBuiltin<"__builtin_dx_sin_f32">,
+  Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
+}
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -2047,3 +2047,4 @@
 include "llvm/IR/IntrinsicsWebAssembly.td"
 include "llvm/IR/IntrinsicsRISCV.td"
 include "llvm/IR/IntrinsicsVE.td"
+include "llvm/IR/IntrinsicsDirectX.td"
Index: llvm/include/llvm/IR/CMakeLists.txt
===
--- llvm/include/llvm/IR/CMakeLists.txt
+++ llvm/include/llvm/IR/CMakeLists.txt
@@ -8,6 +8,7 @@
 tablegen(LLVM IntrinsicsAMDGPU.h -gen-intrinsic-enums -intrinsic-prefix=amdgcn)
 tablegen(LLVM IntrinsicsARM.h -gen-intrinsic-enums -intrinsic-prefix=arm)
 tablegen(LLVM IntrinsicsBPF.h -gen-intrinsic-enums -intrinsic-prefix=bpf)
+tablegen(LLVM IntrinsicsDirectX.h -gen-intrinsic-enums -intrinsic-prefix=dx)
 tablegen(LLVM IntrinsicsHexagon.h -gen-intrinsic-enums 
-intrinsic-prefix=hexagon)
 tablegen(LLVM IntrinsicsMips.h -gen-intrinsic-enums -intrinsic-prefix=mips)
 tablegen(LLVM IntrinsicsNVPTX.h -gen-intrinsic-enums -intrinsic-prefix=nvvm)
Index: clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.15-library -x hlsl -S 
-emit-llvm  -o - %s | FileCheck %s
+
+//CHECK:call float @llvm.dx.sin.f32
+
+float foo(float a) {
+  return __builtin_dx_sin_f32(a);
+}


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -36,6 +36,7 @@
 #include "llvm/IR/IntrinsicsAMDGPU.h"
 #include "llvm/IR/IntrinsicsARM.h"
 #include "llvm/IR/IntrinsicsBPF.h"
+#include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/IntrinsicsHexagon.h"
 #include "llvm/IR/IntrinsicsMips.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
Index: llvm/include/llvm/IR/IntrinsicsDirectX.td
===
--- /dev/null
+++ llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -0,0 +1,17 @@
+//===- IntrinsicsDirectX.td - Defines DirectX intrinsics ---*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines all of the DirectX-specific intrinsics.
+//
+//===--===//
+
+// Specialized loads from packet
+let TargetPrefix = "dx" in {  // All intrinsics start with "llvm.dx."
+  def int_dx_sin_f32 : GCCBuiltin<"__builtin_dx_sin_f32">,
+  Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
+}
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -2047,3 

[PATCH] D124509: [RISCV] Fix int16 -> __fp16 conversion code gen

2022-04-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm not opposed to this patch, but here's some additional info

I think this is failing because we hit this code in CGExprScalar.cpp. Where 
SrcTy and DstTy are both i16 when using the conversion intrinsics.

  // Ignore conversions like int -> uint.
  if (SrcTy == DstTy) {
llvm::dbgs() << "ctopper20\n";
if (Opts.EmitImplicitIntegerSignChangeChecks)
  EmitIntegerSignChangeCheck(Src, NoncanonicalSrcType, Src,
 NoncanonicalDstType, Loc);
  
return Src;
  }

Something like this seems to fix it.

  diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
  index d3fe04d5a791..62662bf860c2 100644
  --- a/clang/lib/CodeGen/CGExprScalar.cpp
  +++ b/clang/lib/CodeGen/CGExprScalar.cpp
  @@ -1339,7 +1339,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value 
*Src, QualType SrcType,
 }
   
 // Ignore conversions like int -> uint.
  -  if (SrcTy == DstTy) {
  +  if (SrcTy == DstTy && !DstType->isHalfType()) {
   if (Opts.EmitImplicitIntegerSignChangeChecks)
 EmitIntegerSignChangeCheck(Src, NoncanonicalSrcType, Src,
NoncanonicalDstType, Loc);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124509

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


[PATCH] D124595: [HLSL] Add llvm intrinsic for HLSL.

2022-04-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added reviewers: simoll, k-ishizaka, kaz7.
Herald added subscribers: Anastasia, dexonsmith, hiraditya, mgorny.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

A directx specific llvm intrinsic is introduced:

  float @llvm.dx.sin.f32(float)

It is for 
https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst#sin.
This change the llvm intrinsic and test it can be generated from clang codeGen.
The clang builtin change is in https://reviews.llvm.org/D124593


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124595

Files:
  clang/include/clang/Basic/BuiltinsDirectX.def
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/Basic/Targets/DirectX.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
  clang/test/SemaHLSL/Builtins/sin_f32.hlsl
  llvm/include/llvm/IR/CMakeLists.txt
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsDirectX.td
  llvm/lib/IR/Function.cpp

Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -36,6 +36,7 @@
 #include "llvm/IR/IntrinsicsAMDGPU.h"
 #include "llvm/IR/IntrinsicsARM.h"
 #include "llvm/IR/IntrinsicsBPF.h"
+#include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/IntrinsicsHexagon.h"
 #include "llvm/IR/IntrinsicsMips.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
Index: llvm/include/llvm/IR/IntrinsicsDirectX.td
===
--- /dev/null
+++ llvm/include/llvm/IR/IntrinsicsDirectX.td
@@ -0,0 +1,17 @@
+//===- IntrinsicsDirectX.td - Defines DirectX intrinsics ---*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines all of the DirectX-specific intrinsics.
+//
+//===--===//
+
+// Specialized loads from packet
+let TargetPrefix = "dx" in {  // All intrinsics start with "llvm.dx."
+  def int_dx_sin_f32 : GCCBuiltin<"__builtin_dx_sin_f32">,
+  Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
+}
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -2047,3 +2047,4 @@
 include "llvm/IR/IntrinsicsWebAssembly.td"
 include "llvm/IR/IntrinsicsRISCV.td"
 include "llvm/IR/IntrinsicsVE.td"
+include "llvm/IR/IntrinsicsDirectX.td"
Index: llvm/include/llvm/IR/CMakeLists.txt
===
--- llvm/include/llvm/IR/CMakeLists.txt
+++ llvm/include/llvm/IR/CMakeLists.txt
@@ -8,6 +8,7 @@
 tablegen(LLVM IntrinsicsAMDGPU.h -gen-intrinsic-enums -intrinsic-prefix=amdgcn)
 tablegen(LLVM IntrinsicsARM.h -gen-intrinsic-enums -intrinsic-prefix=arm)
 tablegen(LLVM IntrinsicsBPF.h -gen-intrinsic-enums -intrinsic-prefix=bpf)
+tablegen(LLVM IntrinsicsDirectX.h -gen-intrinsic-enums -intrinsic-prefix=dx)
 tablegen(LLVM IntrinsicsHexagon.h -gen-intrinsic-enums -intrinsic-prefix=hexagon)
 tablegen(LLVM IntrinsicsMips.h -gen-intrinsic-enums -intrinsic-prefix=mips)
 tablegen(LLVM IntrinsicsNVPTX.h -gen-intrinsic-enums -intrinsic-prefix=nvvm)
Index: clang/test/SemaHLSL/Builtins/sin_f32.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/Builtins/sin_f32.hlsl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.15-library -x hlsl -ast-dump -o - %s | FileCheck %s
+
+//CHECK: CallExpr 0x{{.+}}  'float'
+//CHECK-NEXT:ImplicitCastExpr 0x{{.+}}  'float (*)(float) throw()' 
+//CHECK-NEXT`-DeclRefExpr 0x{{.+}}  '' Function 0x26df56e3fc0 '__builtin_dx_sin_f32'
+
+float foo(float a) {
+  return __builtin_dx_sin_f32(a);
+}
Index: clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/Builtins/sin_f32.hlsl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.15-library -x hlsl -S -emit-llvm  -o - %s | FileCheck %s
+
+//CHECK:call float @llvm.dx.sin.f32
+
+float foo(float a) {
+  return __builtin_dx_sin_f32(a);
+}
Index: clang/lib/Basic/Targets/DirectX.h
===
--- clang/lib/Basic/Targets/DirectX.h
+++ clang/lib/Basic/Targets/DirectX.h
@@ -44,6 +44,9 @@
 };
 
 class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
+
+  static const Builtin::Info BuiltinInfo[];
+
 public:
   DirectXTargetInfo(const 

[PATCH] D124594: [LegacyPM] Remove DataFlowSanitizerLegacyPass

2022-04-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D124594#3479195 , @browneee wrote:

> I know this is currently used in at least one other place:
> https://github.com/tensorflow/tensorflow/blob/dde12a690476650573a0ef3f8f681271a2016224/tensorflow/compiler/xla/service/cpu/compiler_functor.cc#L111

Ah, I see. Seems that they need to migrate away.
The legacy passes for asan/msan/tsan have all been removed now...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124594

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


[PATCH] D124594: [LegacyPM] Remove DataFlowSanitizerLegacyPass

2022-04-27 Thread Andrew via Phabricator via cfe-commits
browneee added a comment.

I know this is currently used in at least one other place:
https://github.com/tensorflow/tensorflow/blob/dde12a690476650573a0ef3f8f681271a2016224/tensorflow/compiler/xla/service/cpu/compiler_functor.cc#L111


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124594

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


[PATCH] D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name

2022-04-27 Thread Wang Yihan via Phabricator via cfe-commits
yihanaa added a comment.

> While we'd usually be happy to take the fix-in-hand and apply it, part of the 
> discussion on the other thread is whether to remove `__builtin_dump_struct` 
> entirely. Because of that, I don't think we should make substantial changes 
> in this area until it's clear we're keeping the builtin.

Thanks for take a look, I agree to wait for the outcome of the discussion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122920

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


[PATCH] D124594: [LegacyPM] Remove DataFlowSanitizerLegacyPass

2022-04-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: Sanitizers, browneee, vitalybuka.
Herald added subscribers: StephenFan, hiraditya.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Using the legacy PM for the optimization pipeline was deprecated in 13.0.0.
Following recent changes to remove non-core features of the legacy
PM/optimization pipeline, remove ThreadSanitizerLegacyPass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124594

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.h
  llvm/bindings/go/llvm/transforms_instrumentation.go
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp

Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -99,7 +99,6 @@
   initializeInstrOrderFileLegacyPassPass(Registry);
   initializeInstrProfilingLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -3104,34 +3104,6 @@
   DFSF.PHIFixups.push_back({, ShadowPN, OriginPN});
 }
 
-namespace {
-class DataFlowSanitizerLegacyPass : public ModulePass {
-private:
-  std::vector ABIListFiles;
-
-public:
-  static char ID;
-
-  DataFlowSanitizerLegacyPass(
-  const std::vector  = std::vector())
-  : ModulePass(ID), ABIListFiles(ABIListFiles) {}
-
-  bool runOnModule(Module ) override {
-return DataFlowSanitizer(ABIListFiles).runImpl(M);
-  }
-};
-} // namespace
-
-char DataFlowSanitizerLegacyPass::ID;
-
-INITIALIZE_PASS(DataFlowSanitizerLegacyPass, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerLegacyPassPass(
-const std::vector ) {
-  return new DataFlowSanitizerLegacyPass(ABIListFiles);
-}
-
 PreservedAnalyses DataFlowSanitizerPass::run(Module ,
  ModuleAnalysisManager ) {
   if (DataFlowSanitizer(ABIListFiles).runImpl(M)) {
Index: llvm/include/llvm/Transforms/Instrumentation.h
===
--- llvm/include/llvm/Transforms/Instrumentation.h
+++ llvm/include/llvm/Transforms/Instrumentation.h
@@ -129,10 +129,6 @@
 
 ModulePass *createInstrOrderFilePass();
 
-// Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
-ModulePass *createDataFlowSanitizerLegacyPassPass(
-const std::vector  = std::vector());
-
 // Options for sanitizer coverage instrumentation.
 struct SanitizerCoverageOptions {
   enum Type {
Index: llvm/include/llvm/InitializePasses.h
===
--- llvm/include/llvm/InitializePasses.h
+++ llvm/include/llvm/InitializePasses.h
@@ -123,7 +123,6 @@
 void initializeDCELegacyPassPass(PassRegistry&);
 void initializeDFAJumpThreadingLegacyPassPass(PassRegistry &);
 void initializeDSELegacyPassPass(PassRegistry&);
-void initializeDataFlowSanitizerLegacyPassPass(PassRegistry &);
 void initializeDeadMachineInstructionElimPass(PassRegistry&);
 void initializeDebugifyMachineModulePass(PassRegistry &);
 void initializeDelinearizationPass(PassRegistry&);
Index: llvm/bindings/go/llvm/transforms_instrumentation.go
===
--- llvm/bindings/go/llvm/transforms_instrumentation.go
+++ /dev/null
@@ -1,29 +0,0 @@
-//===- transforms_instrumentation.go - Bindings for instrumentation ---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file defines bindings for the instrumentation component.
-//
-//===--===//
-
-package llvm
-
-/*
-#include "InstrumentationBindings.h"
-#include 
-*/
-import "C"
-import "unsafe"
-
-func (pm PassManager) 

[PATCH] D124593: [HLSL][clang] Add clang builtin for HLSL.

2022-04-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added reviewers: anakryiko, ast, yonghong-song.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A directx specific clang intrinsic is introduced:

  float __builtin_dx_sin_f32(float);

It is for 
https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst#sin.
This change only add clang builtin and test it can make into ast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124593

Files:
  clang/include/clang/Basic/BuiltinsDirectX.def
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/Basic/Targets/DirectX.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/test/SemaHLSL/Builtins/sin_f32.hlsl

Index: clang/test/SemaHLSL/Builtins/sin_f32.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/Builtins/sin_f32.hlsl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.15-library -x hlsl -ast-dump -o - %s | FileCheck %s
+
+//CHECK: CallExpr 0x{{.+}}  'float'
+//CHECK-NEXT:ImplicitCastExpr 0x{{.+}}  'float (*)(float) throw()' 
+//CHECK-NEXT`-DeclRefExpr 0x{{.+}}  '' Function 0x26df56e3fc0 '__builtin_dx_sin_f32'
+
+float foo(float a) {
+  return __builtin_dx_sin_f32(a);
+}
Index: clang/lib/Basic/Targets/DirectX.h
===
--- clang/lib/Basic/Targets/DirectX.h
+++ clang/lib/Basic/Targets/DirectX.h
@@ -44,6 +44,9 @@
 };
 
 class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
+
+  static const Builtin::Info BuiltinInfo[];
+
 public:
   DirectXTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(Triple) {
@@ -66,7 +69,7 @@
 return Feature == "directx";
   }
 
-  ArrayRef getTargetBuiltins() const override { return None; }
+  ArrayRef getTargetBuiltins() const override;
 
   const char *getClobbers() const override { return ""; }
 
Index: clang/lib/Basic/Targets/DirectX.cpp
===
--- clang/lib/Basic/Targets/DirectX.cpp
+++ clang/lib/Basic/Targets/DirectX.cpp
@@ -12,6 +12,8 @@
 
 #include "DirectX.h"
 #include "Targets.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetBuiltins.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -20,3 +22,16 @@
  MacroBuilder ) const {
   DefineStd(Builder, "DIRECTX", Opts);
 }
+
+const Builtin::Info DirectXTargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
+#include "clang/Basic/BuiltinsDirectX.def"
+};
+
+ArrayRef DirectXTargetInfo::getTargetBuiltins() const {
+  return llvm::makeArrayRef(BuiltinInfo, clang::DirectX::LastTSBuiltin -
+ Builtin::FirstTSBuiltin);
+}
Index: clang/include/clang/Basic/TargetBuiltins.h
===
--- clang/include/clang/Basic/TargetBuiltins.h
+++ clang/include/clang/Basic/TargetBuiltins.h
@@ -75,6 +75,16 @@
   };
   }
 
+  /// DirectX builtins
+  namespace DirectX {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsDirectX.def"
+LastTSBuiltin
+  };
+  } // namespace DirectX
+
   /// PPC builtins
   namespace PPC {
 enum {
Index: clang/include/clang/Basic/BuiltinsDirectX.def
===
--- /dev/null
+++ clang/include/clang/Basic/BuiltinsDirectX.def
@@ -0,0 +1,27 @@
+//===-- BuiltinsDirectX.def - DirectX Builtin function database -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the DirectX-specific builtin function database.  Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===--===//
+
+// The format of this database matches clang/Basic/Builtins.def.
+
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
+#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+BUILTIN(__builtin_dx_sin_f32, "ff", "ne")
+
+#undef BUILTIN
+#undef TARGET_BUILTIN

[PATCH] D124356: [Driver][Solaris] -r: imply -nostdlib like GCC

2022-04-27 Thread Brad Smith 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 rG3d7da810e4a6: [Driver][Solaris] -r: imply -nostdlib like GCC 
(authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124356

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -108,3 +108,13 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o \
+// RUN: --target=sparc-sun-solaris2.11 -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-L
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: {{.*}}values-{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -84,7 +84,8 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
@@ -124,7 +125,8 @@
   bool NeedsSanitizerDeps = addSanitizerRuntimes(getToolChain(), Args, 
CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (getToolChain().ShouldLinkCXXStdlib(Args))
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 if (Args.hasArg(options::OPT_fstack_protector) ||
@@ -161,11 +163,13 @@
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
   }
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -108,3 +108,13 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o \
+// RUN: --target=sparc-sun-solaris2.11 -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-L
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: {{.*}}values-{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -84,7 +84,8 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
@@ -124,7 +125,8 @@
   bool NeedsSanitizerDeps = addSanitizerRuntimes(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (getToolChain().ShouldLinkCXXStdlib(Args))
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 if (Args.hasArg(options::OPT_fstack_protector) ||
@@ -161,11 +163,13 @@
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 CmdArgs.push_back(
 

[clang] 3d7da81 - [Driver][Solaris] -r: imply -nostdlib like GCC

2022-04-27 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-04-28T00:19:45-04:00
New Revision: 3d7da810e4a6e1ade2c0d649f17f8aa820248765

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

LOG: [Driver][Solaris] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 2d40598bfc1c0..c75375ac95f7b 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -84,7 +84,8 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
@@ -124,7 +125,8 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
   bool NeedsSanitizerDeps = addSanitizerRuntimes(getToolChain(), Args, 
CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (getToolChain().ShouldLinkCXXStdlib(Args))
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 if (Args.hasArg(options::OPT_fstack_protector) ||
@@ -161,11 +163,13 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
 }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
   }
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index d40e5dac2da9e..57b2b1ba159b0 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -108,3 +108,13 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o \
+// RUN: --target=sparc-sun-solaris2.11 -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-L
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: {{.*}}values-{{[^.]+}}.o



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


[PATCH] D124556: [NFC] Prevent shadowing a variable declared in `if`

2022-04-27 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@ken-matsui, can you provide some rationale for the change (got compiler 
warning/error)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124556

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


[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-04-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

gentle ping. @pcc  could we please move this forward if the direction looks 
good to you? It has been sitting for a while...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

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


[PATCH] D124509: [RISCV] Fix int16 -> __fp16 conversion code gen

2022-04-27 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

It's seem like all targets need to return `false` in 
`useFP16ConversionIntrinsics` for correctness of `int16` -> `__fp16` conversion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124509

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


[PATCH] D124060: [PowerPC] Enable CR bits support for Power8 and above.

2022-04-27 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:519
 .Default(false);
+  Features["crbits"] = llvm::StringSwitch(CPU)
+.Case("ppc64le", true)

shchenz wrote:
> nemanjai wrote:
> > shchenz wrote:
> > > amyk wrote:
> > > > shchenz wrote:
> > > > > If we set the `+crbits` by the arch name, do we still need the 
> > > > > customization (Turn on crbits for O2 and above) in 
> > > > > `computeFSAdditions()`? 
> > > > Yeah, that's a good point. I looked into this previously, and it 
> > > > appears that addition of `-mcrbits` inside `computeFSAdditions()` may 
> > > > still be necessary. 
> > > > 
> > > > In particular, we have test cases that test pre-POWER8 with 
> > > > optimizations on (or, if no optimization level is provided, then -O2 is 
> > > > assumed the default). In these cases, much of the code changes if the 
> > > > customization inside `computeFSAdditions()` is removed because we would 
> > > > no longer be using crbits pre-P8.
> > > hmm, OK, then we still have the same issue that this patch fixes for 
> > > pre-POWER8. I'm ok with leaving it for now as IMO Power7/Power6 should 
> > > not be major versions for PowerPC.
> > Up until Power8, the only instructions we had that require `crbits` were 
> > CR-logicals (which existed since the POWER architecture - i.e. before 
> > PowerPC). In Power8, we added BCD instructions that also require `crbits`. 
> > So that's why we turn it on for Power8 and up.
> Fail enough.
haha, I mean fair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124060

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478978 , @aaronpuchert 
wrote:

> Git will apply the LF -> CRLF transformation when it checks out itself. Git 
> doesn't show the file as modified because after cleaning the file (i.e. 
> applying CRLF -> LF) it's the same as in the index.

One way to look at this is that the two filters //clean// (for checking in) and 
//smudge// (for checking out) are neither left nor right inverses of each other.

- The composition //clean// ∘ //smudge// not being the identity caused our 
original problem of files showing up modified with no way to fix it: no 
checked-out file could reproduce the checked-in file.
- The composition //smudge// ∘ //clean// not being the identity caused the 
intermittent issue after `arc patch`: the file didn't show up as modified, even 
though it wasn't what Git would produce on checkout.

The documentation says that //clean// should be 
 a projection 
:

> For best results, `clean` should not alter its output further if it is run 
> twice ("clean→clean" should be equivalent to "clean")

We should also have //clean// ∘ //smudge// ∘ //clean// = //clean//, and that's 
what `git add --renormalize` uses: by checking in cleaned files we're in the 
subset of files on which //clean// ∘ //smudge// is the identity. In fact in our 
case //clean// should even be the equalizer 
 of //smudge// ∘ 
//clean// and the identity on checked-in files, that is be able to produce 
every file that survives the round-trip.

In case you needed an advertisement for category theory 
.
 ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124434: [Clang][Test] Run tests in C++14 mode explicitly.

2022-04-27 Thread Jun Zhang via Phabricator via cfe-commits
junaire planned changes to this revision.
junaire added a comment.

> In general, my concern with the this patch is that it loses test coverage by 
> specifying an explicit language mode. We typically prefer to fix the tests so 
> that they can work in any language mode (and perhaps add additional RUN lines 
> in the process to do so).

OK, I'll do this. But I guess it is not sort of trivial work and will take 
plenty of time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124434

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present for all archs

2022-04-27 Thread Davide Italiano via Phabricator via cfe-commits
davide accepted this revision.
davide 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/D122258/new/

https://reviews.llvm.org/D122258

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present for all archs

2022-04-27 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

In D122258#3479045 , @int3 wrote:

> Thanks for the feedback!
>
>> The binary compatibility issue is non-existent on arm64, but it could be 
>> still a thing on x86_64.
>
> Can we enable `OmitDwarfIfHaveCompactUnwind` by default on arm64 then? And 
> have it be opt-in just for x86_64?

I think it's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present for all archs

2022-04-27 Thread Jez Ng via Phabricator via cfe-commits
int3 added a comment.

Thanks for the feedback!

> The binary compatibility issue is non-existent on arm64, but it could be 
> still a thing on x86_64.

Can we enable `OmitDwarfIfHaveCompactUnwind` by default on arm64 then? And have 
it be opt-in just for x86_64?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 425679.
LegalizeAdulthood added a comment.

Add file block comment


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

https://reviews.llvm.org/D124500

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp
  clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.h
  clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp
@@ -0,0 +1,207 @@
+//=== ModernizeModuleTest.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangTidyTest.h"
+#include "modernize/IntegralLiteralExpressionMatcher.h"
+#include "clang/Lex/Lexer.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+static std::vector tokenify(const char *Text) {
+  LangOptions LangOpts;
+  std::vector Includes;
+  LangOptions::setLangDefaults(LangOpts, Language::CXX, llvm::Triple(),
+   Includes, LangStandard::lang_cxx20);
+  Lexer Lex(SourceLocation{}, LangOpts, Text, Text, Text + std::strlen(Text));
+  std::vector Tokens;
+  bool End = false;
+  while (!End) {
+Token Tok;
+End = Lex.LexFromRawLexer(Tok);
+Tokens.push_back(Tok);
+  }
+
+  return Tokens;
+}
+
+static bool matchText(const char *Text) {
+  std::vector Tokens{tokenify(Text)};
+  modernize::IntegralLiteralExpressionMatcher Matcher(Tokens);
+
+  return Matcher.match();
+}
+
+namespace {
+
+struct Param {
+  bool Matched;
+  const char *Text;
+};
+
+class MatcherTest : public ::testing::TestWithParam {};
+
+} // namespace
+
+static const Param Params[] = {
+// valid integral literals
+{true, "1"},
+{true, "0177"},
+{true, "0xdeadbeef"},
+{true, "0b1011"},
+{true, "'c'"},
+// invalid literals
+{false, "1.23"},
+{false, "0x1p3"},
+{false, R"("string")"},
+
+// literals with unary operators
+{true, "-1"},
+{true, "+1"},
+{true, "~1"},
+{true, "!1"},
+// invalid unary operators
+{false, "1-"},
+{false, "1+"},
+{false, "1~"},
+{false, "1!"},
+
+// valid binary operators
+{true, "1+1"},
+{true, "1-1"},
+{true, "1*1"},
+{true, "1/1"},
+{true, "1%2"},
+{true, "1<<1"},
+{true, "1>>1"},
+{true, "1<=>1"},
+{true, "1<1"},
+{true, "1>1"},
+{true, "1<=1"},
+{true, "1>=1"},
+{true, "1==1"},
+{true, "1!=1"},
+{true, "1&1"},
+{true, "1^1"},
+{true, "1|1"},
+{true, "1&&1"},
+{true, "1||1"},
+// invalid binary operator
+{false, "1+"},
+{false, "1-"},
+{false, "1*"},
+{false, "1/"},
+{false, "1%"},
+{false, "1<<"},
+{false, "1>>"},
+{false, "1<=>"},
+{false, "1<"},
+{false, "1>"},
+{false, "1<="},
+{false, "1>="},
+{false, "1=="},
+{false, "1!="},
+{false, "1&"},
+{false, "1^"},
+{false, "1|"},
+{false, "1&&"},
+{false, "1||"},
+
+// valid ternary operator
+{true, "1?1:1"},
+// invalid ternary operator
+{false, "?"},
+{false, "?1"},
+{false, "?:"},
+{false, "?:1"},
+{false, "?1:"},
+{false, "?1:1"},
+{false, "1?"},
+{false, "1?1"},
+{false, "1?:"},
+{false, "1?1:"},
+{false, "1?:1"},
+
+// parenthesized expressions
+{true, "(1)"},
+{true, "((+1))"},
+{true, "((+(1)))"},
+{true, "(-1)"},
+{true, "-(1)"},
+{true, "(+1)"},
+{true, "((+1))"},
+{true, "+(1)"},
+{true, "(~1)"},
+{true, "~(1)"},
+{true, "(!1)"},
+{true, "!(1)"},
+{true, "(1+1)"},
+{true, "(1-1)"},
+{true, "(1*1)"},
+{true, "(1/1)"},
+{true, "(1%2)"},
+{true, "(1<<1)"},
+{true, "(1>>1)"},
+{true, "(1<=>1)"},
+{true, "(1<1)"},
+{true, "(1>1)"},
+{true, "(1<=1)"},
+{true, "(1>=1)"},
+{true, "(1==1)"},
+{true, "(1!=1)"},
+{true, "(1&1)"},
+{true, "(1^1)"},
+{true, "(1|1)"},
+{true, "(1&&1)"},
+{true, "(1||1)"},
+{true, "(1?1:1)"},
+
+// more complicated expressions
+{true, "1+1+1"},
+{true, "1+1+1+1"},
+{true, "1+1+1+1+1"},
+{true, "1*1*1"},
+{true, "1*1*1*1"},
+{true, "1*1*1*1*1"},
+{true, "1<<1<<1"},
+

[PATCH] D124487: [HLSL] Adjust access specifier behavior

2022-04-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 425678.
beanz added a comment.
Herald added a project: clang-tools-extra.

Updates based on PR feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124487

Files:
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/ParserHLSL/access_specifiers.hlsl

Index: clang/test/ParserHLSL/access_specifiers.hlsl
===
--- /dev/null
+++ clang/test/ParserHLSL/access_specifiers.hlsl
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -DSTRUCT -o - %s -verify
+
+#ifdef STRUCT
+#define KEYWORD struct
+#else
+#define KEYWORD class
+#endif
+
+KEYWORD Doggo {
+  int legs;// expected-note {{member is declared here}} expected-note {{member is declared here}}
+protected: // expected-warning {{access specifiers are a clang HLSL extension}}
+  int ears[2]; // expected-note {{declared protected here}}
+private:   // expected-warning {{access specifiers are a clang HLSL extension}}
+  int tail;// expected-note {{declared private here}} expected-note {{declared private here}}
+};
+
+KEYWORD Shiba : public Doggo { // expected-warning {{access specifiers are a clang HLSL extension}}
+  int undercoat;
+};
+
+KEYWORD Akita : Doggo {
+  int floof;
+};
+
+KEYWORD Chow : private Doggo {  // expected-warning {{access specifiers are a clang HLSL extension}} expected-note {{constrained by private inheritance here}}
+  int megafloof;
+};
+
+KEYWORD Dachshund : protected Doggo {  // expected-warning {{access specifiers are a clang HLSL extension}} expected-note {{constrained by protected inheritance here}}
+  int wiry;
+};
+
+void Puppers() {
+  Shiba Shibe;
+  Shibe.undercoat = 0x;
+  Shibe.legs = 4;
+
+  Shibe.tail = 1;// expected-error {{'tail' is a private member of 'Doggo'}}
+  Shibe.ears[0] = 1; // expected-error {{'ears' is a protected member of 'Doggo'}}
+
+  Akita Aki;
+  Aki.floof = 0x;
+  Aki.legs = 4;
+
+  Aki.tail = 1; // expected-error {{'tail' is a private member of 'Doggo'}}
+
+  Chow Ch;
+  Ch.megafloof = 0x;
+
+  Ch.legs = 4; // expected-error {{'legs' is a private member of 'Doggo'}}
+
+  Dachshund DH;
+  DH.legs = 4; // expected-error {{'legs' is a protected member of 'Doggo'}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2501,6 +2501,11 @@
  bool Virtual, AccessSpecifier Access,
  TypeSourceInfo *TInfo,
  SourceLocation EllipsisLoc) {
+  // In HLSL, unspecified class access is public rather than private.
+  if (getLangOpts().HLSL && Class->getTagKind() == TTK_Class &&
+  Access == AS_none)
+Access = AS_public;
+
   QualType BaseType = TInfo->getType();
   if (BaseType->containsErrors()) {
 // Already emitted a diagnostic when parsing the error type.
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2170,8 +2170,11 @@
 
   // Parse an (optional) access specifier.
   AccessSpecifier Access = getAccessSpecifierIfPresent();
-  if (Access != AS_none)
+  if (Access != AS_none) {
 ConsumeToken();
+if (getLangOpts().HLSL)
+  Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
+  }
 
   CheckMisplacedCXX11Attribute(Attributes, StartLoc);
 
@@ -3270,6 +3273,8 @@
 LLVM_FALLTHROUGH;
   case tok::kw_public:
   case tok::kw_protected: {
+if (getLangOpts().HLSL)
+  Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
 AccessSpecifier NewAS = getAccessSpecifierIfPresent();
 assert(NewAS != AS_none);
 // Current token is a C++ access specifier.
@@ -3509,8 +3514,9 @@
   // C++ 11p3: Members of a class defined with the keyword class are private
   // by default. Members of a class defined with the keywords struct or union
   // are public by default.
+  // HLSL: In HLSL members of a class are public by default.
   AccessSpecifier CurAS;
-  if (TagType == DeclSpec::TST_class)
+  if (TagType == DeclSpec::TST_class && !getLangOpts().HLSL)
 CurAS = AS_private;
   else
 CurAS = AS_public;
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td

[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478978 , @aaronpuchert 
wrote:

> In D124563#3478968 , @modimo wrote:
>
>> I used `arc patch` and also saw the same thing.
>
> The patch does actually change the files to LF endings. So just applying the 
> patch with non-Git tools will make LF endings, but Git will apply the LF -> 
> CRLF transformation when it checks out itself. Git doesn't show the file as 
> modified because after cleaning the file (i.e. applying CRLF -> LF) it's the 
> same as in the index.

To confirm in main:

  ~/llvm-project2# git ls-files --eol 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  i/lfw/crlf  attr/text eol=crlf  
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp

`i/lf` indicates in the index it's stored as LF but transformed to `w/crlf` 
CRLF in the working directory.

After running `arc patch` though:

  ~/llvm-project# llvm-arc patch D124563
  ~/llvm-project# git ls-files --eol 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  i/lfw/lfattr/text eol=crlf  
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp

So confirmed it was an `arc patch` diff application. EOL is... tricky.

> Sorry for all the noise, I was just annoyed about this empty `test` directory 
> and thought we just need to move that file... well, it was a bit of an 
> adventure. Thanks for helping out here.

It happens, properly fixing the original diff to make it actually do something 
was definitely the right choice. If anything Git should warn loudly that the 
index needs to be refreshed if `.gitattributes` is modified or added.

Happy to help, I learned quite a lot about git internals digging into this :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478968 , @modimo wrote:

> I used `arc patch` and also saw the same thing.

The patch does actually change the files to LF endings. So just applying the 
patch with non-Git tools will make LF endings, but Git will apply the LF -> 
CRLF transformation when it checks out itself. Git doesn't show the file as 
modified because after cleaning the file (i.e. applying CRLF -> LF) it's the 
same as in the index.

Sorry for all the noise, I was just annoyed about this empty `test` directory 
and thought we just need to move that file... well, it was a bit of an 
adventure. Thanks for helping out here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124060: [PowerPC] Enable CR bits support for Power8 and above.

2022-04-27 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:519
 .Default(false);
+  Features["crbits"] = llvm::StringSwitch(CPU)
+.Case("ppc64le", true)

nemanjai wrote:
> shchenz wrote:
> > amyk wrote:
> > > shchenz wrote:
> > > > If we set the `+crbits` by the arch name, do we still need the 
> > > > customization (Turn on crbits for O2 and above) in 
> > > > `computeFSAdditions()`? 
> > > Yeah, that's a good point. I looked into this previously, and it appears 
> > > that addition of `-mcrbits` inside `computeFSAdditions()` may still be 
> > > necessary. 
> > > 
> > > In particular, we have test cases that test pre-POWER8 with optimizations 
> > > on (or, if no optimization level is provided, then -O2 is assumed the 
> > > default). In these cases, much of the code changes if the customization 
> > > inside `computeFSAdditions()` is removed because we would no longer be 
> > > using crbits pre-P8.
> > hmm, OK, then we still have the same issue that this patch fixes for 
> > pre-POWER8. I'm ok with leaving it for now as IMO Power7/Power6 should not 
> > be major versions for PowerPC.
> Up until Power8, the only instructions we had that require `crbits` were 
> CR-logicals (which existed since the POWER architecture - i.e. before 
> PowerPC). In Power8, we added BCD instructions that also require `crbits`. So 
> that's why we turn it on for Power8 and up.
Fail enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124060

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478951 , @aaronpuchert 
wrote:

> In D124563#3478937 , @modimo wrote:
>
>> Checking locally I'm seeing LF as the line ending in crlf.cpp in the working 
>> directory. Can you double check that everything matches up?
>
> I had this too, but checking out again seems to have fixed it. Maybe you used 
> `arc patch` like I did? I presume that applies just textually and doesn't 
> know about `.gitattributes`.
>
> And sorry for landing already, there seems to have been a race...

Ah that would explain it, I used `arc patch` and also saw the same thing. It 
was fixed after I switched off `arcpatch-D124563` and back. Anyways it's all 
good on main which is what matters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-04-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/55132.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124589

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3336,6 +3336,14 @@
   verifyFormat("if (public == private)\n");
   verifyFormat("void foo(public, private)");
   verifyFormat("public::foo();");
+
+  verifyFormat("class A {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; }\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
+   "};");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2039,7 +2039,7 @@
   const FormatToken *Previous = FormatTok->Previous;
   if (Previous &&
   (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
- tok::kw_delete, tok::l_square) ||
+ tok::kw_delete, tok::l_square, tok::star) ||
FormatTok->isCppStructuredBinding(Style) || Previous->closesScope() ||
Previous->isSimpleTypeSpecifier())) {
 nextToken();


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3336,6 +3336,14 @@
   verifyFormat("if (public == private)\n");
   verifyFormat("void foo(public, private)");
   verifyFormat("public::foo();");
+
+  verifyFormat("class A {\n"
+   "public:\n"
+   "  std::unique_ptr b() { return nullptr; }\n"
+   "\n"
+   "private:\n"
+   "  int c;\n"
+   "};");
 }
 
 TEST_F(FormatTest, SeparatesLogicalBlocks) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2039,7 +2039,7 @@
   const FormatToken *Previous = FormatTok->Previous;
   if (Previous &&
   (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
- tok::kw_delete, tok::l_square) ||
+ tok::kw_delete, tok::l_square, tok::star) ||
FormatTok->isCppStructuredBinding(Style) || Previous->closesScope() ||
Previous->isSimpleTypeSpecifier())) {
 nextToken();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478937 , @modimo wrote:

> Checking locally I'm seeing LF as the line ending in crlf.cpp in the working 
> directory. Can you double check that everything matches up?

Ah it was some strange setup on my end. Confirmed patch and commit in main are 
good with CRLF. Apologies for the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478937 , @modimo wrote:

> Checking locally I'm seeing LF as the line ending in crlf.cpp in the working 
> directory. Can you double check that everything matches up?

I had this too, but checking out again seems to have fixed it. Maybe you used 
`arc patch` like I did? I presume that applies just textually and doesn't know 
about `.gitattributes`.

And sorry for landing already, there seems to have been a race...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[clang-tools-extra] c9a16e8 - Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2022-04-28T03:05:10+02:00
New Revision: c9a16e8c3d99173c7525e576d78eed57110d2b08

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

LOG: Drop '* text=auto' from .gitattributes and normalize

Git wants to check in 'text' files with LF endings, so this changes them
in the repository but not in the checkout, where they keep CRLF endings.

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

Added: 


Modified: 
clang-tools-extra/test/.gitattributes
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp

clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected

Removed: 




diff  --git a/clang-tools-extra/test/.gitattributes 
b/clang-tools-extra/test/.gitattributes
index 9d17a32c7b261..42567e3196d61 100644
--- a/clang-tools-extra/test/.gitattributes
+++ b/clang-tools-extra/test/.gitattributes
@@ -2,10 +2,6 @@
 # rely on or check fixed character -offset, Offset: or FileOffset: locations
 # will fail when run on input files checked out with 
diff erent line endings.
 
-# Most test input files should use native line endings, to ensure that we run
-# tests against both line ending types.
-* text=auto
-
 # These test input files rely on one-byte Unix (LF) line-endings, as they use
 # fixed -offset, FileOffset:, or Offset: numbers in their tests.
 clang-apply-replacements/ClangRenameClassReplacements.cpp text eol=lf

diff  --git 
a/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
index 26f79968f556d..09e50c292cc91 100644
--- a/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
+++ b/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = 0;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = 0;
+}

diff  --git 
a/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
index ad8e907856283..7a5e11354748d 100644
--- 
a/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
+++ 
b/clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = nullptr;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = nullptr;
+}



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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9a16e8c3d99: Drop * text=auto from 
.gitattributes and normalize (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

Files:
  clang-tools-extra/test/.gitattributes
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected


Index: 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
===
--- 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
+++ 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = nullptr;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = nullptr;
+}
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
===
--- clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = 0;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = 0;
+}
Index: clang-tools-extra/test/.gitattributes
===
--- clang-tools-extra/test/.gitattributes
+++ clang-tools-extra/test/.gitattributes
@@ -2,10 +2,6 @@
 # rely on or check fixed character -offset, Offset: or FileOffset: locations
 # will fail when run on input files checked out with different line endings.
 
-# Most test input files should use native line endings, to ensure that we run
-# tests against both line ending types.
-* text=auto
-
 # These test input files rely on one-byte Unix (LF) line-endings, as they use
 # fixed -offset, FileOffset:, or Offset: numbers in their tests.
 clang-apply-replacements/ClangRenameClassReplacements.cpp text eol=lf


Index: clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
===
--- clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = nullptr;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = nullptr;
+}
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
===
--- clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = 0;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = 0;
+}
Index: clang-tools-extra/test/.gitattributes
===
--- clang-tools-extra/test/.gitattributes
+++ clang-tools-extra/test/.gitattributes
@@ -2,10 +2,6 @@
 # rely on or check fixed character -offset, Offset: or FileOffset: locations
 # will fail when run on input files checked out with different line endings.
 
-# Most test input files should use native line endings, to ensure that we run
-# tests against both line ending types.
-* text=auto
-
 # These test input files rely on one-byte Unix (LF) line-endings, as they use
 # fixed -offset, FileOffset:, or Offset: numbers in their tests.
 clang-apply-replacements/ClangRenameClassReplacements.cpp text eol=lf
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo requested changes to this revision.
modimo added a comment.
This revision now requires changes to proceed.

Checking locally I'm seeing LF as the line ending in crlf.cpp in the working 
directory. Can you double check that everything matches up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert commandeered this revision.
aaronpuchert edited reviewers, added: modimo; removed: aaronpuchert.
aaronpuchert added a comment.

Ok, let's do it this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478915 , @aaronpuchert 
wrote:

> Drop `* text=auto`, so that we renormalize only the files that need it.

Makes sense to me, thanks for putting it up. If you want to commandeer I can 
accept the change or you can accept your own revision?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Would be nice if someone could accept this. I think this comes closest to the 
intention of D97625 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478781 , @aaronpuchert 
wrote:

> In D124563#3478653 , @modimo wrote:
>
>> I think the way to go is to revert ac5f7be6a868 
>>  then 
>> land everything as a single stack to prevent this issue.
>
> Doesn't change anything about existing commits though. There is no way to fix 
> that now I'm afraid. We can only fix it for future commits.

Yeah unfortunately. On Linux since it has the timestamp check landing this in 
one piece will be clean but on Windows the existing commits will continue to 
have this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478653 , @modimo wrote:

> I think the way to go is to revert ac5f7be6a868 
>  then 
> land everything as a single stack to prevent this issue.

Doesn't change anything about existing commits though. There is no way to fix 
that now I'm afraid. We can only fix it for future commits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D124563#3478627 , @smeenai wrote:

> If I check out this commit and then check out the previous commit, 
> `clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp` and 
> `clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected`
>  become modified in my working directory; their line endings are changed from 
> CRLF to LF. That seems undesirable.

In the current top-of-tree, the gitattributes line endings and the actual line 
endings contradict each other, leading to such inconsistencies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478747 , @aaronpuchert 
wrote:

> How about we remove `* text=auto` for now? Or would that break something?

The documentation  says that:

> If you want to ensure that text files that any contributor introduces to the 
> repository have their line endings normalized, you can set the `text` 
> attribute to "auto" for `all` files.
>
>   *   text=auto

And for now we don't actually want that. So I'd say remove that line and 
normalize the two remaining files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D124563#3478625 , @smeenai wrote:

> I *think* this would mean that if you're on Windows and have `core.autocrlf` 
> set to `input`, when you commit changes to this files, Git will convert them 
> back to LF line endings. Not 100% sure of that though.

Ok, that's a good point.

In D124563#3478642 , @modimo wrote:

> Good catch. Looking at git documentation 
> (https://git-scm.com/docs/gitattributes#_text) by virtue of applying `* 
> text=auto` the line endings will be stored internally as LF and then use the 
> system settings on checkout.

How about we remove `* text=auto` for now? Or would that break something?

Perhaps we can discuss `* text=auto` on the entire code base separately.

In D124563#3478726 , @Meinersbur 
wrote:

> Still don't know why Linux git doesn't do the same?

Linux checks the modified time stamp before looking at file contents. After 
`touch`ing the files I can also reproduce it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D124563#3478625 , @smeenai wrote:

> I *think* this would mean that if you're on Windows and have `core.autocrlf` 
> set to `input`, when you commit changes to this files, Git will convert them 
> back to LF line endings. Not 100% sure of that though.

As far as I recall this was done because there are many ways how the line 
endings can be accidentally changed (`core.autocrlf` being one of then, others 
are `clang-format` or text editors that do not retain line endings) and 
committed. Removing the files from `.gitignore` undo the intended line ending 
pin from D97625 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D122258: [MC] Omit DWARF unwind info if compact unwind is present for all archs

2022-04-27 Thread Davide Italiano via Phabricator via cfe-commits
davide requested changes to this revision.
davide added a comment.
This revision now requires changes to proceed.

Compact unwind was developed as a goal to replace the DWARF unwind. Some apps 
did not work if the OS was missing DWARF unwind, so we kept both for Intel. The 
binary compatibility issue is non-existent on arm64, but it could be still a 
thing on x86_64. 
If a function cannot be encoded in CU, we need the compiler to emit both (where 
the CU is a magic value that points to the dwarf unwind info for that function).

tl;dr: this is "a nice cleanup", and potentially the bincompat issue might be 
cone, but the cost of breaking programs in the wild is IMHO too high.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122258

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Regarding `crlf.cpp`(`.expected`), adding the modified changes to a commit 
indeed solved the problem I described in 
https://reviews.llvm.org/rGac5f7be6a8688955a282becf00eebc542238a86b#1080897 and 
I was working with that so far. Still don't know why Linux git doesn't do the 
same?

Don't know about the other files, but according to 
https://github.com/git/git/commit/af6e0fe3a589d58bfd508c1c6ccbeb38586eb06b, 
this seems the right thing to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478627 , @smeenai wrote:

> If I check out this commit and then check out the previous commit, 
> `clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp` and 
> `clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected`
>  become modified in my working directory; their line endings are changed from 
> CRLF to LF. That seems undesirable.

Good catch, I see it as well. The `.gitattributes` change needs to be atomic 
with the renormalization change. If I checkout from main after the 
`.gitattributes` change (`git checkout ac5f7be6a868`) I'll see the files as 
dirty. However, if I checkout the revision before (`git checkout 
ac5f7be6a868~1`) this goes away. I think the way to go is to revert 
ac5f7be6a868 
 then land 
everything as a single stack to prevent this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D124563#3478561 , @smeenai wrote:

> The following files have their line endings (when checked out on disk) 
> changed from CRLF to LF by this patch. Seems harmless, but I just wanted to 
> confirm that it was expected:
>
>   
> clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include.h
>   
> clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include2.h
>   
> clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
>   
> clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
>   clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
>   clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
>   clang-tools-extra/test/pp-trace/Inputs/module.map
>
> (The files which should be CRLF according to `.gitattributes` remained CRLF.)

Good catch. Looking at git documentation 
(https://git-scm.com/docs/gitattributes#_text) by virtue of applying `* 
text=auto` the line endings will be stored internally as LF and then use the 
system settings on checkout. Looking on my linux box I see LF endings but 
checking this out on Windows I see CRLF endings so this behavior is correct. 
This diff is displaying index changes which does move from CRLF->LF. I didn't 
see any test failures on Linux and these files will not have changed on Windows 
so this should be good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 425650.
dgoldman added a comment.

- Remove extraneous computeExprType declaration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -24,7 +24,7 @@
 int z;
   } t;
   // return statement
-  return t.b[[a]]r]](t.z)]];
+  return t.b[[a]]r]]([[t.z]])]];
 }
 void f() {
   int a = [[5 +]] [[4 * xyz]]();
@@ -59,11 +59,22 @@
   EXPECT_AVAILABLE(AvailableCases);
 
   ExtraArgs = {"-xc"};
-  const char *AvailableButC = R"cpp(
+  const char *AvailableC = R"cpp(
 void foo() {
   int x = [[1]];
 })cpp";
-  EXPECT_UNAVAILABLE(AvailableButC);
+  EXPECT_AVAILABLE(AvailableC);
+  ExtraArgs = {"-xobjective-c"};
+  const char *AvailableObjC = R"cpp(
+__attribute__((objc_root_class))
+@interface Foo
+@end
+@implementation Foo
+- (void)method {
+  int x = [[1 + 2]];
+}
+@end)cpp";
+  EXPECT_AVAILABLE(AvailableObjC);
   ExtraArgs = {};
 
   const char *NoCrashCases = R"cpp(
@@ -82,7 +93,7 @@
 int bar(int a = [[1]]);
 int z = [[1]];
   } t;
-  return [[t]].bar(t]].z]]);
+  return [[t]].bar([[t]].z);
 }
 void v() { return; }
 // function default argument
@@ -123,7 +134,7 @@
   EXPECT_UNAVAILABLE(UnavailableCases);
 
   // vector of pairs of input and output strings
-  const std::vector> InputOutputs = {
+  std::vector> InputOutputs = {
   // extraction from variable declaration/assignment
   {R"cpp(void varDecl() {
int a = 5 * (4 + (3 [[- 1)]]);
@@ -291,6 +302,92 @@
   for (const auto  : InputOutputs) {
 EXPECT_EQ(IO.second, apply(IO.first)) << IO.first;
   }
+
+  ExtraArgs = {"-xobjective-c"};
+  EXPECT_UNAVAILABLE(R"cpp(
+  __attribute__((objc_root_class))
+  @interface Foo
+  - (void)setMethod1:(int)a;
+  - (int)method1;
+  @property int prop1;
+  @end
+  @implementation Foo
+  - (void)method {
+[[self.method1]] = 1;
+[[self.method1]] += 1;
+[[self.prop1]] = 1;
+[[self.prop1]] += 1;
+  }
+  @end)cpp");
+  InputOutputs = {
+  // Function Pointer
+  {R"cpp(struct Handlers {
+   void (*handlerFunc)(int);
+ };
+ void runFunction(void (*func)(int)) {}
+ void f(struct Handlers *handler) {
+   runFunction([[handler->handlerFunc]]);
+ })cpp",
+   R"cpp(struct Handlers {
+   void (*handlerFunc)(int);
+ };
+ void runFunction(void (*func)(int)) {}
+ void f(struct Handlers *handler) {
+   void (*placeholder)(int) = handler->handlerFunc; runFunction(placeholder);
+ })cpp"},
+  // We don't preserve types through typedefs.
+  {R"cpp(typedef long NSInteger;
+ void varDecl() {
+NSInteger a = 2 * 5;
+NSInteger b = [[a * 7]] + 3;
+ })cpp",
+   R"cpp(typedef long NSInteger;
+ void varDecl() {
+NSInteger a = 2 * 5;
+long placeholder = a * 7; NSInteger b = placeholder + 3;
+ })cpp"},
+  // Support ObjC property references (explicit property getter).
+  {R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ @property int prop1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int x = [[self.prop1]] + 1;
+ }
+ @end)cpp",
+   R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ @property int prop1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int placeholder = self.prop1; int x = placeholder + 1;
+ }
+ @end)cpp"},
+  // Support ObjC property references (implicit property getter).
+  {R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ - (int)method1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int x = [[self.method1]] + 1;
+ }
+ @end)cpp",
+   R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ - (int)method1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int placeholder = self.method1; int x = placeholder + 1;
+ }
+ @end)cpp"},
+  };
+  for 

[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

If I check out this commit and then check out the previous commit, 
`clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp` and 
`clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected` 
become modified in my working directory; their line endings are changed from 
CRLF to LF. That seems undesirable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D124563#3478623 , @aaronpuchert 
wrote:

> So maybe we should simply remove
>
>   # These test input files rely on two-byte Windows (CRLF) line endings.
>   clang-apply-replacements/Inputs/crlf/crlf.cpp text eol=crlf
>   clang-apply-replacements/Inputs/crlf/crlf.cpp.expected text eol=crlf
>
> from the `.gitattributes` file again. Then we can keep them stored with CRLF 
> endings, and each file has a comment anyway that they rely on them. The files 
> have been there for many years and never been a problem.

I *think* this would mean that if you're on Windows and have `core.autocrlf` 
set to `input`, when you commit changes to this files, Git will convert them 
back to LF line endings. Not 100% sure of that though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Most of the files changed here are not affected by the `.gitattributes` file, 
such as

  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include2.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
  clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
  clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
  clang-tools-extra/test/pp-trace/Inputs/module.map

The only affected files seem to be

  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected

Looking back at D97625 , the main goal of that 
change was to ensure that tests relying on LF endings also work on Windows, and 
the two files that want CRLF did not in fact cause test failures.

So maybe we should simply remove

  # These test input files rely on two-byte Windows (CRLF) line endings.
  clang-apply-replacements/Inputs/crlf/crlf.cpp text eol=crlf
  clang-apply-replacements/Inputs/crlf/crlf.cpp.expected text eol=crlf

from the `.gitattributes` file again. Then we can keep them stored with CRLF 
endings, and each file has a comment anyway that they rely on them. The files 
have been there for many years and never been a problem.

Could you test if this works for you?

We can still discuss normalizing the other files, but maybe we can get some 
reviewers involved in `clang-tools-extra` for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:170
+  if (E->hasPlaceholderType(BuiltinType::PseudoObject)) {
+if (const auto *PR = dyn_cast(E)) {
+  if (PR->isMessagingSetter()) {

sammccall wrote:
> E->getObjCProperty()?
Hmm I'm not sure when that would be useful looking at the logic there, can you 
give an example just to make sure I understand what it would handle?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:176
+// it returns nil (setter method must have a void return type).
+return "";
+  } else if (PR->isMessagingGetter()) {

sammccall wrote:
> please don't use "" as a sentinel value, it will lead to bugs
> 
> Why are we checking this here rather than in eligibleForExtraction?
I put it in the ExtractionContext constructor since we would otherwise have to 
perform the same logic twice to compute the type string. I could make it into a 
function to be shared by both if you'd like? 



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:208
+  std::string ExtractedVarDecl =
+  Type + " " + VarName.str() + " = " + ExtractionCode.str() + "; ";
   return tooling::Replacement(SM, InsertionLoc, 0, ExtractedVarDecl);

sammccall wrote:
> Type + Varname isn't correct for types in general, particularly those that 
> use declarator syntax.
> printType with varname as the placeholder should do what you want.
> 
> Can you add a testcase where the variable has function pointer type?
I went ahead and added this but I couldn't think of a way to get a result like 
this without enabling this for MemberExprs, so I went ahead and re-enabled for 
them since I think it could be useful for them. LMK if I should revert that 
change. I guess if we don't want to support MemberExprs I should disable the 
ObjC property support since it probably makes to match the C++ equivalent?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-04-27 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 425644.
dgoldman marked 5 inline comments as done.
dgoldman added a comment.

- Don't use a method for computing the type
- Compute the type using printType
- Support MemberExprs and add a test for function pointers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -24,7 +24,7 @@
 int z;
   } t;
   // return statement
-  return t.b[[a]]r]](t.z)]];
+  return t.b[[a]]r]]([[t.z]])]];
 }
 void f() {
   int a = [[5 +]] [[4 * xyz]]();
@@ -59,11 +59,22 @@
   EXPECT_AVAILABLE(AvailableCases);
 
   ExtraArgs = {"-xc"};
-  const char *AvailableButC = R"cpp(
+  const char *AvailableC = R"cpp(
 void foo() {
   int x = [[1]];
 })cpp";
-  EXPECT_UNAVAILABLE(AvailableButC);
+  EXPECT_AVAILABLE(AvailableC);
+  ExtraArgs = {"-xobjective-c"};
+  const char *AvailableObjC = R"cpp(
+__attribute__((objc_root_class))
+@interface Foo
+@end
+@implementation Foo
+- (void)method {
+  int x = [[1 + 2]];
+}
+@end)cpp";
+  EXPECT_AVAILABLE(AvailableObjC);
   ExtraArgs = {};
 
   const char *NoCrashCases = R"cpp(
@@ -82,7 +93,7 @@
 int bar(int a = [[1]]);
 int z = [[1]];
   } t;
-  return [[t]].bar(t]].z]]);
+  return [[t]].bar([[t]].z);
 }
 void v() { return; }
 // function default argument
@@ -123,7 +134,7 @@
   EXPECT_UNAVAILABLE(UnavailableCases);
 
   // vector of pairs of input and output strings
-  const std::vector> InputOutputs = {
+  std::vector> InputOutputs = {
   // extraction from variable declaration/assignment
   {R"cpp(void varDecl() {
int a = 5 * (4 + (3 [[- 1)]]);
@@ -291,6 +302,92 @@
   for (const auto  : InputOutputs) {
 EXPECT_EQ(IO.second, apply(IO.first)) << IO.first;
   }
+
+  ExtraArgs = {"-xobjective-c"};
+  EXPECT_UNAVAILABLE(R"cpp(
+  __attribute__((objc_root_class))
+  @interface Foo
+  - (void)setMethod1:(int)a;
+  - (int)method1;
+  @property int prop1;
+  @end
+  @implementation Foo
+  - (void)method {
+[[self.method1]] = 1;
+[[self.method1]] += 1;
+[[self.prop1]] = 1;
+[[self.prop1]] += 1;
+  }
+  @end)cpp");
+  InputOutputs = {
+  // Function Pointer
+  {R"cpp(struct Handlers {
+   void (*handlerFunc)(int);
+ };
+ void runFunction(void (*func)(int)) {}
+ void f(struct Handlers *handler) {
+   runFunction([[handler->handlerFunc]]);
+ })cpp",
+   R"cpp(struct Handlers {
+   void (*handlerFunc)(int);
+ };
+ void runFunction(void (*func)(int)) {}
+ void f(struct Handlers *handler) {
+   void (*placeholder)(int) = handler->handlerFunc; runFunction(placeholder);
+ })cpp"},
+  // We don't preserve types through typedefs.
+  {R"cpp(typedef long NSInteger;
+ void varDecl() {
+NSInteger a = 2 * 5;
+NSInteger b = [[a * 7]] + 3;
+ })cpp",
+   R"cpp(typedef long NSInteger;
+ void varDecl() {
+NSInteger a = 2 * 5;
+long placeholder = a * 7; NSInteger b = placeholder + 3;
+ })cpp"},
+  // Support ObjC property references (explicit property getter).
+  {R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ @property int prop1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int x = [[self.prop1]] + 1;
+ }
+ @end)cpp",
+   R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ @property int prop1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int placeholder = self.prop1; int x = placeholder + 1;
+ }
+ @end)cpp"},
+  // Support ObjC property references (implicit property getter).
+  {R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ - (int)method1;
+ @end
+ @implementation Foo
+ - (void)method {
+   int x = [[self.method1]] + 1;
+ }
+ @end)cpp",
+   R"cpp(__attribute__((objc_root_class))
+ @interface Foo
+ - (int)method1;
+ @end
+ @implementation Foo
+ - (void)method 

[PATCH] D119296: KCFI sanitizer

2022-04-27 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen updated this revision to Diff 425642.
samitolvanen marked an inline comment as done.
samitolvanen added a comment.
Herald added subscribers: ormris, wenlei, steven_wu, mgorny.

- Added an LLVM pass to remove unneeded `llvm.kcfi.check` calls.
- Switched from zeros to 0xcc for x86 type identifier padding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ControlFlowIntegrity.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Sanitizers.def
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/test/CodeGen/kcfi.c
  clang/test/Driver/fsanitize.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/KCFI.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/KCFI.cpp
  llvm/test/CodeGen/AArch64/kcfi.ll
  llvm/test/CodeGen/X86/kcfi.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/KCFI/basic.ll
  llvm/test/Transforms/KCFI/no_uses.ll

Index: llvm/test/Transforms/KCFI/no_uses.ll
===
--- /dev/null
+++ llvm/test/Transforms/KCFI/no_uses.ll
@@ -0,0 +1,15 @@
+; RUN: opt -S -kcfi < %s | FileCheck %s
+; RUN: opt -S -passes=kcfi < %s | FileCheck %s
+
+declare void @f1() #0 prefix i32 10
+
+define void @g() {
+  ; CHECK-NOT: call void @llvm.kcfi.check(ptr @f1, i32 10)
+  call void @llvm.kcfi.check(ptr @f1, i32 10)
+  ret void
+}
+
+; CHECK-NOT: declare void @llvm.kcfi.check(ptr, i32 immarg)
+declare void @llvm.kcfi.check(ptr, i32 immarg)
+
+attributes #0 = { "kcfi" }
Index: llvm/test/Transforms/KCFI/basic.ll
===
--- /dev/null
+++ llvm/test/Transforms/KCFI/basic.ll
@@ -0,0 +1,36 @@
+; RUN: opt -S -kcfi < %s | FileCheck %s
+; RUN: opt -S -passes=kcfi < %s | FileCheck %s
+
+define void @f1() #0 prefix i32 10 {
+  ret void
+}
+
+declare void @f2() #0 prefix i32 11
+
+define internal void @f3() {
+  ret void
+}
+
+define void @g(ptr noundef %x) {
+  ; CHECK: call void @llvm.kcfi.check(ptr %x, i32 10)
+  call void @llvm.kcfi.check(ptr %x, i32 10)
+
+  ; CHECK-NOT: call void @llvm.kcfi.check(ptr @f1, i32 10)
+  ; CHECK: call void @llvm.kcfi.check(ptr @f1, i32 11)
+  call void @llvm.kcfi.check(ptr @f1, i32 10)
+  call void @llvm.kcfi.check(ptr @f1, i32 11)
+
+  ; CHECK: call void @llvm.kcfi.check(ptr @f2, i32 10)
+  ; CHECK-NOT: call void @llvm.kcfi.check(ptr @f2, i32 11)
+  call void @llvm.kcfi.check(ptr @f2, i32 10)
+  call void @llvm.kcfi.check(ptr @f2, i32 11)
+
+  ; CHECK: call void @llvm.kcfi.check(ptr @f3, i32 10)
+  call void @llvm.kcfi.check(ptr @f3, i32 10)
+  ret void
+}
+
+; CHECK: declare void @llvm.kcfi.check(ptr, i32 immarg)
+declare void @llvm.kcfi.check(ptr, i32 immarg)
+
+attributes #0 = { "kcfi" }
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -59,6 +59,7 @@
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: PromotePass
 ; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
+; CHECK-O-NEXT: Running pass: KCFIPass
 ; CHECK-O-NEXT: Running pass: InstCombinePass
 ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo
 ; These next two can appear in any order since they are accessed as parameters
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -49,6 +49,7 @@
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 

[PATCH] D124563: Renormalize line endings after ac5f7be6a8688955a282becf00eebc542238a86b

2022-04-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

The following files have their line endings (when checked out on disk) changed 
from CRLF to LF by this patch. Seems harmless, but I just wanted to confirm 
that it was expected:

  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include2.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
  clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
  clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
  clang-tools-extra/test/pp-trace/Inputs/module.map

(The files which should be CRLF according to `.gitattributes` remained CRLF.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124563

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


[PATCH] D124570: Revert "[analyzer][NFC] Refactor GenericTaintChecker to use CallDescriptionMap"

2022-04-27 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud created this revision.
t-rasmud added a reviewer: NoQ.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: All.
t-rasmud requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 6a7d75cf1183802f38d3fea417be0a4edaf03711 
 in order 
to get rid of the crash rdar://90041422


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124570

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -22,14 +22,15 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "llvm/Support/YAMLTraits.h"
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -37,651 +38,577 @@
 using namespace taint;
 
 namespace {
-
-class GenericTaintChecker;
-
-/// Check for CWE-134: Uncontrolled Format String.
-constexpr llvm::StringLiteral MsgUncontrolledFormatString =
-"Untrusted data is used as a format string "
-"(CWE-134: Uncontrolled Format String)";
-
-/// Check for:
-/// CERT/STR02-C. "Sanitize data passed to complex subsystems"
-/// CWE-78, "Failure to Sanitize Data into an OS Command"
-constexpr llvm::StringLiteral MsgSanitizeSystemArgs =
-"Untrusted data is passed to a system call "
-"(CERT/STR02-C. Sanitize data passed to complex subsystems)";
-
-/// Check if tainted data is used as a buffer size in strn.. functions,
-/// and allocators.
-constexpr llvm::StringLiteral MsgTaintedBufferSize =
-"Untrusted data is used to specify the buffer size "
-"(CERT/STR31-C. Guarantee that storage for strings has sufficient space "
-"for character data and the null terminator)";
-
-/// Check if tainted data is used as a custom sink's parameter.
-constexpr llvm::StringLiteral MsgCustomSink =
-"Untrusted data is passed to a user-defined sink";
-
-using ArgIdxTy = int;
-using ArgVecTy = llvm::SmallVector;
-
-/// Denotes the return value.
-constexpr ArgIdxTy ReturnValueIndex{-1};
-
-static ArgIdxTy fromArgumentCount(unsigned Count) {
-  assert(Count <=
- static_cast(std::numeric_limits::max()) &&
- "ArgIdxTy is not large enough to represent the number of arguments.");
-  return Count;
-}
-
-/// Check if the region the expression evaluates to is the standard input,
-/// and thus, is tainted.
-/// FIXME: Move this to Taint.cpp.
-bool isStdin(SVal Val, const ASTContext ) {
-  // FIXME: What if Val is NonParamVarRegion?
-
-  // The region should be symbolic, we do not know it's value.
-  const auto *SymReg = dyn_cast_or_null(Val.getAsRegion());
-  if (!SymReg)
-return false;
-
-  // Get it's symbol and find the declaration region it's pointing to.
-  const auto *Sm = dyn_cast(SymReg->getSymbol());
-  if (!Sm)
-return false;
-  const auto *DeclReg = dyn_cast(Sm->getRegion());
-  if (!DeclReg)
-return false;
-
-  // This region corresponds to a declaration, find out if it's a global/extern
-  // variable named stdin with the proper type.
-  if (const auto *D = dyn_cast_or_null(DeclReg->getDecl())) {
-D = D->getCanonicalDecl();
-// FIXME: This should look for an exact match.
-if (D->getName().contains("stdin") && D->isExternC()) {
-  const QualType FILETy = ACtx.getFILEType().getCanonicalType();
-  const QualType Ty = D->getType().getCanonicalType();
-
-  if (Ty->isPointerType())
-return Ty->getPointeeType() == FILETy;
-}
+class GenericTaintChecker : public Checker {
+public:
+  static void *getTag() {
+static int Tag;
+return 
   }
-  return false;
-}
-
-SVal getPointeeOf(const CheckerContext , Loc LValue) {
-  const QualType ArgTy = LValue.getType(C.getASTContext());
-  if (!ArgTy->isPointerType() || !ArgTy->getPointeeType()->isVoidType())
-return C.getState()->getSVal(LValue);
-
-  // Do not dereference void pointers. Treat them as byte pointers instead.
-  // FIXME: we might want to consider more than just the first byte.
-  return C.getState()->getSVal(LValue, C.getASTContext().CharTy);
-}
-
-/// Given a pointer/reference argument, return the value it refers to.
-Optional 

[PATCH] D119296: KCFI sanitizer

2022-04-27 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added a comment.

In D119296#3466217 , @joaomoreira 
wrote:

> Oh, one other tiny detail I forgot to mention. I noticed that the tag is 
> pushing the functions 6 bytes forward, regardless of any prepending padding 
> nops that were added to ensure 16b alignment. It would be cool to care about 
> the proper function alignment and also to not emit dummy padding nops when 
> the padding area can be filled with the tag itself.

Looking at `MCAsmStreamer::emitValueToAlignment`, using a non-power of two 
alignment seems problematic. I suppose we could emit additional nops before the 
type identifier to maintain expected alignment for the function entry, but that 
would end up bloating the binary even more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D123605: [WIP][Sema][SVE] Move/simplify Sema testing for SVE ACLE builtins

2022-04-27 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: clang/test/Sema/aarch64-sve2-intrinsics/acle_sve2_imm_n.cpp:25
+{
+  // expected-error-re@+1 3 {{argument value {{[0-9]+}} is outside the valid 
range [0, 7]}}
+  EXPAND_XZM_FUNC(SVE_ACLE_FUNC(svqshlu,_n_s8,,), pg, svundef_s8(), -1);

I've not seen this before, presumably it's short hand instead of needing to 
repeat multiple identical `expected-error` check lines?  If so, is it worth 
using this throughout the test files and essentially only require one 
`expected-error` per function or does this only work here because the 
`EXPAND...` macro emits its three function calls on the same line?


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

https://reviews.llvm.org/D123605

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


[PATCH] D121177: [modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

2022-04-27 Thread Volodymyr Sapsai 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 rGd32c685e1012: [modules] Merge equivalent extensions and 
diagnose ivar redeclarations for… (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121177

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/merge-extension-ivars.m
  clang/test/Modules/redecl-ivars.m

Index: clang/test/Modules/redecl-ivars.m
===
--- /dev/null
+++ clang/test/Modules/redecl-ivars.m
@@ -0,0 +1,166 @@
+// UNSUPPORTED: -zos, -aix
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// Same class extensions with the same ivars but from different modules aren't considered
+// an error and they are merged together. Test that differences in extensions and/or ivars
+// are still reported as errors.
+
+//--- include/Interfaces.h
+@interface NSObject @end
+@interface ObjCInterface : NSObject
+@end
+@interface ObjCInterfaceLevel2 : ObjCInterface
+@end
+
+@protocol Protocol1 @end
+@protocol Protocol2 @end
+
+//--- include/IvarsInExtensions.h
+#import 
+@interface ObjCInterface() {
+  int ivarName;
+}
+@end
+@interface ObjCInterfaceLevel2() {
+  int bitfieldIvarName: 3;
+}
+@end
+
+//--- include/IvarsInExtensionsWithMethodsProtocols.h
+#import 
+@interface ObjCInterface() {
+  int methodRelatedIvar;
+}
+- (void)test;
+@end
+@interface ObjCInterfaceLevel2()  {
+  int protocolRelatedIvar;
+}
+@end
+
+//--- include/IvarInImplementation.h
+#import 
+@implementation ObjCInterface {
+  int ivarName;
+}
+@end
+
+//--- include/module.modulemap
+module Interfaces {
+  header "Interfaces.h"
+  export *
+}
+module IvarsInExtensions {
+  header "IvarsInExtensions.h"
+  export *
+}
+module IvarsInExtensionsWithMethodsProtocols {
+  header "IvarsInExtensionsWithMethodsProtocols.h"
+  export *
+}
+module IvarInImplementation {
+  header "IvarInImplementation.h"
+  export *
+}
+
+
+//--- test-mismatch-in-extension.m
+// Different ivars with the same name aren't mergeable and constitute an error.
+#import 
+@interface ObjCInterface() {
+  float ivarName; // expected-note {{previous definition is here}}
+}
+@end
+@interface ObjCInterfaceLevel2() {
+  int bitfieldIvarName: 5; // expected-note {{previous definition is here}}
+}
+@end
+#import 
+// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
+// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
+@implementation ObjCInterfaceLevel2
+@end
+
+
+//--- test-mismatch-in-ivars-number.m
+// Extensions with different amount of ivars aren't considered to be the same.
+#import 
+@interface ObjCInterface() {
+  int ivarName; // expected-note {{previous definition is here}}
+  float anotherIvar;
+}
+@end
+#import 
+// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
+@implementation ObjCInterface
+@end
+
+
+//--- test-mismatch-in-methods-protocols.m
+// Extensions with different methods or protocols aren't considered to be the same.
+#import 

[clang] d32c685 - [modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

2022-04-27 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-04-27T15:52:59-07:00
New Revision: d32c685e1012785c0d2824214740f973d30e1daa

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

LOG: [modules] Merge equivalent extensions and diagnose ivar redeclarations for 
extensions loaded from different modules.

Emitting metadata for the same ivar multiple times can lead to
miscompilations. Objective-C runtime adds offsets to calculate ivar
position in memory and presence of duplicate offsets causes wrong final
position thus overwriting unrelated memory.

Such a situation is impossible with modules disabled as clang diagnoses
ivar redeclarations during sema checks after parsing
(`Sema::ActOnFields`). Fix the case with modules enabled by checking
during deserialization if ivar is already declared. We also support
a use case where the same category ends up in multiple modules. We
don't want to treat this case as ivar redeclaration and instead merge
corresponding ivars.

rdar://83468070

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

Added: 
clang/test/Modules/merge-extension-ivars.m
clang/test/Modules/redecl-ivars.m

Modified: 
clang/include/clang/AST/DeclObjC.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/DeclObjC.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index 110b7dc0c6f2..59a2cf5de234 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -1951,7 +1951,10 @@ class ObjCIvarDecl : public FieldDecl {
   /// in; this is either the interface where the ivar was declared, or the
   /// interface the ivar is conceptually a part of in the case of synthesized
   /// ivars.
-  const ObjCInterfaceDecl *getContainingInterface() const;
+  ObjCInterfaceDecl *getContainingInterface();
+  const ObjCInterfaceDecl *getContainingInterface() const {
+return const_cast(this)->getContainingInterface();
+  }
 
   ObjCIvarDecl *getNextIvar() { return NextIvar; }
   const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
@@ -2885,15 +2888,16 @@ 
ObjCInterfaceDecl::filtered_category_iterator::operator++() {
 }
 
 inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) {
-  return Cat->isUnconditionallyVisible();
+  return !Cat->isInvalidDecl() && Cat->isUnconditionallyVisible();
 }
 
 inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) {
-  return Cat->IsClassExtension() && Cat->isUnconditionallyVisible();
+  return !Cat->isInvalidDecl() && Cat->IsClassExtension() &&
+ Cat->isUnconditionallyVisible();
 }
 
 inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) {
-  return Cat->IsClassExtension();
+  return !Cat->isInvalidDecl() && Cat->IsClassExtension();
 }
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index d46a6c4500f4..8e8e40a5cd37 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1106,6 +1106,18 @@ class ASTReader
   /// been completed.
   std::deque PendingDeclContextInfos;
 
+  template 
+  using DuplicateObjCDecls = std::pair;
+
+  /// When resolving duplicate ivars from Objective-C extensions we don't error
+  /// out immediately but check if can merge identical extensions. Not checking
+  /// extensions for equality immediately because ivar deserialization isn't
+  /// over yet at that point.
+  llvm::SmallMapVector,
+   llvm::SmallVector, 4>,
+   2>
+  PendingObjCExtensionIvarRedeclarations;
+
   /// The set of NamedDecls that have been loaded, but are members of a
   /// context that has been merged into another context where the corresponding
   /// declaration is either missing or has not yet been loaded.

diff  --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index f15dd78929e2..15c545b59c81 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1647,6 +1647,11 @@ ObjCIvarDecl 
*ObjCInterfaceDecl::all_declared_ivar_begin() {
 
   ObjCIvarDecl *curIvar = nullptr;
   if (!data().IvarList) {
+// Force ivar deserialization upfront, before building IvarList.
+(void)ivar_empty();
+for (const auto *Ext : known_extensions()) {
+  (void)Ext->ivar_empty();
+}
 if (!ivar_empty()) {
   ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
   data().IvarList = *I; ++I;
@@ -1838,8 +1843,8 @@ ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext 
, unsigned ID) {
   ObjCIvarDecl::None, nullptr, false);
 }
 
-const 

[clang] 7d2dddc - [PS5] Enable dead-stripping globals in ASan

2022-04-27 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2022-04-27T15:44:42-07:00
New Revision: 7d2dddce8f0d3ed896f1437b01a097cb7fd1bfe9

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

LOG: [PS5] Enable dead-stripping globals in ASan

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index a8227f1f8285..b63c6e463706 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -857,13 +857,13 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
  AsanOutlineInstrumentation);
 
 // As a workaround for a bug in gold 2.26 and earlier, dead stripping of
-// globals in ASan is disabled by default on ELF targets.
+// globals in ASan is disabled by default on most ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
 AsanGlobalsDeadStripping = Args.hasFlag(
 options::OPT_fsanitize_address_globals_dead_stripping,
 options::OPT_fno_sanitize_address_globals_dead_stripping,
 !TC.getTriple().isOSBinFormatELF() || TC.getTriple().isOSFuchsia() ||
-TC.getTriple().isPS4());
+TC.getTriple().isPS());
 
 AsanUseOdrIndicator =
 Args.hasFlag(options::OPT_fsanitize_address_use_odr_indicator,

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index c6135f88541b..4b03bfc9dcb7 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -245,6 +245,7 @@
 // RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address -### -- %s 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-scei-ps4  -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-sie-ps5  -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
 // CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
 // CHECK-NO-ASAN-GLOBALS-NOT: 
-cc1{{.*}}-fsanitize-address-globals-dead-stripping
 



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


[PATCH] D124525: [OpenMP][ClangLinkerWrapper] Extending linker wrapper to embed metadata for multi-arch fat binaries

2022-04-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

need a test for the generated registration code




Comment at: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp:98-104
+  // struct __tgt_image_info {
+  //   int32_t version;
+  //   int32_t image_number;
+  //   int32_t number_images;
+  //   char* offload_arch;
+  //   char* target_compile_opts;
+  // };

I am wondering whether we should add a few more fields to make it more generic 
for all offloading languages and platforms:


```
char* target_triple;
char* offloading_kind; // openmp, hip, etc
char* file_type; // elf, spirv, bitcode, etc
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124525

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


[PATCH] D124489: Deprecate LLVM_BUILD_EXTERNAL_COMPILER_RT

2022-04-27 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

I spoke to a few other engineers in Apple. They are

1. Happy for us to proceed with marking `LLVM_BUILD_EXTERNAL_COMPILER_RT` as 
deprecated.
2. Okay with using `LLVM_BUILD_EXTERNAL_COMPILER_RT` being an error by default 
that can be downgraded to a warning using a CMake cache option.

@beanz If you can adapt the patch to make the warning into an error with a way 
to downgrade then I'll happily approve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124489

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


[PATCH] D124563: renormalize

2022-04-27 Thread Di Mo via Phabricator via cfe-commits
modimo created this revision.
Herald added subscribers: hoy, wenlei.
Herald added a project: All.
modimo 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/D124563

Files:
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include2.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
  clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
  clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
  clang-tools-extra/test/pp-trace/Inputs/module.map

Index: clang-tools-extra/test/pp-trace/Inputs/module.map
===
--- clang-tools-extra/test/pp-trace/Inputs/module.map
+++ clang-tools-extra/test/pp-trace/Inputs/module.map
@@ -1,18 +1,18 @@
-// module.map
-
-module Level1A {
-  header "Level1A.h"
-  export *
-}
-module Level1B {
-  header "Level1B.h"
-  export *
-  module Level2B {
-header "Level2B.h"
-export *
-  }
-}
-module Level2A {
-  header "Level2A.h"
-  export *
-}
+// module.map
+
+module Level1A {
+  header "Level1A.h"
+  export *
+}
+module Level1B {
+  header "Level1B.h"
+  export *
+  module Level2B {
+header "Level2B.h"
+export *
+  }
+}
+module Level2A {
+  header "Level2A.h"
+  export *
+}
Index: clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
===
--- clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
+++ clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
@@ -1,10 +1,10 @@
-// module.map
-
-module Level1A {
-  header "Level1A.h"
-  export *
-}
-module Missing {
-  header "Missing.h"
-  export *
-}
+// module.map
+
+module Level1A {
+  header "Level1A.h"
+  export *
+}
+module Missing {
+  header "Missing.h"
+  export *
+}
Index: clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
===
--- clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
+++ clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
@@ -1,10 +1,10 @@
-// module.map
-
-module Level1A {
-  header "Level1A.h"
-  export *
-}
-module HasError {
-  header "HasError.h"
-  export *
-}
+// module.map
+
+module Level1A {
+  header "Level1A.h"
+  export *
+}
+module HasError {
+  header "HasError.h"
+  export *
+}
Index: clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return-if-constexpr.cpp
@@ -1,22 +1,22 @@
-// RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++17
-
-// Constexpr if is an exception to the rule, we cannot remove the else.
-void f() {
-  if (sizeof(int) > 4)
-return;
-  else
-return;
-  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: do not use 'else' after 'return'
-
-  if constexpr (sizeof(int) > 4)
-return;
-  else
-return;
-
-  if constexpr (sizeof(int) > 4)
-return;
-  else if constexpr (sizeof(long) > 4)
-return;
-  else
-return;
-}
+// RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++17
+
+// Constexpr if is an exception to the rule, we cannot remove the else.
+void f() {
+  if (sizeof(int) > 4)
+return;
+  else
+return;
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: do not use 'else' after 'return'
+
+  if constexpr (sizeof(int) > 4)
+return;
+  else
+return;
+
+  if constexpr (sizeof(int) > 4)
+return;
+  else if constexpr (sizeof(long) > 4)
+return;
+  else
+return;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
===
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/system/sys/types.h
@@ -1 +1 @@
-// This file is intentionally empty.
+// This file is intentionally empty.
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-duplicate-include/readability-duplicate-include2.h
===
--- 

[PATCH] D123313: [OpenMP] Make clang argument handling for the new driver more generic

2022-04-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123313

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


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

As far as I know this is supposed to be a broadcast from lane 0 to every lane, 
so not sure why the control flow really matters


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

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


[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

2022-04-27 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM with a minor nit.




Comment at: clang/lib/Driver/Driver.cpp:4230
+  // compile action to embed it in. If preprocessing only ignore embedding.
+  if ((!isa(HostAction) && PL.back() != phases::Preprocess) 
||
+  HostOnly)

Nit: `(!isa(HostAction) && PL.back() != phases::Preprocess)` 
-> `!(isa(HostAction) || PL.back() == phases::Preprocess)`

It's a bit easier to understand that way, IMO. We could also return early if 
`HostOnly` is set and make this condition simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124220

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


[PATCH] D124558: [Tooling/DependencyScanning] Make skipping excluded PP ranges during dependency scanning the default

2022-04-27 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is to improve maintenance a bit and remove need to maintain the additional 
option and related code-paths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124558

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.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
@@ -191,14 +191,6 @@
 llvm::cl::desc("Reuse the file manager and its cache between invocations."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
-llvm::cl::opt SkipExcludedPPRanges(
-"skip-excluded-pp-ranges",
-llvm::cl::desc(
-"Use the preprocessor optimization that skips excluded conditionals by "
-"bumping the buffer pointer in the lexer instead of lexing the tokens  "
-"until reaching the end directive."),
-llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
-
 llvm::cl::opt ModuleName(
 "module-name", llvm::cl::Optional,
 llvm::cl::desc("the module of which the dependencies are to be computed"),
@@ -522,7 +514,7 @@
   SharedStream DependencyOS(llvm::outs());
 
   DependencyScanningService Service(ScanMode, Format, ReuseFileManager,
-SkipExcludedPPRanges, OptimizeArgs);
+OptimizeArgs);
   llvm::ThreadPool Pool(llvm::hardware_concurrency(NumThreads));
   std::vector> WorkerTools;
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I)
Index: clang/test/ClangScanDeps/regular_cdb.cpp
===
--- clang/test/ClangScanDeps/regular_cdb.cpp
+++ clang/test/ClangScanDeps/regular_cdb.cpp
@@ -20,11 +20,6 @@
 // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess | \
 // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
 
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources \
-// RUN:   -skip-excluded-pp-ranges=0 | FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
-// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-minimized-sources \
-// RUN:   -skip-excluded-pp-ranges=0 | FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
-//
 // Make sure we didn't produce any dependency files!
 // RUN: not cat %t.dir/regular_cdb.d
 // RUN: not cat %t.dir/regular_cdb_clangcl.d
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -288,9 +288,7 @@
   OverlayFS->pushOverlay(InMemoryFS);
   RealFS = OverlayFS;
 
-  if (Service.canSkipExcludedPPRanges())
-PPSkipMappings =
-std::make_unique();
+  PPSkipMappings = std::make_unique();
   if (Service.getMode() == ScanningMode::MinimizedSourcePreprocessing)
 DepFS = new DependencyScanningWorkerFilesystem(
 Service.getSharedCache(), RealFS, PPSkipMappings.get());
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
@@ -15,9 +15,9 @@
 
 DependencyScanningService::DependencyScanningService(
 ScanningMode Mode, ScanningOutputFormat Format, bool ReuseFileManager,
-bool SkipExcludedPPRanges, bool OptimizeArgs)
+bool OptimizeArgs)
 : Mode(Mode), Format(Format), ReuseFileManager(ReuseFileManager),
-  SkipExcludedPPRanges(SkipExcludedPPRanges), OptimizeArgs(OptimizeArgs) {
+  OptimizeArgs(OptimizeArgs) {
   // Initialize targets for object file support.
   llvm::InitializeAllTargets();
   llvm::InitializeAllTargetMCs();
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -48,7 +48,6 @@
 public:
   DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format,
 bool ReuseFileManager = true,
-bool SkipExcludedPPRanges = true,
  

[PATCH] D117112: [AArch64] Support for Ampere1 core

2022-04-27 Thread Philipp Tomsich via Phabricator via cfe-commits
philipp.tomsich updated this revision to Diff 425609.
philipp.tomsich added a comment.
Herald added a project: All.

Update to reflect review results.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117112

Files:
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64SchedAmpere1.td
  llvm/lib/Target/AArch64/AArch64SchedPredAmpere.td
  llvm/lib/Target/AArch64/AArch64SchedPredicates.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1192,6 +1192,16 @@
  AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
  AArch64::AEK_BF16 | AArch64::AEK_I8MM,
  "8.5-A"),
+ARMCPUTestParams("ampere1", "armv8.6-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_SIMD |
+ AArch64::AEK_FP16 | AArch64::AEK_RAS |
+ AArch64::AEK_LSE |
+ AArch64::AEK_DOTPROD | AArch64::AEK_RCPC |
+ AArch64::AEK_RDM | AArch64::AEK_MTE |
+ AArch64::AEK_SSBS | AArch64::AEK_SB |
+ AArch64::AEK_BF16 | AArch64::AEK_I8MM,
+ "8.6-A"),
 ARMCPUTestParams(
 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
 AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -12,6 +12,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s
===
--- llvm/test/MC/AArch64/armv8.3a-rcpc.s
+++ llvm/test/MC/AArch64/armv8.3a-rcpc.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-e1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=neoverse-n2 < %s 2>&1 | FileCheck %s
+// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mcpu=ampere1 < %s 2>&1 | FileCheck %s
 // RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.2a -mattr=+rcpc < %s 2>&1 | FileCheck %s
 // RUN: not llvm-mc -triple aarch64-none-linux-gnu -mattr=+v8.2a < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-REQ %s < %t
Index: llvm/test/MC/AArch64/armv8.2a-dotprod.s
===
--- llvm/test/MC/AArch64/armv8.2a-dotprod.s
+++ llvm/test/MC/AArch64/armv8.2a-dotprod.s
@@ -13,6 +13,7 @@
 // RUN: llvm-mc -triple aarch64 -mcpu=tsv110 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
 // RUN: llvm-mc -triple aarch64 -mcpu=cortex-r82 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
 // RUN: llvm-mc -triple aarch64 -mattr=+v8r -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
+// RUN: llvm-mc -triple aarch64 -mcpu=ampere1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
 
 // RUN: not llvm-mc -triple aarch64 -mattr=+v8.2a -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
@@ -36,6 +37,8 @@
 // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
 // RUN: not llvm-mc -triple aarch64 -mcpu=neoverse-n2 -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
+// RUN: not llvm-mc -triple aarch64 -mcpu=ampere1 -mattr=-dotprod -show-encoding < %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
 
 udot v0.2s, v1.8b, 

[PATCH] D124452: [clang-format] Adjust editor cursor position past #include blocks

2022-04-27 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
owenpan marked an inline comment as done.
Closed by commit rGdb57acff2647: [clang-format] Adjust editor cursor position 
past #include blocks (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124452

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -890,6 +890,21 @@
   EXPECT_EQ(10u, newCursor(Code, 43));
 }
 
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionWithRegrouping) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  std::string Code = "#include \"b\"\n"  // Start of line: 0
+ "\n"// Start of line: 13
+ "#include \"aa\"\n" // Start of line: 14
+ "int i;";   // Start of line: 28
+  std::string Expected = "#include \"aa\"\n" // Start of line: 0
+ "#include \"b\"\n"  // Start of line: 14
+ "int i;";   // Start of line: 27
+  EXPECT_EQ(Expected, sort(Code));
+  EXPECT_EQ(12u, newCursor(Code, 26)); // Closing quote of "aa"
+  EXPECT_EQ(26u, newCursor(Code, 27)); // Newline after "aa"
+  EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2638,10 +2638,10 @@
 StringRef Code, tooling::Replacements ,
 unsigned *Cursor) {
   tooling::IncludeCategoryManager Categories(Style.IncludeStyle, FileName);
-  unsigned IncludesBeginOffset = Includes.front().Offset;
-  unsigned IncludesEndOffset =
+  const unsigned IncludesBeginOffset = Includes.front().Offset;
+  const unsigned IncludesEndOffset =
   Includes.back().Offset + Includes.back().Text.size();
-  unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
+  const unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
   if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset))
 return;
   SmallVector Indices =
@@ -2685,7 +2685,7 @@
   // the entire block. Otherwise, no replacement is generated.
   // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is 
not
   // enough as additional newlines might be added or removed across #include
-  // blocks. This we handle below by generating the updated #imclude blocks and
+  // blocks. This we handle below by generating the updated #include blocks and
   // comparing it to the original.
   if (Indices.size() == Includes.size() && llvm::is_sorted(Indices) &&
   Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve)
@@ -2706,6 +2706,9 @@
 CurrentCategory = Includes[Index].Category;
   }
 
+  if (Cursor && *Cursor >= IncludesEndOffset)
+*Cursor += result.size() - IncludesBlockSize;
+
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -890,6 +890,21 @@
   EXPECT_EQ(10u, newCursor(Code, 43));
 }
 
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionWithRegrouping) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  std::string Code = "#include \"b\"\n"  // Start of line: 0
+ "\n"// Start of line: 13
+ "#include \"aa\"\n" // Start of line: 14
+ "int i;";   // Start of line: 28
+  std::string Expected = "#include \"aa\"\n" // Start of line: 0
+ "#include \"b\"\n"  // Start of line: 14
+ "int i;";   // Start of line: 27
+  EXPECT_EQ(Expected, sort(Code));
+  EXPECT_EQ(12u, newCursor(Code, 26)); // Closing quote of "aa"
+  EXPECT_EQ(26u, newCursor(Code, 27)); // Newline after "aa"
+  EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2638,10 +2638,10 @@
 StringRef 

[clang] db57acf - [clang-format] Adjust editor cursor position past #include blocks

2022-04-27 Thread via cfe-commits

Author: owenca
Date: 2022-04-27T14:26:23-07:00
New Revision: db57acff264796c6c43214e731dbfcf97ff5f6af

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

LOG: [clang-format] Adjust editor cursor position past #include blocks

Fixes #55027.

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9077330cb3b7c..b2c710174ecd9 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2638,10 +2638,10 @@ static void sortCppIncludes(const FormatStyle ,
 StringRef Code, tooling::Replacements ,
 unsigned *Cursor) {
   tooling::IncludeCategoryManager Categories(Style.IncludeStyle, FileName);
-  unsigned IncludesBeginOffset = Includes.front().Offset;
-  unsigned IncludesEndOffset =
+  const unsigned IncludesBeginOffset = Includes.front().Offset;
+  const unsigned IncludesEndOffset =
   Includes.back().Offset + Includes.back().Text.size();
-  unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
+  const unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
   if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset))
 return;
   SmallVector Indices =
@@ -2685,7 +2685,7 @@ static void sortCppIncludes(const FormatStyle ,
   // the entire block. Otherwise, no replacement is generated.
   // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is 
not
   // enough as additional newlines might be added or removed across #include
-  // blocks. This we handle below by generating the updated #imclude blocks and
+  // blocks. This we handle below by generating the updated #include blocks and
   // comparing it to the original.
   if (Indices.size() == Includes.size() && llvm::is_sorted(Indices) &&
   Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve)
@@ -2706,6 +2706,9 @@ static void sortCppIncludes(const FormatStyle ,
 CurrentCategory = Includes[Index].Category;
   }
 
+  if (Cursor && *Cursor >= IncludesEndOffset)
+*Cursor += result.size() - IncludesBlockSize;
+
   // If the #includes are out of order, we generate a single replacement fixing
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index a38e1a18325c2..54e43d0ba3fa4 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -890,6 +890,21 @@ TEST_F(SortIncludesTest, CalculatesCorrectCursorPosition) {
   EXPECT_EQ(10u, newCursor(Code, 43));
 }
 
+TEST_F(SortIncludesTest, CalculatesCorrectCursorPositionWithRegrouping) {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  std::string Code = "#include \"b\"\n"  // Start of line: 0
+ "\n"// Start of line: 13
+ "#include \"aa\"\n" // Start of line: 14
+ "int i;";   // Start of line: 28
+  std::string Expected = "#include \"aa\"\n" // Start of line: 0
+ "#include \"b\"\n"  // Start of line: 14
+ "int i;";   // Start of line: 27
+  EXPECT_EQ(Expected, sort(Code));
+  EXPECT_EQ(12u, newCursor(Code, 26)); // Closing quote of "aa"
+  EXPECT_EQ(26u, newCursor(Code, 27)); // Newline after "aa"
+  EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
+}
+
 TEST_F(SortIncludesTest, DeduplicateIncludes) {
   EXPECT_EQ("#include \n"
 "#include \n"



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


[PATCH] D124556: Prevent shadowing a variable declared in `if`

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui created this revision.
Herald added a project: All.
ken-matsui 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/D124556

Files:
  clang/lib/Basic/Diagnostic.cpp


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -983,13 +983,13 @@
   if (const char *S = tok::getPunctuatorSpelling(Kind))
 // Quoted token spelling for punctuators.
 Out << '\'' << S << '\'';
-  else if (const char *S = tok::getKeywordSpelling(Kind))
+  else if ((S = tok::getKeywordSpelling(Kind)))
 // Unquoted token spelling for keywords.
 Out << S;
-  else if (const char *S = getTokenDescForDiagnostic(Kind))
+  else if ((S = getTokenDescForDiagnostic(Kind)))
 // Unquoted translatable token name.
 Out << S;
-  else if (const char *S = tok::getTokenName(Kind))
+  else if ((S = tok::getTokenName(Kind)))
 // Debug name, shouldn't appear in user-facing diagnostics.
 Out << '<' << S << '>';
   else


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -983,13 +983,13 @@
   if (const char *S = tok::getPunctuatorSpelling(Kind))
 // Quoted token spelling for punctuators.
 Out << '\'' << S << '\'';
-  else if (const char *S = tok::getKeywordSpelling(Kind))
+  else if ((S = tok::getKeywordSpelling(Kind)))
 // Unquoted token spelling for keywords.
 Out << S;
-  else if (const char *S = getTokenDescForDiagnostic(Kind))
+  else if ((S = getTokenDescForDiagnostic(Kind)))
 // Unquoted translatable token name.
 Out << S;
-  else if (const char *S = tok::getTokenName(Kind))
+  else if ((S = tok::getTokenName(Kind)))
 // Debug name, shouldn't appear in user-facing diagnostics.
 Out << '<' << S << '>';
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124474: Honor COMPILER_RT_INCLUDE_TESTS when using LLVM_BUILD_EXTERNAL_COMPILER_RT=ON

2022-04-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I posted a PR to swift that migrates build-script to use 
`LLVM_ENABLE_RUNTIMES`: https://github.com/apple/swift/pull/58465

Obviously I can't test this against your internal infrastructure, but the 
change here is pretty trivial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124474

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


[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

Hi @aaron.ballman,

Thank you for your review! I updated the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui updated this revision to Diff 425601.
ken-matsui added a comment.

Add a diagnostic for line directive of a gnu extension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Misc/warning-flags.c
  clang/test/Preprocessor/line-directive.c


Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -27,8 +27,8 @@
 #define A 42 "foo"
 #line A
 
-# 42
-# 42 "foo"
+# 42 // expected-warning {{this style of line directive is a GNU extension}}
+# 42 "foo" // expected-warning {{this style of line directive is a GNU 
extension}}
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit
@@ -97,7 +97,7 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, 
not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number 
as decimal, not octal}}
+# 020  // expected-warning {{GNU line marker directive interprets number 
as decimal, not octal}} expected-warning {{this style of line directive is a 
GNU extension}}
 extern int array_gnuline[__LINE__ == 20 ? 1:-1];
 
 /* PR3917 */
@@ -106,7 +106,7 @@
 _\
 _LINE__ == 42 ? 1: -1];  /* line marker is location of first _ */
 
-# 51
+# 51 // expected-warning {{this style of line directive is a GNU extension}}
 extern char array2_gnuline[\
 _\
 _LINE__ == 52 ? 1: -1];  /* line marker is location of first _ */
@@ -115,7 +115,7 @@
 #line 0 "line-directive.c" // expected-warning {{#line directive with zero 
argument is a GNU extension}}
 undefined t; // expected-error {{unknown type name 'undefined'}}
 
-# 115 "main"
+# 115 "main" // expected-warning {{this style of line directive is a GNU 
extension}}
 # 116 "enter-1" 1
 # 117 "enter-2" 1
 # 118 "" 2 // pop to enter-1
Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -90,4 +90,4 @@
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 27
+CHECK: Number in -Wpedantic (not covered by other -W flags): 28
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1335,7 +1335,10 @@
   unsigned FlagVal;
   Token FlagTok;
   PP.Lex(FlagTok);
-  if (FlagTok.is(tok::eod)) return false;
+  if (FlagTok.is(tok::eod)) {
+PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive);
+return false;
+  }
   if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag, PP))
 return true;
 
@@ -1431,6 +1434,7 @@
   // If the StrTok is "eod", then it wasn't present.  Otherwise, it must be a
   // string followed by eod.
   if (StrTok.is(tok::eod)) {
+Diag(StrTok, diag::ext_pp_gnu_line_directive);
 // Treat this like "#line NN", which doesn't change file characteristics.
 FileKind = SourceMgr.getFileCharacteristic(DigitTok.getLocation());
   } else if (StrTok.isNot(tok::string_literal)) {
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -427,6 +427,9 @@
 def ext_pp_opencl_variadic_macros : Extension<
   "variadic macros are a Clang extension in OpenCL">;
 
+def ext_pp_gnu_line_directive : Extension<
+  "this style of line directive is a GNU extension">;
+
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;


Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -27,8 +27,8 @@
 #define A 42 "foo"
 #line A
 
-# 42
-# 42 "foo"
+# 42 // expected-warning {{this style of line directive is a GNU extension}}
+# 42 "foo" // expected-warning {{this style of line directive is a GNU extension}}
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit
@@ -97,7 +97,7 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number as decimal, not octal}}
+# 020  // expected-warning {{GNU line marker 

[clang] fd0e60d - [PS5] Test sanitizer options/lib names

2022-04-27 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2022-04-27T13:45:41-07:00
New Revision: fd0e60d7874363a641e35a862b05d8dfabab77ef

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

LOG: [PS5] Test sanitizer options/lib names

The functionality was added in 7726ad0, catching up on the tests now.

Added: 


Modified: 
clang/test/Driver/fsanitize.c
clang/test/Driver/sanitizer-ld.c

Removed: 




diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index f31e6156120fd..c6135f88541b6 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -783,6 +783,29 @@
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=address -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS4
 // CHECK-ASAN-NOLIB-PS4-NOT: SceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS5
+// Make sure there are no *.{o,bc} or -l passed before the ASan library.
+// CHECK-ASAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceAddressSanitizer_nosubmission_stub_weak}}
+// CHECK-ASAN-PS5: 
--dependent-lib=libSceAddressSanitizer_nosubmission_stub_weak.a
+// CHECK-ASAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceAddressSanitizer_nosubmission_stub_weak}}
+// CHECK-ASAN-PS5: -lSceAddressSanitizer_nosubmission_stub_weak
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nostdlib %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nodefaultlibs %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// CHECK-ASAN-NOLIB-PS5-NOT: SceAddressSanitizer_nosubmission_stub_weak
+
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-PS5
+// Make sure there are no *.{o,bc} or -l passed before the TSan library.
+// CHECK-TSAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceThreadSanitizer_nosubmission_stub_weak}}
+// CHECK-TSAN-PS5: 
--dependent-lib=libSceThreadSanitizer_nosubmission_stub_weak.a
+// CHECK-TSAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceThreadSanitizer_nosubmission_stub_weak}}
+// CHECK-TSAN-PS5: -lSceThreadSanitizer_nosubmission_stub_weak
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nostdlib %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nodefaultlibs %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// CHECK-TSAN-NOLIB-PS5-NOT: SceThreadSanitizer_nosubmission_stub_weak
+
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-MINIMAL
 // CHECK-ASAN-MINIMAL: error: invalid argument '-fsanitize-minimal-runtime' 
not allowed with '-fsanitize=address'
 

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 966edbd7d038b..def3ef967a46e 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -759,6 +759,14 @@
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
 
+// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-sie-ps5 -fuse-ld=ld \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS5 %s
+// CHECK-UBSAN-PS5: --dependent-lib=libSceUBSanitizer_nosubmission_stub_weak.a
+// CHECK-UBSAN-PS5: "{{.*}}ld{{(.gold)?(.exe)?}}"
+// CHECK-UBSAN-PS5: -lSceUBSanitizer_nosubmission_stub_weak
+
 // RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
@@ -767,6 +775,14 @@
 // CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-sie-ps5 -fuse-ld=ld \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS5 %s
+// CHECK-ASAN-PS5: 
--dependent-lib=libSceAddressSanitizer_nosubmission_stub_weak.a
+// CHECK-ASAN-PS5: "{{.*}}ld{{(.gold)?(.exe)?}}"
+// CHECK-ASAN-PS5: -lSceAddressSanitizer_nosubmission_stub_weak
+
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
@@ -777,6 +793,16 @@
 // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang 

[PATCH] D95063: AMDGPU: Use optimization remarks for register usage

2022-04-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm abandoned this revision.
arsenm added a comment.
Herald added subscribers: hsmhsm, foad.
Herald added a project: All.

Obsoleted by D123878 


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

https://reviews.llvm.org/D95063

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


[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 425595.
void added a comment.

Fix test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Randstruct.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-randomized-struct.c
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- clang/unittests/AST/RandstructTest.cpp
+++ clang/unittests/AST/RandstructTest.cpp
@@ -132,6 +132,12 @@
 namespace clang {
 namespace ast_matchers {
 
+long declCount(const RecordDecl *RD) {
+  return llvm::count_if(RD->decls(), [&](const Decl *D) {
+return isa(D) || isa(D);
+  });
+}
+
 #define RANDSTRUCT_TEST_SUITE_TEST RecordLayoutRandomizationTestSuiteTest
 
 TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
@@ -159,9 +165,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_FALSE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
@@ -177,9 +185,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedRandomize) {
@@ -195,9 +205,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MismatchedAttrsDeclVsDef) {
@@ -280,19 +292,27 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
   const field_names Actual = getFieldNamesFromRecord(RD);
   const field_names Subseq = {"x", "y", "z"};
 
   EXPECT_TRUE(RD->isRandomized());
   EXPECT_TRUE(isSubsequence(Actual, Subseq));
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
-TEST(RANDSTRUCT_TEST, CheckVariableLengthArrayMemberRemainsAtEndOfStructure) {
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure1) {
   std::unique_ptr AST = makeAST(R"c(
 struct test {
 int a;
-double b;
-short c;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
 char name[];
 } __attribute__((randomize_layout));
   )c");
@@ -300,8 +320,64 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
+  EXPECT_TRUE(RD->hasFlexibleArrayMember());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure2) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[0];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure3) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[1];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
 }
 
 TEST(RANDSTRUCT_TEST, RandstructDoesNotOverrideThePackedAttr) {
@@ -340,9 +416,11 @@
 

[PATCH] D124551: [Driver] Add f16 support to -mrecip parsing.

2022-04-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: spatel, efriedma, RKSimon.
Herald added a subscriber: StephenFan.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

This is a followup to D120158  which added an 
'h' suffix to the
backend handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124551

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/attr-mrecip.c
  clang/test/Driver/mrecip.c

Index: clang/test/Driver/mrecip.c
===
--- clang/test/Driver/mrecip.c
+++ clang/test/Driver/mrecip.c
@@ -37,6 +37,9 @@
 // RUN: %clang -### -S %s -mrecip=divf,sqrtd,vec-divd,vec-sqrtf  2>&1 | FileCheck --check-prefix=RECIP8 %s
 // RECIP8: "-mrecip=divf,sqrtd,vec-divd,vec-sqrtf"
 
+// RUN: %clang -### -S %s -mrecip=vec-sqrth  2>&1 | FileCheck --check-prefix=RECIP18 %s
+// RECIP18: "-mrecip=vec-sqrth"
+
  Check optional refinement step specifiers.
 
 // RUN: %clang -### -S %s -mrecip=all:1  2>&1 | FileCheck --check-prefix=RECIP9 %s
@@ -51,6 +54,9 @@
 // RUN: %clang -### -S %s -mrecip=divd:1,!sqrtf:2,vec-divf:9,vec-sqrtd:0  2>&1 | FileCheck --check-prefix=RECIP12 %s
 // RECIP12: "-mrecip=divd:1,!sqrtf:2,vec-divf:9,vec-sqrtd:0"
 
+// RUN: %clang -### -S %s -mrecip=sqrth:2  2>&1 | FileCheck --check-prefix=RECIP19 %s
+// RECIP19: "-mrecip=sqrth:2"
+
  Check invalid parameters.
 
 // RUN: %clang -### -S %s -mrecip=bogus  2>&1 | FileCheck --check-prefix=RECIP13 %s
@@ -68,3 +74,11 @@
 // RUN: %clang -### -S %s -mrecip=!vec-divd:  2>&1 | FileCheck --check-prefix=RECIP17 %s
 // RECIP17: error: invalid value 
 
+// RUN: %clang -### -S %s -mrecip=divh:1,divh  2>&1 | FileCheck --check-prefix=RECIP20 %s
+// RECIP20: error: invalid value 
+
+// RUN: %clang -### -S %s -mrecip=divh,div  2>&1 | FileCheck --check-prefix=RECIP21 %s
+// RECIP21: error: invalid value 
+
+// RUN: %clang -### -S %s -mrecip=sqrt,sqrth  2>&1 | FileCheck --check-prefix=RECIP22 %s
+// RECIP22: error: invalid value 
Index: clang/test/CodeGen/attr-mrecip.c
===
--- clang/test/CodeGen/attr-mrecip.c
+++ clang/test/CodeGen/attr-mrecip.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3,divh -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 // CHECK: baz{{.*}} #0
-// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3"
+// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3,divh"
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -226,12 +226,16 @@
   llvm::StringMap OptionStrings;
   OptionStrings.insert(std::make_pair("divd", false));
   OptionStrings.insert(std::make_pair("divf", false));
+  OptionStrings.insert(std::make_pair("divh", false));
   OptionStrings.insert(std::make_pair("vec-divd", false));
   OptionStrings.insert(std::make_pair("vec-divf", false));
+  OptionStrings.insert(std::make_pair("vec-divh", false));
   OptionStrings.insert(std::make_pair("sqrtd", false));
   OptionStrings.insert(std::make_pair("sqrtf", false));
+  OptionStrings.insert(std::make_pair("sqrth", false));
   OptionStrings.insert(std::make_pair("vec-sqrtd", false));
   OptionStrings.insert(std::make_pair("vec-sqrtf", false));
+  OptionStrings.insert(std::make_pair("vec-sqrth", false));
 
   for (unsigned i = 0; i != NumOptions; ++i) {
 StringRef Val = A->getValue(i);
@@ -255,10 +259,11 @@
 D.Diag(diag::err_drv_unknown_argument) << Val;
 return;
   }
-  // The option was specified without a float or double suffix.
-  // Make sure that the double entry was not already specified.
+  // The option was specified without a half or float or double suffix.
+  // Make sure that the double or half entry was not already specified.
   // The float entry will be checked below.
-  if (OptionStrings[ValBase.str() + 'd']) {
+  if (OptionStrings[ValBase.str() + 'd'] ||
+  OptionStrings[ValBase.str() + 'h']) {
 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Val;
 return;
   }
@@ -273,9 +278,12 @@
 // Mark the matched option as found. Do not allow duplicate specifiers.
 OptionIter->second = true;
 
-// If the precision was not specified, also mark the double entry as found.
-if (ValBase.back() != 'f' && ValBase.back() != 'd')
+// If the precision was not specified, also mark the double and half entry
+// as found.
+if (ValBase.back() != 'f' && ValBase.back() != 'd' && ValBase.back() != 'h') {
   OptionStrings[ValBase.str() + 'd'] = true;
+  OptionStrings[ValBase.str() + 'h'] = true;

[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: clang/lib/AST/Randstruct.cpp:201
+dyn_cast(RandomizedFields.back()->getType()))
+  if (CA->getSize().sle(2) || CA->isIncompleteArrayType())
+FlexibleArray = RandomizedFields.pop_back_val();

aaron.ballman wrote:
> CA->isIncompleteArrayType() looks to be at the wrong spot. An incomplete 
> array type is one of type `IncompleteArrayType`, which a `ConstantArrayType` 
> is not. Are we missing test coverage, or does the `hasFlexibleArrayMember()` 
> make it so that we just need to remove this check entirely?
It looks like if it's an `IncompleteArrayType`, then it will be captured by 
`hasFlexibleArrayMember`. I think we can do without the check here. (It doesn't 
hurt, because it should always return `false`.)



Comment at: clang/unittests/AST/RandstructTest.cpp:368
+int h;
+char name[0];
+} __attribute__((randomize_layout));

aaron.ballman wrote:
> Can you add a test where the last field is `char name[1];` and another one 
> for `char name[];` so that we have full coverage there?
The `name[]` is above this test. The `name[1]` is due to a copy-paste error 
(oops). Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

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


[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 425593.
void marked 2 inline comments as done.
void added a comment.

Add a few more tests and remove a dead check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Randstruct.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-randomized-struct.c
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- clang/unittests/AST/RandstructTest.cpp
+++ clang/unittests/AST/RandstructTest.cpp
@@ -132,6 +132,12 @@
 namespace clang {
 namespace ast_matchers {
 
+long declCount(const RecordDecl *RD) {
+  return llvm::count_if(RD->decls(), [&](const Decl *D) {
+return isa(D) || isa(D);
+  });
+}
+
 #define RANDSTRUCT_TEST_SUITE_TEST RecordLayoutRandomizationTestSuiteTest
 
 TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
@@ -159,9 +165,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_FALSE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
@@ -177,9 +185,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedRandomize) {
@@ -195,9 +205,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MismatchedAttrsDeclVsDef) {
@@ -280,19 +292,27 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
   const field_names Actual = getFieldNamesFromRecord(RD);
   const field_names Subseq = {"x", "y", "z"};
 
   EXPECT_TRUE(RD->isRandomized());
   EXPECT_TRUE(isSubsequence(Actual, Subseq));
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
-TEST(RANDSTRUCT_TEST, CheckVariableLengthArrayMemberRemainsAtEndOfStructure) {
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure1) {
   std::unique_ptr AST = makeAST(R"c(
 struct test {
 int a;
-double b;
-short c;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
 char name[];
 } __attribute__((randomize_layout));
   )c");
@@ -300,8 +320,64 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
+  EXPECT_TRUE(RD->hasFlexibleArrayMember());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure2) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[0];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure3) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[1];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
 }
 
 TEST(RANDSTRUCT_TEST, 

[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj planned changes to this revision.
upsj added a comment.

I wasn't aware of that, sounds perfect, thanks! Then I'll put this on hold 
until I figure out if it's really necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D124373#3477996 , @upsj wrote:

> This is part of my long-term goal to add support for forwarding parameters 
> and documentation for make_unique-like functions to clangd. To be fair, the 
> details are not entirely fleshed out - for inlay hints (displaying parameter 
> names inline), the entire function template is already available in an 
> instantiated form, so I can work with existing matchers. For signature help 
> (displaying which parameters are available, which one is active while 
> typing), IIRC you only have the template instantiation pattern available, so 
> I need to find the necessary parts of the AST myself.

Ah, thank you for the background information!

> My thought was to try and move towards this goal in small steps, but if this 
> is an important build time/size consideration, I can also see whether both of 
> them are actually necessary (I suspect isParameterPack might not be) before 
> moving forward?

We support locally defined matchers so that you can still use all the AST 
matching awesomeness, but without increasing the compile times for everyone for 
one-off matchers. e.g,., 
https://github.com/llvm/llvm-project/blob/c874dd53628db8170d4c5ba3878817abc385a695/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp#L23
  My recommendation is to do something similar for clangd, but once we find a 
second use for the matcher, we can go ahead and hoist it into ASTMatchers.h at 
that point. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[clang] 5e096ce - Update PGO and 3-stage cache files

2022-04-27 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-04-27T14:41:56-05:00
New Revision: 5e096ce6c84fe80a15158dd10d3a23fb7135aa6d

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

LOG: Update PGO and 3-stage cache files

These files are out of date and haven't been updated to work within the
monorepo. This change updates them appropriately so that they build
using the monorepo build infrastructure.

Added: 


Modified: 
clang/cmake/caches/3-stage-base.cmake
clang/cmake/caches/PGO-stage2.cmake
clang/cmake/caches/PGO.cmake

Removed: 




diff  --git a/clang/cmake/caches/3-stage-base.cmake 
b/clang/cmake/caches/3-stage-base.cmake
index 31391aa4defce..63a1c21528dc9 100644
--- a/clang/cmake/caches/3-stage-base.cmake
+++ b/clang/cmake/caches/3-stage-base.cmake
@@ -1,6 +1,8 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 if(APPLE)
   # Use LLD to have fewer requirements on system linker, unless we're on an 
apple

diff  --git a/clang/cmake/caches/PGO-stage2.cmake 
b/clang/cmake/caches/PGO-stage2.cmake
index 2080cd405f2a6..b9b2f62e9cae4 100644
--- a/clang/cmake/caches/PGO-stage2.cmake
+++ b/clang/cmake/caches/PGO-stage2.cmake
@@ -1,2 +1,3 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")

diff  --git a/clang/cmake/caches/PGO.cmake b/clang/cmake/caches/PGO.cmake
index 7e4a001129cb9..e1d0585e453f8 100644
--- a/clang/cmake/caches/PGO.cmake
+++ b/clang/cmake/caches/PGO.cmake
@@ -1,8 +1,10 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
 
-set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
 set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_TARGETS
   generate-profdata



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


[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

2022-04-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4215
Action *HostAction) const {
-  if (!isa(HostAction))
+  if (Args.hasArg(options::OPT_offload_host_only))
 return HostAction;

tra wrote:
> jhuber6 wrote:
> > tra wrote:
> > > This will not always be correct. E.g. `--offload-host-only 
> > > --offload-host-device` would be true here, but we would still want to 
> > > compile for both and device.
> > > 
> > > Is there a reason we can no longer rely on `HostAction`?
> > Guess I should just use the last argument. Host action is used below, can 
> > probably merge these if statements.
> I guess the general idea is to avoid the ambiguity about what controls the 
> behavior of the function. Is that the `Args`, or the `HostAction`?
> Ideally I'd prefer to parse command line options once, save results somewhere 
> we could use them and then use those flargs to control the behavior, 
> regardless of which options were used to specify it. E.g. 
> CUDA/HIPActionBuilder classes have these member fields:
> ```
>   bool CompileHostOnly = false;
>   bool CompileDeviceOnly = false;
> 
> ...
>   Arg *PartialCompilationArg = Args.getLastArg(
>   options::OPT_cuda_host_only, options::OPT_cuda_device_only,
>   options::OPT_cuda_compile_host_device);
>   CompileHostOnly = PartialCompilationArg &&
> PartialCompilationArg->getOption().matches(
> options::OPT_cuda_host_only);
>   CompileDeviceOnly = PartialCompilationArg &&
>   PartialCompilationArg->getOption().matches(
>   options::OPT_cuda_device_only);
> ...
> ```
> 
I more or less copied that below, but I suppose we are recalculating them each 
phase. We don't have a monolithic class with my new implementation, but I 
suppose I could add these to the Compilation or something if we don't want to 
recalculate it. Beside that, does anything else seem amiss?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124220

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added a comment.

This is part of my long-term goal to add support for forwarding parameters and 
documentation for make_unique-like functions to clangd. To be fair, the details 
are not entirely fleshed out - for inlay hints (displaying parameter names 
inline), the entire function template is already available in an instantiated 
form, so I can work with existing matchers. For signature help (displaying 
which parameters are available, which one is active while typing), IIRC you 
only have the template instantiation pattern available, so I need to find the 
necessary parts of the AST myself.

My thought was to try and move towards this goal in small steps, but if this is 
an important build time/size consideration, I can also see whether both of them 
are actually necessary (I suspect isParameterPack might not be) before moving 
forward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124221: Add new builtin __builtin_reflect_struct.

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:420
+auto *FD = IFD ? IFD->getAnonField() : dyn_cast(D);
+if (!FD || (FD->isUnnamedBitfield() || FD->isAnonymousStructOrUnion()))
+  continue;

rsmith wrote:
> yihanaa wrote:
> > erichkeane wrote:
> > > rsmith wrote:
> > > > erichkeane wrote:
> > > > > rsmith wrote:
> > > > > > erichkeane wrote:
> > > > > > > rsmith wrote:
> > > > > > > > erichkeane wrote:
> > > > > > > > > Losing the unnamed bitfield is unfortunate, and I the 'dump 
> > > > > > > > > struct' handles.  As is losing the anonymous struct/union.
> > > > > > > > > 
> > > > > > > > > Also, how does this handle 'record type' members?  Does the 
> > > > > > > > > user have to know the inner type already?  If they already 
> > > > > > > > > know that much information about the type, they wouldn't 
> > > > > > > > > really need this, right?
> > > > > > > > If `__builtin_dump_struct` includes unnamed bitfields, that's a 
> > > > > > > > bug in that builtin.
> > > > > > > > 
> > > > > > > > In general, the user function gets given the bases and members 
> > > > > > > > with the right types, so they can use an overload set or a 
> > > > > > > > template to dispatch based on that type. See the SemaCXX test 
> > > > > > > > for a basic example of that.
> > > > > > > I thought it did?  For the use case I see `__builtin_dump_struct` 
> > > > > > > having, I would think printing the existence of unnamed bitfields 
> > > > > > > to be quite useful.
> > > > > > > 
> > > > > > > 
> > > > > > Why? They're not part of the value, they're just padding.
> > > > > They are lexically part of the type and are part of what makes up the 
> > > > > 'size' of the thing. I would expect something dumping the type to be 
> > > > > as consistent lexically as possible.
> > > > Looks like `__builtin_dump_struct` currently includes them *and* prints 
> > > > a value (whatever garbage happens to be in those padding bits). That's 
> > > > obviously a bug.
> > > O.o! Yeah, printing the value is nonsense.
> > I think the user should be informed somehow that there is an unnamed 
> > bitfield here
> It seems to me that `__builtin_dump_struct` is displaying the value of a 
> struct object, not the representation of the object, and unnamed bitfields 
> are not a part of the value, so should not be included. And I think it makes 
> sense for that builtin to be value-oriented: someone using it presumably 
> already knows whatever they want to know about the representation, to the 
> extent that it matters, or can look it up; what they don't know is the 
> information that varies from one instance to another. If we want a builtin 
> that's more oriented around showing the struct's memory representation, I 
> think we'd want quite a different output format, including offsets for fields 
> -- and even then I don't think it makes sense to include unnamed bit-fields 
> because they're not different from any other kind of padding in the object. 
> If we still want to print unnamed bit-fields for some reason, presumably we 
> should also print alignment and packing attributes and pragmas, because they 
> too can change the padding within a struct.
I tend to agree that `__builtin_dump_struct` should be focused on the values in 
the structure and not the representation.

However, keeping in mind that the original builtin was for kernel folks and the 
kernel tends to do some pretty interesting things (that aren't always supported 
by the standard), there's a part of me that wonders if they have a use case for 
unnamed bit-fields where they expect data to be squirreled away in those bits 
(through `memcpy()` or some other means) that they'd like to be able to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124221

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


[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

2022-04-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2527
   HelpText<"Use the static host OpenMP runtime while linking.">;
+def offload_device_only : Flag<["-"], "offload-device-only">,
+  HelpText<"Only compile for the offloading device.">;

jhuber6 wrote:
> tra wrote:
> > We should be using "--" for the new options.
> What's the reason for preferring `--` over `-`? Is it just because `-o` can 
> bind to output?
Convention, I guess. Legacy (e.g. `-nostdlib` )  and single-letter options 
(e.g. `-o` `-m`, `-f` ) use single dash. Long options typically use double-dash.



Comment at: clang/lib/Driver/Driver.cpp:4215
Action *HostAction) const {
-  if (!isa(HostAction))
+  if (Args.hasArg(options::OPT_offload_host_only))
 return HostAction;

jhuber6 wrote:
> tra wrote:
> > This will not always be correct. E.g. `--offload-host-only 
> > --offload-host-device` would be true here, but we would still want to 
> > compile for both and device.
> > 
> > Is there a reason we can no longer rely on `HostAction`?
> Guess I should just use the last argument. Host action is used below, can 
> probably merge these if statements.
I guess the general idea is to avoid the ambiguity about what controls the 
behavior of the function. Is that the `Args`, or the `HostAction`?
Ideally I'd prefer to parse command line options once, save results somewhere 
we could use them and then use those flargs to control the behavior, regardless 
of which options were used to specify it. E.g. CUDA/HIPActionBuilder classes 
have these member fields:
```
  bool CompileHostOnly = false;
  bool CompileDeviceOnly = false;

...
  Arg *PartialCompilationArg = Args.getLastArg(
  options::OPT_cuda_host_only, options::OPT_cuda_device_only,
  options::OPT_cuda_compile_host_device);
  CompileHostOnly = PartialCompilationArg &&
PartialCompilationArg->getOption().matches(
options::OPT_cuda_host_only);
  CompileDeviceOnly = PartialCompilationArg &&
  PartialCompilationArg->getOption().matches(
  options::OPT_cuda_device_only);
...
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124220

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


[PATCH] D114115: [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Lit is aware of zlib's presence or absence, you could use `REQUIRES: zlib` (or 
you might factor that bit out into its own test with the REQUIRES).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114115

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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:681
+ ArgStringList ) const {
+  CmdArgs.push_back(
+  Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));

tra wrote:
> Nit: `CmdArgs.append({ ... })` to add all arguments at once would be a bit 
> more readable (no `CmdArgs.push_back` littering space between args).
will do when committing


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

https://reviews.llvm.org/D124545

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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:681
+ ArgStringList ) const {
+  CmdArgs.push_back(
+  Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));

Nit: `CmdArgs.append({ ... })` to add all arguments at once would be a bit more 
readable (no `CmdArgs.push_back` littering space between args).


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

https://reviews.llvm.org/D124545

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


[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Thank you for working on this new diagnostic!




Comment at: 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp:1
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = 0;
-}
+
+// This file intentionally uses a CRLF newlines!

I think this file (and the next one) are making unintended line ending changes 
and should be reverted.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:430
 
+def warn_pp_gnu_ext_line_directive : Warning<"style of line directive is a GNU 
extension">;
+

Tweaking for grammar, but mostly, this should be marked as an `Extension` 
rather than a `Warning` so that it's controlled only via `-pedantic` rather 
than another warning group.



Comment at: clang/test/Misc/warning-flags.c:21
 
-CHECK: Warnings without flags (67):
+CHECK: Warnings without flags (68):
 

Once you make the diagnostic an extension, the changes to this file can be 
reverted. (It's worth noting that two lines above we document that this list 
should not grow.)



Comment at: clang/test/Preprocessor/line-directive.c:31
+# 42 // expected-warning {{style of line directive is a GNU extension}}
 # 42 "foo"
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}

This should get the same diagnostic.



Comment at: clang/test/Preprocessor/line-directive.c:33
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit

As should this form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D114115: [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

I think the problem here is that if zlib is not available, you won't get the 
clang command line you expect:

https://lab.llvm.org/buildbot/#/builders/216/builds/3519

  Input was:
  <<
   1: clang version 15.0.0 
(https://github.com/llvm/llvm-project.git 
2d0c897212d0551966b26eae986209ea31c4f032) 
   2: Target: x86_64-unknown-fuchsia 
   3: Thread model: posix 
   4: InstalledDir: 
c:\buildbot-root\llvm-clang-x86_64-sie-win\build\bin 
   5: clang: warning: cannot compress debug sections (zlib not 
installed) [-Wdebug-compression-unavailable] 
   6:  
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" "-cc1" 
"-triple" "x86_64-unknown-fuchsia" "-emit-obj" "--mrelax-relocations" 
"-disable-free" "-clear-ast-before-backend" "-main-file-name" "fuchsia.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" 
"-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" 
"-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" 
"-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-resource-dir" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0" 
"-isysroot" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform"
 "-internal-isystem" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0\\include"
 "-internal-externc-isystem" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform\\include"
 "-Og" 
"-fdebug-compilation-dir=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-ferror-limit" "19" "-fsanitize=safe-stack" "-stack-protector" "2" 
"-fgnuc-version=4.2.1" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
"C:\\Users\\BUILDB~1\\AppData\\Local\\Temp\\lit-tmp-f3r87ykv\\fuchsia-9a49da.o" 
"-x" "c" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver\\fuchsia.c"
 
   7:  
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\bin\\ld.lld" "-z" 
"max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" 
"separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr" 
"--sysroot=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform"
 "-pie" "--build-id" "--hash-style=gnu" "--eh-frame-hdr" "-dynamic-linker" 
"ld.so.1" "-o" "a.out" "Scrt1.o" 
"-LC:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform\\lib"
 "--compress-debug-sections=zlib" 
"C:\\Users\\BUILDB~1\\AppData\\Local\\Temp\\lit-tmp-f3r87ykv\\fuchsia-9a49da.o" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0\\lib\\fuchsia\\libclang_rt.builtins-x86_64.a"
 "-lc" 
  >>

Since lld does produce the expected argument, it suggests that maybe LLD isn't 
doing any detection of whether zlib is available like the compiler is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114115

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


[clang] 82aa5e2 - Revert "[Driver] Support for compressed debug info on Fuchsia"

2022-04-27 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-04-27T11:41:41-07:00
New Revision: 82aa5e2c6fe9ffbd637d421a799deffa0d90d7bf

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

LOG: Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 2d0c897212d0551966b26eae986209ea31c4f032 which
is still breaking on the sanitizer bots.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6fe6f7f82feb2..9e0b259dfcae7 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,7 +127,6 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 07bb12b547ddf..888f6b1a2c4b7 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -253,15 +253,6 @@
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
 
-// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
-// RUN: --sysroot=%S/platform \
-// RUN: -Og -gz 2>&1 \
-// RUN: | FileCheck %s -check-prefix=CHECK-GZ
-// CHECK-GZ: "{{[^"]*}}clang{{[^"]*}}"
-// CHECK-GZ: "--compress-debug-sections=zlib"
-// CHECK-GZ: "{{[^"]*}}ld.lld{{[^"]*}}"
-// CHECK-GZ: "--compress-debug-sections=zlib"
-
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -gsplit-dwarf -g -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF



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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

Add -L -l options for linker.


https://reviews.llvm.org/D124545

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/test/Driver/hip-runtime-libs-linux.hip
  clang/test/Driver/hip-runtime-libs-msvc.hip

Index: clang/test/Driver/hip-runtime-libs-msvc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-runtime-libs-msvc.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows
+
+// RUN:  touch %t.o
+
+// Test HIP runtime lib args specified by --rocm-path.
+// RUN: %clang -### --hip-link -target x86_64-pc-windows-msvc \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib"
Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- /dev/null
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -0,0 +1,43 @@
+// UNSUPPORTED: system-windows
+
+// RUN:  touch %t.o
+
+// Test HIP runtime lib args specified by --rocm-path.
+// RUN: %clang -### --hip-link -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
+// Test HIP runtime lib args specified by environment variable ROCM_PATH.
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --hip-link \
+// RUN:   -target x86_64-linux-gnu %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
+// Test detecting latest /opt/rocm-{release} directory.
+// RUN: rm -rf %T/opt
+// RUN: mkdir -p %T/opt
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
+// RUN: %clang -### --hip-link -target x86_64-linux-gnu \
+// RUN:   --sysroot=%T %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-REL %s
+
+// Test HIP runtime lib is not linked without --hip-link.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// Test HIP runtime lib is not linked with -nostdlib.
+// RUN: %clang -### --hip-link -nostdlib -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// Test HIP runtime lib is not linked with -no-hip-rt.
+// RUN: %clang -### --hip-link -no-hip-rt -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
+// ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
+// NOHIPRT-NOT: "-L{{.*/Inputs/rocm/lib}}"
+// NOHIPRT-NOT: "-rpath" "{{.*/Inputs/rocm/lib}}"
+// NOHIPRT-NOT: "-lamdhip64"
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -96,6 +96,9 @@
   void AddHIPIncludeArgs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const override;
 
+  void AddHIPRuntimeLibArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
   bool getWindowsSDKLibraryPath(
   const llvm::opt::ArgList , std::string ) const;
   bool getUniversalCRTLibraryPath(const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -286,6 +286,8 @@
 A.renderAsInput(Args, CmdArgs);
   }
 
+  addHIPRuntimeLibArgs(TC, Args, CmdArgs);
+
   TC.addProfileRTLibs(Args, CmdArgs);
 
   std::vector Environment;
@@ -475,6 +477,13 @@
   RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
 }
 
+void MSVCToolChain::AddHIPRuntimeLibArgs(const ArgList ,
+ ArgStringList ) const {
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-libpath:") +
+   RocmInstallation.getLibPath()));
+  CmdArgs.push_back("amdhip64.lib");
+}
+
 void MSVCToolChain::printVerboseInfo(raw_ostream ) const {
   CudaInstallation.print(OS);
   RocmInstallation.print(OS);
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -37,6 +37,8 @@
   llvm::opt::ArgStringList ) 

[clang] 2d0c897 - [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-04-27T11:24:41-07:00
New Revision: 2d0c897212d0551966b26eae986209ea31c4f032

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

LOG: [Driver] Support for compressed debug info on Fuchsia

Pass the --compress-debug-sections=zlib argument to the linker when
the use of compressed debug info is requested.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 9e0b259dfcae7..6fe6f7f82feb2 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,6 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   D.getLTOMode() == LTOK_Thin);
   }
 
+  addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 888f6b1a2c4b7..07bb12b547ddf 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -253,6 +253,15 @@
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
 
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform \
+// RUN: -Og -gz 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-GZ
+// CHECK-GZ: "{{[^"]*}}clang{{[^"]*}}"
+// CHECK-GZ: "--compress-debug-sections=zlib"
+// CHECK-GZ: "{{[^"]*}}ld.lld{{[^"]*}}"
+// CHECK-GZ: "--compress-debug-sections=zlib"
+
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -gsplit-dwarf -g -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF



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


[PATCH] D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D122920#3476388 , @yihanaa wrote:

> In D122920#3472379 , @asoffer wrote:
>
>> In D122920#3471865 , @yihanaa 
>> wrote:
>>
>>> In D122920#3471654 , @erichkeane 
>>> wrote:
>>>
 @yihanaa : I'd suggest seeing the conversation that @rsmith @aaron.ballman 
 and I are having about this builtin here: https://reviews.llvm.org/D124221

 In general it looks like the three of us think that this builtin needs an 
 overhaul in implementation/functionality in order to be further useful. 
 While we very much appreciate your attempts to try to improve it, we 
 believe there needs to be larger-scale changes.
>>>
>>> Thanks for your reply, I would like to get involved and help if needed
>>
>> While I eagerly await `__builtin_reflect_struct`, this change still provides 
>> significant value in fixing a regression with `__builtin_dump_struct`. 
>> Should we proceed with this change and that proposal independently?
>
> Agree

While we'd usually be happy to take the fix-in-hand and apply it, part of the 
discussion on the other thread is whether to remove `__builtin_dump_struct` 
entirely. Because of that, I don't think we should make substantial changes in 
this area until it's clear we're keeping the builtin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122920

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


[PATCH] D124461: [Analyzer] Remove undefined function

2022-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124461

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Due to how expensive it is to instantiate all the templates from ASTMatchers.h, 
we typically don't add new matchers unless there's a need for them in-tree or 
they're expected to be generally useful to a number of out-of-tree matchers. 
Are you planning to make use of these matchers for a clang-tidy check you're 
working on or something along those lines? Or are they mostly to add missing 
coverage?

On the technical side (feel free to ignore this until we know we're going to 
add the matchers to Clang if you'd like), you should add test coverage for the 
new matchers to clang/unittests/ASTMatchers and you should regenerate the 
documentation by running clang/docs/tools/dump_ast_matchers.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124487: [HLSL] Adjust access specifier behavior

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1603
+def ext_hlsl_access_specifiers : ExtWarn<
+  "access specifiers are a clang HLSL extension">;
 

This also needs to go into a warning group.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3517-3519
+  // HLSL: In HLSL members of a class are public by default.
   AccessSpecifier CurAS;
+  if (TagType == DeclSpec::TST_class && !getLangOpts().HLSL)

Gross. 冷



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2504-2507
+  // In HLSL, unspecified class access is public rather than private.
+  if (getLangOpts().HLSL && Class->getTagKind() == TTK_Class &&
+  Access == AS_none)
+Access = AS_public;

冷



Comment at: clang/test/ParserHLSL/access_specifiers.hlsl:4-5
+class Doggo {
+  // expected-note@+1 {{member is declared here}}
+  int legs;
+// expected-warning@+1 {{access specifiers are a clang HLSL extension}}

(It's generally easier to maintain tests when the expected check lines are 
directly on the impacted line rather than using offsets to it. Same applies 
through the rest of the test. NB: we don't care about 80 col limits in tests.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124487

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


[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1938
+return IsConservativeExtend ? ABIArgInfo::getConservativeExtend(Ty)
+: ABIArgInfo::getExtend(Ty);
   }

LiuChen3 wrote:
> rjmccall wrote:
> > LiuChen3 wrote:
> > > rjmccall wrote:
> > > > This looks wrong.  In non-`ConservativeExtend` mode, we don't get to 
> > > > assume extension at all and should use `Direct`, right?
> > > As I understand it, `Direct` means do nothing with the parameters. Caller 
> > > won't do the extension and callee can't assume the parameter is correct. 
> > > This makes new clang behave in the opposite way to currently clang 
> > > behavior, which will cause incompatibility issue. e.g:
> > > https://godbolt.org/z/d3Peq4nsG
> > Oh, I see, you're thinking that `-mno-conservative-extend` means "do what 
> > old versions of clang did" rather than "break compatibility with old 
> > versions of clang and just follow the x86_64 ABI".  That's definitely 
> > different from the documentation I suggested, so something's got to change.
> > 
> > I think these are the possibilities here:
> > 
> > 1. Some platforms, like Apple's, are probably going to define Clang's 
> > current behavior as the platform ABI.  So those platforms need to continue 
> > to use `Extend`.  My previous comment about using `Direct` wasn't paying 
> > due attention to this case.
> > 
> > 2. On other platforms, we need to maintain compatibility by default with 
> > both the platform ABI and old Clang behavior.  Those platforms will need to 
> > use `ConservativeExtend`.
> > 
> > 3. Some people may want to opt out of (2) and just be compatible with the 
> > platform ABI, which has minor code-size and performance wins.  If we 
> > support that with an option, I believe it should cause us to emit `Direct`. 
> >  This is what I was thinking `-mno-conservative-extend` would mean.
> > 
> > 4. Some people may want to force the use of (1) even on platforms where 
> > that isn't the platform ABI.  I don't know if this is really something we 
> > should support in the long term, but it might be valuable for people 
> > staging this change in.  This is what you seem to be thinking 
> > `-mno-conservative-extend` would mean.
> > 
> > I would suggest these spellings for the argument, instead of making it 
> > boolean:
> > 
> > ```
> > -mextend-small-integers=none// Force the use of Direct
> > -mextend-small-integers=conservative // Force the use of ConservativeExtend
> > -mextend-small-integers=assumed // Force the use of Extend
> > -mextend-small-integers=default // Use the default rule for the target
> > ```
> Yes. That's what I mean. I totally misunderstood your meaning before. 
> I agree with your method. I will work on that. Just one concern about the 
> 'default': the default behavior is 'conservative' instead of 'default'. 
> Wouldn't that be a little weird? But with my limited English I can't think of 
> a better word. 'default' is ok for me. :-)
The default will be platform-specific.  For example, the de facto macOS x86_64 
ABI is to extend in the caller, because clang is the system compiler, and 
that's what clang does.  Apple just needs to update its documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124532: [AST] Improve traversal of concept requirements

2022-04-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124532

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


[PATCH] D124540: [clang][dataflow] Perform structural comparison of indirection values in `join`.

2022-04-27 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, sgatev.
Herald added subscribers: tschuett, steakhal, rnkovacs.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch changes `Environment::join`, in the case that two values at the same
location are not (pointer) equal, to structurally compare indirection values
(pointers and references) for equivalence (that is, equivalent pointees) before
resorting to merging.

This change makes join consistent with equivalence, which also performs
structural comparison. It also fixes a bug where the values are `ReferenceValue`
but the merge creates a non-reference value. This case arises when the
`ReferenceValue`s were created to represent an lvalue, so the "reference-ness"
is not reflected in the type. In this case, the pointees will always be
equivalent, because lvalues at the same code location point to the location of a
fixed declaration, whose location is itself stable across blocks.

We were unable to reproduce a unit test for this latter bug, but have verified
the fix in the context of a larger piece of code that triggers the bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124540

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -21,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -353,6 +354,16 @@
   continue;
 }
 
+// FIXME: add unit tests that cover this statement.
+if (auto *IndVal1 = dyn_cast(Val)) {
+  auto *IndVal2 = cast(It->second);
+  assert(IndVal1->getKind() == IndVal2->getKind());
+  if (>getPointeeLoc() == >getPointeeLoc()) {
+JoinedEnv.LocToVal.insert({Loc, Val});
+continue;
+  }
+}
+
 if (Value *MergedVal = mergeDistinctValues(
 Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model))
   JoinedEnv.LocToVal.insert({Loc, MergedVal});


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -21,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -353,6 +354,16 @@
   continue;
 }
 
+// FIXME: add unit tests that cover this statement.
+if (auto *IndVal1 = dyn_cast(Val)) {
+  auto *IndVal2 = cast(It->second);
+  assert(IndVal1->getKind() == IndVal2->getKind());
+  if (>getPointeeLoc() == >getPointeeLoc()) {
+JoinedEnv.LocToVal.insert({Loc, Val});
+continue;
+  }
+}
+
 if (Value *MergedVal = mergeDistinctValues(
 Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model))
   JoinedEnv.LocToVal.insert({Loc, MergedVal});
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >