Skip to content

Commit 6241a64

Browse files
committed
Merge from 'main' to 'sycl-web' (106 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGBuiltin.cpp
2 parents e85760b + bac2a07 commit 6241a64

File tree

331 files changed

+10757
-4965
lines changed

Some content is hidden

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

331 files changed

+10757
-4965
lines changed

clang-tools-extra/clangd/IncludeCleaner.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,6 @@ void setIncludeCleanerAnalyzesStdlib(bool B) { AnalyzeStdlib = B; }
6060

6161
namespace {
6262

63-
// Returns the range starting at '#' and ending at EOL. Escaped newlines are not
64-
// handled.
65-
clangd::Range getDiagnosticRange(llvm::StringRef Code, unsigned HashOffset) {
66-
clangd::Range Result;
67-
Result.end = Result.start = offsetToPosition(Code, HashOffset);
68-
69-
// Span the warning until the EOL or EOF.
70-
Result.end.character +=
71-
lspLength(Code.drop_front(HashOffset).take_until([](char C) {
72-
return C == '\n' || C == '\r';
73-
}));
74-
return Result;
75-
}
76-
7763
bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
7864
// Convert the path to Unix slashes and try to match against the filter.
7965
llvm::SmallString<64> NormalizedPath(HeaderPath);
@@ -224,7 +210,7 @@ std::vector<Diag> generateUnusedIncludeDiagnostics(
224210
D.InsideMainFile = true;
225211
D.Severity = DiagnosticsEngine::Warning;
226212
D.Tags.push_back(Unnecessary);
227-
D.Range = getDiagnosticRange(Code, Inc->HashOffset);
213+
D.Range = rangeTillEOL(Code, Inc->HashOffset);
228214
// FIXME(kirillbobyrev): Removing inclusion might break the code if the
229215
// used headers are only reachable transitively through this one. Suggest
230216
// including them directly instead.

clang-tools-extra/clangd/IncludeCleaner.h

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "Diagnostics.h"
2222
#include "Headers.h"
2323
#include "ParsedAST.h"
24+
#include "Protocol.h"
2425
#include "clang-include-cleaner/Types.h"
2526
#include "clang/Basic/SourceManager.h"
2627
#include "clang/Tooling/Syntax/Tokens.h"

clang-tools-extra/clangd/SourceCode.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1242,5 +1242,17 @@ SourceLocation translatePreamblePatchLocation(SourceLocation Loc,
12421242
}
12431243
return Loc;
12441244
}
1245+
1246+
clangd::Range rangeTillEOL(llvm::StringRef Code, unsigned HashOffset) {
1247+
clangd::Range Result;
1248+
Result.end = Result.start = offsetToPosition(Code, HashOffset);
1249+
1250+
// Span the warning until the EOL or EOF.
1251+
Result.end.character +=
1252+
lspLength(Code.drop_front(HashOffset).take_until([](char C) {
1253+
return C == '\n' || C == '\r';
1254+
}));
1255+
return Result;
1256+
}
12451257
} // namespace clangd
12461258
} // namespace clang

clang-tools-extra/clangd/SourceCode.h

+4
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ inline bool isReservedName(llvm::StringRef Name) {
337337
/// using presumed locations. Returns \p Loc if it isn't inside preamble patch.
338338
SourceLocation translatePreamblePatchLocation(SourceLocation Loc,
339339
const SourceManager &SM);
340+
341+
/// Returns the range starting at offset and spanning the whole line. Escaped
342+
/// newlines are not handled.
343+
clangd::Range rangeTillEOL(llvm::StringRef Code, unsigned HashOffset);
340344
} // namespace clangd
341345
} // namespace clang
342346
#endif

