Skip to content

Commit 3cdc27b

Browse files
committed
merge main into amd-staging
Change-Id: I4385997497d801b4164232276b85ef76e8dd07dc
2 parents e553a98 + 7111d03 commit 3cdc27b

Some content is hidden

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

48 files changed

+287
-243
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

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

99
#include "InitVariablesCheck.h"
1010

11+
#include "../utils/LexerUtils.h"
1112
#include "clang/AST/ASTContext.h"
13+
#include "clang/AST/Type.h"
1214
#include "clang/ASTMatchers/ASTMatchFinder.h"
13-
#include "clang/Lex/PPCallbacks.h"
1415
#include "clang/Lex/Preprocessor.h"
1516
#include <optional>
1617

@@ -107,8 +108,9 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
107108
<< MatchedDecl;
108109
if (*InitializationString != nullptr)
109110
Diagnostic << FixItHint::CreateInsertion(
110-
MatchedDecl->getLocation().getLocWithOffset(
111-
MatchedDecl->getName().size()),
111+
utils::lexer::findNextTerminator(MatchedDecl->getLocation(),
112+
*Result.SourceManager,
113+
Result.Context->getLangOpts()),
112114
*InitializationString);
113115
if (AddMathInclude) {
114116
Diagnostic << IncludeInserter.createIncludeInsertion(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ Changes in existing checks
194194
fix false positive that floating point variable is only used in increment
195195
expression.
196196

197+
- Improved :doc:`cppcoreguidelines-init-variables
198+
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
199+
insertion location for function pointers.
200+
197201
- Improved :doc:`cppcoreguidelines-prefer-member-initializer
198202
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
199203
avoid false positive when member initialization depends on a structured
@@ -212,9 +216,9 @@ Changes in existing checks
212216
false positive for C++23 deducing this.
213217

214218
- Improved :doc:`modernize-avoid-c-arrays
215-
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using ``std::span``
216-
as a replacement for parameters of incomplete C array type in C++20 and
217-
``std::array`` or ``std::vector`` before C++20.
219+
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
220+
``std::span`` as a replacement for parameters of incomplete C array type in
221+
C++20 and ``std::array`` or ``std::vector`` before C++20.
218222

219223
- Improved :doc:`modernize-loop-convert
220224
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,17 @@ void test_clang_diagnostic_error() {
134134
// CHECK-MESSAGES: :[[@LINE-1]]:3: error: unknown type name 'UnknownType' [clang-diagnostic-error]
135135
// CHECK-FIXES-NOT: {{^}} UnknownType b = 0;{{$}}
136136
}
137+
138+
namespace gh112089 {
139+
void foo(void*);
140+
using FPtr = void(*)(void*);
141+
void test() {
142+
void(*a1)(void*);
143+
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'a1' is not initialized [cppcoreguidelines-init-variables]
144+
// CHECK-FIXES: void(*a1)(void*) = nullptr;
145+
FPtr a2;
146+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'a2' is not initialized [cppcoreguidelines-init-variables]
147+
// CHECK-FIXES: FPtr a2 = nullptr;
148+
}
149+
} // namespace gh112089
150+

clang/docs/SafeBuffers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ A relatively fresh version of C++ is recommended. In particular, the very useful
5858
standard view class ``std::span`` requires C++20.
5959

6060
Other implementations of the C++ standard library may provide different
61-
flags to enable such hardening hardening.
61+
flags to enable such hardening.
6262

6363
If you're using custom containers and views, they will need to be hardened
6464
this way as well, but you don't necessarily need to do this ahead of time.

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class Intrinsic {
578578
class NeonEmitter {
579579
const RecordKeeper &Records;
580580
DenseMap<const Record *, ClassKind> ClassMap;
581-
std::map<std::string, std::deque<Intrinsic>> IntrinsicMap;
581+
std::map<std::string, std::deque<Intrinsic>, std::less<>> IntrinsicMap;
582582
unsigned UniqueNumber;
583583

584584
void createIntrinsic(const Record *R, SmallVectorImpl<Intrinsic *> &Out);
@@ -1937,9 +1937,9 @@ void Intrinsic::indexBody() {
19371937
Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types,
19381938
std::optional<std::string> MangledName) {
19391939
// First, look up the name in the intrinsic map.
1940-
assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
1940+
assert_with_loc(IntrinsicMap.find(Name) != IntrinsicMap.end(),
19411941
("Intrinsic '" + Name + "' not found!").str());
1942-
auto &V = IntrinsicMap.find(Name.str())->second;
1942+
auto &V = IntrinsicMap.find(Name)->second;
19431943
std::vector<Intrinsic *> GoodVec;
19441944

19451945
// Create a string to print if we end up failing.

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,10 @@ set(files
738738
__tuple/tuple_like_no_subrange.h
739739
__tuple/tuple_size.h
740740
__tuple/tuple_types.h
741-
__type_traits/add_const.h
742-
__type_traits/add_cv.h
741+
__type_traits/add_cv_quals.h
743742
__type_traits/add_lvalue_reference.h
744743
__type_traits/add_pointer.h
745744
__type_traits/add_rvalue_reference.h
746-
__type_traits/add_volatile.h
747745
__type_traits/aligned_storage.h
748746
__type_traits/aligned_union.h
749747
__type_traits/alignment_of.h

libcxx/include/__type_traits/add_const.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

libcxx/include/__type_traits/add_cv.h renamed to libcxx/include/__type_traits/add_cv_quals.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

20+
template <class _Tp>
21+
struct _LIBCPP_TEMPLATE_VIS add_const {
22+
typedef _LIBCPP_NODEBUG const _Tp type;
23+
};
24+
25+
#if _LIBCPP_STD_VER >= 14
26+
template <class _Tp>
27+
using add_const_t = typename add_const<_Tp>::type;
28+
#endif
29+
2030
template <class _Tp>
2131
struct _LIBCPP_TEMPLATE_VIS add_cv {
2232
typedef _LIBCPP_NODEBUG const volatile _Tp type;
@@ -27,6 +37,16 @@ template <class _Tp>
2737
using add_cv_t = typename add_cv<_Tp>::type;
2838
#endif
2939

40+
template <class _Tp>
41+
struct _LIBCPP_TEMPLATE_VIS add_volatile {
42+
typedef _LIBCPP_NODEBUG volatile _Tp type;
43+
};
44+
45+
#if _LIBCPP_STD_VER >= 14
46+
template <class _Tp>
47+
using add_volatile_t = typename add_volatile<_Tp>::type;
48+
#endif
49+
3050
_LIBCPP_END_NAMESPACE_STD
3151

3252
#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H

libcxx/include/__type_traits/add_volatile.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

libcxx/include/__type_traits/is_trivially_assignable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
1111

1212
#include <__config>
13-
#include <__type_traits/add_const.h>
1413
#include <__type_traits/add_lvalue_reference.h>
1514
#include <__type_traits/add_rvalue_reference.h>
1615
#include <__type_traits/integral_constant.h>

0 commit comments

Comments
 (0)