diff options
author | Taewook Oh <twoh@fb.com> | 2016-06-13 20:40:21 +0000 |
---|---|---|
committer | Taewook Oh <twoh@fb.com> | 2016-06-13 20:40:21 +0000 |
commit | f42103ce8b38a1a534ae08a5f44ec28a8df034fe (patch) | |
tree | b3648d39a13b48498873a65e81ab754b3b81d90c /clang/include | |
parent | 92375f55ed9341cd6ecf8f34f6c1975a1b892a72 (diff) | |
download | bcm5719-llvm-f42103ce8b38a1a534ae08a5f44ec28a8df034fe.tar.gz bcm5719-llvm-f42103ce8b38a1a534ae08a5f44ec28a8df034fe.zip |
Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.
Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842
Re-commit of r272562 after addressing clang-x86-win2008-selfhost failure.
llvm-svn: 272584
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticLexKinds.td | 8 | ||||
-rw-r--r-- | clang/include/clang/Basic/FileManager.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Basic/VirtualFileSystem.h | 7 | ||||
-rw-r--r-- | clang/include/clang/Lex/DirectoryLookup.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Lex/HeaderSearch.h | 5 |
5 files changed, 24 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index f646136133f..604d51db1ff 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -275,6 +275,14 @@ def ext_missing_whitespace_after_macro_name : ExtWarn< def warn_missing_whitespace_after_macro_name : Warning< "whitespace recommended after macro name">; +class NonportablePath : Warning< + "non-portable path to file '%0'; specified path differs in case from file" + " name on disk">; +def pp_nonportable_path : NonportablePath, + InGroup<DiagGroup<"nonportable-include-path">>; +def pp_nonportable_system_path : NonportablePath, DefaultIgnore, + InGroup<DiagGroup<"nonportable-system-include-path">>; + def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">, InGroup<DiagGroup<"pragma-once-outside-header">>; def pp_pragma_sysheader_in_main_file : Warning< diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index 17758ec3f39..b6a9ca70284 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -52,6 +52,7 @@ 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. @@ -82,6 +83,7 @@ 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 bc09e678788..6ac0812dbb1 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/clang/include/clang/Basic/VirtualFileSystem.h @@ -91,6 +91,13 @@ 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<std::string> getName() { + if (auto Status = status()) + return Status->getName().str(); + 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 20c4bb03ab6..ee0af292e6f 100644 --- a/clang/include/clang/Lex/DirectoryLookup.h +++ b/clang/include/clang/Lex/DirectoryLookup.h @@ -151,6 +151,9 @@ 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. /// @@ -172,6 +175,7 @@ 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 152258af166..7bac01ef3a4 100644 --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/include/clang/Lex/HeaderSearch.h @@ -580,8 +580,9 @@ private: /// \brief Look up the file with the specified name and determine its owning /// module. const FileEntry * - getFileAndSuggestModule(StringRef FileName, const DirectoryEntry *Dir, - bool IsSystemHeaderDir, Module *RequestingModule, + getFileAndSuggestModule(StringRef FileName, SourceLocation IncludeLoc, + const DirectoryEntry *Dir, bool IsSystemHeaderDir, + Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule); public: |