Skip to content

NFC: Fix unused function and variable warnings #68870

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
Sep 29, 2023
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
2 changes: 0 additions & 2 deletions lib/Frontend/PrintingDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ static void enqueueDiagnostic(
info.Loc.getOpaquePointerValue(),
highlightRanges.data(), highlightRanges.size() / 2);
}
#endif

/// Retrieve the stack of source buffers from the provided location out to
/// a physical source file, with source buffer IDs for each step along the way
Expand All @@ -389,7 +388,6 @@ static SmallVector<unsigned, 1> getSourceBufferStack(
}
}

#if SWIFT_BUILD_SWIFT_SYNTAX
void PrintingDiagnosticConsumer::queueBuffer(
SourceManager &sourceMgr, unsigned bufferID) {
QueuedBuffer knownSourceFile = queuedBuffers[bufferID];
Expand Down
23 changes: 13 additions & 10 deletions lib/Sema/TypeCheckMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ llvm::Optional<Identifier> getIdentifierFromStringLiteralArgument(

/// For a macro expansion expression that is known to be #externalMacro,
/// handle the definition.
#if SWIFT_BUILD_SWIFT_SYNTAX
static MacroDefinition handleExternalMacroDefinition(
ASTContext &ctx, MacroExpansionExpr *expansion) {
// Dig out the module and type name.
Expand All @@ -177,20 +178,20 @@ static MacroDefinition handleExternalMacroDefinition(

return MacroDefinition::forExternal(*moduleName, *typeName);
}
#endif // SWIFT_BUILD_SWIFT_SYNTAX

MacroDefinition MacroDefinitionRequest::evaluate(
Evaluator &evaluator, MacroDecl *macro
) const {
ASTContext &ctx = macro->getASTContext();

// If no definition was provided, the macro is... undefined, of course.
auto definition = macro->definition;
if (!definition)
return MacroDefinition::forUndefined();

#if SWIFT_BUILD_SWIFT_SYNTAX
ASTContext &ctx = macro->getASTContext();
auto sourceFile = macro->getParentSourceFile();

#if SWIFT_BUILD_SWIFT_SYNTAX
char *externalMacroNamePtr;
ptrdiff_t externalMacroNameLength;
ptrdiff_t *replacements;
Expand Down Expand Up @@ -937,6 +938,7 @@ createMacroSourceFile(std::unique_ptr<llvm::MemoryBuffer> buffer,
return macroSourceFile;
}

#if SWIFT_BUILD_SWIFT_SYNTAX
static uint8_t getRawMacroRole(MacroRole role) {
switch (role) {
case MacroRole::Expression: return 0;
Expand All @@ -952,6 +954,7 @@ static uint8_t getRawMacroRole(MacroRole role) {
case MacroRole::Extension: return 8;
}
}
#endif // SWIFT_BUILD_SWIFT_SYNTAX

/// Evaluate the given freestanding macro expansion.
static SourceFile *
Expand Down Expand Up @@ -994,13 +997,6 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion,
#endif
});

// Only one freestanding macro role is permitted, so look at the roles to
// figure out which one to use.
MacroRole macroRole =
macroRoles.contains(MacroRole::Expression) ? MacroRole::Expression
: macroRoles.contains(MacroRole::Declaration) ? MacroRole::Declaration
: MacroRole::CodeItem;

auto macroDef = macro->getDefinition();
switch (macroDef.kind) {
case MacroDefinition::Kind::Undefined:
Expand Down Expand Up @@ -1048,6 +1044,13 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion,
}

#if SWIFT_BUILD_SWIFT_SYNTAX
// Only one freestanding macro role is permitted, so look at the roles to
// figure out which one to use.
MacroRole macroRole =
macroRoles.contains(MacroRole::Expression) ? MacroRole::Expression
: macroRoles.contains(MacroRole::Declaration) ? MacroRole::Declaration
: MacroRole::CodeItem;

PrettyStackTraceFreestandingMacroExpansion debugStack(
"expanding freestanding macro", expansion);

Expand Down