| 39 | PreprocessHarness::PreprocessHarness() : m_errors(&m_symbols) {} |
| 40 | |
| 41 | std::string PreprocessHarness::preprocess(std::string_view content, |
| 42 | CompilationUnit* compUnit) { |
| 43 | std::string result; |
| 44 | PreprocessFile::SpecialInstructions instructions( |
| 45 | PreprocessFile::SpecialInstructions::DontMute, |
| 46 | PreprocessFile::SpecialInstructions::DontMark, |
| 47 | PreprocessFile::SpecialInstructions::DontFilter, |
| 48 | PreprocessFile::SpecialInstructions::CheckLoop, |
| 49 | PreprocessFile::SpecialInstructions::ComplainUndefinedMacro, |
| 50 | PreprocessFile::SpecialInstructions::Evaluate, |
| 51 | compUnit ? PreprocessFile::SpecialInstructions::Persist |
| 52 | : PreprocessFile::SpecialInstructions::DontPersist); |
| 53 | CompilationUnit unit(false); |
| 54 | CommandLineParser clp(&m_errors, &m_symbols, false, false); |
| 55 | Library lib("work", &m_symbols); |
| 56 | Compiler compiler(&clp, &m_errors, &m_symbols); |
| 57 | CompileSourceFile csf(BadPathId, &clp, &m_errors, &compiler, &m_symbols, |
| 58 | compUnit ? compUnit : &unit, &lib); |
| 59 | PreprocessFile pp(BadSymbolId, &csf, instructions, |
| 60 | compUnit ? compUnit : &unit, &lib, nullptr, 0, content, |
| 61 | nullptr, 0, BadPathId); |
| 62 | |
| 63 | if (!pp.preprocess()) { |
| 64 | result = "ERROR_PP"; |
| 65 | } |
| 66 | if (m_errors.hasFatalErrors()) { |
| 67 | result = "ERROR_PP"; |
| 68 | } |
| 69 | m_errors.printMessages(); |
| 70 | if (result.empty()) result = pp.getPreProcessedFileContent(); |
| 71 | return result; |
| 72 | } |
| 73 | |
| 74 | } // namespace SURELOG |
nothing calls this directly
no test coverage detected