From 3ceebcb48135612b8d90500f65693398f7e526cd Mon Sep 17 00:00:00 2001 From: Peiming Liu Date: Fri, 8 Mar 2024 13:30:34 -0800 Subject: [PATCH 001/968] =?UTF-8?q?[mlir]=20tentative=20fix=20for=20"'GTES?= =?UTF-8?q?T=5FNO=5FLLVM=5FSUPPORT'=20is=20not=20defined"=20war=E2=80=A6?= =?UTF-8?q?=20(#84539)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ning when unittest is enabled --- mlir/unittests/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mlir/unittests/CMakeLists.txt b/mlir/unittests/CMakeLists.txt index d0e222091c9f..6fad249a0b2f 100644 --- a/mlir/unittests/CMakeLists.txt +++ b/mlir/unittests/CMakeLists.txt @@ -1,5 +1,8 @@ set_target_properties(MLIRUnitTests PROPERTIES FOLDER "MLIR Tests") +# To silence warning caused by Wundef. +add_definitions(-DGTEST_NO_LLVM_SUPPORT=0) + function(add_mlir_unittest test_dirname) add_unittest(MLIRUnitTests ${test_dirname} ${ARGN}) endfunction() -- GitLab From 1cf428a05a62711200d37a1b12722ca16c33a6ea Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Fri, 8 Mar 2024 13:46:08 -0800 Subject: [PATCH 002/968] Skip MemtagBasicDeathTest#Unsupported when running with HWASan (#84243) Tested in AOSP. --- compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp index fd277f962a9a..37a18858e67c 100644 --- a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp @@ -12,12 +12,17 @@ #include "platform.h" #include "tests/scudo_unit_test.h" +extern "C" void __hwasan_init() __attribute__((weak)); + #if SCUDO_LINUX namespace scudo { TEST(MemtagBasicDeathTest, Unsupported) { if (archSupportsMemoryTagging()) GTEST_SKIP(); + // Skip when running with HWASan. + if (&__hwasan_init != 0) + GTEST_SKIP(); EXPECT_DEATH(archMemoryTagGranuleSize(), "not supported"); EXPECT_DEATH(untagPointer((uptr)0), "not supported"); -- GitLab From e93489c434da5fd93ed54c3c41b0c06f718bb8ff Mon Sep 17 00:00:00 2001 From: Jakub Kuderski Date: Fri, 8 Mar 2024 17:43:56 -0500 Subject: [PATCH 003/968] [mlir] Add missing build deps for Mesh transforms (#84581) --- mlir/lib/Dialect/Mesh/Transforms/CMakeLists.txt | 2 ++ utils/bazel/llvm-project-overlay/mlir/BUILD.bazel | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mlir/lib/Dialect/Mesh/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Mesh/Transforms/CMakeLists.txt index 28af82044007..212ea6d6948b 100644 --- a/mlir/lib/Dialect/Mesh/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Mesh/Transforms/CMakeLists.txt @@ -17,7 +17,9 @@ add_mlir_dialect_library(MLIRMeshTransforms MLIRArithDialect MLIRArithUtils MLIRControlFlowDialect + MLIRControlFlowInterfaces MLIRFuncDialect + MLIRFunctionInterfaces MLIRIR MLIRMeshDialect MLIRPass diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel index cadcbcc5a092..3be8f34ae0f4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -3410,8 +3410,10 @@ cc_library( ":ArithDialect", ":ArithUtils", ":ControlFlowDialect", + ":ControlFlowInterfaces", ":DialectUtils", ":FuncDialect", + ":FunctionInterfaces", ":IR", ":MeshDialect", ":MeshShardingInterface", -- GitLab From cb6ff746e0c7b9218b6f5c11db44162cacd623a4 Mon Sep 17 00:00:00 2001 From: Kojo Acquah Date: Fri, 8 Mar 2024 22:50:13 +0000 Subject: [PATCH 004/968] [mlir][ArmNeon] Implements LowerVectorToArmNeon Pattern for SMMLA (#81895) This patch adds a the `LowerVectorToArmNeonPattern` patterns to the ArmNeon. This pattern inspects `vector.contract` ops that can be 1-1 mapped to an `arm.neon.smmla` intrinsic. The contract ops must be separated into tiles who's inputs must fit that of a single smmla op (`2x8xi32` inputs and `2x2xi32` output). The `vector.contract` inputs must be sign extended from narrow types (<=i8) to be converted. If all conditions are met, an smmla op is inserted with additional `vector.shape_casts` to handle linearizing the input and output dimension. --- .../include/mlir/Dialect/ArmNeon/Transforms.h | 21 +++ .../Conversion/VectorToLLVM/CMakeLists.txt | 1 + mlir/lib/Dialect/ArmNeon/CMakeLists.txt | 15 +- mlir/lib/Dialect/ArmNeon/IR/CMakeLists.txt | 13 ++ .../Dialect/ArmNeon/Transforms/CMakeLists.txt | 14 ++ .../LowerContractionToSMMLAPattern.cpp | 146 ++++++++++++++++++ .../Dialect/ArmNeon/lower-to-arm-neon.mlir | 42 +++++ mlir/test/lib/Dialect/ArmNeon/CMakeLists.txt | 13 ++ .../Dialect/ArmNeon/TestLowerToArmNeon.cpp | 61 ++++++++ mlir/test/lib/Dialect/CMakeLists.txt | 1 + mlir/tools/mlir-opt/CMakeLists.txt | 1 + mlir/tools/mlir-opt/mlir-opt.cpp | 2 + .../llvm-project-overlay/mlir/BUILD.bazel | 21 +++ 13 files changed, 338 insertions(+), 13 deletions(-) create mode 100644 mlir/include/mlir/Dialect/ArmNeon/Transforms.h create mode 100644 mlir/lib/Dialect/ArmNeon/IR/CMakeLists.txt create mode 100644 mlir/lib/Dialect/ArmNeon/Transforms/CMakeLists.txt create mode 100644 mlir/lib/Dialect/ArmNeon/Transforms/LowerContractionToSMMLAPattern.cpp create mode 100644 mlir/test/Dialect/ArmNeon/lower-to-arm-neon.mlir create mode 100644 mlir/test/lib/Dialect/ArmNeon/CMakeLists.txt create mode 100644 mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp diff --git a/mlir/include/mlir/Dialect/ArmNeon/Transforms.h b/mlir/include/mlir/Dialect/ArmNeon/Transforms.h new file mode 100644 index 000000000000..49cad22defec --- /dev/null +++ b/mlir/include/mlir/Dialect/ArmNeon/Transforms.h @@ -0,0 +1,21 @@ +//===- Transforms.h - ArmNeon Transformation Entrypoints --------*- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_ARMNEON_TRANSFORMS_H +#define MLIR_DIALECT_ARMNEON_TRANSFORMS_H + +namespace mlir { + +namespace arm_neon { +void populateLowerContractionToSMMLAPatternPatterns( + RewritePatternSet &patterns); +} // namespace arm_neon + +} // namespace mlir + +#endif // MLIR_DIALECT_ARMNEON_TRANSFORMS_H diff --git a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt index 5fbb50f62395..a0fce139f274 100644 --- a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt @@ -34,6 +34,7 @@ add_mlir_conversion_library(MLIRVectorToLLVMPass MLIRVectorToLLVM MLIRArmNeonDialect + MLIRArmNeonTransforms MLIRArmSMEDialect MLIRArmSMETransforms MLIRArmSVEDialect diff --git a/mlir/lib/Dialect/ArmNeon/CMakeLists.txt b/mlir/lib/Dialect/ArmNeon/CMakeLists.txt index 060b6df1b334..9f57627c321f 100644 --- a/mlir/lib/Dialect/ArmNeon/CMakeLists.txt +++ b/mlir/lib/Dialect/ArmNeon/CMakeLists.txt @@ -1,13 +1,2 @@ -add_mlir_dialect_library(MLIRArmNeonDialect - IR/ArmNeonDialect.cpp - - ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/ArmNeon - - DEPENDS - MLIRArmNeonIncGen - - LINK_LIBS PUBLIC - MLIRIR - MLIRSideEffectInterfaces - ) +add_subdirectory(IR) +add_subdirectory(Transforms) diff --git a/mlir/lib/Dialect/ArmNeon/IR/CMakeLists.txt b/mlir/lib/Dialect/ArmNeon/IR/CMakeLists.txt new file mode 100644 index 000000000000..b04919a3a318 --- /dev/null +++ b/mlir/lib/Dialect/ArmNeon/IR/CMakeLists.txt @@ -0,0 +1,13 @@ +add_mlir_dialect_library(MLIRArmNeonDialect + ArmNeonDialect.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/ArmNeon + + DEPENDS + MLIRArmNeonIncGen + + LINK_LIBS PUBLIC + MLIRIR + MLIRSideEffectInterfaces + ) diff --git a/mlir/lib/Dialect/ArmNeon/Transforms/CMakeLists.txt b/mlir/lib/Dialect/ArmNeon/Transforms/CMakeLists.txt new file mode 100644 index 000000000000..84fb1b0116d2 --- /dev/null +++ b/mlir/lib/Dialect/ArmNeon/Transforms/CMakeLists.txt @@ -0,0 +1,14 @@ +add_mlir_dialect_library(MLIRArmNeonTransforms + LowerContractionToSMMLAPattern.cpp + + DEPENDS + MLIRArmNeonIncGen + + LINK_LIBS PUBLIC + MLIRArmNeonDialect + MLIRFuncDialect + MLIRVectorDialect + MLIRIR + MLIRLLVMCommonConversion + MLIRLLVMDialect + ) diff --git a/mlir/lib/Dialect/ArmNeon/Transforms/LowerContractionToSMMLAPattern.cpp b/mlir/lib/Dialect/ArmNeon/Transforms/LowerContractionToSMMLAPattern.cpp new file mode 100644 index 000000000000..47c84708f3c3 --- /dev/null +++ b/mlir/lib/Dialect/ArmNeon/Transforms/LowerContractionToSMMLAPattern.cpp @@ -0,0 +1,146 @@ +//===- LowerContractionToSMMLAPattern.cpp - Contract to SMMLA ---*- 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 implements lowering patterns from vector.contract to +// arm_neon.intr.smmla +// +//===--- + +#include "mlir/Dialect/Arith/IR/Arith.h" +#include "mlir/Dialect/ArmNeon/ArmNeonDialect.h" +#include "mlir/Dialect/ArmNeon/Transforms.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/LLVMIR/LLVMDialect.h" +#include "mlir/Dialect/Vector/IR/VectorOps.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" + +#define DEBUG_TYPE "lower-contract-to-arm-neon" + +using namespace mlir; +using namespace mlir::arm_neon; + +namespace { + +/// Return the shaped type with new element type. +static Type matchContainerType(Type element, Type container) { + if (auto shapedTy = dyn_cast(container)) { + return shapedTy.clone(element); + } + return element; +} + +/// Lowering from a single vector::contractOp directly to the arm neon smmla +/// intrinsic. The shapes of the contract and intrinsic must match. +class LowerContractionToSMMLAPattern + : public OpRewritePattern { +public: + using OpRewritePattern::OpRewritePattern; + LogicalResult matchAndRewrite(vector::ContractionOp op, + PatternRewriter &rewriter) const override { + Location loc = op.getLoc(); + Value lhs = op.getLhs(); + Value rhs = op.getRhs(); + Value res = op.getAcc(); + + // Check index maps that represent M N K in contract. + auto indexingMaps = op.getIndexingMapsArray(); + if (llvm::any_of(indexingMaps, [](mlir::AffineMap affineMap) { + return affineMap.isPermutation() || affineMap.getNumDims() != 3 || + affineMap.getNumResults() != 2; + })) { + return failure(); + } + + // Check iterator types for contract. + auto iteratorTypes = op.getIteratorTypesArray(); + if (iteratorTypes.size() != 3 || + iteratorTypes[0] != vector::IteratorType::parallel || + iteratorTypes[1] != vector::IteratorType::parallel || + iteratorTypes[2] != vector::IteratorType::reduction) { + return failure(); + } + + // Check the tile size by mapping the dimensions of the contract. + mlir::VectorType lhsType = op.getLhsType(); + mlir::VectorType rhsType = op.getRhsType(); + auto dimM = lhsType.getDimSize(0); + auto dimN = rhsType.getDimSize(0); + auto dimK = lhsType.getDimSize(1); + if (rhsType.getDimSize(1) != dimK || dimM != 2 || dimN != 2 || dimK != 8) { + return failure(); + } + + // Check two extsi inputs Rhs Lhs for contract. + arith::ExtSIOp origLhsExtOp = + dyn_cast_or_null(lhs.getDefiningOp()); + arith::ExtSIOp origRhsExtOp = + dyn_cast_or_null(rhs.getDefiningOp()); + if (!origLhsExtOp || !origRhsExtOp) { + return failure(); + } + + // Match any iX to i32 for X<8 then turn into an i8 output. Feed into + // following neon instruction. Check inputs for extsi are <=i8 + Value extsiLhs; + Value extsiRhs; + if (auto lhsExtInType = + origLhsExtOp.getIn().getType().dyn_cast()) { + if (lhsExtInType.getElementTypeBitWidth() <= 8) { + Type targetLhsExtTy = + matchContainerType(rewriter.getI8Type(), lhsExtInType); + extsiLhs = rewriter.createOrFold(loc, targetLhsExtTy, + origLhsExtOp.getIn()); + } + } + if (auto rhsExtInType = + origRhsExtOp.getIn().getType().dyn_cast()) { + if (rhsExtInType.getElementTypeBitWidth() <= 8) { + Type targetRhsExtTy = + matchContainerType(rewriter.getI8Type(), rhsExtInType); + extsiRhs = rewriter.createOrFold(loc, targetRhsExtTy, + origRhsExtOp.getIn()); + } + } + + if (!extsiLhs || !extsiRhs) { + return failure(); + } + + // Collapse to 1D vectors required by smmla intrinsic + auto collapsedInputType = VectorType::get( + {16}, extsiLhs.getType().cast().getElementType()); + auto collapsedOutputType = + VectorType::get({4}, res.getType().cast().getElementType()); + auto collapsedLhs = rewriter.createOrFold( + extsiLhs.getLoc(), collapsedInputType, extsiLhs); + auto collapsedRhs = rewriter.createOrFold( + extsiRhs.getLoc(), collapsedInputType, extsiRhs); + auto collapsedRes = rewriter.createOrFold( + res.getLoc(), collapsedOutputType, res); + + // Replace the contract with a neon op + auto smmlaOp = rewriter.createOrFold( + op.getLoc(), collapsedRes.getType(), collapsedRes, collapsedLhs, + collapsedRhs); + + // Reshape output back to 2D + rewriter.replaceOpWithNewOp(op, op.getResultType(), + smmlaOp); + return success(); + } +}; + +} // namespace + +void mlir::arm_neon::populateLowerContractionToSMMLAPatternPatterns( + RewritePatternSet &patterns) { + MLIRContext *context = patterns.getContext(); + patterns.add(context, /*benefit=*/1); +} diff --git a/mlir/test/Dialect/ArmNeon/lower-to-arm-neon.mlir b/mlir/test/Dialect/ArmNeon/lower-to-arm-neon.mlir new file mode 100644 index 000000000000..cba7b00ba77a --- /dev/null +++ b/mlir/test/Dialect/ArmNeon/lower-to-arm-neon.mlir @@ -0,0 +1,42 @@ +// RUN: mlir-opt -test-lower-to-arm-neon -verify-diagnostics -split-input-file %s | FileCheck %s + +// CHECK-LABEL: test_lower_vector_arm_neon_mixed_types +// CHECK-SAME: %[[A0:.*]]: vector<2x8xi8>, %[[A1:.*]]: vector<2x8xi4>, %[[A2:.*]]: vector<2x2xi32> +// CHECK-DAG: %[[D0:.*]] = arith.extsi %[[A1]] : vector<2x8xi4> to vector<2x8xi8> +// CHECK-DAG: %[[D1:.*]] = vector.shape_cast %[[A0]] : vector<2x8xi8> to vector<16xi8> +// CHECK-DAG: %[[D2:.*]] = vector.shape_cast %[[D0]] : vector<2x8xi8> to vector<16xi8> +// CHECK-DAG: %[[D3:.*]] = vector.shape_cast %[[A2]] : vector<2x2xi32> to vector<4xi32> +// CHECK-DAG: %[[D4:.*]] = arm_neon.intr.smmla %[[D3]], %[[D1]], %[[D2]] : vector<16xi8> to vector<4xi32> +// CHECK-DAG: %[[D5:.*]] = vector.shape_cast %[[D4]] : vector<4xi32> to vector<2x2xi32> +func.func @test_lower_vector_arm_neon_mixed_types(%lhs: vector<2x8xi8>, %rhs: vector<2x8xi4>, %acc : vector<2x2xi32>) -> vector<2x2xi32> { + %lhs_extsi = arith.extsi %lhs : vector<2x8xi8> to vector<2x8xi32> + %rhs_extsi = arith.extsi %rhs : vector<2x8xi4> to vector<2x8xi32> + %res = vector.contract {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind} %lhs_extsi, %rhs_extsi, %acc : vector<2x8xi32>, vector<2x8xi32> into vector<2x2xi32> + return %res : vector<2x2xi32> +} + +// ----- + +// CHECK-LABEL: test_lower_vector_arm_neon_same_types +// CHECK-SAME: %[[A0:.*]]: vector<2x8xi8>, %[[A1:.*]]: vector<2x8xi8>, %[[A2:.*]]: vector<2x2xi32> +// CHECK-DAG: %[[D0:.*]] = vector.shape_cast %[[A0]] : vector<2x8xi8> to vector<16xi8> +// CHECK-DAG: %[[D1:.*]] = vector.shape_cast %[[A1]] : vector<2x8xi8> to vector<16xi8> +// CHECK-DAG: %[[D2:.*]] = vector.shape_cast %[[A2]] : vector<2x2xi32> to vector<4xi32> +// CHECK-DAG: %[[D3:.*]] = arm_neon.intr.smmla %[[D2]], %[[D0]], %[[D1]] : vector<16xi8> to vector<4xi32> +// CHECK-DAG: %[[D4:.*]] = vector.shape_cast %[[D3]] : vector<4xi32> to vector<2x2xi32> +func.func @test_lower_vector_arm_neon_same_types(%lhs: vector<2x8xi8>, %rhs: vector<2x8xi8>, %acc : vector<2x2xi32>) -> vector<2x2xi32> { + %lhs_extsi = arith.extsi %lhs : vector<2x8xi8> to vector<2x8xi32> + %rhs_extsi = arith.extsi %rhs : vector<2x8xi8> to vector<2x8xi32> + %res = vector.contract {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind} %lhs_extsi, %rhs_extsi, %acc : vector<2x8xi32>, vector<2x8xi32> into vector<2x2xi32> + return %res : vector<2x2xi32> +} + +// ----- + +// CHECK-LABEL: test_lower_vector_arm_neon_without_extsi +// CHECK-SAME: %[[A0:.*]]: vector<2x8xi32>, %[[A1:.*]]: vector<2x8xi32>, %[[A2:.*]]: vector<2x2xi32> +// CHECK-DAG: %[[D0:.*]] = vector.contract +func.func @test_lower_vector_arm_neon_without_extsi(%lhs: vector<2x8xi32>, %rhs: vector<2x8xi32>, %acc : vector<2x2xi32>) -> vector<2x2xi32> { + %res = vector.contract {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind} %lhs, %rhs, %acc : vector<2x8xi32>, vector<2x8xi32> into vector<2x2xi32> + return %res : vector<2x2xi32> +} diff --git a/mlir/test/lib/Dialect/ArmNeon/CMakeLists.txt b/mlir/test/lib/Dialect/ArmNeon/CMakeLists.txt new file mode 100644 index 000000000000..21548ca57701 --- /dev/null +++ b/mlir/test/lib/Dialect/ArmNeon/CMakeLists.txt @@ -0,0 +1,13 @@ +# Exclude tests from libMLIR.so +add_mlir_library(MLIRArmNeonTestPasses + TestLowerToArmNeon.cpp + + EXCLUDE_FROM_LIBMLIR + + LINK_LIBS PUBLIC + MLIRArmNeonDialect + MLIRArmNeonTransforms + MLIRIR + MLIRPass + MLIRTransforms + ) diff --git a/mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp b/mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp new file mode 100644 index 000000000000..2e5a4a988882 --- /dev/null +++ b/mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp @@ -0,0 +1,61 @@ +//===- TestLowerToArmNeon.cpp - Test lowering to ArmNeon as a sink pass -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements a pass for testing the lowering to ArmNeon as a +// generally usable sink pass. +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/ArmNeon/ArmNeonDialect.h" +#include "mlir/Dialect/ArmNeon/Transforms.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Pass/PassManager.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" + +#define PASS_NAME "test-lower-to-arm-neon" + +using namespace mlir; +using namespace mlir::arm_neon; + +namespace { +struct TestLowerToArmNeon + : public PassWrapper> { + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLowerToArmNeon) + + StringRef getArgument() const final { return PASS_NAME; } + StringRef getDescription() const final { return "Tests lower to arm Neon."; } + TestLowerToArmNeon() = default; + TestLowerToArmNeon(const TestLowerToArmNeon &pass) = default; + + void getDependentDialects(DialectRegistry ®istry) const override { + registry.insert(); + } + + void runOnOperation() override; +}; + +} // namespace + +void TestLowerToArmNeon::runOnOperation() { + MLIRContext *context = &getContext(); + RewritePatternSet patterns(context); + populateLowerContractionToSMMLAPatternPatterns(patterns); + if (failed(applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)))) + return signalPassFailure(); +} + +namespace mlir { +namespace test { + +void registerTestLowerToArmNeon() { PassRegistration(); } + +} // namespace test +} // namespace mlir diff --git a/mlir/test/lib/Dialect/CMakeLists.txt b/mlir/test/lib/Dialect/CMakeLists.txt index e20cd4473a35..29fb4441a24f 100644 --- a/mlir/test/lib/Dialect/CMakeLists.txt +++ b/mlir/test/lib/Dialect/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(Affine) add_subdirectory(Arith) +add_subdirectory(ArmNeon) add_subdirectory(ArmSME) add_subdirectory(Bufferization) add_subdirectory(ControlFlow) diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt index 4389840af10e..e8091bca3326 100644 --- a/mlir/tools/mlir-opt/CMakeLists.txt +++ b/mlir/tools/mlir-opt/CMakeLists.txt @@ -17,6 +17,7 @@ if(MLIR_INCLUDE_TESTS) MLIRTestFuncToLLVM MLIRAffineTransformsTestPasses MLIRArithTestPasses + MLIRArmNeonTestPasses MLIRArmSMETestPasses MLIRBufferizationTestPasses MLIRControlFlowTestPasses diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp index e4d05631c35f..82b3881792bf 100644 --- a/mlir/tools/mlir-opt/mlir-opt.cpp +++ b/mlir/tools/mlir-opt/mlir-opt.cpp @@ -111,6 +111,7 @@ void registerTestLoopFusion(); void registerTestCFGLoopInfoPass(); void registerTestLoopMappingPass(); void registerTestLoopUnrollingPass(); +void registerTestLowerToArmNeon(); void registerTestLowerToArmSME(); void registerTestLowerToLLVM(); void registerTestMakeIsolatedFromAbovePass(); @@ -237,6 +238,7 @@ void registerTestPasses() { mlir::test::registerTestCFGLoopInfoPass(); mlir::test::registerTestLoopMappingPass(); mlir::test::registerTestLoopUnrollingPass(); + mlir::test::registerTestLowerToArmNeon(); mlir::test::registerTestLowerToArmSME(); mlir::test::registerTestLowerToLLVM(); mlir::test::registerTestMakeIsolatedFromAbovePass(); diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel index 3be8f34ae0f4..8da2b51ffc99 100644 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -1931,6 +1931,27 @@ cc_library( ], ) +cc_library( + name = "ArmNeonTransforms", + srcs = ["lib/Dialect/ArmNeon/Transforms/LowerVectorToArmNeon.cpp"], + hdrs = ["include/mlir/Dialect/ArmNeon/Transforms.h"], + includes = ["include"], + deps = [ + ":ArithDialect", + ":ArmNeonIncGen", + ":ArmNeonDialect", + ":FuncDialect", + ":IR", + ":LLVMDialect", + ":SideEffectInterfaces", + ":Support", + ":VectorDialect", + ":Transforms", + "//llvm:Core", + "//llvm:Support", + ], +) + gentbl_cc_library( name = "ArmNeonConversionIncGen", tbl_outs = [ -- GitLab From c22828991e7ca7b99048761c078252e94403ba6e Mon Sep 17 00:00:00 2001 From: Daniel Thornburgh Date: Fri, 8 Mar 2024 15:13:20 -0800 Subject: [PATCH 005/968] =?UTF-8?q?Revert=20"[builtins]=20Disable=20COMPIL?= =?UTF-8?q?ER=5FRT=5FCRT=5FUSE=5FEH=5FFRAME=5FREGISTRY=20by=20d=E2=80=A6?= =?UTF-8?q?=20(#84580)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …efault (#83201)" This reverts commit 062cfada643c1aa48a1bb81894e2920d390fe8cf. See issue #84574. --- compiler-rt/lib/builtins/CMakeLists.txt | 2 +- compiler-rt/test/builtins/Unit/ctor_dtor.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 3f2c0f043639..f9611574a562 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -917,7 +917,7 @@ cmake_dependent_option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON "COM if (COMPILER_RT_BUILD_CRT) add_compiler_rt_component(crt) - option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" OFF) + option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" ON) include(CheckSectionExists) check_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY diff --git a/compiler-rt/test/builtins/Unit/ctor_dtor.c b/compiler-rt/test/builtins/Unit/ctor_dtor.c index 3d5f895a0a1c..47560722a9f7 100644 --- a/compiler-rt/test/builtins/Unit/ctor_dtor.c +++ b/compiler-rt/test/builtins/Unit/ctor_dtor.c @@ -9,13 +9,23 @@ // Ensure the various startup functions are called in the proper order. +// CHECK: __register_frame_info() /// ctor() is here if ld.so/libc supports DT_INIT/DT_FINI // CHECK: main() /// dtor() is here if ld.so/libc supports DT_INIT/DT_FINI +// CHECK: __deregister_frame_info() struct object; static int counter; +void __register_frame_info(const void *fi, struct object *obj) { + printf("__register_frame_info()\n"); +} + +void __deregister_frame_info(const void *fi) { + printf("__deregister_frame_info()\n"); +} + void __attribute__((constructor)) ctor() { printf("ctor()\n"); ++counter; -- GitLab From 624ea68cbc3ce422b3ee110c0c0af839eec2e278 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 8 Mar 2024 10:39:34 -0800 Subject: [PATCH 006/968] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (#84219) Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected This is an NFC change that does not yet add any error handling or change any code to return any errors. This is the second big change in the patch series started with https://github.com/llvm/llvm-project/pull/83501 A follow-up PR will wire up error handling. --- lldb/include/lldb/Core/ValueObject.h | 11 +++- lldb/include/lldb/Core/ValueObjectCast.h | 2 +- lldb/include/lldb/Core/ValueObjectChild.h | 2 +- .../lldb/Core/ValueObjectConstResult.h | 2 +- .../lldb/Core/ValueObjectDynamicValue.h | 2 +- lldb/include/lldb/Core/ValueObjectMemory.h | 2 +- lldb/include/lldb/Core/ValueObjectRegister.h | 4 +- .../lldb/Core/ValueObjectSyntheticFilter.h | 2 +- lldb/include/lldb/Core/ValueObjectVTable.h | 2 +- lldb/include/lldb/Core/ValueObjectVariable.h | 2 +- .../lldb/DataFormatters/TypeSynthetic.h | 20 ++++-- .../lldb/DataFormatters/VectorIterator.h | 2 +- lldb/include/lldb/Symbol/CompilerType.h | 5 +- lldb/include/lldb/Symbol/Type.h | 2 +- lldb/include/lldb/Symbol/TypeSystem.h | 7 +- .../lldb/Target/StackFrameRecognizer.h | 3 +- lldb/include/lldb/Utility/Log.h | 14 ++++ lldb/source/API/SBValue.cpp | 2 +- lldb/source/Core/FormatEntity.cpp | 2 +- lldb/source/Core/IOHandlerCursesGUI.cpp | 2 +- lldb/source/Core/ValueObject.cpp | 31 ++++++--- lldb/source/Core/ValueObjectCast.cpp | 6 +- lldb/source/Core/ValueObjectChild.cpp | 6 +- lldb/source/Core/ValueObjectConstResult.cpp | 7 +- lldb/source/Core/ValueObjectDynamicValue.cpp | 7 +- lldb/source/Core/ValueObjectMemory.cpp | 10 ++- lldb/source/Core/ValueObjectRegister.cpp | 12 ++-- .../Core/ValueObjectSyntheticFilter.cpp | 24 ++++--- lldb/source/Core/ValueObjectVTable.cpp | 6 +- lldb/source/Core/ValueObjectVariable.cpp | 7 +- lldb/source/DataFormatters/FormatManager.cpp | 11 +++- lldb/source/DataFormatters/TypeSynthetic.cpp | 16 ++++- .../DataFormatters/ValueObjectPrinter.cpp | 2 +- lldb/source/DataFormatters/VectorType.cpp | 16 +++-- .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp | 7 +- .../Clang/ClangExpressionSourceCode.cpp | 2 +- .../TSan/InstrumentationRuntimeTSan.cpp | 4 +- .../Language/CPlusPlus/BlockPointer.cpp | 4 +- .../Plugins/Language/CPlusPlus/Coroutines.cpp | 8 ++- .../Plugins/Language/CPlusPlus/Coroutines.h | 2 +- .../Language/CPlusPlus/GenericBitset.cpp | 4 +- .../Language/CPlusPlus/GenericOptional.cpp | 6 +- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 18 +++--- .../Plugins/Language/CPlusPlus/LibCxx.h | 8 +-- .../Language/CPlusPlus/LibCxxAtomic.cpp | 6 +- .../CPlusPlus/LibCxxInitializerList.cpp | 6 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 12 ++-- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 14 ++-- .../Language/CPlusPlus/LibCxxQueue.cpp | 2 +- .../CPlusPlus/LibCxxRangesRefView.cpp | 2 +- .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp | 6 +- .../Language/CPlusPlus/LibCxxTuple.cpp | 4 +- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 8 +-- .../Language/CPlusPlus/LibCxxValarray.cpp | 6 +- .../Language/CPlusPlus/LibCxxVariant.cpp | 2 +- .../Language/CPlusPlus/LibCxxVector.cpp | 14 ++-- .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 17 +++-- .../Language/CPlusPlus/LibStdcppTuple.cpp | 7 +- .../CPlusPlus/LibStdcppUniquePointer.cpp | 5 +- lldb/source/Plugins/Language/ObjC/Cocoa.cpp | 2 +- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 30 ++++----- .../Plugins/Language/ObjC/NSDictionary.cpp | 64 +++++++++---------- lldb/source/Plugins/Language/ObjC/NSError.cpp | 2 +- .../Plugins/Language/ObjC/NSException.cpp | 4 +- .../Plugins/Language/ObjC/NSIndexPath.cpp | 6 +- lldb/source/Plugins/Language/ObjC/NSSet.cpp | 32 +++++----- .../AppleObjCRuntime/AppleObjCRuntime.cpp | 3 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 40 ++++++++---- .../TypeSystem/Clang/TypeSystemClang.h | 7 +- lldb/source/Symbol/CompilerType.cpp | 5 +- lldb/source/Symbol/Type.cpp | 2 +- lldb/source/Symbol/Variable.cpp | 6 +- lldb/source/Target/StackFrame.cpp | 19 +++--- 73 files changed, 399 insertions(+), 248 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index b4d2c8098edc..e7e35e2b2bff 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -476,7 +476,13 @@ public: virtual size_t GetIndexOfChildWithName(llvm::StringRef name); - uint32_t GetNumChildren(uint32_t max = UINT32_MAX); + llvm::Expected GetNumChildren(uint32_t max = UINT32_MAX); + /// Like \c GetNumChildren but returns 0 on error. You probably + /// shouldn't be using this function. It exists primarily to ease the + /// transition to more pervasive error handling while not all APIs + /// have been updated. + uint32_t GetNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX); + bool HasChildren() { return GetNumChildrenIgnoringErrors() > 0; } const Value &GetValue() const { return m_value; } @@ -958,7 +964,8 @@ protected: int32_t synthetic_index); /// Should only be called by ValueObject::GetNumChildren(). - virtual uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; + virtual llvm::Expected + CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; void SetNumChildren(uint32_t num_children); diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index 51c647680d52..ba25e166f326 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -33,7 +33,7 @@ public: std::optional GetByteSize() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 47a13be08bb8..1f88e607cb57 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -39,7 +39,7 @@ public: lldb::ValueType GetValueType() const override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 9f1246cf2a78..37dc0867f26c 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -67,7 +67,7 @@ public: lldb::ValueType GetValueType() const override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 21a9b409fd5b..82c20eee0cd4 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -43,7 +43,7 @@ public: ConstString GetDisplayTypeName() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index a74b325546b0..a8fb0353d601 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -47,7 +47,7 @@ public: ConstString GetDisplayTypeName() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 6c470c1a6865..fec8566ba33d 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -47,7 +47,7 @@ public: ConstString GetQualifiedTypeName() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; @@ -95,7 +95,7 @@ public: ConstString GetTypeName() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; bool SetValueFromCString(const char *value_str, Status &error) override; diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index 1e54babc94f3..ca6d6c728005 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -47,7 +47,7 @@ public: bool MightHaveChildren() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectVTable.h b/lldb/include/lldb/Core/ValueObjectVTable.h index e7e14fc83d78..4662f395a4dd 100644 --- a/lldb/include/lldb/Core/ValueObjectVTable.h +++ b/lldb/include/lldb/Core/ValueObjectVTable.h @@ -64,7 +64,7 @@ public: std::optional GetByteSize() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index da270300df0b..db3847f14a0b 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -46,7 +46,7 @@ public: ConstString GetDisplayTypeName() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 38f3ce0fa5f0..ede7442a02bf 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -38,13 +38,17 @@ public: virtual ~SyntheticChildrenFrontEnd() = default; - virtual uint32_t CalculateNumChildren() = 0; + virtual llvm::Expected CalculateNumChildren() = 0; - virtual uint32_t CalculateNumChildren(uint32_t max) { + virtual llvm::Expected CalculateNumChildren(uint32_t max) { auto count = CalculateNumChildren(); - return count <= max ? count : max; + if (!count) + return count; + return *count <= max ? *count : max; } + uint32_t CalculateNumChildrenIgnoringErrors(uint32_t max = UINT32_MAX); + virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) = 0; virtual size_t GetIndexOfChildWithName(ConstString name) = 0; @@ -109,7 +113,7 @@ public: ~SyntheticValueProviderFrontEnd() override = default; - uint32_t CalculateNumChildren() override { return 0; } + llvm::Expected CalculateNumChildren() override { return 0; } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return nullptr; } @@ -322,7 +326,9 @@ public: ~FrontEnd() override = default; - uint32_t CalculateNumChildren() override { return filter->GetCount(); } + llvm::Expected CalculateNumChildren() override { + return filter->GetCount(); + } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { if (idx >= filter->GetCount()) @@ -426,9 +432,9 @@ public: bool IsValid(); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; - uint32_t CalculateNumChildren(uint32_t max) override; + llvm::Expected CalculateNumChildren(uint32_t max) override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h index 7711b9de95db..70bcf50ca1b1 100644 --- a/lldb/include/lldb/DataFormatters/VectorIterator.h +++ b/lldb/include/lldb/DataFormatters/VectorIterator.h @@ -24,7 +24,7 @@ public: VectorIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp, llvm::ArrayRef item_names); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 414c44275aaa..c1dce4ccbf79 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -386,8 +386,9 @@ public: std::optional GetTypeBitAlign(ExecutionContextScope *exe_scope) const; - uint32_t GetNumChildren(bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) const; + llvm::Expected + GetNumChildren(bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) const; lldb::BasicType GetBasicTypeEnumeration() const; diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index acd1a769f13c..b5eac5fa732d 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -440,7 +440,7 @@ public: std::optional GetByteSize(ExecutionContextScope *exe_scope); - uint32_t GetNumChildren(bool omit_empty_base_classes); + llvm::Expected GetNumChildren(bool omit_empty_base_classes); bool IsAggregateType(); diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 63829131556e..f647fcbf1636 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -300,9 +300,10 @@ public: virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0; - virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) = 0; + virtual llvm::Expected + GetNumChildren(lldb::opaque_compiler_type_t type, + bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) = 0; virtual CompilerType GetBuiltinTypeByName(ConstString name); diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h index e111f4a4dc70..5e8e12b2a4e9 100644 --- a/lldb/include/lldb/Target/StackFrameRecognizer.h +++ b/lldb/include/lldb/Target/StackFrameRecognizer.h @@ -164,7 +164,8 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject { m_value = m_parent->GetValue(); return true; } - uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) override { + llvm::Expected + CalculateNumChildren(uint32_t max = UINT32_MAX) override { return m_parent->GetNumChildren(max); } CompilerType GetCompilerTypeImpl() override { diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h index 1fe28d61b9da..01876ad732d4 100644 --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -373,4 +373,18 @@ template Log *GetLog(Cat mask) { ::llvm::consumeError(::std::move(error_private)); \ } while (0) +// Write message to the verbose log, if error is set. In the log +// message refer to the error with {0}. Error is cleared regardless of +// whether logging is enabled. +#define LLDB_LOG_ERRORV(log, error, ...) \ + do { \ + ::lldb_private::Log *log_private = (log); \ + ::llvm::Error error_private = (error); \ + if (log_private && log_private->GetVerbose() && error_private) { \ + log_private->FormatError(::std::move(error_private), __FILE__, __func__, \ + __VA_ARGS__); \ + } else \ + ::llvm::consumeError(::std::move(error_private)); \ + } while (0) + #endif // LLDB_UTILITY_LOG_H diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 89d26a1fbe28..94a8f3ea319e 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -947,7 +947,7 @@ uint32_t SBValue::GetNumChildren(uint32_t max) { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) - num_children = value_sp->GetNumChildren(max); + num_children = value_sp->GetNumChildrenIgnoringErrors(max); return num_children; } diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index fa5eadc6ff4e..cf82676bedda 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -926,7 +926,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, s.PutChar('['); if (index_higher < 0) - index_higher = valobj->GetNumChildren() - 1; + index_higher = valobj->GetNumChildrenIgnoringErrors() - 1; uint32_t max_num_children = target->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 620e68a28510..f86dce247135 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -4519,7 +4519,7 @@ struct Row { calculated_children = true; ValueObjectSP valobj = value.GetSP(); if (valobj) { - const size_t num_children = valobj->GetNumChildren(); + const uint32_t num_children = valobj->GetNumChildrenIgnoringErrors(); for (size_t i = 0; i < num_children; ++i) { children.push_back(Row(valobj->GetChildAtIndex(i), this)); } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 0ed7f03be25c..d813044d02ff 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -377,7 +377,7 @@ ValueObjectSP ValueObject::GetChildAtIndex(uint32_t idx, bool can_create) { // We may need to update our value if we are dynamic if (IsPossibleDynamicType()) UpdateValueIfNeeded(false); - if (idx < GetNumChildren()) { + if (idx < GetNumChildrenIgnoringErrors()) { // Check if we have already made the child value object? if (can_create && !m_children.HasChildAtIndex(idx)) { // No we haven't created the child at this index, so lets have our @@ -440,7 +440,7 @@ ValueObjectSP ValueObject::GetChildMemberWithName(llvm::StringRef name, return child_sp; } -uint32_t ValueObject::GetNumChildren(uint32_t max) { +llvm::Expected ValueObject::GetNumChildren(uint32_t max) { UpdateValueIfNeeded(); if (max < UINT32_MAX) { @@ -452,11 +452,24 @@ uint32_t ValueObject::GetNumChildren(uint32_t max) { } if (!m_flags.m_children_count_valid) { - SetNumChildren(CalculateNumChildren()); + auto num_children_or_err = CalculateNumChildren(); + if (num_children_or_err) + SetNumChildren(*num_children_or_err); + else + return num_children_or_err; } return m_children.GetChildrenCount(); } +uint32_t ValueObject::GetNumChildrenIgnoringErrors(uint32_t max) { + auto value_or_err = GetNumChildren(max); + if (value_or_err) + return *value_or_err; + LLDB_LOG_ERRORV(GetLog(LLDBLog::DataFormatters), value_or_err.takeError(), + "{0}"); + return 0; +} + bool ValueObject::MightHaveChildren() { bool has_children = false; const uint32_t type_info = GetTypeInfo(); @@ -464,7 +477,7 @@ bool ValueObject::MightHaveChildren() { if (type_info & (eTypeHasChildren | eTypeIsPointer | eTypeIsReference)) has_children = true; } else { - has_children = GetNumChildren() > 0; + has_children = GetNumChildrenIgnoringErrors() > 0; } return has_children; } @@ -1176,7 +1189,7 @@ bool ValueObject::DumpPrintableRepresentation( if (flags.Test(eTypeIsArray)) { if ((custom_format == eFormatBytes) || (custom_format == eFormatBytesWithASCII)) { - const size_t count = GetNumChildren(); + const size_t count = GetNumChildrenIgnoringErrors(); s << '['; for (size_t low = 0; low < count; low++) { @@ -1215,7 +1228,7 @@ bool ValueObject::DumpPrintableRepresentation( // format should be printed // directly { - const size_t count = GetNumChildren(); + const size_t count = GetNumChildrenIgnoringErrors(); Format format = FormatManager::GetSingleItemFormat(custom_format); @@ -1294,7 +1307,7 @@ bool ValueObject::DumpPrintableRepresentation( break; case eValueObjectRepresentationStyleChildrenCount: - strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildren()); + strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildrenIgnoringErrors()); str = strm.GetString(); break; @@ -2320,7 +2333,9 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( child_valobj_sp = root->GetSyntheticArrayMember(index, true); if (!child_valobj_sp) if (root->HasSyntheticValue() && - root->GetSyntheticValue()->GetNumChildren() > index) + llvm::expectedToStdOptional( + root->GetSyntheticValue()->GetNumChildren()) + .value_or(0) > index) child_valobj_sp = root->GetSyntheticValue()->GetChildAtIndex(index); if (child_valobj_sp) { diff --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp index a5c555f86b13..c8e316415141 100644 --- a/lldb/source/Core/ValueObjectCast.cpp +++ b/lldb/source/Core/ValueObjectCast.cpp @@ -41,11 +41,13 @@ ValueObjectCast::~ValueObjectCast() = default; CompilerType ValueObjectCast::GetCompilerTypeImpl() { return m_cast_type; } -uint32_t ValueObjectCast::CalculateNumChildren(uint32_t max) { +llvm::Expected ValueObjectCast::CalculateNumChildren(uint32_t max) { ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren( true, &exe_ctx); - return children_count <= max ? children_count : max; + if (!children_count) + return children_count; + return *children_count <= max ? *children_count : max; } std::optional ValueObjectCast::GetByteSize() { diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index 2e55dd7726bd..c6a97dd1a5cd 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -49,10 +49,12 @@ lldb::ValueType ValueObjectChild::GetValueType() const { return m_parent->GetValueType(); } -uint32_t ValueObjectChild::CalculateNumChildren(uint32_t max) { +llvm::Expected ValueObjectChild::CalculateNumChildren(uint32_t max) { ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx); - return children_count <= max ? children_count : max; + if (!children_count) + return children_count; + return *children_count <= max ? *children_count : max; } static void AdjustForBitfieldness(ConstString &name, diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index 5c7aa4452b70..8ac2c1cac2f6 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -216,10 +216,13 @@ std::optional ValueObjectConstResult::GetByteSize() { void ValueObjectConstResult::SetByteSize(size_t size) { m_byte_size = size; } -uint32_t ValueObjectConstResult::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectConstResult::CalculateNumChildren(uint32_t max) { ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx); - return children_count <= max ? children_count : max; + if (!children_count) + return children_count; + return *children_count <= max ? *children_count : max; } ConstString ValueObjectConstResult::GetTypeName() { diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index 4e64760371ae..4695febdf8ca 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -85,12 +85,15 @@ ConstString ValueObjectDynamicValue::GetDisplayTypeName() { return m_parent->GetDisplayTypeName(); } -uint32_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) { const bool success = UpdateValueIfNeeded(false); if (success && m_dynamic_type_info.HasType()) { ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx); - return children_count <= max ? children_count : max; + if (!children_count) + return children_count; + return *children_count <= max ? *children_count : max; } else return m_parent->GetNumChildren(max); } diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp index 7f68236c7884..f555ab82f441 100644 --- a/lldb/source/Core/ValueObjectMemory.cpp +++ b/lldb/source/Core/ValueObjectMemory.cpp @@ -126,17 +126,21 @@ ConstString ValueObjectMemory::GetDisplayTypeName() { return m_compiler_type.GetDisplayTypeName(); } -uint32_t ValueObjectMemory::CalculateNumChildren(uint32_t max) { +llvm::Expected ValueObjectMemory::CalculateNumChildren(uint32_t max) { if (m_type_sp) { auto child_count = m_type_sp->GetNumChildren(true); - return child_count <= max ? child_count : max; + if (!child_count) + return child_count; + return *child_count <= max ? *child_count : max; } ExecutionContext exe_ctx(GetExecutionContextRef()); const bool omit_empty_base_classes = true; auto child_count = m_compiler_type.GetNumChildren(omit_empty_base_classes, &exe_ctx); - return child_count <= max ? child_count : max; + if (!child_count) + return child_count; + return *child_count <= max ? *child_count : max; } std::optional ValueObjectMemory::GetByteSize() { diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp index d4c144cc7edb..9d9da8bb119d 100644 --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -74,7 +74,8 @@ ConstString ValueObjectRegisterSet::GetQualifiedTypeName() { return ConstString(); } -uint32_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) { const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx); if (reg_set) { auto reg_count = reg_set->num_registers; @@ -118,7 +119,7 @@ ValueObject *ValueObjectRegisterSet::CreateChildAtIndex( size_t idx, bool synthetic_array_member, int32_t synthetic_index) { ValueObject *valobj = nullptr; if (m_reg_ctx_sp && m_reg_set) { - const size_t num_children = GetNumChildren(); + uint32_t num_children = GetNumChildrenIgnoringErrors(); if (idx < num_children) valobj = new ValueObjectRegister( *this, m_reg_ctx_sp, @@ -220,10 +221,13 @@ ConstString ValueObjectRegister::GetTypeName() { return m_type_name; } -uint32_t ValueObjectRegister::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectRegister::CalculateNumChildren(uint32_t max) { ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx); - return children_count <= max ? children_count : max; + if (!children_count) + return children_count; + return *children_count <= max ? *children_count : max; } std::optional ValueObjectRegister::GetByteSize() { diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index 7f8a9a34cb35..adac1b400705 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -31,7 +31,9 @@ public: DummySyntheticFrontEnd(ValueObject &backend) : SyntheticChildrenFrontEnd(backend) {} - uint32_t CalculateNumChildren() override { return m_backend.GetNumChildren(); } + llvm::Expected CalculateNumChildren() override { + return m_backend.GetNumChildren(); + } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return m_backend.GetChildAtIndex(idx); @@ -84,7 +86,8 @@ ConstString ValueObjectSynthetic::GetDisplayTypeName() { return m_parent->GetDisplayTypeName(); } -uint32_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectSynthetic::CalculateNumChildren(uint32_t max) { Log *log = GetLog(LLDBLog::DataFormatters); UpdateValueIfNeeded(); @@ -92,18 +95,23 @@ uint32_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) { return m_synthetic_children_count <= max ? m_synthetic_children_count : max; if (max < UINT32_MAX) { - size_t num_children = m_synth_filter_up->CalculateNumChildren(max); + auto num_children = m_synth_filter_up->CalculateNumChildren(max); LLDB_LOGF(log, "[ValueObjectSynthetic::CalculateNumChildren] for VO of name " - "%s and type %s, the filter returned %zu child values", - GetName().AsCString(), GetTypeName().AsCString(), num_children); + "%s and type %s, the filter returned %u child values", + GetName().AsCString(), GetTypeName().AsCString(), + num_children ? *num_children : 0); return num_children; } else { - size_t num_children = (m_synthetic_children_count = - m_synth_filter_up->CalculateNumChildren(max)); + auto num_children_or_err = m_synth_filter_up->CalculateNumChildren(max); + if (!num_children_or_err) { + m_synthetic_children_count = 0; + return num_children_or_err; + } + auto num_children = (m_synthetic_children_count = *num_children_or_err); LLDB_LOGF(log, "[ValueObjectSynthetic::CalculateNumChildren] for VO of name " - "%s and type %s, the filter returned %zu child values", + "%s and type %s, the filter returned %u child values", GetName().AsCString(), GetTypeName().AsCString(), num_children); return num_children; } diff --git a/lldb/source/Core/ValueObjectVTable.cpp b/lldb/source/Core/ValueObjectVTable.cpp index 4d1cbb8d2f6f..9bfe8dc9700d 100644 --- a/lldb/source/Core/ValueObjectVTable.cpp +++ b/lldb/source/Core/ValueObjectVTable.cpp @@ -33,7 +33,9 @@ public: std::optional GetByteSize() override { return m_addr_size; }; - uint32_t CalculateNumChildren(uint32_t max) override { return 0; }; + llvm::Expected CalculateNumChildren(uint32_t max) override { + return 0; + }; ValueType GetValueType() const override { return eValueTypeVTableEntry; }; @@ -159,7 +161,7 @@ std::optional ValueObjectVTable::GetByteSize() { return std::nullopt; } -uint32_t ValueObjectVTable::CalculateNumChildren(uint32_t max) { +llvm::Expected ValueObjectVTable::CalculateNumChildren(uint32_t max) { if (UpdateValueIfNeeded(false)) return m_num_vtable_entries <= max ? m_num_vtable_entries : max; return 0; diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index dc62bb6358dc..fb29c22c0ab5 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -94,7 +94,8 @@ ConstString ValueObjectVariable::GetQualifiedTypeName() { return ConstString(); } -uint32_t ValueObjectVariable::CalculateNumChildren(uint32_t max) { +llvm::Expected +ValueObjectVariable::CalculateNumChildren(uint32_t max) { CompilerType type(GetCompilerType()); if (!type.IsValid()) @@ -103,7 +104,9 @@ uint32_t ValueObjectVariable::CalculateNumChildren(uint32_t max) { ExecutionContext exe_ctx(GetExecutionContextRef()); const bool omit_empty_base_classes = true; auto child_count = type.GetNumChildren(omit_empty_base_classes, &exe_ctx); - return child_count <= max ? child_count : max; + if (!child_count) + return child_count; + return *child_count <= max ? *child_count : max; } std::optional ValueObjectVariable::GetByteSize() { diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 092fa3c8ce49..d7ba5b4b70c9 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -451,8 +451,13 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { if (valobj.GetSummaryFormat().get() != nullptr) return valobj.GetSummaryFormat()->IsOneLiner(); + auto num_children = valobj.GetNumChildren(); + if (!num_children) { + llvm::consumeError(num_children.takeError()); + return true; + } // no children, no party - if (valobj.GetNumChildren() == 0) + if (*num_children == 0) return false; // ask the type if it has any opinion about this eLazyBoolCalculate == no @@ -471,7 +476,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { size_t total_children_name_len = 0; - for (size_t idx = 0; idx < valobj.GetNumChildren(); idx++) { + for (size_t idx = 0; idx < *num_children; idx++) { bool is_synth_val = false; ValueObjectSP child_sp(valobj.GetChildAtIndex(idx)); // something is wrong here - bail out @@ -523,7 +528,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { } // if this child has children.. - if (child_sp->GetNumChildren()) { + if (child_sp->HasChildren()) { // ...and no summary... // (if it had a summary and the summary wanted children, we would have // bailed out anyway diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp index 0ae38c4d31f2..7aa0670190b2 100644 --- a/lldb/source/DataFormatters/TypeSynthetic.cpp +++ b/lldb/source/DataFormatters/TypeSynthetic.cpp @@ -115,6 +115,16 @@ std::string CXXSyntheticChildren::GetDescription() { return std::string(sstr.GetString()); } +uint32_t +SyntheticChildrenFrontEnd::CalculateNumChildrenIgnoringErrors(uint32_t max) { + auto value_or_err = CalculateNumChildren(max); + if (value_or_err) + return *value_or_err; + LLDB_LOG_ERRORV(GetLog(LLDBLog::DataFormatters), value_or_err.takeError(), + "{0}"); + return 0; +} + lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromExpression( llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx) { @@ -178,13 +188,15 @@ bool ScriptedSyntheticChildren::FrontEnd::IsValid() { return (m_wrapper_sp && m_wrapper_sp->IsValid() && m_interpreter); } -uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() { +llvm::Expected +ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() { if (!m_wrapper_sp || m_interpreter == nullptr) return 0; return m_interpreter->CalculateNumChildren(m_wrapper_sp, UINT32_MAX); } -uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) { +llvm::Expected +ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) { if (!m_wrapper_sp || m_interpreter == nullptr) return 0; return m_interpreter->CalculateNumChildren(m_wrapper_sp, max); diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 46e50a8d421a..b853199e878c 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -627,7 +627,7 @@ uint32_t ValueObjectPrinter::GetMaxNumChildrenToPrint(bool &print_dotdotdot) { if (m_options.m_pointer_as_array) return m_options.m_pointer_as_array.m_element_count; - size_t num_children = synth_valobj.GetNumChildren(); + uint32_t num_children = synth_valobj.GetNumChildrenIgnoringErrors(); print_dotdotdot = false; if (num_children) { const size_t max_num_children = GetMostSpecializedValue() diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index a0626a8cba77..19de204c2435 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -9,6 +9,7 @@ #include "lldb/DataFormatters/VectorType.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/FormattersHelpers.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/TypeSystem.h" @@ -224,10 +225,16 @@ public: ~VectorTypeSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override { return m_num_children; } + llvm::Expected CalculateNumChildren() override { + return m_num_children; + } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { - if (idx >= CalculateNumChildren()) + auto num_children_or_err = CalculateNumChildren(); + if (!num_children_or_err) + return ValueObjectConstResult::Create( + nullptr, Status(num_children_or_err.takeError())); + if (idx >= *num_children_or_err) return {}; std::optional size = m_child_type.GetByteSize(nullptr); if (!size) @@ -266,7 +273,7 @@ public: size_t GetIndexOfChildWithName(ConstString name) override { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } @@ -293,7 +300,8 @@ bool lldb_private::formatters::VectorTypeSummaryProvider( s.PutChar('('); bool first = true; - size_t idx = 0, len = synthetic_children->CalculateNumChildren(); + size_t idx = 0, + len = synthetic_children->CalculateNumChildrenIgnoringErrors(); for (; idx < len; idx++) { auto child_sp = synthetic_children->GetChildAtIndex(idx); diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp index 656f07437095..173b5613d1b8 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp @@ -768,7 +768,12 @@ private: // get number of children const bool omit_empty_base_classes = true; - uint32_t n = m_type.GetNumChildren(omit_empty_base_classes, nullptr); + auto n_or_err = m_type.GetNumChildren(omit_empty_base_classes, nullptr); + if (!n_or_err) { + LLDB_LOG_ERROR(m_log, n_or_err.takeError(), LOG_PREFIX "{0}"); + return {}; + } + uint32_t n = *n_or_err; if (!n) { LLDB_LOG(m_log, LOG_PREFIX "No children found in struct"); return {}; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp index b48bbbecc0cd..3d43ed3f99ff 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp @@ -229,7 +229,7 @@ void AddLambdaCaptureDecls(StreamString &stream, StackFrame *frame, assert(frame); if (auto thisValSP = ClangExpressionUtil::GetLambdaValueObject(frame)) { - uint32_t numChildren = thisValSP->GetNumChildren(); + uint32_t numChildren = thisValSP->GetNumChildrenIgnoringErrors(); for (uint32_t i = 0; i < numChildren; ++i) { auto childVal = thisValSP->GetChildAtIndex(i); ConstString childName(childVal ? childVal->GetName() : ConstString("")); diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp index 72293c5331f4..b2781aa5e7db 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -27,6 +27,8 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -211,7 +213,7 @@ CreateStackTrace(ValueObjectSP o, auto trace_sp = std::make_shared(); ValueObjectSP trace_value_object = o->GetValueForExpressionPath(trace_item_name.c_str()); - size_t count = trace_value_object->GetNumChildren(); + size_t count = trace_value_object->GetNumChildrenIgnoringErrors(); for (size_t j = 0; j < count; j++) { addr_t trace_addr = trace_value_object->GetChildAtIndex(j)->GetValueAsUnsigned(0); diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp index ef0f67d1e9f9..9a6e135e0083 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -74,7 +74,7 @@ public: ~BlockPointerSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override { + llvm::Expected CalculateNumChildren() override { const bool omit_empty_base_classes = false; return m_block_struct_type.GetNumChildren(omit_empty_base_classes, nullptr); } @@ -84,7 +84,7 @@ public: return lldb::ValueObjectSP(); } - if (idx >= CalculateNumChildren()) { + if (idx >= CalculateNumChildrenIgnoringErrors()) { return lldb::ValueObjectSP(); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp index 3827f9c21eff..5e63d1d7b214 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp @@ -11,6 +11,8 @@ #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" using namespace lldb; using namespace lldb_private; @@ -22,7 +24,7 @@ static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP valobj_sp) { // We expect a single pointer in the `coroutine_handle` class. // We don't care about its name. - if (valobj_sp->GetNumChildren() != 1) + if (valobj_sp->GetNumChildrenIgnoringErrors() != 1) return LLDB_INVALID_ADDRESS; ValueObjectSP ptr_sp(valobj_sp->GetChildAtIndex(0)); if (!ptr_sp) @@ -104,8 +106,8 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: ~StdlibCoroutineHandleSyntheticFrontEnd() = default; -uint32_t lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + StdlibCoroutineHandleSyntheticFrontEnd::CalculateNumChildren() { if (!m_resume_ptr_sp || !m_destroy_ptr_sp) return 0; diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h index 5c6a80b57ff4..1d4bc65e2637 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h +++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h @@ -34,7 +34,7 @@ public: ~StdlibCoroutineHandleSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp index 6a9da1d17c76..33955dccb6cc 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp @@ -34,7 +34,9 @@ public: bool MightHaveChildren() override { return true; } lldb::ChildCacheState Update() override; - uint32_t CalculateNumChildren() override { return m_elements.size(); } + llvm::Expected CalculateNumChildren() override { + return m_elements.size(); + } ValueObjectSP GetChildAtIndex(uint32_t idx) override; private: diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp index c06afb53eb8a..23756de7f1e6 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp @@ -19,7 +19,7 @@ using namespace lldb_private; bool lldb_private::formatters::GenericOptionalSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { stream.Printf(" Has Value=%s ", - valobj.GetNumChildren() == 0 ? "false" : "true"); + valobj.GetNumChildrenIgnoringErrors() == 0 ? "false" : "true"); return true; } @@ -41,7 +41,9 @@ public: } bool MightHaveChildren() override { return true; } - uint32_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; } + llvm::Expected CalculateNumChildren() override { + return m_has_value ? 1U : 0U; + } ValueObjectSP GetChildAtIndex(uint32_t idx) override; lldb::ChildCacheState Update() override; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index bba887fec3ac..10a1fe039189 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -63,7 +63,7 @@ lldb::ValueObjectSP lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair( ValueObject &pair) { ValueObjectSP value; - if (pair.GetNumChildren() > 1) { + if (pair.GetNumChildrenIgnoringErrors() > 1) { ValueObjectSP second_child = pair.GetChildAtIndex(1); if (second_child) { value = second_child->GetChildMemberWithName("__value_"); @@ -351,8 +351,8 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { return lldb::ChildCacheState::eRefetch; } -uint32_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibCxxMapIteratorSyntheticFrontEnd::CalculateNumChildren() { return 2; } @@ -509,8 +509,8 @@ lldb::ChildCacheState lldb_private::formatters:: return lldb::ChildCacheState::eRefetch; } -uint32_t lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibCxxUnorderedMapIteratorSyntheticFrontEnd::CalculateNumChildren() { return 2; } @@ -566,8 +566,8 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: Update(); } -uint32_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return (m_cntrl ? 1 : 0); } @@ -661,8 +661,8 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator( : nullptr); } -uint32_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxUniquePtrSyntheticFrontEnd::CalculateNumChildren() { if (m_value_ptr_sp) return m_deleter_sp ? 2 : 1; return 0; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index ad2f58508ab7..a59f21841ec8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -87,7 +87,7 @@ class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -135,7 +135,7 @@ public: ~LibCxxUnorderedMapIteratorSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -166,7 +166,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -186,7 +186,7 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp index 8e4c36103a74..7f30dc186291 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp @@ -90,7 +90,7 @@ public: ~LibcxxStdAtomicSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -124,8 +124,8 @@ bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: return true; } -uint32_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdAtomicSyntheticFrontEnd::CalculateNumChildren() { return m_real_child ? 1 : 0; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index 00012dfc056e..bd9c72497664 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -26,7 +26,7 @@ public: ~LibcxxInitializerListSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -59,8 +59,8 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: // delete m_start; } -uint32_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxInitializerListSyntheticFrontEnd::CalculateNumChildren() { m_num_elements = 0; ValueObjectSP size_sp(m_backend.GetChildMemberWithName("__size_")); if (size_sp) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index 17f6b737d9f6..d7cfeb30557c 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -136,7 +136,7 @@ class ForwardListFrontEnd : public AbstractListFrontEnd { public: ForwardListFrontEnd(ValueObject &valobj); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; ValueObjectSP GetChildAtIndex(uint32_t idx) override; lldb::ChildCacheState Update() override; }; @@ -147,7 +147,7 @@ public: ~ListFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -240,7 +240,7 @@ ForwardListFrontEnd::ForwardListFrontEnd(ValueObject &valobj) Update(); } -uint32_t ForwardListFrontEnd::CalculateNumChildren() { +llvm::Expected ForwardListFrontEnd::CalculateNumChildren() { if (m_count != UINT32_MAX) return m_count; @@ -254,7 +254,7 @@ uint32_t ForwardListFrontEnd::CalculateNumChildren() { } ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(uint32_t idx) { - if (idx >= CalculateNumChildren()) + if (idx >= CalculateNumChildrenIgnoringErrors()) return nullptr; if (!m_head) @@ -308,7 +308,7 @@ ListFrontEnd::ListFrontEnd(lldb::ValueObjectSP valobj_sp) Update(); } -uint32_t ListFrontEnd::CalculateNumChildren() { +llvm::Expected ListFrontEnd::CalculateNumChildren() { if (m_count != UINT32_MAX) return m_count; if (!m_head || !m_tail || m_node_address == 0) @@ -347,7 +347,7 @@ lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(uint32_t idx) { static ConstString g_value("__value_"); static ConstString g_next("__next_"); - if (idx >= CalculateNumChildren()) + if (idx >= CalculateNumChildrenIgnoringErrors()) return lldb::ValueObjectSP(); if (!m_head || !m_tail || m_node_address == 0) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 6d24eb03779c..ec5b320e2218 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -177,7 +177,7 @@ public: ~LibcxxStdMapSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -209,8 +209,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: Update(); } -uint32_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren() { if (m_count != UINT32_MAX) return m_count; @@ -311,13 +311,13 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { static ConstString g_cc_("__cc_"), g_cc("__cc"); static ConstString g_nc("__nc"); - - if (idx >= CalculateNumChildren()) + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); + if (idx >= num_children) return lldb::ValueObjectSP(); if (m_tree == nullptr || m_root_node == nullptr) return lldb::ValueObjectSP(); - MapIterator iterator(m_root_node, CalculateNumChildren()); + MapIterator iterator(m_root_node, num_children); const bool need_to_skip = (idx > 0); size_t actual_advancde = idx; @@ -382,7 +382,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( name.Printf("[%" PRIu64 "]", (uint64_t)idx); auto potential_child_sp = iterated_sp->Clone(ConstString(name.GetString())); if (potential_child_sp) { - switch (potential_child_sp->GetNumChildren()) { + switch (potential_child_sp->GetNumChildrenIgnoringErrors()) { case 1: { auto child0_sp = potential_child_sp->GetChildAtIndex(0); if (child0_sp && diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp index fbadee89b7b7..5b459a17fe29 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp @@ -28,7 +28,7 @@ public: bool MightHaveChildren() override { return true; } lldb::ChildCacheState Update() override; - uint32_t CalculateNumChildren() override { + llvm::Expected CalculateNumChildren() override { return m_container_sp ? m_container_sp->GetNumChildren() : 0; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp index 74f54f767356..01a7b8f142ec 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp @@ -27,7 +27,7 @@ public: ~LibcxxStdRangesRefViewSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override { + llvm::Expected CalculateNumChildren() override { // __range_ will be the sole child of this type return 1; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp index af2b51d2b540..9895f336bfd0 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp @@ -27,7 +27,7 @@ public: ~LibcxxStdSpanSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -73,8 +73,8 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd:: Update(); } -uint32_t lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdSpanSyntheticFrontEnd::CalculateNumChildren() { return m_num_elements; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp index 62bb7d619267..3e3259ab428d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp @@ -26,7 +26,9 @@ public: bool MightHaveChildren() override { return true; } lldb::ChildCacheState Update() override; - uint32_t CalculateNumChildren() override { return m_elements.size(); } + llvm::Expected CalculateNumChildren() override { + return m_elements.size(); + } ValueObjectSP GetChildAtIndex(uint32_t idx) override; private: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index b3c364294335..af29fdb6d001 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -33,7 +33,7 @@ public: ~LibcxxStdUnorderedMapSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -62,8 +62,8 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: Update(); } -uint32_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdUnorderedMapSyntheticFrontEnd::CalculateNumChildren() { return m_num_elements; } @@ -94,7 +94,7 @@ static bool isUnorderedMap(ConstString type_name) { lldb::ValueObjectSP lldb_private::formatters:: LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { - if (idx >= CalculateNumChildren()) + if (idx >= CalculateNumChildrenIgnoringErrors()) return lldb::ValueObjectSP(); if (m_tree == nullptr) return lldb::ValueObjectSP(); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp index 463c7b8d7ce3..99f94406e99a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp @@ -24,7 +24,7 @@ public: ~LibcxxStdValarraySyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -63,8 +63,8 @@ lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd:: // delete m_finish; } -uint32_t lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdValarraySyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) return 0; uint64_t start_val = m_start->GetValueAsUnsigned(0); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp index 1f62062f09be..62794318e077 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp @@ -205,7 +205,7 @@ public: bool MightHaveChildren() override { return true; } lldb::ChildCacheState Update() override; - uint32_t CalculateNumChildren() override { return m_size; } + llvm::Expected CalculateNumChildren() override { return m_size; } ValueObjectSP GetChildAtIndex(uint32_t idx) override; private: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index fcf727ad2ea0..461fed35164b 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -25,7 +25,7 @@ public: ~LibcxxStdVectorSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -46,7 +46,7 @@ class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -82,8 +82,8 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: // delete m_finish; } -uint32_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren() { if (!m_start || !m_finish) return 0; uint64_t start_val = m_start->GetValueAsUnsigned(0); @@ -165,8 +165,8 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd:: } } -uint32_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + LibcxxVectorBoolSyntheticFrontEnd::CalculateNumChildren() { return m_count; } @@ -259,7 +259,7 @@ size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd:: return UINT32_MAX; const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 5abb3d50674b..86bb575af5ca 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -43,7 +43,7 @@ class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: explicit LibstdcppMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -64,7 +64,7 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -132,7 +132,8 @@ lldb::ChildCacheState LibstdcppMapIteratorSyntheticFrontEnd::Update() { return lldb::ChildCacheState::eReuse; } -uint32_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected +LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() { return 2; } @@ -219,7 +220,10 @@ lldb::ChildCacheState VectorIteratorSyntheticFrontEnd::Update() { return lldb::ChildCacheState::eRefetch; } -uint32_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; } +llvm::Expected +VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { + return 1; +} lldb::ValueObjectSP VectorIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { @@ -371,7 +375,10 @@ LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd( Update(); } -uint32_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; } +llvm::Expected +LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { + return 1; +} lldb::ValueObjectSP LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp index 64d2ec9d943a..05199ba35b9a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -26,7 +26,7 @@ class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: explicit LibStdcppTupleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -65,7 +65,7 @@ lldb::ChildCacheState LibStdcppTupleSyntheticFrontEnd::Update() { ValueObjectSP current_child = next_child_sp; next_child_sp = nullptr; - size_t child_count = current_child->GetNumChildren(); + size_t child_count = current_child->GetNumChildrenIgnoringErrors(); for (size_t i = 0; i < child_count; ++i) { ValueObjectSP child_sp = current_child->GetChildAtIndex(i); llvm::StringRef name_str = child_sp->GetName().GetStringRef(); @@ -95,7 +95,8 @@ LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { return lldb::ValueObjectSP(); } -uint32_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected +LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() { return m_members.size(); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp index 3a48fe412e07..92f540d9ca52 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp @@ -26,7 +26,7 @@ class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: explicit LibStdcppUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -135,7 +135,8 @@ LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { return lldb::ValueObjectSP(); } -uint32_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected +LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() { if (m_del_obj) return 2; return 1; diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index cb740f8e71e1..96166657ceeb 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -1038,7 +1038,7 @@ public: ~ObjCClassSyntheticChildrenFrontEnd() override = default; - uint32_t CalculateNumChildren() override { return 0; } + llvm::Expected CalculateNumChildren() override { return 0; } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return lldb::ValueObjectSP(); diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 7f060b2613d6..67d0cd08f51a 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -50,7 +50,7 @@ public: ~NSArrayMSyntheticFrontEndBase() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -214,7 +214,7 @@ public: ~GenericNSArrayISyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -302,7 +302,7 @@ public: ~NSArray0SyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -319,7 +319,7 @@ public: ~NSArray1SyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -477,15 +477,15 @@ lldb_private::formatters:: : NSArrayMSyntheticFrontEndBase(valobj_sp), m_data_32(nullptr), m_data_64(nullptr) {} -uint32_t lldb_private::formatters::NSArrayMSyntheticFrontEndBase:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + NSArrayMSyntheticFrontEndBase::CalculateNumChildren() { return GetUsedCount(); } lldb::ValueObjectSP lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetChildAtIndex( uint32_t idx) { - if (idx >= CalculateNumChildren()) + if (idx >= CalculateNumChildrenIgnoringErrors()) return lldb::ValueObjectSP(); lldb::addr_t object_at_idx = GetDataAddress(); size_t pyhs_idx = idx; @@ -542,7 +542,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } @@ -628,15 +628,15 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } template -uint32_t -lldb_private::formatters::GenericNSArrayISyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected +lldb_private::formatters::GenericNSArrayISyntheticFrontEnd< + D32, D64, Inline>::CalculateNumChildren() { return m_data_32 ? m_data_32->used : m_data_64->used; } @@ -685,7 +685,7 @@ template lldb::ValueObjectSP lldb_private::formatters::GenericNSArrayISyntheticFrontEnd:: GetChildAtIndex(uint32_t idx) { - if (idx >= CalculateNumChildren()) + if (idx >= CalculateNumChildrenIgnoringErrors()) return lldb::ValueObjectSP(); lldb::addr_t object_at_idx; if (Inline) { @@ -719,7 +719,7 @@ lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName( return UINT32_MAX; } -uint32_t +llvm::Expected lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren() { return 0; } @@ -754,7 +754,7 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::GetIndexOfChildWithName( return UINT32_MAX; } -uint32_t +llvm::Expected lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren() { return 1; } diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index da94eda1529c..ec6fd756394a 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -103,7 +103,7 @@ public: ~NSDictionaryISyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -144,7 +144,7 @@ class NSConstantDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: NSConstantDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -176,7 +176,7 @@ class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -209,7 +209,7 @@ public: ~NSDictionary1SyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -230,7 +230,7 @@ public: ~GenericNSDictionaryMSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -262,9 +262,9 @@ namespace Foundation1100 { NSDictionaryMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); ~NSDictionaryMSyntheticFrontEnd() override; - - uint32_t CalculateNumChildren() override; - + + llvm::Expected CalculateNumChildren() override; + lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; lldb::ChildCacheState Update() override; @@ -601,13 +601,13 @@ size_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + NSDictionaryISyntheticFrontEnd::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; return (m_data_32 ? m_data_32->_used : m_data_64->_used); @@ -656,7 +656,7 @@ bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd:: lldb::ValueObjectSP lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -739,13 +739,13 @@ size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); const uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + NSCFDictionarySyntheticFrontEnd::CalculateNumChildren() { if (!m_hashtable.IsValid()) return 0; return m_hashtable.GetCount(); @@ -781,7 +781,7 @@ lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex( lldb::addr_t m_keys_ptr = m_hashtable.GetKeyPointer(); lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer(); - const uint32_t num_children = CalculateNumChildren(); + const uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -875,13 +875,13 @@ size_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + NSConstantDictionarySyntheticFrontEnd::CalculateNumChildren() { return m_size; } @@ -921,7 +921,7 @@ bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd:: lldb::ValueObjectSP lldb_private::formatters:: NSConstantDictionarySyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -994,8 +994,8 @@ size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd:: return name == g_zero ? 0 : UINT32_MAX; } -uint32_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd:: - CalculateNumChildren() { +llvm::Expected lldb_private::formatters:: + NSDictionary1SyntheticFrontEnd::CalculateNumChildren() { return 1; } @@ -1081,17 +1081,18 @@ size_t lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd< D32, D64>::GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } template -uint32_t -lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected +lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd< + D32, D64>::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; - return (m_data_32 ? m_data_32->_used : m_data_64->_used); + return (m_data_32 ? (uint32_t)m_data_32->_used : (uint32_t)m_data_64->_used); } template @@ -1153,7 +1154,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd< m_values_ptr = m_data_64->_buffer + (m_ptr_size * size); } - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -1245,14 +1246,13 @@ lldb_private::formatters::Foundation1100:: NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t -lldb_private::formatters::Foundation1100:: - NSDictionaryMSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected lldb_private::formatters::Foundation1100:: + NSDictionaryMSyntheticFrontEnd::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; return (m_data_32 ? m_data_32->_used : m_data_64->_used); @@ -1306,7 +1306,7 @@ lldb_private::formatters::Foundation1100:: lldb::addr_t m_values_ptr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr); - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp index b034e799b716..5ef7edc7e80c 100644 --- a/lldb/source/Plugins/Language/ObjC/NSError.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp @@ -116,7 +116,7 @@ public: // no need to delete m_child_ptr - it's kept alive by the cluster manager on // our behalf - uint32_t CalculateNumChildren() override { + llvm::Expected CalculateNumChildren() override { if (m_child_ptr) return 1; if (m_child_sp) diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp index 09d3a1b42b74..e7ce26ea4c6f 100644 --- a/lldb/source/Plugins/Language/ObjC/NSException.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp @@ -123,9 +123,7 @@ public: ~NSExceptionSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override { - return 4; - } + llvm::Expected CalculateNumChildren() override { return 4; } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { switch (idx) { diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp index 10bb907c58ed..a434cee09d38 100644 --- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -40,7 +40,9 @@ public: ~NSIndexPathSyntheticFrontEnd() override = default; - uint32_t CalculateNumChildren() override { return m_impl.GetNumIndexes(); } + llvm::Expected CalculateNumChildren() override { + return m_impl.GetNumIndexes(); + } lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return m_impl.GetIndexAtIndex(idx, m_uint_star_type); @@ -127,7 +129,7 @@ public: size_t GetIndexOfChildWithName(ConstString name) override { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp index c965a2a13400..7d0a6a507211 100644 --- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp @@ -46,7 +46,7 @@ public: ~NSSetISyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -84,7 +84,7 @@ class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: NSCFSetSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -117,7 +117,7 @@ public: ~GenericNSSetMSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -233,7 +233,7 @@ public: ~NSSetCodeRunningSyntheticFrontEnd() override; - uint32_t CalculateNumChildren() override; + llvm::Expected CalculateNumChildren() override; lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override; @@ -414,12 +414,12 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetIndexOfChildWithName( ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t +llvm::Expected lldb_private::formatters::NSSetISyntheticFrontEnd::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; @@ -468,7 +468,7 @@ bool lldb_private::formatters::NSSetISyntheticFrontEnd::MightHaveChildren() { lldb::ValueObjectSP lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -551,12 +551,12 @@ lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetIndexOfChildWithName( ConstString name) { const char *item_name = name.GetCString(); const uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } -uint32_t +llvm::Expected lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren() { if (!m_hashtable.IsValid()) return 0; @@ -591,7 +591,7 @@ lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer(); - const uint32_t num_children = CalculateNumChildren(); + const uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); @@ -691,18 +691,18 @@ lldb_private::formatters:: ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildren()) + if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) return UINT32_MAX; return idx; } template -uint32_t -lldb_private::formatters:: - GenericNSSetMSyntheticFrontEnd::CalculateNumChildren() { +llvm::Expected +lldb_private::formatters::GenericNSSetMSyntheticFrontEnd< + D32, D64>::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; - return (m_data_32 ? m_data_32->_used : m_data_64->_used); + return (m_data_32 ? (uint32_t)m_data_32->_used : (uint32_t)m_data_64->_used); } template @@ -753,7 +753,7 @@ lldb_private::formatters:: lldb::addr_t m_objs_addr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr); - uint32_t num_children = CalculateNumChildren(); + uint32_t num_children = CalculateNumChildrenIgnoringErrors(); if (idx >= num_children) return lldb::ValueObjectSP(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index f08f9f0f815d..9434376f7d9e 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -539,7 +539,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( return object; }; - for (size_t idx = 0; idx < reserved_dict->GetNumChildren(); idx++) { + for (size_t idx = 0; idx < reserved_dict->GetNumChildrenIgnoringErrors(); + idx++) { ValueObjectSP dict_entry = reserved_dict->GetChildAtIndex(idx); DataExtractor data; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 51ab13108feb..c02b08cb4782 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -5263,9 +5263,10 @@ GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, return std::nullopt; } -uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) { +llvm::Expected +TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type, + bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) { if (!type) return 0; @@ -5361,9 +5362,13 @@ uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type, CompilerType pointee_clang_type(GetPointeeType(type)); uint32_t num_pointee_children = 0; - if (pointee_clang_type.IsAggregateType()) - num_pointee_children = + if (pointee_clang_type.IsAggregateType()) { + auto num_children_or_err = pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx); + if (!num_children_or_err) + return num_children_or_err; + num_pointee_children = *num_children_or_err; + } // If this type points to a simple type, then it has 1 child if (num_pointee_children == 0) num_children = 1; @@ -5397,9 +5402,13 @@ uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type, clang::QualType pointee_type(pointer_type->getPointeeType()); CompilerType pointee_clang_type(GetType(pointee_type)); uint32_t num_pointee_children = 0; - if (pointee_clang_type.IsAggregateType()) - num_pointee_children = + if (pointee_clang_type.IsAggregateType()) { + auto num_children_or_err = pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx); + if (!num_children_or_err) + return num_children_or_err; + num_pointee_children = *num_children_or_err; + } if (num_pointee_children == 0) { // We have a pointer to a pointee type that claims it has no children. We // will want to look at @@ -6108,8 +6117,15 @@ CompilerType TypeSystemClang::GetChildCompilerTypeAtIndex( child_is_base_class = false; language_flags = 0; - const bool idx_is_valid = - idx < GetNumChildren(type, omit_empty_base_classes, exe_ctx); + auto num_children_or_err = + GetNumChildren(type, omit_empty_base_classes, exe_ctx); + if (!num_children_or_err) { + LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), num_children_or_err.takeError(), + "{0}"); + return {}; + } + + const bool idx_is_valid = idx < *num_children_or_err; int32_t bit_offset; switch (parent_type_class) { case clang::Type::Builtin: @@ -6265,8 +6281,10 @@ CompilerType TypeSystemClang::GetChildCompilerTypeAtIndex( CompilerType base_class_clang_type = GetType(getASTContext().getObjCInterfaceType( superclass_interface_decl)); - if (base_class_clang_type.GetNumChildren(omit_empty_base_classes, - exe_ctx) > 0) { + if (llvm::expectedToStdOptional( + base_class_clang_type.GetNumChildren( + omit_empty_base_classes, exe_ctx)) + .value_or(0) > 0) { if (idx == 0) { clang::QualType ivar_qual_type( getASTContext().getObjCInterfaceType( diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index a73164895baa..05c303baa416 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -833,9 +833,10 @@ public: GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override; - uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) override; + llvm::Expected + GetNumChildren(lldb::opaque_compiler_type_t type, + bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) override; CompilerType GetBuiltinTypeByName(ConstString name) override; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 76b79daa6ac1..85dd2d841a5a 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -770,8 +770,9 @@ lldb::Format CompilerType::GetFormat() const { return lldb::eFormatDefault; } -uint32_t CompilerType::GetNumChildren(bool omit_empty_base_classes, - const ExecutionContext *exe_ctx) const { +llvm::Expected +CompilerType::GetNumChildren(bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) const { if (IsValid()) if (auto type_system_sp = GetTypeSystem()) return type_system_sp->GetNumChildren(m_type, omit_empty_base_classes, diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 6069d066eaf6..44a24d7178f5 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -488,7 +488,7 @@ std::optional Type::GetByteSize(ExecutionContextScope *exe_scope) { return {}; } -uint32_t Type::GetNumChildren(bool omit_empty_base_classes) { +llvm::Expected Type::GetNumChildren(bool omit_empty_base_classes) { return GetForwardCompilerType().GetNumChildren(omit_empty_base_classes, nullptr); } diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index a33c3433d9e2..90edede0f065 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -27,6 +27,8 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -568,7 +570,9 @@ static void PrivateAutoComplete( case eTypeClassObjCObjectPointer: case eTypeClassPointer: { bool omit_empty_base_classes = true; - if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0) + if (llvm::expectedToStdOptional( + compiler_type.GetNumChildren(omit_empty_base_classes, nullptr)) + .value_or(0)) request.AddCompletion((prefix_path + "->").str()); else { request.AddCompletion(prefix_path.str()); diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 50cf01e63cd4..c29a71d92572 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -857,10 +857,11 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "\"(%s) %s\" is not an array type", valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetData()); - } else if ( - static_cast(child_index) >= - synthetic - ->GetNumChildren() /* synthetic does not have that many values */) { + } else if (static_cast(child_index) >= + synthetic + ->GetNumChildrenIgnoringErrors() /* synthetic does + not have that + many values */) { valobj_sp->GetExpressionPath(var_expr_path_strm); error.SetErrorStringWithFormat( "array index %ld is not valid for \"(%s) %s\"", child_index, @@ -929,10 +930,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "\"(%s) %s\" is not an array type", valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetData()); - } else if ( - static_cast(child_index) >= - synthetic - ->GetNumChildren() /* synthetic does not have that many values */) { + } else if (static_cast(child_index) >= + synthetic->GetNumChildrenIgnoringErrors() /* synthetic + does not have that many values */) { valobj_sp->GetExpressionPath(var_expr_path_strm); error.SetErrorStringWithFormat( "array index %ld is not valid for \"(%s) %s\"", child_index, @@ -1397,7 +1397,8 @@ ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent, return parent; } - for (int ci = 0, ce = parent->GetNumChildren(); ci != ce; ++ci) { + for (int ci = 0, ce = parent->GetNumChildrenIgnoringErrors(); ci != ce; + ++ci) { ValueObjectSP child_sp = parent->GetChildAtIndex(ci); if (!child_sp) { -- GitLab From 4d323e404d43526ad8263769f00aace9db2e57c5 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Sat, 9 Mar 2024 01:09:28 +0100 Subject: [PATCH 007/968] [libc++] Allow the use of extensions in the implementation (#79532) We've talked about allowing extensions on [discourse](https://discourse.llvm.org/t/rfc-use-language-extensions-from-future-standards-in-libc/71898/5) and in a libc++ monthly meeting and agreed to test it out in the LLVM 18 release. We've done that with the `tuple` constructor overload set (using conditional `explicit`). Since we haven't heard about any breakages, it seems safe to do. This patch enables the use of extension from later C++ standards inside the versioned `std` namespaces. This should be good enough, since almost all of our code is inside that namespace. This approach also avoids the use of extensions inside the test `std` suite. That part of the code base should stay clean, since it's a test suite that is also used by other vendors to test their implementations. --- libcxx/include/__config | 61 +++++++++++++++++++++++++++-------------- libcxx/include/tuple | 6 ---- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index 3a438e85a7b8..11e13e0c2498 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -406,6 +406,10 @@ _LIBCPP_HARDENING_MODE_DEBUG # define __has_include(...) 0 # endif +# ifndef __has_warning +# define __has_warning(...) 0 +# endif + # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" # endif @@ -723,6 +727,23 @@ typedef __char32_t char32_t; # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE # endif +# ifdef _LIBCPP_COMPILER_CLANG_BASED +# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") +# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) +# elif defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") +# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) +# else +# define _LIBCPP_DIAGNOSTIC_PUSH +# define _LIBCPP_DIAGNOSTIC_POP +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) +# endif + # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST # define _LIBCPP_HARDENING_SIG f # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE @@ -810,16 +831,33 @@ typedef __char32_t char32_t; # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI # endif +// TODO: Remove this workaround once we drop support for Clang 16 +#if __has_warning("-Wc++23-extensions") +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") +#else +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions") +#endif + // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. // clang-format off -# define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ +# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_DIAGNOSTIC_PUSH \ + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \ + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \ + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \ + namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ inline namespace _LIBCPP_ABI_NAMESPACE { -# define _LIBCPP_END_NAMESPACE_STD }} +# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_DIAGNOSTIC_POP # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \ inline namespace __fs { namespace filesystem { -# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} +# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD // clang-format on # if __has_attribute(__enable_if__) @@ -1256,23 +1294,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c // the ABI inconsistent. # endif -# ifdef _LIBCPP_COMPILER_CLANG_BASED -# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") -# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) -# elif defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") -# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) -# else -# define _LIBCPP_DIAGNOSTIC_PUSH -# define _LIBCPP_DIAGNOSTIC_POP -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) -# endif - // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these // functions is gradually being added to existing C libraries. The conditions // below check for known C library versions and conditions under which these diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 0101d64aea4a..8808db6739fb 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -548,10 +548,6 @@ class _LIBCPP_TEMPLATE_VIS tuple { public: // [tuple.cnstr] - _LIBCPP_DIAGNOSTIC_PUSH - _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") - _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") - // tuple() constructors (including allocator_arg_t variants) template