Skip to content

Commit 23c3b27

Browse files
Merge from 'main' to 'sycl-web' (167 commits)
CONFLICT (content): Merge conflict in clang/lib/Basic/IdentifierTable.cpp
2 parents 2e7231e + fb65b17 commit 23c3b27

File tree

638 files changed

+31309
-12400
lines changed

Some content is hidden

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

638 files changed

+31309
-12400
lines changed

.github/workflows/libclang-abi-tests.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ jobs:
124124
- name: Dump ABI
125125
run: |
126126
parallel abi-dumper -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o {}-${{ matrix.ref }}.abi ./build/lib/{} ::: ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}
127-
# Remove symbol versioning from dumps, so we can compare across major
128-
# versions. We don't need to do this for libclang.so since its ABI
129-
# is stable across major releases and the symbol versions don't change.
130-
if [ -e libclang-cpp.so-${{ matrix.ref }}.abi ]; then
131-
sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' libclang-cpp.so-${{ matrix.ref }}.abi
132-
fi
127+
for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
128+
# Remove symbol versioning from dumps, so we can compare across major versions.
129+
sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
130+
done
133131
- name: Upload ABI file
134132
uses: actions/upload-artifact@v2
135133
with:

bolt/include/bolt/Core/BinaryDomTree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#ifndef BOLT_CORE_BINARY_DOMTREE_H
1515
#define BOLT_CORE_BINARY_DOMTREE_H
1616

17+
#include "bolt/Core/BinaryBasicBlock.h"
18+
#include "llvm/IR/Dominators.h"
1719
#include "llvm/Support/GenericDomTreeConstruction.h"
1820

