Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (6 commits)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in libclc/CMakeLists.txt
  • Loading branch information
t-demchuk committed Apr 8, 2024
2 parents de8e527 + b439140 commit 3f2a809
Show file tree
Hide file tree
Showing 14 changed files with 505 additions and 57 deletions.
22 changes: 19 additions & 3 deletions clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> {
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;

static inline NamingCheckId getEmptyKey() {
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
"EMPTY"};
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(), "EMPTY"};
}

static inline NamingCheckId getTombstoneKey() {
return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
"TOMBSTONE"};
"TOMBSTONE"};
}

static unsigned getHashValue(NamingCheckId Val) {
Expand Down Expand Up @@ -367,6 +366,23 @@ class RenamerClangTidyVisitor
return true;
}

bool VisitDesignatedInitExpr(DesignatedInitExpr *Expr) {
for (const DesignatedInitExpr::Designator &D : Expr->designators()) {
if (!D.isFieldDesignator())
continue;
const FieldDecl *FD = D.getFieldDecl();
if (!FD)
continue;
const IdentifierInfo *II = FD->getIdentifier();
if (!II)
continue;
SourceRange FixLocation{D.getFieldLoc(), D.getFieldLoc()};
Check->addUsage(FD, FixLocation, SM);
}

return true;
}

private:
RenamerClangTidyCheck *Check;
const SourceManager *SM;
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ Changes in existing checks
- Improved :doc:`readability-identifier-naming
<clang-tidy/checks/readability/identifier-naming>` check in `GetConfigPerFile`
mode by resolving symbolic links to header files. Fixed handling of Hungarian
Prefix when configured to `LowerCase`.
Prefix when configured to `LowerCase`. Added support for renaming designated
initializers.

- Improved :doc:`readability-implicit-bool-conversion
<clang-tidy/checks/readability/implicit-bool-conversion>` check to provide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,13 @@ STATIC_MACRO void someFunc(MyFunPtr, const MyFunPtr****) {}
// CHECK-FIXES: {{^}}STATIC_MACRO void someFunc(my_fun_ptr_t, const my_fun_ptr_t****) {}
#undef STATIC_MACRO
}

struct Some_struct {
int SomeMember;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for public member 'SomeMember' [readability-identifier-naming]
// CHECK-FIXES: {{^}} int some_member;
};
Some_struct g_s1{ .SomeMember = 1 };
// CHECK-FIXES: {{^}}Some_struct g_s1{ .some_member = 1 };
Some_struct g_s2{.SomeMember=1};
// CHECK-FIXES: {{^}}Some_struct g_s2{.some_member=1};
19 changes: 19 additions & 0 deletions flang/include/flang/Runtime/freestanding-tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "flang/Common/api-attrs.h"
#include "flang/Runtime/c-or-cpp.h"
#include <algorithm>
#include <cctype>
#include <cstring>

// The file defines a set of utilities/classes that might be
Expand Down Expand Up @@ -57,6 +58,11 @@
#define STD_STRCMP_UNSUPPORTED 1
#endif

#if !defined(STD_TOUPPER_UNSUPPORTED) && \
(defined(__CUDACC__) || defined(__CUDA__)) && defined(__CUDA_ARCH__)
#define STD_TOUPPER_UNSUPPORTED 1
#endif

