Skip to content

Commit

Permalink
[clang] NFC: Deprecate FileEntry::getName() (llvm#68157)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jansvoboda11 authored Dec 6, 2023
1 parent 9982f8e commit d1f86c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/include/clang/Basic/FileEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ class FileEntry {

public:
~FileEntry();
LLVM_DEPRECATED("Use FileEntryRef::getName() instead.", "")
StringRef getName() const { return LastRef->getName(); }

StringRef tryGetRealPathName() const { return RealPathName; }
Expand Down
4 changes: 4 additions & 0 deletions clang/unittests/Basic/FileManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ TEST_F(FileManagerTest, getFileRefReturnsCorrectNameForDifferentStatPath) {
ASSERT_FALSE(!F1Alias);
ASSERT_FALSE(!F1Alias2);
EXPECT_EQ("dir/f1.cpp", F1->getName());
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
EXPECT_EQ("dir/f1.cpp", F1Alias->getName());
EXPECT_EQ("dir/f1.cpp", F1Alias2->getName());
EXPECT_EQ(&F1->getFileEntry(), &F1Alias->getFileEntry());
Expand All @@ -303,7 +305,9 @@ TEST_F(FileManagerTest, getFileRefReturnsCorrectNameForDifferentStatPath) {
ASSERT_FALSE(!F2Alias);
ASSERT_FALSE(!F2Alias2);
EXPECT_EQ("dir/f2.cpp", F2->getName());
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
EXPECT_EQ("dir/f2.cpp", F2Alias->getName());
EXPECT_EQ("dir/f2.cpp", F2Alias2->getName());
EXPECT_EQ(&F2->getFileEntry(), &F2Alias->getFileEntry());
Expand Down
19 changes: 19 additions & 0 deletions llvm/include/llvm/Support/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@
#define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
#endif

// clang-format off
#if defined(__clang__) || defined(__GNUC__)
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
_Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \
_Pragma("warning(push)") \
_Pragma("warning(disable : 4996)")
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \
_Pragma("warning(pop)")
#else
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
#endif
// clang-format on

// Indicate that a non-static, non-const C++ member function reinitializes
// the entire object to a known state, independent of the previous state of
// the object.
Expand Down

0 comments on commit d1f86c3

Please sign in to comment.