Skip to content

Commit 530bdc5

Browse files
Cleanup header inclusion in stl/src (#1270)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent c70b7a8 commit 530bdc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+114
-184
lines changed

stl/src/StlCompareStringA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
#include <crtdbg.h>
5+
#include <cstring> // for __strncnt
56
#include <internal_shared.h>
6-
#include <string.h>
77

88
#include <Windows.h>
99

stl/src/StlCompareStringW.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#include <crtdbg.h>
5-
#include <internal_shared.h>
6-
#include <string.h>
4+
#include <cstring> // for wcsnlen
75

86
#include <Windows.h>
97

stl/src/StlLCMapStringA.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
#include <internal_shared.h>
5-
#include <locale.h>
65

76
#include "awint.hpp"
87

stl/src/StlLCMapStringW.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#include <internal_shared.h>
5-
#include <locale.h>
4+
#include <cstring> // for wcsnlen
65

76
#include "awint.hpp"
87

stl/src/_tolower.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55

66
#include <yvals.h>
77

8-
#include <ctype.h>
8+
#include <cctype>
9+
#include <clocale>
10+
#include <cstdlib>
911
#include <internal_shared.h>
10-
#include <locale.h>
11-
#include <stddef.h>
12-
#include <stdlib.h>
1312
#include <xlocinfo.h>
1413

1514
#include "awint.hpp"

stl/src/_toupper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
#include <yvals.h>
77

8-
#include <ctype.h>
9-
#include <locale.h>
10-
#include <stddef.h>
8+
#include <cctype>
9+
#include <clocale>
10+
#include <cstddef>
1111
#include <xlocinfo.h>
1212

1313
#include "awint.hpp"

stl/src/cond.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
// condition variable functions
55

6+
#include <cstdlib>
67
#include <internal_shared.h>
7-
#include <limits.h>
8-
#include <stdlib.h>
98
#include <type_traits>
109
#include <xthreads.h>
1110
#include <xtimec.h>

stl/src/cthread.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
// thread functions
55

6+
#include <cstdint>
7+
#include <cstdio>
8+
#include <cstdlib>
9+
#include <cstring>
610
#include <process.h>
7-
#include <stdint.h>
8-
#include <stdio.h>
9-
#include <stdlib.h>
10-
#include <string.h>
1111
#include <xthreads.h>
1212

1313
#include <Windows.h>

stl/src/excptptr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
#endif // _VCRT_ALLOW_INTERNALS
1212

1313
#include <Unknwn.h>
14+
#include <cstdlib> // for abort
15+
#include <cstring> // for memcpy
1416
#include <eh.h>
1517
#include <ehdata.h>
1618
#include <exception>
1719
#include <internal_shared.h>
1820
#include <malloc.h>
1921
#include <memory>
2022
#include <new>
21-
#include <stddef.h>
2223
#include <stdexcept>
23-
#include <string.h>
2424
#include <trnsctrl.h>
2525
#include <xcall_once.h>
2626

stl/src/filesys.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
#include <yvals.h>
1010

11+
#include <cstring>
1112
#include <direct.h>
1213
#include <experimental/filesystem>
1314
#include <io.h>
14-
#include <string.h>
1515

1616
#include <Windows.h>
1717

stl/src/filesystem.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
// Do not include or define anything else here.
1010
// In particular, basic_string must not be included here.
1111

12+
#include <clocale>
1213
#include <corecrt_terminate.h>
14+
#include <cstdlib>
15+
#include <cstring>
1316
#include <internal_shared.h>
14-
#include <limits.h>
15-
#include <locale.h>
16-
#include <stdlib.h>
17-
#include <string.h>
1817
#include <xfilesystem_abi.h>
1918

2019
#include <Windows.h>
21-
#include <WinIoCtl.h>
20+
#include <winioctl.h>
2221

2322
// We have several switches that do not have case statements for every possible enum value.
2423
// Hence, disabling this warning.

stl/src/future.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#include <cstdlib>
54
#include <exception>
65
#include <future>
76

stl/src/ios.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// ios_base basic members
55

6-
#include <new>
76
#include <xiosbase>
87
_STD_BEGIN
98

@@ -26,20 +25,6 @@ __PURE_APPDOMAIN_GLOBAL static ios_base* stdstr[_Nstdstr + 2] = {
2625
nullptr}; // [1, _Nstdstr] hold pointers to standard streams
2726
__PURE_APPDOMAIN_GLOBAL static char stdopens[_Nstdstr + 2] = {0}; // [1, _Nstdstr] hold open counts for standard streams
2827

29-
// void __CLR_OR_THIS_CALL ios_base::clear(iostate state, bool reraise) { // set state, possibly reraise exception
30-
// _Mystate = (iostate)(state & _Statmask);
31-
// if ((_Mystate & _Except) == 0)
32-
// ;
33-
// else if (reraise)
34-
// _RERAISE;
35-
// else if (_Mystate & _Except & badbit)
36-
// _THROW(failure("ios_base::badbit set"));
37-
// else if (_Mystate & _Except & failbit)
38-
// _THROW(failure("ios_base::failbit set"));
39-
// else
40-
// _THROW(failure("ios_base::eofbit set"));
41-
// }
42-
4328
void __CLRCALL_PURE_OR_CDECL ios_base::_Ios_base_dtor(ios_base* _This) { // destroy the object
4429
if (0 < _This->_Stdstr && 0 < --stdopens[_This->_Stdstr]) {
4530
return;
@@ -49,30 +34,6 @@ void __CLRCALL_PURE_OR_CDECL ios_base::_Ios_base_dtor(ios_base* _This) { // dest
4934
delete _This->_Ploc;
5035
}
5136

52-
// ios_base::_Iosarray& __CLR_OR_THIS_CALL ios_base::_Findarr(int idx) { // locate or make a variable array element
53-
// static _Iosarray stub(0, 0);
54-
// _Iosarray *p, *q;
55-
//
56-
// if (idx < 0) { // handle bad index
57-
// setstate(badbit);
58-
// return stub;
59-
// }
60-
//
61-
// for (p = _Arr, q = 0; p != 0; p = p->_Next)
62-
// if (p->_Index == idx)
63-
// return *p; // found element, return it
64-
// else if (q == 0 && p->_Lo == 0 && p->_Vp == 0)
65-
// q = p; // found recycling candidate
66-
//
67-
// if (q != 0) { // recycle existing element
68-
// q->_Index = idx;
69-
// return *q;
70-
// }
71-
//
72-
// _Arr = new _Iosarray(idx, _Arr); // make a new element
73-
// return *_Arr;
74-
// }
75-
7637
void __CLRCALL_PURE_OR_CDECL ios_base::_Addstd(ios_base* _This) { // add standard stream to destructor list
7738
_BEGIN_LOCK(_LOCK_STREAM)
7839
for (_This->_Stdstr = 1; _This->_Stdstr < _Nstdstr; ++_This->_Stdstr) {

stl/src/locale0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ _STD_END
7373

7474
#if !STDCPP_IMPLIB || defined(_M_CEE_PURE)
7575

76+
#include <cstdlib>
7677
#include <locale>
77-
#include <stdlib.h>
7878

7979
_EXTERN_C
8080

stl/src/mpiostream.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#error This file must be built with /clr:pure.
77
#endif
88

9-
#include <fstream>
109
#include <iostream>
1110

1211
#pragma warning(disable : 4074)

stl/src/mutex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
// mutex functions
55

6+
#include <cstdio>
7+
#include <cstdlib>
68
#include <internal_shared.h>
7-
#include <stdio.h>
8-
#include <stdlib.h>
99
#include <type_traits>
1010
#include <xthreads.h>
1111
#include <xtimec.h>

stl/src/nothrow.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#undef MRTDLL
1212
#endif
1313

14-
#include <yvals.h>
15-
1614
#include <new>
1715
_STD_BEGIN
1816

stl/src/ppltasks.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#include <crtdbg.h>
54
#include <crtdefs.h>
65
#include <pplinterface.h>
76
#include <ppltasks.h>

stl/src/primitives.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#pragma warning(disable : 4324) // structure was padded due to alignment specifier
88

99
#include <crtdefs.h>
10+
#include <cstdlib> // for __max
1011
#include <exception>
1112
#include <new>
12-
#include <stdlib.h>
1313

1414
#include <Windows.h>
1515

stl/src/taskscheduler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
#include <condition_variable>
5+
#include <cstddef> // for size_t
56
#include <mutex>
67
#include <ppltaskscheduler.h>
7-
#include <stddef.h>
88

99
#include <Windows.h>
1010

stl/src/thread0.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
// thread support functions
55

6-
#include <yvals.h>
7-
8-
#include <stdlib.h>
6+
#include <cstdlib>
97
#include <system_error>
108
#include <xthreads.h>
119

stl/src/vector_algorithms.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <immintrin.h>
1212
#include <intrin0.h>
1313
#include <isa_availability.h>
14-
#include <xmmintrin.h>
1514

1615
extern "C" long __isa_enabled;
1716

stl/src/winapinls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#if _STL_WIN32_WINNT < _WIN32_WINNT_VISTA
77

88
#include <algorithm>
9-
#include <ctype.h>
10-
#include <stdlib.h>
9+
#include <cctype>
10+
#include <cstdlib> // for _countof
1111
#include <string_view>
1212

1313
namespace {

stl/src/winapisupp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
// clang-format off
55
// Prevent clang-format from reordering <AppModel.h> before <Windows.h>
66
#include <Windows.h>
7-
#include <AppModel.h>
7+
#include <AppModel.h> // for APPMODEL_ERROR_NO_PACKAGE
88
#include "awint.hpp"
99
#include <internal_shared.h>
10-
#include <stdlib.h>
10+
#include <cstdlib>
1111
// clang-format on
1212

1313
#pragma warning(push)
1414
#pragma warning(disable : 4265) // non-virtual destructor in base class
1515
#include <wrl/wrappers/corewrappers.h>
1616
#pragma warning(pop)
17-
#include <stdint.h>
17+
#include <cstdint>
1818

1919
#if !defined(_CRT_WINDOWS) && !defined(UNDOCKED_WINDOWS_UCRT)
2020
// GetCurrentPackageId retrieves the current package id, if the app is deployed via a package.

stl/src/xferaise.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <yvals.h>
77

8-
#include <errno.h>
8+
#include <cerrno>
99
#include <ymath.h>
1010

1111
_EXTERN_C_UNLESS_PURE

stl/src/xfprec.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33

44
// _FXp* functions
55

6-
#include "xmath.hpp"
76
#include "xxfftype.hpp"
87
#include "xxxprec.hpp"

stl/src/xgetwctype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <yvals.h>
77

8-
#include <wchar.h>
8+
#include <cwchar>
99
#include <xlocinfo.h>
1010

1111
#include "awint.hpp"

stl/src/xlock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#include <yvals.h>
77

8-
#include <locale.h>
9-
#include <stdlib.h>
8+
#include <clocale>
9+
#include <cstdlib>
1010

1111
#include "xmtx.hpp"
1212

stl/src/xlprec.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33

44
// _LXp* functions
55

6-
#include "xmath.hpp"
76
#include "xxlftype.hpp"
87
#include "xxxprec.hpp"

stl/src/xmath.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
#ifndef _XMATH
55
#define _XMATH
6-
#include <errno.h>
7-
#include <math.h>
8-
#include <stddef.h>
6+
#include <cerrno>
7+
#include <cmath>
98
#include <ymath.h>
109

1110
// FLOAT PROPERTIES

0 commit comments

Comments
 (0)