mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ModuleInterface: refactor out a utility to extract compiler flags from a module interface file. NFC
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "llvm/Support/Host.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include <system_error>
|
||||
|
||||
using namespace swift;
|
||||
@@ -947,6 +948,18 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
|
||||
}
|
||||
}
|
||||
|
||||
bool swift::extractCompilerFlagsFromInterface(StringRef buffer,
|
||||
llvm::StringSaver &ArgSaver,
|
||||
SmallVectorImpl<const char *> &SubArgs) {
|
||||
SmallVector<StringRef, 1> FlagMatches;
|
||||
auto FlagRe = llvm::Regex("^// swift-module-flags:(.*)$", llvm::Regex::Newline);
|
||||
if (!FlagRe.match(buffer, &FlagMatches))
|
||||
return true;
|
||||
assert(FlagMatches.size() == 2);
|
||||
llvm::cl::TokenizeGNUCommandLine(FlagMatches[1], ArgSaver, SubArgs);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SerializedModuleLoaderBase::canImportModule(
|
||||
ImportPath::Element mID, llvm::VersionTuple version, bool underlyingVersion) {
|
||||
// Look on disk.
|
||||
|
||||
Reference in New Issue
Block a user