namespace Fortran::runtime {

#if STD_FILL_N_UNSUPPORTED
Expand Down Expand Up @@ -195,5 +201,18 @@ static inline RT_API_ATTRS int strcmp(const char *lhs, const char *rhs) {
using std::strcmp;
#endif // !STD_STRCMP_UNSUPPORTED

#if STD_TOUPPER_UNSUPPORTED
// Provides alternative implementation for std::toupper(), if
// it is not supported.
static inline RT_API_ATTRS int toupper(int ch) {
if (ch >= 'a' && ch <= 'z') {
return ch - 'a' + 'A';
}
return ch;
}
#else // !STD_TOUPPER_UNSUPPORTED
using std::toupper;
#endif // !STD_TOUPPER_UNSUPPORTED

} // namespace Fortran::runtime
#endif // FORTRAN_RUNTIME_FREESTANDING_TOOLS_H_
16 changes: 8 additions & 8 deletions flang/lib/Decimal/decimal-to-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include "flang/Common/leading-zero-bit-count.h"
#include "flang/Decimal/binary-floating-point.h"
#include "flang/Decimal/decimal.h"
#include "flang/Runtime/freestanding-tools.h"
#include <cinttypes>
#include <cstring>
#include <ctype.h>
#include <utility>

namespace Fortran::decimal {
Expand Down Expand Up @@ -468,8 +468,8 @@ BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ConvertToBinary(
++q;
}
}
if ((!limit || limit >= q + 3) && toupper(q[0]) == 'N' &&
toupper(q[1]) == 'A' && toupper(q[2]) == 'N') {
if ((!limit || limit >= q + 3) && runtime::toupper(q[0]) == 'N' &&
runtime::toupper(q[1]) == 'A' && runtime::toupper(q[2]) == 'N') {
// NaN
p = q + 3;
bool isQuiet{true};
Expand All @@ -493,11 +493,11 @@ BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ConvertToBinary(
}
return {Real{NaN(isQuiet)}};
} else { // Inf?
if ((!limit || limit >= q + 3) && toupper(q[0]) == 'I' &&
toupper(q[1]) == 'N' && toupper(q[2]) == 'F') {
if ((!limit || limit >= q + 8) && toupper(q[3]) == 'I' &&
toupper(q[4]) == 'N' && toupper(q[5]) == 'I' &&
toupper(q[6]) == 'T' && toupper(q[7]) == 'Y') {
if ((!limit || limit >= q + 3) && runtime::toupper(q[0]) == 'I' &&
runtime::toupper(q[1]) == 'N' && runtime::toupper(q[2]) == 'F') {
if ((!limit || limit >= q + 8) && runtime::toupper(q[3]) == 'I' &&
runtime::toupper(q[4]) == 'N' && runtime::toupper(q[5]) == 'I' &&
runtime::toupper(q[6]) == 'T' && runtime::toupper(q[7]) == 'Y') {
p = q + 8;
} else {
p = q + 3;
Expand Down
8 changes: 4 additions & 4 deletions libc/test/UnitTest/LibcDeathTestExecutors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace testing {
bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
const char *LHSStr, const char *RHSStr,
internal::Location Loc) {
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 1000);

if (const char *error = Result.get_error()) {
Ctx->markFail();
Expand All @@ -31,7 +31,7 @@ bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
if (Result.timed_out()) {
Ctx->markFail();
tlog << Loc;
tlog << "Process timed out after " << 500 << " milliseconds.\n";
tlog << "Process timed out after " << 1000 << " milliseconds.\n";
return false;
}

Expand Down Expand Up @@ -62,7 +62,7 @@ bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
const char *LHSStr, const char *RHSStr,
internal::Location Loc) {
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 1000);

if (const char *error = Result.get_error()) {
Ctx->markFail();
Expand All @@ -74,7 +74,7 @@ bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
if (Result.timed_out()) {
Ctx->markFail();
tlog << Loc;
tlog << "Process timed out after " << 500 << " milliseconds.\n";
tlog << "Process timed out after " << 1000 << " milliseconds.\n";
return false;
}

Expand Down
20 changes: 20 additions & 0 deletions llvm/include/llvm/Object/GOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ class Record {
}
};

class TXTRecord : public Record {
public:
/// \brief Maximum length of data; any more must go in continuation.
static const uint8_t TXTMaxDataLength = 56;

static Error getData(const uint8_t *Record, SmallString<256> &CompleteData);

static void getElementEsdId(const uint8_t *Record, uint32_t &EsdId) {
get<uint32_t>(Record, 4, EsdId);
}

static void getOffset(const uint8_t *Record, uint32_t &Offset) {
get<uint32_t>(Record, 12, Offset);
}

static void getDataLength(const uint8_t *Record, uint16_t &Length) {
get<uint16_t>(Record, 22, Length);
}
};

class HDRRecord : public Record {
public:
static Error getData(const uint8_t *Record, SmallString<256> &CompleteData);
Expand Down
56 changes: 42 additions & 14 deletions llvm/include/llvm/Object/GOFFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ namespace llvm {
namespace object {

class GOFFObjectFile : public ObjectFile {
friend class GOFFSymbolRef;

IndexedMap<const uint8_t *> EsdPtrs; // Indexed by EsdId.
SmallVector<const uint8_t *, 256> TextPtrs;

mutable DenseMap<uint32_t, std::pair<size_t, std::unique_ptr<char[]>>>
EsdNamesCache;
Expand All @@ -38,7 +41,7 @@ class GOFFObjectFile : public ObjectFile {
// (EDID, 0) code, r/o data section
// (EDID,PRID) r/w data section
SmallVector<SectionEntryImpl, 256> SectionList;
mutable DenseMap<uint32_t, std::string> SectionDataCache;
mutable DenseMap<uint32_t, SmallVector<uint8_t>> SectionDataCache;

public:
Expected<StringRef> getSymbolName(SymbolRef Symbol) const;
Expand Down Expand Up @@ -66,6 +69,10 @@ class GOFFObjectFile : public ObjectFile {
return true;
}

bool isSectionNoLoad(DataRefImpl Sec) const;
bool isSectionReadOnlyData(DataRefImpl Sec) const;
bool isSectionZeroInit(DataRefImpl Sec) const;

private:
// SymbolRef.
Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
Expand All @@ -75,27 +82,24 @@ class GOFFObjectFile : public ObjectFile {
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
uint64_t getSymbolSize(DataRefImpl Symb) const;

const uint8_t *getSymbolEsdRecord(DataRefImpl Symb) const;
bool isSymbolUnresolved(DataRefImpl Symb) const;
bool isSymbolIndirect(DataRefImpl Symb) const;

// SectionRef.
void moveSectionNext(DataRefImpl &Sec) const override {}
virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override {
return StringRef();
}
uint64_t getSectionAddress(DataRefImpl Sec) const override { return 0; }
uint64_t getSectionSize(DataRefImpl Sec) const override { return 0; }
void moveSectionNext(DataRefImpl &Sec) const override;
virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
uint64_t getSectionAddress(DataRefImpl Sec) const override;
uint64_t getSectionSize(DataRefImpl Sec) const override;
virtual Expected<ArrayRef<uint8_t>>
getSectionContents(DataRefImpl Sec) const override {
return ArrayRef<uint8_t>();
}
uint64_t getSectionIndex(DataRefImpl Sec) const override { return 0; }
uint64_t getSectionAlignment(DataRefImpl Sec) const override { return 0; }
getSectionContents(DataRefImpl Sec) const override;
uint64_t getSectionIndex(DataRefImpl Sec) const override { return Sec.d.a; }
uint64_t getSectionAlignment(DataRefImpl Sec) const override;
bool isSectionCompressed(DataRefImpl Sec) const override { return false; }
bool isSectionText(DataRefImpl Sec) const override { return false; }
bool isSectionData(DataRefImpl Sec) const override { return false; }
bool isSectionText(DataRefImpl Sec) const override;
bool isSectionData(DataRefImpl Sec) const override;
bool isSectionBSS(DataRefImpl Sec) const override { return false; }
bool isSectionVirtual(DataRefImpl Sec) const override { return false; }
relocation_iterator section_rel_begin(DataRefImpl Sec) const override {
Expand All @@ -109,6 +113,7 @@ class GOFFObjectFile : public ObjectFile {
const uint8_t *getSectionPrEsdRecord(DataRefImpl &Sec) const;
const uint8_t *getSectionEdEsdRecord(uint32_t SectionIndex) const;
const uint8_t *getSectionPrEsdRecord(uint32_t SectionIndex) const;
uint32_t getSectionDefEsdId(DataRefImpl &Sec) const;

// RelocationRef.
void moveRelocationNext(DataRefImpl &Rel) const override {}
Expand All @@ -122,6 +127,29 @@ class GOFFObjectFile : public ObjectFile {
SmallVectorImpl<char> &Result) const override {}
};

class GOFFSymbolRef : public SymbolRef {
public:
GOFFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
assert(isa<GOFFObjectFile>(SymbolRef::getObject()));
}

const GOFFObjectFile *getObject() const {
return cast<GOFFObjectFile>(BasicSymbolRef::getObject());
}

Expected<uint32_t> getSymbolGOFFFlags() const {
return getObject()->getSymbolFlags(getRawDataRefImpl());
}

Expected<SymbolRef::Type> getSymbolGOFFType() const {
return getObject()->getSymbolType(getRawDataRefImpl());
}

uint64_t getSize() const {
return getObject()->getSymbolSize(getRawDataRefImpl());
}
};

} // namespace object

} // namespace llvm
Expand Down
Loading

0 comments on commit 3f2a809

Please sign in to comment.