Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I17c58e5f74ea661b1fdf8fa4053474c5547a1c0a
  • Loading branch information
ronlieb committed Sep 2, 2024
2 parents 14feed9 + 5dcea46 commit 6f9c93f
Show file tree
Hide file tree
Showing 115 changed files with 3,640 additions and 1,373 deletions.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ Bug Fixes to C++ Support
- Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)
- Template parameter names are considered in the name lookup of out-of-line class template
specialization right before its declaration context. (#GH64082)
- Fixed a constraint comparison bug for friend declarations. (#GH78101)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace clang {
DIAG_SIZE_AST = 300,
DIAG_SIZE_COMMENT = 100,
DIAG_SIZE_CROSSTU = 100,
DIAG_SIZE_SEMA = 4500,
DIAG_SIZE_SEMA = 5000,
DIAG_SIZE_ANALYSIS = 100,
DIAG_SIZE_REFACTORING = 1000,
DIAG_SIZE_INSTALLAPI = 100,
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -5606,7 +5606,7 @@ def note_checking_constraints_for_function_here : Note<
def note_constraint_substitution_here : Note<
"while substituting template arguments into constraint expression here">;
def note_constraint_normalization_here : Note<
"while calculating associated constraint of template '%0' here">;
"while calculating associated constraint of template %0 here">;
def note_parameter_mapping_substitution_here : Note<
"while substituting into concept arguments here; substitution failures not "
"allowed in concept arguments">;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12720,8 +12720,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
}

case Builtin::BI__noop:
// __noop always evaluates successfully
return true;
// __noop always evaluates successfully and returns 0.
return Success(0, E);

case Builtin::BI__builtin_is_constant_evaluated: {
const auto *Callee = Info.CurrentCall->getCallee();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ std::optional<std::string> ToolChain::getRuntimePath() const {
llvm::sys::path::append(P, "lib");
if (auto Ret = getTargetSubDirPath(P))
return Ret;
// Darwin does not use per-target runtime directory.
if (Triple.isOSDarwin())
// Darwin and AIX does not use per-target runtime directory.
if (Triple.isOSDarwin() || Triple.isOSAIX())
return {};
llvm::sys::path::append(P, Triple.str());
return std::string(P);
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
ProbablyBracedList = NextTok->isNot(tok::l_square);
}

// Cpp macro definition body that is a nonempty braced list or block:
// Cpp macro definition body containing nonempty braced list or block:
if (IsCpp && Line->InMacroBody && PrevTok != FormatTok &&
!FormatTok->Previous && NextTok->is(tok::eof) &&
// A statement can end with only `;` (simple statement), a block
// closing brace (compound statement), or `:` (label statement).
// If PrevTok is a block opening brace, Tok ends an empty block.
Expand Down
9 changes: 8 additions & 1 deletion clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,14 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
// possible that e.g. constraints involving C<Class<T>> and C<Class> are
// perceived identical.
std::optional<Sema::ContextRAII> ContextScope;
if (auto *RD = dyn_cast<CXXRecordDecl>(DeclInfo.getDeclContext())) {
const DeclContext *DC = [&] {
if (!DeclInfo.getDecl())
return DeclInfo.getDeclContext();
return DeclInfo.getDecl()->getFriendObjectKind()
? DeclInfo.getLexicalDeclContext()
: DeclInfo.getDeclContext();
}();
if (auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
ThisScope.emplace(S, const_cast<CXXRecordDecl *>(RD), Qualifiers());
ContextScope.emplace(S, const_cast<DeclContext *>(cast<DeclContext>(RD)),
/*NewThisContext=*/false);
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,7 @@ void Sema::PrintInstantiationStack() {
case CodeSynthesisContext::ConstraintNormalization:
Diags.Report(Active->PointOfInstantiation,
diag::note_constraint_normalization_here)
<< cast<NamedDecl>(Active->Entity)->getName()
<< Active->InstantiationRange;
<< cast<NamedDecl>(Active->Entity) << Active->InstantiationRange;
break;
case CodeSynthesisContext::ParameterMappingSubstitution:
Diags.Report(Active->PointOfInstantiation,
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ template<typename T> requires Bar2<T> struct S2 { };
// expected-note@-1{{template is declared here}}
template<typename T> requires Bar2<T> && true struct S2<T> { };
// expected-error@-1{{class template partial specialization is not more specialized than the primary template}}
// expected-note@-2{{while calculating associated constraint of template 'S2' here}}
// expected-note@-2{{while calculating associated constraint of template 'S2<T>' here}}

namespace type_pack {
template<typename... Args>
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-counted-by.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void test6(struct anon_struct *p, int index) {
p->array[index] = __builtin_dynamic_object_size(p->array, 1);
}

// SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos(
// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos(
// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] {
// SANITIZE-WITH-ATTR-NEXT: entry:
// SANITIZE-WITH-ATTR-NEXT: [[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8
Expand All @@ -649,7 +649,7 @@ void test6(struct anon_struct *p, int index) {
// SANITIZE-WITH-ATTR-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], i64 0, i64 [[TMP0]]
// SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP1]]
//
// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos(
// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos(
// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] {
// NO-SANITIZE-WITH-ATTR-NEXT: entry:
// NO-SANITIZE-WITH-ATTR-NEXT: [[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8
Expand Down Expand Up @@ -955,7 +955,7 @@ void test10(struct union_of_fams *p, int index) {
p->bytes[index] = (unsigned char)__builtin_dynamic_object_size(p->bytes, 1);
}

// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos(
// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos(
// SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] {
// SANITIZE-WITH-ATTR-NEXT: entry:
// SANITIZE-WITH-ATTR-NEXT: [[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8
Expand All @@ -964,7 +964,7 @@ void test10(struct union_of_fams *p, int index) {
// SANITIZE-WITH-ATTR-NEXT: [[TMP0:%.*]] = zext nneg i32 [[NARROW]] to i64
// SANITIZE-WITH-ATTR-NEXT: ret i64 [[TMP0]]
//
// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos(
// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos(
// NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] {
// NO-SANITIZE-WITH-ATTR-NEXT: entry:
// NO-SANITIZE-WITH-ATTR-NEXT: [[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Driver/aix-print-runtime-dir.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Test output of -print-runtime-dir on AIX

// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s

// RUN: %clang -print-runtime-dir --target=powerpc64-ibm-aix \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s

// PRINT-RUNTIME-DIR: lib{{/|\\}}aix{{$}}
18 changes: 17 additions & 1 deletion clang/test/SemaCXX/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,21 @@ static void __builtin_cpu_init(); // expected-error {{static declaration of '__b
#endif

#ifdef _MSC_VER
constexpr int x = []{ __noop; return 0; }(); // expected-no-diagnostics
constexpr int x = [] {
__noop;
return 0;
}(); // expected-no-diagnostics
static_assert([] { return __noop; }() == 0);
static_assert([] { return __noop(4); }() == 0);
extern int not_accessed;
void not_called();
static_assert([] { return __noop(not_accessed *= 6); }() == 0);
static_assert([] { return __noop(not_called()); }() == 0);
static_assert([] { return __noop(throw ""); }() == 0);
static_assert([] { return __noop(throw "", throw ""); }() == 0);
static_assert([] {
int a = 5;
__noop(++a);
return a;
}() == 5);
#endif
23 changes: 23 additions & 0 deletions clang/test/SemaTemplate/concepts-friends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,26 @@ struct S {
};

}

namespace GH78101 {

template <typename T, int i>
concept True = true;

template <typename T, int I> struct Template {
static constexpr int i = I;

friend constexpr auto operator+(True<i> auto f) { return i; }
};

template <int I> struct Template<float, I> {
static constexpr int i = I;

friend constexpr auto operator+(True<i> auto f) { return i; }
};

Template<void, 4> f{};

static_assert(+Template<float, 5>{} == 5);

} // namespace GH78101
5 changes: 5 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3256,6 +3256,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[10], BK_Block);
EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace);
EXPECT_BRACE_KIND(Tokens[11], BK_Block);

Tokens = annotate("#define MEMBER(NAME) NAME{\"\"}");
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_BRACE_KIND(Tokens[7], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);
}

TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __sanitizer {
bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
Dl_info info;
int result = dladdr((const void *)addr, &info);
if (!result) return false;
if (!result || !info.dli_sname) return false;

// Compute offset if possible. `dladdr()` doesn't always ensure that `addr >=
// sym_addr` so only compute the offset when this holds. Failure to find the
Expand All @@ -51,7 +51,7 @@ bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) {
Dl_info info;
int result = dladdr((const void *)addr, &info);
if (!result) return false;
if (!result || !info.dli_sname) return false;
const char *demangled = DemangleSwiftAndCXX(info.dli_sname);
if (!demangled)
demangled = info.dli_sname;
Expand Down
13 changes: 12 additions & 1 deletion flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,18 @@ constexpr TypeBuilderFunc getModel<const double *>() {
template <>
constexpr TypeBuilderFunc getModel<long double>() {
return [](mlir::MLIRContext *context) -> mlir::Type {
return mlir::FloatType::getF80(context);
// See TODO at the top of the file. This is configuring for the host system
// - it might be incorrect when cross-compiling!
constexpr size_t size = sizeof(long double);
static_assert(size == 16 || size == 10 || size == 8,
"unsupported long double size");
if constexpr (size == 16)
return mlir::FloatType::getF128(context);
if constexpr (size == 10)
return mlir::FloatType::getF80(context);
if constexpr (size == 8)
return mlir::FloatType::getF64(context);
llvm_unreachable("failed static assert");
};
}
template <>
Expand Down
10 changes: 5 additions & 5 deletions flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
elements.push_back(subrangeTy);
}
return mlir::LLVM::DICompositeTypeAttr::get(
context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
/*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
/*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
dataLocation, /*rank=*/nullptr, allocated, associated);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
}

return mlir::LLVM::DICompositeTypeAttr::get(
context, llvm::dwarf::DW_TAG_structure_type, /*recursive_id=*/{},
context, llvm::dwarf::DW_TAG_structure_type,
mlir::StringAttr::get(context, result.second.name), fileAttr, line, scope,
/*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
/*alignInBits=*/0, elements, /*dataLocation=*/nullptr, /*rank=*/nullptr,
Expand Down Expand Up @@ -236,8 +236,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
// have been set to some valid default values.

return mlir::LLVM::DICompositeTypeAttr::get(
context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
/*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
/*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
/*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
/*associated=*/nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,16 @@ int main(int, char**)
test_1_2();
test_1_3<float>();
test_1_3<double>();
// test_1_3<long double>(); // UNIMPLEMENTED
#ifdef TEST_LONG_DOUBLE_IS_DOUBLE
test_1_3<long double>(); // UNIMPLEMENTED when long double is a distinct type
#endif
test_1_4();

static_assert(test_1_3<float>());
static_assert(test_1_3<double>());
// static_assert(test_1_3<long double>()); // UNIMPLEMENTED
#ifdef TEST_LONG_DOUBLE_IS_DOUBLE
static_assert(test_1_3<long double>()); // UNIMPLEMENTED when long double is a distinct type
#endif
static_assert(test_1_4());

return 0;
Expand Down
24 changes: 21 additions & 3 deletions lldb/include/lldb/Symbol/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ FLAGS_ENUM(TypeQueryOptions){
/// If set, the query will ignore all Module entries in the type context,
/// even for exact matches.
e_ignore_modules = (1u << 2),
/// If set, all anonymous namespaces in the context must be matched exactly
/// by the pattern. Otherwise, superfluous namespaces are skipped.
e_strict_namespaces = (1u << 3),
/// When true, the find types call should stop the query as soon as a single
/// matching type is found. When false, the type query should find all
/// matching types.
e_find_one = (1u << 3),
e_find_one = (1u << 4),
};
LLDB_MARK_AS_BITMASK_ENUM(TypeQueryOptions)

Expand Down Expand Up @@ -264,7 +267,22 @@ class TypeQuery {
bool GetExactMatch() const { return (m_options & e_exact_match) != 0; }

bool GetIgnoreModules() const { return (m_options & e_ignore_modules) != 0; }
void SetIgnoreModules() { m_options &= ~e_ignore_modules; }
void SetIgnoreModules(bool b) {
if (b)
m_options |= e_ignore_modules;
else
m_options &= ~e_ignore_modules;
}

bool GetStrictNamespaces() const {
return (m_options & e_strict_namespaces) != 0;
}
void SetStrictNamespaces(bool b) {
if (b)
m_options |= e_strict_namespaces;
else
m_options &= ~e_strict_namespaces;
}

/// The \a m_context can be used in two ways: normal types searching with
/// the context containing a stanadard declaration context for a type, or
Expand All @@ -279,7 +297,7 @@ class TypeQuery {
if (b)
m_options |= e_find_one;
else
m_options &= (e_exact_match | e_find_one);
m_options &= ~e_find_one;
}

/// Access the internal compiler context array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfo(
TypeResults results;
TypeQuery query(const_lookup_name.GetStringRef(),
TypeQueryOptions::e_exact_match |
TypeQueryOptions::e_strict_namespaces |
TypeQueryOptions::e_find_one);
if (module_sp) {
module_sp->FindTypes(query, results);
Expand Down
8 changes: 1 addition & 7 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,6 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
continue;
}

// If there is no name, then there is no need to look anything up for this
// DIE.
const char *name = die.GetName();
if (!name || !name[0])
return;

// Add this DIE's contribution at the end of the chain.
auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
context.push_back({kind, ConstString(name)});
Expand All @@ -471,7 +465,7 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
push_ctx(CompilerContextKind::Typedef, die.GetName());
break;
case DW_TAG_base_type:
push_ctx(CompilerContextKind::Builtin, name);
push_ctx(CompilerContextKind::Builtin, die.GetName());
break;
// If any of the tags below appear in the parent chain, stop the decl
// context and return. Prior to these being in here, if a type existed in a
Expand Down
Loading

0 comments on commit 6f9c93f

Please sign in to comment.