1921
namespace llvm {
2022
namespace bolt {
2123

22-
class BinaryBasicBlock;
2324
using BinaryDomTreeNode = DomTreeNodeBase<BinaryBasicBlock>;
2425
using BinaryDominatorTree = DomTreeBase<BinaryBasicBlock>;
2526

bolt/include/bolt/Passes/RegReAssign.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef BOLT_PASSES_REGREASSIGN_H
1010
#define BOLT_PASSES_REGREASSIGN_H
1111

12+
#include "bolt/Passes/BinaryFunctionCallGraph.h"
1213
#include "bolt/Passes/BinaryPasses.h"
1314
#include "bolt/Passes/RegAnalysis.h"
1415

bolt/lib/Utils/CommandLineOpts.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,9 @@ OutputFilename("o",
135135
cl::Optional,
136136
cl::cat(BoltOutputCategory));
137137

138-
cl::opt<std::string>
139-
PerfData("perfdata",
140-
cl::desc("<data file>"),
141-
cl::Optional,
142-
cl::cat(AggregatorCategory),
143-
cl::sub(*cl::AllSubCommands));
138+
cl::opt<std::string> PerfData("perfdata", cl::desc("<data file>"), cl::Optional,
139+
cl::cat(AggregatorCategory),
140+
cl::sub(cl::SubCommand::getAll()));
144141

145142
static cl::alias
146143
PerfDataA("p",
@@ -181,12 +178,9 @@ cl::opt<bool> UpdateDebugSections(
181178
cl::cat(BoltCategory));
182179

183180
cl::opt<unsigned>
184-
Verbosity("v",
185-
cl::desc("set verbosity level for diagnostic output"),
186-
cl::init(0),
187-
cl::ZeroOrMore,
188-
cl::cat(BoltCategory),
189-
cl::sub(*cl::AllSubCommands));
181+
Verbosity("v", cl::desc("set verbosity level for diagnostic output"),
182+
cl::init(0), cl::ZeroOrMore, cl::cat(BoltCategory),
183+
cl::sub(cl::SubCommand::getAll()));
190184

191185
bool processAllFunctions() {
192186
if (opts::AggregateOnly)

bolt/tools/driver/llvm-bolt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static cl::OptionCategory *Perf2BoltCategories[] = {&AggregatorCategory,
4949
static cl::opt<std::string> InputFilename(cl::Positional,
5050
cl::desc("<executable>"),
5151
cl::Required, cl::cat(BoltCategory),
52-
cl::sub(*cl::AllSubCommands));
52+
cl::sub(cl::SubCommand::getAll()));
5353

5454
static cl::opt<std::string>
5555
InputDataFilename("data",

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Tooling/ReplacementsYaml.h"
2525
#include "llvm/ADT/ArrayRef.h"
2626
#include "llvm/ADT/Optional.h"
27+
#include "llvm/ADT/StringSet.h"
2728
#include "llvm/Support/FileSystem.h"
2829
#include "llvm/Support/MemoryBuffer.h"
2930
#include "llvm/Support/Path.h"
@@ -140,7 +141,7 @@ std::error_code collectReplacementsFromDirectory(
140141
static llvm::DenseMap<const FileEntry *, std::vector<tooling::Replacement>>
141142
groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
142143
const clang::SourceManager &SM) {
143-
std::set<StringRef> Warned;
144+
llvm::StringSet<> Warned;
144145
llvm::DenseMap<const FileEntry *, std::vector<tooling::Replacement>>
145146
GroupedReplacements;
146147

clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) {
5959
BlockToOutputState = dataflow::runDataflowAnalysis(
6060
*Context, Analysis, Env,
6161
[&ASTCtx, &Diagnoser, &Diagnostics](
62-
const Stmt *Stmt,
62+
const CFGStmt &Stmt,
6363
const DataflowAnalysisState<UncheckedOptionalAccessModel::Lattice>
6464
&State) mutable {
65-
auto StmtDiagnostics = Diagnoser.diagnose(ASTCtx, Stmt, State.Env);
65+
auto StmtDiagnostics =
66+
Diagnoser.diagnose(ASTCtx, Stmt.getStmt(), State.Env);
6667
llvm::move(StmtDiagnostics, std::back_inserter(Diagnostics));
6768
});
6869
if (!BlockToOutputState)

clang-tools-extra/clang-tidy/objc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_clang_library(clangTidyObjCModule
1010
ForbiddenSubclassingCheck.cpp
1111
MissingHashCheck.cpp
1212
NSInvocationArgumentLifetimeCheck.cpp
13+
NSDateFormatterCheck.cpp
1314
ObjCTidyModule.cpp
1415
PropertyDeclarationCheck.cpp
1516
SuperSelfCheck.cpp
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
//===--- NSDateFormatterCheck.cpp - clang-tidy ----------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "NSDateFormatterCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/ASTMatchers/ASTMatchers.h"
13+
14+
using namespace clang::ast_matchers;
15+
16+
namespace clang {
17+
namespace tidy {
18+
namespace objc {
19+
20+
void NSDateFormatterCheck::registerMatchers(MatchFinder *Finder) {
21+
// Adding matchers.
22+
23+
Finder->addMatcher(
24+
objcMessageExpr(hasSelector("setDateFormat:"),
25+
hasReceiverType(asString("NSDateFormatter *")),
26+
hasArgument(0, ignoringImpCasts(
27+
objcStringLiteral().bind("str_lit")))),
28+
this);
29+
}
30+
31+
static char ValidDatePatternChars[] = {
32+
'G', 'y', 'Y', 'u', 'U', 'r', 'Q', 'q', 'M', 'L', 'I', 'w', 'W', 'd',
33+
'D', 'F', 'g', 'E', 'e', 'c', 'a', 'b', 'B', 'h', 'H', 'K', 'k', 'j',
34+
'J', 'C', 'm', 's', 'S', 'A', 'z', 'Z', 'O', 'v', 'V', 'X', 'x'};
35+
36+
// Checks if the string pattern used as a date format specifier is valid.
37+
// A string pattern is valid if all the letters(a-z, A-Z) in it belong to the
38+
// set of reserved characters. See:
39+
// https://www.unicode.org/reports/tr35/tr35.html#Invalid_Patterns
40+
bool isValidDatePattern(StringRef Pattern) {
41+
for (auto &PatternChar : Pattern) {
42+
if (isalpha(PatternChar)) {
43+
if (std::find(std::begin(ValidDatePatternChars),
44+
std::end(ValidDatePatternChars),
45+
PatternChar) == std::end(ValidDatePatternChars)) {
46+
return false;
47+
}
48+
}
49+
}
50+
return true;
51+
}
52+
53+
// Checks if the string pattern used as a date format specifier contains
54+
// any incorrect pattern and reports it as a warning.
55+
// See: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns
56+
void NSDateFormatterCheck::check(const MatchFinder::MatchResult &Result) {
57+
// Callback implementation.
58+
const auto *StrExpr = Result.Nodes.getNodeAs<ObjCStringLiteral>("str_lit");
59+
const StringLiteral *SL = cast<ObjCStringLiteral>(StrExpr)->getString();
60+
StringRef SR = SL->getString();
61+
62+
if (!isValidDatePattern(SR)) {
63+
diag(StrExpr->getExprLoc(), "invalid date format specifier");
64+
}
65+
66+
if (SR.contains('y') && SR.contains('w') && !SR.contains('Y')) {
67+
diag(StrExpr->getExprLoc(),
68+
"use of calendar year (y) with week of the year (w); "
69+
"did you mean to use week-year (Y) instead?");
70+
}
71+
if (SR.contains('F')) {
72+
if (!(SR.contains('e') || SR.contains('E'))) {
73+
diag(StrExpr->getExprLoc(),
74+
"day of week in month (F) used without day of the week (e or E); "
75+
"did you forget e (or E) in the format string?");
76+
}
77+
if (!SR.contains('M')) {
78+
diag(StrExpr->getExprLoc(),
79+
"day of week in month (F) used without the month (M); "
80+
"did you forget M in the format string?");
81+
}
82+
}
83+
if (SR.contains('W') && !SR.contains('M')) {
84+
diag(StrExpr->getExprLoc(), "Week of Month (W) used without the month (M); "
85+
"did you forget M in the format string?");
86+
}
87+
if (SR.contains('Y') && SR.contains('Q') && !SR.contains('y')) {
88+
diag(StrExpr->getExprLoc(),
89+
"use of week year (Y) with quarter number (Q); "
90+
"did you mean to use calendar year (y) instead?");
91+
}
92+
if (SR.contains('Y') && SR.contains('M') && !SR.contains('y')) {
93+
diag(StrExpr->getExprLoc(),
94+
"use of week year (Y) with month (M); "
95+
"did you mean to use calendar year (y) instead?");
96+
}
97+
if (SR.contains('Y') && SR.contains('D') && !SR.contains('y')) {
98+
diag(StrExpr->getExprLoc(),
99+
"use of week year (Y) with day of the year (D); "
100+
"did you mean to use calendar year (y) instead?");
101+
}
102+
if (SR.contains('Y') && SR.contains('W') && !SR.contains('y')) {
103+
diag(StrExpr->getExprLoc(),
104+
"use of week year (Y) with week of the month (W); "
105+
"did you mean to use calendar year (y) instead?");
106+
}
107+
if (SR.contains('Y') && SR.contains('F') && !SR.contains('y')) {
108+
diag(StrExpr->getExprLoc(),
109+
"use of week year (Y) with day of the week in month (F); "
110+
"did you mean to use calendar year (y) instead?");
111+
}
112+
}
113+
114+
} // namespace objc
115+
} // namespace tidy
116+
} // namespace clang
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===--- NSDateFormatterCheck.h - clang-tidy --------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_NSDATEFORMATTERCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_NSDATEFORMATTERCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace objc {
17+
18+
/// Checks the string pattern used as a date format specifier and reports
19+
/// warnings if it contains any incorrect sub-pattern.
20+
///
21+
/// For the user-facing documentation see:
22+
/// http://clang.llvm.org/extra/clang-tidy/checks/objc-NSDateFormatter.html
23+
class NSDateFormatterCheck : public ClangTidyCheck {
24+
public:
25+
NSDateFormatterCheck(StringRef Name, ClangTidyContext *Context)
26+
: ClangTidyCheck(Name, Context) {}
27+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
28+
return LangOpts.ObjC;
29+
}
30+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32+
};
33+
34+
} // namespace objc
35+
} // namespace tidy
36+
} // namespace clang
37+
38+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_NSDATEFORMATTERCHECK_H

0 commit comments

Comments
 (0)