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

Method postPreprocess_

src/SourceCompile/CompileSourceFile.cpp:256–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256bool CompileSourceFile::postPreprocess_() {
257 FileSystem* const fileSystem = FileSystem::getInstance();
258 if (m_commandLineParser->parseOnly()) {
259 m_ppResultFileId = fileSystem->copy(m_fileId, m_symbolTable);
260 return true;
261 }
262 std::string m_pp_result = m_pp->getPreProcessedFileContent();
263 if (!m_text.empty()) {
264 m_parser = new ParseFile(m_pp_result, this, m_compilationUnit,
265 m_library); // unit test
266 }
267 if (!(m_commandLineParser->writePpOutput() ||
268 m_commandLineParser->writePpOutputFileId())) {
269 return true;
270 }
271
272 m_ppResultFileId = m_commandLineParser->writePpOutputFileId();
273 if (!m_ppResultFileId) {
274 const std::string_view libraryName = m_library->getName();
275 m_ppResultFileId = fileSystem->getPpOutputFile(
276 m_commandLineParser->fileunit(), m_fileId, libraryName, m_symbolTable);
277 }
278
279 if (m_commandLineParser->lowMem() || m_commandLineParser->link()) {
280 return true;
281 }
282
283 const PathId ppResultDirId =
284 fileSystem->getParent(m_ppResultFileId, m_symbolTable);
285 if (!fileSystem->mkdirs(ppResultDirId)) {
286 Location loc(ppResultDirId);
287 Error err(ErrorDefinition::PP_CANNOT_CREATE_DIRECTORY, loc);
288 m_errors->addError(err);
289 return false;
290 }
291 if (!m_pp->usingCachedVersion() || !fileSystem->exists(m_ppResultFileId)) {
292 if (!fileSystem->writeContent(m_ppResultFileId, m_pp_result, true)) {
293 Location loc(m_ppResultFileId);
294 Error err(ErrorDefinition::PP_OPEN_FILE_FOR_WRITE, loc);
295 m_errors->addError(err);
296 return false;
297 }
298 }
299 return true;
300}
301
302void CompileSourceFile::registerAntlrPpHandlerForId(
303 SymbolId id, PreprocessFile::AntlrParserHandler* pp) {

Callers

nothing calls this directly

Calls 15

parseOnlyMethod · 0.80
copyMethod · 0.80
writePpOutputMethod · 0.80
writePpOutputFileIdMethod · 0.80
fileunitMethod · 0.80
lowMemMethod · 0.80
linkMethod · 0.80
writeContentMethod · 0.80
getNameMethod · 0.45
getPpOutputFileMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected