Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings and fixes #603

Merged
merged 11 commits into from
May 29, 2024
93 changes: 84 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

name: ${{ matrix.name }}
runs-on: ${{ matrix.runs-on }}
container: ${{ (matrix.compiler == 'gcc' && 'ubuntu:22.04') || matrix.container }}
container: ${{ matrix.container }}
env: ${{ matrix.env }}
permissions:
contents: write
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
DEBIAN_FRONTEND: 'noninteractive'
TZ: 'Etc/UTC'
with:
apt-get: ${{ matrix.install }} git build-essential python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev
apt-get: ${{ matrix.install }} git build-essential python3 curl openjdk-11-jdk ninja-build pkg-config libncurses-dev libxml2-utils libxml2-dev
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }}
ccflags: ${{ matrix.ccflags }}
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
Expand Down Expand Up @@ -148,6 +148,7 @@ jobs:

- name: Install Libxml2
id: libxml2-install
if: matrix.compiler == 'msvc'
shell: bash
run: |
set -x
Expand Down Expand Up @@ -240,9 +241,9 @@ jobs:
cmake-version: ${{ matrix.compiler == 'clang' && '3.26' || '>=3.26' }}
cxxstd: ${{ matrix.cxxstd }}
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }}
ccflags: ${{ matrix.ccflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
ccflags: ${{ matrix.ccflags }}${{ ( matrix.compiler == 'gcc' && ' -static') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
generator: Ninja
toolchain: ${{ steps.package-install.outputs.vcpkg_toolchain || steps.package-install.outputs.vcpkg-toolchain }}
build-type: ${{ matrix.build-type }}
Expand All @@ -254,8 +255,8 @@ jobs:
-D duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }}
-D Duktape_ROOT=${{ steps.duktape-install.outputs.duktape-root }}
-D fmt_ROOT=${{ steps.fmt-install.outputs.fmt-root }}
-D libxml2_ROOT=${{ steps.libxml2-install.outputs.libxml2-root }}
-D LibXml2_ROOT=${{ steps.libxml2-install.outputs.libxml2-root }}
${{ (steps.libxml2-install.outputs.libxml2-root && format('-D libxml2_ROOT={0}', steps.libxml2-install.outputs.libxml2-root)) || '' }}
${{ (steps.libxml2-install.outputs.libxml2-root && format('-D LibXml2_ROOT={0}', steps.libxml2-install.outputs.libxml2-root)) || '' }}
export-compile-commands: true
run-tests: true
install: true
Expand Down Expand Up @@ -357,7 +358,9 @@ jobs:

name: Demos
timeout-minutes: 120
runs-on: ubuntu-22.04
# We purposefully use an older version of Ubuntu to
# ensure compatibility with the oldest supported version
runs-on: ubuntu-20.04
container: ubuntu:23.04

permissions:
Expand Down Expand Up @@ -431,9 +434,10 @@ jobs:
- name: Upload demo artifacts
uses: actions/upload-artifact@v3
with:
name: demos
name: demos${{ contains(fromJSON('["master", "develop"]'), github.ref_name) || format('-{0}', github.ref_name) || '' }}
path: ${{ env.demos_path }}
retention-days: 1
# develop and master are retained for longer so that they can be compared
retention-days: ${{ contains(fromJSON('["master", "develop"]'), github.ref_name) || '30' || '1' }}

- name: Update website demos
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
Expand All @@ -454,6 +458,77 @@ jobs:
chmod 755 -R $(pwd)/demos
scp -o StrictHostKeyChecking=no -r $(pwd)/demos/* [email protected]:$demo_dir/

- name: Download previous demos
if: startsWith(github.ref, 'refs/tags/')
id: download-prev-demos
uses: actions/download-artifact@v3
with:
name: demos-develop
path: demos-previous

- name: Compare demos
if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true'
id: compare-demos
run: |
set -x

# Define URLs and directories
LOCAL_DEMOS_DIR="./demos/"
PREV_DEMOS_DIR="./demos-previous/"
DIFF_DIR="./demos-diff/"

# Create directories if they don't exist
mkdir -p $PREV_DEMOS_DIR $DIFF_DIR

# Iterate over the previous files and compare them with the corresponding local files
find $PREV_DEMOS_DIR -type f | while read previous_file; do
# Derive the corresponding local file path
local_file="${LOCAL_DEMOS_DIR}${previous_file#$PREV_DEMOS_DIR}"
diff_output="$DIFF_DIR${previous_file#$PREV_DEMOS_DIR}"
if [[ -f $local_file ]]; then
mkdir -p "$(dirname "$diff_output")"
diff "$previous_file" "$local_file" > "$diff_output"
if [[ ! -s $diff_output ]]; then
rm "$diff_output"
fi
else
echo "LOCAL FILE $local_file DOES NOT EXITS." > "$diff_output"
echo "PREVIOUS CONTENT OF THE FILE WAS:" >> "$diff_output"
cat "$previous_file" >> "$diff_output"
fi
done

# Iterate over the local files to find new files
find $LOCAL_DEMOS_DIR -type f | while read local_file; do
previous_file="${PREV_DEMOS_DIR}${local_file#$LOCAL_DEMOS_DIR}"
diff_output="$DIFF_DIR${local_file#$LOCAL_DEMOS_DIR}"
if [[ ! -f $previous_file ]]; then
echo "PREVIOUS $previous_file DOES NOT EXIST." > "$diff_output"
echo "IT HAS BEEN INCLUDED IN THIS VERSION." >> "$diff_output"
echo "NEW CONTENT OF THE FILE IS:" >> "$diff_output"
fi
done

# Check if the diff directory is empty
if [[ -z $(ls -A $DIFF_DIR) ]]; then
echo "No differences found."
# Store this as an output for the next step
echo "diff=false" >> $GITHUB_OUTPUT
else
# Calculate number of files in the diff directory
N_FILES=$(find $DIFF_DIR -type f | wc -l)
echo "Differences found in $N_FILES output files."
echo "diff=true" >> $GITHUB_OUTPUT
fi

- name: Upload diff artifacts
if: startsWith(github.ref, 'refs/tags/') && steps.download-prev-demos.outputs.cache-hit == 'true' && steps.compare-demos.outputs.diff == 'true'
uses: actions/upload-artifact@v3
with:
name: demos-diff
path: demos-diff
retention-days: 30

releases:
needs: build
defaults:
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Windows PowerShell::
--
[source,bash]
----
Invoke-WebRequest -Uri "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" -OutFile "duktape-2.7.0.tar.xz"
Invoke-WebRequest -Uri "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" -OutFile "duktape-2.7.0.tar.xz" <.>
----

<.> Downloads the `duktape` source code.
Expand Down Expand Up @@ -169,9 +169,9 @@ Windows PowerShell::
--
[source,bash]
----
$content = Get-Content -Path "src\duk_config.h"
$content = $content -replace '#define DUK_F_DLL_BUILD', '#undef DUK_F_DLL_BUILD'
$content | Set-Content -Path "src\duk_config.h"
$content = Get-Content -Path "src\duk_config.h" <.>
$content = $content -replace '#define DUK_F_DLL_BUILD', '#undef DUK_F_DLL_BUILD' <.>
$content | Set-Content -Path "src\duk_config.h" <.>
----

<.> Read the content of `duk_config.h`
Expand Down
4 changes: 4 additions & 0 deletions include/mrdocs/Dom/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ class MRDOCS_DECL
class MRDOCS_DECL
LazyObjectImpl : public ObjectImpl
{
#ifdef __cpp_lib_atomic_shared_ptr
std::atomic<std::shared_ptr<ObjectImpl>> mutable sp_;
#else
std::shared_ptr<ObjectImpl> mutable sp_;
#endif

using impl_type = Object::impl_type;

Expand Down
8 changes: 7 additions & 1 deletion src/lib/AST/ParseJavadoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,11 @@ convertCopydoc(unsigned id)
case CommandTraits::KCI_copydetails:
return doc::Parts::description;
default:
{
report::error("error: unsupported CommandTrait id <{}>", id);
MRDOCS_UNREACHABLE();
}
}
}

static
Expand All @@ -640,6 +643,7 @@ convertStyle(InlineCommandRenderKind kind)
return doc::Style::none;
default:
// unknown RenderKind
report::error("error: unsupported InlineCommandRenderKind <{}>", static_cast<int>(kind));
MRDOCS_UNREACHABLE();
}
}
Expand All @@ -657,6 +661,7 @@ convertDirection(ParamCommandPassDirection kind)
case ParamCommandPassDirection::InOut:
return doc::ParamDirection::inout;
default:
report::error("error: unsupported ParamCommandPassDirection <{}>", static_cast<int>(kind));
MRDOCS_UNREACHABLE();
}
}
Expand Down Expand Up @@ -1240,9 +1245,10 @@ visitBlockCommandComment(
case CommandTraits::KCI_copybrief:
case CommandTraits::KCI_copydetails:
case CommandTraits::KCI_copydoc:
report::error("error: inline command {} should be handled elsewhere", cmd->Name);
MRDOCS_UNREACHABLE();

default:
report::error("error: unsupported block command {}", cmd->Name);
MRDOCS_UNREACHABLE();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/Dom/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ ObjectImpl&
LazyObjectImpl::
obj() const
{
#ifdef __cpp_lib_atomic_shared_ptr
auto impl = sp_.load();
if(impl)
return *impl;
Expand All @@ -225,6 +226,9 @@ obj() const
expected, construct().impl()))
return *sp_.load();
return *expected;
#else
return *sp_;
#endif
}

std::size_t
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Gen/adoc/AdocCorpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class DomJavadoc : public dom::LazyObjectImpl
doc::visit(I, visitor);
if(! s.empty())
list.emplace_back(key, std::move(s));
};
}

template<class T>
void
Expand All @@ -435,7 +435,7 @@ class DomJavadoc : public dom::LazyObjectImpl
{
list.emplace_back(key, std::move(s));
}
};
}

template<class T>
void
Expand All @@ -457,7 +457,7 @@ class DomJavadoc : public dom::LazyObjectImpl
return;
list.emplace_back(key, dom::newArray<
dom::DefaultArrayImpl>(std::move(elements)));
};
}

dom::Object
construct() const override
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Gen/html/HTMLCorpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class DomJavadoc : public dom::LazyObjectImpl
doc::visit(I, visitor);
if(! s.empty())
list.emplace_back(key, std::move(s));
};
}

template<class T>
void
Expand All @@ -303,7 +303,7 @@ class DomJavadoc : public dom::LazyObjectImpl
{
list.emplace_back(key, std::move(s));
}
};
}

dom::Object
construct() const override
Expand Down
5 changes: 3 additions & 2 deletions src/lib/Lib/ExecutionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ results()
// Each Bitcode can have multiple Infos
for(auto& bitcode : bitcodes)
{
Expected infos = readBitcode(bitcode);
Expected<std::vector<std::unique_ptr<Info>>> infos =
readBitcode(bitcode);
if (infos.has_value())
{
std::move(
Expand All @@ -179,7 +180,7 @@ results()
report::error("Failed to read bitcode: {}", infos.error());
}
}
Expected merged = mergeInfos(Infos);
Expected<std::unique_ptr<Info>> merged = mergeInfos(Infos);
std::unique_ptr<Info> I = std::move(merged.value());
MRDOCS_ASSERT(I);
MRDOCS_ASSERT(id == I->id);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Lib/SingleFileDB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SingleFileDB
getCompileCommands(
llvm::StringRef FilePath) const override
{
if(! FilePath.equals(cc_.front().Filename))
if (FilePath != cc_.front().Filename)
return {};
return { cc_.front() };
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Metadata/Finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,17 @@ class Finalizer

if constexpr(std::derived_from<NodeTy, doc::Reference>)
{
#if 0
// This warning shouldn't be triggered if the symbol has
// been explicitly marked excluded in mrdocs.yml
if(! resolveReference(N))
{
report::warn("Failed to resolve reference to '{}' from '{}'",
N.string, current_->Name);
}
#else
resolveReference(N);
#endif
}
});
}
Expand Down
11 changes: 10 additions & 1 deletion src/tool/ToolMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ print_version(llvm::raw_ostream& os)
os << project_name
<< "\n " << project_description
<< "\n version: " << project_version
<< "\n built with LLVM " << LLVM_VERSION_STRING;
<< "\n built with LLVM " << LLVM_VERSION_STRING
<< "\n";
}

int
Expand All @@ -60,7 +61,15 @@ mrdocs_main(int argc, char const** argv)
toolArgs.reportLevel.getValue()));

// Set up addons directory
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
// error: ISO C++ forbids taking address of function ‘::main’
#endif
void* addressOfMain = reinterpret_cast<void*>(&main);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
auto exp = setupAddonsDir(
toolArgs.addonsDir,argv[0], addressOfMain);
if (!exp)
Expand Down
Loading