Skip to content

Commit 6b4e78e

Browse files
committed
format code
1 parent d12d64a commit 6b4e78e

File tree

7 files changed

+39
-33
lines changed

7 files changed

+39
-33
lines changed

include/slang.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4421,8 +4421,8 @@ struct IModule : public IComponentType
44214421

44224422
/** Disassemble a module.
44234423
*/
4424-
virtual SLANG_NO_THROW SlangResult SLANG_MCALL disassemble(
4425-
slang::IBlob** outDisassembledBlob) = 0;
4424+
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
4425+
disassemble(slang::IBlob** outDisassembledBlob) = 0;
44264426
};
44274427

44284428
#define SLANG_UUID_IModule IModule::getTypeGuid()

source/slang-record-replay/record/slang-module.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ SlangResult ModuleRecorder::disassemble(ISlangBlob** outBlob)
249249
{
250250
// No need to record this call as it is just a query.
251251
slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
252-
auto res = m_actualModule->disassemble(outBlob);
252+
auto res = m_actualModule->disassemble(outBlob);
253253
return res;
254254
}
255255
} // namespace SlangRecord

source/slang-record-replay/record/slang-module.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class ModuleRecorder : public IModuleRecorder, public IComponentTypeRecorder
5656
ISlangBlob** outDiagnostics) override;
5757
virtual SLANG_NO_THROW SlangInt32 SLANG_MCALL getDependencyFileCount() override;
5858
virtual SLANG_NO_THROW char const* SLANG_MCALL getDependencyFilePath(SlangInt32 index) override;
59-
virtual SLANG_NO_THROW SlangResult SLANG_MCALL disassemble(slang::IBlob** outDisassembly) override;
59+
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
60+
disassemble(slang::IBlob** outDisassembly) override;
6061

6162
// Interfaces for `IComponentType`
6263
virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override

source/slang/slang-compiler.h

+11-12
Original file line numberDiff line numberDiff line change
@@ -1833,18 +1833,17 @@ class Module : public ComponentType, public slang::IModule
18331833
// Source files that have been pulled into the module with `__include`.
18341834
Dictionary<SourceFile*, FileDecl*> m_mapSourceFileToFileDecl;
18351835

1836-
public:
1837-
SLANG_NO_THROW SlangResult SLANG_MCALL disassemble(
1838-
slang::IBlob** outDisassembledBlob) override
1839-
{
1840-
if (!outDisassembledBlob)
1841-
return SLANG_E_INVALID_ARG;
1842-
String disassembly;
1843-
this->getIRModule()->getModuleInst()->dump(disassembly);
1844-
auto blob = StringUtil::createStringBlob(disassembly);
1845-
*outDisassembledBlob = blob.detach();
1846-
return SLANG_OK;
1847-
}
1836+
public:
1837+
SLANG_NO_THROW SlangResult SLANG_MCALL disassemble(slang::IBlob** outDisassembledBlob) override
1838+
{
1839+
if (!outDisassembledBlob)
1840+
return SLANG_E_INVALID_ARG;
1841+
String disassembly;
1842+
this->getIRModule()->getModuleInst()->dump(disassembly);
1843+
auto blob = StringUtil::createStringBlob(disassembly);
1844+
*outDisassembledBlob = blob.detach();
1845+
return SLANG_OK;
1846+
}
18481847
};
18491848
typedef Module LoadedModule;
18501849

source/slang/slang-ir.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -8950,20 +8950,20 @@ void IRInst::addBlock(IRBlock* block)
89508950
block->insertAtEnd(this);
89518951
}
89528952

8953-
void IRInst::dump(String &outStr)
8954-
{
8955-
StringBuilder sb;
8953+
void IRInst::dump(String& outStr)
8954+
{
8955+
StringBuilder sb;
89568956

89578957
if (auto intLit = as<IRIntLit>(this))
89588958
{
89598959
sb << intLit->getValue();
89608960
}
89618961
else if (auto stringLit = as<IRStringLit>(this))
89628962
{
8963-
sb << stringLit->getStringSlice();
8963+
sb << stringLit->getStringSlice();
89648964
}
89658965
else
8966-
{
8966+
{
89678967
IRDumpOptions options;
89688968
StringWriter writer(&sb, Slang::WriterFlag::AutoFlush);
89698969
dumpIR(this, options, nullptr, &writer);

source/slang/slang-ir.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ struct IRInst
819819

820820
/// Print the IR to a string for debugging purposes.
821821
///
822-
void dump(String &outStr);
822+
void dump(String& outStr);
823823

824824
/// Insert a basic block at the end of this func/code containing inst.
825825
void addBlock(IRBlock* block);

source/slang/slang-options.cpp

+17-11
Original file line numberDiff line numberDiff line change
@@ -2953,40 +2953,44 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv)
29532953
case OptionKind::DumpModule:
29542954
{
29552955
CommandLineArg fileName;
2956-
SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName));
2956+
SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName));
29572957
auto desc = slang::SessionDesc();
29582958
ComPtr<slang::ISession> session;
29592959
m_session->createSession(desc, session.writeRef());
29602960
ComPtr<slang::IBlob> diagnostics;
29612961

29622962
// Coerce Slang to load from the given file, without letting it automatically
2963-
// choose .slang-module files over .slang files.
2963+
// choose .slang-module files over .slang files.
29642964
// First try to load as source string, and fall back to loading as an IR Blob.
29652965
// Avoid guessing based on filename or inspect the file contents.
29662966
FILE* file = fopen(fileName.value.getBuffer(), "rb");
29672967
fseek(file, 0, SEEK_END);
29682968
size_t size = ftell(file);
29692969
fseek(file, 0, SEEK_SET);
2970-
std::vector<char> buffer(size+1);
2970+
std::vector<char> buffer(size + 1);
29712971
fread(buffer.data(), 1, size, file);
29722972
buffer[size] = 0;
29732973
fclose(file);
2974-
2974+
29752975
ComPtr<slang::IModule> module;
2976-
module = session->loadModuleFromSourceString("module", "path", buffer.data(), diagnostics.writeRef());
2976+
module = session->loadModuleFromSourceString(
2977+
"module",
2978+
"path",
2979+
buffer.data(),
2980+
diagnostics.writeRef());
29772981
if (!module)
29782982
{
29792983
// Load buffer as an IR blob
29802984
ComPtr<slang::IBlob> blob;
29812985
blob = RawBlob::create(buffer.data(), size);
2982-
2986+
29832987
module = session->loadModuleFromIRBlob(
29842988
"module",
29852989
"path",
29862990
blob,
29872991
diagnostics.writeRef());
29882992
}
2989-
2993+
29902994
if (module)
29912995
{
29922996
ComPtr<slang::IBlob> disassemblyBlob;
@@ -2997,7 +3001,9 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv)
29973001
}
29983002
else
29993003
{
3000-
m_sink->diagnoseRaw(Severity::Note, (const char*)disassemblyBlob->getBufferPointer());
3004+
m_sink->diagnoseRaw(
3005+
Severity::Note,
3006+
(const char*)disassemblyBlob->getBufferPointer());
30013007
}
30023008
}
30033009
else
@@ -3007,11 +3013,11 @@ SlangResult OptionsParser::_parse(int argc, char const* const* argv)
30073013
m_sink->diagnoseRaw(
30083014
Severity::Error,
30093015
(const char*)diagnostics->getBufferPointer());
3010-
}
3016+
}
30113017
return SLANG_FAIL;
30123018
}
3013-
3014-
3019+
3020+
30153021
break;
30163022
}
30173023
default:

0 commit comments

Comments
 (0)