Files
revng-revng/lib/Backend/DecompileToSingleFile.cpp
T
Pietro Fezzardi c8e8f095fb PTMLCTypeBuilder: replace getIndented{Tag,Scope}
These methods had a misleading name, because they always returned a
ScopeTag, and never indented anything.
As a result they were misused or used in a confusing way in most of
their uses.

They have now both been replaced by two different overloaded methods
with the name getScopeTag.

This commit also fixes all their broken uses.
2025-05-14 10:11:46 +02:00

32 lines
1011 B
C++

//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/Support/raw_ostream.h"
#include "revng/Backend/DecompileToSingleFile.h"
#include "revng/TypeNames/PTMLCTypeBuilder.h"
using namespace revng::pipes;
void printSingleCFile(ptml::CTypeBuilder &B,
const DecompileStringMap &Functions,
const std::set<MetaAddress> &Targets) {
auto Scope = B.getScopeTag(ptml::tags::Div);
// Print headers
B.append(B.getIncludeQuote("types-and-globals.h")
+ B.getIncludeQuote("helpers.h") + "\n");
if (Targets.empty()) {
// If Targets is empty print all the Functions' bodies
for (const auto &[MetaAddress, CFunction] : Functions)
B.append(CFunction + '\n');
} else {
// Otherwise only print the bodies of the Targets
auto End = Functions.end();
for (const auto &MetaAddress : Targets)
if (auto It = Functions.find(MetaAddress); It != End)
B.append(It->second + '\n');
}
}