Skip to content

Commit e207762

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW40)
2 parents ac706af + b12c4e3 commit e207762

File tree

421 files changed

+8707
-4509
lines changed

Some content is hidden

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

421 files changed

+8707
-4509
lines changed

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ std::vector<InlayHint> inlayHints(ParsedAST &AST) {
366366
std::vector<InlayHint> Results;
367367
InlayHintVisitor Visitor(Results, AST);
368368
Visitor.TraverseAST(AST.getASTContext());
369+
370+
// De-duplicate hints. Duplicates can sometimes occur due to e.g. explicit
371+
// template instantiations.
372+
llvm::sort(Results);
373+
Results.erase(std::unique(Results.begin(), Results.end()), Results.end());
374+
369375
return Results;
370376
}
371377

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,14 @@ llvm::json::Value toJSON(const InlayHint &H) {
13261326
return llvm::json::Object{
13271327
{"range", H.range}, {"kind", H.kind}, {"label", H.label}};
13281328
}
1329+
bool operator==(const InlayHint &A, const InlayHint &B) {
1330+
return std::tie(A.kind, A.range, A.label) ==
1331+
std::tie(B.kind, B.range, B.label);
1332+
}
1333+
bool operator<(const InlayHint &A, const InlayHint &B) {
1334+
return std::tie(A.kind, A.range, A.label) <
1335+
std::tie(B.kind, B.range, B.label);
1336+
}
13291337

13301338
static const char *toString(OffsetEncoding OE) {
13311339
switch (OE) {

clang-tools-extra/clangd/Protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,8 @@ struct InlayHint {
15481548
std::string label;
15491549
};
15501550
llvm::json::Value toJSON(const InlayHint &);
1551+
bool operator==(const InlayHint &, const InlayHint &);
1552+
bool operator<(const InlayHint &, const InlayHint &);
15511553

15521554
struct ReferenceContext {
15531555
/// Include the declaration of the current symbol.

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,18 @@ TEST(TypeHints, DefaultTemplateArgs) {
612612
ExpectedHint{": A<float>", "var"});
613613
}
614614

615+
TEST(TypeHints, Deduplication) {
616+
assertTypeHints(R"cpp(
617+
template <typename T>
618+
void foo() {
619+
auto $var[[var]] = 42;
620+
}
621+
template void foo<int>();
622+
template void foo<float>();
623+
)cpp",
624+
ExpectedHint{": int", "var"});
625+
}
626+
615627
// FIXME: Low-hanging fruit where we could omit a type hint:
616628
// - auto x = TypeName(...);
617629
// - auto x = (TypeName) (...);
@@ -625,4 +637,4 @@ TEST(TypeHints, DefaultTemplateArgs) {
625637

626638
} // namespace
627639
} // namespace clangd
628-
} // namespace clang
640+
} // namespace clang

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
709709
CMAKE_CXX_COMPILER_LAUNCHER
710710
CMAKE_MAKE_PROGRAM
711711
CMAKE_OSX_ARCHITECTURES
712+
CMAKE_BUILD_TYPE
712713
LLVM_ENABLE_PROJECTS
713714
LLVM_ENABLE_RUNTIMES)
714715

clang/cmake/modules/AddClang.cmake

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ macro(add_clang_library name)
100100
# The Xcode generator doesn't handle object libraries correctly.
101101
list(APPEND LIBTYPE OBJECT)
102102
endif()
103-
if (NOT EXCLUDE_FROM_ALL)
104-
# Only include libraries that don't have EXCLUDE_FROM_ALL set. This
105-
# ensure that the clang static analyzer libraries are not compiled
106-
# as part of clang-shlib if CLANG_ENABLE_STATIC_ANALYZER=OFF.
107-
set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
108-
endif()
103+
set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
109104
endif()
110105
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
111106

@@ -115,11 +110,8 @@ macro(add_clang_library name)
115110
endif()
116111

117112
foreach(lib ${libs})
118-
if(TARGET ${lib})
113+
if(TARGET ${lib})
119114
target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
120-
if (EXCLUDE_FROM_ALL)
121-
continue()
122-
endif()
123115

