Skip to content

Fix eight warnings on Linux. #327

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 1 commit into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/IDE/SyntaxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -1318,6 +1315,7 @@ bool ModelASTWalker::findUrlStartingLoc(StringRef Text,
return true;
}
}
#endif
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this cause equivalent unreachable code warnings for return false?

Could you do #ifdef ... #else ... #endif instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the 'return false' is reachable with and without SWIFT_HAVE_WORKING_STD_REGEX?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Cute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I patched it both ways but settled on this way because it looked cleaner.

}

Expand Down Expand Up @@ -1354,10 +1352,8 @@ bool ModelASTWalker::searchForURL(CharSourceRange Range) {
Optional<SyntaxNode> ModelASTWalker::parseFieldNode(StringRef Text,
StringRef OrigText,
SourceLoc OrigLoc) {
#ifndef SWIFT_HAVE_WORKING_STD_REGEX
return None;
#endif

Optional<SyntaxNode> Node;
#ifdef SWIFT_HAVE_WORKING_STD_REGEX
std::match_results<StringRef::iterator> Matches;
for (unsigned i = 0; i != 3; ++i) {
auto &Rx = getDocCommentRegex(i);
Expand All @@ -1372,7 +1368,9 @@ Optional<SyntaxNode> 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<SyntaxNode>({ SyntaxNodeKind::DocCommentField, Range });
Node = Optional<SyntaxNode>({ SyntaxNodeKind::DocCommentField, Range });
#endif
return Node;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

}

bool ModelASTWalker::findFieldsInDocCommentLine(SyntaxNode Node) {
Expand Down
6 changes: 4 additions & 2 deletions lib/Immediate/REPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class ConvertForWcharSize<4> {

using Convert = ConvertForWcharSize<sizeof(wchar_t)>;

#if defined(__APPLE__)
static void convertFromUTF8(llvm::StringRef utf8,
llvm::SmallVectorImpl<wchar_t> &out) {
size_t reserve = out.size() + utf8.size();
Expand Down Expand Up @@ -157,9 +158,12 @@ static void convertToUTF8(llvm::ArrayRef<wchar_t> 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,
Expand All @@ -183,8 +187,6 @@ static bool appendToREPLFile(SourceFile &SF,
return FoundAnySideEffects;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file LGTM.

}

#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
Expand Down
4 changes: 2 additions & 2 deletions lib/SILAnalysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/runtime/Casting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -1400,6 +1401,7 @@ static void *_dynamicCastUnknownClass(void *object,

return const_cast<void*>(swift_dynamicCastUnknownClass(object, targetType));
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.


static bool _dynamicCastUnknownClassIndirect(OpaqueValue *dest,
void *object,
Expand Down