Skip to content

Commit ff5b5cf

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaChecking.cpp
2 parents 29a12d3 + 6201f66 commit ff5b5cf

File tree

418 files changed

+10399
-3733
lines changed

Some content is hidden

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

418 files changed

+10399
-3733
lines changed

.arcconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"phabricator.uri" : "https://reviews.llvm.org/",
33
"repository.callsign" : "G",
4-
"conduit_uri" : "https://reviews.llvm.org/"
4+
"conduit_uri" : "https://reviews.llvm.org/",
5+
"base": "git:HEAD^"
56
}

clang-tools-extra/.arcconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "clang/Index/IndexingAction.h"
3737
#include "clang/Index/IndexingOptions.h"
3838
#include "clang/Index/USRGeneration.h"
39+
#include "clang/Tooling/Syntax/Tokens.h"
3940
#include "llvm/ADT/ArrayRef.h"
4041
#include "llvm/ADT/None.h"
4142
#include "llvm/ADT/STLExtras.h"
@@ -593,22 +594,23 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LocatedSymbol &S) {
593594

594595
// FIXME(nridge): Reduce duplication between this function and declToSym().
595596
static llvm::Optional<TypeHierarchyItem>
596-
declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
597+
declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND,
598+
const syntax::TokenBuffer &TB) {
597599
auto &SM = Ctx.getSourceManager();
598-
599600
SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
600-
// getFileLoc is a good choice for us, but we also need to make sure
601-
// sourceLocToPosition won't switch files, so we call getSpellingLoc on top of
602-
// that to make sure it does not switch files.
603-
// FIXME: sourceLocToPosition should not switch files!
604-
SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
605-
SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
606-
if (NameLoc.isInvalid() || BeginLoc.isInvalid() || EndLoc.isInvalid())
601+
auto FilePath =
602+
getCanonicalPath(SM.getFileEntryForID(SM.getFileID(NameLoc)), SM);
603+
auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
604+
if (!FilePath || !TUPath)
605+
return llvm::None; // Not useful without a uri.
606+
607+
auto DeclToks = TB.spelledForExpanded(TB.expandedTokens(ND.getSourceRange()));
608+
if (!DeclToks || DeclToks->empty())
607609
return llvm::None;
608610

609-
Position NameBegin = sourceLocToPosition(SM, NameLoc);
610-
Position NameEnd = sourceLocToPosition(
611-
SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));
611+
auto NameToks = TB.spelledForExpanded(TB.expandedTokens(NameLoc));
612+
if (!NameToks || NameToks->empty())
613+
return llvm::None;
612614

613615
index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
614616
// FIXME: this is not classifying constructors, destructors and operators
@@ -619,20 +621,18 @@ declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
619621
THI.name = printName(Ctx, ND);
620622
THI.kind = SK;
621623
THI.deprecated = ND.isDeprecated();
622-
THI.range =
623-
Range{sourceLocToPosition(SM, BeginLoc), sourceLocToPosition(SM, EndLoc)};
624-
THI.selectionRange = Range{NameBegin, NameEnd};
624+
THI.range = halfOpenToRange(
625+
SM, syntax::Token::range(SM, DeclToks->front(), DeclToks->back())
626+
.toCharRange(SM));
627+
THI.selectionRange = halfOpenToRange(
628+
SM, syntax::Token::range(SM, NameToks->front(), NameToks->back())
629+
.toCharRange(SM));
625630
if (!THI.range.contains(THI.selectionRange)) {
626631
// 'selectionRange' must be contained in 'range', so in cases where clang
627632
// reports unrelated ranges we need to reconcile somehow.
628633
THI.range = THI.selectionRange;
629634
}
630635

631-
auto FilePath =
632-
getCanonicalPath(SM.getFileEntryForID(SM.getFileID(BeginLoc)), SM);
633-
auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
634-
if (!FilePath || !TUPath)
635-
return llvm::None; // Not useful without a uri.
636636
THI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
637637

638638
return THI;
@@ -685,7 +685,8 @@ using RecursionProtectionSet = llvm::SmallSet<const CXXRecordDecl *, 4>;
685685

