Skip to content

Commit 2f4a3c6

Browse files
authored
Merge pull request #167 from sx-aurora-dev/feature/merge-upstream-20220215
Feature/merge upstream 20220215
2 parents 81e6745 + 684c25e commit 2f4a3c6

File tree

406 files changed

+3927
-2064
lines changed

Some content is hidden

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

406 files changed

+3927
-2064
lines changed

clang/include/clang/Tooling/Transformer/Transformer.h

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,25 @@ namespace tooling {
2222
/// defined by the arguments of the constructor.
2323
class Transformer : public ast_matchers::MatchFinder::MatchCallback {
2424
public:
25-
using ChangeConsumer =
26-
std::function<void(Expected<clang::tooling::AtomicChange> Change)>;
27-
28-
/// \param Consumer Receives each rewrite or error. Will not necessarily be
29-
/// called for each match; for example, if the rewrite is not applicable
30-
/// because of macros, but doesn't fail. Note that clients are responsible
25+
/// Provides the set of changes to the consumer. The callback is free to move
26+
/// or destructively consume the changes as needed.
27+
///
28+
/// We use \c MutableArrayRef as an abstraction to provide decoupling, and we
29+
/// expect the majority of consumers to copy or move the individual values
30+
/// into a separate data structure.
31+
using ChangeSetConsumer = std::function<void(
32+
Expected<llvm::MutableArrayRef<AtomicChange>> Changes)>;
33+
34+
/// \param Consumer Receives all rewrites for a single match, or an error.
35+
/// Will not necessarily be called for each match; for example, if the rule
36+
/// generates no edits but does not fail. Note that clients are responsible
3137
/// for handling the case that independent \c AtomicChanges conflict with each
3238
/// other.
33-
Transformer(transformer::RewriteRule Rule, ChangeConsumer Consumer)
34-
: Rule(std::move(Rule)), Consumer(std::move(Consumer)) {}
39+
explicit Transformer(transformer::RewriteRule Rule,
40+
ChangeSetConsumer Consumer)
41+
: Rule(std::move(Rule)), Consumer(std::move(Consumer)) {
42+
assert(this->Consumer && "Consumer is empty");
43+
}
3544

3645
/// N.B. Passes `this` pointer to `MatchFinder`. So, this object should not
3746
/// be moved after this call.
@@ -43,8 +52,9 @@ class Transformer : public ast_matchers::MatchFinder::MatchCallback {
4352

4453
private:
4554
transformer::RewriteRule Rule;
46-
/// Receives each successful rewrites as an \c AtomicChange.
47-
ChangeConsumer Consumer;
55+
/// Receives sets of successful rewrites as an
56+
/// \c llvm::ArrayRef<AtomicChange>.
57+
ChangeSetConsumer Consumer;
4858
};
4959
} // namespace tooling
5060
} // namespace clang

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,9 @@ void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
862862
MangleReturnType, FD);
863863
}
864864

865-
static const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC) {
866-
while (isa<LinkageSpecDecl>(DC)) {
867-
DC = getEffectiveParentContext(DC);
868-
}
869-
870-
return DC;
871-
}
872-
873865
/// Return whether a given namespace is the 'std' namespace.
874866
static bool isStd(const NamespaceDecl *NS) {
875-
if (!IgnoreLinkageSpecDecls(getEffectiveParentContext(NS))
876-
->isTranslationUnit())
867+
if (!getEffectiveParentContext(NS)->isTranslationUnit())
877868
return false;
878869

879870
const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
@@ -978,7 +969,7 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
978969
return;
979970
}
980971

981-
DC = IgnoreLinkageSpecDecls(DC);
972+
assert(!isa<LinkageSpecDecl>(DC) && "context cannot be LinkageSpecDecl");
982973

