Skip to content

Commit 6ed46be

Browse files
authored
Merge pull request #68870 from tshortli/fix-macro-warnings
NFC: Fix unused function and variable warnings
2 parents b59e20b + 8ebe83f commit 6ed46be

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/Frontend/PrintingDiagnosticConsumer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ static void enqueueDiagnostic(
363363
info.Loc.getOpaquePointerValue(),
364364
highlightRanges.data(), highlightRanges.size() / 2);
365365
}
366-
#endif
367366

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

392-
#if SWIFT_BUILD_SWIFT_SYNTAX
393391
void PrintingDiagnosticConsumer::queueBuffer(
394392
SourceManager &sourceMgr, unsigned bufferID) {
395393
QueuedBuffer knownSourceFile = queuedBuffers[bufferID];

lib/Sema/TypeCheckMacros.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ llvm::Optional<Identifier> getIdentifierFromStringLiteralArgument(
162162

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

178179
return MacroDefinition::forExternal(*moduleName, *typeName);
179180
}
181+
#endif // SWIFT_BUILD_SWIFT_SYNTAX
180182

181183
MacroDefinition MacroDefinitionRequest::evaluate(
182184
Evaluator &evaluator, MacroDecl *macro
183185
) const {
184-
ASTContext &ctx = macro->getASTContext();
185-
186186
// If no definition was provided, the macro is... undefined, of course.
187187
auto definition = macro->definition;
188188
if (!definition)
189189
return MacroDefinition::forUndefined();
190190

191+
#if SWIFT_BUILD_SWIFT_SYNTAX
192+
ASTContext &ctx = macro->getASTContext();
191193
auto sourceFile = macro->getParentSourceFile();
192194

193-
#if SWIFT_BUILD_SWIFT_SYNTAX
194195
char *externalMacroNamePtr;
195196
ptrdiff_t externalMacroNameLength;
196197
ptrdiff_t *replacements;
@@ -937,6 +938,7 @@ createMacroSourceFile(std::unique_ptr<llvm::MemoryBuffer> buffer,
937938
return macroSourceFile;
938939
}
939940

941+
#if SWIFT_BUILD_SWIFT_SYNTAX
940942
static uint8_t getRawMacroRole(MacroRole role) {
941943
switch (role) {
942944
case MacroRole::Expression: return 0;
@@ -952,6 +954,7 @@ static uint8_t getRawMacroRole(MacroRole role) {
952954
case MacroRole::Extension: return 8;
953955
}
954956
}
957+
#endif // SWIFT_BUILD_SWIFT_SYNTAX
955958

956959
/// Evaluate the given freestanding macro expansion.
957960
static SourceFile *
@@ -994,13 +997,6 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion,
994997
#endif
995998
});
996999

997-
// Only one freestanding macro role is permitted, so look at the roles to
998-
// figure out which one to use.
999-
MacroRole macroRole =
1000-
macroRoles.contains(MacroRole::Expression) ? MacroRole::Expression
1001-
: macroRoles.contains(MacroRole::Declaration) ? MacroRole::Declaration
1002-
: MacroRole::CodeItem;
1003-
10041000
auto macroDef = macro->getDefinition();
10051001
switch (macroDef.kind) {
10061002
case MacroDefinition::Kind::Undefined:
@@ -1048,6 +1044,13 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion,
10481044
}
10491045

10501046
#if SWIFT_BUILD_SWIFT_SYNTAX
1047+
// Only one freestanding macro role is permitted, so look at the roles to
1048+
// figure out which one to use.
1049+
MacroRole macroRole =
1050+
macroRoles.contains(MacroRole::Expression) ? MacroRole::Expression
1051+
: macroRoles.contains(MacroRole::Declaration) ? MacroRole::Declaration
1052+
: MacroRole::CodeItem;
1053+
10511054
PrettyStackTraceFreestandingMacroExpansion debugStack(
10521055
"expanding freestanding macro", expansion);
10531056

0 commit comments

Comments
 (0)