Skip to content

Commit 7562c10

Browse files
committed
[omit-needless-words] Fix a bug found by -Wunused-result
StringRef::drop_back() returns the new string; it doesn't mutate `this`.
1 parent 6d32a0b commit 7562c10

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/Basic/StringExtras.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static StringRef omitNeedlessWords(StringRef name,
669669
NameRole::Partial, allPropertyNames, scratch);
670670
if (shortenedNameWord == newShortenedNameWord &&
671671
shortenedNameWord.back() == 'e') {
672-
shortenedNameWord.drop_back();
672+
shortenedNameWord = shortenedNameWord.drop_back();
673673
newShortenedNameWord =
674674
omitNeedlessWords(shortenedNameWord, typeName.CollectionElement,
675675
NameRole::Partial, allPropertyNames, scratch);

test/IDE/Inputs/custom-modules/OmitNeedlessWords.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
@interface SEGreebieArray : NSObject
88
@end
99

10+
@interface Echo : NSObject
11+
@end
12+
1013
typedef NS_OPTIONS(NSUInteger, OMWWobbleOptions) {
1114
OMWWobbleSideToSide = 0x01,
1215
OMWWobbleBackAndForth = 0x02,
@@ -21,6 +24,7 @@ typedef NS_OPTIONS(NSUInteger, OMWWobbleOptions) {
2124
-(void)jumpToTop:(nonnull id)sender;
2225
-(void)removeWithNoRemorse:(nonnull id)object;
2326
-(void)bookmarkWithURLs:(nonnull NSArray<NSURL *> *)urls;
27+
-(void)listenToEchoes:(nonnull NSArray<Echo *> *)echoes;
2428
-(void)saveToURL:(nonnull NSURL *)url forSaveOperation:(NSInteger)operation;
2529
-(void)indexWithItemNamed:(nonnull NSString *)name;
2630
-(void)methodAndReturnError:(NSError **)error;

test/IDE/print_omit_needless_words.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
// CHECK-OMIT-NEEDLESS-WORDS: func jumpToTop(_: Any)
210210
// CHECK-OMIT-NEEDLESS-WORDS: func removeWithNoRemorse(_: Any)
211211
// CHECK-OMIT-NEEDLESS-WORDS: func bookmark(with: [NSURL])
212+
// CHECK-OMIT-NEEDLESS-WORDS: func listen(to: [Echo])
212213
// CHECK-OMIT-NEEDLESS-WORDS: func save(to: NSURL, forSaveOperation: Int)
213214
// CHECK-OMIT-NEEDLESS-WORDS: func index(withItemNamed: String)
214215
// CHECK-OMIT-NEEDLESS-WORDS: func methodAndReturnError(_: AutoreleasingUnsafeMutablePointer<NSError?>!)

0 commit comments

Comments
 (0)