983974
if (isLocalContainerContext(DC)) {
984975
mangleLocalName(GD, AdditionalAbiTags);
@@ -1054,7 +1045,7 @@ void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
10541045
void CXXNameMangler::mangleTemplateName(const TemplateDecl *TD,
10551046
const TemplateArgument *TemplateArgs,
10561047
unsigned NumTemplateArgs) {
1057-
const DeclContext *DC = IgnoreLinkageSpecDecls(getEffectiveDeclContext(TD));
1048+
const DeclContext *DC = getEffectiveDeclContext(TD);
10581049

10591050
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
10601051
mangleUnscopedTemplateName(TD, nullptr);
@@ -1070,7 +1061,7 @@ void CXXNameMangler::mangleUnscopedName(GlobalDecl GD,
10701061
// <unscoped-name> ::= <unqualified-name>
10711062
// ::= St <unqualified-name> # ::std::
10721063

1073-
if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
1064+
if (isStdNamespace(getEffectiveDeclContext(ND)))
10741065
Out << "St";
10751066

10761067
mangleUnqualifiedName(GD, AdditionalAbiTags);
@@ -2030,7 +2021,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
20302021
// ::= # empty
20312022
// ::= <substitution>
20322023

2033-
DC = IgnoreLinkageSpecDecls(DC);
2024+
assert(!isa<LinkageSpecDecl>(DC) && "prefix cannot be LinkageSpecDecl");
20342025

20352026
if (DC->isTranslationUnit())
20362027
return;

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
770770
// Apply sanitizer attributes to the function.
771771
if (SanOpts.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
772772
Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
773-
if (SanOpts.hasOneOf(SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress))
773+
if (SanOpts.hasOneOf(SanitizerKind::HWAddress |
774+
SanitizerKind::KernelHWAddress))
774775
Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
775776
if (SanOpts.has(SanitizerKind::MemTag))
776777
Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3142,7 +3142,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
31423142
// initializers.
31433143
if (Line.IsMultiVariableDeclStmt &&
31443144
(Left.NestingLevel == Line.First->NestingLevel ||
3145-
startsWithInitStatement(Line)))
3145+
((Left.NestingLevel == Line.First->NestingLevel + 1) &&
3146+
startsWithInitStatement(Line))))
31463147
return false;
31473148
return Left.Previous && !Left.Previous->isOneOf(
31483149
tok::l_paren, tok::coloncolon, tok::l_square);

clang/lib/Headers/opencl-c.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13424,8 +13424,8 @@ long __ovld atomic_fetch_max(volatile __global atomic_long *object, long operand
1342413424
long __ovld atomic_fetch_max(volatile __local atomic_long *object, long operand);
1342513425
ulong __ovld atomic_fetch_max(volatile __global atomic_ulong *object, ulong operand);
1342613426
ulong __ovld atomic_fetch_max(volatile __local atomic_ulong *object, ulong operand);
13427-
uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, ptrdiff_t operand);
13428-
uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, ptrdiff_t operand);
13427+
uintptr_t __ovld atomic_fetch_max(volatile __global atomic_uintptr_t *object, uintptr_t operand);
13428+
uintptr_t __ovld atomic_fetch_max(volatile __local atomic_uintptr_t *object, uintptr_t operand);
1342913429
#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
1343013430
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
1343113431
#endif
@@ -13543,8 +13543,8 @@ long __ovld atomic_fetch_max_explicit(volatile __global atomic_long *object, lon
1354313543
long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *object, long operand, memory_order order);
1354413544
ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *object, ulong operand, memory_order order);
1354513545
ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *object, ulong operand, memory_order order);
13546-
uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
13547-
uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
13546+
uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t *object, uintptr_t operand, memory_order order);
13547+
uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t *object, uintptr_t operand, memory_order order);
1354813548
#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
1354913549
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
1355013550
#endif
@@ -13661,8 +13661,8 @@ long __ovld atomic_fetch_max_explicit(volatile __global atomic_long *object, lon
1366113661
long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *object, long operand, memory_order order, memory_scope scope);
1366213662
ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
1366313663
ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
13664-
uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
13665-
uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
13664+
uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t *object, uintptr_t operand, memory_order order, memory_scope scope);
13665+
uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t *object, uintptr_t operand, memory_order order, memory_scope scope);
1366613666
#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
1366713667
#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
1366813668

clang/lib/Tooling/Transformer/Transformer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ void Transformer::run(const MatchFinder::MatchResult &Result) {
6565
}
6666
}
6767

68+
llvm::SmallVector<AtomicChange, 1> Changes;
69+
Changes.reserve(ChangesByFileID.size());
6870
for (auto &IDChangePair : ChangesByFileID)
69-
Consumer(std::move(IDChangePair.second));
71+
Changes.push_back(std::move(IDChangePair.second));
72+
Consumer(llvm::MutableArrayRef<AtomicChange>(Changes));
7073
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
void test1() {}
1+
void test1(void) {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
void test2() {}
1+
void test2(void) {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
void foo() { }
1+
void foo(void) { }

clang/test/CodeGen/_Bool-conversion.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// CHECK: }
66

77
static _Bool f0_0(void *a0) { return (_Bool) a0; }
8-
int f0() { return f0_0((void*) 0x2); }
8+
int f0(void) { return f0_0((void*) 0x2); }
99

1010
_Bool f1(void) {
11-
return (_Bool) ({ void (*x)(); x = 0; });
11+
return (_Bool) ({ void (*x)(void); x = 0; });
1212
}

0 commit comments

Comments
 (0)