686686
static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
687687
std::vector<TypeHierarchyItem> &SuperTypes,
688-
RecursionProtectionSet &RPSet) {
688+
RecursionProtectionSet &RPSet,
689+
const syntax::TokenBuffer &TB) {
689690
// typeParents() will replace dependent template specializations
690691
// with their class template, so to avoid infinite recursion for
691692
// certain types of hierarchies, keep the templates encountered
@@ -700,9 +701,9 @@ static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
700701

701702
for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
702703
if (Optional<TypeHierarchyItem> ParentSym =
703-
declToTypeHierarchyItem(ASTCtx, *ParentDecl)) {
704+
declToTypeHierarchyItem(ASTCtx, *ParentDecl, TB)) {
704705
ParentSym->parents.emplace();
705-
fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet);
706+
fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet, TB);
706707
SuperTypes.emplace_back(std::move(*ParentSym));
707708
}
708709
}
@@ -805,7 +806,7 @@ getTypeHierarchy(ParsedAST &AST, Position Pos, int ResolveLevels,
805806
return llvm::None;
806807

807808
Optional<TypeHierarchyItem> Result =
808-
declToTypeHierarchyItem(AST.getASTContext(), *CXXRD);
809+
declToTypeHierarchyItem(AST.getASTContext(), *CXXRD, AST.getTokens());
809810
if (!Result)
810811
return Result;
811812

@@ -814,7 +815,8 @@ getTypeHierarchy(ParsedAST &AST, Position Pos, int ResolveLevels,
814815
Result->parents.emplace();
815816

816817
RecursionProtectionSet RPSet;
817-
fillSuperTypes(*CXXRD, AST.getASTContext(), *Result->parents, RPSet);
818+
fillSuperTypes(*CXXRD, AST.getASTContext(), *Result->parents, RPSet,
819+
AST.getTokens());
818820
}
819821

820822
if ((Direction == TypeHierarchyDirection::Children ||

clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ bool ExtractVariable::prepare(const Selection &Inputs) {
450450
if (Inputs.SelectionBegin == Inputs.SelectionEnd)
451451
return false;
452452
const ASTContext &Ctx = Inputs.AST->getASTContext();
453+
// FIXME: Enable non-C++ cases once we start spelling types explicitly instead
454+
// of making use of auto.
455+
if (!Ctx.getLangOpts().CPlusPlus)
456+
return false;
453457
const SourceManager &SM = Inputs.AST->getSourceManager();
454458
if (const SelectionTree::Node *N =
455459
computeExtractedExpr(Inputs.ASTSelection.commonAncestor()))

clang-tools-extra/clangd/test/type-hierarchy.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# CHECK-NEXT: "parents": [],
4949
# CHECK-NEXT: "range": {
5050
# CHECK-NEXT: "end": {
51-
# CHECK-NEXT: "character": 15,
51+
# CHECK-NEXT: "character": 16,
5252
# CHECK-NEXT: "line": 0
5353
# CHECK-NEXT: },
5454
# CHECK-NEXT: "start": {
@@ -71,7 +71,7 @@
7171
# CHECK-NEXT: ],
7272
# CHECK-NEXT: "range": {
7373
# CHECK-NEXT: "end": {
74-
# CHECK-NEXT: "character": 24,
74+
# CHECK-NEXT: "character": 25,
7575
# CHECK-NEXT: "line": 1
7676
# CHECK-NEXT: },
7777
# CHECK-NEXT: "start": {
@@ -94,7 +94,7 @@
9494
# CHECK-NEXT: ],
9595
# CHECK-NEXT: "range": {
9696
# CHECK-NEXT: "end": {
97-
# CHECK-NEXT: "character": 24,
97+
# CHECK-NEXT: "character": 25,
9898
# CHECK-NEXT: "line": 2
9999
# CHECK-NEXT: },
100100
# CHECK-NEXT: "start": {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ TEST(RenameTest, WithinFileRename) {
202202
}
203203
)cpp",
204204

205+
// Incomplete class specializations
206+
R"cpp(
207+
template <typename T>
208+
class [[Fo^o]] {};
209+
void func([[Foo]]<int>);
210+
)cpp",
211+
205212
// Template class instantiations.
206213
R"cpp(
207214
template <typename T>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ TEST_F(ExtractVariableTest, Test) {
230230
)cpp";
231231
EXPECT_AVAILABLE(AvailableCases);
232232

233+
ExtraArgs = {"-xc"};
234+
const char *AvailableButC = R"cpp(
235+
void foo() {
236+
int x = [[1]];
237+
})cpp";
238+
EXPECT_UNAVAILABLE(AvailableButC);
239+
ExtraArgs = {};
240+
233241
const char *NoCrashCases = R"cpp(
234242
// error-ok: broken code, but shouldn't crash
235243
template<typename T, typename ...Args>

clang/.arcconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.

clang/docs/LanguageExtensions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,34 @@ the clang implementation are in :doc:`Block-ABI-Apple<Block-ABI-Apple>`.
12551255

12561256
Query for this feature with ``__has_extension(blocks)``.
12571257

1258+
ASM Goto with Output Constraints
1259+
================================
1260+
1261+
In addition to the functionality provided by `GCC's extended
1262+
assembly`<https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_, clang
1263+
supports output constraints with the `goto` form.
1264+
1265+
The goto form of GCC's extended assembly allows the programmer to branch to a C
1266+
label from within an inline assembly block. Clang extends this behavior by
1267+
allowing the programmer to use output constraints:
1268+
1269+
.. code-block:: c++
1270+
1271+
int foo(int x) {
1272+
int y;
1273+
asm goto("# %0 %1 %l2" : "=r"(y) : "r"(x) : : err);
1274+
return y;
1275+
err:
1276+
return -1;
1277+
}
1278+
1279+
It's important to note that outputs are valid only on the "fallthrough" branch.
1280+
Using outputs on an indirect branch may result in undefined behavior. For
1281+
example, in the function above, use of the value assigned to `y` in the `err`
1282+
block is undefined behavior.
1283+
1284+
Query for this feature with ``__has_extension(gnu_asm_goto_with_outputs)``.
1285+
12581286
Objective-C Features
12591287
====================
12601288

0 commit comments

Comments
 (0)