clang-tools-extra/clangd/XRefs.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,9 @@ maybeFindIncludeReferences(ParsedAST &AST, Position Pos,
13621362
return std::nullopt;
13631363

13641364
// Add the #include line to the references list.
1365-
auto IncludeLen = std::string{"#include"}.length() + Inc.Written.length() + 1;
13661365
ReferencesResult::Reference Result;
1367-
Result.Loc.range = clangd::Range{Position{Inc.HashLine, 0},
1368-
Position{Inc.HashLine, (int)IncludeLen}};
1366+
Result.Loc.range =
1367+
rangeTillEOL(SM.getBufferData(SM.getMainFileID()), Inc.HashOffset);
13691368
Result.Loc.uri = URIMainFile;
13701369
Results.References.push_back(std::move(Result));
13711370

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ TEST(FindReferences, ExplicitSymbols) {
22992299

23002300
TEST(FindReferences, UsedSymbolsFromInclude) {
23012301
const char *Tests[] = {
2302-
R"cpp([[#include ^"bar.h"]]
2302+
R"cpp( [[#include ^"bar.h"]]
23032303
#include <vector>
23042304
int fstBar = [[bar1]]();
23052305
int sndBar = [[bar2]]();

clang/docs/ReleaseNotes.rst

+36
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,42 @@ Improvements to Clang's diagnostics
383383
(`#57081: <https://github.com/llvm/llvm-project/issues/57081>`_)
384384
- Clang no longer emits inappropriate notes about the loss of ``__unaligned`` qualifier
385385
on overload resolution, when the actual reason for the failure is loss of other qualifiers.
386+
- Clang's notes about unconvertible types in overload resolution failure now covers
387+
the source range of parameter declaration of the candidate function declaration.
388+
389+
*Example Code*:
390+
391+
.. code-block:: c++
392+
393+
void func(int aa, int bb);
394+
void test() { func(1, "two"); }
395+
396+
*BEFORE*:
397+
398+
.. code-block:: text
399+
400+
source:2:15: error: no matching function for call to 'func'
401+
void test() { func(1, "two"); }
402+
^~~~
403+
source:1:6: note: candidate function not viable: no known conversion from 'const char[4]' to 'int' for 2nd argument
404+
void func(int aa, int bb);
405+
^
406+
407+
*AFTER*:
408+
409+
.. code-block:: text
410+
411+
source:2:15: error: no matching function for call to 'func'
412+
void test() { func(1, "two"); }
413+
^~~~
414+
source:1:6: note: candidate function not viable: no known conversion from 'const char[4]' to 'int' for 2nd argument
415+
void func(int aa, int bb);
416+
^ ~~~~~~
417+
- ``-Wformat`` cast fix-its will now suggest ``static_cast`` instead of C-style casts
418+
for C++ code.
419+
- ``-Wformat`` will no longer suggest a no-op fix-it for fixing scoped enum format
420+
warnings. Instead, it will suggest casting the enum object to the type specified
421+
in the format string.
386422

387423
Bug Fixes in This Version
388424
-------------------------

clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h

+3-10
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
#include "clang/AST/Decl.h"
1818
#include "clang/AST/Stmt.h"
19+
#include "clang/Sema/Sema.h"
1920

2021
namespace clang {
22+
class Sema;
2123

2224
using DefMapTy = llvm::DenseMap<const VarDecl *, std::vector<const VarDecl *>>;
2325

@@ -45,21 +47,12 @@ class UnsafeBufferUsageHandler {
4547

4648
/// Returns a reference to the `Preprocessor`:
4749
virtual bool isSafeBufferOptOut(const SourceLocation &Loc) const = 0;
48-
49-
/// Returns the text indicating that the user needs to provide input there:
50-
virtual std::string
51-
getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") const {
52-
std::string s = std::string("<# ");
53-
s += HintTextToUser;
54-
s += " #>";
55-
return s;
56-
}
5750
};
5851

5952
// This function invokes the analysis and allows the caller to react to it
6053
// through the handler class.
6154
void checkUnsafeBufferUsage(const Decl *D, UnsafeBufferUsageHandler &Handler,
62-
bool EmitSuggestions);
55+
bool EmitSuggestions, Sema &Sema);
6356

6457
namespace internal {
6558
// Tests if any two `FixItHint`s in `FixIts` conflict. Two `FixItHint`s

clang/include/clang/Basic/BuiltinsRISCV.def

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
// Zbb extension
1919
TARGET_BUILTIN(__builtin_riscv_orc_b_32, "UZiUZi", "nc", "zbb")
2020
TARGET_BUILTIN(__builtin_riscv_orc_b_64, "UWiUWi", "nc", "zbb,64bit")
21-
TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
22-
TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
23-
TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")
24-
TARGET_BUILTIN(__builtin_riscv_ctz_64, "iUWi", "nc", "zbb,64bit")
21+
TARGET_BUILTIN(__builtin_riscv_clz_32, "UiUZi", "nc", "zbb|xtheadbb")
22+
TARGET_BUILTIN(__builtin_riscv_clz_64, "UiUWi", "nc", "zbb|xtheadbb,64bit")
23+
TARGET_BUILTIN(__builtin_riscv_ctz_32, "UiUZi", "nc", "zbb")
24+
TARGET_BUILTIN(__builtin_riscv_ctz_64, "UiUWi", "nc", "zbb,64bit")
2525

2626
// Zbc or Zbkc extension
2727
TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")

clang/include/clang/Basic/riscv_vector.td

+2-2
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,7 @@ let ManualCodegen = [{
23682368
let OverloadedName = "vfcvt_x" in
23692369
defm :
23702370
RVVConvBuiltinSet<"vfcvt_x_f_v", "xfd", [["Iv", "Ivvu"]]>;
2371-
let OverloadedName = "vfcvt_xu" in
2371+
let OverloadedName = "vfcvt_xu" in
23722372
defm :
23732373
RVVConvBuiltinSet<"vfcvt_xu_f_v", "xfd", [["Uv", "Uvvu"]]>;
23742374
let OverloadedName = "vfcvt_f" in {
@@ -2411,7 +2411,7 @@ let ManualCodegen = [{
24112411
let OverloadedName = "vfcvt_x" in
24122412
defm :
24132413
RVVConvBuiltinSet<"vfcvt_x_f_v", "xfd", [["Iv", "Ivv"]]>;
2414-
let OverloadedName = "vfcvt_xu" in
2414+
let OverloadedName = "vfcvt_xu" in
24152415
defm :
24162416
RVVConvBuiltinSet<"vfcvt_xu_f_v", "xfd", [["Uv", "Uvv"]]>;
24172417
let OverloadedName = "vfcvt_f" in {

clang/lib/AST/Interp/Source.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,11 @@
1414
#define LLVM_CLANG_AST_INTERP_SOURCE_H
1515

1616
#include "PrimType.h"
17-
#include "llvm/ADT/PointerUnion.h"
17+
#include "clang/AST/Decl.h"
18+
#include "clang/AST/Stmt.h"
1819
#include "llvm/Support/Endian.h"
1920

2021
namespace clang {
21-
22-
class Decl;
23-
class Stmt;
24-
class SourceLocation;
25-
class Expr;
26-
class SourceRange;
27-
2822
namespace interp {
2923
class Function;
3024

0 commit comments

Comments
 (0)