Skip to content

Commit 6b554b9

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:7ebf3e019488 into amd-gfx:481ed31ee2aa
Local branch amd-gfx 481ed31 Merged main:c14ca4c16c22 into amd-gfx:6385230779ab Remote branch main 7ebf3e0 [StaticAnalyzer] Remove isShiftOverflow and isLeftShiftResultUnrepresentable
2 parents 481ed31 + 7ebf3e0 commit 6b554b9

File tree

26 files changed

+606
-98
lines changed

26 files changed

+606
-98
lines changed

clang/lib/Format/FormatToken.h

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,10 @@ struct FormatToken {
618618

619619
bool isStringLiteral() const { return tok::isStringLiteral(Tok.getKind()); }
620620

621+
bool isAttribute() const {
622+
return isOneOf(tok::kw___attribute, tok::kw___declspec, TT_AttributeMacro);
623+
}
624+
621625
bool isObjCAtKeyword(tok::ObjCKeywordKind Kind) const {
622626
return Tok.isObjCAtKeyword(Kind);
623627
}
@@ -633,9 +637,10 @@ struct FormatToken {
633637

634638
bool canBePointerOrReferenceQualifier() const {
635639
return isOneOf(tok::kw_const, tok::kw_restrict, tok::kw_volatile,
636-
tok::kw___attribute, tok::kw__Nonnull, tok::kw__Nullable,
640+
tok::kw__Nonnull, tok::kw__Nullable,
637641
tok::kw__Null_unspecified, tok::kw___ptr32, tok::kw___ptr64,
638-
tok::kw___funcref, TT_AttributeMacro);
642+
tok::kw___funcref) ||
643+
isAttribute();
639644
}
640645

641646
/// Determine whether the token is a simple-type-specifier.
@@ -708,25 +713,16 @@ struct FormatToken {
708713
/// Returns \c true if this is a keyword that can be used
709714
/// like a function call (e.g. sizeof, typeid, ...).
710715
bool isFunctionLikeKeyword() const {
711-
switch (Tok.getKind()) {
712-
case tok::kw_throw:
713-
case tok::kw_typeid:
714-
case tok::kw_return:
715-
case tok::kw_sizeof:
716-
case tok::kw_alignof:
717-
case tok::kw_alignas:
718-
case tok::kw_decltype:
719-
case tok::kw_noexcept:
720-
case tok::kw_static_assert:
721-
case tok::kw__Atomic:
722-
case tok::kw___attribute:
723-
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
724-
#include "clang/Basic/TransformTypeTraits.def"
725-
case tok::kw_requires:
716+
if (isAttribute())
726717
return true;
727-
default:
728-
return false;
729-
}
718+
719+
return isOneOf(tok::kw_throw, tok::kw_typeid, tok::kw_return,
720+
tok::kw_sizeof, tok::kw_alignof, tok::kw_alignas,
721+
tok::kw_decltype, tok::kw_noexcept, tok::kw_static_assert,
722+
tok::kw__Atomic,
723+
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
724+
#include "clang/Basic/TransformTypeTraits.def"
725+
tok::kw_requires);
730726
}
731727

732728
/// Returns \c true if this is a string literal that's like a label,

clang/lib/Format/NamespaceEndCommentsFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ processTokens(const FormatToken *Tok, tok::TokenKind StartTok,
4848
const FormatToken *skipAttribute(const FormatToken *Tok) {
4949
if (!Tok)
5050
return nullptr;
51-
if (Tok->is(tok::kw___attribute)) {
51+
if (Tok->isAttribute()) {
5252
Tok = Tok->getNextNonComment();
5353
Tok = processTokens(Tok, tok::l_paren, tok::r_paren, nullptr);
5454
} else if (Tok->is(tok::l_square)) {

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ class AnnotatingParser {
376376
// Infer the role of the l_paren based on the previous token if we haven't
377377
// detected one yet.
378378
if (PrevNonComment && OpeningParen.is(TT_Unknown)) {
379-
if (PrevNonComment->is(tok::kw___attribute)) {
379+
if (PrevNonComment->isAttribute()) {
380380
OpeningParen.setType(TT_AttributeLParen);
381381
} else if (PrevNonComment->isOneOf(TT_TypenameMacro, tok::kw_decltype,
382382
tok::kw_typeof,
@@ -1207,11 +1207,13 @@ class AnnotatingParser {
12071207
return false;
12081208
if (Line.MustBeDeclaration && Contexts.size() == 1 &&
12091209
!Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) &&
1210-
!Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) &&
1211-
(!Tok->Previous ||
1212-
!Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause,
1213-
TT_LeadingJavaAnnotation))) {
1214-
Line.MightBeFunctionDecl = true;
1210+
!Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen)) {
1211+
if (const auto *Previous = Tok->Previous;
1212+
!Previous ||
1213+
(!Previous->isAttribute() &&
1214+
!Previous->isOneOf(TT_RequiresClause, TT_LeadingJavaAnnotation))) {
1215+
Line.MightBeFunctionDecl = true;
1216+
}
12151217
}
12161218
break;
12171219
case tok::l_square:
@@ -2389,7 +2391,7 @@ class AnnotatingParser {
23892391
assert(T->MatchingParen->is(tok::l_paren));
23902392
assert(T->MatchingParen->is(TT_AttributeLParen));
23912393
if (const auto *Tok = T->MatchingParen->Previous;
2392-
Tok && Tok->is(tok::kw___attribute)) {
2394+
Tok && Tok->isAttribute()) {
23932395
T = Tok->Previous;
23942396
continue;
23952397
}
@@ -5613,10 +5615,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
56135615
tok::less, tok::coloncolon);
56145616
}
56155617

5616-
if (Right.is(tok::kw___attribute) ||
5617-
(Right.is(tok::l_square) && Right.is(TT_AttributeSquare))) {
5618+
if (Right.isAttribute())
5619+
return true;
5620+
5621+
if (Right.is(tok::l_square) && Right.is(TT_AttributeSquare))
56185622
return Left.isNot(TT_AttributeSquare);
5619-
}
56205623

56215624
if (Left.is(tok::identifier) && Right.is(tok::string_literal))
56225625
return true;

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
354354
bool SwitchLabelEncountered = false;
355355

356356
do {
357-
if (FormatTok->getType() == TT_AttributeMacro) {
357+
if (FormatTok->isAttribute()) {
358358
nextToken();
359359
continue;
360360
}
@@ -2658,7 +2658,7 @@ static void markOptionalBraces(FormatToken *LeftBrace) {
26582658

26592659
void UnwrappedLineParser::handleAttributes() {
26602660
// Handle AttributeMacro, e.g. `if (x) UNLIKELY`.
2661-
if (FormatTok->is(TT_AttributeMacro))
2661+
if (FormatTok->isAttribute())
26622662
nextToken();
26632663
else if (FormatTok->is(tok::l_square))
26642664
handleCppAttributes();
@@ -3835,8 +3835,8 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
38353835
// it is often token-pasted.
38363836
// An [[attribute]] can be before the identifier.
38373837
while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::hashhash,
3838-
tok::kw___attribute, tok::kw___declspec,
38393838
tok::kw_alignas, tok::l_square) ||
3839+
FormatTok->isAttribute() ||
38403840
((Style.Language == FormatStyle::LK_Java || Style.isJavaScript()) &&
38413841
FormatTok->isOneOf(tok::period, tok::comma))) {
38423842
if (Style.isJavaScript() &&

clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,6 @@ static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
5858
return StOutBound && !StInBound;
5959
}
6060

61-
static bool isShiftOverflow(const BinaryOperator *B, CheckerContext &C) {
62-
return C.isGreaterOrEqual(
63-
B->getRHS(), C.getASTContext().getIntWidth(B->getLHS()->getType()));
64-
}
65-
66-
static bool isLeftShiftResultUnrepresentable(const BinaryOperator *B,
67-
CheckerContext &C) {
68-
SValBuilder &SB = C.getSValBuilder();
69-
ProgramStateRef State = C.getState();
70-
const llvm::APSInt *LHS = SB.getKnownValue(State, C.getSVal(B->getLHS()));
71-
const llvm::APSInt *RHS = SB.getKnownValue(State, C.getSVal(B->getRHS()));
72-
assert(LHS && RHS && "Values unknown, inconsistent state");
73-
return (unsigned)RHS->getZExtValue() > LHS->countl_zero();
74-
}
75-
7661
void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
7762
CheckerContext &C) const {
7863
if (C.getSVal(B).isUndef()) {

clang/test/OpenMP/ompx_bare_messages.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clang_cc1 -verify -fopenmp %s
2-
// RUN: %clang_cc1 -verify -fopenmp-simd %s
3-
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64 %s
1+
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown %s
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -triple x86_64-unknown-unknown %s
3+
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64 %s
44

55
void foo() {
66
}

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,19 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) {
21072107
EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_Unknown);
21082108
EXPECT_TOKEN(Tokens[6], tok::r_paren, TT_Unknown);
21092109
EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_AttributeRParen);
2110+
2111+
Tokens = annotate("bool foo __declspec(dllimport);");
2112+
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
2113+
EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_AttributeLParen);
2114+
EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen);
2115+
2116+
FormatStyle Style = getLLVMStyle();
2117+
Style.AttributeMacros.push_back("FOO");
2118+
Tokens = annotate("bool foo FOO(unused);", Style);
2119+
ASSERT_EQ(Tokens.size(), 8u) << Tokens;
2120+
EXPECT_TOKEN(Tokens[2], tok::identifier, TT_AttributeMacro);
2121+
EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_AttributeLParen);
2122+
EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen);
21102123
}
21112124

21122125
} // namespace

lldb/include/lldb/Breakpoint/BreakpointName.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,11 @@ class BreakpointName {
141141
{
142142
SetHelp(help);
143143
}
144-
145-
BreakpointName(ConstString name,
146-
BreakpointOptions &options,
147-
const Permissions &permissions = Permissions(),
148-
const char *help = nullptr) :
149-
m_name(name), m_options(options),
150-
m_permissions(permissions) {
151-
SetHelp(help);
152-
};
153144

154145
BreakpointName(const BreakpointName &rhs) :
155146
m_name(rhs.m_name), m_options(rhs.m_options),
156147
m_permissions(rhs.m_permissions), m_help(rhs.m_help)
157148
{}
158-
159-
BreakpointName(ConstString name, const Breakpoint &bkpt,
160-
const char *help);
161149

162150
ConstString GetName() const { return m_name; }
163151
BreakpointOptions &GetOptions() { return m_options; }

lldb/source/Breakpoint/BreakpointName.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ const Flags::ValueType BreakpointName::Permissions::permissions_mask
2828
(0x5u)
2929
};
3030

31-
BreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt,
32-
const char *help) :
33-
m_name(name), m_options(bkpt.GetOptions())
34-
{
35-
SetHelp(help);
36-
}
37-
3831
bool BreakpointName::Permissions::GetDescription(Stream *s,
3932
lldb::DescriptionLevel level) {
4033
if (!AnySet())

llvm/include/llvm/BinaryFormat/GOFF.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// constants for the GOFF file format.
1111
//
1212
// GOFF specifics can be found in MVS Program Management: Advanced Facilities.
13+
// See
14+
// https://www.ibm.com/docs/en/zos/3.1.0?topic=facilities-generalized-object-file-format-goff
1315
//
1416
//===----------------------------------------------------------------------===//
1517

@@ -19,13 +21,24 @@
1921
#include "llvm/Support/DataTypes.h"
2022

2123
namespace llvm {
24+
2225
namespace GOFF {
2326

27+
/// \brief Length of the parts of a physical GOFF record.
2428
constexpr uint8_t RecordLength = 80;
2529
constexpr uint8_t RecordPrefixLength = 3;
2630
constexpr uint8_t PayloadLength = 77;
31+
constexpr uint8_t RecordContentLength = RecordLength - RecordPrefixLength;
32+
33+
/// \brief Maximum data length before starting a new card for RLD and TXT data.
34+
///
35+
/// The maximum number of bytes that can be included in an RLD or TXT record and
36+
/// their continuations is a SIGNED 16 bit int despite what the spec says. The
37+
/// number of bytes we allow ourselves to attach to a card is thus arbitrarily
38+
/// limited to 32K-1 bytes.
39+
constexpr uint16_t MaxDataLength = 32 * 1024 - 1;
2740

28-
// Prefix byte on every record. This indicates GOFF format.
41+
/// \brief Prefix byte on every record. This indicates GOFF format.
2942
constexpr uint8_t PTVPrefix = 0x03;
3043

3144
enum RecordType : uint8_t {

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476404
19+
#define LLVM_MAIN_REVISION 476411
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===- MCGOFFObjectWriter.h - GOFF Object Writer ----------------*- 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_MC_MCGOFFOBJECTWRITER_H
10+
#define LLVM_MC_MCGOFFOBJECTWRITER_H
11+
12+
#include "llvm/MC/MCObjectWriter.h"
13+
14+
namespace llvm {
15+
class MCObjectWriter;
16+
class raw_pwrite_stream;
17+
18+
class MCGOFFObjectTargetWriter : public MCObjectTargetWriter {
19+
protected:
20+
MCGOFFObjectTargetWriter() = default;
21+
22+
public:
23+
virtual ~MCGOFFObjectTargetWriter() = default;
24+
25+
Triple::ObjectFormatType getFormat() const override { return Triple::GOFF; }
26+
27+
static bool classof(const MCObjectTargetWriter *W) {
28+
return W->getFormat() == Triple::GOFF;
29+
}
30+
};
31+
32+
/// \brief Construct a new GOFF writer instance.
33+
///
34+
/// \param MOTW - The target-specific GOFF writer subclass.
35+
/// \param OS - The stream to write to.
36+
/// \returns The constructed object writer.
37+
std::unique_ptr<MCObjectWriter>
38+
createGOFFObjectWriter(std::unique_ptr<MCGOFFObjectTargetWriter> MOTW,
39+
raw_pwrite_stream &OS);
40+
} // namespace llvm
41+
42+
#endif

llvm/include/llvm/MC/MCGOFFStreamer.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===- MCGOFFStreamer.h - MCStreamer GOFF Object File Interface--*- 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_MC_MCGOFFSTREAMER_H
10+
#define LLVM_MC_MCGOFFSTREAMER_H
11+
12+
#include "llvm/MC/MCObjectStreamer.h"
13+
#include "llvm/MC/MCObjectWriter.h"
14+
15+
namespace llvm {
16+
17+
class MCGOFFStreamer : public MCObjectStreamer {
18+
public:
19+
MCGOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
20+
std::unique_ptr<MCObjectWriter> OW,
21+
std::unique_ptr<MCCodeEmitter> Emitter)
22+
: MCObjectStreamer(Context, std::move(MAB), std::move(OW),
23+
std::move(Emitter)) {}
24+
25+
~MCGOFFStreamer() override;
26+
27+
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override {
28+
return false;
29+
}
30+
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
31+
Align ByteAlignment) override {}
32+
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override {}
33+
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
34+
uint64_t Size = 0, Align ByteAlignment = Align(1),
35+
SMLoc Loc = SMLoc()) override {}
36+
};
37+
38+
} // end namespace llvm
39+
40+
#endif

0 commit comments

Comments
 (0)