From 86d99cea9b0a40cfbe86dcb4a8448e966c04284a Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 7 Dec 2015 15:05:36 -0800 Subject: [PATCH] Fix eight Linux warnings. Fix spurious docs warning that @in and @in_guaranteed should be ``fn``. Add ``#ifdef SWIFT_OBJC_INTEROP`` to silence a -Wunused-function on linux since that function is only used from within that #ifdef elsewhere. Fix three -Wunused-function warnings on linux. Fix two -Wunreachable-code warnings on linux dealing with SWIFT_HAVE_WORKING_STD_REGEX. --- lib/IDE/SyntaxModel.cpp | 16 +++++++--------- lib/Immediate/REPL.cpp | 6 ++++-- lib/SILAnalysis/AliasAnalysis.cpp | 4 ++-- stdlib/public/runtime/Casting.cpp | 2 ++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/IDE/SyntaxModel.cpp b/lib/IDE/SyntaxModel.cpp index 065ef03d6c759..26177ff5c0a1b 100644 --- a/lib/IDE/SyntaxModel.cpp +++ b/lib/IDE/SyntaxModel.cpp @@ -1291,10 +1291,7 @@ bool ModelASTWalker::processComment(CharSourceRange Range) { bool ModelASTWalker::findUrlStartingLoc(StringRef Text, unsigned &Start, std::regex &Regex) { -#ifndef SWIFT_HAVE_WORKING_STD_REGEX - return false; -#endif - +#ifdef SWIFT_HAVE_WORKING_STD_REGEX static const auto MailToPosition = std::find(URLProtocols.begin(), URLProtocols.end(), "mailto"); @@ -1318,6 +1315,7 @@ bool ModelASTWalker::findUrlStartingLoc(StringRef Text, return true; } } +#endif return false; } @@ -1354,10 +1352,8 @@ bool ModelASTWalker::searchForURL(CharSourceRange Range) { Optional ModelASTWalker::parseFieldNode(StringRef Text, StringRef OrigText, SourceLoc OrigLoc) { -#ifndef SWIFT_HAVE_WORKING_STD_REGEX - return None; -#endif - + Optional Node; +#ifdef SWIFT_HAVE_WORKING_STD_REGEX std::match_results Matches; for (unsigned i = 0; i != 3; ++i) { auto &Rx = getDocCommentRegex(i); @@ -1372,7 +1368,9 @@ Optional ModelASTWalker::parseFieldNode(StringRef Text, StringRef MatchStr(Match.first, Match.second - Match.first); auto Loc = OrigLoc.getAdvancedLoc(MatchStr.data() - OrigText.data()); CharSourceRange Range(Loc, MatchStr.size()); - return Optional({ SyntaxNodeKind::DocCommentField, Range }); + Node = Optional({ SyntaxNodeKind::DocCommentField, Range }); +#endif + return Node; } bool ModelASTWalker::findFieldsInDocCommentLine(SyntaxNode Node) { diff --git a/lib/Immediate/REPL.cpp b/lib/Immediate/REPL.cpp index 79b63bbc005e5..81c14200fd890 100644 --- a/lib/Immediate/REPL.cpp +++ b/lib/Immediate/REPL.cpp @@ -130,6 +130,7 @@ class ConvertForWcharSize<4> { using Convert = ConvertForWcharSize; +#if defined(__APPLE__) static void convertFromUTF8(llvm::StringRef utf8, llvm::SmallVectorImpl &out) { size_t reserve = out.size() + utf8.size(); @@ -157,9 +158,12 @@ static void convertToUTF8(llvm::ArrayRef wide, (void)res; out.set_size(utf8_begin - out.begin()); } +#endif } // end anonymous namespace +#if defined(__APPLE__) + static bool appendToREPLFile(SourceFile &SF, PersistentParserState &PersistentState, REPLContext &RC, @@ -183,8 +187,6 @@ static bool appendToREPLFile(SourceFile &SF, return FoundAnySideEffects; } -#if defined(__APPLE__) - /// An arbitrary, otherwise-unused char value that editline interprets as /// entering/leaving "literal mode", meaning it passes prompt characters through /// to the terminal without affecting the line state. This prevents color diff --git a/lib/SILAnalysis/AliasAnalysis.cpp b/lib/SILAnalysis/AliasAnalysis.cpp index 9cdd131551a9d..0f168f67f37b0 100644 --- a/lib/SILAnalysis/AliasAnalysis.cpp +++ b/lib/SILAnalysis/AliasAnalysis.cpp @@ -368,8 +368,8 @@ static bool isTypedAccessOracle(SILInstruction *I) { /// address is with pointer_to_address (via UnsafePointer) or /// unchecked_addr_cast (via Builtin.reinterpretCast). Consequently, if the /// given value is directly derived from a memory location, it cannot -/// alias. Call arguments also cannot alias because they must follow @in, @out, -/// @inout, or @in_guaranteed conventions. +/// alias. Call arguments also cannot alias because they must follow \@in, @out, +/// @inout, or \@in_guaranteed conventions. /// /// FIXME: pointer_to_address should contain a flag that indicates whether the /// address is aliasing. Currently, we aggressively assume that diff --git a/stdlib/public/runtime/Casting.cpp b/stdlib/public/runtime/Casting.cpp index 48ea259ef21ca..ec5404f1fe835 100644 --- a/stdlib/public/runtime/Casting.cpp +++ b/stdlib/public/runtime/Casting.cpp @@ -1388,6 +1388,7 @@ swift::swift_dynamicCastMetatypeUnconditional(const Metadata *sourceType, } } +#if SWIFT_OBJC_INTEROP /// Do a dynamic cast to the target class. static void *_dynamicCastUnknownClass(void *object, const Metadata *targetType, @@ -1400,6 +1401,7 @@ static void *_dynamicCastUnknownClass(void *object, return const_cast(swift_dynamicCastUnknownClass(object, targetType)); } +#endif static bool _dynamicCastUnknownClassIndirect(OpaqueValue *dest, void *object,