Skip to content

Commit 3787844

Browse files
authored
Merge pull request #423 from Xilinx/bump_to_c57b9f5a
[AutoBump] Merge with c57b9f5 (Sep 21) (9)
2 parents d061bda + a15136b commit 3787844

File tree

433 files changed

+12853
-7622
lines changed

Some content is hidden

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

433 files changed

+12853
-7622
lines changed

bolt/include/bolt/Core/BinaryBasicBlock.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "bolt/Core/MCPlus.h"
2020
#include "llvm/ADT/GraphTraits.h"
2121
#include "llvm/ADT/StringRef.h"
22+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
2223
#include "llvm/MC/MCInst.h"
2324
#include "llvm/MC/MCSymbol.h"
2425
#include "llvm/Support/ErrorOr.h"

clang-tools-extra/clang-move/HelperDeclRefGraph.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ HelperDeclRefGraph::getReachableNodes(const Decl *Root) const {
7676
llvm::DenseSet<const CallGraphNode *> ConnectedNodes;
7777
std::function<void(const CallGraphNode *)> VisitNode =
7878
[&](const CallGraphNode *Node) {
79-
if (ConnectedNodes.count(Node))
79+
if (!ConnectedNodes.insert(Node).second)
8080
return;
81-
ConnectedNodes.insert(Node);
82-
for (auto It = Node->begin(), End = Node->end(); It != End; ++It)
83-
VisitNode(*It);
81+
for (const CallGraphNode::CallRecord &Callee : *Node)
82+
VisitNode(Callee);
8483
};
8584

8685
VisitNode(RootNode);

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ void ExpandModularHeadersPPCallbacks::handleModuleFile(
116116
if (!MF)
117117
return;
118118
// Avoid processing a ModuleFile more than once.
119-
if (VisitedModules.count(MF))
119+
if (!VisitedModules.insert(MF).second)
120120
return;
121-
VisitedModules.insert(MF);
122121

123122
// Visit all the input files of this module and mark them to record their
124123
// contents later.

clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ DanglingHandleCheck::DanglingHandleCheck(StringRef Name,
9797
ClangTidyContext *Context)
9898
: ClangTidyCheck(Name, Context),
9999
HandleClasses(utils::options::parseStringList(Options.get(
100-
"HandleClasses",
101-
"std::basic_string_view;std::experimental::basic_string_view"))),
100+
"HandleClasses", "std::basic_string_view;std::experimental::basic_"
101+
"string_view;std::span"))),
102102
IsAHandle(cxxRecordDecl(hasAnyName(HandleClasses)).bind("handle")) {}
103103

104104
void DanglingHandleCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

