Skip to content

Commit d1f86c3

Browse files
authored
[clang] NFC: Deprecate FileEntry::getName() (#68157)
All uses of `FileEntry::getName()` were removed in favor of `FileEntryRef::getName()`. This patch finally formally deprecates that function. The plan is to remove it entirely in the main branch after we cut the release branch for LLVM 18.
1 parent 9982f8e commit d1f86c3

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

clang/include/clang/Basic/FileEntry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ class FileEntry {
394394

395395
public:
396396
~FileEntry();
397+
LLVM_DEPRECATED("Use FileEntryRef::getName() instead.", "")
397398
StringRef getName() const { return LastRef->getName(); }
398399

399400
StringRef tryGetRealPathName() const { return RealPathName; }

clang/unittests/Basic/FileManagerTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ TEST_F(FileManagerTest, getFileRefReturnsCorrectNameForDifferentStatPath) {
284284
ASSERT_FALSE(!F1Alias);
285285
ASSERT_FALSE(!F1Alias2);
286286
EXPECT_EQ("dir/f1.cpp", F1->getName());
287+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
287288
EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());
289+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
288290
EXPECT_EQ("dir/f1.cpp", F1Alias->getName());
289291
EXPECT_EQ("dir/f1.cpp", F1Alias2->getName());
290292
EXPECT_EQ(&F1->getFileEntry(), &F1Alias->getFileEntry());
@@ -303,7 +305,9 @@ TEST_F(FileManagerTest, getFileRefReturnsCorrectNameForDifferentStatPath) {
303305
ASSERT_FALSE(!F2Alias);
304306
ASSERT_FALSE(!F2Alias2);
305307
EXPECT_EQ("dir/f2.cpp", F2->getName());
308+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
306309
EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
310+
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
307311
EXPECT_EQ("dir/f2.cpp", F2Alias->getName());
308312
EXPECT_EQ("dir/f2.cpp", F2Alias2->getName());
309313
EXPECT_EQ(&F2->getFileEntry(), &F2Alias->getFileEntry());

llvm/include/llvm/Support/Compiler.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@
157157
#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
158158
#endif
159159

160+
// clang-format off
161+
#if defined(__clang__) || defined(__GNUC__)
162+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
163+
_Pragma("GCC diagnostic push") \
164+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
165+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
166+
_Pragma("GCC diagnostic pop")
167+
#elif defined(_MSC_VER)
168+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
169+
_Pragma("warning(push)") \
170+
_Pragma("warning(disable : 4996)")
171+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
172+
_Pragma("warning(pop)")
173+
#else
174+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
175+
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
176+
#endif
177+
// clang-format on
178+
160179
// Indicate that a non-static, non-const C++ member function reinitializes
161180
// the entire object to a known state, independent of the previous state of
162181
// the object.

0 commit comments

Comments
 (0)