Skip to content

Commit 178643a

Browse files
Force CodeQL to use gcc-14 defaults
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
1 parent d30b73a commit 178643a

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎.github/workflows/codeql.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,19 @@ jobs:
3939
run: |
4040
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 140
4141
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 140
42+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 140
43+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 140
4244
sudo update-alternatives --set gcc /usr/bin/gcc-14
4345
sudo update-alternatives --set g++ /usr/bin/g++-14
44-
cc --version | head -n1
46+
sudo update-alternatives --set cc /usr/bin/gcc-14
47+
sudo update-alternatives --set c++ /usr/bin/g++-14
48+
which gcc
49+
which g++
50+
which cc
51+
which c++
4552
gcc --version | head -n1
4653
g++ --version | head -n1
54+
cc --version | head -n1
4755
c++ --version | head -n1
4856
4957
- name: Initialize CodeQL
@@ -54,10 +62,10 @@ jobs:
5462

5563
- name: Build
5664
env:
57-
CC: gcc-14
58-
CXX: g++-14
65+
CC: cc
66+
CXX: c++
5967
run: |
60-
cmake -B _build -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14
68+
cmake -B _build -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
6169
cmake --build _build --parallel $(nproc)
6270
6371
- name: Perform CodeQL Analysis

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The technical progression and current state of the NLAP implementation comprise
6363
5. **C++23 Parsing Library:** Engineered a specialized, performance- and heap-optimized C++23 validation library for low-level HTTP/1.1 parsing and message generation.
6464
6. **Architectural Refactoring:** Executed a comprehensive code-base refactoring based on the empirical performance metrics gathered from the initial reference implementations.
6565
7. **Schema Implementation:** Developed the comprehensive structural boundaries for all NLAP protocol subtypes, formalized through complete Document Type Definitions (DTD) and YANG modeling layouts compiled with AI assistance.
66-
8. **Zero-Copy XML Parsing Engine:** Implemented a memory-optimized XML parsing layer utilizing non-allocating string views (`std::string_view`) and lightweight iteration helpers to minimize data-handling overhead, developed with AI assistance.
66+
8. **Zero-Copy XML Parsing Engine:** Implemented a memory-optimized XML parsing layer utilizing C++23 features (`std::generator`) and non-allocating string views (`std::string_view`) to minimize data-handling overhead, developed with AI assistance.
6767

6868
# 5. Working Components
6969

‎lib/xml/xmlparser.cpp‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <algorithm>
77
#include <atomic>
8+
#include <generator>
89
#include <cstring>
910
#include <memory>
1011
#include <utility>
@@ -68,14 +69,13 @@ std::string getElementText(DOMElement* Element)
6869
return trimCopy(Value);
6970
}
7071

71-
template <typename Callback>
72-
void forEachElementChild(DOMElement* Parent, Callback&& Visitor)
72+
std::generator<DOMElement*> iterateElementChildren(DOMElement* Parent)
7373
{
7474
DOMNodeList* Children = Parent->getChildNodes();
7575
for (XMLSize_t Index = 0; Index < Children->getLength(); ++Index) {
7676
DOMNode* Child = Children->item(Index);
7777
if (Child->getNodeType() == DOMNode::ELEMENT_NODE) {
78-
Visitor(static_cast<DOMElement*>(Child));
78+
co_yield static_cast<DOMElement*>(Child);
7979
}
8080
}
8181
}
@@ -85,8 +85,7 @@ struct MessageSlice
8585
std::string_view Slice;
8686
};
8787

88-
template <typename Callback>
89-
void splitMessages(std::string_view Input, bool& FramingError, Callback&& Visitor)
88+
std::generator<MessageSlice> splitMessages(std::string_view Input, bool& FramingError)
9089
{
9190
std::size_t Cursor = 0;
9291
std::size_t LastEnd = std::string_view::npos;
@@ -99,7 +98,7 @@ void splitMessages(std::string_view Input, bool& FramingError, Callback&& Visito
9998

10099
if (LastEnd != std::string_view::npos && Start != LastEnd) {
101100
FramingError = true;
102-
return;
101+
co_return;
103102
}
104103

105104
const std::size_t End = Input.find(NLAP_XML_END_MARKER, Start);
@@ -108,9 +107,7 @@ void splitMessages(std::string_view Input, bool& FramingError, Callback&& Visito
108107
}
109108

110109
const std::size_t MessageEnd = End + NLAP_XML_END_MARKER.size();
111-
if (!Visitor(MessageSlice{Input.substr(Start, MessageEnd - Start)})) {
112-
return;
113-
}
110+
co_yield MessageSlice{Input.substr(Start, MessageEnd - Start)};
114111

115112
Cursor = MessageEnd;
116113
LastEnd = MessageEnd;
@@ -200,12 +197,12 @@ void populateTree(DOMElement* Element, XMLNode& Node, std::string_view RawMessag
200197
{
201198
bool HasElementChildren = false;
202199

203-
forEachElementChild(Element, [&](DOMElement* Child) {
200+
for (DOMElement* Child : iterateElementChildren(Element)) {
204201
HasElementChildren = true;
205202
const std::string ChildName = transcodeXMLCh(Child->getTagName());
206203
XMLNode& ChildNode = Node[ChildName];
207204
populateTree(Child, ChildNode, RawMessage, SearchOffset);
208-
});
205+
}
209206

210207
if (HasElementChildren) {
211208
return;
@@ -300,11 +297,11 @@ uint16_t parseMessage(
300297
XMLNode& RootNode = OutputTree[RootName];
301298

302299
std::size_t SearchOffset = 0;
303-
forEachElementChild(Root, [&](DOMElement* Child) {
300+
for (DOMElement* Child : iterateElementChildren(Root)) {
304301
const std::string ChildName = transcodeXMLCh(Child->getTagName());
305302
XMLNode& ChildNode = RootNode[ChildName];
306303
populateTree(Child, ChildNode, RawMessage, SearchOffset);
307-
});
304+
}
308305

309306
return 0;
310307
}
@@ -375,22 +372,17 @@ ParseResult_t XMLParser::parse(char* InputBuffer) const
375372
}
376373

377374
bool FramingError = false;
378-
splitMessages(InputBufferSV, FramingError, [&](const MessageSlice& Slice) {
375+
for (const MessageSlice& Slice : splitMessages(InputBufferSV, FramingError)) {
379376
ResultTree_t Tree;
380377
const uint16_t MessageError = parseMessage(_GrammarPool, Slice.Slice, Tree);
381378

382379
if (MessageError != 0) {
383380
Result.ErrorCode = MessageError;
384381
Result.Results.clear();
385-
return false;
382+
return Result;
386383
}
387384

388385
Result.Results.push_back(std::move(Tree));
389-
return true;
390-
});
391-
392-
if (Result.ErrorCode != 0) {
393-
return Result;
394386
}
395387

396388
if (FramingError) {

0 commit comments

Comments
 (0)