Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c81e6d
[mlir][llvm] Add icmp folder (#65343)
gysit Sep 6, 2023
d26c78b
[flang] handle indirect module variable use in internal procedure (#6…
jeanPerier Sep 6, 2023
ca23c93
[mlir][python] Create all missing attribute builders.
ingomueller-net Sep 1, 2023
a479be0
[MC] Change tryParseRegister to return ParseStatus (NFC)
s-barannikov Sep 6, 2023
f470c36
[clang][dataflow] Eliminate uses of `RecordValue::getChild()`. (#65329)
martinboehme Sep 6, 2023
6c3232b
[lldb][Docs] Add simpler "automatic" cross-compile option to build do…
DavidSpickett Sep 6, 2023
be12f26
[clang][dataflow][NFC] Remove stale comment. (#65322)
martinboehme Sep 6, 2023
c0703ea
[clang][dataflow] Emit an error if source code is not compiled as C++…
martinboehme Sep 6, 2023
56426c6
[libc] customizable namespace 1/4 (#65321)
gchatelet Sep 6, 2023
b793c7e
[libc][NFC] split type_traits / utility in separate files (#65314)
gchatelet Sep 6, 2023
af9b25f
[RISCV] Optimize floating point scalar move and splat
kito-cheng Sep 6, 2023
bcdbd0b
Revert "[libc][NFC] split type_traits / utility in separate files (#6…
gchatelet Sep 6, 2023
9a26d2c
[clangd][unittests] Limit paralelism for clangd unittests
kadircet Sep 5, 2023
e821914
[LLDB] Skip TestBSDArchives.py on windows
omjavaid Sep 6, 2023
b027ce0
[DAG] Fold (shl (sext (add_nsw x, c1)), c2) -> (add (shl (sext x), c2…
RKSimon Sep 6, 2023
6cfb411
[llvm][test] Write temporary files to %t instead of CWD
gribozavr Sep 6, 2023
4acc3ff
[reland][libc][NFC] split type_traits / utility in separate files (#6…
gchatelet Sep 6, 2023
fdb29f7
[scudo] Rename AllocatorRingBuffer into scudo:ring_buffer
fabio-d Sep 6, 2023
97bf104
Revert "[DAG] Fold (shl (sext (add_nsw x, c1)), c2) -> (add (shl (sex…
gribozavr Sep 6, 2023
b0831c3
[clang-tidy][misc-include-cleaner]Avoid to insert same include header…
HerrCai0907 Sep 6, 2023
74f985b
[RISCV] Remove -riscv-v-vector-bits-min in tests. NFC (#65404)
lukel97 Sep 6, 2023
c5fabac
[X86][Driver] Move mno-gather/mno-scatter from m_x86_Features_Group t…
phoebewang Sep 6, 2023
43d729d
[flang][HLFIR] add more memory effects interfaces
tblah Aug 23, 2023
3e7cd5e
[JITLink][AArch32] Fixes for initial AArch32 backend
eymay Sep 6, 2023
87568ff
[mlir][SCF] convert-scf-to-cf: Lower scf.forall to scf.parallel (#65449)
matthias-springer Sep 6, 2023
d71adeb
[include-cleaner] Map the 4-argument move overload to the algorithm h…
VitaNuo Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 15 additions & 8 deletions clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
Expand Down Expand Up @@ -199,6 +200,8 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {

tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
FileStyle->IncludeStyle);
// Deduplicate insertions when running in bulk fix mode.
llvm::StringSet<> InsertedHeaders{};
for (const auto &Inc : Missing) {
std::string Spelling = include_cleaner::spellHeader(
{Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
Expand All @@ -209,14 +212,18 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
// main file.
if (auto Replacement =
HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
Angled, tooling::IncludeDirective::Include))
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
"no header providing \"%0\" is directly included")
<< Inc.SymRef.Target.name()
<< FixItHint::CreateInsertion(
SM->getComposedLoc(SM->getMainFileID(),
Replacement->getOffset()),
Replacement->getReplacementText());
Angled, tooling::IncludeDirective::Include)) {
DiagnosticBuilder DB =
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
"no header providing \"%0\" is directly included")
<< Inc.SymRef.Target.name();
if (areDiagsSelfContained() ||
InsertedHeaders.insert(Replacement->getReplacementText()).second) {
DB << FixItHint::CreateInsertion(
SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()),
Replacement->getReplacementText());
}
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/unittests/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import lit.formats
import lit.util

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

# Clangd unittests uses ~4 threads per test. So make sure we don't over commit.
core_count = lit.util.usable_core_count()
# FIXME: Split unittests into groups that use threads, and groups that do not,
# and only limit multi-threaded tests.
lit_config.parallelism_groups["clangd"] = max(1, core_count // 4)
config.parallelism_group = "clangd"

if platform.system() == "Darwin":
shlibpath_var = "DYLD_LIBRARY_PATH"
elif platform.system() == "Windows":
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ Changes in existing checks
<clang-tidy/checks/misc/include-cleaner>` check by adding option
`DeduplicateFindings` to output one finding per symbol occurrence.

- Improved :doc:`misc-include-cleaner
<clang-tidy/checks/misc/include-cleaner>` check to avoid fixes insert
same include header multiple times.

- Improved :doc:`misc-redundant-expression
<clang-tidy/checks/misc/redundant-expression>` check to ignore
false-positives in unevaluated context (e.g., ``decltype``).
Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ headerForAmbiguousStdSymbol(const NamedDecl *ND) {
if (FD->getNumParams() == 1)
// move(T&& t)
return tooling::stdlib::Header::named("<utility>");
if (FD->getNumParams() == 3)
if (FD->getNumParams() == 3 || FD->getNumParams() == 4)
// move(InputIt first, InputIt last, OutputIt dest);
// move(ExecutionPolicy&& policy, ForwardIt1 first,
// ForwardIt1 last, ForwardIt2 d_first);
return tooling::stdlib::Header::named("<algorithm>");
} else if (FName == "remove") {
if (FD->getNumParams() == 1)
Expand Down
10 changes: 10 additions & 0 deletions clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,16 @@ TEST_F(HeadersForSymbolTest, AmbiguousStdSymbols) {
"move",
"<algorithm>",
},
{
R"cpp(
namespace std {
template<class ExecutionPolicy, class ForwardIt1, class ForwardIt2>
ForwardIt2 move(ExecutionPolicy&& policy,
ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first);
})cpp",
"move",
"<algorithm>",
},
{
R"cpp(
namespace std {
Expand Down
32 changes: 32 additions & 0 deletions clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,38 @@ int QuxResult = qux();
)"}}));
}


TEST(IncludeCleanerCheckTest, MultipleTimeMissingInclude) {
const char *PreCode = R"(
#include "bar.h"

int BarResult = bar();
int BazResult_0 = baz_0();
int BazResult_1 = baz_1();
)";
const char *PostCode = R"(
#include "bar.h"
#include "baz.h"

int BarResult = bar();
int BazResult_0 = baz_0();
int BazResult_1 = baz_1();
)";

std::vector<ClangTidyError> Errors;
EXPECT_EQ(PostCode,
runCheckOnCode<IncludeCleanerCheck>(
PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
{{"bar.h", R"(#pragma once
#include "baz.h"
int bar();
)"},
{"baz.h", R"(#pragma once
int baz_0();
int baz_1();
)"}}));
}

TEST(IncludeCleanerCheckTest, SystemMissingIncludes) {
const char *PreCode = R"(
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -5846,9 +5846,9 @@ def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, Group<
def mno_retpoline_external_thunk : Flag<["-"], "mno-retpoline-external-thunk">, Group<m_x86_Features_Group>;
def mvzeroupper : Flag<["-"], "mvzeroupper">, Group<m_x86_Features_Group>;
def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group<m_x86_Features_Group>;
def mno_gather : Flag<["-"], "mno-gather">, Group<m_x86_Features_Group>,
def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>,
HelpText<"Disable generation of gather instructions in auto-vectorization(x86 only)">;
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_x86_Features_Group>,
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>,
HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">;
} // let Flags = [TargetSpecific]

Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ ControlFlowContext::build(const Decl &D, Stmt &S, ASTContext &C) {
std::make_error_code(std::errc::invalid_argument),
"Cannot analyze templated declarations");

// The shape of certain elements of the AST can vary depending on the
// language. We currently only support C++.
if (!C.getLangOpts().CPlusPlus)
return llvm::createStringError(
std::make_error_code(std::errc::invalid_argument),
"Can only analyze C++");

CFG::BuildOptions Options;
Options.PruneTriviallyFalseEdges = true;
Options.AddImplicitDtors = true;
Expand Down
4 changes: 0 additions & 4 deletions clang/unittests/Analysis/FlowSensitive/TestingSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,6 @@ inline Value *getFieldValue(const RecordStorageLocation *Loc,

/// Returns the value of a `Field` on a `Struct.
/// Returns null if `Struct` is null.
///
/// Note: This function currently does not use the `Env` parameter, but it will
/// soon be needed to look up the `Value` when `setChild()` changes to return a
/// `StorageLocation *`.
inline Value *getFieldValue(const RecordValue *Struct, const ValueDecl &Field,
const Environment &Env) {
if (Struct == nullptr)
Expand Down
20 changes: 15 additions & 5 deletions clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ const Formula &getFormula(const ValueDecl &D, const Environment &Env) {
return cast<BoolValue>(Env.getValue(D))->formula();
}

TEST(TransferTest, CNotSupported) {
std::string Code = R"(
void target() {}
)";
ASSERT_THAT_ERROR(checkDataflowWithNoopAnalysis(
Code, [](const auto &, auto &) {}, {BuiltinOptions{}},
LangStandard::lang_c89),
llvm::FailedWithMessage("Can only analyze C++"));
}

TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
std::string Code = R"(
void target() {
Expand Down Expand Up @@ -2860,11 +2870,11 @@ TEST(TransferTest, AggregateInitialization) {

// Check that fields initialized in an initializer list are always
// modeled in other instances of the same type.
const auto &OtherBVal =
getValueForDecl<RecordValue>(ASTCtx, Env, "OtherB");
EXPECT_THAT(OtherBVal.getChild(*BarDecl), NotNull());
EXPECT_THAT(OtherBVal.getChild(*BazDecl), NotNull());
EXPECT_THAT(OtherBVal.getChild(*QuxDecl), NotNull());
const auto &OtherBLoc =
getLocForDecl<RecordStorageLocation>(ASTCtx, Env, "OtherB");
EXPECT_THAT(OtherBLoc.getChild(*BarDecl), NotNull());
EXPECT_THAT(OtherBLoc.getChild(*BazDecl), NotNull());
EXPECT_THAT(OtherBLoc.getChild(*QuxDecl), NotNull());
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/scudo/standalone/combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ class Allocator {
map(/*Addr=*/nullptr,
roundUp(ringBufferSizeInBytes(AllocationRingBufferSize),
getPageSizeCached()),
"AllocatorRingBuffer"));
"scudo:ring_buffer"));
auto *RingBuffer = reinterpret_cast<AllocationRingBuffer *>(RawRingBuffer);
RingBuffer->Size = AllocationRingBufferSize;
static_assert(sizeof(AllocationRingBuffer) %
Expand Down
Loading