Skip to content

Resolve more warnings #70943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 17, 2024
Merged
3 changes: 3 additions & 0 deletions lib/Demangling/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ static void reportNow(uint32_t flags, const char *message) {
fflush(stderr);
#endif
#if SWIFT_STDLIB_HAS_ASL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
#pragma clang diagnostic pop
#elif defined(__ANDROID__) && !defined(__TERMUX__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftDemangle", "%s", message);
#endif
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"

#include "CompilationRecord.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/FrontendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/TargetParser/Host.h"

using namespace swift;
using namespace swift::driver;
Expand Down
5 changes: 3 additions & 2 deletions lib/DriverTool/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
#include "swift/FrontendTool/FrontendTool.h"
#include "swift/DriverTool/DriverTool.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
Expand All @@ -47,6 +46,8 @@
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"

#include <memory>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/DriverTool/swift_llvm_opt_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
Expand All @@ -66,6 +65,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"

using namespace swift;
Expand Down
1 change: 0 additions & 1 deletion lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7928,7 +7928,6 @@ void Parser::parseExpandedMemberList(SmallVectorImpl<ASTNode> &items) {
if (Tok.is(tok::NUM_TOKENS))
consumeTokenWithoutFeedingReceiver();

auto *decl = CurDeclContext->getAsDecl();
bool previousHadSemi = true;

SourceLoc startingLoc = Tok.getLoc();
Expand Down
1 change: 0 additions & 1 deletion lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7625,7 +7625,6 @@ class SwiftToClangBasicReader :
if (!rawKind)
return nullptr;

clang::attr::Kind attrKind = static_cast<clang::attr::Kind>(rawKind - 1);
auto name = readIdentifier();
auto scopeName = readIdentifier();

Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/Concurrency/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ void swift::swift_task_reportUnexpectedExecutor(
fflush(stderr);
#endif
#if SWIFT_STDLIB_HAS_ASL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
#pragma clang diagnostic pop
#elif defined(__ANDROID__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);
#endif
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/Concurrency/TaskGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,10 @@ struct TaskGroupStatus {
write(STDERR_FILENO, message, strlen(message));
#endif
#if defined(SWIFT_STDLIB_HAS_ASL)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
#pragma clang diagnostic pop
#elif defined(__ANDROID__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);
#endif
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/Concurrency/TaskLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ static void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroupImpl(
fflush(stderr);
#endif
#if SWIFT_STDLIB_HAS_ASL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
#pragma clang diagnostic pop
#elif defined(__ANDROID__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);
#endif
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/LLVMSupport/ErrorHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ void error(const char *prefix, const char *msg, const char *file = nullptr, unsi
}

#if SWIFT_STDLIB_HAS_ASL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", buffer);
#pragma clang diagnostic pop
#elif defined(__ANDROID__) && !defined(__TERMUX__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", buffer);
#elif defined(_WIN32)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SwiftShims/swift/shims/LibcOverlayShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static inline char * _Nullable * _Null_unspecified _swift_stdlib_getEnviron() {
return environ;
}
#elif defined(__APPLE__)
static inline char * _Nullable *_swift_stdlib_getEnviron() {
static inline char * _Nullable * _Null_unspecified _swift_stdlib_getEnviron() {
extern char * _Nullable **_NSGetEnviron(void);
return *_NSGetEnviron();
}
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ reportNow(uint32_t flags, const char *message)
fflush(stderr);
#endif
#if SWIFT_STDLIB_HAS_ASL
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
asl_log(nullptr, nullptr, ASL_LEVEL_ERR, "%s", message);
#pragma clang diagnostic pop
#elif defined(__ANDROID__)
__android_log_print(ANDROID_LOG_FATAL, "SwiftRuntime", "%s", message);
#endif
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/SwiftObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
// Real class name: mangled "Swift._SwiftObject"
#define SwiftObject _TtCs12_SwiftObject

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-root-class"
#if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
#endif
Expand All @@ -43,6 +45,7 @@ SWIFT_RUNTIME_EXPORT @interface SwiftObject<NSObject> {
Class isa;
SWIFT_HEAPOBJECT_NON_OBJC_MEMBERS;
}
#pragma clang diagnostic pop

- (BOOL)isEqual:(id)object;
- (NSUInteger)hash;
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/SwiftObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,10 @@ static bool isObjCForUnownedReference(void *value) {
if (object == nullptr)
return nullptr;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreceiver-forward-class"
if ([id_const_cast(object) isKindOfClass:[__SwiftValue class]]) {
#pragma clang diagnostic pop
// Source is a `__SwiftValue` container
// Unwrap, then use the most general casting machine to do the heavy lifting
auto typeValue = getValueFromSwiftValue(reinterpret_cast<__SwiftValue *>(object));
Expand Down
6 changes: 6 additions & 0 deletions stdlib/tools/swift-reflection-test/swift-reflection-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ static int PipeMemoryReader_queryDataLayout(void *Context,

static void PipeMemoryReader_freeBytes(void *reader_context, const void *bytes,
void *context) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
free((void *)bytes);
#pragma clang diagnostic pop
}

static
Expand Down Expand Up @@ -652,10 +655,13 @@ int reflectEnumValue(SwiftReflectionContextRef RC,
void *outFreeContext = NULL;
// !!! FIXME !!! obtain the pointer by properly projecting the enum value
// Next lines are a hack to prove the concept.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
const void *rawPtr
= PipeMemoryReader_readBytes((void *)&Pipe, EnumInstance, 8, &outFreeContext);
uintptr_t instance = *(uintptr_t *)rawPtr & 0xffffffffffffff8ULL;
PipeMemoryReader_freeBytes((void *)&Pipe, rawPtr, outFreeContext);
#pragma clang diagnostic pop

// Indirect enum stores the payload as the first field of a closure context
swift_typeinfo_t TI = swift_reflection_infoForInstance(RC, instance);
Expand Down
4 changes: 4 additions & 0 deletions tools/SourceKit/lib/Support/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Logger::~Logger() {
fprintf(stderr, "%s: %s\n", LoggerName.c_str(), LogMsg.c_str());

#if __APPLE__
// rdar://121076739
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// Use the Apple System Log facility.
aslclient asl = asl_open(LoggerName.c_str(), "com.apple.console",
ASL_OPT_NO_DELAY);
Expand All @@ -76,5 +79,6 @@ Logger::~Logger() {
asl_send(asl, msg);
asl_free(msg);
asl_close(asl);
#pragma clang diagnostic pop
#endif
}
2 changes: 1 addition & 1 deletion unittests/AST/TestContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "swift/Basic/SourceManager.h"
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"

#include "llvm/Support/Host.h"
#include "llvm/TargetParser/Host.h"

namespace swift {
namespace unittest {
Expand Down
6 changes: 3 additions & 3 deletions unittests/DependencyScan/ModuleDeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//

#include "ScanFixture.h"
#include "swift/Basic/Platform.h"
#include "swift/Basic/Defer.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Support/Host.h"
#include "swift/Basic/Platform.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include "gtest/gtest.h"
#include <string>

Expand Down