From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- source/compiler-core/slang-downstream-compiler.cpp | 99 ++++++++++++---------- 1 file changed, 56 insertions(+), 43 deletions(-) (limited to 'source/compiler-core/slang-downstream-compiler.cpp') diff --git a/source/compiler-core/slang-downstream-compiler.cpp b/source/compiler-core/slang-downstream-compiler.cpp index 855319176..190400f55 100644 --- a/source/compiler-core/slang-downstream-compiler.cpp +++ b/source/compiler-core/slang-downstream-compiler.cpp @@ -1,37 +1,36 @@ // slang-downstream-compiler.cpp #include "slang-downstream-compiler.h" +#include "../core/slang-blob.h" +#include "../core/slang-castable.h" +#include "../core/slang-char-util.h" #include "../core/slang-common.h" -#include "slang-com-helper.h" -#include "../core/slang-string-util.h" - -#include "../core/slang-type-text-util.h" - #include "../core/slang-io.h" #include "../core/slang-shared-library.h" -#include "../core/slang-blob.h" -#include "../core/slang-char-util.h" - -#include "../core/slang-castable.h" - +#include "../core/slang-string-util.h" +#include "../core/slang-type-text-util.h" +#include "slang-artifact-associated-impl.h" +#include "slang-artifact-desc-util.h" +#include "slang-artifact-helper.h" #include "slang-artifact-impl.h" #include "slang-artifact-representation-impl.h" -#include "slang-artifact-associated-impl.h" #include "slang-artifact-util.h" -#include "slang-artifact-helper.h" -#include "slang-artifact-desc-util.h" +#include "slang-com-helper.h" namespace Slang { /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DownstreamCompilerBase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ -SlangResult DownstreamCompilerBase::convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) +SlangResult DownstreamCompilerBase::convert( + IArtifact* from, + const ArtifactDesc& to, + IArtifact** outArtifact) { SLANG_UNUSED(from); SLANG_UNUSED(to); SLANG_UNUSED(outArtifact); - + return SLANG_E_NOT_AVAILABLE; } @@ -46,8 +45,7 @@ void* DownstreamCompilerBase::castAs(const Guid& guid) void* DownstreamCompilerBase::getInterface(const Guid& guid) { - if (guid == ISlangUnknown::getTypeGuid() || - guid == ICastable::getTypeGuid() || + if (guid == ISlangUnknown::getTypeGuid() || guid == ICastable::getTypeGuid() || guid == IDownstreamCompiler::getTypeGuid()) { return static_cast(this); @@ -64,7 +62,9 @@ void* DownstreamCompilerBase::getObject(const Guid& guid) /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CommandLineDownstreamCompiler !!!!!!!!!!!!!!!!!!!!!!*/ -SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptions, IArtifact** outArtifact) +SlangResult CommandLineDownstreamCompiler::compile( + const CompileOptions& inOptions, + IArtifact** outArtifact) { if (!isVersionCompatible(inOptions)) { @@ -77,11 +77,11 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // Copy the command line options CommandLine cmdLine(m_cmdLine); - // Work out the ArtifactDesc + // Work out the ArtifactDesc const auto targetDesc = ArtifactDescUtil::makeDescForCompileTarget(options.targetType); auto helper = DefaultArtifactHelper::getSingleton(); - + List> artifactList; // It may be necessary to produce a temporary file 'lock file'. @@ -93,11 +93,13 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // If no module path is set we will need to generate one if (options.modulePath.count == 0) { - // We could use the path to the source, or use the source name/paths as defined on the artifact - // For now we just go with a lock file based on "slang-generated". - SLANG_RETURN_ON_FAIL(helper->createLockFile(asCharSlice(toSlice("slang-generated")), lockFile.writeRef())); + // We could use the path to the source, or use the source name/paths as defined on the + // artifact For now we just go with a lock file based on "slang-generated". + SLANG_RETURN_ON_FAIL( + helper->createLockFile(asCharSlice(toSlice("slang-generated")), lockFile.writeRef())); - auto lockArtifact = Artifact::create(ArtifactDesc::make(ArtifactKind::Base, ArtifactPayload::Lock, ArtifactStyle::None)); + auto lockArtifact = Artifact::create( + ArtifactDesc::make(ArtifactKind::Base, ArtifactPayload::Lock, ArtifactStyle::None)); lockArtifact->addRepresentation(lockFile); artifactList.add(lockArtifact); @@ -108,14 +110,17 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio options.modulePath = SliceUtil::asTerminatedCharSlice(modulePath); } - // Append command line args to the end of cmdLine using the target specific function for the specified options + // Append command line args to the end of cmdLine using the target specific function for the + // specified options SLANG_RETURN_ON_FAIL(calcArgs(options, cmdLine)); - // The 'productArtifact' is the main product produced from the compilation - the executable/sharedlibrary/object etc + // The 'productArtifact' is the main product produced from the compilation - the + // executable/sharedlibrary/object etc ComPtr productArtifact; { List> artifacts; - SLANG_RETURN_ON_FAIL(calcCompileProducts(options, DownstreamProductFlag::All, lockFile, artifacts)); + SLANG_RETURN_ON_FAIL( + calcCompileProducts(options, DownstreamProductFlag::All, lockFile, artifacts)); for (IArtifact* artifact : artifacts) { @@ -129,7 +134,7 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio artifactList.add(ComPtr(artifact)); } } - + SLANG_ASSERT(productArtifact); // Somethings gone wrong if we don't find the main artifact if (!productArtifact) @@ -155,21 +160,22 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio } #endif - // Go through the list of artifacts in the artifactList and check if they exist. - // - // This is useful because `calcCompileProducts` is conservative and may produce artifacts for products that aren't actually - // produced, by the compilation. + // Go through the list of artifacts in the artifactList and check if they exist. + // + // This is useful because `calcCompileProducts` is conservative and may produce artifacts for + // products that aren't actually produced, by the compilation. { - + Count count = artifactList.getCount(); for (Index i = 0; i < count; ++i) { IArtifact* artifact = artifactList[i]; - + if (!artifact->exists()) { // We should find a file rep and if we do we can disown it. Disowning will mean - // when scope is lost the rep won't try and delete the (apparently non existing) backing file. + // when scope is lost the rep won't try and delete the (apparently non existing) + // backing file. if (auto fileRep = findRepresentation(artifact)) { fileRep->disown(); @@ -189,7 +195,8 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio } } - // Add all of the source artifacts, that are temporary on the file system, such that they can stay in scope for debugging + // Add all of the source artifacts, that are temporary on the file system, such that they can + // stay in scope for debugging for (auto sourceArtifact : options.sourceArtifacts) { if (auto fileRep = findRepresentation(sourceArtifact)) @@ -205,16 +212,18 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // Create the result artifact auto artifact = ArtifactUtil::createArtifact(targetDesc); - // Createa the diagnostics + // Createa the diagnostics auto diagnostics = ArtifactDiagnostics::create(); SLANG_RETURN_ON_FAIL(parseOutput(exeRes, diagnostics)); ArtifactUtil::addAssociated(artifact, diagnostics); - // Find the rep from the 'main' artifact, we'll just use the same representation on the output + // Find the rep from the 'main' artifact, we'll just use the same representation on the output // artifact. Sharing is desirable, because the rep owns the file. - if (auto fileRep = productArtifact ? findRepresentation(productArtifact) : nullptr) + if (auto fileRep = productArtifact + ? findRepresentation(productArtifact) + : nullptr) { artifact->addRepresentation(fileRep); } @@ -222,13 +231,17 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio // Add the artifact list if there is anything in it if (artifactList.getCount()) { - // Holds all of the artifacts that are relatated to the final artifact - such as debug files, ancillary file and lock files - auto artifactContainer = ArtifactUtil::createArtifact(ArtifactDesc::make(ArtifactKind::Container, ArtifactPayload::Unknown, ArtifactStyle::Unknown)); + // Holds all of the artifacts that are relatated to the final artifact - such as debug + // files, ancillary file and lock files + auto artifactContainer = ArtifactUtil::createArtifact(ArtifactDesc::make( + ArtifactKind::Container, + ArtifactPayload::Unknown, + ArtifactStyle::Unknown)); auto slice = SliceUtil::asSlice(artifactList); artifactContainer->setChildren(slice.data, slice.count); - + artifact->addAssociated(artifactContainer); } @@ -236,4 +249,4 @@ SlangResult CommandLineDownstreamCompiler::compile(const CompileOptions& inOptio return SLANG_OK; } -} +} // namespace Slang -- cgit v1.2.3