mirror of
https://github.com/Z3Prover/z3
synced 2026-01-19 16:53:18 +00:00
Update code-conventions-analyzer to run daily instead of weekly
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
66207dd7bd
commit
69f9e5ed7a
2 changed files with 46 additions and 15 deletions
59
.github/workflows/code-conventions-analyzer.lock.yml
generated
vendored
59
.github/workflows/code-conventions-analyzer.lock.yml
generated
vendored
|
|
@ -24,8 +24,8 @@
|
|||
name: "Code Conventions Analyzer"
|
||||
"on":
|
||||
schedule:
|
||||
- cron: "4 0 * * 1"
|
||||
# Friendly format: weekly (scattered)
|
||||
- cron: "4 0 * * *"
|
||||
# Friendly format: daily (scattered)
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
|
|
@ -482,6 +482,7 @@ jobs:
|
|||
- Three-way comparison operator (`<=>`)
|
||||
- Ranges library
|
||||
- Coroutines (if beneficial)
|
||||
- `std::format` for string formatting (replace stringstream for exceptions)
|
||||
|
||||
### 3. Common Library Function Usage
|
||||
|
||||
|
|
@ -530,6 +531,23 @@ jobs:
|
|||
- Redundant AST creation calls (rebuilding same expression multiple times)
|
||||
- Opportunities to cache and reuse AST node references
|
||||
- Use of temporaries instead of repeated construction
|
||||
- **Nested API calls with non-deterministic argument evaluation**
|
||||
- Detect expressions where multiple arguments to an API call are themselves API calls
|
||||
- C++ does **not guarantee evaluation order of function arguments**, which can lead to:
|
||||
- Platform-dependent performance differences
|
||||
- Unintended allocation or reference-counting patterns
|
||||
- Hard-to-reproduce profiling results
|
||||
- Prefer storing intermediate results in temporaries to enforce evaluation order and improve clarity
|
||||
- Example:
|
||||
```cpp
|
||||
// Avoid
|
||||
auto* v = m.mk_and(m.mk_or(a, b), m.mk_or(c, d));
|
||||
|
||||
// Prefer
|
||||
auto* o1 = m.mk_or(a, b);
|
||||
auto* o2 = m.mk_or(c, d);
|
||||
auto* v = m.mk_and(o1, o2);
|
||||
```
|
||||
|
||||
**Hash Table Operations:**
|
||||
- Double hash lookups (check existence + insert/retrieve)
|
||||
|
|
@ -551,6 +569,13 @@ jobs:
|
|||
- Replace with `std::optional<T>` return values
|
||||
- Cleaner API that avoids pointer/reference output parameters
|
||||
|
||||
**Exception String Construction:**
|
||||
- Using `stringstream` to build exception messages
|
||||
- Unnecessary string copies when raising exceptions
|
||||
- Replace with `std::format` for cleaner, more efficient code
|
||||
- Constant arguments should be merged into the string
|
||||
- Use `std::formatter` to avoid creating temporary strings
|
||||
|
||||
**Bitfield Opportunities:**
|
||||
- Structs with multiple boolean flags
|
||||
- Small integer fields that could use bitfields
|
||||
|
|
@ -780,10 +805,16 @@ jobs:
|
|||
- **Bitfield Opportunities**: [Structs with bool flags or small integers]
|
||||
- **Estimated Savings**: [Total size reduction across codebase]
|
||||
|
||||
### 4.4 AST Creation Efficiency
|
||||
### 4.4 AST Creation Efficiency and Determinism
|
||||
- **Redundant Creation**: [Examples of rebuilding same expression multiple times]
|
||||
- **Temporary Usage**: [Places where temporaries could be cached]
|
||||
- **Impact**: [Performance improvement potential]
|
||||
PROMPT_EOF
|
||||
- name: Append prompt (part 2)
|
||||
env:
|
||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||
run: |
|
||||
cat << 'PROMPT_EOF' >> "$GH_AW_PROMPT"
|
||||
- **Temporary Usage**: [Places where temporaries could be cached and order of creation determinized]
|
||||
- **Impact**: [Performance improvement potential and determinism across platforms]
|
||||
|
||||
### 4.5 Hash Table Operation Optimization
|
||||
- **Double Lookups**: [Check existence + insert/get patterns]
|
||||
|
|
@ -807,24 +838,24 @@ jobs:
|
|||
- **API Improvements**: [Specific function signatures to update]
|
||||
- **Examples**: [File:line references with before/after]
|
||||
|
||||
PROMPT_EOF
|
||||
- name: Append prompt (part 2)
|
||||
env:
|
||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||
run: |
|
||||
cat << 'PROMPT_EOF' >> "$GH_AW_PROMPT"
|
||||
### 4.9 Array Parameter Modernization
|
||||
### 4.9 Exception String Construction
|
||||
- **Current**: [stringstream usage for building exception messages]
|
||||
- **Modern**: [std::format and std::formater opportunities]
|
||||
- **String Copies**: [Unnecessary copies when raising exceptions]
|
||||
- **Examples**: [Specific exception construction sites]
|
||||
|
||||
### 4.10 Array Parameter Modernization
|
||||
- **Current**: [Pointer + size parameter pairs]
|
||||
- **Modern**: [std::span usage opportunities]
|
||||
- **Type Safety**: [How span improves API safety]
|
||||
- **Examples**: [Function signatures to update]
|
||||
|
||||
### 4.10 Increment Operator Patterns
|
||||
### 4.11 Increment Operator Patterns
|
||||
- **Postfix Usage**: [Count of i++ where result is unused]
|
||||
- **Prefix Preference**: [Places to use ++i instead]
|
||||
- **Iterator Loops**: [Heavy iterator usage areas]
|
||||
|
||||
### 4.11 Exception Control Flow
|
||||
### 4.12 Exception Control Flow
|
||||
- **Current Usage**: [Exceptions used for normal control flow]
|
||||
- **Modern Alternatives**: [std::expected, std::optional, error codes]
|
||||
- **Performance**: [Impact of exception-based control flow]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
description: Analyzes Z3 codebase for consistent coding conventions and opportunities to use modern C++ features
|
||||
on:
|
||||
schedule: weekly
|
||||
schedule: daily
|
||||
workflow_dispatch:
|
||||
permissions: read-all
|
||||
tools:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue