Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_STL_VERIFY shouldn't emit long strings for function names #2054

Merged
merged 4 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions stl/inc/yvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ _STL_DISABLE_CLANG_WARNINGS
#error _ITERATOR_DEBUG_LEVEL != 0 must imply _CONTAINER_DEBUG_LEVEL == 1.
#endif // _ITERATOR_DEBUG_LEVEL != 0 && _CONTAINER_DEBUG_LEVEL == 0

#define _STL_REPORT_ERROR(mesg) \
do { \
_RPTF0(_CRT_ASSERT, mesg); \
_CRT_SECURE_INVALID_PARAMETER(mesg); \
#ifndef _STL_CRT_SECURE_INVALID_PARAMETER
#ifdef _DEBUG
#define _STL_CRT_SECURE_INVALID_PARAMETER(expr) ::_invalid_parameter(_CRT_WIDE(#expr), L"", __FILEW__, __LINE__, 0)
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
#else
#define _STL_CRT_SECURE_INVALID_PARAMETER(expr) _CRT_SECURE_INVALID_PARAMETER(expr)
#endif
#endif
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved

#define _STL_REPORT_ERROR(mesg) \
do { \
_RPTF0(_CRT_ASSERT, mesg); \
_STL_CRT_SECURE_INVALID_PARAMETER(mesg); \
} while (false)

#ifdef __clang__
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ tests\GH_001411_core_headers
tests\GH_001530_binomial_accuracy
tests\GH_001541_case_sensitive_boolalpha
tests\GH_001638_dllexport_derived_classes
tests\GH_001956_stl_verify_emits_long_strings
tests\LWG2597_complex_branch_cut
tests\LWG3018_shared_ptr_function
tests\P0019R8_atomic_ref
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\strict_concepts_latest_matrix.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright (c) Microsoft Corporation.
fsb4000 marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <iostream>
#include <ranges>
#include <vector>

using namespace std;

namespace myVeryLongNamespace {

struct A {
double x;
double getX() const {
return x;
}

template <ranges::range RangeOfA>
static double getFirstValue(RangeOfA&& r) {
auto getValue = [](const A& a) -> double { return a.getX(); };
auto x_range = r | views::transform(getValue);
return *begin(x_range);
}
};

struct B {
A a;
const A& getA() const {
return a;
}

template <ranges::range RangeOfB>
static double getFirstValue(RangeOfB&& r) {
auto getValue = [](const B& b) -> const auto& {
return b.getA();
};
auto b_range = r | views::transform(getValue);
return A::getFirstValue(b_range);
}
};

struct C {
B b;
const B& getB() const {
return b;
}

template <ranges::range RangeOfC>
static double getFirstValue(RangeOfC&& r) {
auto getValue = [](const C& c) -> const auto& {
return c.getB();
};
auto c_range = r | views::transform(getValue);
return B::getFirstValue(c_range);
}
};

struct D {
C c;
const C& getC() const {
return c;
}

template <ranges::range RangeOfD>
static double getFirstValue(RangeOfD&& r) {
auto getValue = [](const D& d) -> const auto& {
return d.getC();
};
auto d_range = r | views::transform(getValue);
return C::getFirstValue(d_range);
}
};

} // namespace myVeryLongNamespace

void test() {
using namespace myVeryLongNamespace;
auto a = A{1};
auto b = B{a};
auto c = C{b};
auto d = D{c};

auto d_range = vector{d, d, d};

auto isPositive = [](const auto& d) { return d.c.b.a.x > 0.0; };

auto filtered_range = d_range | views::filter(isPositive) | views::filter(isPositive) | views::filter(isPositive);

auto result = D::getFirstValue(filtered_range);
cout << result << endl;
}

int main() {} // COMPILE-ONLY