Skip to content

Commit 822e155

Browse files
committed
Merge commit '67aa314bcee719a5821bd4ab69c9be5c84961784' into HEAD
2 parents 5f06ace + 67aa314 commit 822e155

File tree

861 files changed

+35243
-23802
lines changed

Some content is hidden

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

861 files changed

+35243
-23802
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,8 @@ bool BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
20312031
assert(PrevInstr && "no previous instruction for a fall through");
20322032
if (MIB->isUnconditionalBranch(Instr) &&
20332033
!MIB->isUnconditionalBranch(*PrevInstr) &&
2034-
!MIB->getConditionalTailCall(*PrevInstr)) {
2034+
!MIB->getConditionalTailCall(*PrevInstr) &&
2035+
!MIB->isReturn(*PrevInstr)) {
20352036
// Temporarily restore inserter basic block.
20362037
InsertBB = PrevBB;
20372038
} else {

bolt/test/AArch64/jmp-after-ret.s

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## This test checks that the unreachable unconditional branch is removed
2+
## if it is located after return instruction.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
7+
# RUN: %s -o %t.o
8+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
9+
# RUN: llvm-bolt %t.exe -o %t.bolt | FileCheck %s
10+
11+
# CHECK: UCE removed 1 blocks
12+
13+
.text
14+
.align 4
15+
.global main
16+
.type main, %function
17+
main:
18+
b.eq 1f
19+
ret
20+
b main
21+
1:
22+
mov x1, #1
23+
ret
24+
.size main, .-main

bolt/test/X86/jmp-after-ret.s

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## This test checks that the unreachable unconditional branch is removed
2+
## if it is located after return instruction.
3+
4+
# REQUIRES: system-linux
5+
6+
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
7+
# RUN: %s -o %t.o
8+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
9+
# RUN: llvm-bolt %t.exe -o %t.bolt | FileCheck %s
10+
11+
# CHECK: UCE removed 1 blocks
12+
13+
.text
14+
.globl main
15+
.type main, %function
16+
.size main, .Lend-main
17+
main:
18+
je 1f
19+
retq
20+
jmp main
21+
1:
22+
movl $0x2, %ebx
23+
retq
24+
.Lend:

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

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,53 @@ namespace optutils = clang::tidy::utils::options;
2323
static constexpr std::size_t DefaultMinimumLength = 2;
2424

2525
/// The default value for ignored parameter names.
26-
static const std::string DefaultIgnoredParameterNames =
27-
optutils::serializeStringList({"\"\"", "iterator", "Iterator", "begin",
28-
"Begin", "end", "End", "first", "First",
29-
"last", "Last", "lhs", "LHS", "rhs", "RHS"});
26+
static constexpr llvm::StringLiteral DefaultIgnoredParameterNames = "\"\";"
27+
"iterator;"
28+
"Iterator;"
29+
"begin;"
30+
"Begin;"
31+
"end;"
32+
"End;"
33+
"first;"
34+
"First;"
35+
"last;"
36+
"Last;"
37+
"lhs;"
38+
"LHS;"
39+
"rhs;"
40+
"RHS";
3041

3142
/// The default value for ignored parameter type suffixes.
32-
static const std::string DefaultIgnoredParameterTypeSuffixes =
33-
optutils::serializeStringList({"bool",
34-
"Bool",
35-
"_Bool",
36-
"it",
37-
"It",
38-
"iterator",
39-
"Iterator",
40-
"inputit",
41-
"InputIt",
42-
"forwardit",
43-
"ForwardIt",
44-
"bidirit",
45-
"BidirIt",
46-
"constiterator",
47-
"const_iterator",
48-
"Const_Iterator",
49-
"Constiterator",
50-
"ConstIterator",
51-
"RandomIt",
52-
"randomit",
53-
"random_iterator",
54-
"ReverseIt",
55-
"reverse_iterator",
56-
"reverse_const_iterator",
57-
"ConstReverseIterator",
58-
"Const_Reverse_Iterator",
59-
"const_reverse_iterator",
60-
"Constreverseiterator",
61-
"constreverseiterator"});
43+
static constexpr llvm::StringLiteral DefaultIgnoredParameterTypeSuffixes =
44+
"bool;"
45+
"Bool;"
46+
"_Bool;"
47+
"it;"
48+
"It;"
49+
"iterator;"
50+
"Iterator;"
51+
"inputit;"
52+
"InputIt;"
53+
"forwardit;"
54+
"ForwardIt;"
55+
"bidirit;"
56+
"BidirIt;"
57+
"constiterator;"
58+
"const_iterator;"
59+
"Const_Iterator;"
60+
"Constiterator;"
61+
"ConstIterator;"
62+
"RandomIt;"
63+
"randomit;"
64+
"random_iterator;"
65+
"ReverseIt;"
66+
"reverse_iterator;"
67+
"reverse_const_iterator;"
68+
"ConstReverseIterator;"
69+
"Const_Reverse_Iterator;"
70+
"const_reverse_iterator;"
71+
"Constreverseiterator;"
72+
"constreverseiterator";
6273

6374
/// The default value for the QualifiersMix check option.
6475
static constexpr bool DefaultQualifiersMix = false;

clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
#include "llvm/Support/Regex.h"
1515
#include <algorithm>
1616
#include <cctype>
17+
#include <functional>
1718

1819
namespace clang {
1920
namespace tidy {
2021
namespace cppcoreguidelines {
2122

22-
namespace {
23-
24-
bool isCapsOnly(StringRef Name) {
25-
return std::all_of(Name.begin(), Name.end(), [](const char C) {
26-
if (std::isupper(C) || std::isdigit(C) || C == '_')
27-
return true;
28-
return false;
23+
static bool isCapsOnly(StringRef Name) {
24+
return llvm::all_of(Name, [](const char C) {
25+
return std::isupper(C) || std::isdigit(C) || C == '_';
2926
});
3027
}
3128

29+
namespace {
30+
3231
class MacroUsageCallbacks : public PPCallbacks {
3332
public:
3433
MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager &SM,
35-
StringRef RegExpStr, bool CapsOnly, bool IgnoreCommandLine)
34+
StringRef RegExpStr, bool CapsOnly,
35+
bool IgnoreCommandLine)
3636
: Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
3737
IgnoreCommandLineMacros(IgnoreCommandLine) {}
3838
void MacroDefined(const Token &MacroNameTok,
@@ -79,21 +79,24 @@ void MacroUsageCheck::registerPPCallbacks(const SourceManager &SM,
7979
}
8080

8181
void MacroUsageCheck::warnMacro(const MacroDirective *MD, StringRef MacroName) {
82-
StringRef Message =
83-
"macro '%0' used to declare a constant; consider using a 'constexpr' "
84-
"constant";
85-
86-
/// A variadic macro is function-like at the same time. Therefore variadic
87-
/// macros are checked first and will be excluded for the function-like
88-
/// diagnostic.
89-
if (MD->getMacroInfo()->isVariadic())
82+
const MacroInfo *Info = MD->getMacroInfo();
83+
StringRef Message;
84+
85+
if (llvm::all_of(Info->tokens(), std::mem_fn(&Token::isLiteral)))
86+
Message = "macro '%0' used to declare a constant; consider using a "
87+
"'constexpr' constant";
88+
// A variadic macro is function-like at the same time. Therefore variadic
89+
// macros are checked first and will be excluded for the function-like
90+
// diagnostic.
91+
else if (Info->isVariadic())
9092
Message = "variadic macro '%0' used; consider using a 'constexpr' "
9193
"variadic template function";
92-
else if (MD->getMacroInfo()->isFunctionLike())
94+
else if (Info->isFunctionLike())
9395
Message = "function-like macro '%0' used; consider a 'constexpr' template "
9496
"function";
9597

96-
diag(MD->getLocation(), Message) << MacroName;
98+
if (!Message.empty())
99+
diag(MD->getLocation(), Message) << MacroName;
97100
}
98101

99102
void MacroUsageCheck::warnNaming(const MacroDirective *MD,

clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -285,31 +285,6 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
285285
return {};
286286
}
287287

288-
// If the return type is a constrained 'auto', we need to include the token
289-
// after the concept. Unfortunately, the source range of an AutoTypeLoc, if it
290-
// is constrained, does not include the 'auto'.
291-
// FIXME: fix the AutoTypeLoc location in clang.
292-
auto ATL = ReturnLoc.getAs<AutoTypeLoc>();
293-
if (ATL && ATL.isConstrained() && !ATL.isDecltypeAuto()) {
294-
SourceLocation End =
295-
expandIfMacroId(ReturnLoc.getSourceRange().getEnd(), SM);
296-
SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);
297-
298-
// Extend the ReturnTypeRange until the last token before the function
299-
// name.
300-
std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(End);
301-
StringRef File = SM.getBufferData(Loc.first);
302-
const char *TokenBegin = File.data() + Loc.second;
303-
Lexer Lexer(SM.getLocForStartOfFile(Loc.first), LangOpts, File.begin(),
304-
TokenBegin, File.end());
305-
Token T;
306-
SourceLocation LastTLoc = End;
307-
while (!Lexer.LexFromRawLexer(T) &&
308-
SM.isBeforeInTranslationUnit(T.getLocation(), BeginNameF)) {
309-
LastTLoc = T.getLocation();
310-
}
311-
ReturnTypeRange.setEnd(LastTLoc);
312-
}
313288

314289
// If the return type has no local qualifiers, it's source range is accurate.
315290
if (!hasAnyNestedLocalQualifiers(F.getReturnType()))

0 commit comments

Comments
 (0)