Skip to content

Commit

Permalink
[AutoBump] Merge with c57b9f5 (Sep 21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorickert committed Dec 13, 2024
2 parents b56783c + c57b9f5 commit a15136b
Show file tree
Hide file tree
Showing 433 changed files with 12,853 additions and 7,622 deletions.
1 change: 1 addition & 0 deletions bolt/include/bolt/Core/BinaryBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "bolt/Core/MCPlus.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorOr.h"
Expand Down
7 changes: 3 additions & 4 deletions clang-tools-extra/clang-move/HelperDeclRefGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ HelperDeclRefGraph::getReachableNodes(const Decl *Root) const {
llvm::DenseSet<const CallGraphNode *> ConnectedNodes;
std::function<void(const CallGraphNode *)> VisitNode =
[&](const CallGraphNode *Node) {
if (ConnectedNodes.count(Node))
if (!ConnectedNodes.insert(Node).second)
return;
ConnectedNodes.insert(Node);
for (auto It = Node->begin(), End = Node->end(); It != End; ++It)
VisitNode(*It);
for (const CallGraphNode::CallRecord &Callee : *Node)
VisitNode(Callee);
};

VisitNode(RootNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ void ExpandModularHeadersPPCallbacks::handleModuleFile(
if (!MF)
return;
// Avoid processing a ModuleFile more than once.
if (VisitedModules.count(MF))
if (!VisitedModules.insert(MF).second)
return;
VisitedModules.insert(MF);

// Visit all the input files of this module and mark them to record their
// contents later.
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ DanglingHandleCheck::DanglingHandleCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
HandleClasses(utils::options::parseStringList(Options.get(
"HandleClasses",
"std::basic_string_view;std::experimental::basic_string_view"))),
"HandleClasses", "std::basic_string_view;std::experimental::basic_"
"string_view;std::span"))),
IsAHandle(cxxRecordDecl(hasAnyName(HandleClasses)).bind("handle")) {}

void DanglingHandleCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ PreambleFileStatusCache::getProducingFS(
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
auto File = getUnderlyingFS().openFileForRead(Path, IsText);
openFileForRead(const llvm::Twine &Path) override {
auto File = getUnderlyingFS().openFileForRead(Path);
if (!File || !*File)
return File;
// Eagerly stat opened file, as the followup `status` call on the file
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/ParsedAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ class TidyDiagnosticGroups {
llvm::StringRef Check;
while (!Checks.empty()) {
std::tie(Check, Checks) = Checks.split(',');
Check = Check.trim();

if (Check.empty())
continue;

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ class TimerFS : public llvm::vfs::ProxyFileSystem {
: ProxyFileSystem(std::move(FS)) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
openFileForRead(const llvm::Twine &Path) override {
WallTimerRegion T(Timer);
auto FileOr = getUnderlyingFS().openFileForRead(Path, IsText);
auto FileOr = getUnderlyingFS().openFileForRead(Path);
if (!FileOr)
return FileOr;
return std::make_unique<TimerFile>(Timer, std::move(FileOr.get()));
Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/clangd/index/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ struct Symbol {
ImplementationDetail = 1 << 2,
/// Symbol is visible to other files (not e.g. a static helper function).
VisibleOutsideFile = 1 << 3,
/// Symbol has an attached documentation comment.
HasDocComment = 1 << 4
};

SymbolFlag Flags = SymbolFlag::None;

/// FIXME: also add deprecation message and fixit?
};

Expand Down
57 changes: 47 additions & 10 deletions clang-tools-extra/clangd/index/SymbolCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,21 @@ bool SymbolCollector::handleDeclOccurrence(
return true;

const Symbol *BasicSymbol = Symbols.find(ID);
if (isPreferredDeclaration(*OriginalDecl, Roles))
bool SkipDocCheckInDef = false;
if (isPreferredDeclaration(*OriginalDecl, Roles)) {
// If OriginalDecl is preferred, replace/create the existing canonical
// declaration (e.g. a class forward declaration). There should be at most
// one duplicate as we expect to see only one preferred declaration per
// TU, because in practice they are definitions.
BasicSymbol = addDeclaration(*OriginalDecl, std::move(ID), IsMainFileOnly);
else if (!BasicSymbol || DeclIsCanonical)
SkipDocCheckInDef = true;
} else if (!BasicSymbol || DeclIsCanonical) {
BasicSymbol = addDeclaration(*ND, std::move(ID), IsMainFileOnly);
SkipDocCheckInDef = true;
}

if (Roles & static_cast<unsigned>(index::SymbolRole::Definition))
addDefinition(*OriginalDecl, *BasicSymbol);
addDefinition(*OriginalDecl, *BasicSymbol, SkipDocCheckInDef);

return true;
}
Expand Down Expand Up @@ -1025,16 +1029,28 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
*CompletionTUInfo,
/*IncludeBriefComments*/ false);
std::string Documentation =
formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
/*CommentsFromHeaders=*/true));
std::string DocComment;
std::string Documentation;
bool AlreadyHasDoc = S.Flags & Symbol::HasDocComment;
if (!AlreadyHasDoc) {
DocComment = getDocComment(Ctx, SymbolCompletion,
/*CommentsFromHeaders=*/true);
Documentation = formatDocumentation(*CCS, DocComment);
}
const auto UpdateDoc = [&] {
if (!AlreadyHasDoc) {
if (!DocComment.empty())
S.Flags |= Symbol::HasDocComment;
S.Documentation = Documentation;
}
};
if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
if (Opts.StoreAllDocumentation)
S.Documentation = Documentation;
UpdateDoc();
Symbols.insert(S);
return Symbols.find(S.ID);
}
S.Documentation = Documentation;
UpdateDoc();
std::string Signature;
std::string SnippetSuffix;
getSignature(*CCS, &Signature, &SnippetSuffix, SymbolCompletion.Kind,
Expand All @@ -1058,8 +1074,8 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
return Symbols.find(S.ID);
}

void SymbolCollector::addDefinition(const NamedDecl &ND,
const Symbol &DeclSym) {
void SymbolCollector::addDefinition(const NamedDecl &ND, const Symbol &DeclSym,
bool SkipDocCheck) {
if (DeclSym.Definition)
return;
const auto &SM = ND.getASTContext().getSourceManager();
Expand All @@ -1074,6 +1090,27 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
Symbol S = DeclSym;
// FIXME: use the result to filter out symbols.
S.Definition = *DefLoc;

std::string DocComment;
std::string Documentation;
if (!SkipDocCheck && !(S.Flags & Symbol::HasDocComment) &&
(llvm::isa<FunctionDecl>(ND) || llvm::isa<CXXMethodDecl>(ND))) {
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
*CompletionTUInfo,
/*IncludeBriefComments*/ false);
DocComment = getDocComment(ND.getASTContext(), SymbolCompletion,
/*CommentsFromHeaders=*/true);
if (!S.Documentation.empty())
Documentation = S.Documentation.str() + '\n' + DocComment;
else
Documentation = formatDocumentation(*CCS, DocComment);
if (!DocComment.empty())
S.Flags |= Symbol::HasDocComment;
S.Documentation = Documentation;
}

Symbols.insert(S);
}

Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clangd/index/SymbolCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class SymbolCollector : public index::IndexDataConsumer {
private:
const Symbol *addDeclaration(const NamedDecl &, SymbolID,
bool IsMainFileSymbol);
void addDefinition(const NamedDecl &, const Symbol &DeclSymbol);
void addDefinition(const NamedDecl &, const Symbol &DeclSymbol,
bool SkipDocCheck);
void processRelations(const NamedDecl &ND, const SymbolID &ID,
ArrayRef<index::SymbolRelation> Relations);

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/support/ThreadsafeFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
: ProxyFileSystem(std::move(FS)) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine &InPath, bool IsText = true) override {
openFileForRead(const llvm::Twine &InPath) override {
llvm::SmallString<128> Path;
InPath.toVector(Path);

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/unittests/ClangdTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ TEST(ClangdTests, PreambleVFSStatCache) {
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const Twine &Path, bool IsText = true) override {
openFileForRead(const Twine &Path) override {
++CountStats[llvm::sys::path::filename(Path.str())];
return ProxyFileSystem::openFileForRead(Path);
}
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ TEST(DiagnosticTest, ClangTidyEnablesClangWarning) {
TU.ExtraArgs = {"-Wunused"};
TU.ClangTidyProvider = addClangArgs({"-Wno-unused"}, {});
EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());

TU.ExtraArgs = {"-Wno-unused"};
TU.ClangTidyProvider = addClangArgs({"-Wunused"}, {"-*, clang-diagnostic-*"});
EXPECT_THAT(TU.build().getDiagnostics(), SizeIs(1));
}

TEST(DiagnosticTest, LongFixMessages) {
Expand Down
52 changes: 52 additions & 0 deletions clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,58 @@ TEST_F(SymbolCollectorTest, Documentation) {
forCodeCompletion(false))));
}

TEST_F(SymbolCollectorTest, DocumentationInMain) {
const std::string Header = R"(
// doc Foo
class Foo {
void f();
};
)";
const std::string Main = R"(
// doc f
void Foo::f() {}
)";
CollectorOpts.StoreAllDocumentation = true;
runSymbolCollector(Header, Main);
EXPECT_THAT(Symbols,
UnorderedElementsAre(
AllOf(qName("Foo"), doc("doc Foo"), forCodeCompletion(true)),
AllOf(qName("Foo::f"), doc("doc f"), returnType(""),
forCodeCompletion(false))));
}

