MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / preprocess

Method preprocess

src/SourceCompile/PreprocessHarness.cpp:41–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39PreprocessHarness::PreprocessHarness() : m_errors(&m_symbols) {}
40
41std::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

Callers

nothing calls this directly

Calls 3

hasFatalErrorsMethod · 0.80
printMessagesMethod · 0.80

Tested by

no test coverage detected