summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticGroups.td1
-rw-r--r--clang/include/clang/Basic/DiagnosticLexKinds.td4
-rw-r--r--clang/include/clang/Basic/FileManager.h2
-rw-r--r--clang/include/clang/Basic/VirtualFileSystem.h7
-rw-r--r--clang/include/clang/Lex/DirectoryLookup.h4
-rw-r--r--clang/include/clang/Lex/HeaderSearch.h5
-rw-r--r--clang/lib/Basic/FileManager.cpp3
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp16
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp14
-rw-r--r--clang/lib/Lex/PPDirectives.cpp67
-rw-r--r--clang/test/Lexer/Inputs/case-insensitive-include.h5
-rw-r--r--clang/test/Lexer/case-insensitive-include-ms.c18
-rw-r--r--clang/test/Lexer/case-insensitive-include.c27
-rw-r--r--clang/test/PCH/case-insensitive-include.c2
14 files changed, 13 insertions, 162 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 38181904f87..979c81f6361 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -390,7 +390,6 @@ def : DiagGroup<"sequence-point", [Unsequenced]>;
def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
def KeywordAsMacro : DiagGroup<"keyword-macro">;
def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
-def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
// Just silence warnings about -Wstrict-aliasing for now.
def : DiagGroup<"strict-aliasing=0">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 52116a603d5..dab8cf279ca 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -274,10 +274,6 @@ def ext_missing_whitespace_after_macro_name : ExtWarn<
"whitespace required after macro name">;
def warn_missing_whitespace_after_macro_name : Warning<
"whitespace recommended after macro name">;
-def pp_nonportable_path : Warning<
- "non-portable path to file '%0'; specified path differs in case from file"
- " name on disk">,
- InGroup<NonportableIncludePath>;
def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
InGroup<DiagGroup<"pragma-once-outside-header">>;
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index b6a9ca70284..17758ec3f39 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -52,7 +52,6 @@ public:
/// descriptor for the file.
class FileEntry {
const char *Name; // Name of the file.
- std::string RealPathName; // Real path to the file; could be empty.
off_t Size; // File size in bytes.
time_t ModTime; // Modification time of file.
const DirectoryEntry *Dir; // Directory file lives in.
@@ -83,7 +82,6 @@ public:
}
const char *getName() const { return Name; }
- StringRef tryGetRealPathName() const { return RealPathName; }
bool isValid() const { return IsValid; }
off_t getSize() const { return Size; }
unsigned getUID() const { return UID; }
diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/clang/include/clang/Basic/VirtualFileSystem.h
index 4353f845881..bc09e678788 100644
--- a/clang/include/clang/Basic/VirtualFileSystem.h
+++ b/clang/include/clang/Basic/VirtualFileSystem.h
@@ -91,13 +91,6 @@ public:
virtual ~File();
/// \brief Get the status of the file.
virtual llvm::ErrorOr<Status> status() = 0;
- /// \brief Get the name of the file
- virtual llvm::ErrorOr<StringRef> getName() {
- if (auto Status = status())
- return Status->getName();
- else
- return Status.getError();
- }
/// \brief Get the contents of the file as a \p MemoryBuffer.
virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
getBuffer(const Twine &Name, int64_t FileSize = -1,
diff --git a/clang/include/clang/Lex/DirectoryLookup.h b/clang/include/clang/Lex/DirectoryLookup.h
index ee0af292e6f..20c4bb03ab6 100644
--- a/clang/include/clang/Lex/DirectoryLookup.h
+++ b/clang/include/clang/Lex/DirectoryLookup.h
@@ -151,9 +151,6 @@ public:
///
/// \param HS The header search instance to search with.
///
- /// \param IncludeLoc the source location of the #include or #import
- /// directive.
- ///
/// \param SearchPath If not NULL, will be set to the search path relative
/// to which the file was found.
///
@@ -175,7 +172,6 @@ public:
/// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this
/// vector and point Filename to it.
const FileEntry *LookupFile(StringRef &Filename, HeaderSearch &HS,
- SourceLocation IncludeLoc,
SmallVectorImpl<char> *SearchPath,
SmallVectorImpl<char> *RelativePath,
Module *RequestingModule,
diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 7bac01ef3a4..152258af166 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -580,9 +580,8 @@ private:
/// \brief Look up the file with the specified name and determine its owning
/// module.
const FileEntry *
- getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc,
- const DirectoryEntry *Dir, bool IsSystemHeaderDir,
- Module *RequestingModule,
+ getFileAndSuggestModule(StringRef FileName, const DirectoryEntry *Dir,
+ bool IsSystemHeaderDir, Module *RequestingModule,
ModuleMap::KnownHeader *SuggestedModule);
public:
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f9fa2338992..c4cc8dc5419 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -312,9 +312,6 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
UFE.InPCH = Data.InPCH;
UFE.File = std::move(F);
UFE.IsValid = true;
- if (UFE.File)
- if (auto RealPathName = UFE.File->getName())
- UFE.RealPathName = RealPathName->str();
return &UFE;
}
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 120d7e0d9e0..d64c4e3d8c0 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -140,19 +140,16 @@ namespace {
class RealFile : public File {
int FD;
Status S;
- std::string RealName;
friend class RealFileSystem;
- RealFile(int FD, StringRef NewName, StringRef NewRealPathName)
+ RealFile(int FD, StringRef NewName)
: FD(FD), S(NewName, {}, {}, {}, {}, {},
- llvm::sys::fs::file_type::status_error, {}),
- RealName(NewRealPathName.str()) {
+ llvm::sys::fs::file_type::status_error, {}) {
assert(FD >= 0 && "Invalid or inactive file descriptor");
}
public:
~RealFile() override;
ErrorOr<Status> status() override;
- ErrorOr<StringRef> getName() override;
ErrorOr<std::unique_ptr<MemoryBuffer>> getBuffer(const Twine &Name,
int64_t FileSize,
bool RequiresNullTerminator,
@@ -173,10 +170,6 @@ ErrorOr<Status> RealFile::status() {
return S;
}
-ErrorOr<StringRef> RealFile::getName() {
- return RealName.empty() ? S.getName() : StringRef(RealName);
-}
-
ErrorOr<std::unique_ptr<MemoryBuffer>>
RealFile::getBuffer(const Twine &Name, int64_t FileSize,
bool RequiresNullTerminator, bool IsVolatile) {
@@ -214,10 +207,9 @@ ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
ErrorOr<std::unique_ptr<File>>
RealFileSystem::openFileForRead(const Twine &Name) {
int FD;
- SmallString<256> RealName;
- if (std::error_code EC = sys::fs::openFileForRead(Name, FD, &RealName))
+ if (std::error_code EC = sys::fs::openFileForRead(Name, FD))
return EC;
- return std::unique_ptr<File>(new RealFile(FD, Name.str(), RealName.str()));
+ return std::unique_ptr<File>(new RealFile(FD, Name.str()));
}
llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const {
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index e5cc30e41c5..f7fc0b0f65f 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -250,9 +250,8 @@ const char *DirectoryLookup::getName() const {
}
const FileEntry *HeaderSearch::getFileAndSuggestModule(
- StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
- bool IsSystemHeaderDir, Module *RequestingModule,
- ModuleMap::KnownHeader *SuggestedModule) {
+ StringRef FileName, const DirectoryEntry *Dir, bool IsSystemHeaderDir,
+ Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule) {
// If we have a module map that might map this header, load it and
// check whether we'll have a suggestion for a module.
const FileEntry *File = getFileMgr().getFile(FileName, /*OpenFile=*/true);
@@ -273,7 +272,6 @@ const FileEntry *HeaderSearch::getFileAndSuggestModule(
const FileEntry *DirectoryLookup::LookupFile(
StringRef &Filename,
HeaderSearch &HS,
- SourceLocation IncludeLoc,
SmallVectorImpl<char> *SearchPath,
SmallVectorImpl<char> *RelativePath,
Module *RequestingModule,
@@ -299,7 +297,7 @@ const FileEntry *DirectoryLookup::LookupFile(
RelativePath->append(Filename.begin(), Filename.end());
}
- return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),
+ return HS.getFileAndSuggestModule(TmpDir, getDir(),
isSystemHeaderDirectory(),
RequestingModule, SuggestedModule);
}
@@ -587,7 +585,7 @@ const FileEntry *HeaderSearch::LookupFile(
RelativePath->append(Filename.begin(), Filename.end());
}
// Otherwise, just return the file.
- return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,
+ return getFileAndSuggestModule(Filename, nullptr,
/*IsSystemHeaderDir*/false,
RequestingModule, SuggestedModule);
}
@@ -624,7 +622,7 @@ const FileEntry *HeaderSearch::LookupFile(
Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :
BuildSystemModule;
if (const FileEntry *FE = getFileAndSuggestModule(
- TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,
+ TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,
RequestingModule, SuggestedModule)) {
if (!Includer) {
assert(First && "only first includer can have no file");
@@ -715,7 +713,7 @@ const FileEntry *HeaderSearch::LookupFile(
bool InUserSpecifiedSystemFramework = false;
bool HasBeenMapped = false;
const FileEntry *FE = SearchDirs[i].LookupFile(
- Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
+ Filename, *this, SearchPath, RelativePath, RequestingModule,
SuggestedModule, InUserSpecifiedSystemFramework, HasBeenMapped,
MappedName);
if (HasBeenMapped) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index dccb588cb2a..34adf7fac29 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -24,9 +24,6 @@
#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/Pragma.h"
#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SaveAndRestore.h"
@@ -1559,41 +1556,6 @@ static void diagnoseAutoModuleImport(
("@import " + PathString + ";").str());
}
-namespace {
- // Given a vector of path components and a string containing the real
- // path to the file, build a properly-cased replacement in the vector,
- // and return true if the replacement should be suggested.
- bool TrySimplifyPath(SmallVectorImpl<StringRef> &Components,
- StringRef RealPathName) {
- auto RealPathComponentIter = llvm::sys::path::rbegin(RealPathName);
- auto RealPathComponentEnd = llvm::sys::path::rend(RealPathName);
- int Cnt = 0;
- bool SuggestReplacement = false;
- // Below is a best-effort to handle ".." in paths. It is admittedly
- // not 100% correct in the presence of symlinks.
- for(auto &Component : llvm::reverse(Components)) {
- if ("." == Component) {
- } else if (".." == Component) {
- ++Cnt;
- } else if (Cnt) {
- --Cnt;
- } else if (RealPathComponentIter != RealPathComponentEnd) {
- if (Component != *RealPathComponentIter) {
- // If these path components differ by more than just case, then we
- // may be looking at symlinked paths. Bail on this diagnostic to avoid
- // noisy false positives.
- SuggestReplacement = RealPathComponentIter->equals_lower(Component);
- if (!SuggestReplacement)
- break;
- Component = *RealPathComponentIter;
- }
- ++RealPathComponentIter;
- }
- }
- return SuggestReplacement;
- }
-}
-
/// HandleIncludeDirective - The "\#include" tokens have just been read, read
/// the file to be included from the lexer, then include it! This is a common
/// routine with functionality shared between \#include, \#include_next and
@@ -1758,35 +1720,6 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
}
}
- // Issue a diagnostic if the name of the file on disk has a different case
- // than the one we're about to open.
- const bool CheckIncludePathPortability =
- File && !File->tryGetRealPathName().empty();
-
- if (CheckIncludePathPortability) {
- StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename;
- StringRef RealPathName = File->tryGetRealPathName();
- SmallVector<StringRef, 16> Components(llvm::sys::path::begin(Name),
- llvm::sys::path::end(Name));
-
- if (TrySimplifyPath(Components, RealPathName)) {
- SmallString<128> Path;
- Path.reserve(Name.size()+2);
- Path.push_back(isAngled ? '<' : '"');
- for (auto Component : Components) {
- Path.append(Component);
- // Append the separator the user used, or the close quote
- Path.push_back(
- Path.size() <= Filename.size() ? Filename[Path.size()-1] :
- (isAngled ? '>' : '"'));
- }
- auto Replacement = Path.str().str();
- SourceRange Range(FilenameTok.getLocation(), CharEnd);
- Diag(FilenameTok, diag::pp_nonportable_path) << Replacement <<
- FixItHint::CreateReplacement(Range, Replacement);
- }
- }
-
// Should we enter the source file? Set to false if either the source file is
// known to have no effect beyond its effect on module visibility -- that is,
// if it's got an include guard that is already defined or is a modular header
diff --git a/clang/test/Lexer/Inputs/case-insensitive-include.h b/clang/test/Lexer/Inputs/case-insensitive-include.h
deleted file mode 100644
index 60bdf36dbb7..00000000000
--- a/clang/test/Lexer/Inputs/case-insensitive-include.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-
-struct S {
- int x;
-};
diff --git a/clang/test/Lexer/case-insensitive-include-ms.c b/clang/test/Lexer/case-insensitive-include-ms.c
deleted file mode 100644
index 86bd8bba68e..00000000000
--- a/clang/test/Lexer/case-insensitive-include-ms.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// REQUIRES: case-insensitive-filesystem
-
-// RUN: mkdir -p %T/apath
-// RUN: cp %S/Inputs/case-insensitive-include.h %T
-// RUN: cd %T
-// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s -include %s -I %T -verify
-// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -fdiagnostics-parseable-fixits %s -include %s -I %T 2>&1 | FileCheck %s
-
-#include "..\Output\.\case-insensitive-include.h"
-#include "..\Output\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""
-#include "..\output\.\case-insensitive-include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\""
-
-#include "apath\..\.\case-insensitive-include.h"
-#include "apath\..\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath\\..\\.\\case-insensitive-include.h\""
-#include "APath\..\.\case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
diff --git a/clang/test/Lexer/case-insensitive-include.c b/clang/test/Lexer/case-insensitive-include.c
deleted file mode 100644
index d25ff025a82..00000000000
--- a/clang/test/Lexer/case-insensitive-include.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// REQUIRES: case-insensitive-filesystem
-
-// RUN: mkdir -p %T/apath
-// RUN: cp %S/Inputs/case-insensitive-include.h %T
-// RUN: cd %T
-// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -include %s -I %T 2>&1 | FileCheck %s
-
-#include "case-insensitive-include.h"
-#include "Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:38}:"\"case-insensitive-include.h\""
-
-#include "../Output/./case-insensitive-include.h"
-#include "../Output/./Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\""
-#include "../output/./case-insensitive-include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\""
-
-#include "apath/.././case-insensitive-include.h"
-#include "apath/.././Case-Insensitive-Include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath/.././case-insensitive-include.h\""
-#include "APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
-
-#include "../Output/./apath/.././case-insensitive-include.h"
-#include "../Output/./APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-(
-#include "../output/./apath/.././case-insensitive-include.h" // expected-warning {{non-portable path}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:61}:"\"../Output/./apath/.././case-insensitive-include.h\""
diff --git a/clang/test/PCH/case-insensitive-include.c b/clang/test/PCH/case-insensitive-include.c
index 1dcda273c2f..707de702f15 100644
--- a/clang/test/PCH/case-insensitive-include.c
+++ b/clang/test/PCH/case-insensitive-include.c
@@ -2,7 +2,7 @@
// Test this without pch.
// RUN: cp %S/Inputs/case-insensitive-include.h %T
-// RUN: %clang_cc1 -Wno-nonportable-include-path -fsyntax-only %s -include %s -I %T -verify
+// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -verify
// Test with pch.
// RUN: %clang_cc1 -emit-pch -o %t.pch %s -I %T
OpenPOWER on IntegriCloud