TEST_F(SymbolCollectorTest, DocumentationAtDeclThenDef) {
const std::string Header = R"(
class Foo {
// doc f decl
void f();
};
)";
const std::string Main = R"(
// doc f def
void Foo::f() {}
)";
CollectorOpts.StoreAllDocumentation = true;
runSymbolCollector(Header, Main);
EXPECT_THAT(Symbols,
UnorderedElementsAre(AllOf(qName("Foo")),
AllOf(qName("Foo::f"), doc("doc f decl"))));
}

TEST_F(SymbolCollectorTest, DocumentationAtDefThenDecl) {
const std::string Header = R"(
// doc f def
void f() {}
// doc f decl
void f();
)";
CollectorOpts.StoreAllDocumentation = true;
runSymbolCollector(Header, "" /*Main*/);
EXPECT_THAT(Symbols,
UnorderedElementsAre(AllOf(qName("f"), doc("doc f def"))));
}

TEST_F(SymbolCollectorTest, ClassMembers) {
const std::string Header = R"(
class Foo {
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 @@ -117,6 +117,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
the offending code with ``reinterpret_cast``, to more clearly express intent.

- Improved :doc:`bugprone-dangling-handle
<clang-tidy/checks/bugprone/dangling-handle>` check to treat `std::span` as a
handle class.

- Improved :doc:`bugprone-forwarding-reference-overload
<clang-tidy/checks/bugprone/forwarding-reference-overload>` check by fixing
a crash when determining if an ``enable_if[_t]`` was found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ Examples:
return Array;
}

span<int> g() {
array<int, 1> V;
return {V};
int Array[10]{};
return {Array};
}

Options
-------

.. option:: HandleClasses

A semicolon-separated list of class names that should be treated as handles.
By default only ``std::basic_string_view`` and
``std::experimental::basic_string_view`` are considered.
By default only ``std::basic_string_view``,
``std::experimental::basic_string_view`` and ``std::span`` are considered.
25 changes: 25 additions & 0 deletions clang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# C language Family Front-end

Welcome to Clang.

This is a compiler front-end for the C family of languages (C, C++ and Objective-C) which is built as part of the LLVM compiler infrastructure project.

Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of different source-level tools. One example of this is the Clang Static Analyzer.

If you're interested in more (including how to build Clang) it is best to read the relevant websites. Here are some pointers:

* Information on Clang:     http://clang.llvm.org/

* Building and using Clang: http://clang.llvm.org/get_started.html

* Clang Static Analyzer: http://clang-analyzer.llvm.org/

* Information on the LLVM project: http://llvm.org/

* If you have questions or comments about Clang, a great place to disucss them is on the Clang forums:    

[Clang Frontend - LLVM Discussion Forums](https://discourse.llvm.org/c/clang/)

* If you find a bug in Clang, please file it in the LLVM bug tracker:

https://github.com/llvm/llvm-project/issues
26 changes: 0 additions & 26 deletions clang/README.txt

This file was deleted.

4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ Bug Fixes to C++ Support
- Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
- Fixed an assertion failure in debug mode, and potential crashes in release mode, when
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
- Clang now uses the correct set of template argument lists when comparing the constraints of
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
a class template. (#GH102320)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading

0 comments on commit a15136b

Please sign in to comment.