Skip to content

Commit b867275

Browse files
committed
warn => err
Created using spr 1.3.5-bogner
2 parents 8c7c536 + 07e2300 commit b867275

File tree

510 files changed

+37209
-24409
lines changed

Some content is hidden

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

510 files changed

+37209
-24409
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,7 @@ void BinaryFunction::duplicateConstantIslands() {
33263326
static std::string constructFilename(std::string Filename,
33273327
std::string Annotation,
33283328
std::string Suffix) {
3329-
std::replace(Filename.begin(), Filename.end(), '/', '-');
3329+
llvm::replace(Filename, '/', '-');
33303330
if (!Annotation.empty())
33313331
Annotation.insert(0, "-");
33323332
if (Filename.size() + Annotation.size() + Suffix.size() > MAX_PATH) {

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
437437
// This is a work around for XCode clang. There is a build error when we
438438
// pass DWCtx.compile_units() to llvm::upper_bound
439439
std::call_once(InitVectorFlag, initCUVector);
440-
auto CUIter = std::upper_bound(CUOffsets.begin(), CUOffsets.end(), Offset,
441-
[](uint64_t LHS, const DWARFUnit *RHS) {
442-
return LHS < RHS->getNextUnitOffset();
443-
});
440+
auto CUIter = llvm::upper_bound(CUOffsets, Offset,
441+
[](uint64_t LHS, const DWARFUnit *RHS) {
442+
return LHS < RHS->getNextUnitOffset();
443+
});
444444
CU = CUIter != CUOffsets.end() ? (*CUIter) : nullptr;
445445
}
446446
return CU;

bolt/lib/Passes/AsmDump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void dumpFunction(const BinaryFunction &BF) {
109109
}
110110

111111
std::string PrintName = BF.getPrintName();
112-
std::replace(PrintName.begin(), PrintName.end(), '/', '-');
112+
llvm::replace(PrintName, '/', '-');
113113
std::string Filename =
114114
opts::AsmDump.empty()
115115
? (PrintName + ".s")

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const char *dynoStatsOptName(const bolt::DynoStats::Category C) {
3535

3636
OptNames[C] = bolt::DynoStats::Description(C);
3737

38-
std::replace(OptNames[C].begin(), OptNames[C].end(), ' ', '-');
38+
llvm::replace(OptNames[C], ' ', '-');
3939

4040
return OptNames[C].c_str();
4141
}

bolt/lib/Passes/PettisAndHansen.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ std::vector<Cluster> pettisAndHansen(const CallGraph &Cg) {
143143
// Find an arc with max weight and merge its nodes
144144

145145
while (!Carcs.empty()) {
146-
auto Maxpos =
147-
std::max_element(Carcs.begin(), Carcs.end(),
148-
[&](const ClusterArc &Carc1, const ClusterArc &Carc2) {
149-
return Carc1.Weight < Carc2.Weight;
150-
});
146+
auto Maxpos = llvm::max_element(
147+
Carcs, [&](const ClusterArc &Carc1, const ClusterArc &Carc2) {
148+
return Carc1.Weight < Carc2.Weight;
149+
});
151150

152151
ClusterArc Max = *Maxpos;
153152
Carcs.erase(Maxpos);

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,12 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
10221022
// JavaScript from escaping characters incorrectly, and introducing bad paths
10231023
// in the URLs.
10241024
std::string RootPathEscaped = RootPath.str().str();
1025-
std::replace(RootPathEscaped.begin(), RootPathEscaped.end(), '\\', '/');
1025+
llvm::replace(RootPathEscaped, '\\', '/');
10261026
OS << "var RootPath = \"" << RootPathEscaped << "\";\n";
10271027

10281028
llvm::SmallString<128> Base(CDCtx.Base);
10291029
std::string BaseEscaped = Base.str().str();
1030-
std::replace(BaseEscaped.begin(), BaseEscaped.end(), '\\', '/');
1030+
llvm::replace(BaseEscaped, '\\', '/');
10311031
OS << "var Base = \"" << BaseEscaped << "\";\n";
10321032

10331033
CDCtx.Idx.sort();

clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,113 @@ class MustacheTemplateFile : public Template {
7070
MustacheTemplateFile(StringRef TemplateStr) : Template(TemplateStr) {}
7171
};
7272

73+
static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
74+
75+
static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
76+
77+
static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
78+
return Error::success();
79+
}
80+
7381
Error MustacheHTMLGenerator::generateDocs(
7482
StringRef RootDir, StringMap<std::unique_ptr<doc::Info>> Infos,
7583
const clang::doc::ClangDocContext &CDCtx) {
84+
if (auto Err = setupTemplateFiles(CDCtx))
85+
return Err;
86+
// Track which directories we already tried to create.
87+
StringSet<> CreatedDirs;
88+
// Collect all output by file name and create the necessary directories.
89+
StringMap<std::vector<doc::Info *>> FileToInfos;
90+
for (const auto &Group : Infos) {
91+
doc::Info *Info = Group.getValue().get();
92+
93+
SmallString<128> Path;
94+
sys::path::native(RootDir, Path);
95+
sys::path::append(Path, Info->getRelativeFilePath(""));
96+
if (!CreatedDirs.contains(Path)) {
97+
if (std::error_code EC = sys::fs::create_directories(Path))
98+
return createStringError(EC, "failed to create directory '%s'.",
99+
Path.c_str());
100+
CreatedDirs.insert(Path);
101+
}
102+
103+
sys::path::append(Path, Info->getFileBaseName() + ".html");
104+
FileToInfos[Path].push_back(Info);
105+
}
106+
107+
for (const auto &Group : FileToInfos) {
108+
std::error_code FileErr;
109+
raw_fd_ostream InfoOS(Group.getKey(), FileErr, sys::fs::OF_None);
110+
if (FileErr)
111+
return createFileOpenError(Group.getKey(), FileErr);
112+
113+
for (const auto &Info : Group.getValue())
114+
if (Error Err = generateDocForInfo(Info, InfoOS, CDCtx))
115+
return Err;
116+
}
76117
return Error::success();
77118
}
78119

120+
static json::Value extractValue(const NamespaceInfo &I,
121+
const ClangDocContext &CDCtx) {
122+
Object NamespaceValue = Object();
123+
return NamespaceValue;
124+
}
125+
126+
static json::Value extractValue(const RecordInfo &I,
127+
const ClangDocContext &CDCtx) {
128+
Object RecordValue = Object();
129+
return RecordValue;
130+
}
131+
132+
static Error setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
133+
Info *I) {
134+
return createStringError(inconvertibleErrorCode(),
135+
"setupTemplateValue is unimplemented");
136+
}
137+
79138
Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
80139
const ClangDocContext &CDCtx) {
140+
switch (I->IT) {
141+
case InfoType::IT_namespace: {
142+
json::Value V =
143+
extractValue(*static_cast<clang::doc::NamespaceInfo *>(I), CDCtx);
144+
if (auto Err = setupTemplateValue(CDCtx, V, I))
145+
return Err;
146+
NamespaceTemplate->render(V, OS);
147+
break;
148+
}
149+
case InfoType::IT_record: {
150+
json::Value V =
151+
extractValue(*static_cast<clang::doc::RecordInfo *>(I), CDCtx);
152+
if (auto Err = setupTemplateValue(CDCtx, V, I))
153+
return Err;
154+
// Serialize the JSON value to the output stream in a readable format.
155+
RecordTemplate->render(V, OS);
156+
break;
157+
}
158+
case InfoType::IT_enum:
159+
OS << "IT_enum\n";
160+
break;
161+
case InfoType::IT_function:
162+
OS << "IT_Function\n";
163+
break;
164+
case InfoType::IT_typedef:
165+
OS << "IT_typedef\n";
166+
break;
167+
case InfoType::IT_default:
168+
return createStringError(inconvertibleErrorCode(), "unexpected InfoType");
169+
}
81170
return Error::success();
82171
}
83172

84173
Error MustacheHTMLGenerator::createResources(ClangDocContext &CDCtx) {
174+
for (const auto &FilePath : CDCtx.UserStylesheets)
175+
if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
176+
return Err;
177+
for (const auto &FilePath : CDCtx.JsScripts)
178+
if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
179+
return Err;
85180
return Error::success();
86181
}
87182

clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
4949
if (PosLLVM != StringRef::npos)
5050
Guard = Guard.substr(PosLLVM);
5151

52-
std::replace(Guard.begin(), Guard.end(), '/', '_');
53-
std::replace(Guard.begin(), Guard.end(), '.', '_');
54-
std::replace(Guard.begin(), Guard.end(), '-', '_');
52+
llvm::replace(Guard, '/', '_');
53+
llvm::replace(Guard, '.', '_');
54+
llvm::replace(Guard, '-', '_');
5555

5656
// The prevalent style in clang is LLVM_CLANG_FOO_BAR_H
5757
if (StringRef(Guard).starts_with("clang"))

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void IdentifierNamingCheck::HungarianNotation::loadFileConfig(
496496
StringRef Val = Options.get(Buffer, "");
497497
if (!Val.empty()) {
498498
std::string Type = PrimType.str();
499-
std::replace(Type.begin(), Type.end(), '-', ' ');
499+
llvm::replace(Type, '-', ' ');
500500
HNOption.PrimitiveType[Type] = Val.str();
501501
}
502502
}
@@ -1358,7 +1358,7 @@ IdentifierNamingCheck::getFailureInfo(
13581358
std::string KindName =
13591359
fixupWithCase(Type, StyleNames[SK], ND, Style, HNOption,
13601360
IdentifierNamingCheck::CT_LowerCase);
1361-
std::replace(KindName.begin(), KindName.end(), '_', ' ');
1361+
llvm::replace(KindName, '_', ' ');
13621362

13631363
std::string Fixup = fixupWithStyle(Type, Name, Style, HNOption, ND);
13641364
if (StringRef(Fixup) == Name) {

clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ bool MagicNumbersCheck::isIgnoredValue(const IntegerLiteral *Literal) const {
202202
if (IgnorePowersOf2IntegerValues && IntValue.isPowerOf2())
203203
return true;
204204

205-
return std::binary_search(IgnoredIntegerValues.begin(),
206-
IgnoredIntegerValues.end(), Value);
205+
return llvm::binary_search(IgnoredIntegerValues, Value);
207206
}
208207

209208
bool MagicNumbersCheck::isIgnoredValue(const FloatingLiteral *Literal) const {
@@ -213,14 +212,12 @@ bool MagicNumbersCheck::isIgnoredValue(const FloatingLiteral *Literal) const {
213212

214213
if (&FloatValue.getSemantics() == &llvm::APFloat::IEEEsingle()) {
215214
const float Value = FloatValue.convertToFloat();
216-
return std::binary_search(IgnoredFloatingPointValues.begin(),
217-
IgnoredFloatingPointValues.end(), Value);
215+
return llvm::binary_search(IgnoredFloatingPointValues, Value);
218216
}
219217

220218
if (&FloatValue.getSemantics() == &llvm::APFloat::IEEEdouble()) {
221219
const double Value = FloatValue.convertToDouble();
222-
return std::binary_search(IgnoredDoublePointValues.begin(),
223-
IgnoredDoublePointValues.end(), Value);
220+
return llvm::binary_search(IgnoredDoublePointValues, Value);
224221
}
225222

226223
return false;

0 commit comments

Comments
 (0)