Skip to content

Commit 0d5155a

Browse files
authored
merge main into amd-staging (llvm#2232)
2 parents 5255366 + 6d27783 commit 0d5155a

File tree

68 files changed

+728
-279
lines changed

Some content is hidden

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

68 files changed

+728
-279
lines changed

bolt/lib/Core/DebugData.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
676676
return;
677677
}
678678

679-
std::vector<uint64_t> OffsetsArray;
680679
auto writeExpression = [&](uint32_t Index) -> void {
681680
const DebugLocationEntry &Entry = LocList[Index];
682681
encodeULEB128(Entry.Expr.size(), LocBodyStream);

bolt/lib/Passes/FrameAnalysis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ bool FrameAnalysis::updateArgsTouchedFor(const BinaryFunction &BF, MCInst &Inst,
320320
if (!BC.MIB->isCall(Inst))
321321
return false;
322322

323-
std::set<int64_t> Res;
324323
const MCSymbol *TargetSymbol = BC.MIB->getTargetSymbol(Inst);
325324
// If indirect call, we conservatively assume it accesses all stack positions
326325
if (TargetSymbol == nullptr) {

bolt/lib/Passes/HFSort.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ std::vector<Cluster> clusterize(const CallGraph &Cg) {
239239
}
240240

241241
std::vector<Cluster> randomClusters(const CallGraph &Cg) {
242-
std::vector<NodeId> FuncIds(Cg.numNodes(), 0);
243242
std::vector<Cluster> Clusters;
244243
Clusters.reserve(Cg.numNodes());
245244

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4703,7 +4703,6 @@ RewriteInstance::getOutputSections(ELFObjectFile<ELFT> *File,
47034703
}
47044704

47054705
// Assign indices to sections.
4706-
std::unordered_map<std::string, uint64_t> NameToIndex;
47074706
for (uint32_t Index = 1; Index < OutputSections.size(); ++Index)
47084707
OutputSections[Index].first->setIndex(Index);
47094708

bolt/tools/bat-dump/bat-dump.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,6 @@ static void report_error(StringRef Message, Error E) {
7373
exit(1);
7474
}
7575

76-
static std::string GetExecutablePath(const char *Argv0) {
77-
SmallString<256> ExecutablePath(Argv0);
78-
// Do a PATH lookup if Argv0 isn't a valid path.
79-
if (!llvm::sys::fs::exists(ExecutablePath))
80-
if (llvm::ErrorOr<std::string> P =
81-
llvm::sys::findProgramByName(ExecutablePath))
82-
ExecutablePath = *P;
83-
return std::string(ExecutablePath);
84-
}
85-
8676
void dumpBATFor(llvm::object::ELFObjectFileBase *InputFile) {
8777
BoltAddressTranslation BAT;
8878
if (!BAT.enabledFor(InputFile)) {
@@ -163,7 +153,6 @@ int main(int argc, char **argv) {
163153
report_error(opts::InputFilename, errc::no_such_file_or_directory);
164154

165155
ToolName = argv[0];
166-
std::string ToolPath = GetExecutablePath(argv[0]);
167156
Expected<llvm::object::OwningBinary<llvm::object::Binary>> BinaryOrErr =
168157
llvm::object::createBinary(opts::InputFilename);
169158
if (Error E = BinaryOrErr.takeError())

clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "llvm/Support/YAMLTraits.h"
1313
#include "llvm/Support/raw_ostream.h"
1414

15-
using llvm::yaml::MappingTraits;
1615
using ContextType = clang::find_all_symbols::SymbolInfo::ContextType;
1716
using clang::find_all_symbols::SymbolInfo;
1817
using clang::find_all_symbols::SymbolAndSignals;

clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,21 @@ void NewDeleteOverloadsCheck::onEndOfTranslationUnit() {
168168
// complexity when searching for corresponding free store functions.
169169
for (const auto *Overload : RP.second) {
170170
const auto *Match =
171-
std::find_if(RP.second.begin(), RP.second.end(),
172-
[&Overload](const FunctionDecl *FD) {
173-
if (FD == Overload)
174-
return false;
175-
// If the declaration contexts don't match, we don't
176-
// need to check any further.
177-
if (FD->getDeclContext() != Overload->getDeclContext())
178-
return false;
179-
180-
// Since the declaration contexts match, see whether
181-
// the current element is the corresponding operator.
182-
if (!areCorrespondingOverloads(Overload, FD))
183-
return false;
184-
185-
return true;
186-
});
171+
llvm::find_if(RP.second, [&Overload](const FunctionDecl *FD) {
172+
if (FD == Overload)
173+
return false;
174+
// If the declaration contexts don't match, we don't
175+
// need to check any further.
176+
if (FD->getDeclContext() != Overload->getDeclContext())
177+
return false;
178+
179+
// Since the declaration contexts match, see whether
180+
// the current element is the corresponding operator.
181+
if (!areCorrespondingOverloads(Overload, FD))
182+
return false;
183+
184+
return true;
185+
});
187186

188187
if (Match == RP.second.end()) {
189188
// Check to see if there is a corresponding overload in a base class

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ void filterRenameTargets(llvm::DenseSet<const NamedDecl *> &Decls) {
185185
// For renaming, we're only interested in foo's declaration, so drop the other
186186
// one. There should never be more than one UsingDecl here, otherwise the
187187
// rename would be ambiguos anyway.
188-
auto UD = std::find_if(Decls.begin(), Decls.end(), [](const NamedDecl *D) {
189-
return llvm::isa<UsingDecl>(D);
190-
});
188+
auto UD = llvm::find_if(
189+
Decls, [](const NamedDecl *D) { return llvm::isa<UsingDecl>(D); });
191190
if (UD != Decls.end()) {
192191
Decls.erase(UD);
193192
}

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ Improvements to Clang's diagnostics
570570
}
571571
572572
573+
- A new ``-Wcharacter-conversion`` warns where comparing or implicitly converting
574+
between different Unicode character types (``char8_t``, ``char16_t``, ``char32_t``).
575+
This warning only triggers in C++ as these types are aliases in C. (#GH138526)
576+
573577
Improvements to Clang's time-trace
574578
----------------------------------
575579

clang/include/clang/AST/ASTDiagnostic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ namespace clang {
3838
/// is initialized before passing it in.
3939
QualType desugarForDiagnostic(ASTContext &Context, QualType QT,
4040
bool &ShouldAKA);
41+
42+
std::string FormatUTFCodeUnitAsCodepoint(unsigned Value, QualType T);
43+
4144
} // end namespace clang
4245

4346
#endif

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25212521
bool isChar16Type() const;
25222522
bool isChar32Type() const;
25232523
bool isAnyCharacterType() const;
2524+
bool isUnicodeCharacterType() const;
25242525
bool isIntegralType(const ASTContext &Ctx) const;
25252526

25262527
/// Determine whether this type is an integral or enumeration type.

clang/include/clang/Basic/Diagnostic.h

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,29 @@ class FixItHint {
9292
/// modification is known.
9393
FixItHint() = default;
9494

95-
bool isNull() const {
96-
return !RemoveRange.isValid();
97-
}
95+
bool isNull() const { return !RemoveRange.isValid(); }
9896

9997
/// Create a code modification hint that inserts the given
10098
/// code string at a specific location.
101-
static FixItHint CreateInsertion(SourceLocation InsertionLoc,
102-
StringRef Code,
99+
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code,
103100
bool BeforePreviousInsertions = false) {
104101
FixItHint Hint;
105102
Hint.RemoveRange =
106-
CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
103+
CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
107104
Hint.CodeToInsert = std::string(Code);
108105
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
109106
return Hint;
110107
}
111108

112109
/// Create a code modification hint that inserts the given
113110
/// code from \p FromRange at a specific location.
114-
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc,
115-
CharSourceRange FromRange,
116-
bool BeforePreviousInsertions = false) {
111+
static FixItHint
112+
CreateInsertionFromRange(SourceLocation InsertionLoc,
113+
CharSourceRange FromRange,
114+
bool BeforePreviousInsertions = false) {
117115
FixItHint Hint;
118116
Hint.RemoveRange =
119-
CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
117+
CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
120118
Hint.InsertFromRange = FromRange;
121119
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
122120
return Hint;
@@ -143,8 +141,7 @@ class FixItHint {
143141
return Hint;
144142
}
145143

146-
static FixItHint CreateReplacement(SourceRange RemoveRange,
147-
StringRef Code) {
144+
static FixItHint CreateReplacement(SourceRange RemoveRange, StringRef Code) {
148145
return CreateReplacement(CharSourceRange::getTokenRange(RemoveRange), Code);
149146
}
150147
};
@@ -553,13 +550,11 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
553550
/// avoid redundancy across arguments.
554551
///
555552
/// This is a hack to avoid a layering violation between libbasic and libsema.
556-
using ArgToStringFnTy = void (*)(
557-
ArgumentKind Kind, intptr_t Val,
558-
StringRef Modifier, StringRef Argument,
559-
ArrayRef<ArgumentValue> PrevArgs,
560-
SmallVectorImpl<char> &Output,
561-
void *Cookie,
562-
ArrayRef<intptr_t> QualTypeVals);
553+
using ArgToStringFnTy = void (*)(ArgumentKind Kind, intptr_t Val,
554+
StringRef Modifier, StringRef Argument,
555+
ArrayRef<ArgumentValue> PrevArgs,
556+
SmallVectorImpl<char> &Output, void *Cookie,
557+
ArrayRef<intptr_t> QualTypeVals);
563558

564559
void *ArgToStringCookie = nullptr;
565560
ArgToStringFnTy ArgToStringFn;
@@ -656,9 +651,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
656651

657652
/// Retrieve the maximum number of template instantiation
658653
/// notes to emit along with a given diagnostic.
659-
unsigned getTemplateBacktraceLimit() const {
660-
return TemplateBacktraceLimit;
661-
}
654+
unsigned getTemplateBacktraceLimit() const { return TemplateBacktraceLimit; }
662655

663656
/// Specify the maximum number of constexpr evaluation
664657
/// notes to emit along with a given diagnostic.
@@ -744,9 +737,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
744737
/// fails.
745738
///
746739
/// By default, we show all candidates.
747-
void setShowOverloads(OverloadsShown Val) {
748-
ShowOverloads = Val;
749-
}
740+
void setShowOverloads(OverloadsShown Val) { ShowOverloads = Val; }
750741
OverloadsShown getShowOverloads() const { return ShowOverloads; }
751742

752743
/// When a call or operator fails, print out up to this many candidate
@@ -885,9 +876,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
885876
unsigned getNumErrors() const { return NumErrors; }
886877
unsigned getNumWarnings() const { return NumWarnings; }
887878

888-
void setNumWarnings(unsigned NumWarnings) {
889-
this->NumWarnings = NumWarnings;
890-
}
879+
void setNumWarnings(unsigned NumWarnings) { this->NumWarnings = NumWarnings; }
891880

892881
/// Return an ID for a diagnostic with the specified format string and
893882
/// level.
@@ -907,9 +896,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
907896

908897
/// Converts a diagnostic argument (as an intptr_t) into the string
909898
/// that represents it.
910-
void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
911-
StringRef Modifier, StringRef Argument,
912-
ArrayRef<ArgumentValue> PrevArgs,
899+
void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier,
900+
StringRef Argument, ArrayRef<ArgumentValue> PrevArgs,
913901
SmallVectorImpl<char> &Output,
914902
ArrayRef<intptr_t> QualTypeVals) const {
915903
ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
@@ -1074,8 +1062,9 @@ class DiagnosticErrorTrap {
10741062
unsigned NumUnrecoverableErrors;
10751063

10761064
public:
1077-
explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag)
1078-
: Diag(Diag) { reset(); }
1065+
explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag) : Diag(Diag) {
1066+
reset();
1067+
}
10791068

10801069
/// Determine whether any errors have occurred since this
10811070
/// object instance was created.
@@ -1278,7 +1267,8 @@ class DiagnosticBuilder : public StreamingDiagnostic {
12781267
bool Emit() {
12791268
// If this diagnostic is inactive, then its soul was stolen by the copy ctor
12801269
// (or by a subclass, as in SemaDiagnosticBuilder).
1281-
if (!isActive()) return false;
1270+
if (!isActive())
1271+
return false;
12821272

12831273
// Process the diagnostic.
12841274
bool Result = DiagObj->EmitDiagnostic(*this, IsForceEmit);
@@ -1553,7 +1543,9 @@ class Diagnostic {
15531543
unsigned getID() const { return DiagID; }
15541544
const SourceLocation &getLocation() const { return DiagLoc; }
15551545
bool hasSourceManager() const { return DiagObj->hasSourceManager(); }
1556-
SourceManager &getSourceManager() const { return DiagObj->getSourceManager();}
1546+
SourceManager &getSourceManager() const {
1547+
return DiagObj->getSourceManager();
1548+
}
15571549

15581550
unsigned getNumArgs() const { return DiagStorage.NumDiagArgs; }
15591551

@@ -1709,8 +1701,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StoredDiagnostic &);
17091701
/// formats and prints fully processed diagnostics.
17101702
class DiagnosticConsumer {
17111703
protected:
1712-
unsigned NumWarnings = 0; ///< Number of warnings reported
1713-
unsigned NumErrors = 0; ///< Number of errors reported
1704+
unsigned NumWarnings = 0; ///< Number of warnings reported
1705+
unsigned NumErrors = 0; ///< Number of errors reported
17141706

17151707
public:
17161708
DiagnosticConsumer() = default;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
111111
ImplicitEnumEnumCast,
112112
EnumFloatConversion,
113113
EnumCompareConditional]>;
114+
def CharacterConversion : DiagGroup<"character-conversion">;
114115
def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
115116
def ObjCSignedCharBoolImplicitIntConversion :
116117
DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
@@ -1119,6 +1120,7 @@ def Parentheses : DiagGroup<"parentheses",
11191120
// - __null-to-integer conversion warnings are on by default
11201121
def Conversion : DiagGroup<"conversion",
11211122
[BoolConversion,
1123+
CharacterConversion,
11221124
ConstantConversion,
11231125
EnumConversion,
11241126
BitFieldEnumConversion,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4369,6 +4369,29 @@ def warn_address_of_reference_bool_conversion : Warning<
43694369
"code; pointer may be assumed to always convert to true">,
43704370
InGroup<UndefinedBoolConversion>;
43714371

4372+
def warn_impcast_unicode_char_type
4373+
: Warning<"implicit conversion from %0 to %1 may change the meaning of the "
4374+
"represented code unit">,
4375+
InGroup<CharacterConversion>;
4376+
def warn_impcast_unicode_precision
4377+
: Warning<"implicit conversion from %0 to %1 may lose precision and change "
4378+
"the meaning of the represented code unit">,
4379+
InGroup<CharacterConversion>;
4380+
def warn_impcast_unicode_char_type_constant
4381+
: Warning<"implicit conversion from %0 to %1 changes the meaning of the "
4382+
"%select{code unit|code point}2 '%3'">,
4383+
InGroup<CharacterConversion>;
4384+
4385+
def warn_comparison_unicode_mixed_types
4386+
: Warning<"comparing values of different Unicode code unit types %0 and %1 "
4387+
"may compare different code points">,
4388+
InGroup<CharacterConversion>;
4389+
4390+
def warn_comparison_unicode_mixed_types_constant
4391+
: Warning<"comparing values of different Unicode code unit types %0 and %1 "
4392+
"compares unrelated code units '%2' and '%3'">,
4393+
InGroup<CharacterConversion>;
4394+
43724395
def warn_xor_used_as_pow : Warning<
43734396
"result of '%0' is %1; did you mean exponentiation?">,
43744397
InGroup<XorUsedAsPow>;
@@ -6834,7 +6857,7 @@ def err_counted_by_on_incomplete_type_on_use : Error <
68346857

68356858
def note_counted_by_consider_completing_pointee_ty : Note<
68366859
"consider providing a complete definition for %0">;
6837-
6860+
68386861
def note_counted_by_consider_using_sized_by : Note<
68396862
"consider using '__sized_by%select{|_or_null}0' instead of "
68406863
"'__counted_by%select{|_or_null}0'">;
@@ -7733,6 +7756,11 @@ def warn_comparison_of_mixed_enum_types_switch : Warning<
77337756
"%diff{ ($ and $)|}0,1">,
77347757
InGroup<EnumCompareSwitch>;
77357758

7759+
def warn_arith_conv_mixed_unicode_types
7760+
: Warning<"%sub{select_arith_conv_kind}0 "
7761+
"different Unicode character types %1 and %2">,
7762+
InGroup<CharacterConversion>;
7763+
77367764
def err_typecheck_assign_const : Error<
77377765
"%select{"
77387766
"cannot assign to return value because function %1 returns a const value|"

0 commit comments

Comments
 (0)