clang-tools-extra/clangd/FS.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ PreambleFileStatusCache::getProducingFS(
6464
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
6565

6666
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
67-
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
68-
auto File = getUnderlyingFS().openFileForRead(Path, IsText);
67+
openFileForRead(const llvm::Twine &Path) override {
68+
auto File = getUnderlyingFS().openFileForRead(Path);
6969
if (!File || !*File)
7070
return File;
7171
// Eagerly stat opened file, as the followup `status` call on the file

clang-tools-extra/clangd/ParsedAST.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ class TidyDiagnosticGroups {
280280
llvm::StringRef Check;
281281
while (!Checks.empty()) {
282282
std::tie(Check, Checks) = Checks.split(',');
283+
Check = Check.trim();
284+
283285
if (Check.empty())
284286
continue;
285287

clang-tools-extra/clangd/Preamble.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ class TimerFS : public llvm::vfs::ProxyFileSystem {
479479
: ProxyFileSystem(std::move(FS)) {}
480480

481481
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
482-
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
482+
openFileForRead(const llvm::Twine &Path) override {
483483
WallTimerRegion T(Timer);
484-
auto FileOr = getUnderlyingFS().openFileForRead(Path, IsText);
484+
auto FileOr = getUnderlyingFS().openFileForRead(Path);
485485
if (!FileOr)
486486
return FileOr;
487487
return std::make_unique<TimerFile>(Timer, std::move(FileOr.get()));

clang-tools-extra/clangd/index/Symbol.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ struct Symbol {
145145
ImplementationDetail = 1 << 2,
146146
/// Symbol is visible to other files (not e.g. a static helper function).
147147
VisibleOutsideFile = 1 << 3,
148+
/// Symbol has an attached documentation comment.
149+
HasDocComment = 1 << 4
148150
};
149-
150151
SymbolFlag Flags = SymbolFlag::None;
152+
151153
/// FIXME: also add deprecation message and fixit?
152154
};
153155

clang-tools-extra/clangd/index/SymbolCollector.cpp

+47-10
Original file line numberDiff line numberDiff line change
@@ -635,17 +635,21 @@ bool SymbolCollector::handleDeclOccurrence(
635635
return true;
636636

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

647651
if (Roles & static_cast<unsigned>(index::SymbolRole::Definition))
648-
addDefinition(*OriginalDecl, *BasicSymbol);
652+
addDefinition(*OriginalDecl, *BasicSymbol, SkipDocCheckInDef);
649653

650654
return true;
651655
}
@@ -1025,16 +1029,28 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
10251029
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
10261030
*CompletionTUInfo,
10271031
/*IncludeBriefComments*/ false);
1028-
std::string Documentation =
1029-
formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
1030-
/*CommentsFromHeaders=*/true));
1032+
std::string DocComment;
1033+
std::string Documentation;
1034+
bool AlreadyHasDoc = S.Flags & Symbol::HasDocComment;
1035+
if (!AlreadyHasDoc) {
1036+
DocComment = getDocComment(Ctx, SymbolCompletion,
1037+
/*CommentsFromHeaders=*/true);
1038+
Documentation = formatDocumentation(*CCS, DocComment);
1039+
}
1040+
const auto UpdateDoc = [&] {
1041+
if (!AlreadyHasDoc) {
1042+
if (!DocComment.empty())
1043+
S.Flags |= Symbol::HasDocComment;
1044+
S.Documentation = Documentation;
1045+
}
1046+
};
10311047
if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
10321048
if (Opts.StoreAllDocumentation)
1033-
S.Documentation = Documentation;
1049+
UpdateDoc();
10341050
Symbols.insert(S);
10351051
return Symbols.find(S.ID);
10361052
}
1037-
S.Documentation = Documentation;
1053+
UpdateDoc();
10381054
std::string Signature;
10391055
std::string SnippetSuffix;
10401056
getSignature(*CCS, &Signature, &SnippetSuffix, SymbolCompletion.Kind,
@@ -1058,8 +1074,8 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
10581074
return Symbols.find(S.ID);
10591075
}
10601076

1061-
void SymbolCollector::addDefinition(const NamedDecl &ND,
1062-
const Symbol &DeclSym) {
1077+
void SymbolCollector::addDefinition(const NamedDecl &ND, const Symbol &DeclSym,
1078+
bool SkipDocCheck) {
10631079
if (DeclSym.Definition)
10641080
return;
10651081
const auto &SM = ND.getASTContext().getSourceManager();
@@ -1074,6 +1090,27 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
10741090
Symbol S = DeclSym;
10751091
// FIXME: use the result to filter out symbols.
10761092
S.Definition = *DefLoc;
1093+
1094+
std::string DocComment;
1095+
std::string Documentation;
1096+
if (!SkipDocCheck && !(S.Flags & Symbol::HasDocComment) &&
1097+
(llvm::isa<FunctionDecl>(ND) || llvm::isa<CXXMethodDecl>(ND))) {
1098+
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
1099+
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
1100+
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
1101+
*CompletionTUInfo,
1102+
/*IncludeBriefComments*/ false);
1103+
DocComment = getDocComment(ND.getASTContext(), SymbolCompletion,
1104+
/*CommentsFromHeaders=*/true);
1105+
if (!S.Documentation.empty())
1106+
Documentation = S.Documentation.str() + '\n' + DocComment;
1107+
else
1108+
Documentation = formatDocumentation(*CCS, DocComment);
1109+
if (!DocComment.empty())
1110+
S.Flags |= Symbol::HasDocComment;
1111+
S.Documentation = Documentation;
1112+
}
1113+
10771114
Symbols.insert(S);
10781115
}
10791116

clang-tools-extra/clangd/index/SymbolCollector.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ class SymbolCollector : public index::IndexDataConsumer {
161161
private:
162162
const Symbol *addDeclaration(const NamedDecl &, SymbolID,
163163
bool IsMainFileSymbol);
164-
void addDefinition(const NamedDecl &, const Symbol &DeclSymbol);
164+
void addDefinition(const NamedDecl &, const Symbol &DeclSymbol,
165+
bool SkipDocCheck);
165166
void processRelations(const NamedDecl &ND, const SymbolID &ID,
166167
ArrayRef<index::SymbolRelation> Relations);
167168

clang-tools-extra/clangd/support/ThreadsafeFS.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
2929
: ProxyFileSystem(std::move(FS)) {}
3030

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

clang-tools-extra/clangd/unittests/ClangdTests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ TEST(ClangdTests, PreambleVFSStatCache) {
10101010
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}
10111011

10121012
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
1013-
openFileForRead(const Twine &Path, bool IsText = true) override {
1013+
openFileForRead(const Twine &Path) override {
10141014
++CountStats[llvm::sys::path::filename(Path.str())];
10151015
return ProxyFileSystem::openFileForRead(Path);
10161016
}

clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ TEST(DiagnosticTest, ClangTidyEnablesClangWarning) {
748748
TU.ExtraArgs = {"-Wunused"};
749749
TU.ClangTidyProvider = addClangArgs({"-Wno-unused"}, {});
750750
EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
751+
752+
TU.ExtraArgs = {"-Wno-unused"};
753+
TU.ClangTidyProvider = addClangArgs({"-Wunused"}, {"-*, clang-diagnostic-*"});
754+
EXPECT_THAT(TU.build().getDiagnostics(), SizeIs(1));
751755
}
752756

753757
TEST(DiagnosticTest, LongFixMessages) {

clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,58 @@ TEST_F(SymbolCollectorTest, Documentation) {
14771477
forCodeCompletion(false))));
14781478
}
14791479

1480+
TEST_F(SymbolCollectorTest, DocumentationInMain) {
1481+
const std::string Header = R"(
1482+
// doc Foo
1483+
class Foo {
1484+
void f();
1485+
};
1486+
)";
1487+
const std::string Main = R"(
1488+
// doc f
1489+
void Foo::f() {}
1490+
)";
1491+
CollectorOpts.StoreAllDocumentation = true;
1492+
runSymbolCollector(Header, Main);
1493+
EXPECT_THAT(Symbols,
1494+
UnorderedElementsAre(
1495+
AllOf(qName("Foo"), doc("doc Foo"), forCodeCompletion(true)),
1496+
AllOf(qName("Foo::f"), doc("doc f"), returnType(""),
1497+
forCodeCompletion(false))));
1498+
}
1499+
1500+
TEST_F(SymbolCollectorTest, DocumentationAtDeclThenDef) {
1501+
const std::string Header = R"(
1502+
class Foo {
1503+
// doc f decl
1504+
void f();
1505+
};
1506+
)";
1507+
const std::string Main = R"(
1508+
// doc f def
1509+
void Foo::f() {}
1510+
)";
1511+
CollectorOpts.StoreAllDocumentation = true;
1512+
runSymbolCollector(Header, Main);
1513+
EXPECT_THAT(Symbols,
1514+
UnorderedElementsAre(AllOf(qName("Foo")),
1515+
AllOf(qName("Foo::f"), doc("doc f decl"))));
1516+
}
1517+
1518+
TEST_F(SymbolCollectorTest, DocumentationAtDefThenDecl) {
1519+
const std::string Header = R"(
1520+
// doc f def
1521+
void f() {}
1522+
1523+
// doc f decl
1524+
void f();
1525+
)";
1526+
CollectorOpts.StoreAllDocumentation = true;
1527+
runSymbolCollector(Header, "" /*Main*/);
1528+
EXPECT_THAT(Symbols,
1529+
UnorderedElementsAre(AllOf(qName("f"), doc("doc f def"))));
1530+
}
1531+
14801532
TEST_F(SymbolCollectorTest, ClassMembers) {
14811533
const std::string Header = R"(
14821534
class Foo {

clang-tools-extra/docs/ReleaseNotes.rst

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ Changes in existing checks
117117
<clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
118118
the offending code with ``reinterpret_cast``, to more clearly express intent.
119119

120+
- Improved :doc:`bugprone-dangling-handle
121+
<clang-tidy/checks/bugprone/dangling-handle>` check to treat `std::span` as a
122+
handle class.
123+
120124
- Improved :doc:`bugprone-forwarding-reference-overload
121125
<clang-tidy/checks/bugprone/forwarding-reference-overload>` check by fixing
122126
a crash when determining if an ``enable_if[_t]`` was found.

clang-tools-extra/docs/clang-tidy/checks/bugprone/dangling-handle.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ Examples:
2828
return Array;
2929
}
3030

31+
span<int> g() {
32+
array<int, 1> V;
33+
return {V};
34+
int Array[10]{};
35+
return {Array};
36+
}
37+
3138
Options
3239
-------
3340

3441
.. option:: HandleClasses
3542

3643
A semicolon-separated list of class names that should be treated as handles.
37-
By default only ``std::basic_string_view`` and
38-
``std::experimental::basic_string_view`` are considered.
44+
By default only ``std::basic_string_view``,
45+
``std::experimental::basic_string_view`` and ``std::span`` are considered.

clang/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# C language Family Front-end
2+
3+
Welcome to Clang.
4+
5+
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.
6+
7+
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.
8+
9+
If you're interested in more (including how to build Clang) it is best to read the relevant websites. Here are some pointers:
10+
11+
* Information on Clang:     http://clang.llvm.org/
12+
13+
* Building and using Clang: http://clang.llvm.org/get_started.html
14+
15+
* Clang Static Analyzer: http://clang-analyzer.llvm.org/
16+
17+
* Information on the LLVM project: http://llvm.org/
18+
19+
* If you have questions or comments about Clang, a great place to disucss them is on the Clang forums:    
20+
21+
[Clang Frontend - LLVM Discussion Forums](https://discourse.llvm.org/c/clang/)
22+
23+
* If you find a bug in Clang, please file it in the LLVM bug tracker:
24+
25+
https://github.com/llvm/llvm-project/issues

clang/README.txt

-26
This file was deleted.

clang/docs/ReleaseNotes.rst

+4
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ Bug Fixes to C++ Support
403403
- Avoided a redundant friend declaration instantiation under a certain ``consteval`` context. (#GH107175)
404404
- Fixed an assertion failure in debug mode, and potential crashes in release mode, when
405405
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
406+
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
407+
- Clang now uses the correct set of template argument lists when comparing the constraints of
408+
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
409+
a class template. (#GH102320)
406410

407411
Bug Fixes to AST Handling
408412
^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)