Skip to content

Commit df95e76

Browse files
committed
Merge from 'main' to 'sycl-web' (206 commits)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/IPO/PassManagerBuilder.cpp CONFLICT (content): Merge conflict in llvm/lib/Passes/PassBuilderPipelines.cpp
2 parents f6c3efd + 7ec05fe commit df95e76

File tree

705 files changed

+37401
-12406
lines changed

Some content is hidden

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

705 files changed

+37401
-12406
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,9 +2036,9 @@ void BinaryContext::renameSection(BinarySection &Section,
20362036
deregisterSectionName(Section);
20372037

20382038
Section.Name = NewName.str();
2039-
Section.setOutputName(NewName);
2039+
Section.setOutputName(Section.Name);
20402040

2041-
NameToSection.insert(std::make_pair(NewName.str(), &Section));
2041+
NameToSection.insert(std::make_pair(Section.Name, &Section));
20422042

20432043
// Reinsert with the new name.
20442044
Sections.insert(&Section);

clang-tools-extra/clangd/Headers.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Lex/HeaderSearch.h"
1616
#include "clang/Lex/PPCallbacks.h"
1717
#include "clang/Lex/Preprocessor.h"
18+
#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/Path.h"
2021
#include <cstring>
@@ -121,12 +122,10 @@ class IncludeStructure::RecordHeaders : public PPCallbacks,
121122
// isSelfContainedHeader only returns true once the full header-guard
122123
// structure has been seen, i.e. when exiting the *outer* copy of the
123124
// file. So last result wins.
124-
if (isSelfContainedHeader(FE, PrevFID, SM, HeaderInfo))
125-
Out->NonSelfContained.erase(
126-
*Out->getID(SM.getFileEntryForID(PrevFID)));
125+
if (tooling::isSelfContainedHeader(FE, SM, HeaderInfo))
126+
Out->NonSelfContained.erase(*Out->getID(FE));
127127
else
128-
Out->NonSelfContained.insert(
129-
*Out->getID(SM.getFileEntryForID(PrevFID)));
128+
Out->NonSelfContained.insert(*Out->getID(FE));
130129
}
131130
break;
132131
}

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,58 +1183,5 @@ bool isProtoFile(SourceLocation Loc, const SourceManager &SM) {
11831183
return SM.getBufferData(FID).startswith(ProtoHeaderComment);
11841184
}
11851185

1186-
namespace {
1187-
1188-
// Is Line an #if or #ifdef directive?
1189-
// FIXME: This makes headers with #ifdef LINUX/WINDOWS/MACOS marked as non
1190-
// self-contained and is probably not what we want.
1191-
bool isIf(llvm::StringRef Line) {
1192-
Line = Line.ltrim();
1193-
if (!Line.consume_front("#"))
1194-
return false;
1195-
Line = Line.ltrim();
1196-
return Line.startswith("if");
1197-
}
1198-
1199-
// Is Line an #error directive mentioning includes?
1200-
bool isErrorAboutInclude(llvm::StringRef Line) {
1201-
Line = Line.ltrim();
1202-
if (!Line.consume_front("#"))
1203-
return false;
1204-
Line = Line.ltrim();
1205-
if (!Line.startswith("error"))
1206-
return false;
1207-
return Line.contains_insensitive(
1208-
"includ"); // Matches "include" or "including".
1209-
}
1210-
1211-
// Heuristically headers that only want to be included via an umbrella.
1212-
bool isDontIncludeMeHeader(llvm::StringRef Content) {
1213-
llvm::StringRef Line;
1214-
// Only sniff up to 100 lines or 10KB.
1215-
Content = Content.take_front(100 * 100);
1216-
for (unsigned I = 0; I < 100 && !Content.empty(); ++I) {
1217-
std::tie(Line, Content) = Content.split('\n');
1218-
if (isIf(Line) && isErrorAboutInclude(Content.split('\n').first))
1219-
return true;
1220-
}
1221-
return false;
1222-
}
1223-
1224-
} // namespace
1225-
1226-
bool isSelfContainedHeader(const FileEntry *FE, FileID FID,
1227-
const SourceManager &SM, HeaderSearch &HeaderInfo) {
1228-
// FIXME: Should files that have been #import'd be considered
1229-
// self-contained? That's really a property of the includer,
1230-
// not of the file.
1231-
if (!HeaderInfo.isFileMultipleIncludeGuarded(FE) &&
1232-
!HeaderInfo.hasFileBeenImported(FE))
1233-
return false;
1234-
// This pattern indicates that a header can't be used without
1235-
// particular preprocessor state, usually set up by another header.
1236-
return !isDontIncludeMeHeader(SM.getBufferData(FID));
1237-
}
1238-
12391186
} // namespace clangd
12401187
} // namespace clang

