Skip to content

[clang] NFC: Deprecate FileEntry::getName() #68157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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