Skip to content

Commit 314f2ed

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:74f985b793bf into amd-gfx:f5c1367337e7
Local branch amd-gfx f5c1367 Merged main:be12f26dc00c into amd-gfx:c3c19225c0f4 Remote branch main 74f985b [RISCV] Remove -riscv-v-vector-bits-min in tests. NFC (llvm#65404)
2 parents f5c1367 + 74f985b commit 314f2ed

File tree

261 files changed

+2212
-1032
lines changed

Some content is hidden

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

261 files changed

+2212
-1032
lines changed

clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/ADT/STLExtras.h"
3434
#include "llvm/ADT/SmallVector.h"
3535
#include "llvm/ADT/StringRef.h"
36+
#include "llvm/ADT/StringSet.h"
3637
#include "llvm/Support/ErrorHandling.h"
3738
#include "llvm/Support/Path.h"
3839
#include "llvm/Support/Regex.h"
@@ -199,6 +200,8 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
199200

200201
tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
201202
FileStyle->IncludeStyle);
203+
// Deduplicate insertions when running in bulk fix mode.
204+
llvm::StringSet<> InsertedHeaders{};
202205
for (const auto &Inc : Missing) {
203206
std::string Spelling = include_cleaner::spellHeader(
204207
{Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
@@ -209,14 +212,18 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
209212
// main file.
210213
if (auto Replacement =
211214
HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
212-
Angled, tooling::IncludeDirective::Include))
213-
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
214-
"no header providing \"%0\" is directly included")
215-
<< Inc.SymRef.Target.name()
216-
<< FixItHint::CreateInsertion(
217-
SM->getComposedLoc(SM->getMainFileID(),
218-
Replacement->getOffset()),
219-
Replacement->getReplacementText());
215+
Angled, tooling::IncludeDirective::Include)) {
216+
DiagnosticBuilder DB =
217+
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
218+
"no header providing \"%0\" is directly included")
219+
<< Inc.SymRef.Target.name();
220+
if (areDiagsSelfContained() ||
221+
InsertedHeaders.insert(Replacement->getReplacementText()).second) {
222+
DB << FixItHint::CreateInsertion(
223+
SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()),
224+
Replacement->getReplacementText());
225+
}
226+
}
220227
}
221228
}
222229

clang-tools-extra/clangd/unittests/lit.cfg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import lit.formats
2+
import lit.util
23

34
config.name = "Clangd Unit Tests"
45
config.test_format = lit.formats.GoogleTest(".", "Tests")
@@ -9,6 +10,13 @@
910
# FIXME: it seems every project has a copy of this logic. Move it somewhere.
1011
import platform
1112

