citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 3eaf882b0106ad6c056bbc6ffe4e33b2c0d8703d
parent 3b50871659fc1c4a028284d9f586fbee7ede0fb7
Author: Kyle Milz <kyle@0x30.net>
Date:   Sun, 14 Aug 2016 21:25:31 -0600

src: -M is a preprocessing arg too

Diffstat:
Msrc/inst_frontend.cc | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/inst_frontend.cc b/src/inst_frontend.cc @@ -53,6 +53,16 @@ ends_with(std::string const &value, std::string const &suffix) return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin()); } +// Returns true if value ends with suffix, false otherwise. +static bool +starts_with(std::string const &value, std::string const &prefix) +{ + if (prefix.length() > value.length()) + return false; + + return std::equal(prefix.begin(), prefix.end(), value.begin()); +} + // Copies one file to another preserving timestamps. static void copy_file(std::string const &dst_fn, std::string const &src_fn) @@ -146,7 +156,8 @@ InstrumentFrontend::process_cmdline() for (auto &arg : m_args) { cmd_line << arg << " "; - if (std::strcmp(arg, "-E") == 0) { + if (std::strcmp(arg, "-E") == 0 || + starts_with(arg, "-M")) { *m_log << "Preprocessor argument found\n"; exec_compiler(); }