const char *virtualPath,
const char *realPath);
+/**
+ * \brief Set the case sensitivity for the \c CXVirtualFileOverlay object.
+ * The \c CXVirtualFileOverlay object is case-sensitive by default, this
+ * option can be used to override the default.
+ * \returns 0 for success, non-zero to indicate an error.
+ */
+CINDEX_LINKAGE enum CXErrorCode
+clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay,
+ int caseSensitive);
+
/**
* \brief Write out the \c CXVirtualFileOverlay object to a char buffer.
*
#include "CXString.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/raw_ostream.h"
struct CXVirtualFileOverlayImpl {
std::vector<std::pair<std::string, std::string> > Mappings;
+ Optional<bool> IsCaseSensitive;
};
CXVirtualFileOverlay clang_VirtualFileOverlay_create(unsigned) {
return CXError_Success;
}
+enum CXErrorCode
+clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay VFO,
+ int caseSensitive) {
+ if (!VFO)
+ return CXError_InvalidArguments;
+
+ VFO->IsCaseSensitive = caseSensitive;
+ return CXError_Success;
+}
+
namespace {
struct EntryTy {
std::string VPath;
class JSONVFSPrinter {
llvm::raw_ostream &OS;
+ CXVirtualFileOverlay VFO;
public:
- JSONVFSPrinter(llvm::raw_ostream &OS) : OS(OS) {}
+ JSONVFSPrinter(llvm::raw_ostream &OS, CXVirtualFileOverlay VFO)
+ : OS(OS), VFO(VFO) {}
/// Entries must be sorted.
void print(ArrayRef<EntryTy> Entries) {
OS << "{\n"
- " 'version': 0,\n"
- " 'roots': [\n";
+ " 'version': 0,\n";
+ if (VFO->IsCaseSensitive.hasValue()) {
+ OS << " 'case-sensitive': '";
+ if (VFO->IsCaseSensitive.getValue())
+ OS << "true";
+ else
+ OS << "false";
+ OS << "',\n";
+ }
+ OS << " 'roots': [\n";
printDirNodes(Entries, "", 4);
OS << " ]\n"
"}\n";
llvm::SmallString<256> Buf;
llvm::raw_svector_ostream OS(Buf);
- JSONVFSPrinter Printer(OS);
+ JSONVFSPrinter Printer(OS, VFO);
Printer.print(Entries);
StringRef Data = OS.str();
T.map("/path/virtual/dir/foo3.h", "/real/foo3.h");
T.map("/path/virtual/dir/in/subdir/foo4.h", "/real/foo4.h");
}
+ {
+ const char *contents =
+ "{\n"
+ " 'version': 0,\n"
+ " 'case-sensitive': 'false',\n"
+ " 'roots': [\n"
+ " {\n"
+ " 'type': 'directory',\n"
+ " 'name': \"/path/virtual\",\n"
+ " 'contents': [\n"
+ " {\n"
+ " 'type': 'file',\n"
+ " 'name': \"foo.h\",\n"
+ " 'external-contents': \"/real/foo.h\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+ TestVFO T(contents);
+ T.map("/path/virtual/foo.h", "/real/foo.h");
+ clang_VirtualFileOverlay_setCaseSensitivity(T.VFO, false);
+ }
}
TEST(libclang, ModuleMapDescriptor) {