clang-tools-extra/clangd/SourceCode.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,6 @@ bool isHeaderFile(llvm::StringRef FileName,
325325
/// Returns true if the given location is in a generated protobuf file.
326326
bool isProtoFile(SourceLocation Loc, const SourceManager &SourceMgr);
327327

328-
/// This scans source code, and should not be called when using a preamble.
329-
/// Prefer to access the cache in IncludeStructure::isSelfContained if you can.
330-
bool isSelfContainedHeader(const FileEntry *FE, FileID ID,
331-
const SourceManager &SM, HeaderSearch &HeaderInfo);
332-
333328
/// Returns true if Name is reserved, like _Foo or __Vector_base.
334329
inline bool isReservedName(llvm::StringRef Name) {
335330
// This doesn't catch all cases, but the most common.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "clang/Index/IndexSymbol.h"
2929
#include "clang/Lex/Preprocessor.h"
3030
#include "clang/Lex/Token.h"
31+
#include "clang/Tooling/Inclusions/HeaderAnalysis.h"
3132
#include "llvm/ADT/ArrayRef.h"
3233
#include "llvm/Support/Casting.h"
3334
#include "llvm/Support/FileSystem.h"
@@ -419,8 +420,8 @@ class SymbolCollector::HeaderFileURICache {
419420
getFrameworkHeaderIncludeSpelling(FE, HFI->Framework, HS))
420421
return *Spelling;
421422

422-
if (!isSelfContainedHeader(FE, FID, PP->getSourceManager(),
423-
PP->getHeaderSearchInfo())) {
423+
if (!tooling::isSelfContainedHeader(FE, PP->getSourceManager(),
424+
PP->getHeaderSearchInfo())) {
424425
// A .inc or .def file is often included into a real header to define
425426
// symbols (e.g. LLVM tablegen files).
426427
if (Filename.endswith(".inc") || Filename.endswith(".def"))

clang/bindings/python/clang/cindex.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,31 @@ class Bar {
15041504
"""
15051505
return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self)
15061506

1507+
def is_move_assignment_operator_method(self):
1508+
"""Returnrs True if the cursor refers to a move-assignment operator.
1509+
1510+
A move-assignment operator `X::operator=` is a non-static,
1511+
non-template member function of _class_ `X` with exactly one
1512+
parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
1513+
volatile X&&`.
1514+
1515+
1516+
That is, for example, the `operator=` in:
1517+
1518+
class Foo {
1519+
bool operator=(const volatile Foo&&);
1520+
};
1521+
1522+
Is a move-assignment operator, while the `operator=` in:
1523+
1524+
class Bar {
1525+
bool operator=(const int&&);
1526+
};
1527+
1528+
Is not.
1529+
"""
1530+
return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
1531+
15071532
def is_mutable_field(self):
15081533
"""Returns True if the cursor refers to a C++ field that is declared
15091534
'mutable'.
@@ -3465,6 +3490,10 @@ def cursor(self):
34653490
[Cursor],
34663491
bool),
34673492

3493+
("clang_CXXMethod_isMoveAssignmentOperator",
3494+
[Cursor],
3495+
bool),
3496+
34683497
("clang_CXXMethod_isPureVirtual",
34693498
[Cursor],
34703499
bool),

clang/bindings/python/tests/cindex/test_cursor.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,64 @@ def test_is_default_method(self):
219219
self.assertTrue(xc.is_default_method())
220220
self.assertFalse(yc.is_default_method())
221221

222+
def test_is_move_assignment_operator_method(self):
223+
"""Ensure Cursor.is_move_assignment_operator_method works."""
224+
source_with_move_assignment_operators = """
225+
struct Foo {
226+
// Those are move-assignment operators
227+
bool operator=(const Foo&&);
228+
bool operator=(Foo&&);
229+
bool operator=(volatile Foo&&);
230+
bool operator=(const volatile Foo&&);
231+
232+
// Positive-check that the recognition works for templated classes too
233+
template <typename T>
234+
class Bar {
235+
bool operator=(const Bar&&);
236+
bool operator=(Bar<T>&&);
237+
bool operator=(volatile Bar&&);
238+
bool operator=(const volatile Bar<T>&&);
239+
};
240+
"""
241+
source_without_move_assignment_operators = """
242+
struct Foo {
243+
// Those are not move-assignment operators
244+
template<typename T>
245+
bool operator=(const T&&);
246+
bool operator=(const bool&&);
247+
bool operator=(char&&);
248+
bool operator=(volatile unsigned int&&);
249+
bool operator=(const volatile unsigned char&&);
250+
bool operator=(int);
251+
bool operator=(Foo);
252+
};
253+
"""
254+
tu_with_move_assignment_operators = get_tu(
255+
source_with_move_assignment_operators, lang="cpp"
256+
)
257+
tu_without_move_assignment_operators = get_tu(
258+
source_without_move_assignment_operators, lang="cpp"
259+
)
260+
261+
move_assignment_operators_cursors = get_cursors(
262+
tu_with_move_assignment_operators, "operator="
263+
)
264+
non_move_assignment_operators_cursors = get_cursors(
265+
tu_without_move_assignment_operators, "operator="
266+
)
267+
268+
self.assertEqual(len(move_assignment_operators_cursors), 8)
269+
self.assertTrue(len(non_move_assignment_operators_cursors), 7)
270+
271+
self.assertTrue(all([
272+
cursor.is_move_assignment_operator_method()
273+
for cursor in move_assignment_operators_cursors
274+
]))
275+
self.assertFalse(any([
276+
cursor.is_move_assignment_operator_method()
277+
for cursor in non_move_assignment_operators_cursors
278+
]))
279+
222280
def test_is_mutable_field(self):
223281
"""Ensure Cursor.is_mutable_field works."""
224282
source = 'class X { int x_; mutable int y_; };'

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ libclang
792792
- Introduced the new function ``clang_CXXMethod_isCopyAssignmentOperator``,
793793
which identifies whether a method cursor is a copy-assignment
794794
operator.
795+
- Introduced the new function ``clang_CXXMethod_isMoveAssignmentOperator``,
796+
which identifies whether a method cursor is a move-assignment
797+
operator.
795798
- ``clang_Cursor_getNumTemplateArguments``, ``clang_Cursor_getTemplateArgumentKind``,
796799
``clang_Cursor_getTemplateArgumentType``, ``clang_Cursor_getTemplateArgumentValue`` and
797800
``clang_Cursor_getTemplateArgumentUnsignedValue`` now work on struct, class,

clang/include/clang-c/Index.h

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,23 +2080,6 @@ enum CXCursorKind {
20802080
CXCursor_OverloadCandidate = 700
20812081
};
20822082

2083-
/**
2084-
* Describes the kind of result generated.
2085-
*/
2086-
enum CXCompletionResultKind {
2087-
/** Refers to a declaration. */
2088-
CXCompletionResult_Declaration = 0,
2089-
2090-
/** Refers to a keyword or symbol. */
2091-
CXCompletionResult_Keyword = 1,
2092-
2093-
/** Refers to a macro. */
2094-
CXCompletionResult_Macro = 2,
2095-
2096-
/** Refers to a precomputed pattern. */
2097-
CXCompletionResult_Pattern = 3
2098-
};
2099-
21002083
/**
21012084
* A cursor representing some element in the abstract syntax tree for
21022085
* a translation unit.
@@ -4343,6 +4326,31 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
43434326
*/
43444327
CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
43454328

4329+
/**
4330+
* Determine if a C++ member function is a move-assignment operator,
4331+
* returning 1 if such is the case and 0 otherwise.
4332+
*
4333+
* > A move-assignment operator `X::operator=` is a non-static,
4334+
* > non-template member function of _class_ `X` with exactly one
4335+
* > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4336+
* > volatile X&&`.
4337+
*
4338+
* That is, for example, the `operator=` in:
4339+
*
4340+
* class Foo {
4341+
* bool operator=(const volatile Foo&&);
4342+
* };
4343+
*
4344+
* Is a move-assignment operator, while the `operator=` in:
4345+
*
4346+
* class Bar {
4347+
* bool operator=(const int&&);
4348+
* };
4349+
*
4350+
* Is not.
4351+
*/
4352+
CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
4353+
43464354
/**
43474355
* Determine if a C++ record is abstract, i.e. whether a class or struct
43484356
* has a pure virtual member function.
@@ -4619,8 +4627,6 @@ CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
46194627
*/
46204628

46214629
/* for debug/testing */
4622-
CINDEX_LINKAGE CXString
4623-
clang_getCompletionResultKindSpelling(enum CXCompletionResultKind Kind);
46244630
CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
46254631
CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
46264632
CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
@@ -4664,17 +4670,12 @@ typedef void *CXCompletionString;
46644670
* A single result of code completion.
46654671
*/
46664672
typedef struct {
4667-
/**
4668-
* The kind of this completion result.
4669-
* Useful to distinguish between declarations and keywords.
4670-
*/
4671-
enum CXCompletionResultKind ResultKind;
4672-
46734673
/**
46744674
* The kind of entity that this completion refers to.
46754675
*
4676-
* The cursor kind will be a macro or a declaration (one of the *Decl cursor
4677-
* kinds), describing the entity that the completion is referring to.
4676+
* The cursor kind will be a macro, keyword, or a declaration (one of the
4677+
* *Decl cursor kinds), describing the entity that the completion is
4678+
* referring to.
46784679
*
46794680
* \todo In the future, we would like to provide a full cursor, to allow
46804681
* the client to extract additional information from declaration.

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7374,7 +7374,7 @@ by showing the control-flow statement where the path diverges.
73747374
if (somePredicate()) {
73757375
...
73767376
callback();
7377-
} esle {
7377+
} else {
73787378
callback(); // OK: callback is called on every path
73797379
}
73807380
}

0 commit comments

Comments
 (0)