Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 4d09f68

Browse files
committed
Revert r272562 for build bot failure (clang-x86-win2008-selfhost)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272572 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent def8b33 commit 4d09f68

14 files changed

+13
-266
lines changed

include/clang/Basic/DiagnosticLexKinds.td

-7
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,6 @@ def ext_missing_whitespace_after_macro_name : ExtWarn<
275275
def warn_missing_whitespace_after_macro_name : Warning<
276276
"whitespace recommended after macro name">;
277277

278-
class NonportablePath : Warning<
279-
"non-portable path to file '%0'; specified path differs in case from file"
280-
" name on disk">;
281-
def pp_nonportable_path : NonportablePath, InGroup<DiagGroup<"nonportable-include-path">>;
282-
def pp_nonportable_system_path : NonportablePath, DefaultIgnore,
283-
InGroup<DiagGroup<"nonportable-system-include-path">>;
284-
285278
def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
286279
InGroup<DiagGroup<"pragma-once-outside-header">>;
287280
def pp_pragma_sysheader_in_main_file : Warning<

include/clang/Basic/FileManager.h

-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class DirectoryEntry {
5252
/// descriptor for the file.
5353
class FileEntry {
5454
const char *Name; // Name of the file.
55-
std::string RealPathName; // Real path to the file; could be empty.
5655
off_t Size; // File size in bytes.
5756
time_t ModTime; // Modification time of file.
5857
const DirectoryEntry *Dir; // Directory file lives in.
@@ -83,7 +82,6 @@ class FileEntry {
8382
}
8483

8584
const char *getName() const { return Name; }
86-
StringRef tryGetRealPathName() const { return RealPathName; }
8785
bool isValid() const { return IsValid; }
8886
off_t getSize() const { return Size; }
8987
unsigned getUID() const { return UID; }

include/clang/Basic/VirtualFileSystem.h

-7
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@ class File {
9191
virtual ~File();
9292
/// \brief Get the status of the file.
9393
virtual llvm::ErrorOr<Status> status() = 0;
94-
/// \brief Get the name of the file
95-
virtual llvm::ErrorOr<std::string> getName() {
96-
if (auto Status = status())
97-
return Status->getName().str();
98-
else
99-
return Status.getError();
100-
}
10194
/// \brief Get the contents of the file as a \p MemoryBuffer.
10295
virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
10396
getBuffer(const Twine &Name, int64_t FileSize = -1,

include/clang/Lex/DirectoryLookup.h

-4
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ class DirectoryLookup {
151151
///
152152
/// \param HS The header search instance to search with.
153153
///
154-
/// \param IncludeLoc the source location of the #include or #import
155-
/// directive.
156-
///
157154
/// \param SearchPath If not NULL, will be set to the search path relative
158155
/// to which the file was found.
159156
///
@@ -175,7 +172,6 @@ class DirectoryLookup {
175172
/// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this
176173
/// vector and point Filename to it.
177174
const FileEntry *LookupFile(StringRef &Filename, HeaderSearch &HS,
178-
SourceLocation IncludeLoc,
179175
SmallVectorImpl<char> *SearchPath,
180176
SmallVectorImpl<char> *RelativePath,
181177
Module *RequestingModule,

include/clang/Lex/HeaderSearch.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,8 @@ class HeaderSearch {
580580
/// \brief Look up the file with the specified name and determine its owning
581581
/// module.
582582
const FileEntry *
583-
getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,
584-
const DirectoryEntry *Dir, bool IsSystemHeaderDir,
585-
Module *RequestingModule,
583+
getFileAndSuggestModule(StringRef FileName, const DirectoryEntry *Dir,
584+
bool IsSystemHeaderDir, Module *RequestingModule,
586585
ModuleMap::KnownHeader *SuggestedModule);
587586

588587
public:

lib/Basic/FileManager.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
312312
UFE.InPCH = Data.InPCH;
313313
UFE.File = std::move(F);
314314
UFE.IsValid = true;
315-
if (UFE.File)
316-
if (auto RealPathName = UFE.File->getName())
317-
UFE.RealPathName = *RealPathName;
318315
return &UFE;
319316
}
320317

lib/Basic/VirtualFileSystem.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,16 @@ namespace {
140140
class RealFile : public File {
141141
int FD;
142142
Status S;
143-
std::string RealName;
144143
friend class RealFileSystem;
145-
RealFile(int FD, StringRef NewName, StringRef NewRealPathName)
144+
RealFile(int FD, StringRef NewName)
146145
: FD(FD), S(NewName, {}, {}, {}, {}, {},
147-
llvm::sys::fs::file_type::status_error, {}),
148-
RealName(NewRealPathName.str()) {
146+
llvm::sys::fs::file_type::status_error, {}) {
149147
assert(FD >= 0 && "Invalid or inactive file descriptor");
150148
}
151149

152150
public:
153151
~RealFile() override;
154152
ErrorOr<Status> status() override;
155-
ErrorOr<std::string> getName() override;
156153
ErrorOr<std::unique_ptr<MemoryBuffer>> getBuffer(const Twine &Name,
157154
int64_t FileSize,
158155
bool RequiresNullTerminator,
@@ -173,10 +170,6 @@ ErrorOr<Status> RealFile::status() {
173170
return S;
174171
}
175172

176-
ErrorOr<std::string> RealFile::getName() {
177-
return RealName.empty() ? S.getName().str() : RealName;
178-
}
179-
180173
ErrorOr<std::unique_ptr<MemoryBuffer>>
181174
RealFile::getBuffer(const Twine &Name, int64_t FileSize,
182175
bool RequiresNullTerminator, bool IsVolatile) {
@@ -214,10 +207,9 @@ ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
214207
ErrorOr<std::unique_ptr<File>>
215208
RealFileSystem::openFileForRead(const Twine &Name) {
216209
int FD;
217-
SmallString<256> RealName;
218-
if (std::error_code EC = sys::fs::openFileForRead(Name, FD, &RealName))
210+
if (std::error_code EC = sys::fs::openFileForRead(Name, FD))
219211
return EC;
220-
return std::unique_ptr<File>(new RealFile(FD, Name.str(), RealName.str()));
212+
return std::unique_ptr<File>(new RealFile(FD, Name.str()));
221213
}
222214

223215
llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const {

lib/Lex/HeaderSearch.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@ const char *DirectoryLookup::getName() const {
250250
}
251251

252252
const FileEntry *HeaderSearch::getFileAndSuggestModule(
253-
StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
254-
bool IsSystemHeaderDir, Module *RequestingModule,
255-
ModuleMap::KnownHeader *SuggestedModule) {
253+
StringRef FileName, const DirectoryEntry *Dir, bool IsSystemHeaderDir,
254+
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) {
256255
// If we have a module map that might map this header, load it and
257256
// check whether we'll have a suggestion for a module.
258257
const FileEntry *File = getFileMgr().getFile(FileName, /*OpenFile=*/true);
@@ -273,7 +272,6 @@ const FileEntry *HeaderSearch::getFileAndSuggestModule(
273272
const FileEntry *DirectoryLookup::LookupFile(
274273
StringRef &Filename,
275274
HeaderSearch &HS,
276-
SourceLocation IncludeLoc,
277275
SmallVectorImpl<char> *SearchPath,
278276
SmallVectorImpl<char> *RelativePath,
279277
Module *RequestingModule,
@@ -299,7 +297,7 @@ const FileEntry *DirectoryLookup::LookupFile(
299297
RelativePath->append(Filename.begin(), Filename.end());
300298
}
301299

302-
return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),
300+
return HS.getFileAndSuggestModule(TmpDir, getDir(),
303301
isSystemHeaderDirectory(),
304302
RequestingModule, SuggestedModule);
305303
}
@@ -587,7 +585,7 @@ const FileEntry *HeaderSearch::LookupFile(
587585
RelativePath->append(Filename.begin(), Filename.end());
588586
}
589587
// Otherwise, just return the file.
590-
return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,
588+
return getFileAndSuggestModule(Filename, nullptr,
591589
/*IsSystemHeaderDir*/false,
592590
RequestingModule, SuggestedModule);
593591
}
@@ -624,7 +622,7 @@ const FileEntry *HeaderSearch::LookupFile(
624622
Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :
625623
BuildSystemModule;
626624
if (const FileEntry *FE = getFileAndSuggestModule(
627-
TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,
625+
TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,
628626
RequestingModule, SuggestedModule)) {
629627
if (!Includer) {
630628
assert(First && "only first includer can have no file");
@@ -715,7 +713,7 @@ const FileEntry *HeaderSearch::LookupFile(
715713
bool InUserSpecifiedSystemFramework = false;
716714
bool HasBeenMapped = false;
717715
const FileEntry *FE = SearchDirs[i].LookupFile(
718-
Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
716+
Filename, *this, SearchPath, RelativePath, RequestingModule,
719717
SuggestedModule, InUserSpecifiedSystemFramework, HasBeenMapped,
720718
MappedName);
721719
if (HasBeenMapped) {

lib/Lex/PPDirectives.cpp

-148
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "clang/Lex/ModuleLoader.h"
2525
#include "clang/Lex/Pragma.h"
2626
#include "llvm/ADT/APInt.h"
27-
#include "llvm/ADT/STLExtras.h"
28-
#include "llvm/ADT/StringExtras.h"
29-
#include "llvm/ADT/StringSwitch.h"
30-
#include "llvm/ADT/iterator_range.h"
3127
#include "llvm/Support/ErrorHandling.h"
3228
#include "llvm/Support/Path.h"
3329
#include "llvm/Support/SaveAndRestore.h"
@@ -141,84 +137,6 @@ static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
141137
return MD_NoWarn;
142138
}
143139

144-
// Return true if we want to issue a diagnostic by default if we
145-
// encounter this name in a #include with the wrong case. For now,
146-
// this includes the standard C and C++ headers, Posix headers,
147-
// and Boost headers. Improper case for these #includes is a
148-
// potential portability issue.
149-
static bool warnByDefaultOnWrongCase(StringRef Include) {
150-
// If the first component of the path is "boost", treat this like a standard header
151-
// for the purposes of diagnostics.
152-
if (::llvm::sys::path::begin(Include)->equals_lower("boost"))
153-
return true;
154-
155-
// "condition_variable" is the longest standard header name at 18 characters.
156-
// If the include file name is longer than that, it can't be a standard header.
157-
static constexpr std::size_t MaxStdHeaderNameLen = 18u;
158-
if (Include.size() > MaxStdHeaderNameLen)
159-
return false;
160-
161-
// Lowercase and normalize the search string.
162-
SmallString<32> LowerInclude{Include};
163-
for (char &Ch : LowerInclude) {
164-
// In the ASCII range?
165-
if (Ch < 0 || Ch > 0x7f)
166-
return false; // Can't be a standard header
167-
// ASCII lowercase:
168-
if (Ch >= 'A' && Ch <= 'Z')
169-
Ch += 'a' - 'A';
170-
// Normalize path separators for comparison purposes.
171-
else if (::llvm::sys::path::is_separator(Ch))
172-
Ch = '/';
173-
}
174-
175-
// The standard C/C++ and Posix headers
176-
return llvm::StringSwitch<bool>(LowerInclude)
177-
// C library headers
178-
.Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
179-
.Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
180-
.Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
181-
.Cases("stdatomic.h", "stdbool.h", "stddef.h", "stdint.h", "stdio.h", true)
182-
.Cases("stdlib.h", "stdnoreturn.h", "string.h", "tgmath.h", "threads.h", true)
183-
.Cases("time.h", "uchar.h", "wchar.h", "wctype.h", true)
184-
185-
// C++ headers for C library facilities
186-
.Cases("cassert", "ccomplex", "cctype", "cerrno", "cfenv", true)
187-
.Cases("cfloat", "cinttypes", "ciso646", "climits", "clocale", true)
188-
.Cases("cmath", "csetjmp", "csignal", "cstdalign", "cstdarg", true)
189-
.Cases("cstdbool", "cstddef", "cstdint", "cstdio", "cstdlib", true)
190-
.Cases("cstring", "ctgmath", "ctime", "cuchar", "cwchar", true)
191-
.Case("cwctype", true)
192-
193-
// C++ library headers
194-
.Cases("algorithm", "fstream", "list", "regex", "thread", true)
195-
.Cases("array", "functional", "locale", "scoped_allocator", "tuple", true)
196-
.Cases("atomic", "future", "map", "set", "type_traits", true)
197-
.Cases("bitset", "initializer_list", "memory", "shared_mutex", "typeindex", true)
198-
.Cases("chrono", "iomanip", "mutex", "sstream", "typeinfo", true)
199-
.Cases("codecvt", "ios", "new", "stack", "unordered_map", true)
200-
.Cases("complex", "iosfwd", "numeric", "stdexcept", "unordered_set", true)
201-
.Cases("condition_variable", "iostream", "ostream", "streambuf", "utility", true)
202-
.Cases("deque", "istream", "queue", "string", "valarray", true)
203-
.Cases("exception", "iterator", "random", "strstream", "vector", true)
204-
.Cases("forward_list", "limits", "ratio", "system_error", true)
205-
206-
// POSIX headers (which aren't also C headers)
207-
.Cases("aio.h", "arpa/inet.h", "cpio.h", "dirent.h", "dlfcn.h", true)
208-
.Cases("fcntl.h", "fmtmsg.h", "fnmatch.h", "ftw.h", "glob.h", true)
209-
.Cases("grp.h", "iconv.h", "langinfo.h", "libgen.h", "monetary.h", true)
210-
.Cases("mqueue.h", "ndbm.h", "net/if.h", "netdb.h", "netinet/in.h", true)
211-
.Cases("netinet/tcp.h", "nl_types.h", "poll.h", "pthread.h", "pwd.h", true)
212-
.Cases("regex.h", "sched.h", "search.h", "semaphore.h", "spawn.h", true)
213-
.Cases("strings.h", "stropts.h", "sys/ipc.h", "sys/mman.h", "sys/msg.h", true)
214-
.Cases("sys/resource.h", "sys/select.h", "sys/sem.h", "sys/shm.h", "sys/socket.h", true)
215-
.Cases("sys/stat.h", "sys/statvfs.h", "sys/time.h", "sys/times.h", "sys/types.h", true)
216-
.Cases("sys/uio.h", "sys/un.h", "sys/utsname.h", "sys/wait.h", "syslog.h", true)
217-
.Cases("tar.h", "termios.h", "trace.h", "ulimit.h", true)
218-
.Cases("unistd.h", "utime.h", "utmpx.h", "wordexp.h", true)
219-
.Default(false);
220-
}
221-
222140
bool Preprocessor::CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef,
223141
bool *ShadowFlag) {
224142
// Missing macro name?
@@ -1638,39 +1556,6 @@ static void diagnoseAutoModuleImport(
16381556
("@import " + PathString + ";").str());
16391557
}
16401558

1641-
// Given a vector of path components and a string containing the real
1642-
// path to the file, build a properly-cased replacement in the vector,
1643-
// and return true if the replacement should be suggested.
1644-
static bool trySimplifyPath(SmallVectorImpl<StringRef> &Components,
1645-
StringRef RealPathName) {
1646-
auto RealPathComponentIter = llvm::sys::path::rbegin(RealPathName);
1647-
auto RealPathComponentEnd = llvm::sys::path::rend(RealPathName);
1648-
int Cnt = 0;
1649-
bool SuggestReplacement = false;
1650-
// Below is a best-effort to handle ".." in paths. It is admittedly
1651-
// not 100% correct in the presence of symlinks.
1652-
for (auto &Component : llvm::reverse(Components)) {
1653-
if ("." == Component) {
1654-
} else if (".." == Component) {
1655-
++Cnt;
1656-
} else if (Cnt) {
1657-
--Cnt;
1658-
} else if (RealPathComponentIter != RealPathComponentEnd) {
1659-
if (Component != *RealPathComponentIter) {
1660-
// If these path components differ by more than just case, then we
1661-
// may be looking at symlinked paths. Bail on this diagnostic to avoid
1662-
// noisy false positives.
1663-
SuggestReplacement = RealPathComponentIter->equals_lower(Component);
1664-
if (!SuggestReplacement)
1665-
break;
1666-
Component = *RealPathComponentIter;
1667-
}
1668-
++RealPathComponentIter;
1669-
}
1670-
}
1671-
return SuggestReplacement;
1672-
}
1673-
16741559
/// HandleIncludeDirective - The "\#include" tokens have just been read, read
16751560
/// the file to be included from the lexer, then include it! This is a common
16761561
/// routine with functionality shared between \#include, \#include_next and
@@ -1946,39 +1831,6 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
19461831
// FIXME: If we have a suggested module, and we've already visited this file,
19471832
// don't bother entering it again. We know it has no further effect.
19481833

1949-
// Issue a diagnostic if the name of the file on disk has a different case
1950-
// than the one we're about to open.
1951-
const bool CheckIncludePathPortability =
1952-
File && !File->tryGetRealPathName().empty();
1953-
1954-
if (CheckIncludePathPortability) {
1955-
StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.str() : Filename;
1956-
StringRef RealPathName = File->tryGetRealPathName();
1957-
SmallVector<StringRef, 16> Components(llvm::sys::path::begin(Name),
1958-
llvm::sys::path::end(Name));
1959-
1960-
if (trySimplifyPath(Components, RealPathName)) {
1961-
SmallString<128> Path;
1962-
Path.reserve(Name.size()+2);
1963-
Path.push_back(isAngled ? '<' : '"');
1964-
for (auto Component : Components) {
1965-
Path.append(Component);
1966-
// Append the separator the user used, or the close quote
1967-
Path.push_back(
1968-
Path.size() <= Filename.size() ? Filename[Path.size()-1] :
1969-
(isAngled ? '>' : '"'));
1970-
}
1971-
auto Replacement = Path.str().str();
1972-
// For user files and known standard headers, by default we issue a diagnostic.
1973-
// For other system headers, we don't. They can be controlled separately.
1974-
auto DiagId = (FileCharacter == SrcMgr::C_User || warnByDefaultOnWrongCase(Name)) ?
1975-
diag::pp_nonportable_path : diag::pp_nonportable_system_path;
1976-
SourceRange Range(FilenameTok.getLocation(), CharEnd);
1977-
Diag(FilenameTok, DiagId) << Replacement <<
1978-
FixItHint::CreateReplacement(Range, Replacement);
1979-
}
1980-
}
1981-
19821834
// Ask HeaderInfo if we should enter this #include file. If not, #including
19831835
// this file will have no effect.
19841836
if (ShouldEnter &&

test/Lexer/Inputs/case-insensitive-include.h

-8
This file was deleted.

test/Lexer/case-insensitive-include-ms.c

-18
This file was deleted.

0 commit comments

Comments
 (0)