diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/include/clang/Lex/HeaderSearch.h @@ -20,6 +20,7 @@ #include "clang/Lex/ModuleMap.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" @@ -116,6 +117,9 @@ /// of the framework. StringRef Framework; + /// Alias that this header is known as. + llvm::SmallString<64> Alias; + HeaderFileInfo() : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), External(false), isModuleHeader(false), isCompilingModuleHeader(false), diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1030,8 +1030,10 @@ CurDir = It; - // This file is a system header or C++ unfriendly if the dir is. HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry()); + HFI.Alias = Filename.str(); + + // This file is a system header or C++ unfriendly if the dir is. HFI.DirInfo = CurDir->getDirCharacteristic(); // If the directory characteristic is User but this framework was diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -207,6 +207,7 @@ EXPECT_TRUE(FI); EXPECT_TRUE(FI->IsValid); EXPECT_EQ(FI->Framework.str(), "Foo"); + EXPECT_EQ(FI->Alias, "Foo/Foo.h"); } // Helper struct with null terminator character to make MemoryBuffer happy. @@ -275,6 +276,7 @@ EXPECT_TRUE(FI); EXPECT_TRUE(FI->IsValid); EXPECT_EQ(FI->Framework.str(), "Foo"); + EXPECT_EQ(FI->Alias, "Foo/Foo.h"); } } // namespace