Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I0101418ab9aed384628b887f4ea983599eda06c8
  • Loading branch information
ronlieb committed Jun 29, 2024
2 parents 1fb58bc + 0ce801f commit 81b3afd
Show file tree
Hide file tree
Showing 208 changed files with 3,263 additions and 3,488 deletions.
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/support/Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class JSONTracer : public EventTracer {
Out.object([&] {
Out.attribute("pid", 0);
Out.attribute("ph", Phase);
for (const auto &KV : Event)
Out.attribute(KV.first, KV.second);
for (const auto *KV : llvm::json::sortedElements(Event))
Out.attribute(KV->first, KV->second);
});
}

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/test/trace.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
# CHECK: "traceEvents": [
# CHECK: {
# CHECK: "ph": "X",
# CHECK: "name": "BuildPreamble",
# CHECK: "args": {
# CHECK: "File": "{{.*(/|\\)}}foo.c"
# CHECK: },
# CHECK: "name": "BuildPreamble",
# CHECK: }
# CHECK: {
# CHECK: "ph": "X",
# CHECK: "name": "BuildAST",
# CHECK: "args": {
# CHECK: "File": "{{.*(/|\\)}}foo.c"
# CHECK: },
# CHECK: "name": "BuildAST",
# CHECK: }
# CHECK: ]
# CHECK: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Sema/Sema.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Passes/PassBuilder.h"
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/OpenMPKinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ bool needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind);
/// is restricted only to memory order clauses of "OMPC_acquire",
/// "OMPC_relaxed" and "OMPC_seq_cst".
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter);

/// Checks if the specified directive is considered as "executable". This
/// combines the OpenMP categories of "executable" and "subsidiary", plus
/// any other directives that should be treated as executable.
/// \param DKind Specified directive.
/// \return true - if the above condition is met for this directive
/// otherwise - false.
bool isOpenMPExecutableDirective(OpenMPDirectiveKind DKind);
}

#endif
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/Interp/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ Descriptor::Descriptor(const DeclTy &D)
}

QualType Descriptor::getType() const {
if (auto *E = asExpr())
if (const auto *E = asExpr())
return E->getType();
if (auto *D = asValueDecl())
if (const auto *D = asValueDecl())
return D->getType();
if (auto *T = dyn_cast<TypeDecl>(asDecl()))
if (const auto *T = dyn_cast<TypeDecl>(asDecl()))
return QualType(T->getTypeForDecl(), 0);
llvm_unreachable("Invalid descriptor type");
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
if (const auto *ND = dyn_cast_if_present<NamedDecl>(asDecl()))
ND->printQualifiedName(OS);
else if (asExpr())
OS << "expr (TODO)";
OS << "Expr " << (const void *)asExpr();
}

// Print a few interesting bits about the descriptor.
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Basic/OpenMPKinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ bool clang::needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind) {
DKind == OMPD_target_parallel_loop;
}

bool clang::isOpenMPExecutableDirective(OpenMPDirectiveKind DKind) {
if (DKind == OMPD_error)
return true;
Category Cat = getDirectiveCategory(DKind);
return Cat == Category::Executable || Cat == Category::Subsidiary;
}

void clang::getOpenMPCaptureRegions(
SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
OpenMPDirectiveKind DKind) {
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/CodeGen/CGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
template <bool IsInBounds>
Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
const llvm::Twine &Name) {
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
llvm::GetElementPtrInst *GEP;
if (IsInBounds)
GEP = cast<llvm::GetElementPtrInst>(CreateConstInBoundsGEP2_32(
Expand Down Expand Up @@ -218,7 +218,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
Address CreateStructGEP(Address Addr, unsigned Index,
const llvm::Twine &Name = "") {
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));

Expand All @@ -240,7 +240,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
Address CreateConstArrayGEP(Address Addr, uint64_t Index,
const llvm::Twine &Name = "") {
llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
CharUnits EltSize =
CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType()));

Expand All @@ -260,7 +260,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index,
const llvm::Twine &Name = "") {
llvm::Type *ElTy = Addr.getElementType();
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));