124116
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
125117
get_target_export_arg(${name} Clang export_to_clangtargets UMBRELLA clang-libraries)

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8610,6 +8610,9 @@ def err_typecheck_choose_expr_requires_constant : Error<
86108610
"'__builtin_choose_expr' requires a constant expression">;
86118611
def warn_unused_expr : Warning<"expression result unused">,
86128612
InGroup<UnusedValue>;
8613+
def warn_unused_comma_left_operand : Warning<
8614+
"left operand of comma operator has no effect">,
8615+
InGroup<UnusedValue>;
86138616
def warn_unused_voidptr : Warning<
86148617
"expression result unused; should this cast be to 'void'?">,
86158618
InGroup<UnusedValue>;

clang/include/clang/Sema/Sema.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5169,7 +5169,7 @@ class Sema final {
51695169

51705170
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
51715171
/// whose result is unused, warn.
5172-
void DiagnoseUnusedExprResult(const Stmt *S);
5172+
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
51735173
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D);
51745174
void DiagnoseUnusedDecl(const NamedDecl *ND);
51755175

@@ -5375,6 +5375,16 @@ class Sema final {
53755375
/// conversion.
53765376
ExprResult tryConvertExprToType(Expr *E, QualType Ty);
53775377

5378+
/// Conditionally issue a diagnostic based on the statement's reachability
5379+
/// analysis evaluation context.
5380+
///
5381+
/// \param Statement If Statement is non-null, delay reporting the
5382+
/// diagnostic until the function body is parsed, and then do a basic
5383+
/// reachability analysis to determine if the statement is reachable.
5384+
/// If it is unreachable, the diagnostic will not be emitted.
5385+
bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
5386+
const PartialDiagnostic &PD);
5387+
53785388
/// Conditionally issue a diagnostic based on the current
53795389
/// evaluation context.
53805390
///

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7097,7 +7097,7 @@ ASTContext::getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const {
70977097
void ASTContext::getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT,
70987098
QualType T, std::string& S,
70997099
bool Extended) const {
7100-
// Encode type qualifer, 'in', 'inout', etc. for the parameter.
7100+
// Encode type qualifier, 'in', 'inout', etc. for the parameter.
71017101
getObjCEncodingForTypeQualifier(QT, S);
71027102
// Encode parameter type.
71037103
ObjCEncOptions Options = ObjCEncOptions()
@@ -7807,7 +7807,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
78077807
.setExpandStructures()),
78087808
FD);
78097809
if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
7810-
// Note that we do extended encoding of protocol qualifer list
7810+
// Note that we do extended encoding of protocol qualifier list
78117811
// Only when doing ivar or property encoding.
78127812
S += '"';
78137813
for (const auto *I : OPT->quals()) {
@@ -10086,7 +10086,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
1008610086
unsigned LHSBits = LHS->castAs<ExtIntType>()->getNumBits();
1008710087
unsigned RHSBits = RHS->castAs<ExtIntType>()->getNumBits();
1008810088

10089-
// Like unsigned/int, shouldn't have a type if they dont match.
10089+
// Like unsigned/int, shouldn't have a type if they don't match.
1009010090
if (LHSUnsigned != RHSUnsigned)
1009110091
return {};
1009210092

@@ -10727,7 +10727,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
1072710727
}
1072810728

1072910729
// On some targets such as PowerPC, some of the builtins are defined with custom
10730-
// type decriptors for target-dependent types. These descriptors are decoded in
10730+
// type descriptors for target-dependent types. These descriptors are decoded in
1073110731
// other functions, but it may be useful to be able to fall back to default
1073210732
// descriptor decoding to define builtins mixing target-dependent and target-
1073310733
// independent types. This function allows decoding one type descriptor with

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
18301830
RecordDecl *FromRecordDecl = nullptr;
18311831
RecordDecl *ToRecordDecl = nullptr;
18321832
// If we have a field that is an ArrayType we need to check if the array
1833-
// element is a RecordDecl and if so we need to import the defintion.
1833+
// element is a RecordDecl and if so we need to import the definition.
18341834
if (FieldFrom->getType()->isArrayType()) {
18351835
// getBaseElementTypeUnsafe(...) handles multi-dimensonal arrays for us.
18361836
FromRecordDecl = FieldFrom->getType()->getBaseElementTypeUnsafe()->getAsRecordDecl();

0 commit comments

Comments
 (0)