Skip to content

Commit 5c4fe26

Browse files
authored
Merge pull request swiftlang#12018 from slavapestov/ide-small-cleanups
2 parents f5a1b8f + 0b3f039 commit 5c4fe26

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,13 +1327,13 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
13271327
/// to the \c Consumer.
13281328
bool DeliveredResults = false;
13291329

1330-
bool typecheckContextImpl(DeclContext *DC) {
1330+
bool typecheckContext(DeclContext *DC) {
13311331
// Nothing to type check in module context.
13321332
if (DC->isModuleScopeContext())
13331333
return true;
13341334

13351335
// Type check the parent context.
1336-
if (!typecheckContextImpl(DC->getParent()))
1336+
if (!typecheckContext(DC->getParent()))
13371337
return false;
13381338

13391339
// Type-check this context.
@@ -1370,17 +1370,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
13701370
llvm_unreachable("Unhandled DeclContextKind in switch.");
13711371
}
13721372

1373-
/// \returns true on success, false on failure.
1374-
bool typecheckContext() {
1375-
return typecheckContextImpl(CurDeclContext);
1376-
}
1377-
1378-
/// \returns true on success, false on failure.
1379-
bool typecheckParsedDecl() {
1380-
assert(ParsedDecl && "should have a parsed decl");
1381-
return typeCheckCompletionDecl(ParsedDecl);
1382-
}
1383-
13841373
Optional<std::pair<Type, ConcreteDeclRef>> typeCheckParsedExpr() {
13851374
assert(ParsedExpr && "should have an expression");
13861375

@@ -5115,17 +5104,14 @@ void CodeCompletionCallbacksImpl::doneParsing() {
51155104
// Add keywords even if type checking fails completely.
51165105
addKeywords(CompletionContext.getResultSink(), MaybeFuncBody);
51175106

5118-
if (!typecheckContext())
5119-
return;
5120-
5121-
if (ParsedDecl && !typecheckParsedDecl())
5122-
return;
5123-
51245107
if (auto *DC = dyn_cast_or_null<DeclContext>(ParsedDecl)) {
51255108
if (DC->isChildContextOf(CurDeclContext))
51265109
CurDeclContext = DC;
51275110
}
51285111

5112+
if (!typecheckContext(CurDeclContext))
5113+
return;
5114+
51295115
Optional<Type> ExprType;
51305116
ConcreteDeclRef ReferencedDecl = nullptr;
51315117
if (ParsedExpr) {

lib/Parse/ParseDecl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4848,11 +4848,11 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
48484848

48494849
// Create the decl for the func and add it to the parent scope.
48504850
auto *FD = FuncDecl::create(Context, StaticLoc, StaticSpelling,
4851-
FuncLoc, FullName, NameLoc,
4852-
/*Throws=*/throwsLoc.isValid(), throwsLoc,
4853-
/*AccessorKeywordLoc=*/SourceLoc(),
4854-
nullptr, BodyParams, FuncRetTy,
4855-
CurDeclContext);
4851+
FuncLoc, FullName, NameLoc,
4852+
/*Throws=*/throwsLoc.isValid(), throwsLoc,
4853+
/*AccessorKeywordLoc=*/SourceLoc(),
4854+
nullptr, BodyParams, FuncRetTy,
4855+
CurDeclContext);
48564856

48574857
// Parse a 'where' clause if present, adding it to our GenericParamList.
48584858
if (Tok.is(tok::kw_where)) {

lib/SILOptimizer/Utils/OptimizerStatsUtils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -716,15 +716,15 @@ void processFuncStatsChanges(SILFunction *F, FunctionStat &OldStat,
716716
// TODO: handle cases where a function got smaller.
717717
if ((SILStatsDumpAll &&
718718
(DeltaBlockCount != 0.0 || OldStat.BlockCount == 0)) ||
719-
(abs(DeltaBlockCount) > FuncBlockCountDeltaThreshold &&
719+
(std::abs(DeltaBlockCount) > FuncBlockCountDeltaThreshold &&
720720
OldStat.BlockCount > FuncBlockCountMinThreshold)) {
721721
stats_os() << nl.get();
722722
printCounterChange("function", "block", DeltaBlockCount, OldStat.BlockCount,
723723
NewStat.BlockCount, Ctx, F->getName());
724724
}
725725

726726
if ((SILStatsDumpAll && (DeltaInstCount != 0.0 || OldStat.InstCount == 0)) ||
727-
(abs(DeltaInstCount) > FuncInstCountDeltaThreshold &&
727+
(std::abs(DeltaInstCount) > FuncInstCountDeltaThreshold &&
728728
OldStat.InstCount > FuncInstCountMinThreshold)) {
729729
stats_os() << nl.get();
730730
printCounterChange("function", "inst", DeltaInstCount, OldStat.InstCount,
@@ -760,7 +760,7 @@ void processModuleStatsChanges(ModuleStat &OldStat, ModuleStat &NewStat,
760760
if ((SILStatsDumpAll &&
761761
(DeltaBlockCount != 0.0 ||
762762
isFirstTimeData(OldStat.BlockCount, NewStat.BlockCount))) ||
763-
(abs(DeltaBlockCount) > BlockCountDeltaThreshold)) {
763+
(std::abs(DeltaBlockCount) > BlockCountDeltaThreshold)) {
764764
stats_os() << nl.get();
765765
printCounterChange("module", "block", DeltaBlockCount, OldStat.BlockCount,
766766
NewStat.BlockCount, Ctx);
@@ -771,7 +771,7 @@ void processModuleStatsChanges(ModuleStat &OldStat, ModuleStat &NewStat,
771771
if ((SILStatsDumpAll &&
772772
(DeltaInstCount != 0.0 ||
773773
isFirstTimeData(OldStat.InstCount, NewStat.InstCount))) ||
774-
(abs(DeltaInstCount) > InstCountDeltaThreshold)) {
774+
(std::abs(DeltaInstCount) > InstCountDeltaThreshold)) {
775775
stats_os() << nl.get();
776776
printCounterChange("module", "inst", DeltaInstCount, OldStat.InstCount,
777777
NewStat.InstCount, Ctx);
@@ -782,7 +782,7 @@ void processModuleStatsChanges(ModuleStat &OldStat, ModuleStat &NewStat,
782782
if ((SILStatsDumpAll &&
783783
(DeltaFunctionCount != 0.0 ||
784784
isFirstTimeData(OldStat.FunctionCount, NewStat.FunctionCount))) ||
785-
(abs(DeltaFunctionCount) > FunctionCountDeltaThreshold)) {
785+
(std::abs(DeltaFunctionCount) > FunctionCountDeltaThreshold)) {
786786
stats_os() << nl.get();
787787
printCounterChange("module", "functions", DeltaFunctionCount,
788788
OldStat.FunctionCount, NewStat.FunctionCount, Ctx);
@@ -791,9 +791,9 @@ void processModuleStatsChanges(ModuleStat &OldStat, ModuleStat &NewStat,
791791
// Print delta for the used memory only if it is above a threshold or we are
792792
// asked to dump all changes.
793793
if ((SILStatsDumpAll &&
794-
(abs(DeltaUsedMemory) > UsedMemoryMinDeltaThreshold ||
794+
(std::abs(DeltaUsedMemory) > UsedMemoryMinDeltaThreshold ||
795795
isFirstTimeData(OldStat.UsedMemory, NewStat.UsedMemory))) ||
796-
(abs(DeltaUsedMemory) > UsedMemoryDeltaThreshold)) {
796+
(std::abs(DeltaUsedMemory) > UsedMemoryDeltaThreshold)) {
797797
stats_os() << nl.get();
798798
printCounterChange("module", "memory", DeltaUsedMemory, OldStat.UsedMemory,
799799
NewStat.UsedMemory, Ctx);

0 commit comments

Comments
 (0)