diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-08-29 05:55:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-08-29 05:55:00 +0000 |
commit | 7b73e0832b20af1f43601a3d19e76d02d9f4dce5 (patch) | |
tree | 564ac1f3310a01d7ac11ee7223b4a0ff5d8e0ac8 /lib/Frontend/CompilerInvocation.cpp | |
parent | 73212dff6437d409e0c1b779fdcac2f4f98ca8b0 (diff) | |
download | clang-7b73e0832b20af1f43601a3d19e76d02d9f4dce5.tar.gz |
Add new -cc1 driver option -analyzer-config, which allows one to specify
a comma separated collection of key:value pairs (which are strings). This
allows a general way to provide analyzer configuration data from the command line.
No clients yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 4f166b0e91..8935e775a7 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1154,6 +1154,36 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, for (unsigned i = 0, e = checkers.size(); i != e; ++i) Opts.CheckersControlList.push_back(std::make_pair(checkers[i], enable)); } + + // Go through the analyzer configuration options. + for (arg_iterator it = Args.filtered_begin(OPT_analyzer_config), + ie = Args.filtered_end(); it != ie; ++it) { + const Arg *A = *it; + A->claim(); + // We can have a list of comma separated config names, e.g: + // '-analyzer-config=key1:val1,key2:val2' + StringRef configList = A->getValue(Args); + SmallVector<StringRef, 4> configVals; + configList.split(configVals, ","); + for (unsigned i = 0, e = configVals.size(); i != e; ++i) { + StringRef key, val; + llvm::tie(key, val) = configVals[i].split(":"); + if (val.empty()) { + Diags.Report(SourceLocation(), + diag::err_analyzer_config_no_value) << configVals[i]; + Success = false; + break; + } + if (val.find(':') != StringRef::npos) { + Diags.Report(SourceLocation(), + diag::err_analyzer_config_multiple_values) + << configVals[i]; + Success = false; + break; + } + Opts.Config[key] = val; + } + } return Success; } |