Config file: Treat section names as target triple regexps (#2718)

This commit is contained in:
Martin Kinkelin 2018-06-01 20:42:01 +02:00 committed by GitHub
parent 7816e7730a
commit ddbd77c009
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 72 deletions

View file

@ -13,6 +13,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
#include <cassert>
#include <cstring>
#include <iostream>
@ -172,7 +173,7 @@ bool ConfigFile::locate(std::string &pathstr) {
return false;
}
bool ConfigFile::read(const char *explicitConfFile, const char *section) {
bool ConfigFile::read(const char *explicitConfFile, const char *triple) {
std::string pathstr;
// explicitly provided by user in command line?
if (explicitConfFile) {
@ -201,7 +202,7 @@ bool ConfigFile::read(const char *explicitConfFile, const char *section) {
pathcstr = strdup(pathstr.c_str());
auto binpath = exe_path::getBinDir();
return readConfig(pathcstr, section, binpath.c_str());
return readConfig(pathcstr, triple, binpath.c_str());
}
void ConfigFile::extendCommandLine(llvm::SmallVectorImpl<const char *> &args) {
@ -219,3 +220,7 @@ void ConfigFile::extendCommandLine(llvm::SmallVectorImpl<const char *> &args) {
args.insert(runIndex == 0 ? args.end() : args.begin() + runIndex,
postSwitches.begin(), postSwitches.end());
}
bool ConfigFile::sectionMatches(const char *section, const char *triple) {
return llvm::Regex(section).match(triple);
}