diff options
author | Brad King <brad.king@kitware.com> | 2016-09-03 12:10:18 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-09-03 12:10:18 (GMT) |
commit | bfdf1322e7638687c96b323b1df20fd9c08b3044 (patch) | |
tree | c216079eb479d30f8dacd119dbdc5f487966b44e /Tests/CMakeLib/run_compile_commands.cxx | |
parent | 4da61391eec301ab564ac8e3e5ee9dc7ffd4f8de (diff) | |
parent | efed6468eda950644014ccfada85300710e05009 (diff) | |
download | CMake-bfdf1322e7638687c96b323b1df20fd9c08b3044.zip CMake-bfdf1322e7638687c96b323b1df20fd9c08b3044.tar.gz CMake-bfdf1322e7638687c96b323b1df20fd9c08b3044.tar.bz2 |
Merge topic 'include-what-you-use'
efed6468 fix a load of include-what-you-use violations
bd3d0eaf cmCTest: don't redefine cout and cerr
3838a0d5 make sure to include cmConfigure.h before cmStandardIncludes.h
54140848 Tests/CMakeLib: include what you use
3f9c4cdf Tests/CMakeLib: use cmsys::ifstream
Diffstat (limited to 'Tests/CMakeLib/run_compile_commands.cxx')
-rw-r--r-- | Tests/CMakeLib/run_compile_commands.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 502ffe7..529c830 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,6 +1,6 @@ #include "cmSystemTools.h" -#include <fstream> +#include <cmsys/FStream.hxx> #include <iostream> #include <map> #include <stdlib.h> @@ -26,7 +26,10 @@ public: }; typedef std::vector<CommandType> TranslationUnitsType; - CompileCommandParser(std::ifstream* input) { this->Input = input; } + CompileCommandParser(std::istream& input) + : Input(input) + { + } void Parse() { @@ -109,8 +112,8 @@ private: void Next() { - this->C = char(Input->get()); - if (this->Input->bad()) { + this->C = char(Input.get()); + if (this->Input.bad()) { ErrorExit("Unexpected end of file."); } } @@ -131,13 +134,13 @@ private: TranslationUnitsType TranslationUnits; CommandType Command; std::string String; - std::ifstream* Input; + std::istream& Input; }; int main() { - std::ifstream file("compile_commands.json"); - CompileCommandParser parser(&file); + cmsys::ifstream file("compile_commands.json"); + CompileCommandParser parser(file); parser.Parse(); for (CompileCommandParser::TranslationUnitsType::const_iterator it = parser.GetTranslationUnits().begin(), |