r278456 - [VFS] Add 'ignore-non-existent-contents' field to YAML files
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 18:50:54 PDT 2016
Author: bruno
Date: Thu Aug 11 20:50:53 2016
New Revision: 278456
URL: http://llvm.org/viewvc/llvm-project?rev=278456&view=rev
Log:
[VFS] Add 'ignore-non-existent-contents' field to YAML files
Add 'ignore-non-existent-contents' to tell the VFS whether an invalid path
obtained via 'external-contents' should cause iteration on the VFS to stop.
If 'true', the VFS should ignore the entry and continue with the next. Allows
YAML files to be shared across multiple compiler invocations regardless of
prior existent paths in 'external-contents'. This global value is overridable
on a per-file basis.
This adds the parsing and write test part, but use by VFS comes next.
Differential Revision: https://reviews.llvm.org/D23422
rdar://problem/27531549
Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-run-reproducer.m
cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml
Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=278456&r1=278455&r2=278456&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu Aug 11 20:50:53 2016
@@ -340,6 +340,7 @@ class YAMLVFSWriter {
Optional<bool> IsCaseSensitive;
Optional<bool> IsOverlayRelative;
Optional<bool> UseExternalNames;
+ Optional<bool> IgnoreNonExistentContents;
std::string OverlayDir;
public:
@@ -351,6 +352,9 @@ public:
void setUseExternalNames(bool UseExtNames) {
UseExternalNames = UseExtNames;
}
+ void setIgnoreNonExistentContents(bool IgnoreContents) {
+ IgnoreNonExistentContents = IgnoreContents;
+ }
void setOverlayDir(StringRef OverlayDirectory) {
IsOverlayRelative = true;
OverlayDir.assign(OverlayDirectory.str());
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=278456&r1=278455&r2=278456&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Aug 11 20:50:53 2016
@@ -801,6 +801,7 @@ public:
/// 'case-sensitive': <boolean, default=true>
/// 'use-external-names': <boolean, default=true>
/// 'overlay-relative': <boolean, default=false>
+/// 'ignore-non-existent-contents': <boolean, default=true>
///
/// Virtual directories are represented as
/// \verbatim
@@ -860,6 +861,14 @@ class RedirectingFileSystem : public vfs
/// \brief Whether to use to use the value of 'external-contents' for the
/// names of files. This global value is overridable on a per-file basis.
bool UseExternalNames = true;
+
+ /// \brief Whether an invalid path obtained via 'external-contents' should
+ /// cause iteration on the VFS to stop. If 'true', the VFS should ignore
+ /// the entry and continue with the next. Allows YAML files to be shared
+ /// across multiple compiler invocations regardless of prior existent
+ /// paths in 'external-contents'. This global value is overridable on a
+ /// per-file basis.
+ bool IgnoreNonExistentContents = true;
/// @}
/// Virtual file paths and external files could be canonicalized without "..",
@@ -937,6 +946,10 @@ public:
return ExternalContentsPrefixDir;
}
+ bool ignoreNonExistentContents() const {
+ return IgnoreNonExistentContents;
+ }
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const {
for (const std::unique_ptr<Entry> &Root : Roots)
@@ -1301,6 +1314,7 @@ public:
KeyStatusPair("case-sensitive", false),
KeyStatusPair("use-external-names", false),
KeyStatusPair("overlay-relative", false),
+ KeyStatusPair("ignore-non-existent-contents", false),
KeyStatusPair("roots", true),
};
@@ -1359,6 +1373,9 @@ public:
} else if (Key == "use-external-names") {
if (!parseScalarBool(I->getValue(), FS->UseExternalNames))
return false;
+ } else if (Key == "ignore-non-existent-contents") {
+ if (!parseScalarBool(I->getValue(), FS->IgnoreNonExistentContents))
+ return false;
} else {
llvm_unreachable("key missing from Keys");
}
@@ -1619,7 +1636,7 @@ public:
JSONWriter(llvm::raw_ostream &OS) : OS(OS) {}
void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool> UseExternalNames,
Optional<bool> IsCaseSensitive, Optional<bool> IsOverlayRelative,
- StringRef OverlayDir);
+ Optional<bool> IgnoreNonExistentContents, StringRef OverlayDir);
};
}
@@ -1675,6 +1692,7 @@ void JSONWriter::write(ArrayRef<YAMLVFSE
Optional<bool> UseExternalNames,
Optional<bool> IsCaseSensitive,
Optional<bool> IsOverlayRelative,
+ Optional<bool> IgnoreNonExistentContents,
StringRef OverlayDir) {
using namespace llvm::sys;
@@ -1692,6 +1710,9 @@ void JSONWriter::write(ArrayRef<YAMLVFSE
OS << " 'overlay-relative': '"
<< (UseOverlayRelative ? "true" : "false") << "',\n";
}
+ if (IgnoreNonExistentContents.hasValue())
+ OS << " 'ignore-non-existent-contents': '"
+ << (IgnoreNonExistentContents.getValue() ? "true" : "false") << "',\n";
OS << " 'roots': [\n";
if (!Entries.empty()) {
@@ -1748,7 +1769,8 @@ void YAMLVFSWriter::write(llvm::raw_ostr
});
JSONWriter(OS).write(Mappings, UseExternalNames, IsCaseSensitive,
- IsOverlayRelative, OverlayDir);
+ IsOverlayRelative, IgnoreNonExistentContents,
+ OverlayDir);
}
VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl(
Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=278456&r1=278455&r2=278456&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Thu Aug 11 20:50:53 2016
@@ -134,6 +134,10 @@ void ModuleDependencyCollector::writeFil
// allows crash reproducer scripts to work across machines.
VFSWriter.setOverlayDir(VFSDir);
+ // Do not ignore non existent contents otherwise we might skip something
+ // that should have been collected here.
+ VFSWriter.setIgnoreNonExistentContents(false);
+
// Explicitly set case sensitivity for the YAML writer. For that, find out
// the sensitivity at the path where the headers all collected to.
VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir));
Modified: cfe/trunk/test/Modules/crash-vfs-run-reproducer.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-run-reproducer.m?rev=278456&r1=278455&r2=278456&view=diff
==============================================================================
--- cfe/trunk/test/Modules/crash-vfs-run-reproducer.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-run-reproducer.m Thu Aug 11 20:50:53 2016
@@ -36,6 +36,7 @@
// CHECKYAML: 'case-sensitive':
// CHECKYAML-NEXT: 'use-external-names': 'false',
// CHECKYAML-NEXT: 'overlay-relative': 'true',
+// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
// CHECKYAML: 'type': 'directory'
// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
// CHECKYAML-NEXT: 'contents': [
Modified: cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml?rev=278456&r1=278455&r2=278456&view=diff
==============================================================================
--- cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml (original)
+++ cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml Thu Aug 11 20:50:53 2016
@@ -1,5 +1,6 @@
{
'version': 0,
+ 'ignore-non-existent-contents': false,
'roots': [
{ 'name': 'OUT_DIR', 'type': 'directory',
'contents': [
More information about the cfe-commits
mailing list