13+
# Clangd unittests uses ~4 threads per test. So make sure we don't over commit.
14+
core_count = lit.util.usable_core_count()
15+
# FIXME: Split unittests into groups that use threads, and groups that do not,
16+
# and only limit multi-threaded tests.
17+
lit_config.parallelism_groups["clangd"] = max(1, core_count // 4)
18+
config.parallelism_group = "clangd"
19+
1220
if platform.system() == "Darwin":
1321
shlibpath_var = "DYLD_LIBRARY_PATH"
1422
elif platform.system() == "Windows":

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ Changes in existing checks
226226
<clang-tidy/checks/misc/include-cleaner>` check by adding option
227227
`DeduplicateFindings` to output one finding per symbol occurrence.
228228

229+
- Improved :doc:`misc-include-cleaner
230+
<clang-tidy/checks/misc/include-cleaner>` check to avoid fixes insert
231+
same include header multiple times.
232+
229233
- Improved :doc:`misc-redundant-expression
230234
<clang-tidy/checks/misc/redundant-expression>` check to ignore
231235
false-positives in unevaluated context (e.g., ``decltype``).

clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,38 @@ int QuxResult = qux();
184184
)"}}));
185185
}
186186

187+
188+
TEST(IncludeCleanerCheckTest, MultipleTimeMissingInclude) {
189+
const char *PreCode = R"(
190+
#include "bar.h"
191+
192+
int BarResult = bar();
193+
int BazResult_0 = baz_0();
194+
int BazResult_1 = baz_1();
195+
)";
196+
const char *PostCode = R"(
197+
#include "bar.h"
198+
#include "baz.h"
199+
200+
int BarResult = bar();
201+
int BazResult_0 = baz_0();
202+
int BazResult_1 = baz_1();
203+
)";
204+
205+
std::vector<ClangTidyError> Errors;
206+
EXPECT_EQ(PostCode,
207+
runCheckOnCode<IncludeCleanerCheck>(
208+
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
209+
{{"bar.h", R"(#pragma once
210+
#include "baz.h"
211+
int bar();
212+
)"},
213+
{"baz.h", R"(#pragma once
214+
int baz_0();
215+
int baz_1();
216+
)"}}));
217+
}
218+
187219
TEST(IncludeCleanerCheckTest, SystemMissingIncludes) {
188220
const char *PreCode = R"(
189221
#include <vector>

clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ ControlFlowContext::build(const Decl &D, Stmt &S, ASTContext &C) {
8484
std::make_error_code(std::errc::invalid_argument),
8585
"Cannot analyze templated declarations");
8686

87+
// The shape of certain elements of the AST can vary depending on the
88+
// language. We currently only support C++.
89+
if (!C.getLangOpts().CPlusPlus)
90+
return llvm::createStringError(
91+
std::make_error_code(std::errc::invalid_argument),
92+
"Can only analyze C++");
93+
8794
CFG::BuildOptions Options;
8895
Options.PruneTriviallyFalseEdges = true;
8996
Options.AddImplicitDtors = true;

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ const Formula &getFormula(const ValueDecl &D, const Environment &Env) {
7070
return cast<BoolValue>(Env.getValue(D))->formula();
7171
}
7272

73+
TEST(TransferTest, CNotSupported) {
74+
std::string Code = R"(
75+
void target() {}
76+
)";
77+
ASSERT_THAT_ERROR(checkDataflowWithNoopAnalysis(
78+
Code, [](const auto &, auto &) {}, {BuiltinOptions{}},
79+
LangStandard::lang_c89),
80+
llvm::FailedWithMessage("Can only analyze C++"));
81+
}
82+
7383
TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
7484
std::string Code = R"(
7585
void target() {

compiler-rt/lib/scudo/standalone/combined.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ class Allocator {
14961496
map(/*Addr=*/nullptr,
14971497
roundUp(ringBufferSizeInBytes(AllocationRingBufferSize),
14981498
getPageSizeCached()),
1499-
"AllocatorRingBuffer"));
1499+
"scudo:ring_buffer"));
15001500
auto *RingBuffer = reinterpret_cast<AllocationRingBuffer *>(RawRingBuffer);
15011501
RingBuffer->Size = AllocationRingBufferSize;
15021502
static_assert(sizeof(AllocationRingBuffer) %

libc/CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,23 @@ if(("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT LLVM_RUNTIMES_BUILD) OR
4444
endif()
4545

4646
option(LIBC_CMAKE_VERBOSE_LOGGING
47-
"Log details warnings and notifications during CMake configuration." OFF)
47+
"Log details warnings and notifications during CMake configuration." OFF)
48+
4849
# Path libc/scripts directory.
4950
set(LIBC_BUILD_SCRIPTS_DIR "${LIBC_SOURCE_DIR}/utils/build_scripts")
5051

52+
# Defining a global namespace to enclose all libc functions.
53+
set(LIBC_NAMESPACE "__llvm_libc_${LLVM_VERSION_MAJOR}_${LLVM_VERSION_MINOR}_${LLVM_VERSION_PATCH}_${LLVM_VERSION_SUFFIX}"
54+
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
55+
)
56+
57+
if(NOT LIBC_NAMESPACE MATCHES "^__llvm_libc")
58+
message(FATAL_ERROR "Invalid LIBC_NAMESPACE. Must start with '__llvm_libc' was '${LIBC_NAMESPACE}'")
59+
endif()
60+
61+
message(STATUS "Setting LIBC_NAMESPACE namespace to '${LIBC_NAMESPACE}'")
62+
add_compile_definitions(LIBC_NAMESPACE=${LIBC_NAMESPACE})
63+
5164
# Flags to pass down to the compiler while building the libc functions.
5265
set(LIBC_COMPILE_OPTIONS_DEFAULT "" CACHE STRING "Architecture to tell clang to optimize for (e.g. -march=... or -mcpu=...)")
5366

@@ -181,7 +194,8 @@ if(LLVM_LIBC_ENABLE_LINTING)
181194
OUTPUT_VARIABLE CLANG_TIDY_OUTPUT)
182195
string(REGEX MATCH "[0-9]+" CLANG_TIDY_VERSION "${CLANG_TIDY_OUTPUT}")
183196
string(REGEX MATCH "[0-9]+" CLANG_MAJOR_VERSION
184-
"${CMAKE_CXX_COMPILER_VERSION}")
197+
"${CMAKE_CXX_COMPILER_VERSION}")
198+
185199
if(NOT CLANG_TIDY_VERSION EQUAL CLANG_MAJOR_VERSION)
186200
set(LLVM_LIBC_ENABLE_LINTING OFF)
187201
message(WARNING "

libc/src/__support/CPP/functional.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_FUNCTIONAL_H
1010
#define LLVM_LIBC_SRC_SUPPORT_CPP_FUNCTIONAL_H
1111

12-
#include "src/__support/CPP/type_traits.h"
13-
#include "src/__support/CPP/utility.h"
12+
#include "src/__support/CPP/type_traits/enable_if.h"
13+
#include "src/__support/CPP/type_traits/is_convertible.h"
14+
#include "src/__support/CPP/type_traits/is_same.h"
15+
#include "src/__support/CPP/type_traits/is_void.h"
16+
#include "src/__support/CPP/type_traits/remove_cvref.h"
17+
#include "src/__support/CPP/type_traits/remove_reference.h"
18+
#include "src/__support/CPP/utility/forward.h"
1419
#include "src/__support/macros/attributes.h"
1520

1621
#include <stdint.h>
@@ -30,7 +35,7 @@ template <typename Ret, typename... Params> class function<Ret(Params...)> {
3035
template <typename Callable>
3136
LIBC_INLINE static Ret callback_fn(intptr_t callable, Params... params) {
3237
return (*reinterpret_cast<Callable *>(callable))(
33-
forward<Params>(params)...);
38+
cpp::forward<Params>(params)...);
3439
}
3540

3641
public:
@@ -42,18 +47,18 @@ template <typename Ret, typename... Params> class function<Ret(Params...)> {
4247
LIBC_INLINE function(
4348
Callable &&callable,
4449
// This is not the copy-constructor.
45-
enable_if_t<!is_same<remove_cvref_t<Callable>, function>::value> * =
50+
enable_if_t<!cpp::is_same_v<remove_cvref_t<Callable>, function>> * =
4651
nullptr,
4752
// Functor must be callable and return a suitable type.
48-
enable_if_t<is_void_v<Ret> ||
49-
is_convertible_v<
53+
enable_if_t<cpp::is_void_v<Ret> ||
54+
cpp::is_convertible_v<
5055
decltype(declval<Callable>()(declval<Params>()...)), Ret>>
5156
* = nullptr)
52-
: callback(callback_fn<remove_reference_t<Callable>>),
57+
: callback(callback_fn<cpp::remove_reference_t<Callable>>),
5358
callable(reinterpret_cast<intptr_t>(&callable)) {}
5459

5560
LIBC_INLINE Ret operator()(Params... params) const {
56-
return callback(callable, forward<Params>(params)...);
61+
return callback(callable, cpp::forward<Params>(params)...);
5762
}
5863

5964
LIBC_INLINE explicit operator bool() const { return callback; }

0 commit comments

Comments
 (0)