Skip to content

Commit 7ae53a5

Browse files
jumormtTalbenXu
andauthored
use ubuntu latest (#1615)
* use ubuntu latest * Remove regex in CFGNormalizer * Remove regex header * use gcc build * merge reg change * correct wrong space --------- Co-authored-by: TalbenXu <[email protected]>
1 parent 21f5718 commit 7ae53a5

File tree

8 files changed

+150
-71
lines changed

8 files changed

+150
-71
lines changed

.github/workflows/docker_publish_x86.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
docker-x86-image:
99
if: github.repository == 'SVF-tools/SVF'
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Checkout
@@ -31,7 +31,7 @@ jobs:
3131

3232
dispatch:
3333
needs: docker-x86-image
34-
runs-on: ubuntu-22.04
34+
runs-on: ubuntu-latest
3535
strategy:
3636
matrix:
3737
repo: ['SVF-tools/Software-Security-Analysis', 'SVF-tools/Teaching-Software-Analysis', 'SVF-tools/Teaching-Software-Verification', 'SVF-tools/SVF-example']

.github/workflows/github-action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
XCODE_VERSION: '15.3.0'
1717
strategy:
1818
matrix:
19-
os: [ubuntu-22.04, macos-latest]
19+
os: [ubuntu-latest, macos-latest]
2020
include:
21-
- os: [ubuntu-22.04]
21+
- os: [ubuntu-latest]
2222
sanitizer: address
2323
steps:
2424
# checkout the repo
@@ -132,7 +132,7 @@ jobs:
132132
lcov --remove coverage.info '/usr/*' --output-file coverage.info
133133
lcov --remove coverage.info '${{github.workspace}}/z3.obj/*' --output-file coverage.info
134134
lcov --remove coverage.info '${{github.workspace}}/llvm-*.obj/*' --output-file coverage.info
135-
lcov --remove coverage.info '${{github.workspace}}/svf/include/FastCluster/*' --output-file coverage.info
135+
lcov --remove coverage.info '${{github.workspace}}/svf/include/FastCluster/*' --output-file coverage.info --ignore-errors unused
136136
lcov --remove coverage.info '${{github.workspace}}/svf/lib/FastCluster/*' --output-file coverage.info
137137
138138
- name: upload-coverage

.github/workflows/svf-lib_publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
XCODE_VERSION: '15.3.0' # Define Xcode version here to reuse it
2020
strategy:
2121
matrix:
22-
os: [ubuntu-22.04, macos-latest]
22+
os: [ubuntu-latest, macos-latest]
2323
steps:
2424
# checkout the repo
2525
- uses: actions/checkout@v2

build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ BUILD_DIR="./${BUILD_TYPE}-build"
250250
rm -rf "${BUILD_DIR}"
251251
mkdir "${BUILD_DIR}"
252252
# If you need shared libs, turn BUILD_SHARED_LIBS on
253-
cmake -D CMAKE_BUILD_TYPE:STRING="${BUILD_TYPE}" \
254-
-DSVF_ENABLE_ASSERTIONS:BOOL=true \
255-
-DSVF_SANITIZE="${SVF_SANITIZER}" \
256-
-DBUILD_SHARED_LIBS=off \
253+
cmake -D CMAKE_BUILD_TYPE:STRING="${BUILD_TYPE}" \
254+
-DSVF_ENABLE_ASSERTIONS:BOOL=true \
255+
-DSVF_SANITIZE="${SVF_SANITIZER}" \
256+
-DBUILD_SHARED_LIBS=off \
257257
-S "${SVFHOME}" -B "${BUILD_DIR}"
258258
cmake --build "${BUILD_DIR}" -j ${jobs}
259259

svf/include/Graphs/CFLGraph.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <fstream>
3434
#include <iostream>
3535
#include <string>
36-
#include <regex>
3736
#include "CFL/CFGrammar.h"
3837
#include "Graphs/GenericGraph.h"
3938
#include "Graphs/ConsG.h"
@@ -50,7 +49,7 @@ class CFLEdge: public GenericCFLEdgeTy
5049
typedef GenericNode<CFLNode, CFLEdge>::GEdgeSetTy CFLEdgeSetTy;
5150

5251
CFLEdge(CFLNode *s, CFLNode *d, GEdgeFlag k = 0):
53-
GenericCFLEdgeTy(s,d,k)
52+
GenericCFLEdgeTy(s,d,k)
5453
{
5554
}
5655
~CFLEdge() override = default;
@@ -77,7 +76,7 @@ class CFLNode: public GenericCFLNodeTy
7776
{
7877
public:
7978
CFLNode (NodeID i = 0, GNodeK k = CFLNodeKd):
80-
GenericCFLNodeTy(i, k)
79+
GenericCFLNodeTy(i, k)
8180
{
8281
}
8382

svf/lib/CFL/CFGNormalizer.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "Util/WorkList.h"
3333
#include "SVFIR/SVFValue.h"
3434
#include <string>
35-
#include <regex>
3635
#include <fstream>
3736
#include <sstream>
3837
#include <iostream>
@@ -437,13 +436,20 @@ void CFGNormalizer::ebnfSignReplace(char sign, CFGrammar *grammar)
437436

438437
void CFGNormalizer::strTrans(std::string LHS, CFGrammar *grammar, GrammarBase::Production& normalProd)
439438
{
440-
std::smatch matches;
441-
std::regex LHSReg("\\s*(.*)");
439+
// Find the position of the first non-whitespace character
440+
size_t start = LHS.find_first_not_of(" \t\n\r");
441+
// If the string contains non-whitespace characters, remove leading spaces
442+
if (start != std::string::npos) {
443+
LHS = LHS.substr(start);
444+
} else {
445+
// If the string contains only spaces, clear it
446+
LHS.clear();
447+
}
448+
442449
std::string delimiter;
443450
size_t pos;
444451
std::string word;
445-
std::regex_search(LHS, matches, LHSReg);
446-
LHS = matches.str(1);
452+
447453
delimiter = " ";
448454
while ((pos = LHS.find(delimiter)) != std::string::npos)
449455
{
@@ -454,6 +460,7 @@ void CFGNormalizer::strTrans(std::string LHS, CFGrammar *grammar, GrammarBase::P
454460
normalProd.push_back(grammar->strToSymbol(LHS));
455461
}
456462

463+
457464
GrammarBase::Symbol CFGNormalizer::check_head(GrammarBase::SymbolMap<GrammarBase::Symbol, GrammarBase::Productions> &grammar, GrammarBase::Production &rule)
458465
{
459466
for(auto symProdPair: grammar)

svf/lib/CFL/CFLGraphBuilder.cpp

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -193,49 +193,79 @@ CFLGraph* CFLGraphBuilder::buildFromText(std::string fileName, GrammarBase *gram
193193
return cflGraph;
194194
}
195195

196-
CFLGraph * CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)
196+
CFLGraph *CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)
197197
{
198198
buildlabelToKindMap(grammar);
199199
cflGraph = new CFLGraph(grammar->getStartKind());
200200
std::string lineString;
201201
std::ifstream inputFile(fileName);
202202
std::cout << "Building CFL Graph from dot file: " << fileName << "..\n";
203-
std::regex reg("Node(\\w+)\\s*->\\s*Node(\\w+)\\s*\\[.*label=(.*)\\]");
204203
std::cout << std::boolalpha;
205-
u32_t lineNum = 0 ;
204+
205+
u32_t lineNum = 0;
206206
current = labelToKindMap.size();
207207

208208
while (getline(inputFile, lineString))
209209
{
210210
lineNum += 1;
211-
std::smatch matches;
212-
if (std::regex_search(lineString, matches, reg))
211+
212+
// Find "Node" prefixes and "->"
213+
size_t srcStart = lineString.find("Node");
214+
if (srcStart == std::string::npos) continue;
215+
216+
size_t srcEnd = lineString.find(" ", srcStart);
217+
if (srcEnd == std::string::npos) continue;
218+
219+
size_t arrowPos = lineString.find("->", srcEnd);
220+
if (arrowPos == std::string::npos) continue;
221+
222+
size_t dstStart = lineString.find("Node", arrowPos);
223+
if (dstStart == std::string::npos) continue;
224+
225+
size_t dstEnd = lineString.find(" ", dstStart);
226+
if (dstEnd == std::string::npos) continue;
227+
228+
size_t labelStart = lineString.find("label=", dstEnd);
229+
if (labelStart == std::string::npos) continue;
230+
231+
labelStart += 6; // Move past "label=" to the start of the label
232+
size_t labelEnd = lineString.find_first_of("]", labelStart);
233+
if (labelEnd == std::string::npos) continue;
234+
235+
// Extract the source ID, destination ID, and label
236+
std::string srcIDStr = lineString.substr(srcStart + 4, srcEnd - (srcStart + 4));
237+
std::string dstIDStr = lineString.substr(dstStart + 4, dstEnd - (dstStart + 4));
238+
std::string label = lineString.substr(labelStart, labelEnd - labelStart);
239+
240+
// Convert source and destination IDs from hexadecimal
241+
u32_t srcID = std::stoul(srcIDStr, nullptr, 16);
242+
u32_t dstID = std::stoul(dstIDStr, nullptr, 16);
243+
244+
CFLNode *src = addGNode(srcID);
245+
CFLNode *dst = addGNode(dstID);
246+
247+
if (labelToKindMap.find(label) != labelToKindMap.end())
248+
{
249+
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
250+
}
251+
else
213252
{
214-
u32_t srcID = std::stoul(matches.str(1), nullptr, 16);
215-
u32_t dstID = std::stoul(matches.str(2), nullptr, 16);
216-
std::string label = matches.str(3);
217-
CFLNode *src = addGNode(srcID);
218-
CFLNode *dst = addGNode(dstID);
219-
if (labelToKindMap.find(label) != labelToKindMap.end())
253+
if (Options::FlexSymMap() == true)
254+
{
255+
labelToKindMap.insert({label, current++});
220256
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
257+
}
221258
else
222259
{
223-
if(Options::FlexSymMap() == true)
224-
{
225-
labelToKindMap.insert({label, current++});
226-
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
227-
}
228-
else
229-
{
230-
std::string msg = "In line " + std::to_string(lineNum) +
231-
" sym can not find in grammar, please correct the input dot or set --flexsymmap.";
232-
SVFUtil::errMsg(msg);
233-
std::cout << msg;
234-
abort();
235-
}
260+
std::string msg = "In line " + std::to_string(lineNum) +
261+
" sym cannot be found in grammar. Please correct the input dot or set --flexsymmap.";
262+
SVFUtil::errMsg(msg);
263+
std::cout << msg;
264+
abort();
236265
}
237266
}
238267
}
268+
239269
inputFile.close();
240270
return cflGraph;
241271
}
@@ -247,7 +277,6 @@ CFLGraph* CFLGraphBuilder::buildFromJson(std::string fileName, GrammarBase *gram
247277
return cflGraph;
248278
}
249279

250-
251280
CFLGraph* AliasCFLGraphBuilder::buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar)
252281
{
253282
cflGraph = new CFLGraph(startKind);
@@ -543,4 +572,4 @@ CFLGraph* VFCFLGraphBuilder::buildBiPEGgraph(ConstraintGraph *graph, Kind startK
543572
}
544573

545574

546-
} // end of SVF namespace
575+
} // end of SVF namespace

0 commit comments

Comments
 (0)