Skip to content

Commit 390d485

Browse files
committed
Merge from 'master' to 'sycl-web' (#121)
CONFLICT (content): Merge conflict in clang/lib/Analysis/CallGraph.cpp
2 parents 6336283 + d68c7b8 commit 390d485

File tree

1,020 files changed

+16464
-5904
lines changed

Some content is hidden

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

1,020 files changed

+16464
-5904
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void HelperDeclRefGraph::print(raw_ostream &OS) const {
2727
OS << " (" << N << ") ";
2828
OS << " calls: ";
2929
for (auto CI = N->begin(), CE = N->end(); CI != CE; ++CI) {
30-
(*CI)->print(OS);
30+
CI->Callee->print(OS);
3131
OS << " (" << CI << ") ";
3232
}
3333
OS << '\n';
@@ -48,7 +48,7 @@ void HelperDeclRefGraph::addEdge(const Decl *Caller, const Decl *Callee) {
4848
// Allocate a new node, mark it as root, and process it's calls.
4949
CallGraphNode *CallerNode = getOrInsertNode(const_cast<Decl *>(Caller));
5050
CallGraphNode *CalleeNode = getOrInsertNode(const_cast<Decl *>(Callee));
51-
CallerNode->addCallee(CalleeNode);
51+
CallerNode->addCallee({CalleeNode, /*CallExpr=*/nullptr});
5252
}
5353

5454
void HelperDeclRefGraph::dump() const { print(llvm::errs()); }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ static std::string getCondVarNames(const Stmt *Cond) {
153153
}
154154

155155
static bool isKnownFalse(const Expr &Cond, const ASTContext &Ctx) {
156+
if (Cond.isValueDependent())
157+
return false;
156158
bool Result = false;
157159
if (Cond.EvaluateAsBooleanCondition(Result, Ctx))
158160
return !Result;

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,8 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const {
18501850
if (InsertInclude && InsertInclude->Insertion)
18511851
LSP.additionalTextEdits.push_back(*InsertInclude->Insertion);
18521852

1853+
LSP.score = Score.ExcludingName;
1854+
18531855
return LSP;
18541856
}
18551857

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ llvm::json::Value toJSON(const CompletionItem &CI) {
869869
Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
870870
if (CI.deprecated)
871871
Result["deprecated"] = CI.deprecated;
872+
Result["score"] = CI.score;
872873
return std::move(Result);
873874
}
874875

clang-tools-extra/clangd/Protocol.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,13 @@ struct CompletionItem {
10941094
/// Indicates if this item is deprecated.
10951095
bool deprecated = false;
10961096

1097+
/// This is Clangd extension.
1098+
/// The score that Clangd calculates to rank completion items. This score can
1099+
/// be used to adjust the ranking on the client side.
1100+
/// NOTE: This excludes fuzzy matching score which is typically calculated on
1101+
/// the client side.
1102+
float score = 0.f;
1103+
10971104
// TODO(krasimir): The following optional fields defined by the language
10981105
// server protocol are unsupported:
10991106
//

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace clangd {
1414
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, RefKind K) {
1515
if (K == RefKind::Unknown)
1616
return OS << "Unknown";
17-
static constexpr std::array<const char *, 3> Messages = {"Decl", "Def",
18-
"Ref"};
17+
static constexpr std::array<const char *, 4> Messages = {"Decl", "Def", "Ref",
18+
"Spelled"};
1919
bool VisitedOnce = false;
2020
for (unsigned I = 0; I < Messages.size(); ++I) {
2121
if (static_cast<uint8_t>(K) & 1u << I) {

clang-tools-extra/clangd/refactor/Rename.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,38 @@ Range toRange(const SymbolLocation &L) {
297297
return R;
298298
}
299299

300+
std::vector<const CXXConstructorDecl *> getConstructors(const NamedDecl *ND) {
301+
std::vector<const CXXConstructorDecl *> Ctors;
302+
if (const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
303+
if (!RD->hasUserDeclaredConstructor())
304+
return {};
305+
for (const CXXConstructorDecl *Ctor : RD->ctors())
306+
Ctors.push_back(Ctor);
307+
for (const auto *D : RD->decls()) {
308+
if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
309+
if (const auto *Ctor =
310+
dyn_cast<CXXConstructorDecl>(FTD->getTemplatedDecl()))
311+
Ctors.push_back(Ctor);
312+
}
313+
}
314+
return Ctors;
315+
}
316+
300317
// Return all rename occurrences (using the index) outside of the main file,
301318
// grouped by the absolute file path.
302319
llvm::Expected<llvm::StringMap<std::vector<Range>>>
303320
findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
304321
llvm::StringRef MainFile, const SymbolIndex &Index) {
305322
RefsRequest RQuest;
306323
RQuest.IDs.insert(*getSymbolID(&RenameDecl));
324+
// Classes and their constructors are different symbols, and have different
325+
// symbol ID.
326+
// When querying references for a class, clangd's own index will also return
327+
// references of the corresponding class constructors, but this is not true
328+
// for all index backends, e.g. kythe, so we add all constructors to the query
329+
// request.
330+
for (const auto *Ctor : getConstructors(&RenameDecl))
331+
RQuest.IDs.insert(*getSymbolID(Ctor));
307332

308333
// Absolute file path => rename occurrences in that file.
309334
llvm::StringMap<std::vector<Range>> AffectedFiles;

clang-tools-extra/clangd/test/completion-auto-trigger.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# CHECK-NEXT: "insertTextFormat": 1,
2525
# CHECK-NEXT: "kind": 5,
2626
# CHECK-NEXT: "label": " size",
27+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
2728
# CHECK-NEXT: "sortText": "{{.*}}size",
2829
# CHECK-NEXT: "textEdit": {
2930
# CHECK-NEXT: "newText": "size",
@@ -46,6 +47,7 @@
4647
# CHECK-NEXT: "insertTextFormat": 1,
4748
# CHECK-NEXT: "kind": 10,
4849
# CHECK-NEXT: "label": " default_capacity",
50+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
4951
# CHECK-NEXT: "sortText": "{{.*}}default_capacity",
5052
# CHECK-NEXT: "textEdit": {
5153
# CHECK-NEXT: "newText": "default_capacity",
@@ -86,6 +88,7 @@
8688
# CHECK-NEXT: "insertTextFormat": 1,
8789
# CHECK-NEXT: "kind": 6,
8890
# CHECK-NEXT: "label": " ns_member",
91+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
8992
# CHECK-NEXT: "sortText": "{{.*}}ns_member",
9093
# CHECK-NEXT: "textEdit": {
9194
# CHECK-NEXT: "newText": "ns_member",

clang-tools-extra/clangd/test/completion-snippets.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# CHECK-NEXT: "insertTextFormat": 2,
3434
# CHECK-NEXT: "kind": 3,
3535
# CHECK-NEXT: "label": " func_with_args(int a, int b)",
36+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
3637
# CHECK-NEXT: "sortText": "{{.*}}func_with_args"
3738
# CHECK-NEXT: "textEdit": {
3839
# CHECK-NEXT: "newText": "func_with_args(${1:int a}, ${2:int b})",

clang-tools-extra/clangd/test/completion.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# CHECK-NEXT: "insertTextFormat": 1,
1818
# CHECK-NEXT: "kind": 5,
1919
# CHECK-NEXT: "label": " a",
20+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
2021
# CHECK-NEXT: "sortText": "{{.*}}a"
2122
# CHECK-NEXT: "textEdit": {
2223
# CHECK-NEXT: "newText": "a",
@@ -50,6 +51,7 @@
5051
# CHECK-NEXT: "insertTextFormat": 1,
5152
# CHECK-NEXT: "kind": 5,
5253
# CHECK-NEXT: "label": " b",
54+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
5355
# CHECK-NEXT: "sortText": "{{.*}}b"
5456
# CHECK-NEXT: "textEdit": {
5557
# CHECK-NEXT: "newText": "b",

clang-tools-extra/clangd/test/protocol.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Content-Length: 146
3939
# CHECK-NEXT: "insertTextFormat": 1,
4040
# CHECK-NEXT: "kind": 5,
4141
# CHECK-NEXT: "label": " a",
42+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
4243
# CHECK-NEXT: "sortText": "{{.*}}"
4344
# CHECK: ]
4445
# CHECK-NEXT: }
@@ -68,6 +69,7 @@ Content-Length: 146
6869
# CHECK-NEXT: "insertTextFormat": 1,
6970
# CHECK-NEXT: "kind": 5,
7071
# CHECK-NEXT: "label": " a",
72+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
7173
# CHECK-NEXT: "sortText": "{{.*}}"
7274
# CHECK: ]
7375
# CHECK-NEXT: }
@@ -97,6 +99,7 @@ Content-Length: 146
9799
# CHECK-NEXT: "insertTextFormat": 1,
98100
# CHECK-NEXT: "kind": 5,
99101
# CHECK-NEXT: "label": " a",
102+
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
100103
# CHECK-NEXT: "sortText": "{{.*}}"
101104
# CHECK: ]
102105
# CHECK-NEXT: }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,7 @@ TEST(CompletionTest, Render) {
16271627
Include.Header = "\"foo.h\"";
16281628
C.Kind = CompletionItemKind::Method;
16291629
C.Score.Total = 1.0;
1630+
C.Score.ExcludingName = .5;
16301631
C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
16311632

16321633
CodeCompleteOptions Opts;
@@ -1644,6 +1645,7 @@ TEST(CompletionTest, Render) {
16441645
EXPECT_THAT(R.additionalTextEdits, IsEmpty());
16451646
EXPECT_EQ(R.sortText, sortText(1.0, "x"));
16461647
EXPECT_FALSE(R.deprecated);
1648+
EXPECT_EQ(R.score, .5f);
16471649

16481650
Opts.EnableSnippets = true;
16491651
R = C.render(Opts);

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,50 @@ TEST(CrossFileRenameTests, DirtyBuffer) {
768768
testing::HasSubstr("too many occurrences"));
769769
}
770770

771+
TEST(CrossFileRename, QueryCtorInIndex) {
772+
const auto MainCode = Annotations("F^oo f;");
773+
auto TU = TestTU::withCode(MainCode.code());
774+
TU.HeaderCode = R"cpp(
775+
class Foo {
776+
public:
777+
Foo() = default;
778+
};
779+
)cpp";
780+
auto AST = TU.build();
781+
782+
RefsRequest Req;
783+
class RecordIndex : public SymbolIndex {
784+
public:
785+
RecordIndex(RefsRequest *R) : Out(R) {}
786+
bool refs(const RefsRequest &Req,
787+
llvm::function_ref<void(const Ref &)> Callback) const override {
788+
*Out = Req;
789+
return false;
790+
}
791+
792+
bool fuzzyFind(const FuzzyFindRequest &,
793+
llvm::function_ref<void(const Symbol &)>) const override {
794+
return false;
795+
}
796+
void lookup(const LookupRequest &,
797+
llvm::function_ref<void(const Symbol &)>) const override {}
798+
799+
void relations(const RelationsRequest &,
800+
llvm::function_ref<void(const SymbolID &, const Symbol &)>)
801+
const override {}
802+
size_t estimateMemoryUsage() const override { return 0; }
803+
804+
RefsRequest *Out;
805+
} RIndex(&Req);
806+
auto Results =
807+
rename({MainCode.point(), "NewName", AST, testPath("main.cc"), &RIndex,
808+
/*CrossFile=*/true});
809+
ASSERT_TRUE(bool(Results)) << Results.takeError();
810+
const auto HeaderSymbols = TU.headerSymbols();
811+
EXPECT_THAT(Req.IDs,
812+
testing::Contains(findSymbol(HeaderSymbols, "Foo::Foo").ID));
813+
}
814+
771815
TEST(CrossFileRenameTests, DeduplicateRefsFromIndex) {
772816
auto MainCode = Annotations("int [[^x]] = 2;");
773817
auto MainFilePath = testPath("main.cc");

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def run_test_once(args, extra_args):
159159
diff_output = e.output
160160

161161
print('------------------------------ Fixes -----------------------------\n' +
162-
diff_output.decode() +
162+
diff_output.decode(errors='ignore') +
163163
'\n------------------------------------------------------------------')
164164

165165
if has_check_fixes:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// UNSUPPORTED: system-windows
22

3-
// RUN: not clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s
3+
// RUN: not --crash clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s
44

55
// CHECK: LLVM ERROR: Cannot chdir into ""!

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ add_subdirectory(utils/hmaptool)
874874

875875
if(CLANG_BUILT_STANDALONE)
876876
llvm_distribution_add_targets()
877+
process_llvm_pass_plugins()
877878
endif()
878879

879880
configure_file(

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ if(NOT APPLE)
2424
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
2525
endif()
2626
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
27-
set(CLANG_SPAWN_CC1 ON CACHE BOOL "")
2827
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
2928
set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
3029
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")

clang/docs/LibASTMatchersReference.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7381,11 +7381,11 @@ <h2 id="traversal-matchers">AST Traversal Matchers</h2>
73817381
</pre></td></tr>
73827382

73837383

7384-
<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('traverse1')"><a name="traverse1Anchor">traverse</a></td><td>ast_type_traits::TraversalKind TK, const BindableMatcher&lt;T&gt; InnerMatcher</td></tr>
7384+
<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('traverse1')"><a name="traverse1Anchor">traverse</a></td><td>TraversalKind TK, const BindableMatcher&lt;T&gt; InnerMatcher</td></tr>
73857385
<tr><td colspan="4" class="doc" id="traverse1"><pre></pre></td></tr>
73867386

73877387

7388-
<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>ast_type_traits::TraversalKind TK, const Matcher&lt;T&gt; InnerMatcher</td></tr>
7388+
<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>TraversalKind TK, const Matcher&lt;T&gt; InnerMatcher</td></tr>
73897389
<tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind.
73907390

73917391
Given
@@ -7394,7 +7394,7 @@ <h2 id="traversal-matchers">AST Traversal Matchers</h2>
73947394
int i = 3.0;
73957395
}
73967396
The matcher
7397-
traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
7397+
traverse(TK_IgnoreImplicitCastsAndParentheses,
73987398
varDecl(hasInitializer(floatLiteral().bind("init")))
73997399
)
74007400
matches the variable declaration with "init" bound to the "3.0".

clang/docs/OpenMPSupport.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ implementation.
199199
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
200200
| device extension | clause: reverse_offload | :none:`unclaimed parts` | D52780 |
201201
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
202-
| device extension | clause: atomic_default_mem_rrder | :none:`unclaimed parts` | D53513 |
202+
| device extension | clause: atomic_default_mem_orrder | :good:`done` | D53513 |
203203
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
204204
| device extension | clause: dynamic_allocators | :none:`unclaimed parts` | D53079 |
205205
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
@@ -217,31 +217,31 @@ implementation.
217217
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
218218
| device extension | pointer attachment | :none:`unclaimed` | |
219219
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
220-
| atomic extension | hints for the atomic construct | :part:`worked on` | D51233 |
220+
| atomic extension | hints for the atomic construct | :good:`done` | D51233 |
221221
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
222222
| base language | C11 support | :none:`unclaimed` | |
223223
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
224224
| base language | C++11/14/17 support | :part:`worked on` | |
225225
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
226226
| base language | lambda support | :good:`done` | |
227227
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
228-
| misc extension | array shaping | :part:`worked on` | |
228+
| misc extension | array shaping | :part:`worked on` | D74144 |
229229
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
230230
| misc extension | library shutdown (omp_pause_resource[_all]) | :none:`unclaimed parts` | D55078 |
231231
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
232232
| misc extension | metadirectives | :none:`worked on` | |
233233
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
234234
| misc extension | conditional modifier for lastprivate clause | :good:`done` | |
235235
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
236-
| misc extension | iterator and multidependences | :none:`unclaimed` | |
236+
| misc extension | iterator and multidependences | :part:`claimed` | |
237237
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
238238
| misc extension | user-defined function variants | :part:`worked on` | D67294, D64095 |
239239
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
240240
| misc extension | pointer/reference to pointer based array reductions | :none:`unclaimed` | |
241241
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
242242
| misc extension | prevent new type definitions in clauses | :none:`unclaimed` | |
243243
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
244-
| memory model extension | memory model update (seq_cst, acq_rel, release, acquire,...) | :none:`unclaimed` | |
244+
| memory model extension | memory model update (seq_cst, acq_rel, release, acquire,...) | :good:`done` | |
245245
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
246246

247247

0 commit comments

Comments
 (0)