Skip to content

Commit

Permalink
Implement CI to check for STL misuse (#1358)
Browse files Browse the repository at this point in the history
Compiles and runs NMODL with glibc debug macros enabled to check the inputs to STL algorithms etc.
  • Loading branch information
matz-e authored Jul 19, 2024
1 parent 4f47074 commit 38f90ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/nmodl-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
os: ubuntu-20.04
- config:
flag_warnings: ON
glibc_asserts: ON
os: ubuntu-22.04
- config:
os: macos-12
Expand Down Expand Up @@ -113,7 +114,6 @@ jobs:
working-directory: ${{runner.workspace}}/nmodl
run: |
echo "------- Configure -------"
mkdir build && pushd build
cmake_args=(-G Ninja
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR)
Expand All @@ -134,11 +134,15 @@ jobs:
CXX=$(command -v clang++-14)
else
CXX=${CXX:-g++}
if [[ -n "${{matrix.config.glibc_asserts}}" ]]; then
cmake_args+=(-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS=-D_GLIBCXX_DEBUG)
fi
fi
cmake_args+=(-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
cmake_args+=(-DNMODL_ENABLE_BACKWARD=On)
cmake .. "${cmake_args[@]}"
cmake -B build -S . "${cmake_args[@]}"
env:
INSTALL_DIR: ${{ runner.workspace }}/install

Expand All @@ -164,7 +168,7 @@ jobs:

- name: Build
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
working-directory: ${{runner.workspace}}/nmodl
env:
CCACHE_BASEDIR: ${{runner.workspace}}/nmodl
CCACHE_DIR: ${{runner.workspace}}/ccache
Expand All @@ -180,7 +184,7 @@ jobs:
ccache -z
# Older versions don't support -v (verbose)
ccache -vs 2>/dev/null || ccache -s
cmake --build .
cmake --build build
ccache -vs 2>/dev/null || ccache -s
- name: Test
shell: bash
Expand All @@ -191,9 +195,9 @@ jobs:
ctest --output-on-failure -T Test
- name: Install
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
working-directory: ${{runner.workspace}}/nmodl
run: |
cmake --build . --target install
cmake --install build
- name: Update references
if: matrix.config.update_references == 'On'
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ stages:
submodules: True
- script: |
brew install flex bison cmake python@3
python3 -m pip install --upgrade pip setuptools
python3 -m pip install --upgrade pip "setuptools<=70.3.0"
python3 -m pip install --user -r requirements.txt
displayName: 'Install Dependencies'
- script: |
Expand Down
4 changes: 2 additions & 2 deletions src/visitors/semantic_analysis_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ bool SemanticAnalysisVisitor::check_table_vars(const ast::Program& node) {
bool SemanticAnalysisVisitor::check_name_conflict(const ast::Program& node) {
// check that there are no RANGE variables which have the same name as a FUNCTION or PROCEDURE
const auto& range_nodes = collect_nodes(node, {ast::AstNodeType::RANGE_VAR});
std::unordered_set<std::string> range_vars{};
std::set<std::string> range_vars{};
for (const auto& range_node: range_nodes) {
range_vars.insert(range_node->get_node_name());
}

const auto& function_nodes =
collect_nodes(node, {ast::AstNodeType::FUNCTION_BLOCK, ast::AstNodeType::PROCEDURE_BLOCK});
std::unordered_set<std::string> func_vars{};
std::set<std::string> func_vars{};
for (const auto& function_node: function_nodes) {
func_vars.insert(function_node->get_node_name());
}
Expand Down

0 comments on commit 38f90ff

Please sign in to comment.