return Address(
Expand All @@ -277,7 +277,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
Address CreateConstGEP(Address Addr, uint64_t Index,
const llvm::Twine &Name = "") {
llvm::Type *ElTy = Addr.getElementType();
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));

return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name),
Expand All @@ -290,7 +290,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
using CGBuilderBaseTy::CreateGEP;
Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index,
const llvm::Twine &Name = "") {
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
CharUnits EltSize =
CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));

Expand Down Expand Up @@ -412,7 +412,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
unsigned FieldIndex,
llvm::MDNode *DbgInfo) {
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
const llvm::DataLayout &DL = BB->getDataLayout();
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));

Expand Down
9 changes: 1 addition & 8 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ class AnnotatingParser {
Left->ParentBracket = Contexts.back().ContextKind;
ScopedContextCreator ContextCreator(*this, tok::less, 12);

// If this angle is in the context of an expression, we need to be more
// hesitant to detect it as opening template parameters.
bool InExprContext = Contexts.back().IsExpression;

Contexts.back().IsExpression = false;
// If there's a template keyword before the opening angle bracket, this is a
// template parameter, not an argument.
Expand Down Expand Up @@ -231,11 +227,8 @@ class AnnotatingParser {
next();
continue;
}
if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace) ||
(CurrentToken->isOneOf(tok::colon, tok::question) && InExprContext &&
!Style.isCSharp() && !Style.isProto())) {
if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace))
return false;
}
// If a && or || is found and interpreted as a binary operator, this set
// of angles is likely part of something like "a < b && c > d". If the
// angles are inside an expression, the ||/&& might also be a binary
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Parse/ParseOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2397,10 +2397,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
StmtResult Parser::ParseOpenMPExecutableDirective(
ParsedStmtContext StmtCtx, OpenMPDirectiveKind DKind, SourceLocation Loc,
bool ReadDirectiveWithinMetadirective) {
assert((DKind == OMPD_error ||
getDirectiveCategory(DKind) == Category::Executable ||
getDirectiveCategory(DKind) == Category::Subsidiary) &&
"Directive with an unexpected category");
assert(isOpenMPExecutableDirective(DKind) && "Unexpected directive category");

bool HasAssociatedStatement = true;
Association Assoc = getDirectiveAssociation(DKind);

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6375,6 +6375,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc,
OpenMPDirectiveKind PrevMappedDirective) {
assert(isOpenMPExecutableDirective(Kind) && "Unexpected directive category");

StmtResult Res = StmtError();
OpenMPBindClauseKind BindKind = OMPC_BIND_unknown;
llvm::SmallVector<OMPClause *> ClausesWithoutBind;
Expand Down
6 changes: 2 additions & 4 deletions clang/test/AST/Interp/arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,9 @@ namespace NonConstReads {
// both-note {{read of non-const variable 'z'}}
#else
void *p = nullptr;
int arr[!p]; // ref-error {{not allowed at file scope}} \
// expected-error {{not allowed at file scope}}
int arr[!p]; // both-error {{not allowed at file scope}}
int z;
int a[z]; // ref-error {{not allowed at file scope}} \
// expected-error {{not allowed at file scope}}
int a[z]; // both-error {{not allowed at file scope}}
#endif

const int y = 0;
Expand Down
18 changes: 18 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,24 @@ TEST_F(TokenAnnotatorTest, UnderstandsGreaterAfterTemplateCloser) {
EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
}

TEST_F(TokenAnnotatorTest, UnderstandsTernaryInTemplate) {
// IsExpression = false
auto Tokens = annotate("foo<true ? 1 : 2>();");
ASSERT_EQ(Tokens.size(), 12u) << Tokens;
EXPECT_TOKEN(Tokens[1], tok::less, TT_TemplateOpener);
EXPECT_TOKEN(Tokens[3], tok::question, TT_ConditionalExpr);
EXPECT_TOKEN(Tokens[5], tok::colon, TT_ConditionalExpr);
EXPECT_TOKEN(Tokens[7], tok::greater, TT_TemplateCloser);

// IsExpression = true
Tokens = annotate("return foo<true ? 1 : 2>();");
ASSERT_EQ(Tokens.size(), 13u) << Tokens;
EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
EXPECT_TOKEN(Tokens[4], tok::question, TT_ConditionalExpr);
EXPECT_TOKEN(Tokens[6], tok::colon, TT_ConditionalExpr);
EXPECT_TOKEN(Tokens[8], tok::greater, TT_TemplateCloser);
}

TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
auto Tokens = annotate("return a < b && c > d;");
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
Expand Down
21 changes: 21 additions & 0 deletions clang/www/cxx_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,27 @@ <h2 id="cxx26">C++2c implementation status</h2>
<td><a href="https://wg21.link/P2893R3">P2893R3</a></td>
<td class="none" align="center">No</td>
</tr>
<!-- Summer 2024 papers (St Louis) -->
<tr>
<td><tt>constexpr</tt> placement new</td>
<td><a href="https://wg21.link/P2747R2">P2747R2</a></td>
<td class="none" align="center">No</td>
</tr>
<tr>
<td>Deleting a Pointer to an Incomplete Type Should be Ill-formed</td>
<td><a href="https://wg21.link/P3144">P3144R2</a></td>
<td class="none" align="center">No</td>
</tr>
<tr>
<td>Ordering of constraints involving fold expressions</td>
<td><a href="https://wg21.link/P2963R3">P2963R3</a></td>
<td class="none" align="center">No</td>
</tr>
<tr>
<td>Structured binding declaration as a condition</td>
<td><a href="https://wg21.link/P0963R3">P0963R3</a></td>
<td class="none" align="center">No</td>
</tr>
</table>
</details>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// XFAIL: *

// RUN: %clangxx_host -gdwarf -o %t %s
// RUN: %lldb %t \
// RUN: -o "expr alignof(OverlappingDerived)" \
// RUN: -o "expr sizeof(OverlappingDerived)" \
// RUN: -o exit | FileCheck %s

struct Empty {};

struct OverlappingBase {
[[no_unique_address]] Empty e;
};
static_assert(sizeof(OverlappingBase) == 1);
static_assert(alignof(OverlappingBase) == 1);

struct Base {
int mem;
};

struct OverlappingDerived : Base, OverlappingBase {};
static_assert(alignof(OverlappingDerived) == 4);
static_assert(sizeof(OverlappingDerived) == 4);

// CHECK: (lldb) expr alignof(OverlappingDerived)
// CHECK-NEXT: ${{.*}} = 4
// CHECK: (lldb) expr sizeof(OverlappingDerived)
// CHECK-NEXT: ${{.*}} = 4

int main() { OverlappingDerived d; }
43 changes: 43 additions & 0 deletions lldb/test/Shell/SymbolFile/DWARF/packed-alignof.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// XFAIL: *
//
// RUN: %clangxx_host -gdwarf -o %t %s
// RUN: %lldb %t \
// RUN: -o "expr alignof(base)" \
// RUN: -o "expr alignof(packed_base)" \
// RUN: -o "expr alignof(derived)" \
// RUN: -o "expr sizeof(derived)" \
// RUN: -o exit | FileCheck %s

struct __attribute__((packed)) packed {
int x;
char y;
int z;
} g_packed_struct;

// LLDB incorrectly calculates alignof(base)
struct foo {};
struct base : foo { int x; };
static_assert(alignof(base) == 4);

// CHECK: (lldb) expr alignof(base)
// CHECK-NEXT: ${{.*}} = 4

// LLDB incorrectly calculates alignof(packed_base)
struct __attribute__((packed)) packed_base { int x; };
static_assert(alignof(packed_base) == 1);

// CHECK: (lldb) expr alignof(packed_base)
// CHECK-NEXT: ${{.*}} = 1

struct derived : packed, packed_base {
short s;
} g_derived;
static_assert(alignof(derived) == 2);
static_assert(sizeof(derived) == 16);

// CHECK: (lldb) expr alignof(derived)
// CHECK-NEXT: ${{.*}} = 2
// CHECK: (lldb) expr sizeof(derived)
// CHECK-NEXT: ${{.*}} = 16

int main() {}
Loading

0 comments on commit 81b3afd

Please sign in to comment.