Skip to content

Commit

Permalink
use ubuntu latest (#1615)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jumormt and TalbenXu authored Dec 21, 2024
1 parent 21f5718 commit 7ae53a5
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker_publish_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
docker-x86-image:
if: github.repository == 'SVF-tools/SVF'
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -31,7 +31,7 @@ jobs:

dispatch:
needs: docker-x86-image
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
repo: ['SVF-tools/Software-Security-Analysis', 'SVF-tools/Teaching-Software-Analysis', 'SVF-tools/Teaching-Software-Verification', 'SVF-tools/SVF-example']
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
XCODE_VERSION: '15.3.0'
strategy:
matrix:
os: [ubuntu-22.04, macos-latest]
os: [ubuntu-latest, macos-latest]
include:
- os: [ubuntu-22.04]
- os: [ubuntu-latest]
sanitizer: address
steps:
# checkout the repo
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --remove coverage.info '${{github.workspace}}/z3.obj/*' --output-file coverage.info
lcov --remove coverage.info '${{github.workspace}}/llvm-*.obj/*' --output-file coverage.info
lcov --remove coverage.info '${{github.workspace}}/svf/include/FastCluster/*' --output-file coverage.info
lcov --remove coverage.info '${{github.workspace}}/svf/include/FastCluster/*' --output-file coverage.info --ignore-errors unused
lcov --remove coverage.info '${{github.workspace}}/svf/lib/FastCluster/*' --output-file coverage.info
- name: upload-coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/svf-lib_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
XCODE_VERSION: '15.3.0' # Define Xcode version here to reuse it
strategy:
matrix:
os: [ubuntu-22.04, macos-latest]
os: [ubuntu-latest, macos-latest]
steps:
# checkout the repo
- uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ BUILD_DIR="./${BUILD_TYPE}-build"
rm -rf "${BUILD_DIR}"
mkdir "${BUILD_DIR}"
# If you need shared libs, turn BUILD_SHARED_LIBS on
cmake -D CMAKE_BUILD_TYPE:STRING="${BUILD_TYPE}" \
-DSVF_ENABLE_ASSERTIONS:BOOL=true \
-DSVF_SANITIZE="${SVF_SANITIZER}" \
-DBUILD_SHARED_LIBS=off \
cmake -D CMAKE_BUILD_TYPE:STRING="${BUILD_TYPE}" \
-DSVF_ENABLE_ASSERTIONS:BOOL=true \
-DSVF_SANITIZE="${SVF_SANITIZER}" \
-DBUILD_SHARED_LIBS=off \
-S "${SVFHOME}" -B "${BUILD_DIR}"
cmake --build "${BUILD_DIR}" -j ${jobs}

Expand Down
5 changes: 2 additions & 3 deletions svf/include/Graphs/CFLGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <fstream>
#include <iostream>
#include <string>
#include <regex>
#include "CFL/CFGrammar.h"
#include "Graphs/GenericGraph.h"
#include "Graphs/ConsG.h"
Expand All @@ -50,7 +49,7 @@ class CFLEdge: public GenericCFLEdgeTy
typedef GenericNode<CFLNode, CFLEdge>::GEdgeSetTy CFLEdgeSetTy;

CFLEdge(CFLNode *s, CFLNode *d, GEdgeFlag k = 0):
GenericCFLEdgeTy(s,d,k)
GenericCFLEdgeTy(s,d,k)
{
}
~CFLEdge() override = default;
Expand All @@ -77,7 +76,7 @@ class CFLNode: public GenericCFLNodeTy
{
public:
CFLNode (NodeID i = 0, GNodeK k = CFLNodeKd):
GenericCFLNodeTy(i, k)
GenericCFLNodeTy(i, k)
{
}

Expand Down
17 changes: 12 additions & 5 deletions svf/lib/CFL/CFGNormalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "Util/WorkList.h"
#include "SVFIR/SVFValue.h"
#include <string>
#include <regex>
#include <fstream>
#include <sstream>
#include <iostream>
Expand Down Expand Up @@ -437,13 +436,20 @@ void CFGNormalizer::ebnfSignReplace(char sign, CFGrammar *grammar)

void CFGNormalizer::strTrans(std::string LHS, CFGrammar *grammar, GrammarBase::Production& normalProd)
{
std::smatch matches;
std::regex LHSReg("\\s*(.*)");
// Find the position of the first non-whitespace character
size_t start = LHS.find_first_not_of(" \t\n\r");
// If the string contains non-whitespace characters, remove leading spaces
if (start != std::string::npos) {
LHS = LHS.substr(start);
} else {
// If the string contains only spaces, clear it
LHS.clear();
}

std::string delimiter;
size_t pos;
std::string word;
std::regex_search(LHS, matches, LHSReg);
LHS = matches.str(1);

delimiter = " ";
while ((pos = LHS.find(delimiter)) != std::string::npos)
{
Expand All @@ -454,6 +460,7 @@ void CFGNormalizer::strTrans(std::string LHS, CFGrammar *grammar, GrammarBase::P
normalProd.push_back(grammar->strToSymbol(LHS));
}


GrammarBase::Symbol CFGNormalizer::check_head(GrammarBase::SymbolMap<GrammarBase::Symbol, GrammarBase::Productions> &grammar, GrammarBase::Production &rule)
{
for(auto symProdPair: grammar)
Expand Down
81 changes: 55 additions & 26 deletions svf/lib/CFL/CFLGraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,49 +193,79 @@ CFLGraph* CFLGraphBuilder::buildFromText(std::string fileName, GrammarBase *gram
return cflGraph;
}

CFLGraph * CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)
CFLGraph *CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)
{
buildlabelToKindMap(grammar);
cflGraph = new CFLGraph(grammar->getStartKind());
std::string lineString;
std::ifstream inputFile(fileName);
std::cout << "Building CFL Graph from dot file: " << fileName << "..\n";
std::regex reg("Node(\\w+)\\s*->\\s*Node(\\w+)\\s*\\[.*label=(.*)\\]");
std::cout << std::boolalpha;
u32_t lineNum = 0 ;

u32_t lineNum = 0;
current = labelToKindMap.size();

while (getline(inputFile, lineString))
{
lineNum += 1;
std::smatch matches;
if (std::regex_search(lineString, matches, reg))

// Find "Node" prefixes and "->"
size_t srcStart = lineString.find("Node");
if (srcStart == std::string::npos) continue;

size_t srcEnd = lineString.find(" ", srcStart);
if (srcEnd == std::string::npos) continue;

size_t arrowPos = lineString.find("->", srcEnd);
if (arrowPos == std::string::npos) continue;

size_t dstStart = lineString.find("Node", arrowPos);
if (dstStart == std::string::npos) continue;

size_t dstEnd = lineString.find(" ", dstStart);
if (dstEnd == std::string::npos) continue;

size_t labelStart = lineString.find("label=", dstEnd);
if (labelStart == std::string::npos) continue;

labelStart += 6; // Move past "label=" to the start of the label
size_t labelEnd = lineString.find_first_of("]", labelStart);
if (labelEnd == std::string::npos) continue;

// Extract the source ID, destination ID, and label
std::string srcIDStr = lineString.substr(srcStart + 4, srcEnd - (srcStart + 4));
std::string dstIDStr = lineString.substr(dstStart + 4, dstEnd - (dstStart + 4));
std::string label = lineString.substr(labelStart, labelEnd - labelStart);

// Convert source and destination IDs from hexadecimal
u32_t srcID = std::stoul(srcIDStr, nullptr, 16);
u32_t dstID = std::stoul(dstIDStr, nullptr, 16);

CFLNode *src = addGNode(srcID);
CFLNode *dst = addGNode(dstID);

if (labelToKindMap.find(label) != labelToKindMap.end())
{
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
}
else
{
u32_t srcID = std::stoul(matches.str(1), nullptr, 16);
u32_t dstID = std::stoul(matches.str(2), nullptr, 16);
std::string label = matches.str(3);
CFLNode *src = addGNode(srcID);
CFLNode *dst = addGNode(dstID);
if (labelToKindMap.find(label) != labelToKindMap.end())
if (Options::FlexSymMap() == true)
{
labelToKindMap.insert({label, current++});
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
}
else
{
if(Options::FlexSymMap() == true)
{
labelToKindMap.insert({label, current++});
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);
}
else
{
std::string msg = "In line " + std::to_string(lineNum) +
" sym can not find in grammar, please correct the input dot or set --flexsymmap.";
SVFUtil::errMsg(msg);
std::cout << msg;
abort();
}
std::string msg = "In line " + std::to_string(lineNum) +
" sym cannot be found in grammar. Please correct the input dot or set --flexsymmap.";
SVFUtil::errMsg(msg);
std::cout << msg;
abort();
}
}
}

inputFile.close();
return cflGraph;
}
Expand All @@ -247,7 +277,6 @@ CFLGraph* CFLGraphBuilder::buildFromJson(std::string fileName, GrammarBase *gram
return cflGraph;
}


CFLGraph* AliasCFLGraphBuilder::buildBigraph(ConstraintGraph *graph, Kind startKind, GrammarBase *grammar)
{
cflGraph = new CFLGraph(startKind);
Expand Down Expand Up @@ -543,4 +572,4 @@ CFLGraph* VFCFLGraphBuilder::buildBiPEGgraph(ConstraintGraph *graph, Kind startK
}


} // end of SVF namespace
} // end of SVF namespace
Loading

0 comments on commit 7ae53a5

Please sign in to comment.